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_uint8_t)zb_random_val(0xFFU)
 
#define ZB_RANDOM_U16()   (zb_uint16_t)zb_random_val(0xFFFFU)
 

Functions

zb_uint32_t zb_random (void)
 
zb_uint32_t zb_random_val (zb_uint32_t max_value)
 
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_uint16_t)zb_random_val(0xFFFFU)

Generate random 16-bit value

Returns
random value between 0 to 0xffff

◆ ZB_RANDOM_U8

#define ZB_RANDOM_U8 ( )    (zb_uint8_t)zb_random_val(0xFFU)

Generate random 8-bit value

Returns
random value between 0 to 255

◆ 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 overriden 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

Returns
random value between 0 to 2^32-1

◆ zb_random_val()

zb_uint32_t zb_random_val ( zb_uint32_t  max_value)

Generate random value between 0 to max_value, inclusively.

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