Wixel SDK
Functions
random.h File Reference
#include <cc2511_types.h>

Go to the source code of this file.

Functions

void randomSeedFromAdc (void)
 
void randomSeedFromSerialNumber (void)
 
uint8 randomNumber (void)
 
void randomSeed (uint8 seed_msb, uint8 seed_lsb)
 

Detailed Description

random.lib is a library that uses the Random Number Generator (otherwise known as the Linear Feedback Shift Register (LFSR) or the CRC module) of the CC251x to generate a pseudo random sequence of numbers.

WARNING: The numbers generated are highly predictable if you know what the previous number was.

Definition in file random.h.

Function Documentation

uint8 randomNumber ( void  )
Returns
a random number between 0 and 255. Before calling this function, you should call randomSeedFromAdc or randomSeedFromSerialNumber to initialize the random number generator.

Definition at line 9 of file random.c.

void randomSeedFromAdc ( void  )

Uses two noisy ADC readings (of the internal temperature sensor) to initialize the state of the random number generator. This function throws away all of the previous state of the random number generator. You will generally want to call this function once at the beginning of your program.

Side effects: This function changes ADCL, ADCH, ADCCON3, and ADCIF in order to use the extra conversion feature of the ADC. This may make it incompatible with other code that uses the ADC.

Definition at line 17 of file random_from_adc.c.

void randomSeedFromSerialNumber ( void  )

Uses the randomly-assigned 4-byte serial number of the Wixel to initialize the state of the random number generator. This function throws away all of the previous state of the random number generator. You will generally want to call this function once at the beginning of your program.

Definition at line 9 of file random_from_sernum.c.