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
00030
00031
00081 #if defined(lgee231)
00082 # define BOARD_TYPE (BOARD_LGEE231)
00083 # define BOARD_NAME "littleGee/v3"
00084 # define RADIO_TYPE (RADIO_AT86RF231)
00085 # define BOARDVERSION (3)
00086 #elif defined(lgee231_v2)
00087 # define BOARD_TYPE (BOARD_LGEE231_V2)
00088 # define BOARD_NAME "littleGee/v2"
00089 # define RADIO_TYPE (RADIO_AT86RF231)
00090 # define BOARDVERSION (2)
00091 #endif
00092
00093 #ifndef BOARD_LGEE231_H
00094 #define BOARD_LGEE231_H (1)
00095
00096
00097 #ifndef DEFAULT_SPI_RATE
00098 # define DEFAULT_SPI_RATE (SPI_RATE_1_2)
00099 #endif
00100
00101
00102
00103
00104
00105 #if BOARDVERSION == 2
00106
00107 #define DDR_TRX_RESET DDRC
00108 #define PORT_TRX_RESET PORTC
00109 #define MASK_TRX_RESET ((1<<1))
00110
00111
00112
00113 #define PORT_TRX_SLPTR PORTC
00114 #define DDR_TRX_SLPTR DDRC
00115 #define MASK_TRX_SLPTR ((1<<0))
00116
00117
00118
00119 #elif BOARDVERSION == 3
00120
00121 #define DDR_TRX_RESET DDRC
00122 #define PORT_TRX_RESET PORTC
00123 #define MASK_TRX_RESET ((1<<3))
00124
00125
00126
00127 #define PORT_TRX_SLPTR PORTC
00128 #define DDR_TRX_SLPTR DDRC
00129 #define MASK_TRX_SLPTR ((1<<0))
00130
00131
00132
00133 #else
00134 #error "Unknown BOARDVERSION, set to 2 or 3"
00135
00136 #endif
00137
00138
00139
00140
00141
00142 #if BOARDVERSION == 2
00143
00144 #define ACC_SELN_DDR DDRB
00145 #define ACC_SELN_PORT PORTB
00146 #define ACC_SELN_PIN PINB
00147 #define ACC_SELN_bp (2)
00148 #define ACC_SELN_ASIN() do{ ACC_SELN_DDR &= ~(1<<ACC_SELN_bp); }while(0)
00149 #define ACC_SELN_ASOUT() do{ ACC_SELN_DDR |= (1<<ACC_SELN_bp); }while(0)
00150 #define ACC_SELN_LO() do{ ACC_SELN_PORT &= ~(1<<ACC_SELN_bp); }while(0)
00151 #define ACC_SELN_HI() do{ ACC_SELN_PORT |= (1<<ACC_SELN_bp); }while(0)
00152
00153 #elif BOARDVERSION == 3
00154
00155 #define ACC_SELN_DDR DDRD
00156 #define ACC_SELN_PORT PORTD
00157 #define ACC_SELN_PIN PIND
00158 #define ACC_SELN_bp (6)
00159 #define ACC_SELN_ASIN() do{ ACC_SELN_DDR &= ~(1<<ACC_SELN_bp); }while(0)
00160 #define ACC_SELN_ASOUT() do{ ACC_SELN_DDR |= (1<<ACC_SELN_bp); }while(0)
00161 #define ACC_SELN_LO() do{ ACC_SELN_PORT &= ~(1<<ACC_SELN_bp); }while(0)
00162 #define ACC_SELN_HI() do{ ACC_SELN_PORT |= (1<<ACC_SELN_bp); }while(0)
00163
00164 #define ACC_IRQ_DDR DDRD
00165 #define ACC_IRQ_PORT PORTD
00166 #define ACC_IRQ_PIN PIND
00167 #define ACC_IRQ_bp (7)
00168 #define ACC_IRQ_ASIN() do{ ACC_IRQ_DDR &= ~(1<<ACC_IRQ_bp); }while(0)
00169 #define ACC_IRQ_ASOUT() do{ ACC_IRQ_DDR |= (1<<ACC_IRQ_bp); }while(0)
00170 #define ACC_IRQ_LO() do{ ACC_IRQ_PORT &= ~(1<<ACC_IRQ_bp); }while(0)
00171 #define ACC_IRQ_HI() do{ ACC_IRQ_PORT |= (1<<ACC_IRQ_bp); }while(0)
00172 #define ACC_IRQ_STATE() ( (ACC_IRQ_PIN & (1<<ACC_IRQ_bp)) != 0)
00173
00174 #else
00175 #error "Unknown BOARDVERSION, set to 2 or 3"
00176
00177 #endif
00178
00179
00180
00181 #if BOARDVERSION == 2
00182
00183 # define TRX_IRQ 0x00
00184 # define TRX_IRQ_vect PCINT2_vect
00189 # define TRX_IRQ_INIT() do{ PCICR |= (1<<PCIE2); } while(0)
00190
00192 #define DI_TRX_IRQ() { PCMSK2 &= ~(1<<PCINT18); }
00193
00194 #define EI_TRX_IRQ() { PCICR |= (1<<PCIE2); PCMSK2 |= (1<<PCINT18); }
00195
00196 #elif BOARDVERSION == 3
00197
00198 #define TRX_IRQ_PORT (PORTB)
00199 #define TRX_IRQ_DDR (DDRB)
00200 #define TRX_IRQ_PIN (PINB)
00201 #define TRX_IRQ_bp (1)
00202
00203 # define TRX_IRQ 0x00
00204 # define TRX_IRQ_vect PCINT0_vect
00205 # define ACC_IRQ_vect PCINT2_vect
00210 # define TRX_IRQ_INIT() do{ PCICR |= (1<<PCIE0); } while(0)
00211
00212 #define DI_TRX_IRQ() { PCMSK0 &= ~(1<<PCINT1); }
00213
00214 #define EI_TRX_IRQ() { PCMSK0 |= (1<<PCINT1); }
00215
00217 #define ACC_IRQ_INIT() do{ PCICR |= (1<<PCIE2); }while(0)
00218
00219 #define EI_ACC_IRQ() do{ PCMSK2 |= (1<<PCINT23); }while(0)
00220
00221 #define DI_ACC_IRQ() do{ PCMSK2 &= ~(1<<PCINT23); }while(0)
00222
00223 #else
00224 #error "Unknown BOARDVERSION, set to 2 or 3"
00225
00226 #endif
00227
00228
00230 #define TRX_TSTAMP_REG TCNT1
00231
00232
00233 #define SPI_TYPE SPI_TYPE_SPI
00234 #define DDR_SPI (DDRB)
00235 #define PORT_SPI (PORTB)
00237 #if BOARDVERSION == 2
00238
00239 #define SPI_MOSI (1<<PB3)
00240 #define SPI_MISO (1<<PB4)
00241 #define SPI_SCK (1<<PB5)
00242 #define SPI_SS (1<<PB0)
00244 #elif BOARDVERSION == 3
00245
00246 #define SPI_MOSI (1<<PB3)
00247 #define SPI_MISO (1<<PB4)
00248 #define SPI_SCK (1<<PB5)
00249 #define SPI_SS (1<<PB2)
00251 #else
00252 #error "Unknown BOARDVERSION, set to 2 or 3"
00253
00254 #endif
00255
00256
00257 #define SPI_DATA_REG SPDR
00263 static inline void SPI_INIT(uint8_t spirate)
00264 {
00265
00266 DDR_SPI |= SPI_MOSI | SPI_SCK | SPI_SS;
00267 DDR_SPI &= ~SPI_MISO;
00268 PORT_SPI |= SPI_SCK | SPI_SS;
00269
00270 SPCR = ((1<<SPE) | (1<<MSTR));
00271
00272 SPCR &= ~((1<<SPR1) | (1<<SPR0) );
00273 SPSR &= ~(1<<SPI2X);
00274
00275 SPCR |= (spirate & 0x03);
00276 SPSR |= ((spirate >> 2) & 0x01);
00277
00278 }
00279
00281 #define SPI_SELN_LOW() uint8_t sreg = SREG; cli(); PORT_SPI &=~SPI_SS
00282
00283 #define SPI_SELN_HIGH() PORT_SPI |= SPI_SS; SREG = sreg
00284
00285 #define SPI_WAITFOR() do { while((SPSR & (1<<SPIF)) == 0);} while(0)
00286
00287
00288
00289 #if BOARDVERSION == 2
00290
00291 #define LED_PORT PORTD
00292 #define LED_DDR DDRD
00293 #define LED_MASK (0x60)
00294 #define LED_SHIFT (5)
00295 #define LEDS_INVERSE (1)
00297 #define LED_NUMBER (2)
00299 #elif BOARDVERSION == 3
00300
00301 #define LED_PORT PORTC
00302 #define LED_DDR DDRC
00303 #define LED_MASK (0x30)
00304 #define LED_SHIFT (4)
00305 #define LEDS_INVERSE (1)
00307 #define LED_NUMBER (2)
00309 #else
00310 #error "Unknown BOARDVERSION, set to 2 or 3"
00311
00312 #endif
00313
00314
00315
00316 #define NO_KEYS (1)
00318
00319
00320 #if BOARDVERSION == 2
00321 #define HIF_TYPE HIF_NONE
00322 #elif BOARDVERSION == 3
00323 #define HIF_TYPE (HIF_UART_0)
00324 #else
00325 #error "Unknown BOARDVERSION, set to 2 or 3"
00326
00327 #endif
00328
00329
00330 #define HWTMR_PRESCALE (1)
00331 #define HWTIMER_TICK ((1.0*HWTMR_PRESCALE)/F_CPU)
00332 #define HWTIMER_TICK_NB (0xFFFFUL)
00333 #define HWTIMER_REG (TCNT1)
00334 #define TIMER_TICK (HWTIMER_TICK_NB * HWTIMER_TICK)
00335 #define TIMER_POOL_SIZE (4)
00336 #define TIMER_INIT() \
00337 do{ \
00338 TCCR1B |= ((1<<CS10)); \
00339 TIMSK1 |= (1<<TOIE1); \
00340 }while(0)
00341 # define TIMER_IRQ_vect TIMER1_OVF_vect
00342
00343
00344
00345 #endif