- Main Page
- Related Pages
- Modules
- Data Structures
- Files

# board_stb.h

Go to the documentation of this file.

    00001 /* Copyright (c) 2008 Axel Wachtler
    00002    All rights reserved.
    00003
    00004    Redistribution and use in source and binary forms, with or without
    00005    modification, are permitted provided that the following conditions
    00006    are met:
    00007
    00008    * Redistributions of source code must retain the above copyright
    00009      notice, this list of conditions and the following disclaimer.
    00010    * Redistributions in binary form must reproduce the above copyright
    00011      notice, this list of conditions and the following disclaimer in the
    00012      documentation and/or other materials provided with the distribution.
    00013    * Neither the name of the authors nor the names of its contributors
    00014      may be used to endorse or promote products derived from this software
    00015      without specific prior written permission.
    00016
    00017    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    00018    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    00019    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    00020    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    00021    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    00022    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    00023    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    00024    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    00025    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    00026    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    00027    POSSIBILITY OF SUCH DAMAGE. */
    00028
    00029 /* $Id: board_stb.h,v 1.12 2009/05/18 05:26:26 awachtler Exp $ */
    00099 #if defined(stb230)
    00100 # define BOARD_TYPE (STB_230)
    00101 # define BOARD_NAME_STB2XX "stb230"
    00102 # define RADIO_TYPE (RADIO_AT86RF230A)
    00103 #elif defined(stb230b)
    00104 # define BOARD_TYPE (STB_230B)
    00105 # define BOARD_NAME_STB2XX "stb230b"
    00106 # define RADIO_TYPE (RADIO_AT86RF230B)
    00107 #elif defined(stb231)
    00108 # define BOARD_TYPE (STB_231)
    00109 # define BOARD_NAME_STB2XX "stb231"
    00110 # define RADIO_TYPE (RADIO_AT86RF231)
    00111 #elif defined(stb212)
    00112 # define BOARD_TYPE (STB_212)
    00113 # define BOARD_NAME_STB2XX "stb212"
    00114 # define RADIO_TYPE (RADIO_AT86RF212)
    00115 #endif
    00116
    00117 #ifndef BOARD_STB2XX_H
    00118 #define BOARD_STB2XX_H
    00119 #define BOARD_NAME BOARD_NAME_STB2XX
    00120
    00121 /*=== Compile time parameters ========================================*/
    00122 #ifndef MAX_FRAME_SIZE
    00123 # define MAX_FRAME_SIZE (127)
    00124 #endif
    00125
    00126 #ifndef DEFAULT_SPI_RATE
    00127 # define DEFAULT_SPI_RATE  (SPI_RATE_1_2)
    00128 #endif
    00129
    00130 /*=== radio interface definition =====================================*/
    00131 #if BOARD_TYPE == STB_230 || BOARD_TYPE == STB_230B
    00132 # include "base_rdk230.h"
    00133 #else
    00134 # include "base_rdk2xx.h"
    00135 #endif
    00136
    00137 static inline void xmem_init(void)
    00138 {
    00139     XMCRA |= _BV(SRE);
    00140     XMCRB |= _BV(XMBK);
    00141 }
    00142
    00143
    00144 /*=== LED access macros ==============================================*/
    00145 #if !defined(USE_RCB_LEDS)
    00146 /*=== use LEDs on STB (Memory Mapped) ===*/
    00147 # define LED_IO_AD     (0x4000)
    00148
    00149 # define LED_PORT      (*((volatile uint8_t *)(LED_IO_AD)))
    00150 # define LED_SHADOW    GPIOR2
    00151 # define LED_MASK      (0x03)
    00152 # define LED_SHIFT     (0)
    00153 # define LEDS_INVERSE  (1)
    00154 # define LED_NUMBER    (2)
    00155
    00156 # define LED_INIT()\
    00157         do{\
    00158             xmem_init(); \
    00159             LED_SHADOW = LED_MASK;\
    00160             LED_PORT = LED_SHADOW;\
    00161         }while(0)
    00162
    00163 # define LED_SET_VALUE(x) \
    00164         do{\
    00165             LED_SHADOW = (LED_SHADOW & ~LED_MASK) | ((~x<<LED_SHIFT) & LED_MASK);\
    00166             LED_PORT = LED_SHADOW;\
    00167         }while(0)
    00168
    00169 # define LED_GET_VALUE()\
    00170         ((~LED_SHADOW & LED_MASK) >> LED_SHIFT)
    00171
    00172 # define LED_SET(ln)\
    00173         do{\
    00174             LED_SHADOW &= ~(_BV(ln+LED_SHIFT) & LED_MASK);\
    00175             LED_PORT = LED_SHADOW;\
    00176         }while(0)
    00177
    00178 # define LED_CLR(ln)\
    00179         do{\
    00180             LED_SHADOW |= (_BV(ln+LED_SHIFT) & LED_MASK);\
    00181             LED_PORT = LED_SHADOW;\
    00182         }while(0)
    00183
    00184 # define LED_VAL(msk,val)\
    00185         do{\
    00186             LED_SHADOW &= ~(LED_MASK|(msk<<LED_SHIFT)); \
    00187             LED_SHADOW |= ~(val & (LED_MASK|msk));\
    00188             LED_PORT = LED_SHADOW;\
    00189         }while(0)
    00190
    00191
    00192 # define LED_TOGGLE(ln)\
    00193         do{\
    00194             LED_SHADOW ^= (_BV(ln+LED_SHIFT) & LED_MASK);\
    00195             LED_PORT = LED_SHADOW;\
    00196         }while(0)
    00197
    00198 #else
    00199 /*=== use LEDs on RCB (IO Mapped) ===*/
    00200 # define LED_PORT      PORTE
    00201 # define LED_DDR       DDRE
    00202 # define LED_MASK      (0x1c)
    00203 # define LED_SHIFT     (2)
    00204 # define LEDS_INVERSE  (1)
    00205 # define LED_NUMBER    (3)
    00206 #endif
    00207 /*=== KEY access macros ==============================================*/
    00208 #define KEY_IO_AD    (0x4000)
    00209 #define PIN_KEY       (*(volatile uint8_t*)(KEY_IO_AD))
    00210 #define xDDR_KEY       DDRE
    00211 #define MASK_KEY      (0x1)
    00212 #define SHIFT_KEY     (0)
    00213 #define INVERSE_KEYS  (0)
    00214 #define PULLUP_KEYS   (0)
    00215 #define KEY_INIT      xmem_init
    00216
    00217 /*=== Host Interface ================================================*/
    00218 #define HIF_TYPE      (HIF_FT245)
    00219 #define HIF_IO_ENABLE XRAM_ENABLE
    00220 #define USB_FIFO_AD  0x2200
    00221 #define XRAM_ENABLE() \
    00222         do {\
    00223             DDRC = 0xff; /*force addr 0 to avoid glitches on ext. SRAM*/\
    00224             PORTC = 0x00;\
    00225             XMCRA |= (1 << SRE);\
    00226             XMCRB = (1 << XMBK);\
    00227         }while(0)
    00228
    00229 #define XRAM_DISABLE() \
    00230         do {\
    00231             XMCRA &= ~(1 << SRE);\
    00232         }while(0)
    00233
    00234 #define HIF_NO_DATA   (0x0100)
    00235 #define FT245_DDR    DDRE
    00236 #define FT245_PIN    PINE
    00237 #define FT245_TXE    _BV(6)
    00238 #define FT245_RXF    _BV(7)
    00239 #define FT245_INIT() do { \
    00240            FT245_DDR &= ~(FT245_TXE|FT245_RXF);\
    00241         } while(0)
    00242 #define TX_IS_READY        (0)
    00243 #define TX_IS_BLOCKED      (FT245_TXE)
    00244 #define RX_HAS_DATA        (0)
    00245 #define RX_HAS_NO_DATA     (FT245_RXF)
    00246 #define FT245_RX_DATA()  ((FT245_PIN & FT245_RXF))
    00247 #define FT245_TX_DATA()  ((FT245_PIN & FT245_TXE))
    00248
    00249 /*=== TIMER Interface ===============================================*/
    00250 #define HWTMR_PRESCALE  (1)
    00251 #define HWTIMER_TICK    ((1.0*HWTMR_PRESCALE)/F_CPU)
    00252 #define HWTIMER_TICK_NB (0xFFFFUL+1)
    00253 #define HWTIMER_REG     (TCNT1)
    00254 #define TIMER_TICK      (HWTIMER_TICK_NB * HWTIMER_TICK)
    00255 #define TIMER_POOL_SIZE     (4)
    00256
    00258 #define TIMER_IRQ_vect   TIMER1_OVF_vect
    00259
    00269 # define TIMER_INIT() \
    00270     do{ \
    00271         TCCR1B |= _BV(CS10); \
    00272         TIMSK1 |= _BV(TOIE1); \
    00273     }while(0)
    00274
    00275
    00276 /*=== OSCCAL tuning =================================================*/
    00277 #ifndef TUNED_OSCCAL
    00278 # define TUNED_OSCCAL (0xbf)  /* default is 0xb1, but @2.9V 0xbf is better */
    00279 #endif
    00280 #endif /* BOARD_STB_H*/