1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-27 07:21:18 +01:00

Merge pull request #4989 from mtausig/at86rf2xx_get_random

at86rf2xx: at86rf2xx_get_random to at86rf2xx_internal for supporting boards
This commit is contained in:
Martine Lenders 2016-09-02 11:02:19 +02:00 committed by GitHub
commit 9b63d5c25e
2 changed files with 29 additions and 0 deletions

View File

@ -211,6 +211,25 @@ void at86rf2xx_configure_phy(at86rf2xx_t *dev)
at86rf2xx_set_state(dev, state);
}
#if defined(MODULE_AT86RF233) || defined(MODULE_AT86RF231)
void at86rf2xx_get_random(at86rf2xx_t *dev, uint8_t *data, const size_t len)
{
for (size_t byteCount = 0; byteCount < len; ++byteCount) {
uint8_t rnd = 0;
for (uint8_t i = 0; i < 4; ++i) {
/* bit 5 and 6 of the AT86RF2XX_REG__PHY_RSSI register contain the RND_VALUE */
uint8_t regVal = at86rf2xx_reg_read(dev, AT86RF2XX_REG__PHY_RSSI)
& AT86RF2XX_PHY_RSSI_MASK__RND_VALUE;
/* shift the two random bits first to the right and then to the correct position of the return byte */
regVal = regVal >> 5;
regVal = regVal << 2 * i;
rnd |= regVal;
}
data[byteCount] = rnd;
}
}
#endif
void at86rf2xx_force_trx_off(const at86rf2xx_t *dev)
{
at86rf2xx_reg_write(dev,

View File

@ -163,6 +163,16 @@ void at86rf2xx_hardware_reset(at86rf2xx_t *dev);
*/
void at86rf2xx_configure_phy(at86rf2xx_t *dev);
#if defined MODULE_AT86RF233 || defined MODULE_AT86RF231
/**
* @brief Read random data from the RNG
*
* @param[in] dev device to configure
* @param[out] data buffer to copy the random data to
* @param[in] len number of random bytes to store in data
*/
void at86rf2xx_get_random(at86rf2xx_t *dev, uint8_t *data, const size_t len);
#endif
#ifdef __cplusplus
}