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
00076 #ifndef BOARD_STK_M8_H
00077 #define BOARD_STK_M8_H
00078
00079 #define BOARD_TYPE (BOARD_STKM8)
00080 #define BOARD_NAME "stkm8"
00081
00082
00083 #ifndef DEFAULT_SPI_RATE
00084 # define DEFAULT_SPI_RATE (SPI_RATE_1_2)
00085 #endif
00086
00087
00088 #define RADIO_TYPE (RADIO_AT86RF230B)
00089
00090
00091
00092 #define DDR_TRX_RESET DDRD
00093 #define PORT_TRX_RESET PORTD
00094 #define MASK_TRX_RESET (_BV(PD6))
00095 #define TRX_RESET_INIT() DDR_TRX_RESET |= MASK_TRX_RESET
00096 #define TRX_RESET_HIGH() PORT_TRX_RESET |= MASK_TRX_RESET
00097 #define TRX_RESET_LOW() PORT_TRX_RESET &= ~MASK_TRX_RESET
00098
00099 #define PORT_TRX_SLPTR PORTD
00100 #define DDR_TRX_SLPTR DDRD
00101 #define MASK_TRX_SLPTR (_BV(PD7))
00102
00103 #define TRX_SLPTR_INIT() DDR_TRX_SLPTR |= MASK_TRX_SLPTR
00104 #define TRX_SLPTR_HIGH() PORT_TRX_SLPTR |= MASK_TRX_SLPTR
00105 #define TRX_SLPTR_LOW() PORT_TRX_SLPTR &= ~MASK_TRX_SLPTR
00106
00107
00108
00109 # define TRX_IRQ_vect TIMER1_CAPT_vect
00115 # define TRX_IRQ_INIT() do{\
00116 \
00117 TCCR1B |= (_BV(ICNC1) | _BV(ICES1));\
00118 TIFR = _BV(ICF1);\
00119 } while(0)
00120
00122 #define DI_TRX_IRQ() {TIMSK &= ~_BV(TICIE1);}
00123
00125 #define EI_TRX_IRQ() {TIMSK |= _BV(TICIE1);}
00126
00128 #define TRX_TSTAMP_REG TCNT1
00129
00130 #define DDR_SPI (DDRB)
00131 #define PORT_SPI (PORTB)
00132
00133 #define SPI_MOSI _BV(PB3)
00134 #define SPI_MISO _BV(PB4)
00135 #define SPI_SCK _BV(PB5)
00136 #define SPI_SS _BV(PB2)
00137
00138 #define SPI_DATA_REG SPDR
00139
00140 static inline void SPI_INIT(uint8_t spirate)
00141 {
00142
00143 PORT_SPI |= SPI_SCK | SPI_SS;
00144 DDR_SPI |= SPI_MOSI | SPI_SCK | SPI_SS;
00145 DDR_SPI &= ~SPI_MISO;
00146
00147 SPCR = (_BV(SPE) | _BV(MSTR));
00148
00149 SPCR &= ~(_BV(SPR1) | _BV(SPR0) );
00150 SPSR &= ~_BV(SPI2X);
00151
00152 SPCR |= (spirate & 0x03);
00153 SPSR |= ((spirate >> 2) & 0x01);
00154
00155 }
00156
00157 #define SPI_SELN_LOW() uint8_t sreg = SREG; cli(); PORT_SPI &=~SPI_SS
00158 #define SPI_SELN_HIGH() PORT_SPI |= SPI_SS; SREG = sreg
00159 #define SPI_WAITFOR() do { while((SPSR & _BV(SPIF)) == 0);} while(0)
00160
00161
00162 #define LED_PORT PORTC
00163 #define LED_DDR DDRC
00164 #define LED_MASK (0x03)
00165 #define LED_SHIFT (0)
00166 #define LED_NUMBER (2)
00167 #define LEDS_INVERSE (1)
00168
00169
00170 #define PORT_KEY PORTD
00171 #define PIN_KEY PIND
00172 #define DDR_KEY DDRD
00173 #define MASK_KEY (0x0c)
00174 #define SHIFT_KEY (2)
00175 #define INVERSE_KEYS (1)
00176 #define PULLUP_KEYS (1)
00177
00178
00179 #define HIF_TYPE HIF_UART_0
00180
00181
00182
00188 #define HWTMR_PRESCALE (1)
00189 #define HWTIMER_TICK ((1.0*HWTMR_PRESCALE)/F_CPU)
00190 #define HWTIMER_TICK_NB (0xFFFFUL)
00191 #define HWTIMER_REG (TCNT1)
00192 #define TIMER_TICK (HWTIMER_TICK_NB * HWTIMER_TICK)
00193 #define TIMER_POOL_SIZE (4)
00194 #define TIMER_INIT() \
00195 do{ \
00196 TCCR1B |= (_BV(CS10)); \
00197 TIMSK |= _BV(TOIE1); \
00198 }while(0)
00199 # define TIMER_IRQ_vect TIMER1_OVF_vect
00200
00201 #endif