mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
ba3088c4bd
into separate patch files
50 lines
1.7 KiB
Diff
50 lines
1.7 KiB
Diff
*** stock_iot-lab_M3/openwsn/cross-layers/openrandom.c Thu Apr 24 11:01:37 2014
|
|
--- riot-openwsn-wip/openwsn/cross-layers/openrandom.c Thu Apr 24 16:55:54 2014
|
|
***************
|
|
*** 4,27 ****
|
|
|
|
//=========================== variables =======================================
|
|
|
|
- typedef struct {
|
|
- uint16_t shift_reg; // Galois shift register used to obtain a pseudo-random number
|
|
- } random_vars_t;
|
|
-
|
|
random_vars_t random_vars;
|
|
|
|
//=========================== prototypes ======================================
|
|
|
|
//=========================== public ==========================================
|
|
|
|
! void openrandom_init() {
|
|
// seed the random number generator with the last 2 bytes of the MAC address
|
|
random_vars.shift_reg = 0;
|
|
random_vars.shift_reg += idmanager_getMyID(ADDR_16B)->addr_16b[0]*256;
|
|
random_vars.shift_reg += idmanager_getMyID(ADDR_16B)->addr_16b[1];
|
|
}
|
|
|
|
! uint16_t openrandom_get16b() {
|
|
uint8_t i;
|
|
uint16_t random_value;
|
|
random_value = 0;
|
|
--- 4,23 ----
|
|
|
|
//=========================== variables =======================================
|
|
|
|
random_vars_t random_vars;
|
|
|
|
//=========================== prototypes ======================================
|
|
|
|
//=========================== public ==========================================
|
|
|
|
! void openrandom_init(void) {
|
|
// seed the random number generator with the last 2 bytes of the MAC address
|
|
random_vars.shift_reg = 0;
|
|
random_vars.shift_reg += idmanager_getMyID(ADDR_16B)->addr_16b[0]*256;
|
|
random_vars.shift_reg += idmanager_getMyID(ADDR_16B)->addr_16b[1];
|
|
}
|
|
|
|
! uint16_t openrandom_get16b(void) {
|
|
uint8_t i;
|
|
uint16_t random_value;
|
|
random_value = 0;
|