Developing with ZBOSS for Zigbee
Random numbers generator

Macros

#define ZB_RAND_MAX   ((zb_uint32_t)~0U)
 
#define ZB_RANDOM_VALUE(max_value)   zb_random_val(max_value)
 
#define ZB_RANDOM_U8()   zb_random_u8()
 
#define ZB_RANDOM_U16()   zb_random_u16()
 

Functions

zb_uint32_t zb_random (void)
 
zb_uint32_t zb_random_val (zb_uint32_t max_value)
 
zb_uint8_t zb_random_u8 (void)
 
zb_uint16_t zb_random_u16 (void)
 
void zb_bzero_volatile (volatile void *s, zb_uint_t size)
 
void zb_generate_prbs9 (zb_uint8_t *dest, zb_uint16_t cnt, zb_uint16_t seed)
 Fill in memory with PRBS9 pattern using linear-feedback shift registers. More...
 

Detailed Description

Macro Definition Documentation

◆ ZB_RAND_MAX

#define ZB_RAND_MAX   ((zb_uint32_t)~0U)

Maximal possible value for randomly generated (32-bit) value

◆ ZB_RANDOM_U16

#define ZB_RANDOM_U16 ( )    zb_random_u16()

Equivalent of zb_random_u16(). The macro is left for compatibility reasons.

◆ ZB_RANDOM_U8

#define ZB_RANDOM_U8 ( )    zb_random_u8()

Equivalent of zb_random_u8(). The macro is left for compatibility reasons.

◆ ZB_RANDOM_VALUE

#define ZB_RANDOM_VALUE (   max_value)    zb_random_val(max_value)

Equivalent of zb_random_val(). The macro is left for compatibility reasons.

Function Documentation

◆ zb_bzero_volatile()

void zb_bzero_volatile ( volatile void *  s,
zb_uint_t  size 
)

Analogue of bzero() for volatile data.

A custom version should be implemented because there is no standard library function for that purpose. Also, this function is not platform-dependent in contrast to ZB_BZERO() macro and therefore can't be overridden by specific ZBOSS platform.

The function sets individually every byte of provided memory region to zero.

◆ zb_generate_prbs9()

void zb_generate_prbs9 ( zb_uint8_t dest,
zb_uint16_t  cnt,
zb_uint16_t  seed 
)

Fill in memory with PRBS9 pattern using linear-feedback shift registers.

Parameters
dest- Pointer to the block of memory to fill.
cnt- Number of bytes to be set.
seed- Random seed

◆ zb_random()

zb_uint32_t zb_random ( void  )

Generate random 32-bit value using zb_random_val() with ZB_UINT32_MAX

Returns
random value between 0 to 2^32-1

◆ zb_random_u16()

zb_uint16_t zb_random_u16 ( void  )

Generate random 16-bit value using zb_random_val() with ZB_UINT16_MAX

Returns
random value between 0 to 0xffff

◆ zb_random_u8()

zb_uint8_t zb_random_u8 ( void  )

Generate random 8-bit value using zb_random_val() with ZB_UINT8_MAX

Returns
random value between 0 to 0xff

◆ zb_random_val()

zb_uint32_t zb_random_val ( zb_uint32_t  max_value)

Generate random value between 0 to max_value, inclusively.

Internal software algorithm using LFSRs can be overridden by define ZB_RANDOM_HARDWARE

Returns
random value between 0 and 'max_value' (32 bits).