Contiki 2.6

random.c File Reference

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

#include "cc253x.h"
#include "sfr-bits.h"
#include "dev/cc2530-rf.h"

Go to the source code of this file.

Functions

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

Detailed Description

Random number generator routines exploiting the cc2530 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 cc253x 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.

Definition at line 70 of file random.c.

Referenced by main().

unsigned short random_rand ( void  )

Generates a new random number using the cc253x RNG.

Returns:
The random number.
Examples:
example-broadcast.c, example-collect.c, and example-multihop.c.

Definition at line 51 of file random.c.

Referenced by ipolite_send(), polite_send(), uip_ds6_addr_add(), uip_ds6_compute_reachable_time(), and uip_ds6_init().