Contiki 3.x
Files | Functions
cc2538 Random Number Generator

Driver for the cc2538 Hardware Random Number Generator. More...

Files

file  random.c
 Random number generator routines exploiting the cc2538 hardware capabilities.
 

Functions

unsigned short random_rand (void)
 Generates a new random number using the cc2538 RNG. More...
 
void random_init (unsigned short seed)
 Seed the cc2538 random number generator. More...
 

Detailed Description

Driver for the cc2538 Hardware Random Number Generator.

Function Documentation

void random_init ( unsigned short  seed)

Seed the cc2538 random number generator.

Seed the cc2430 random number generator.

Parameters
seedIgnored. It's here because the function prototype is in core.
        We form a seed for the RNG by sampling IF_ADC as
        discussed in the user guide.
        Seeding with this method should not be done during
        normal radio operation. Thus, use this function before
        initialising the network.
Note
Must not be called after the RF driver has been initialised and is in normal operation. If it is absolutely necessary to do so, the radio will need re-initialised.

Definition at line 84 of file random.c.

References CC2538_RF_CSP_ISRFOFF, CC2538_RF_CSP_ISRXON, RFCORE_XREG_FRMCTRL0, RFCORE_XREG_RFRND, RFCORE_XREG_RFRND_IRND, RFCORE_XREG_RSSISTAT, RFCORE_XREG_RSSISTAT_RSSI_VALID, SOC_ADC_ADCCON1, SOC_ADC_ADCCON1_RCTRL0, SOC_ADC_ADCCON1_RCTRL1, SOC_ADC_RNDL, and SYS_CTRL_RCGCRFC.

unsigned short random_rand ( void  )

Generates a new random number using the cc2538 RNG.

Generate the next state and return the upper part of it.

Returns
The random number.

Definition at line 58 of file random.c.

References SOC_ADC_ADCCON1, SOC_ADC_ADCCON1_RCTRL0, SOC_ADC_RNDH, and SOC_ADC_RNDL.