Contiki 2.6

random.c File Reference

Random number generator routines exploiting the cc2430 hardware capabilities. More...

#include "cc2430_sfr.h"
#include "dev/cc2430_rf.h"

Go to the source code of this file.

Functions

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

Detailed Description

Random number generator routines exploiting the cc2430 hardware capabilities.

This file overrides core/lib/random.c.

Author:
George Oikonomou - <oikonomou@users.sourceforge.net>

Definition in file random.c.


Function Documentation

void random_init ( unsigned short  seed)

Seed the cc2430 random number generator.

Seed the cc253x random number generator.

Parameters:
seedSeed value for the RNG.

If the SEED argument is 0, seed the RNG with IF_ADC as discussed in the cc2430 datasheet (rev. 2.1), section 13.11.2.2, page 134. Seeding with this method should not be done during normal radio operation. Thus, use this function before initialising the network.

If the SEED is provided, seed with this value instead. This will result in the same sequence of random numbers each time the node reboots. So, don't use it unless you have a reason (e.g. tests)

Definition at line 73 of file random.c.

References cc2430_rf_command().

unsigned short random_rand ( void  )

Generates a new random number using the cc2430 RNG.

Generates a new random number using the cc253x RNG.

Returns:
The random number.

Definition at line 50 of file random.c.