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
00088 #ifndef BOARD_MUSE231_H
00089 #define BOARD_MUSE231_H (1)
00090
00092 # define BOARD_TYPE (BOARD_MUSE231)
00093 # define BOARD_NAME "Multisensor 231"
00094 # define RADIO_TYPE (RADIO_AT86RF231)
00096
00097
00098 #ifndef DEFAULT_SPI_RATE
00099 # define DEFAULT_SPI_RATE (SPI_RATE_1_2)
00100 #endif
00101
00102
00103
00104
00105
00106 #define DDR_TRX_RESET DDRC
00107 #define PORT_TRX_RESET PORTC
00108 #define MASK_TRX_RESET ((1<<1))
00109
00110
00111
00112 #define PORT_TRX_SLPTR PORTC
00113 #define DDR_TRX_SLPTR DDRC
00114 #define MASK_TRX_SLPTR ((1<<0))
00115
00116
00117
00118
00119
00120
00121 #define ACC_IRQ_DDR DDRD
00122 #define ACC_IRQ_PORT PORTD
00123 #define ACC_IRQ_PIN PIND
00124 #define ACC_IRQ_bp (2)
00125 #define ACC_IRQ_ASIN() do{ ACC_IRQ_DDR &= ~(1<<ACC_IRQ_bp); }while(0)
00126 #define ACC_IRQ_ASOUT() do{ ACC_IRQ_DDR |= (1<<ACC_IRQ_bp); }while(0)
00127 #define ACC_IRQ_LO() do{ ACC_IRQ_PORT &= ~(1<<ACC_IRQ_bp); }while(0)
00128 #define ACC_IRQ_HI() do{ ACC_IRQ_PORT |= (1<<ACC_IRQ_bp); }while(0)
00129 #define ACC_IRQ_STATE() ( (ACC_IRQ_PIN & (1<<ACC_IRQ_bp)) != 0)
00130
00131
00132
00133 #define TRX_IRQ_PORT (PORTD)
00134 #define TRX_IRQ_DDR (DDRD)
00135 #define TRX_IRQ_PIN (PIND)
00136 #define TRX_IRQ_bp (5)
00137
00138 # define TRX_IRQ 0x00
00139 # define TRX_IRQ_vect PCINT2_vect
00140 # define ACC_IRQ_vect INT0_vect
00145 # define TRX_IRQ_INIT() do{ PCICR |= (1<<PCIE2); } while(0)
00146
00147 #define DI_TRX_IRQ() { PCMSK2 &= ~(1<<PCINT21); }
00148
00149 #define EI_TRX_IRQ() { PCMSK2 |= (1<<PCINT21); }
00150
00151
00152 #define SPI_TYPE SPI_TYPE_SPI
00153 #define DDR_SPI (DDRB)
00154 #define PORT_SPI (PORTB)
00156 #define SPI_MOSI (1<<PB3)
00157 #define SPI_MISO (1<<PB4)
00158 #define SPI_SCK (1<<PB5)
00159 #define SPI_SS (1<<PB0)
00162 #define SPI_DATA_REG SPDR
00168 static inline void SPI_INIT(uint8_t spirate)
00169 {
00170
00171
00172
00173 PORT_SPI |= (1<<PB2);
00174
00175 PORT_SPI |= SPI_SS | SPI_MISO | SPI_MOSI | SPI_SCK;
00176 DDR_SPI |= SPI_MOSI | SPI_SCK | SPI_SS;
00177 DDR_SPI &= ~SPI_MISO;
00178
00179 SPCR = ((1<<SPE) | (1<<MSTR));
00180
00181 SPCR &= ~((1<<SPR1) | (1<<SPR0) );
00182 SPSR &= ~(1<<SPI2X);
00183
00184 SPCR |= (spirate & 0x03);
00185 SPSR |= ((spirate >> 2) & 0x01);
00186 }
00187
00189 #define SPI_SELN_LOW() uint8_t sreg = SREG; cli(); PORT_SPI &=~SPI_SS
00190
00191 #define SPI_SELN_HIGH() PORT_SPI |= SPI_SS; SREG = sreg
00192
00193 #define SPI_WAITFOR() do { while((SPSR & (1<<SPIF)) == 0);} while(0)
00194
00195
00196
00197 #define LED_PORT PORTD
00198 #define LED_DDR DDRD
00199 #define LED_MASK (0x08)
00200 #define LED_SHIFT (3)
00201 #define LEDS_INVERSE (0)
00203 #define LED_NUMBER (1)
00205
00206 #define LED_PIN PIND
00207 #define LED_ANODE_bp (3)
00208 #define LED_CATHODE_bp (4)
00210
00211 #define LED_INIT() do{ LED_PORT &= ~((1<<LED_CATHODE_bp) | (1<<LED_ANODE_bp)); \
00212 LED_DDR |= ((1<<LED_CATHODE_bp) | (1<<LED_ANODE_bp)); }while(0)
00213
00214
00215 #define NO_KEYS (1)
00217
00218
00219 #define HIF_TYPE HIF_NONE
00220
00221
00222
00223
00224
00225 #define HWTMR_PRESCALE (8)
00226 #define HWTIMER_TICK ((1.0*HWTMR_PRESCALE)/F_CPU)
00227 #define HWTIMER_TICK_NB (1000UL)
00228 #define HWTIMER_REG (TCNT1)
00229 #define TIMER_TICK (HWTIMER_TICK_NB * HWTIMER_TICK)
00230 #define TIMER_POOL_SIZE (4)
00231 #define TIMER_INIT() \
00232 do{ \
00233 TCCR1B = 0; \
00234 OCR1A = HWTIMER_TICK_NB; \
00235 TCCR1B |= ((1<<WGM12) | (1<<CS11)); \
00236 TIMSK1 |= (1<<OCIE1A); \
00237 }while(0)
00238 # define TIMER_IRQ_vect TIMER1_COMPA_vect
00239
00240
00241
00242 #endif