1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 23:11:19 +01:00

drivers/periph: renamed random to hwrng + opts

This commit is contained in:
Hauke Petersen 2016-02-05 16:35:25 +01:00
parent d1a57d040a
commit b59f94593e
2 changed files with 67 additions and 81 deletions

View File

@ -0,0 +1,67 @@
/*
* Copyright (C) 2014-2016 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup drivers_periph_hwrng HWRNG Abstraction
* @ingroup drivers_periph
* @brief Peripheral hardware random number generator interface
*
* The HWRNG interface abstracts means provided by MCU peripherals to create
* random number. On most platforms, these peripherals are called something like
* 'hardware random number generator' or 'pseudo random number generator'. The
* quality of the created random data does differ quite a bit between different
* MCUs, so please refer to your MCUs reference manual for information on this!
*
* @note Refer to your platforms MCU reference manual for information on the
* quality of the used (pseudo) random number generator!
*
* @{
* @file
* @brief Hardware random number generator driver interface
*
* @author Christian Mehlis <mehlis@inf.fu-berlin.de>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
#ifndef PERIPH_HWRNG_H
#define PERIPH_HWRNG_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize the hardware random number generator
*
* On some platforms, the random number generator needs some global
* initialization before it can be used. This should happen in this function
* if it would impose too much overhead to do this everytime the hwrng_read
* function is called. The device should however be put into power of mode
* after initialization and will be powered on and of when hwrng_read is called.
*/
void hwrng_init(void);
/**
* @brief Read N bytes of random data from the hardware device
*
* The read function should power on the HWRNG MCU peripheral, read the given
* number of random bytes and than put the peripheral back to sleep.
*
* @param[in] buf destination buffer to write the bytes to
* @param[in] num number of bytes to get from device
*/
void hwrng_read(uint8_t *buf, unsigned int num);
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_HWRNG_H */
/** @} */

View File

@ -1,81 +0,0 @@
/*
* Copyright (C) 2014 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser General
* Public License v2.1. See the file LICENSE in the top level directory for more
* details.
*/
/**
* @defgroup drivers_periph_random Random
* @ingroup drivers_periph
* @brief Low-level (pseudo) random number generator driver
*
* The quality of the random data read from this interface is highly
* dependent on hardware dependent implementation. Most platforms utilize a
* hardware (Pseudo) Random Number Generator. The quality of the generated
* random data can be however very different.
*
* @note REFER TO YOUR PLATFORMS IMPLEMENTATION ABOUT INFORMATION ABOUT THE
* QUALITY OF RANDOMNES!
*
* @{
* @file
* @brief Low-level random peripheral driver interface definitions
*
* @author Christian Mehlis <mehlis@inf.fu-berlin.de>
*/
#ifndef RANDOM_H
#define RANDOM_H
#include "periph_conf.h"
#ifdef __cplusplus
extern "C" {
#endif
/* only include this file if a random number generator is defined */
#if RANDOM_NUMOF
/**
* @brief Initializes the source of randomness
*
* In case of a hardware random number generator, this peripheral
* is initialized and powered on. If such a device is not present,
* it depends on the implementation how a source for randomness
* is created and initialized.
*/
void random_init(void);
/**
* @brief Reads num or less bytes of randomness from the source, will
* block until random data is available
*
* @param[in] buf destination buffer to write the bytes to
* @param[in] num number of bytes to get from device,
* only values >0 are valid
*
* @return the number of bytes written to buf
* @return 0 on error
*/
int random_read(char *buf, unsigned int num);
/**
* @brief Power on the random number generator
*/
void random_poweron(void);
/**
* @brief Power off the random number generator
*/
void random_poweroff(void);
#endif /* RANDOM_NUMOF */
#ifdef __cplusplus
}
#endif
#endif /* RANDOM_H */
/** @} */