From b24866225a6301d3a663f874725e83c012dc25d3 Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Wed, 26 Dec 2012 17:36:00 +0100 Subject: digital/beacon: add bitcloud stack into common directory digital/zigbit --- .../SystemEnvironment/include/bcEndian.h | 144 ++++++++++++ .../SystemEnvironment/include/bcSysSleep.h | 37 ++++ .../Components/SystemEnvironment/include/dbg.h | 244 +++++++++++++++++++++ .../Components/SystemEnvironment/include/mnUtils.h | 127 +++++++++++ .../Components/SystemEnvironment/include/queue.h | 92 ++++++++ .../Components/SystemEnvironment/include/sysDbg.h | 31 +++ .../SystemEnvironment/include/sysDuplicateTable.h | 82 +++++++ .../Components/SystemEnvironment/include/sysStat.h | 53 +++++ .../SystemEnvironment/include/sysTimer.h | 79 +++++++ .../SystemEnvironment/include/taskManager.h | 118 ++++++++++ .../Components/SystemEnvironment/include/types.h | 242 ++++++++++++++++++++ 11 files changed, 1249 insertions(+) create mode 100644 digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcEndian.h create mode 100644 digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcSysSleep.h create mode 100644 digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/dbg.h create mode 100644 digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/mnUtils.h create mode 100644 digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/queue.h create mode 100644 digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDbg.h create mode 100644 digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDuplicateTable.h create mode 100644 digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysStat.h create mode 100644 digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysTimer.h create mode 100644 digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/taskManager.h create mode 100644 digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/types.h (limited to 'digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include') diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcEndian.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcEndian.h new file mode 100644 index 00000000..405e2fc3 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcEndian.h @@ -0,0 +1,144 @@ +/***************************************************************************//** + \file bcEndian.h + + \brief + Interface for endian-neutral code. + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 3/10/09 Max Gekk - Created. + ******************************************************************************/ +#ifndef _BC_ENDIAN_H +#define _BC_ENDIAN_H +#ifdef _BIG_ENDIAN_ + #ifdef _DO_NOT_USE_BE + #undef _BIG_ENDIAN_ + #endif //_DO_NOT_USE_BE +#endif //_BIG_ENDIAN_ + +/****************************************************************************** + Definitions section + ******************************************************************************/ +/* Swaping bytes */ +#define SWAP16(x) ((uint16_t)(\ + (((uint16_t)(x) & (uint16_t)0x00ffU) << 8) | \ + (((uint16_t)(x) & (uint16_t)0xff00U) >> 8))) + +#define SWAP32(x) ((uint32_t)(\ + (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \ + (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \ + (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \ + (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24))) + +#define SWAP64(x) ((uint64_t)(\ + (((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) | \ + (((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ + (((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ + (((uint64_t)(x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ + (((uint64_t)(x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ + (((uint64_t)(x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ + (((uint64_t)(x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ + (((uint64_t)(x) & (uint64_t)0xff00000000000000ULL) >> 56))) +/* Macroses for reversing of bit fields in structure type depending on endian. */ +#if defined _BIG_ENDIAN_ + #define BIT_FIELDS_1(f1) f1; + #define BIT_FIELDS_2(f1, f2) f2; f1; + #define BIT_FIELDS_3(f1, f2, f3) f3; f2; f1; + #define BIT_FIELDS_4(f1, f2, f3, f4) f4; f3; f2; f1; + #define BIT_FIELDS_5(f1, f2, f3, f4, f5) f5; f4; f3; f2; f1; + #define BIT_FIELDS_6(f1, f2, f3, f4, f5, f6) f6; f5; f4; f3; f2; f1; + #define BIT_FIELDS_7(f1, f2, f3, f4, f5, f6, f7) f7; f6; f5; f4; f3; f2; f1; + #define BIT_FIELDS_8(f1, f2, f3, f4, f5, f6, f7, f8) \ + f8; f7; f6; f5; f4; f3; f2; f1; +#else /* _LITTLE_ENDIAN_ by default */ + #define BIT_FIELDS_1(f1) f1; + #define BIT_FIELDS_2(f1, f2) f1; f2; + #define BIT_FIELDS_3(f1, f2, f3) f1; f2; f3; + #define BIT_FIELDS_4(f1, f2, f3, f4) f1; f2; f3; f4; + #define BIT_FIELDS_5(f1, f2, f3, f4, f5) f1; f2; f3; f4; f5; + #define BIT_FIELDS_6(f1, f2, f3, f4, f5, f6) f1; f2; f3; f4; f5; f6; + #define BIT_FIELDS_7(f1, f2, f3, f4, f5, f6, f7) f1; f2; f3; f4; f5; f6; f7; + #define BIT_FIELDS_8(f1, f2, f3, f4, f5, f6, f7, f8) \ + f1; f2; f3; f4; f5; f6; f7; f8; +#endif /* _BIG_ENDIAN_ */ + +/* various macroses to swap bytes */ +#ifdef _BIG_ENDIAN_ +// Toggles the endianism of u16 (by swapping its bytes). +#if (defined __GNUC__) + #define swap16(x) ((uint16_t)__builtin_bswap_16((uint16_t)(x))) +#elif (defined __ICCAVR32__) + #define swap16(x) ((uint16_t)__swap_bytes_in_halfwords((uint16_t)(x))) +#else + #error unknown compiler +#endif + +// Toggles the endianism of u32 (by swapping its bytes). +#if (defined __GNUC__) + #define swap32(x) ((uint32_t)__builtin_bswap_32((uint32_t)(x))) +#elif (defined __ICCAVR32__) + #define swap32(x) ((uint32_t)__swap_bytes((uint32_t)(x))) +#else + #error unknown compiler +#endif + +// Toggles the endianism of u64 (by swapping its bytes). +#define swap64(x) ((uint64_t)(((uint64_t)swap32((uint64_t)(x) >> 32)) | ((uint64_t)swap32((uint64_t)(x)) << 32))) + +#define CPU_TO_LE16(x) swap16(x) +#define CPU_TO_LE32(x) swap32(x) +#define CPU_TO_LE64(x) swap64(x) +#define LE16_TO_CPU(x) swap16(x) +#define LE32_TO_CPU(x) swap32(x) +#define LE64_TO_CPU(x) swap64(x) + +/* Converting of constants from CPU endian to little endian. */ +#define CCPU_TO_LE16(x) SWAP16(x) + +#define CCPU_TO_LE32(x) SWAP32(x) + +#define CCPU_TO_LE64(x) SWAP64(x) + +/* Converting of constants from little endian to CPU endian. */ +#define CLE16_TO_CPU(x) CCPU_TO_LE16(x) +#define CLE32_TO_CPU(x) CCPU_TO_LE32(x) +#define CLE64_TO_CPU(x) CCPU_TO_LE64(x) + +#else //_BIG_ENDIAN_ + +#define CPU_TO_LE16(x) (x) +#define CPU_TO_LE32(x) (x) +#define CPU_TO_LE64(x) (x) +#define LE16_TO_CPU(x) (x) +#define LE32_TO_CPU(x) (x) +#define LE64_TO_CPU(x) (x) +#define CLE16_TO_CPU(x) (x) +#define CLE32_TO_CPU(x) (x) +#define CLE64_TO_CPU(x) (x) + +/* Converting of constants from CPU endian to little endian. */ +#define CCPU_TO_LE16(x) (x) +#define CCPU_TO_LE32(x) (x) +#define CCPU_TO_LE64(x) (x) + +#endif + +/****************************************************************************** + \brief The macro for declaration of bit fields with little endian order. + + Total size of bit fields must equal 8 bit (or one octet). + + \param amount - amount of bit fields in octet. + \param fields - list of bit fields that are separated by ','. + ******************************************************************************/ +#define LITTLE_ENDIAN_OCTET(amount, fields) BIT_FIELDS_ ## amount fields + +#endif /* _BC_ENDIAN_H */ +/* eof bcEndian.h */ diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcSysSleep.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcSysSleep.h new file mode 100644 index 00000000..6ea0be2c --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/bcSysSleep.h @@ -0,0 +1,37 @@ +/****************************************************************************//** + \file bcSysSleep.h + + \brief + Implementation of the system sleep service. + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 8/06/09 A. Khromykh - Created +*********************************************************************************/ + +#ifndef _MNSYSSLEEP_H +#define _MNSYSSLEEP_H +/********************************************************************************* + Includes section. +**********************************************************************************/ +#include + +/********************************************************************************* + Function prototypes section. +**********************************************************************************/ +/******************************************************************************//** +\brief Prepares system for sleep. + +\param[in] + sleepParam - pointer to sleep structure. +**********************************************************************************/ +void SYS_Sleep(HAL_Sleep_t *sleepParam); + +#endif /* _MNSYSSLEEP_H */ diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/dbg.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/dbg.h new file mode 100644 index 00000000..16b277eb --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/dbg.h @@ -0,0 +1,244 @@ +/*******************************************************************************//** + \file dbg.h + + \brief + A module should use the SYS_writeLog define and should not use writeLog() directly + Module should define own #define on SYS_WriteLog() to have an opportunity + to turn on/off logging by setting special define during compilation + + The LOG is turned on by the _SYS_LOG_ON_ define defined in Makefile + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 29/05/07 D. Ovechkin - Created + 17/01/11 M. Gekk - Guards are added +**********************************************************************************/ + +#ifndef _DBG_H +#define _DBG_H + +/********************************************************************************* + Includes section. +**********************************************************************************/ +#include +#ifdef _SYS_ASSERT_ON_ + #include +#endif // _SYS_ASSERT_ON_ + +/****************************************************************************** + Define(s) section +******************************************************************************/ +/* log type of message */ +typedef enum +{ + HAL_LOG_MESSAGE = 0x80, + MAC_LOG_MESSAGE = 0x81, + NWK_LOG_MESSAGE = 0x82, + APS_LOG_MESSAGE = 0x83, + ZDO_LOG_MESSAGE = 0x84, + SSP_TC_LOG_MESSAGE = 0x85, + ZCL_LOG_MESSAGE = 0x86, + APL_LOG_MESSAGE = 0x87 +} LogMessageLevel_t; + +#if defined(_SYS_LOG_ON_) && defined(_HAL_LOG_ON_) + #define HAL_WRITE_LOG(A) SYS_WriteLog((uint8_t)HAL_LOG_MESSAGE, (uint8_t)A); +#else + #define HAL_WRITE_LOG(A) +#endif + +#if defined(_SYS_LOG_ON_) && defined(_MAC_LOG_ON_) + #define MAC_WRITE_LOG(A) SYS_WriteLog((uint8_t)MAC_LOG_MESSAGE, (uint8_t)A); +#else + #define MAC_WRITE_LOG(A) +#endif + +#if defined(_SYS_LOG_ON_) && defined(_NWK_LOG_ON_) + #define NWK_WRITE_LOG(A) SYS_WriteLog((uint8_t)NWK_LOG_MESSAGE, (uint8_t)A); +#else + #define NWK_WRITE_LOG(A) +#endif + +#if defined(_SYS_LOG_ON_) && defined(_APS_LOG_ON_) + #define APS_WRITE_LOG(A) SYS_WriteLog((uint8_t)APS_LOG_MESSAGE, (uint8_t)A); +#else + #define APS_WRITE_LOG(A) +#endif + +#if defined(_SYS_LOG_ON_) && defined(_ZDO_LOG_ON_) + #define ZDO_WRITE_LOG(A) SYS_WriteLog((uint8_t)ZDO_LOG_MESSAGE, (uint8_t)A); +#else + #define ZDO_WRITE_LOG(A) +#endif + +#if defined(_SYS_LOG_ON_) && defined(_SSP_TC_LOG_ON_) + #define SSP_TC_WRITE_LOG(A) SYS_WriteLog((uint8_t)SSP_TC_LOG_MESSAGE, (uint8_t)A); +#else + #define SSP_TC_WRITE_LOG(A) +#endif + +#if defined(_SYS_LOG_ON_) && defined(_ZCL_LOG_ON_) + #define ZCL_WRITE_LOG(A) SYS_WriteLog((uint8_t)ZCL_LOG_MESSAGE, (uint8_t)A); +#else + #define ZCL_WRITE_LOG(A) +#endif + +#if defined(_SYS_LOG_ON_) && defined(_APL_LOG_ON_) + #define APL_WRITE_LOG(A) SYS_WriteLog((uint8_t)APL_LOG_MESSAGE, (uint8_t)A); +#else + #define APL_WRITE_LOG(A) +#endif + +#define assert_static(e) {enum {_SA_ = 1/(e)};} + +/********************************************************************************* + Function prototypes section. +**********************************************************************************/ +/* ________________________________ SYS_LOG __________________________________ */ +#ifdef _SYS_LOG_ON_ + /****************************************************************************** + Define(s) section + ******************************************************************************/ + #define SYS_INFINITY_LOOP_MONITORING sysInfinityLoopMonitoring = 0; + /* 1 = 10 ms */ + #define TASK_LENGTH 100 + + #if defined(_HAL_LOG_INTERFACE_UART0_) + #define INFORMATION_HANDLER HAL_TaskHandler(); + #elif defined(_HAL_LOG_INTERFACE_UART1_) + #define INFORMATION_HANDLER HAL_TaskHandler(); + #else + #define INFORMATION_HANDLER + #endif + + /****************************************************************************** + External variables section + ******************************************************************************/ + extern volatile uint8_t sysInfinityLoopMonitoring; + + /********************************************************************************* + Function prototypes section. + **********************************************************************************/ + /*****************************************************************************//** + \brief Write log information to defined destination. The destination can be + UART, EEPROM, Ethernet... The destination is determined by the define + during compilation + \param[in] + leyerID - identical definition of application layer; + \param[in] + message - information byte (must be less then 0x80); + **********************************************************************************/ + void SYS_WriteLog(uint8_t leyerID, uint8_t message); + + /*****************************************************************************//** + \brief Initialization of logging system. + **********************************************************************************/ + void SYS_InitLog(void); + + #if defined(_HAL_LOG_INTERFACE_UART0_) || defined(_HAL_LOG_INTERFACE_UART1_) + /**************************************************************************//** + \brief HAL task handler. + ******************************************************************************/ + void HAL_TaskHandler(void); + #endif + + /********************************************************************************* + Inline static functions section + **********************************************************************************/ + /*****************************************************************************//** + \brief Monitoring infinity loop in the soft. + **********************************************************************************/ + INLINE void SYS_InfinityLoopMonitoring(void) + { + sysInfinityLoopMonitoring++; + if (sysInfinityLoopMonitoring > TASK_LENGTH) + { + INFORMATION_HANDLER + } + } +#else + INLINE void SYS_InitLog(void){} + INLINE void SYS_InfinityLoopMonitoring(void){} + INLINE void SYS_WriteLog(uint8_t leyerID, uint8_t message){(void)leyerID; (void)message;} + #define SYS_INFINITY_LOOP_MONITORING +#endif // _SYS_LOG_ON_ + + + +/* ________________________________ SYS_ASSERT _______________________________ */ +#ifdef _SYS_ASSERT_ON_ + /********************************************************************************* + ASSERT is used for debugging wrong conditions + Dbg codes are in each layers. + *********************************************************************************/ + /********************************************************************************* + Function catches unexpected conditions in the logic. + Parameters: + condition - TRUE or FALSE. FALSE means problems in the logic. + dbgCode - assert's unique code. + dbgCode ranges: 0x1000 - 0x1fff - MAC + 0x2000 - 0x2fff - HAL + 0x3000 - 0x3fff - NWK + 0x4000 - 0x4fff - APS + 0x5000 - 0x5fff - ZDO + 0x6000 - 0x6fff - Configuration Server + 0x7000 - 0x7fff - SSP/TC + 0x8000 - 0x8fff - System Environment + 0x9000 - 0x9fff - BSP + 0xf000 - 0xfffe - APL + Returns: + none. + *********************************************************************************/ + void assert(bool condition, uint16_t dbgCode); + // Inline Assert + #define ASSERT(condition, dbgCode) halAssert(condition, dbgCode); + +#else // !_SYS_ASSERT_ON_ + #define ASSERT(condition, dbgCode) {if(condition){}} +#ifndef assert + #define assert(condition, dbgCode) {if(condition){}} +#endif +#endif // _SYS_ASSERT_ON_ + +#define assert_static(e) {enum {_SA_ = 1/(e)};} + +#if defined _SYS_ASSERT_ON_ +#define TOP_GUARD_VALUE 0x55U +#define BOTTOM_GUARD_VALUE 0xAAU + +#define TOP_GUARD uint8_t topGuard; +#define BOTTOM_GUARD uint8_t bottomGuard; +#define INIT_GUARDS(obj) \ + {\ + (obj)->topGuard = TOP_GUARD_VALUE;\ + (obj)->bottomGuard = BOTTOM_GUARD_VALUE;\ + } + +#define CHECK_GUARDS(obj, assertNum) \ + assert((TOP_GUARD_VALUE == (obj)->topGuard) \ + && (BOTTOM_GUARD_VALUE == (obj)->bottomGuard), assertNum) + +#define GUARDED_STRUCT(obj) \ + (obj) = \ + { \ + .topGuard = TOP_GUARD_VALUE, \ + .bottomGuard = BOTTOM_GUARD_VALUE \ + } + +#else +#define TOP_GUARD +#define BOTTOM_GUARD +#define INIT_GUARDS(obj) ((void)0) +#define CHECK_GUARDS(obj, assertNum) ((void)0) +#define GUARDED_STRUCT(obj) (obj) +#endif + +#endif // _DBG_H +//end of dbg.h + diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/mnUtils.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/mnUtils.h new file mode 100644 index 00000000..1be01c42 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/mnUtils.h @@ -0,0 +1,127 @@ +/**************************************************************************//** + \file mnUtils.h + \brief Header file describes stack utilities functions. + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 07/10/08 - Created. +******************************************************************************/ +#ifndef _MNUTILS_H +#define _MNUTILS_H + +/****************************************************************************** + Includes section. +******************************************************************************/ +#include +#include +#include + +/****************************************************************************** + Definitions section. +******************************************************************************/ +#if defined(AT91SAM7X256) || defined(AT91SAM3S4C) + #define SYS_BYTE_MEMCPY SYS_ByteMemcpy +#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \ + || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1) + #define SYS_BYTE_MEMCPY memcpy +#else + #define SYS_BYTE_MEMCPY memcpy +#endif + +#if defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) || \ + defined(ATMEGA128RFA1) +/* Macroses to accept memory I/O registers for AVR Mega family */ +#define MMIO_BYTE(mem_addr) (*(volatile uint8_t *)(mem_addr)) +#define MMIO_WORD(mem_addr) (*(volatile uint16_t *)(mem_addr)) +#endif /* AVR Mega family */ + +#define GET_FIELD_PTR(structPtr, typeName, fieldName) \ + ((uint8_t *)(structPtr) + offsetof(typeName, fieldName)) + +#define GET_PARENT_BY_FIELD(TYPE, FIELD, FIELD_POINTER) \ + ((TYPE *)(((uint8_t *)FIELD_POINTER) - offsetof(TYPE, FIELD))) +#define GET_CONST_PARENT_BY_FIELD(TYPE, FIELD, FIELD_POINTER) \ + ((const TYPE *)(((const uint8_t *)FIELD_POINTER) - offsetof(TYPE, FIELD))) + +#define GET_STRUCT_BY_FIELD_POINTER(struct_type, field_name, field_pointer)\ + ((struct_type *) (((uint8_t *) field_pointer) - FIELD_OFFSET(struct_type, field_name))) +#define GET_INDEX_FROM_OFFSET(PTR1, PTR2) (PTR1 - PTR2) + +// Size of slice between firstField end lastField of struct (including lastField) +#define SLICE_SIZE(type, firstField, lastField)\ + (offsetof(type, lastField) - offsetof(type, firstField) + sizeof(((type *)0)->lastField)) + +#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) + +#undef FIELD_OFFSET +#define FIELD_OFFSET(struct_type, field_name)\ + (((uint8_t*) &((struct_type *)(NULL))->field_name) - (uint8_t*)NULL) + +#define MIN(x,y) ((x)<(y)?(x):(y)) +#define MAX(x,y) ((x)<(y)?(y):(x)) + +/****************************************************************************** + Inline functions' section. +******************************************************************************/ +/**************************************************************************//** + \brief Performs bytes memory copying operation. + + \param dst - points destination memory start address. + src - points source memory start address. + size - number of bytes to copy. + \return pointer to dst. +******************************************************************************/ +INLINE void *SYS_ByteMemcpy(void *dst, const void *src, uint16_t size) +{ + uint8_t *dst_ = (uint8_t *) dst; + const uint8_t *src_ = (const uint8_t *) src; + + while(size--) + *(dst_++) = *(src_++); + return dst; +} + +/**************************************************************************//** + \brief Performs swap bytes in array of length + + \param array - pointer to array. + length - array length + \return no return. +******************************************************************************/ +void SYS_Swap(uint8_t *array, uint8_t length); + +/**************************************************************************//** + \brief Random number generator. The range of the generator is 0-0xFFFF.The SID + is generated in ZDO from UID by srand() + + \param: none. + \returns: a random number. +******************************************************************************/ +static inline uint16_t SYS_GetRandomNumber(void) +{ + uint16_t result = (rand() << 4) & 0xFF00; + + result |= rand() & 0x00FF; + return result; +} + +/**************************************************************************//** + \brief This function copies size bytes of random data into buffer. + + \param: buffer - This is an unsigned char array of size at least sz to hold + the random data. + size - The number of bytes of random data to compute and store. + + \return: 0 Indicates successful completion. +******************************************************************************/ +int SYS_GetRandomSequence(uint8_t *buffer, unsigned long size); + +#endif // _MNUTILS_H +// eof mnUtils.h diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/queue.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/queue.h new file mode 100644 index 00000000..0a7f8094 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/queue.h @@ -0,0 +1,92 @@ +/**********************************************************************//** + \file queue.h + + \brief + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 21/05/07 D. Ovechkin - Created +**************************************************************************/ +#ifndef _QUEUE_H +#define _QUEUE_H + +#include + +/*************************************************************************** + Declare a queue and reset to the default state + Every queue should be declared with this macros! + Any queue element passed as parameter to functions should have as first + field pointer for adding to a queue. + + Parameters: + queue - the name of object. + Returns: + None +****************************************************************************/ +#define DECLARE_QUEUE(queue) QueueDescriptor_t queue = {.head = NULL,} + +// Type of queue element +typedef struct _QueueElement_t +{ + struct _QueueElement_t *next; +} QueueElement_t; + +// Queue descriptor +typedef struct +{ + QueueElement_t *head; +} QueueDescriptor_t; + +/*************************************************************************** + Reset a queue + Parameters: + queue - pointer to a queue descriptor + Returns: + None +****************************************************************************/ +INLINE void resetQueue(QueueDescriptor_t *queue) +{ + queue->head = NULL; +} + +/*************************************************************************** + Get a element from a queue. Element is got from the head + Parameters: + queue - pointer to a queue descriptor + Returns: + None +****************************************************************************/ +INLINE void *getQueueElem(const QueueDescriptor_t *queue) +{ + return queue->head; +} + +/*************************************************************************** + Get next element of queue after current element. The movement is made from + head to tail. At the beginning of looking for elements the head element + should be obtained. + Parameters: + currElement - current element + Returns: + NULL - no next element + NOT NULL - next element is got +****************************************************************************/ +INLINE void* getNextQueueElem(const void *currElem) +{ + return currElem? ((const QueueElement_t*) currElem)->next: NULL; +} + +bool isQueueElem(const QueueDescriptor_t *const queue, const void *const element); +void putQueueElem(QueueDescriptor_t *queue, void *element); +void *deleteHeadQueueElem(QueueDescriptor_t *queue); +bool deleteQueueElem(QueueDescriptor_t *queue, void *element); + +#endif +//eof queue.h diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDbg.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDbg.h new file mode 100644 index 00000000..2e6494f7 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDbg.h @@ -0,0 +1,31 @@ +/***************************************************************************** + \file sysDbg.h + + \brief + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 13.10.2009 ivagulin - Created +******************************************************************************/ + + +#ifndef _SYSDBG_H_ +#define _SYSDBG_H_ + +#include + +typedef enum +{ + SYS_ASSERT_ID_DOUBLE_QUEUE_PUT = 0x8000, + SYS_ASSERT_ID_DRT_SIZE_TOO_BIG = 0x8001, + SYS_ASSERT_ID_DEVICE_WAS_NOT_ABLE_TO_SLEEP = 0x8002 +} SysAssertId_t; + +#endif /* _SYSDBG_H_ */ diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDuplicateTable.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDuplicateTable.h new file mode 100644 index 00000000..4fd5fe89 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysDuplicateTable.h @@ -0,0 +1,82 @@ +/***************************************************************************** + \file sysDuplicateEntry.h + + \brief + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 11/20/2009 I.Vagulin - Created +******************************************************************************/ + + +#ifndef _SYSDUPLICATEENTRY_H_ +#define _SYSDUPLICATEENTRY_H_ + +#include + +typedef enum +{ + SYS_DUPLICATE_TABLE_ANSWER_FOUND, + SYS_DUPLICATE_TABLE_ANSWER_ADDED, + SYS_DUPLICATE_TABLE_ANSWER_FULL, // check can return Full only if removeOldest set to false +} SysDuplicateTableAnswer_t ; + +typedef struct _SYS_DuplicateTableEntry_t +{ + uint16_t address; + uint8_t seqNumber; + uint8_t ttl; + uint8_t mask; +} SYS_DuplicateTableEntry_t ; + +typedef struct _SYS_DuplicateTable_t +{ + bool removeOldest:1; + uint8_t size:7; + SYS_DuplicateTableEntry_t *entries; + + uint16_t agingPeriod; + uint32_t lastStamp; + uint8_t maxTTL; +} SYS_DuplicateTable_t ; + +/***************************************************************************** + Prepare duplicate table to real work :) + + Parameters: table - pointer to allocated table, + entrySize - count of entries in table + entries - pointer to array of entries + agingPeriod - aging period ms + removeOldest - change behaviour on full table + Returns: nothing +*****************************************************************************/ +void SYS_DuplicateTableReset(SYS_DuplicateTable_t *table, + SYS_DuplicateTableEntry_t *entries, uint8_t tableSize, + uint16_t agingPeriod, uint8_t maxTTL, bool removeOldest); + +/***************************************************************************** + Search for record in table, add if not found + Parameters: table - pointer to allocated table, + address, seqNumber - record to search for or to add if not found + Returns: true if record is found false otherwise. +*****************************************************************************/ +SysDuplicateTableAnswer_t SYS_DuplicateTableCheck(SYS_DuplicateTable_t *table, + uint16_t address, uint8_t seqNumber); + +/***************************************************************************** + Search for record in table, remove if found. + Parameters: table - pointer to allocated table, + address, seqNumber - record to search for and to remove if found + Returns: nothing +*****************************************************************************/ +void SYS_DuplicateTableClear(SYS_DuplicateTable_t *table, + uint16_t address, uint8_t seqNumber); + +#endif /* _SYSDUPLICATEENTRY_H_ */ diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysStat.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysStat.h new file mode 100644 index 00000000..79b36051 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysStat.h @@ -0,0 +1,53 @@ +/**************************************************************************//** +\file sysStat.h + +\brief Collection of internal runtime data for report + +\author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + +\internal + History: + 15/04/11 D. Loskutnikov - Created +*******************************************************************************/ +#ifndef _SYS_STAT_H +#define _SYS_STAT_H + +#ifdef _REPORT_STATS_ +/****************************************************************************** + Types section +******************************************************************************/ +typedef struct _SYS_StatGenerator_t +{ + void *next; + uint8_t (*gen)(uint8_t *buf, uint8_t maxSize); +} SYS_StatGenerator_t; + +/****************************************************************************** + Prototypes section +******************************************************************************/ + +/**************************************************************************//** +\brief Register new generator of stat data + +\param[in] gen - generator +******************************************************************************/ +extern void SYS_RegisterStatGenerator(SYS_StatGenerator_t *gen); + +/**************************************************************************//** +\brief Collect stats from registered generators into the supplied buffer + +\param[out] buf - buffer to place stat report +\param[in] maxSize - size limit of buffer +\return number of actually placed bytes +******************************************************************************/ +extern uint8_t SYS_GenerateStatReport(uint8_t *buf, uint8_t maxSize); + +#endif // _REPORT_STATS_ + +#endif // _SYS_STAT_H +// eof sysStat.h diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysTimer.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysTimer.h new file mode 100644 index 00000000..4420725d --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/sysTimer.h @@ -0,0 +1,79 @@ +/**************************************************************************//** + \file sysTimer.h + + \brief Simple interface of HAL application timer. + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 2010-10-18 Max Gekk - Created. + Last change: + $Id: sysTimer.h 17448 2011-06-09 13:53:59Z ataradov $ + ******************************************************************************/ +#if !defined _SYS_TIMER_H +#define _SYS_TIMER_H + +/****************************************************************************** + Includes section + ******************************************************************************/ +#include + +/****************************************************************************** + Types section + ******************************************************************************/ +/* Internal states of system timer. */ +typedef enum _SYS_TimerState_t +{ + SYS_TIMER_STOPPED = 0x00, + SYS_TIMER_STARTED = 0x01 +} SYS_TimerState_t; + +/* Type of the system timer. */ +typedef struct _SYS_Timer_t +{ + SYS_TimerState_t state; + HAL_AppTimer_t timer; +} SYS_Timer_t; + + +/****************************************************************************** + Prototypes section + ******************************************************************************/ +/****************************************************************************** + \brief Initialize the System Timer. + + \param[in] sysTimer - timer pointer will be initialized. + \param[in] mode - timer mode: TIMER_ONE_SHOT_MODE or TIMER_REPEAT_MODE. + \param[in] interval - timer interval (milliseconds). + \param[in] handler - timer handler function pointer. + + \return None. + *****************************************************************************/ +void SYS_InitTimer(SYS_Timer_t *const sysTimer, const TimerMode_t mode, + const uint32_t interval, void (*handler)(void)); + +/****************************************************************************** + \brief Start the HAL Application Timer. + + \param[in] appTimer - timer pointer will be started. + \return None. + ******************************************************************************/ +void SYS_StartTimer(SYS_Timer_t *const sysTimer); + +/****************************************************************************** + \brief Stop the HAL Application Timer. + + \param[in] appTimer - timer pointer will be stopped. + + \return None. + *****************************************************************************/ +void SYS_StopTimer(SYS_Timer_t *const sysTimer); + +#endif /* _SYS_TIMER_H */ +/** eof sysTimer.h */ diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/taskManager.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/taskManager.h new file mode 100644 index 00000000..ad974a16 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/taskManager.h @@ -0,0 +1,118 @@ +/*************************************************************************//** + \file taskManager.h + + \brief The header file describes the public stack Task Manager interface, + task handlers and tasks IDs of Task Manager + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal + History: + 15/05/07 E. Ivanov - Created +*****************************************************************************/ + +#ifndef _TASKMANAGER_H +#define _TASKMANAGER_H +#include +#include + +// \cond internal +//! The list of task ID +typedef enum +{ + MAC_PHY_HWD_TASK_ID = 1 << 0, + HAL_TASK_ID = 1 << 1, + MAC_HWI_TASK_ID = 1 << 2, + NWK_TASK_ID = 1 << 3, + ZDO_TASK_ID = 1 << 4, + APS_TASK_ID = 1 << 5, + SSP_TASK_ID = 1 << 6, + TC_TASK_ID = 1 << 7, + BSP_TASK_ID = 1 << 8, + ZCL_TASK_ID = 1 << 9, + APL_TASK_ID = 1 << 0x0A, +} SYS_TaskId_t; +// \endcond + +/*! This function is called to process a user application task. + The function should be defined in the user application. + Its very first call is intended just for setting stack parameters. + For starting a network a new task should be posted. */ +extern void APL_TaskHandler(void); +// \cond internal +//! This function is called for processing HAL task. Should be defined in HAL +extern void HAL_TaskHandler(void); +//! This function is called for processing BSP task. Should be defined in BSP +extern void BSP_TaskHandler(void); +//! This function is called for processing MAC_PHY_HWD task. Should be defined in MAC_PHY_HWD +extern void MAC_PHY_HWD_TaskHandler(void); +//! This function is called for processing MAC_HWI task. Should be defined in MAC_HWI +extern void MAC_HWI_TaskHandler(void); +//! This function is called for processing NWK task. Should be defined in NWK +extern void NWK_TaskHandler(void); +//! This function is called for processing ZDO task. Should be defined in ZDO +extern void ZDO_TaskHandler(void); +//! This function is called for processing APS task. Should be defined in APS +extern void APS_TaskHandler(void); +//! This function is called for processing SSP task. Should be defined in SSP +extern void SSP_TaskHandler(void); +//! This function is called for processing Trust Center task. Should be defined in Trust Center +extern void TC_TaskHandler(void); +//! This function is called for processing ZCL task. Should be defined in ZCL +extern void ZCL_TaskHandler(void); +//! Initializes radio chip +extern void RF_Init(void); + +extern volatile uint16_t SYS_taskFlag; +// \endcond + +/**************************************************************************************//** +\brief Posts task to the stack Task Manager + +\param[in] taskId - ID of the posted task. An application has APL_TASK_ID. +*********************************************************************************************/ +/* +IDs of the tasks are listed in the SYS_TaskId enum. Each task has its own priority and is called +only if there is no any task with higher priority. A handler is called when respective task can be run. +Each task has its own task handler. Correspondence between tasks and handlers is listed below: \n +HAL - HAL_TaskHandler() \n +BSP - BSP_TaskHandler() \n +MAC_PHY_HWD - MAC_PHY_HWD_TaskHandler() \n +MAC_HWI - MAC_HWI_TaskHandler() \n +NWK - NWK_TaskHandler() \n +ZDO - ZDO_TaskHandler() \n +APS - APS_TaskHandler() \n +APL - APL_TaskHandler() \n +*/ +INLINE void SYS_PostTask(SYS_TaskId_t taskId) +{ + ATOMIC_SECTION_ENTER + SYS_taskFlag |= taskId; + ATOMIC_SECTION_LEAVE +} + +//\cond internal +/**************************************************************************************//** +\brief This function is called by the stack or from the main() function to process tasks. +***************************************************************************************/ +bool SYS_RunTask(void); + +/**************************************************************************************//** + \brief To force runTask to help making sync calls +******************************************************************************************/ +void SYS_ForceRunTask(void); +// \endcond + +/**************************************************************************//** + \brief Initializes the microconroller and the radio chip + + \param none + \return none +******************************************************************************/ +void SYS_SysInit(void); +#endif diff --git a/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/types.h b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/types.h new file mode 100644 index 00000000..16be4404 --- /dev/null +++ b/digital/zigbit/bitcloud/stack/Components/SystemEnvironment/include/types.h @@ -0,0 +1,242 @@ +/************************************************************************************************//** + \file types.h + + \brief The header file describes global system types and pre-processor words + which depends on compiler or platform + + \author + Atmel Corporation: http://www.atmel.com \n + Support email: avr@atmel.com + + Copyright (c) 2008-2011, Atmel Corporation. All rights reserved. + Licensed under Atmel's Limited License Agreement (BitCloudTM). + + \internal +*****************************************************************************************************/ + +#ifndef _TYPES_H +#define _TYPES_H + +#include +#include +#include +#include +#include + +#if defined(__ICCAVR__) || defined(__ICCARM__) || defined(__ICCAVR32__) + +// \cond +#if defined(AT91SAM7X256) || defined(AT91SAM3S4C) + #include +#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \ + || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1) + #include + #include + #include + #include +#elif defined(AT32UC3A0512) + #include +#endif +// \endcond + +/** + * Some preprocessor magic to allow for a header file abstraction of + * interrupt service routine declarations for the IAR compiler. This + * requires the use of the C99 _Pragma() directive (rather than the + * old #pragma one that could not be used as a macro replacement), as + * well as two different levels of preprocessor concetanations in + * order to do both, assign the correct interrupt vector name, as well + * as construct a unique function name for the ISR. + * + * Do *NOT* try to reorder the macros below, or you'll suddenly find + * out about all kinds of IAR bugs... + */ +#define PRAGMA(x) _Pragma(#x) + +// \cond +#if defined(AT91SAM7X256) || defined(AT91SAM3S4C) + + #define PROGMEM_DECLARE(x) x + #define FLASH_VAR + #define FLASH_PTR + #define memcpy_P memcpy + #define hw_platform_address_size_t uint32_t + #define BEGIN_PACK PRAGMA(pack(push, 1)) + #define END_PACK PRAGMA(pack(pop)) + #define INLINE static inline + +#elif defined(AT32UC3A0512) + + #define PROGMEM_DECLARE(x) x + #define FLASH_VAR + #define FLASH_PTR + #define memcpy_P memcpy + #define hw_platform_address_size_t uint32_t + #define BEGIN_PACK PRAGMA(pack(push, 1)) + #define END_PACK PRAGMA(pack(pop)) + #define INLINE static inline + #define INTERRUPT __interrupt + +#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \ + || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1) + + #ifndef __HAS_ELPM__ + #define _MEMATTR __flash + #else /* __HAS_ELPM__ */ + #define _MEMATTR __farflash + #endif /* __HAS_ELPM__ */ + + #define PROGMEM_DECLARE(x) _MEMATTR x + #define FLASH_VAR _MEMATTR + #define FLASH_PTR _MEMATTR + #define BEGIN_PACK + #define END_PACK + #define INLINE PRAGMA(inline=forced) static + + #define ASM asm + #define __SLEEP __sleep() + + #if defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) + #define ENABLE_CHANGE_PROTECTION_REGISTER CCP = 0xD8 + #endif + + #define ISR(vec) PRAGMA(vector=vec) __interrupt void handler_##vec(void) + #define sei() (__enable_interrupt()) + #define cli() (__disable_interrupt()) + /** Wait until bit \c bit in IO register \c sfr is clear. */ + #define loop_until_bit_is_clear(sfr, bit) do {;} while (sfr & (1 << bit)) + + #define wdt_reset() (__watchdog_reset()) + + #define SF_GET_LOW_FUSES() __AddrToZByteToSPMCR_LPM((void __flash *)0x0000, 0x09) +#endif + +#if defined(ATMEGA1284) + #define EEMPE 2 + #define EEPE 1 + #define PSRASY 1 +#endif + +#if defined(AT90USB1287) + #define UPE1 2 + #define USB_GEN_vect USB_General_vect + #define USB_COM_vect USB_Endpoint_Pipe_vect +#endif + +// \endcond + +#define PACK +#define MAY_ALIAS +#define NOP __no_operation() +#define nop() (__no_operation()) +#define PRINTF_STYLE + +#elif defined(__GNUC__) + +// Leave this here until new security naming will settle +#pragma GCC poison _HIGH_SECURITY_ _USE_SKKE_ _AUTHENTICATION_ _ZCL_KE_CLUSTER_ + +// \cond +#if defined(AT91SAM7X256) || defined(AT91SAM3S4C) +#elif defined(X86) +#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \ + || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1) + #include + #include + #if !defined(ATXMEGA128A1) && !defined(ATXMEGA256A3) && !defined(ATXMEGA256D3) + #include + #endif + #include + #include +#elif defined(SIMULATOR) +#endif +// \endcond + +// \cond +#if defined(AT91SAM7X256) || defined(AT91SAM3S4C) + + #define PROGMEM_DECLARE(x) x + #define FLASH_VAR + #define FLASH_PTR + #define memcpy_P memcpy + #define hw_platform_address_size_t uint32_t + #define BEGIN_PACK + #define END_PACK + #define PACK __attribute__ ((packed)) + +#elif defined(ATMEGA1281) || defined(ATMEGA2561) || defined(ATMEGA1284) || defined(AT90USB1287) \ + || defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) || defined(ATMEGA128RFA1) + + #define SF_GET_LOW_FUSES() boot_lock_fuse_bits_get(GET_LOW_FUSE_BITS) + #define PROGMEM_DECLARE(x) x __attribute__((__progmem__)) + #define FLASH_VAR PROGMEM + #define FLASH_PTR + #define hw_platform_address_size_t uint16_t + #define BEGIN_PACK + #define END_PACK + #define PACK + + #define ASM asm volatile + #define __SLEEP asm volatile ("sleep") + #define UINT64_MEMCMP + + #if defined(ATXMEGA128A1) || defined(ATXMEGA256A3) || defined(ATXMEGA256D3) + #define ENABLE_CHANGE_PROTECTION_REGISTER CCP = 0xD8 + #endif + +#elif defined(X86) + #define PROGMEM_DECLARE(x) x + #define FLASH_VAR + #define FLASH_PTR + #define memcpy_P memcpy + #define hw_platform_address_size_t uint32_t + #define BEGIN_PACK + #define END_PACK + #define PACK __attribute__ ((packed)) + +#elif defined(SIMULATOR) + #define PROGMEM_DECLARE(x) x + #define FLASH_VAR + #define FLASH_PTR + #define memcpy_P memcpy + #define hw_platform_address_size_t uint32_t + #define BEGIN_PACK + #define END_PACK + #define PACK __attribute__ ((packed)) + +#endif +// \endcond + +#define INLINE static inline __attribute__ ((always_inline)) +#define MAY_ALIAS __attribute__((__may_alias__)) +#define NOP asm volatile ("nop") +#define PRINTF_STYLE __attribute__ ((format (printf, 1, 2))) + +#else + #error 'Compiler not supported.' +#endif + +typedef bool result_t; +typedef uint64_t BcTime_t; + +BEGIN_PACK +typedef struct PACK {uint16_t val;} u16Packed_t; +typedef struct PACK {uint32_t val;} u32Packed_t; +typedef struct PACK {uint64_t val;} u64Packed_t; +typedef struct PACK {int16_t val;} s16Packed_t; +typedef struct PACK {int32_t val;} s32Packed_t; +typedef struct PACK {int64_t val;} s64Packed_t; +END_PACK + +#if defined __ICCAVR__ || defined __ICCARM__ + typedef uint8_t BitField_t; +#else + typedef unsigned int BitField_t; +#endif + +#define BC_SUCCESS false +#define BC_FAIL true + +#endif +// eof types.h + -- cgit v1.2.3