diff options
Diffstat (limited to 'cc3200/util/random.c')
-rw-r--r-- | cc3200/util/random.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/cc3200/util/random.c b/cc3200/util/random.c index e9a6abcea2..470d95d3a8 100644 --- a/cc3200/util/random.c +++ b/cc3200/util/random.c @@ -43,11 +43,11 @@ /****************************************************************************** * LOCAL TYPES ******************************************************************************/ -typedef union Id_t { +typedef union _rng_id_t { uint32_t id32; uint16_t id16[3]; uint8_t id8[6]; -} Id_t; +} rng_id_t; /****************************************************************************** * LOCAL VARIABLES @@ -64,29 +64,19 @@ static uint32_t lfsr (uint32_t input); ******************************************************************************/ static uint32_t lfsr (uint32_t input) { assert( input != 0 ); - - /*lint -save -e501*/ return (input >> 1) ^ (-(input & 0x01) & 0x00E10000); - /*lint -restore*/ } -#if MICROPY_HW_ENABLE_RNG -/// \moduleref rng - -/// \function rng() -/// Return a 24-bit hardware generated random number. STATIC mp_obj_t pyb_rng_get(void) { return mp_obj_new_int(rng_get()); } - MP_DEFINE_CONST_FUN_OBJ_0(pyb_rng_get_obj, pyb_rng_get); -#endif /****************************************************************************** * PUBLIC FUNCTIONS ******************************************************************************/ void rng_init0 (void) { - Id_t juggler; + rng_id_t juggler; uint32_t seconds; uint16_t mseconds; @@ -95,7 +85,7 @@ void rng_init0 (void) { wlan_get_mac (juggler.id8); - // Flatten the 48-bit board identification to 24 bits + // flatten the 48-bit board identification to 24 bits juggler.id16[0] ^= juggler.id16[2]; juggler.id8[0] ^= juggler.id8[3]; @@ -104,7 +94,8 @@ void rng_init0 (void) { s_seed = juggler.id32 & 0x00FFFFFF; s_seed += (seconds & 0x000FFFFF) + mseconds; - // The seed must not be zero + + // the seed must not be zero if (s_seed == 0) { s_seed = 1; } |