Logo
Developing with ZBOSS for Zigbee
zb_types.h File Reference

Data Structures

union  zb_addr_u_t
 

Macros

#define ZB_STDC_90
 
#define ZB_32BIT_WORD
 
#define ZB_XDATA
 
#define ZB_CODE
 
#define ZB_IAR_CODE
 
#define ZB_REGISTER   register
 
#define ZB_VOID_ARGLIST   void
 
#define ZB_CONST   const
 
#define ZB_INLINE
 
#define ZB_BITFIELD_CAST(x)   (x)
 
#define ZB_CPP_STR2(x)   #x
 
#define ZB_CPP_STR(x)   ZB_CPP_STR2(x)
 
#define ZB_FALSE   0U
 
#define ZB_TRUE   1U
 
#define ZB_FALSE_U   ZB_FALSE
 
#define ZB_TRUE_U   ZB_TRUE
 
#define ZB_B2U(b)   (((b) != ZB_FALSE) ? (1U) : (0U))
 
#define ZB_U2B(u)   (((u) != 0U) ? (ZB_TRUE) : (ZB_FALSE))
 
#define ZB_INT8_MIN   (-127 - 1)
 
#define ZB_INT8_MAX   127
 
#define ZB_UINT8_MIN   0U
 
#define ZB_UINT8_MAX   255U
 
#define ZB_INT16_MIN   (-32767 - 1)
 
#define ZB_INT16_MAX   32767
 
#define ZB_UINT16_MIN   0U
 
#define ZB_UINT16_MAX   65535U
 
#define ZB_INT32_MIN   (-2147483647L - 1)
 
#define ZB_INT32_MAX   2147483647L
 
#define ZB_UINT32_MIN   0UL
 
#define ZB_UINT32_MAX   4294967295UL
 
#define ZB_UINT_MIN   0UL
 
#define ZB_SHORT_MIN   ZB_INT32_MIN
 
#define ZB_SHORT_MAX   ZB_INT32_MAX
 
#define ZB_USHORT_MAX   ZB_UINT32_MAX
 
#define ZB_INT_MIN   ZB_INT32_MIN
 
#define ZB_INT_MAX   ZB_INT32_MAX
 
#define ZB_UINT_MAX   ZB_UINT32_MAX
 
#define ZB_INT_MASK   0x7fffffffU
 
#define ZB_PACKED_STRUCT
 
#define ZB_PACKED_PRE
 
#define ZB_WEAK_PRE
 
#define ZB_WEAK
 
#define ZB_ALIGNED_PRE
 
#define ZB_DEPRECATED
 
#define ZB_NORETURN
 
#define ZB_IS_64BIT_ADDR_UNKNOWN(addr)   (ZB_MEMCMP((addr), (void const*)g_unknown_ieee_addr, 8) == 0)
 
#define ZB_64BIT_ADDR_UNKNOWN(addr)   ZB_MEMSET((addr), -1, 8)
 
#define ZB_EXTPANID_IS_ZERO   ZB_IS_64BIT_ADDR_ZERO
 
#define ZB_EXTPANID_ZERO   ZB_64BIT_ADDR_ZERO
 
#define ZB_EXTPANID_COPY   ZB_64BIT_ADDR_COPY
 
#define ZB_EXTPANID_CMP   ZB_64BIT_ADDR_CMP
 
#define ZB_IEEE_ADDR_IS_ZERO   ZB_IS_64BIT_ADDR_ZERO
 
#define ZB_IEEE_ADDR_IS_UNKNOWN   ZB_IS_64BIT_ADDR_UNKNOWN
 
#define ZB_IEEE_ADDR_ZERO   ZB_64BIT_ADDR_ZERO
 
#define ZB_IEEE_ADDR_UNKNOWN   ZB_64BIT_ADDR_UNKNOWN
 
#define ZB_IEEE_ADDR_COPY   ZB_64BIT_ADDR_COPY
 
#define ZB_IEEE_ADDR_CMP   ZB_64BIT_ADDR_CMP
 
#define ZB_CCM_KEY_IS_ZERO(k)   (ZB_IS_64BIT_ADDR_ZERO((zb_uint8_t*)(k)) && ZB_IS_64BIT_ADDR_ZERO(((zb_uint8_t*)(k)) + 8U))
 
#define ZB_IEEE_ADDR_IS_VALID(addr)   !(ZB_IEEE_ADDR_IS_ZERO(addr)||ZB_IEEE_ADDR_IS_UNKNOWN(addr))
 
#define ZB_ADDR_CMP(addr_mode, addr1, addr2)
 
#define ZB_ADDR_U_CAST(addr)   ((const zb_addr_u *)(const void *)(&(addr)))
 
#define ZB_INT8_C(c)   c
 
#define ZB_UINT8_C(c)   c ## U
 
#define ZB_INT16_C(c)   c
 
#define ZB_UINT16_C(c)   c ## U
 
#define ZB_INT32_C(c)   c ## L
 
#define ZB_UINT32_C(c)   c ## UL
 
#define ZB_OFFSETOF(t, f)   ((zb_size_t)(&((t *)NULL)->f))
 
#define ZB_OFFSETOF_VAR(s, f)   (zb_size_t)(((zb_int8_t *)(&(s)->f)) - ((zb_int8_t *)(s)))
 
#define ZB_SIZEOF_FIELD(type, field)   (sizeof(((type*)0)->field))
 
#define ZB_ARRAY_SIZE(arr)   (sizeof((arr))/sizeof((arr)[0]))
 
#define ZB_SIGNED_SHIFT(v, s)   ((zb_int_t)(v) >> (s))
 
#define ZB_ASSERT_IF_NOT_ALIGNED(data_type, length)   ZB_ASSERT_COMPILE_DECL(((sizeof(data_type) % (length)) == 0U))
 
#define ZB_ASSERT_IF_NOT_ALIGNED_TO_4(data_type)   ZB_ASSERT_IF_NOT_ALIGNED(data_type,4U)
 
#define ZB_ASSERT_VALUE_ALIGNED(const_expr, length)   ZB_ASSERT_COMPILE_DECL((((const_expr) % (length)) == 0U))
 
#define ZB_ASSERT_VALUE_ALIGNED_TO_4(const_expr)   ZB_ASSERT_VALUE_ALIGNED(const_expr, 4U)
 
#define ZB_GET_LOW_BYTE(val)   (zb_uint8_t)((val) & 0xFFU)
 
#define ZB_GET_HI_BYTE(val)   (zb_uint8_t)(((val) >> 8U) & 0xFFU)
 
#define ZB_SET_LOW_BYTE(res, val)   (res) = ((((zb_uint16_t)(res)) & 0xFF00U) | (((zb_uint16_t)(val)) & 0xFFU))
 
#define ZB_SET_HI_BYTE(res, val)   (res) = (((((zb_uint16_t)(val)) << 8U) & 0xFF00U) | (((zb_uint16_t)(res)) & 0xFFU))
 
#define ZB_PKT_16B_ZERO_BYTE   0U
 
#define ZB_PKT_16B_FIRST_BYTE   1U
 
#define ZB_ASSIGN_UINT16(ptr, vp)   *((zb_uint16_t*)(ptr)) = *(zb_uint16_t*)(vp)
 
#define ZB_ASSIGN_INT16(ptr, vp)   *((zb_int16_t*)(ptr)) = *(zb_int16_t*)(vp)
 
#define ZB_COPY_UINT24(ptr, vp)   *((zb_uint24_t*)(ptr)) = *(zb_uint24_t*)(vp)
 
#define ZB_COPY_INT24(ptr, vp)   *((zb_int24_t*)(ptr)) = *(zb_int24_t*)(vp)
 
#define ZB_ASSIGN_UINT32(ptr, vp)   *((zb_uint32_t*)(ptr)) = *(zb_uint32_t*)(vp)
 
#define ZB_ASSIGN_INT32(ptr, vp)   *((zb_int32_t*)(ptr)) = *(zb_int32_t*)(vp)
 
#define ZB_REVERSE16(ptr, val)
 
#define ZB_REVERSE64(ptr, val)
 
#define ZB_ARRAY_IDX_BY_ELEM(ar, el)   ((el) - (ar))
 
#define ZB_ARRAY_IDX_BY_STRUCT_ELEM(ar, el, el_size)   ( ((zb_size_t)(el) - (zb_size_t)(ar)) / (el_size) )
 
#define MIN_SIGNED_24BIT_VAL   (-8388607LL) /* (0xFF800001LL) */
 
#define MAX_SIGNED_24BIT_VAL   (0x7FFFFF)
 
#define MAX_UNSIGNED_24BIT_VAL   (0xFFFFFFU)
 
#define MIN_SIGNED_48BIT_VAL   (-140737488355327LL) /* (0xFFFF800000000001LL) */
 
#define MAX_SIGNED_48BIT_VAL   (0x7FFFFFFFFFFF)
 
#define MAX_UNSIGNED_48BIT_VAL   (0xFFFFFFFFFFFFU)
 
#define ZB_S64_FROM_S48(x)   ((x & 0xFFFFFFFFFFFF) | ((x & 0x800000000000) ? 0xFFFF000000000000 : 0x0))
 
#define ZB_S64_TO_S48(x)   ((zb_int64_t)(x & 0xFFFFFFFFFFFF))
 
#define ZB_S32_FROM_S24(x)   ((x & 0xFFFFFF) | ((x & 0x800000) ? 0xFF000000 : 0x0))
 
#define ZB_S32_TO_S24(x)   ((zb_int32_t)(x & 0xFFFFFF))
 

Typedefs

typedef zb_uint32_t zb_lbitfield_t
 
typedef long long zb_int64_t
 
typedef unsigned long long zb_uint64_t
 
typedef zb_ushort_t zb_uindex_t
 
typedef zb_uint8_t zb_64bit_data_t[8]
 
typedef union zb_addr_u_t zb_addr_u
 
Base types.
typedef char zb_char_t
 Project-local char type. More...
 
typedef unsigned char zb_uchar_t
 Project-local unsigned char type. More...
 
typedef unsigned char zb_uint8_t
 Project-local 1-byte unsigned int type. More...
 
typedef signed char zb_int8_t
 Project-local 1-byte signed int type. More...
 
typedef unsigned short zb_uint16_t
 Project-local 2-byte unsigned int type. More...
 
typedef signed short zb_int16_t
 Project-local 2-byte signed int type. More...
 
typedef unsigned int zb_uint32_t
 Project-local 4-byte unsigned int type. More...
 
typedef signed int zb_int32_t
 Project-local 4-byte signed int type. More...
 
typedef zb_uint32_t zb_bitfield_t
 Type to be used for unsigned bit fields inside structure. More...
 
typedef zb_int32_t zb_sbitfield_t
 Type to be used for signed bit fields inside structure. More...
 
typedef zb_uint32_t zb_size_t
 Project-local size_t type. More...
 
typedef int zb_short_t
 Short int (can fit into single CPU register). More...
 
typedef unsigned int zb_ushort_t
 Short unsigned int (can fit into single CPU register). More...
 
typedef int zb_int_t
 Int (at least 2 bytes). More...
 
typedef unsigned int zb_uint_t
 Unsigned int (at least 2 bytes). More...
 
typedef zb_int_t zb_long_t
 Long int (at least 4 bytes). More...
 
typedef zb_uint_t zb_ulong_t
 Unsigned long int (at least 4 bytes). More...
 
typedef zb_uint8_t zb_bool_t
 General purpose boolean type. For C90, 'zb_bool_t' is an alias of 'zb_uint8_t'. For C99, the availability of the 'stdbool.h' standard header is expected and 'zb_bool_t' is an alias of 'bool'. ZB_FALSE and ZB_TRUE are defined as macros for both standards. More...
 
typedef zb_bitfield_t zb_bitbool_t
 Type to be used for boolean bit fields inside structure. More...
 
typedef float zb_single_t
 Project-local single precision float type. More...
 

Enumerations

enum  zb_param_e { ZB_UNUSED_PARAM = 0 }
 General purpose parameter type. More...
 

Variables

const zb_64bit_addr_t g_zero_addr
 
const zb_64bit_addr_t g_unknown_ieee_addr
 

Endian change API.

Macros to change words endian and access words at potentially non-aligned pointers.

Zigbee uses little endian, see ZB spec, subclause 1.2.1.3.

#define ZB_8BIT_SIZE   1U
 
#define ZB_16BIT_SIZE   2U
 
#define ZB_24BIT_SIZE   3U
 
#define ZB_32BIT_SIZE   4U
 
#define ZB_48BIT_SIZE   6U
 
#define ZB_64BIT_SIZE   8U
 
#define ZB_HTOLE16(ptr, val)   zb_htole16((zb_uint8_t*)(ptr), (zb_uint8_t*)(val))
 
#define ZB_HTOLE16_ONPLACE(val)
 
#define ZB_HTOLE32_ONPLACE(val)   { zb_uint32_t _v = (val); ZB_HTOLE32(&(val), &_v); }
 
#define ZB_HTOLE32(ptr, val)   zb_htole32((zb_uint8_t*)(ptr), (zb_uint8_t*)(val))
 
#define ZB_HTOBE32(ptr, val)   ZB_MEMCPY(ptr, val, 4U)
 
#define ZB_HTOBE16(ptr, val)   (*(zb_uint16_t *)(ptr)) = *((zb_uint16_t *)(val))
 
#define ZB_HTOBE16_VAL(ptr, val)   ((zb_uint16_t *)(ptr))[0] = (val)
 
#define ZB_HTOLE64(ptr, val)   zb_memcpy8(ptr, val)
 
#define ZB_HTOLE32_VAL(ptr, val)
 
#define ZB_HTOLE16_VAL(ptr, val)
 
#define ZB_PUT_NEXT_HTOLE16(ptr, val)
 
#define ZB_PUT_NEXT_HTOLE32(ptr, val)   (ptr) = zb_put_next_htole32((ptr), (val))
 
#define ZB_LETOH64(dst, src)   zb_memcpy8((zb_uint8_t*)dst, (zb_uint8_t*)src)
 
#define ZB_PUT_NEXT_IEEE(dst, src)   (dst) = zb_put_next_ieee((dst), (src));
 
#define ZB_LETOH16   ZB_HTOLE16
 
#define ZB_LETOH24   ZB_HTOLE24
 
#define ZB_LETOH48   ZB_HTOLE48
 
#define ZB_LETOH32   ZB_HTOLE32
 
#define ZB_BETOH16   ZB_HTOBE16
 
#define ZB_BETOH32   ZB_HTOBE32
 
#define ZB_LETOH16_ONPLACE   ZB_HTOLE16_ONPLACE
 
#define ZB_LETOH32_ONPLACE   ZB_HTOLE32_ONPLACE
 
void zb_htole16 (zb_uint8_t *ptr, zb_uint8_t *val)
 
void zb_htole32 (zb_uint8_t *ptr, zb_uint8_t *val)
 
void * zb_put_next_htole16 (zb_uint8_t *dst, zb_uint16_t val)
 
void * zb_put_next_htole32 (zb_uint8_t *dst, zb_uint32_t val1)
 
void zb_get_next_letoh16 (zb_uint16_t *dst, const zb_uint8_t **src)
 
void * zb_put_next_2_htole16 (zb_uint8_t *dst, zb_uint16_t val1, zb_uint16_t val2)
 
void * zb_put_next_2_htole32 (zb_uint8_t *dst, zb_uint32_t val1, zb_uint32_t val2)
 
void * zb_put_next_ieee (zb_uint8_t *dst, zb_ieee_addr_t src)
 

Address types and API.

#define ZB_IS_64BIT_ADDR_ZERO(addr)   (ZB_MEMCMP((addr), (void const*)g_zero_addr, 8) == 0)
 Checks that long address is a zero one. More...
 
#define ZB_64BIT_ADDR_ZERO(addr)   ZB_MEMSET((addr), 0, 8)
 Clears long address. More...
 
#define ZB_64BIT_ADDR_COPY(dst, src)   ZB_MEMCPY(dst, src, sizeof(zb_64bit_addr_t))
 Copy long address. More...
 
#define ZB_64BIT_ADDR_CMP(one, two)   (ZB_MEMCMP((one), (two), 8) == 0)
 Check two long addresses are equal. More...
 
typedef zb_uint8_t zb_64bit_addr_t[8]
 8-bytes address (xpanid or long device address) base type. More...
 
typedef zb_64bit_addr_t zb_ieee_addr_t
 Long (64-bit) device address. More...
 
typedef zb_64bit_addr_t zb_ext_pan_id_t
 Long (64-bit) extended Pan ID. More...