Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00035 #ifndef BOARD_H
00036 #define BOARD_H
00037
00038 #ifndef F_CPU
00039 # error "F_CPU is undefined"
00040 #endif
00041
00042
00043 #include <stdlib.h>
00044 #include <stdint.h>
00045 #include <inttypes.h>
00046 #include <avr/io.h>
00047 #include <avr/sleep.h>
00048 #include <avr/interrupt.h>
00049 #include <util/delay.h>
00050 #include <avr/pgmspace.h>
00051 #include "const.h"
00052 #include "board_cfg.h"
00053
00059
00072 #define DELAY_US(x) _delay_ms(x/1000.0)
00073
00076 #define DELAY_MS(x) _delay_ms(x)
00077
00078 #ifndef PULLUP_KEYS
00079
00082 # define PULLUP_KEYS (0)
00083 #endif
00084
00085
00089 #define SLEEP_ON_IDLE()\
00090 do{\
00091 set_sleep_mode(SLEEP_MODE_IDLE);\
00092 sleep_mode();\
00093 }while(0);
00094
00095
00096 #ifdef NO_TIMER
00097
00099 # define TIMER_POOL_SIZE (0)
00100 # define TIMER_INIT() do{}while(0)
00101 # define TIMER_IRQ TIMER1_OVF_vect
00102 #endif
00103
00104 #ifndef HIF_TYPE
00105
00106 # define NO_HIF (1)
00107 # define HIF_TYPE (HIF_NONE)
00108 #endif
00109
00110 #ifndef HIF_IO_ENABLE
00111
00112 # define HIF_IO_ENABLE() do{}while(0)
00113 #endif
00114
00115 #define HIF_TYPE_IS_UART ((HIF_TYPE >= HIF_UART_0) && ( HIF_TYPE <= HIF_UART_1))
00116 #define HIF_TYPE_IS_USB ((HIF_TYPE == HIF_FT245) || (HIF_TYPE == HIF_AT90USB))
00117
00118
00119 #ifndef TRX_RESET_INIT
00120
00121 # define TRX_RESET_INIT() DDR_TRX_RESET |= MASK_TRX_RESET
00122 #endif
00123
00124 #ifndef TRX_RESET_HIGH
00125
00126 # define TRX_RESET_HIGH() PORT_TRX_RESET |= MASK_TRX_RESET
00127 #endif
00128
00129 #ifndef TRX_RESET_LOW
00130
00131 # define TRX_RESET_LOW() PORT_TRX_RESET &= ~MASK_TRX_RESET
00132 #endif
00133
00134 #ifndef TRX_SLPTR_INIT
00135
00136 # define TRX_SLPTR_INIT() DDR_TRX_SLPTR |= MASK_TRX_SLPTR
00137 #endif
00138
00139 #ifndef TRX_SLPTR_HIGH
00140
00141 # define TRX_SLPTR_HIGH() PORT_TRX_SLPTR |= MASK_TRX_SLPTR
00142 #endif
00143
00144 #ifndef TRX_SLPTR_LOW
00145
00146 # define TRX_SLPTR_LOW() PORT_TRX_SLPTR &= ~MASK_TRX_SLPTR
00147 #endif
00148
00149
00150 #if defined (DBG_PORT) && defined (DBG_DDR) && defined (DBG_PIN)
00151 # define DBG_INIT() do{DBG_DDR |= DBG_PIN; DBG_PORT &= ~DBG_PIN;}while(0)
00152 # define DBG_SET() do{DBG_PORT |= DBG_PIN;}while(0)
00153 # define DBG_CLR() do{DBG_PORT &= ~DBG_PIN;}while(0)
00154 # define DBG_TOGGLE() do{DBG_PORT ^= DBG_PIN;}while(0)
00155 #else
00156 # define DBG_INIT() do{}while(0)
00157 # define DBG_SET() do{}while(0)
00158 # define DBG_CLR() do{}while(0)
00159 # define DBG_TOGGLE() do{}while(0)
00160 #endif
00161
00162
00168 typedef struct
00169 {
00170 uint16_t short_addr;
00171 uint16_t pan_id;
00172 uint64_t ieee_addr;
00173 uint8_t _reserved_[3];
00174 uint8_t crc;
00175 } node_config_t;
00176
00177 static inline void get_node_config(node_config_t *ncfg)
00178 {
00179 uint8_t i = sizeof(node_config_t);
00180 uint8_t *pram = (uint8_t*)ncfg;
00181 do
00182 {
00183 #if FLASHEND > 0xffffL
00184 *pram++ = pgm_read_byte_far(((long)FLASHEND - i + 1));
00185 #else
00186 *pram++ = pgm_read_byte_near((FLASHEND - i + 1));
00187 #endif
00188 }
00189 while(--i);
00190 }
00191
00192
00193 #ifdef __cplusplus
00194 extern "C" {
00195 #endif
00196
00197 #ifdef __cplusplus
00198 }
00199 #endif
00200
00202 #endif