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
00054 #ifndef BOARD_IBDT_H
00055 #define BOARD_IBDT_H
00056
00057
00058
00059 #if defined(ibdt212)
00060
00061 #define BOARD_TYPE BOARD_IBDT212
00062 #define BOARD_NAME "ibdt212"
00063 #ifndef RADIO_TYPE
00064 #define RADIO_TYPE (RADIO_AT86RF212)
00065 #endif
00066
00067 #elif defined(ibdt231)
00068
00069 #define BOARD_TYPE BOARD_IBDT231
00070 #define BOARD_NAME "ibdt231"
00071 #ifndef RADIO_TYPE
00072 #define RADIO_TYPE (RADIO_AT86RF231)
00073 #endif
00074
00075 #elif defined(ibdt232)
00076
00077 #define BOARD_TYPE BOARD_IBDT232
00078 #define BOARD_NAME "ibdt232"
00079 #ifndef RADIO_TYPE
00080 #define RADIO_TYPE (RADIO_AT86RF232)
00081 #endif
00082
00083 #else
00084 #error "Unsupported BOARD_TYPE"
00085 #endif
00086
00087
00088
00089 #ifndef DEFAULT_SPI_RATE
00090 # define DEFAULT_SPI_RATE (SPI_RATE_1_2)
00091 #endif
00092
00093
00094
00095 #define DDR_TRX_RESET DDRD
00096 #define PORT_TRX_RESET PORTD
00097 #define MASK_TRX_RESET (_BV(PD6))
00098
00099
00100
00101 #define PORT_TRX_SLPTR PORTD
00102 #define DDR_TRX_SLPTR DDRD
00103 #define MASK_TRX_SLPTR (_BV(PD7))
00104
00105
00106
00107
00108 # define TRX_IRQ _BV(INT2)
00109 # define TRX_IRQ_vect INT2_vect
00112 # define TRX_IRQ_INIT() do{\
00113 EICRA = _BV(ISC20) | _BV(ISC21);\
00114 EIMSK |= (TRX_IRQ);\
00115 } while(0)
00118 #define DI_TRX_IRQ() {EIMSK &= (~(TRX_IRQ));}
00119
00120 #define EI_TRX_IRQ() {EIMSK |= (TRX_IRQ);}
00121
00123 #define TRX_TSTAMP_REG TCNT1
00124
00125
00126 #define SPI_TYPE SPI_TYPE_SPI
00127 #define DDR_SPI (DDRB)
00128 #define PORT_SPI (PORTB)
00130 #define SPI_MOSI _BV(PB5)
00131 #define SPI_MISO _BV(PB6)
00132 #define SPI_SCK _BV(PB7)
00133 #define SPI_SS _BV(PB4)
00135 #define SPI_DATA_REG SPDR
00141 static inline void SPI_INIT(uint8_t spirate)
00142 {
00143
00144 DDR_SPI |= SPI_MOSI | SPI_SCK | SPI_SS;
00145 DDR_SPI &= ~SPI_MISO;
00146 PORT_SPI |= SPI_SCK | SPI_SS;
00147
00148 SPCR = (_BV(SPE) | _BV(MSTR));
00149
00150 SPCR &= ~(_BV(SPR1) | _BV(SPR0) );
00151 SPSR &= ~_BV(SPI2X);
00152
00153 SPCR |= (spirate & 0x03);
00154 SPSR |= ((spirate >> 2) & 0x01);
00155
00156 }
00157
00159 #define SPI_SELN_LOW() uint8_t sreg = SREG; cli(); PORT_SPI &=~SPI_SS
00160
00161 #define SPI_SELN_HIGH() PORT_SPI |= SPI_SS; SREG = sreg
00162
00163 #define SPI_WAITFOR() do { while((SPSR & _BV(SPIF)) == 0);} while(0)
00164
00165
00166 #define LED_PORT PORTD
00167 #define LED_DDR DDRD
00168 #define LED_MASK (0x30)
00169 #define LED_SHIFT (4)
00170 #define LEDS_INVERSE (1)
00172 #define LED_NUMBER (2)
00175
00176
00177 #define PORT_KEY PORTD
00178 #define PIN_KEY PIND
00179 #define DDR_KEY DDRD
00180 #define MASK_KEY (0x0C)
00181 #define SHIFT_KEY (2)
00182 #define INVERSE_KEYS (1)
00184 #define PULLUP_KEYS (1)
00185
00186 #define SLEEP_ON_KEY_INIT() \
00187 do{\
00188 PCMSK0 |= _BV(PCINT2);\
00189 }while(0)
00190
00191 #define SLEEP_ON_KEY() \
00192 do{\
00193 EIMSK |= _BV(PCIE0);\
00194 set_sleep_mode(SLEEP_MODE_PWR_DOWN);\
00195 sleep_mode();\
00196 EIMSK &= ~_BV(PCIE0);\
00197 } while(0)
00198
00199 #define SLEEP_ON_KEY_vect PCINT0_vect
00200
00201
00202
00204 #define HIF_TYPE HIF_UART_0
00205
00206
00207
00208 #define HWTMR_PRESCALE (64)
00209 #define HWTIMER_TICK ((1.0*HWTMR_PRESCALE)/F_CPU)
00212 #define HWTIMER_TICK_NB (0.001/HWTIMER_TICK)
00214 #define HWTIMER_REG (TCNT1)
00216 #define TIMER_TICK (HWTIMER_TICK * HWTIMER_TICK_NB)
00217
00220 #define TIMER_POOL_SIZE (8)
00223 #define TIMER_INIT() \
00224 do{\
00225 TCCR0B = _BV(CS01) | _BV(CS00);\
00226 TCCR0B |= _BV(WGM02); \
00227 OCR0A = HWTIMER_TICK_NB; \
00228 TIMSK0 |= _BV(OCIE0A);\
00229 }while(0)
00230
00232 #define TIMER_IRQ_vect TIMER0_COMPA_vect
00233
00234 #endif