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
00099 #if defined(stb230)
00100 # define BOARD_TYPE (BOARD_STB230)
00101 # define BOARD_NAME "stb230"
00102 # define RADIO_TYPE (RADIO_AT86RF230A)
00103 #elif defined(stb230b)
00104 # define BOARD_TYPE (BOARD_STB230B)
00105 # define BOARD_NAME "stb230b"
00106 # define RADIO_TYPE (RADIO_AT86RF230B)
00107 #elif defined(stb231)
00108 # define BOARD_TYPE (BOARD_STB231)
00109 # define BOARD_NAME "stb231"
00110 # define RADIO_TYPE (RADIO_AT86RF231)
00111 #elif defined(stb212)
00112 # define BOARD_TYPE (BOARD_STB212)
00113 # define BOARD_NAME "stb212"
00114 # define RADIO_TYPE (RADIO_AT86RF212)
00115 #elif defined(stb232)
00116 # define BOARD_TYPE (BOARD_STB232)
00117 # define BOARD_NAME "stb232"
00118 # define RADIO_TYPE (RADIO_AT86RF232)
00119 #elif defined(stb233)
00120 # define BOARD_TYPE (BOARD_STB233)
00121 # define BOARD_NAME "stb233"
00122 # define RADIO_TYPE (RADIO_AT86RF233)
00123 #endif
00124
00125 #ifndef BOARD_STB2XX_H
00126 #define BOARD_STB2XX_H
00127
00128
00129 #ifndef DEFAULT_SPI_RATE
00130 # define DEFAULT_SPI_RATE (SPI_RATE_1_2)
00131 #endif
00132
00133
00134 #if BOARD_TYPE == BOARD_STB230 || BOARD_TYPE == BOARD_STB230B
00135 # include "base_rdk230.h"
00136 #else
00137 # include "base_rdk2xx.h"
00138 #endif
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 static inline void hif_mmio_init(void)
00157 {
00158 DDRC |= 0xc0;
00159 PORTC = (PORTC & ~0xc0) | 0x80;
00160
00161 PORTG &= ~0x05;
00162
00163
00164
00165 PORTG |= 0x02;
00166 DDRG |= 0x07;
00167 }
00168
00169 static inline void hif_usb_write(uint8_t val)
00170 {
00171 DDRA = 0xFF;
00172 PORTA = val;
00173 PORTC = (PORTC & ~0xc0);
00174 __asm volatile("nop");
00175 PORTC = (PORTC & ~0xc0) | 0x80;
00176 DDRA = 0;
00177 PORTA = 0;
00178 }
00179
00180 static inline uint8_t hif_usb_read(void)
00181 {
00182 PORTG |= 0x01;
00183 PORTC = (PORTC & ~0xc0);
00184 PORTG &= ~0x02;
00185 PORTG |= 0x02;
00186 __asm volatile("nop");
00187 uint8_t rv = PINA;
00188 PORTC = (PORTC & ~0xc0) | 0x80;
00189 PORTG &= ~0x01;
00190
00191 return rv;
00192 }
00193
00194
00195 static inline void hif_led_write(uint8_t val)
00196 {
00197 PORTG |= 0x01;
00198 DDRA = 0xFF;
00199 PORTA = val;
00200 PORTC = (PORTC & ~0xc0) | 0x40;
00201 PORTG &= ~0x01;
00202 PORTG |= 0x01;
00203 __asm volatile("nop");
00204 PORTC = (PORTC & ~0xc0) | 0x80;
00205 DDRA = 0;
00206 PORTA = 0;
00207 PORTG &= ~0x01;
00208 }
00209
00210 static inline uint8_t hif_key_read(void)
00211 {
00212 PORTG |= 0x01;
00213 PORTC = (PORTC & ~0xc0) | 0x40;
00214 PORTG &= ~0x02;
00215 PORTG |= 0x02;
00216 __asm volatile("nop");
00217 uint8_t rv = PINA;
00218 PORTC = (PORTC & ~0xc0) | 0x80;
00219 PORTG &= ~0x01;
00220
00221 return rv;
00222 }
00223
00224
00225 #if !defined(USE_RCB_LEDS)
00226
00227
00228 # define LED_SHADOW GPIOR2
00229 # define LED_MASK (0x03)
00230 # define LED_SHIFT (0)
00231 # define LEDS_INVERSE (1)
00232 # define LED_NUMBER (2)
00233
00234 # define LED_INIT()\
00235 do{\
00236 hif_mmio_init(); \
00237 LED_SHADOW = LED_MASK;\
00238 hif_led_write(LED_SHADOW); \
00239 }while(0)
00240
00241 # define LED_SET_VALUE(x) \
00242 do{\
00243 LED_SHADOW = (LED_SHADOW & ~LED_MASK) | ((~x<<LED_SHIFT) & LED_MASK);\
00244 hif_led_write(LED_SHADOW);\
00245 }while(0)
00246
00247 # define LED_GET_VALUE()\
00248 ((~LED_SHADOW & LED_MASK) >> LED_SHIFT)
00249
00250 # define LED_SET(ln)\
00251 do{\
00252 LED_SHADOW &= ~(_BV(ln+LED_SHIFT) & LED_MASK);\
00253 hif_led_write(LED_SHADOW);\
00254 }while(0)
00255
00256 # define LED_CLR(ln)\
00257 do{\
00258 LED_SHADOW |= (_BV(ln+LED_SHIFT) & LED_MASK);\
00259 hif_led_write(LED_SHADOW);\
00260 }while(0)
00261
00262 # define LED_VAL(msk,val)\
00263 do{\
00264 LED_SHADOW &= ~(LED_MASK|(msk<<LED_SHIFT)); \
00265 LED_SHADOW |= ~(val & (LED_MASK|msk));\
00266 hif_led_write(LED_SHADOW);\
00267 }while(0)
00268
00269
00270 # define LED_TOGGLE(ln)\
00271 do{\
00272 LED_SHADOW ^= (_BV(ln+LED_SHIFT) & LED_MASK);\
00273 hif_led_write(LED_SHADOW);\
00274 }while(0)
00275
00276 #else
00277
00278 # define LED_PORT PORTE
00279 # define LED_DDR DDRE
00280 # define LED_MASK (0x1c)
00281 # define LED_SHIFT (2)
00282 # define LEDS_INVERSE (1)
00283 # define LED_NUMBER (3)
00284 #endif
00285
00286 #define PIN_KEY (hif_key_read())
00287 #define MASK_KEY (0x1)
00288 #define SHIFT_KEY (0)
00289 #define INVERSE_KEYS (0)
00290 #define PULLUP_KEYS (0)
00291 #define KEY_INIT hif_mmio_init
00292
00293
00294 #define HIF_TYPE (HIF_FT245)
00295 #define HIF_IO_ENABLE hif_mmio_init
00296 #define HIF_USB_READ() hif_usb_read()
00297 #define HIF_USB_WRITE(x) hif_usb_write(x)
00298 #define HIF_NO_DATA (0x0100)
00299 #define FT245_DDR DDRE
00300 #define FT245_PIN PINE
00301 #define FT245_TXE _BV(6)
00302 #define FT245_RXF _BV(7)
00303 #define FT245_INIT() do { \
00304 FT245_DDR &= ~(FT245_TXE|FT245_RXF);\
00305 } while(0)
00306
00307 #define FT245_TX_IS_BLOCKED() (0 != (FT245_PIN & FT245_TXE))
00308 #define FT245_RX_HAS_DATA() (0 == (FT245_PIN & FT245_RXF))
00309
00310
00311 #define HWTMR_PRESCALE (1)
00312 #define HWTIMER_TICK ((1.0*HWTMR_PRESCALE)/F_CPU)
00313 #define HWTIMER_TICK_NB (0xFFFFUL+1)
00314 #define HWTIMER_REG (TCNT1)
00315 #define TIMER_TICK (HWTIMER_TICK_NB * HWTIMER_TICK)
00316 #define TIMER_POOL_SIZE (4)
00317
00319 #define TIMER_IRQ_vect TIMER1_OVF_vect
00320
00330 # define TIMER_INIT() \
00331 do{ \
00332 TCCR1B |= _BV(CS10); \
00333 TIMSK1 |= _BV(TOIE1); \
00334 }while(0)
00335
00336 #endif