Logo
Developing with ZBOSS for Zigbee
zboss_api_core.h File Reference
#include "zb_config.h"
#include "zb_vendor.h"
#include "zb_types.h"
#include "zb_errors.h"
#include "zb_osif.h"
#include "zb_debug.h"
#include "zb_trace.h"
#include "zb_pooled_list.h"

Macros

#define ZB_MAX_TIME_VAL   ZB_UINT32_MAX
 
#define ZB_MIN_TIME_VAL   ZB_UINT32_MIN
 
#define ZB_HALF_MAX_TIME_VAL   (ZB_MAX_TIME_VAL / 2U)
 
#define ZB_TIMER_GET()   (zb_timer_get())
 
#define ZB_TIME_SUBTRACT(a, b)   ((zb_time_t)((a) - (b)) < ZB_HALF_MAX_TIME_VAL ? (zb_time_t)((a) - (b)) : (zb_time_t)((b) - (a)))
 
#define ZB_TIME_ADD(a, b)   (zb_time_t)((a) + (b))
 
#define ZB_TIME_GE(a, b)   ((zb_time_t)((a) - (b)) < ZB_HALF_MAX_TIME_VAL)
 
#define ZB_TIME_ONE_SECOND   ZB_MILLISECONDS_TO_BEACON_INTERVAL(1000U)
 
#define ZB_MILLISECONDS_TO_BEACON_INTERVAL_CEIL(ms)   (((zb_time_t)(ms) * 1000U + (ZB_BEACON_INTERVAL_USEC - 1U)) / ZB_BEACON_INTERVAL_USEC)
 
#define ZB_MICROSECONDS_TO_BEACON_INTERVAL_CEIL(us)   (((zb_time_t)(us) + (ZB_BEACON_INTERVAL_USEC - 1U)) / ZB_BEACON_INTERVAL_USEC)
 
#define ZB_MILLISECONDS_TO_BEACON_INTERVAL_FLOOR(ms)   ((zb_time_t)(ms) * 1000U / ZB_BEACON_INTERVAL_USEC)
 
#define ZB_MICROSECONDS_TO_BEACON_INTERVAL_FLOOR(us)   ((zb_time_t)(us) / ZB_BEACON_INTERVAL_USEC)
 
#define ZB_MILLISECONDS_TO_BEACON_INTERVAL(ms)   ZB_MILLISECONDS_TO_BEACON_INTERVAL_CEIL(ms)
 
#define ZB_BEACON_INTERVAL_USEC   (ZB_SYMBOL_DURATION_USEC * ZB_ABASE_SUPERFRAME_DURATION)
 
#define ZB_TIME_BEACON_INTERVAL_TO_MSEC(t)   ((ZB_BEACON_INTERVAL_USEC * (zb_time_t)(t)) / 1000U)
 
#define ZB_TIME_BEACON_INTERVAL_TO_USEC(t)   ((zb_uint64_t)ZB_BEACON_INTERVAL_USEC * (t))
 
#define ZB_TIME_QUARTERECONDS(n)   (ZB_TIME_BEACON_INTERVAL_TO_MSEC((n)) / 250U)
 
#define ZB_MSEC_TO_QUARTERECONDS(n)   ((n) / 250U)
 
#define ZB_QUARTERECONDS_TO_MSEC(n)   250UL*(n)
 
#define ZB_QUARTERECONDS_TO_BEACON_INTERVAL(qsec)   ZB_MILLISECONDS_TO_BEACON_INTERVAL(250U * (qsec))
 
#define ZB_SECONDS_TO_MILLISECONDS(_s)   (1000ul*(_s))
 
#define ZB_SECONDS_TO_BEACON_INTERVAL(_s)   ZB_MILLISECONDS_TO_BEACON_INTERVAL(1000UL * (_s))
 
#define ZB_MILLISECONDS_TO_USEC(ms)   ((ms) * (1000u))
 
#define ZB_USECS_TO_MILLISECONDS(usec)   ((usec) / (1000u))
 
#define ZB_SCHEDULE_APP_CALLBACK(func, param)   zb_schedule_app_callback(func, param)
 
#define ZB_SCHEDULE_APP_CALLBACK2(func, param, user_param)   zb_schedule_app_callback2(func, param, user_param)
 
#define ZB_SCHEDULE_APP_ALARM(func, param, timeout_bi)   zb_schedule_app_alarm(func, param, timeout_bi)
 
#define ZB_ALARM_ANY_PARAM   (zb_uint8_t)(-1)
 
#define ZB_ALARM_ALL_CB   (zb_uint8_t)(-2)
 
#define ZB_SCHEDULE_APP_ALARM_CANCEL(func, param)   zb_schedule_alarm_cancel((func), (param), NULL)
 
#define ZB_SCHEDULE_GET_ALARM_TIME(func, param, timeout_bi)   zb_schedule_get_alarm_time(func, param, timeout_bi)
 
#define ZB_SCHEDULER_IS_STOP()   zb_scheduler_is_stop()
 
#define ZB_SCHEDULER_IS_GOING_TO_STOP()   zb_scheduler_is_going_to_stop()
 
#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()
 
#define ZB_ABS(a)   ((a) < 0 ? -(a) : (a))
 
#define ZB_BITS1(_b)   (1UL << (_b))
 
#define ZB_BITS2(_b1, _b2)   ((1UL << (_b1)) | (1UL << (_b2)))
 
#define ZB_BITS3(_b1, _b2, _b3)   ((1UL << (_b1)) | (1UL << (_b2)) | (1UL << (_b3)))
 
#define ZB_BITS4(_b1, _b2, _b3, _b4)   ((1UL << (_b1)) | (1UL << (_b2)) | (1UL << (_b3)) | (1UL << (_b4)))
 
#define ZB_BITS5(_b1, _b2, _b3, _b4, _b5)
 
#define ZB_SET_BIT_IN_BIT_VECTOR(vector, nbit)   ( (vector)[ (nbit) / 8U ] |= ( 1U << ( (nbit) % 8U )) )
 
#define ZB_CLR_BIT_IN_BIT_VECTOR(vector, nbit)   ( (vector)[ (nbit) / 8U ] &= ~( 1U << ( (nbit) % 8U )) )
 
#define ZB_CHECK_BIT_IN_BIT_VECTOR(vector, nbit)   (ZB_U2B( (vector)[ (nbit) / 8U ] & ( 1U << ( (nbit) % 8U )) ))
 
#define ZB_SIZE_OF_BIT_VECTOR(bit_count)   (((bit_count) + 7U) / 8U)
 
#define ZB_ASSIGN_BIT_IN_BIT_VECTOR(vector, nbit, value)
 Assigns a bit in a bit vector. More...
 
#define ZB_BIT_IS_SET(val, bitmask)   (((val) & (bitmask)) != 0U)
 
#define ZB_PACK_2_U8_IN_U16(param1, param2)   ( (zb_uint16_t)(((zb_uint16_t)(param2) << 8U) | ((zb_uint16_t)(param1))) )
 
#define ZB_UNPACK_2_U8_FROM_U16(u16_value, param1_ptr, param2_ptr)   ((*(param1_ptr) = (zb_uint8_t)(((zb_uint16_t)(u16_value)) & 0xffU)), ((*(param2_ptr) = (zb_uint8_t)(((zb_uint16_t)(u16_value)) >> 8U))))
 

Typedefs

typedef zb_uint8_t zb_cb_param_t
 
typedef void(* zb_callback_t) (zb_uint8_t param)
 
typedef void(* zb_callback2_t) (zb_uint8_t param, zb_uint16_t cb_param)
 
typedef zb_uint32_t zb_time_t
 

Functions

zb_bool_t zb_scheduler_is_going_to_stop (void)
 
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...
 

Macro Definition Documentation

§ ZB_ABS

#define ZB_ABS (   a)    ((a) < 0 ? -(a) : (a))

Return absolute value

§ ZB_ASSIGN_BIT_IN_BIT_VECTOR

#define ZB_ASSIGN_BIT_IN_BIT_VECTOR (   vector,
  nbit,
  value 
)
Value:
(((zb_uint8_t*)vector)[ (nbit) / 8U ] = \
(((zb_uint8_t*)vector)[ (nbit) / 8U ] & ~(1U << (nbit % 8U))) | (value << (nbit % 8U)))
unsigned char zb_uint8_t
Project-local 1-byte unsigned int type.
Definition: zb_types.h:147

Assigns a bit in a bit vector.

Parameters
xPointer to a bit vector.
nbitIndex of the bit to assign
valueNew value of the bit

§ ZB_BIT_IS_SET

#define ZB_BIT_IS_SET (   val,
  bitmask 
)    (((val) & (bitmask)) != 0U)

Checks if the bits specified by 'bitmask' are set in the 'val'. Bit-mask may contain one or several bits set.

Returns
ZB_TRUE if the 'bitmask' is set in 'val'. ZB_FALSE otherwise.

§ ZB_BITS1

#define ZB_BITS1 (   _b)    (1UL << (_b))

Set of ZB_BITSx() macros return value with bits set in provided positions. ZB_BITS1(0) = 1 ZB_BITS2(2,3) = 12 ZB_BITS3(0,1,2) = 7

§ ZB_BITS2

#define ZB_BITS2 (   _b1,
  _b2 
)    ((1UL << (_b1)) | (1UL << (_b2)))

§ ZB_BITS3

#define ZB_BITS3 (   _b1,
  _b2,
  _b3 
)    ((1UL << (_b1)) | (1UL << (_b2)) | (1UL << (_b3)))

§ ZB_BITS4

#define ZB_BITS4 (   _b1,
  _b2,
  _b3,
  _b4 
)    ((1UL << (_b1)) | (1UL << (_b2)) | (1UL << (_b3)) | (1UL << (_b4)))

§ ZB_BITS5

#define ZB_BITS5 (   _b1,
  _b2,
  _b3,
  _b4,
  _b5 
)
Value:
((1UL << (_b1)) | (1UL << (_b2)) | (1UL << (_b3)) | \
(1UL << (_b4)) | (1UL << (_b5)))

§ ZB_CHECK_BIT_IN_BIT_VECTOR

#define ZB_CHECK_BIT_IN_BIT_VECTOR (   vector,
  nbit 
)    (ZB_U2B( (vector)[ (nbit) / 8U ] & ( 1U << ( (nbit) % 8U )) ))

§ ZB_CLR_BIT_IN_BIT_VECTOR

#define ZB_CLR_BIT_IN_BIT_VECTOR (   vector,
  nbit 
)    ( (vector)[ (nbit) / 8U ] &= ~( 1U << ( (nbit) % 8U )) )

§ ZB_PACK_2_U8_IN_U16

#define ZB_PACK_2_U8_IN_U16 (   param1,
  param2 
)    ( (zb_uint16_t)(((zb_uint16_t)(param2) << 8U) | ((zb_uint16_t)(param1))) )

Packs two zb_uint8_t values into single zb_uint16_t value

Returns
packed zb_uint16_t value.

§ ZB_SET_BIT_IN_BIT_VECTOR

#define ZB_SET_BIT_IN_BIT_VECTOR (   vector,
  nbit 
)    ( (vector)[ (nbit) / 8U ] |= ( 1U << ( (nbit) % 8U )) )

§ ZB_SIZE_OF_BIT_VECTOR

#define ZB_SIZE_OF_BIT_VECTOR (   bit_count)    (((bit_count) + 7U) / 8U)

§ ZB_UNPACK_2_U8_FROM_U16

#define ZB_UNPACK_2_U8_FROM_U16 (   u16_value,
  param1_ptr,
  param2_ptr 
)    ((*(param1_ptr) = (zb_uint8_t)(((zb_uint16_t)(u16_value)) & 0xffU)), ((*(param2_ptr) = (zb_uint8_t)(((zb_uint16_t)(u16_value)) >> 8U))))

Unpacks two zb_uint8_t values from single zb_uint16_t value

Typedef Documentation

§ zb_cb_param_t

Callback handler