board_derfa.h
Go to the documentation of this file.

    00001 /* Copyright (c) 2009 - 2013 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$ */
    00068 #ifndef BOARD_DERFA_H
    00069 #define BOARD_DERFA_H
    00070
    00071 #if defined(derfa1)
    00072 # define BOARD_TYPE BOARD_DERFA1
    00073 # define BOARD_NAME "derfa1"
    00074 #define RADIO_TYPE (RADIO_ATMEGA128RFA1_C)
    00075 #elif defined(radiofaro)
    00076 # define BOARD_TYPE BOARD_RADIOFARO
    00077 # define BOARD_NAME "radiofaro"
    00078 #define RADIO_TYPE (RADIO_ATMEGA128RFA1_D)
    00079 #elif defined(radiofaro_v1)
    00080 # define BOARD_TYPE BOARD_RADIOFARO_V1
    00081 # define BOARD_NAME "radiofaro v1"
    00082 #define RADIO_TYPE (RADIO_ATMEGA128RFA1_C)
    00083 #elif defined(zigduino)
    00084 # define BOARD_TYPE BOARD_ZIGDUINO
    00085 # define BOARD_NAME "zigduino"
    00086 #define RADIO_TYPE (RADIO_ATMEGA128RFA1_C)
    00087 #elif defined(xxo)
    00088 # define BOARD_TYPE BOARD_XXO
    00089 # define BOARD_NAME "tic_tac_toe"
    00090 #define RADIO_TYPE (RADIO_ATMEGA128RFA1_C)
    00091 #elif defined(wprog)
    00092 # define BOARD_TYPE BOARD_WPROG
    00093 # define BOARD_NAME "wprog"
    00094 # define RADIO_TYPE (RADIO_ATMEGA128RFA1_D)
    00095 #elif defined(pinoccio)
    00096 # define BOARD_TYPE BOARD_PINOCCIO
    00097 # define BOARD_NAME "pinoccio"
    00098 # define RADIO_TYPE (RADIO_ATMEGA128RFA1_D)
    00099 #elif defined(raspbee)
    00100 # define BOARD_TYPE BOARD_RASPBEE
    00101 # define BOARD_NAME "raspbee"
    00102 # define RADIO_TYPE (RADIO_ATMEGA256RFR2)
    00103 #elif defined(derfa2)
    00104 # define BOARD_TYPE BOARD_DERFA2
    00105 # define BOARD_NAME "derfa2"
    00106 # define RADIO_TYPE (RADIO_ATMEGA256RFR2)
    00107 #elif defined(derfa2p)
    00108 # define BOARD_TYPE BOARD_DERFA2P
    00109 # define BOARD_NAME "derfa2p"
    00110 # define RADIO_TYPE (RADIO_ATMEGA256RFR2)
    00111 #endif
    00112 /*=== Compile time parameters ========================================*/
    00113
    00114 /*=== Hardware Components ============================================*/
    00115
    00117 #define TRX_TSTAMP_REG TCNT1
    00118
    00119 #if BOARD_TYPE == BOARD_RADIOFARO
    00120 # define LED_PORT      PORTG
    00121 # define LED_DDR       DDRG
    00122 # define LED_MASK      (0x06)
    00123 # define LED_SHIFT     (1)
    00124 # define LEDS_INVERSE  (0)
    00125 # define LED_NUMBER    (2)
    00126 #elif BOARD_TYPE == BOARD_WPROG
    00127 # define LED_PORT      PORTD
    00128 # define LED_DDR       DDRD
    00129 # define LED_MASK      (0x40)
    00130 # define LED_SHIFT     (6)
    00131 # define LEDS_INVERSE  (1)
    00132 # define LED_NUMBER    (1)
    00133 #elif BOARD_TYPE == BOARD_PINOCCIO
    00134 # define LED_PORT      PORTB
    00135 # define LED_DDR       DDRB
    00136 # define LED_MASK      (0x70)
    00137 # define LED_SHIFT     (4)
    00138 # define LEDS_INVERSE  (1)
    00139 # define LED_NUMBER    (3)
    00140 #elif BOARD_TYPE == BOARD_XXO
    00141
    00142 /* We just define the first three LEDs in row 1
    00143  * use a special display driver, that is frequently
    00144  * updated to handle the full LED matrix.
    00145  */
    00146
    00147 #define LED_INIT() \
    00148     do {\
    00149         DDRB |= (_BV(PB0) | _BV(PB1) | _BV(PB2) | _BV(PB3));\
    00150         PORTB |= (_BV(PB0) | _BV(PB1) | _BV(PB2) | _BV(PB3));\
    00151     } while(0)
    00152
    00153
    00154 #define LED_SET(x) \
    00155   switch (x) { \
    00156   case 0: PORTB &= ~_BV(0); break; \
    00157   case 1: PORTB &= ~_BV(1); break; \
    00158   case 2: PORTB &= ~_BV(2); break; \
    00159   }
    00160
    00161 #define LED_CLR(x) \
    00162   switch (x) { \
    00163   case 0: PORTB |= _BV(0); break; \
    00164   case 1: PORTB |= _BV(1); break; \
    00165   case 2: PORTB |= _BV(2); break; \
    00166   }
    00167
    00168 #define LED_SET_VALUE(x) \
    00169   do { \
    00170   if (x & 1) PORTB &= ~_BV(0); else PORTB |= _BV(0); \
    00171   if (x & 2) PORTB &= ~_BV(1); else PORTB |= _BV(1); \
    00172   if (x & 4) PORTB &= ~_BV(2); else PORTB |= _BV(2); \
    00173   } while (0)
    00174
    00175 #define LED_GET_VALUE() ( \
    00176   ((PORTB & _BV(0))? 0: 1) | \
    00177   ((PORTB & _BV(1))? 0: 2) | \
    00178   ((PORTB & _BV(2))? 0: 4) \
    00179               )
    00180
    00181 #define LED_VAL(msk,val) do{}while(0)
    00183 #define LED_TOGGLE(ln) \
    00184   switch (ln) { \
    00185   case 0: PORTB ^= _BV(5); break; \
    00186   case 1: PORTB ^= _BV(7); break; \
    00187   case 2: PORTB ^= _BV(6); break; \
    00188   }
    00189
    00190 #define LED_NUMBER (3)
    00191 #define LED_ACTIVITY (0)
    00192
    00193 #elif BOARD_TYPE == BOARD_RASPBEE || BOARD_TYPE == BOARD_DERFA2 || BOARD_TYPE == BOARD_DERFA2P
    00194
    00195 # define LED_INIT() \
    00196     do { \
    00197         DDRD |= _BV(7); \
    00198         DDRG |= _BV(2); \
    00199         PORTD |= _BV(7); \
    00200         PORTG |= _BV(2); \
    00201     } while(0)
    00202
    00203 # define LED_SET(x) \
    00204     switch (x) { \
    00205         case 0: PORTD |= _BV(7); break; \
    00206         case 1: PORTG |= _BV(2); break; \
    00207     }
    00208
    00209 # define LED_CLR(x) \
    00210     switch (x) { \
    00211         case 0: PORTD &= ~_BV(7); break; \
    00212         case 1: PORTG &= ~_BV(2); break; \
    00213     }
    00214
    00215 # define LED_SET_VALUE(x) \
    00216   do { \
    00217     if (x & 1) PORTD &= ~_BV(7); else PORTD |= _BV(7); \
    00218     if (x & 2) PORTG &= ~_BV(2); else PORTG |= _BV(2); \
    00219   } while (0)
    00220
    00221 # define LED_GET_VALUE() ( \
    00222   ((PORTD & _BV(7))? 0: 1) | \
    00223   ((PORTG & _BV(2))? 0: 2) )
    00224
    00225 # define LED_VAL(msk,val) do{}while(0)
    00227 # define LED_TOGGLE(ln) \
    00228   switch (ln) { \
    00229   case 0: PORTD ^= _BV(7); break; \
    00230   case 1: PORTG ^= _BV(2); break; \
    00231   }
    00232
    00233 # define LED_NUMBER (2)
    00234 # define LED_ACTIVITY (0)
    00235
    00236 #else
    00237 # define LED_NUMBER    (0)
    00238 # define NO_LEDS       (1)
    00239 #endif
    00240
    00241 #define NO_KEYS        (1)
    00242
    00243 /*=== Host Interface ================================================*/
    00244 #if BOARD_TYPE == BOARD_RADIOFARO_V1 || \
    00245     BOARD_TYPE == BOARD_ZIGDUINO || \
    00246     BOARD_TYPE == BOARD_PINOCCIO || \
    00247     BOARD_TYPE == BOARD_RASPBEE || \
    00248     BOARD_TYPE == BOARD_DERFA2 || \
    00249     BOARD_TYPE == BOARD_DERFA2P
    00250 # define HIF_TYPE    HIF_UART_0
    00251 #else
    00252 # define HIF_TYPE    HIF_UART_1
    00253 #endif
    00254
    00255 #define TRX_RESET_LOW()   do { TRXPR &= ~_BV(TRXRST); } while (0)
    00256 #define TRX_RESET_HIGH()  do { TRXPR |= _BV(TRXRST); } while (0)
    00257 #define TRX_SLPTR_LOW()   do { TRXPR &= ~_BV(SLPTR); } while (0)
    00258 #define TRX_SLPTR_HIGH()  do { TRXPR |= _BV(SLPTR); } while (0)
    00259
    00260 /*=== TIMER Interface ===============================================*/
    00261 #define HWTMR_PRESCALE  (1)
    00262 #define HWTIMER_TICK    ((1.0*HWTMR_PRESCALE)/F_CPU)
    00263 #define HWTIMER_TICK_NB (0xFFFFUL)
    00264 #define HWTIMER_REG     (TCNT1)
    00265 #define TIMER_TICK      (HWTIMER_TICK_NB * HWTIMER_TICK)
    00266 #define TIMER_POOL_SIZE (4)
    00267 #define TIMER_INIT() \
    00268     do{ \
    00269         TCCR1B |= (_BV(CS10)); \
    00270         TIMSK1 |= _BV(TOIE1); \
    00271     }while(0)
    00272 #define TIMER_IRQ_vect   TIMER1_OVF_vect
    00273
    00274 /*=== PA/LNA init ==================================================*/
    00275 #if BOARD_TYPE == BOARD_RASPBEE || BOARD_TYPE == BOARD_DERFA2P
    00276
    00277 # define TRX_PA_LNA_INIT() \
    00278         do {\
    00279             PORTD &= ~_BV(PD6);\
    00280             DDRD |= _BV(PD6);\
    00281         } while(0)
    00282
    00283 # define TRX_TX_PA_EI() do {PORTD |= _BV(PD6);} while(0)
    00284 # define TRX_TX_PA_DI() do {PORTD &= ~_BV(PD6);} while(0)
    00285 # define TRX_RX_LNA_EI() do {PORTD |= _BV(PD6);} while(0)
    00286 # define TRX_RX_LNA_DI() do {PORTD &= ~_BV(PD6);} while(0)
    00287 #endif /* BOARD_TYPE == BOARD_RASPBEE */
    00288
    00289 #endif /* BOARD_DERFA_H */