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
00126 #ifndef BOARD_WIMOD_H
00127 #define BOARD_WIMOD_H (1)
00128 #if defined(im240a)
00129 # define BOARD_NAME "im240a"
00130 # define BOARD_TYPE BOARD_IM240A
00131 #elif defined(im240a_eval)
00132 # define BOARD_NAME "im240a_eval"
00133 # define BOARD_TYPE BOARD_IM240A_EVAL
00134 #endif
00135
00136 #ifndef DEFAULT_SPI_RATE
00137 # define DEFAULT_SPI_RATE (SPI_RATE_1_2)
00138 #endif
00139
00140
00141 #define RADIO_TYPE (RADIO_AT86RF230B)
00142
00143
00144
00145 #define DDR_TRX_RESET DDRD
00146 #define PORT_TRX_RESET PORTD
00147 #define MASK_TRX_RESET (_BV(PD6))
00148 #define TRX_RESET_INIT() DDR_TRX_RESET |= MASK_TRX_RESET
00149 #define TRX_RESET_HIGH() PORT_TRX_RESET |= MASK_TRX_RESET
00150 #define TRX_RESET_LOW() PORT_TRX_RESET &= ~MASK_TRX_RESET
00151
00152 #define PORT_TRX_SLPTR PORTB
00153 #define DDR_TRX_SLPTR DDRB
00154 #define MASK_TRX_SLPTR (_BV(PB1))
00155
00156 #define TRX_SLPTR_INIT() DDR_TRX_SLPTR |= MASK_TRX_SLPTR
00157 #define TRX_SLPTR_HIGH() PORT_TRX_SLPTR |= MASK_TRX_SLPTR
00158 #define TRX_SLPTR_LOW() PORT_TRX_SLPTR &= ~MASK_TRX_SLPTR
00159
00160
00161
00162 # define TRX_IRQ_vect TIMER1_CAPT_vect
00170 # define TRX_IRQ_INIT() do{\
00171 \
00172 TCCR1B |= (_BV(ICNC1) | _BV(ICES1));\
00173 TIFR1 = _BV(ICF1);\
00174 } while(0)
00175
00177 #define DI_TRX_IRQ() {TIMSK1 &= ~_BV(ICIE1);}
00178
00180 #define EI_TRX_IRQ() {TIMSK1 |= _BV(ICIE1);}
00181
00183 #define TRX_TSTAMP_REG TCNT1
00184
00185 #define DDR_SPI (DDRB)
00186 #define PORT_SPI (PORTB)
00187
00188 #define SPI_MOSI _BV(PB3)
00189 #define SPI_MISO _BV(PB4)
00190 #define SPI_SCK _BV(PB5)
00191 #define SPI_SS _BV(PB2)
00192
00193 #define SPI_DATA_REG SPDR
00194
00195 static inline void SPI_INIT(uint8_t spirate)
00196 {
00197
00198 PORT_SPI |= SPI_SCK | SPI_SS;
00199 DDR_SPI |= SPI_MOSI | SPI_SCK | SPI_SS;
00200 DDR_SPI &= ~SPI_MISO;
00201
00202 SPCR = (_BV(SPE) | _BV(MSTR));
00203
00204 SPCR &= ~(_BV(SPR1) | _BV(SPR0) );
00205 SPSR &= ~_BV(SPI2X);
00206
00207 SPCR |= (spirate & 0x03);
00208 SPSR |= ((spirate >> 2) & 0x01);
00209
00210 }
00211
00212 #define SPI_SELN_LOW() uint8_t sreg = SREG; cli(); PORT_SPI &=~SPI_SS
00213 #define SPI_SELN_HIGH() PORT_SPI |= SPI_SS; SREG = sreg
00214 #define SPI_WAITFOR() do { while((SPSR & _BV(SPIF)) == 0);} while(0)
00215
00216
00217 #if (BOARD_TYPE == BOARD_IM240A_EVAL)
00218
00219
00220
00221
00222 # define LED_PORT PORTD
00223 # define LED_DDR DDRD
00224 # define LED_MASK (0x1c)
00225 # define LED_SHIFT (2)
00226 # define LED_NUMBER (3)
00227 # define LEDS_INVERSE (1)
00228 #else
00229 # define NO_LEDS (1)
00230 #endif
00231
00232
00233 #if (BOARD_TYPE == BOARD_IM240A_EVAL)
00234 # define PORT_KEY PORTC
00235 # define PIN_KEY PINC
00236 # define DDR_KEY DDRC
00237 # define MASK_KEY (0x07)
00238 # define SHIFT_KEY (0)
00239 # define INVERSE_KEYS (1)
00240 # define PULLUP_KEYS (1)
00241 #else
00242 # define NO_KEYS (1)
00243 #endif
00244
00245
00246
00247 #define HIF_TYPE HIF_UART_0
00248
00249
00250
00256 #define HWTMR_PRESCALE (1)
00257 #define HWTIMER_TICK ((1.0*HWTMR_PRESCALE)/F_CPU)
00258 #define HWTIMER_TICK_NB (0xFFFFUL)
00259 #define HWTIMER_REG (TCNT1)
00260 #define TIMER_TICK (HWTIMER_TICK_NB * HWTIMER_TICK)
00261 #define TIMER_POOL_SIZE (4)
00262 #define TIMER_INIT() \
00263 do{ \
00264 TCCR1B |= (_BV(CS10)); \
00265 TIMSK1 |= _BV(TOIE1); \
00266 }while(0)
00267 # define TIMER_IRQ_vect TIMER1_OVF_vect
00268
00269 #endif