1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

kinetis: Update RNGA driver configuration to automatically detect the module

This commit is contained in:
Joakim Nohlgård 2017-11-09 08:01:43 +01:00
parent 19d407a3e9
commit 925a908d95
6 changed files with 18 additions and 38 deletions

View File

@ -269,15 +269,6 @@ static const spi_conf_t spi_config[] = {
#define RTT_MAX_VALUE (0xffffffff)
/** @} */
/**
* @name Random Number Generator configuration
* @{
*/
#define KINETIS_RNGA RNG
#define HWRNG_CLKEN() (SIM->SCGC6 |= (1 << 9))
#define HWRNG_CLKDIS() (SIM->SCGC6 &= ~(1 << 9))
/** @} */
#ifdef __cplusplus
}
#endif

View File

@ -264,15 +264,6 @@ static const spi_conf_t spi_config[] = {
#define RTT_MAX_VALUE (0xffffffff)
/** @} */
/**
* @name Random Number Generator configuration
* @{
*/
#define KINETIS_RNGA RNG
#define HWRNG_CLKEN() (SIM->SCGC6 |= (1 << 9))
#define HWRNG_CLKDIS() (SIM->SCGC6 &= ~(1 << 9))
/** @} */
#ifdef __cplusplus
}
#endif

View File

@ -392,15 +392,6 @@ static const spi_conf_t spi_config[] = {
/** @} */
/**
* @name Random Number Generator configuration
* @{
*/
#define HWRNG_CLKEN() (BITBAND_REG32(SIM->SCGC3, SIM_SCGC3_RNGA_SHIFT) = 1)
#define HWRNG_CLKDIS() (BITBAND_REG32(SIM->SCGC3, SIM_SCGC3_RNGA_SHIFT) = 0)
/** @} */
#ifdef __cplusplus
}
#endif

View File

@ -295,16 +295,6 @@ static const spi_conf_t spi_config[] = {
#define RTT_MAX_VALUE (0xffffffff)
/** @} */
/**
* @name Random Number Generator configuration
* @{
*/
#define KINETIS_RNGA RNG
#define HWRNG_CLKEN() (SIM->SCGC6 |= (1 << 9))
#define HWRNG_CLKDIS() (SIM->SCGC6 &= ~(1 << 9))
/** @} */
#ifdef __cplusplus
}
#endif

View File

@ -112,6 +112,22 @@ extern "C"
#endif
/** @} */
/**
* @name Hardware random number generator module configuration
* @{
*/
#if !defined(HWRNG_CLKEN) && defined(RNG) && !defined(RNG_CMD_ST_MASK)
#define KINETIS_RNGA RNG
#if defined(SIM_SCGC3_RNGA_SHIFT)
#define HWRNG_CLKEN() (bit_set32(&SIM->SCGC3, SIM_SCGC3_RNGA_SHIFT))
#define HWRNG_CLKDIS() (bit_clear32(&SIM->SCGC3, SIM_SCGC3_RNGA_SHIFT))
#elif defined(SIM_SCGC6_RNGA_SHIFT)
#define HWRNG_CLKEN() (bit_set32(&SIM->SCGC6, SIM_SCGC6_RNGA_SHIFT))
#define HWRNG_CLKDIS() (bit_clear32(&SIM->SCGC6, SIM_SCGC6_RNGA_SHIFT))
#endif
#endif /* KINETIS_RNGA */
/** @} */
#ifdef __cplusplus
}
#endif

View File

@ -25,6 +25,7 @@
#include "cpu.h"
#include "periph/hwrng.h"
#include "periph_conf.h"
#include "bit.h"
#ifdef KINETIS_RNGA
@ -60,7 +61,7 @@ void hwrng_read(void *buf, unsigned int num)
}
}
/* power of the device */
/* power off the device */
KINETIS_RNGA->CR = 0;
HWRNG_CLKDIS();
}