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
00118 #if defined(stb128rfa1)
00119 # define BOARD_TYPE (BOARD_STB128RFA1)
00120 # define BOARD_NAME "stb128rfa1"
00121 # define RADIO_TYPE (RADIO_ATMEGA128RFA1_C)
00122 #endif
00123
00124 #ifndef BOARD_STBRFA1_H
00125 #define BOARD_STBRFA1_H
00126
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 DDRD |= 0xc0;
00159 PORTD = (PORTD & ~0xc0) | 0x80;
00160
00161 PORTE &= ~0x10;
00162
00163 PORTE |= 0x20;
00164 DDRE |= 0x30;
00165 PORTG &= ~0x04;
00166
00167 DDRG |= 0x04;
00168 }
00169
00170 static inline void hif_usb_write(uint8_t val)
00171 {
00172 DDRB = 0xFF;
00173 PORTB = val;
00174 PORTD = (PORTD & ~0xc0);
00175 __asm volatile("nop");
00176 PORTD = (PORTD & ~0xc0) | 0x80;
00177 DDRB = 0;
00178 PORTB = 0;
00179 }
00180
00181 static inline uint8_t hif_usb_read(void)
00182 {
00183 PORTE |= 0x10;
00184 PORTD = (PORTD & ~0xc0);
00185 PORTE &= ~0x20;
00186 PORTE |= 0x20;
00187 __asm volatile("nop");
00188 uint8_t rv = PINB;
00189 PORTD = (PORTD & ~0xc0) | 0x80;
00190 PORTE &= ~0x10;
00191
00192 return rv;
00193 }
00194
00195
00196 static inline void hif_led_write(uint8_t val)
00197 {
00198 PORTE |= 0x10;
00199 DDRB = 0xFF;
00200 PORTB = val;
00201 PORTD = (PORTD & ~0xc0) | 0x40;
00202 PORTE &= ~0x10;
00203 PORTE |= 0x10;
00204 __asm volatile("nop");
00205 PORTD = (PORTD & ~0xc0) | 0x80;
00206 DDRB = 0;
00207 PORTB = 0;
00208 PORTE &= ~0x10;
00209 }
00210
00211 static inline uint8_t hif_key_read(void)
00212 {
00213 PORTE |= 0x10;
00214 PORTD = (PORTD & ~0xc0) | 0x40;
00215 PORTE &= ~0x20;
00216 PORTE |= 0x20;
00217 __asm volatile("nop");
00218 uint8_t rv = PINB;
00219 PORTD = (PORTD & ~0xc0) | 0x80;
00220 PORTE &= ~0x10;
00221
00222 return rv;
00223 }
00224
00225
00226
00227
00228 #if !defined(USE_RCB_LEDS)
00229
00230
00231 # define LED_SHADOW GPIOR2
00232 # define LED_MASK (0x03)
00233 # define LED_SHIFT (0)
00234 # define LEDS_INVERSE (1)
00235 # define LED_NUMBER (2)
00236
00237 # define LED_INIT()\
00238 do{\
00239 hif_mmio_init(); \
00240 LED_SHADOW = LED_MASK;\
00241 hif_led_write(LED_SHADOW); \
00242 }while(0)
00243
00244 # define LED_SET_VALUE(x) \
00245 do{\
00246 LED_SHADOW = (LED_SHADOW & ~LED_MASK) | ((~x<<LED_SHIFT) & LED_MASK);\
00247 hif_led_write(LED_SHADOW);\
00248 }while(0)
00249
00250 # define LED_GET_VALUE()\
00251 ((~LED_SHADOW & LED_MASK) >> LED_SHIFT)
00252
00253 # define LED_SET(ln)\
00254 do{\
00255 LED_SHADOW &= ~(_BV(ln+LED_SHIFT) & LED_MASK);\
00256 hif_led_write(LED_SHADOW);\
00257 }while(0)
00258
00259 # define LED_CLR(ln)\
00260 do{\
00261 LED_SHADOW |= (_BV(ln+LED_SHIFT) & LED_MASK);\
00262 hif_led_write(LED_SHADOW);\
00263 }while(0)
00264
00265 # define LED_VAL(msk,val)\
00266 do{\
00267 LED_SHADOW &= ~(LED_MASK|(msk<<LED_SHIFT)); \
00268 LED_SHADOW |= ~(val & (LED_MASK|msk));\
00269 hif_led_write(LED_SHADOW);\
00270 }while(0)
00271
00272
00273 # define LED_TOGGLE(ln)\
00274 do{\
00275 LED_SHADOW ^= (_BV(ln+LED_SHIFT) & LED_MASK);\
00276 hif_led_write(LED_SHADOW);\
00277 }while(0)
00278
00279 #else
00280
00281 # define LED_PORT PORTE
00282 # define LED_DDR DDRE
00283 # define LED_MASK (0x1c)
00284 # define LED_SHIFT (2)
00285 # define LEDS_INVERSE (1)
00286 # define LED_NUMBER (3)
00287 #endif
00288
00289 #define PIN_KEY (hif_key_read())
00290 #define MASK_KEY (0x1)
00291 #define SHIFT_KEY (0)
00292 #define INVERSE_KEYS (0)
00293 #define PULLUP_KEYS (0)
00294 #define KEY_INIT hif_mmio_init
00295
00296
00297 #define HIF_TYPE (HIF_FT245)
00298 #define HIF_IO_ENABLE hif_mmio_init
00299 #define HIF_USB_READ() hif_usb_read()
00300 #define HIF_USB_WRITE(x) hif_usb_write(x)
00301 #define HIF_NO_DATA (0x0100)
00302 #define FT245_DDR DDRE
00303 #define FT245_PIN PINE
00304 #define FT245_TXE _BV(6)
00305 #define FT245_RXF _BV(7)
00306 #define FT245_INIT() do { \
00307 FT245_DDR &= ~(FT245_TXE|FT245_RXF);\
00308 } while(0)
00309
00310 #define FT245_TX_IS_BLOCKED() (0 != (FT245_PIN & FT245_TXE))
00311 #define FT245_RX_HAS_DATA() (0 == (FT245_PIN & FT245_RXF))
00312
00313
00314 #define HWTMR_PRESCALE (1)
00315 #define HWTIMER_TICK ((1.0*HWTMR_PRESCALE)/F_CPU)
00316 #define HWTIMER_TICK_NB (0xFFFFUL+1)
00317 #define HWTIMER_REG (TCNT1)
00318 #define TIMER_TICK (HWTIMER_TICK_NB * HWTIMER_TICK)
00319 #define TIMER_POOL_SIZE (4)
00320
00322 #define TIMER_IRQ_vect TIMER1_OVF_vect
00323
00333 # define TIMER_INIT() \
00334 do{ \
00335 TCCR1B |= _BV(CS10); \
00336 TIMSK1 |= _BV(TOIE1); \
00337 }while(0)
00338
00339 #endif