# board_derfa.h

Go to the documentation of this file.

    00001 /* Copyright (c) 2009 - 2011 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$ */
    00066 #ifndef BOARD_DERFA_H
    00067 #define BOARD_DERFA_H
    00068
    00069 #if defined(derfa1)
    00070 # define BOARD_TYPE BOARD_DERFA1
    00071 # define BOARD_NAME "derfa1"
    00072 #elif defined(radiofaro)
    00073 # define BOARD_TYPE BOARD_RADIOFARO
    00074 # define BOARD_NAME "radiofaro"
    00075 #elif defined(radiofaro_v1)
    00076 # define BOARD_TYPE BOARD_RADIOFARO_V1
    00077 # define BOARD_NAME "radiofaro v1"
    00078 #elif defined(zigduino)
    00079 # define BOARD_TYPE BOARD_ZIGDUINO
    00080 # define BOARD_NAME "zigduino"
    00081 #elif defined(xxo)
    00082 # define BOARD_TYPE BOARD_XXO
    00083 # define BOARD_NAME "tic_tac_toe"
    00084 #endif
    00085 /*=== Compile time parameters ========================================*/
    00086
    00087 /*=== Hardware Components ============================================*/
    00088 #define RADIO_TYPE (RADIO_ATMEGA128RFA1_C)
    00089
    00091 #define TRX_TSTAMP_REG TCNT1
    00092 #if BOARD_TYPE == BOARD_RADIOFARO
    00093 # define LED_PORT      PORTG
    00094 # define LED_DDR       DDRG
    00095 # define LED_MASK      (0x06)
    00096 # define LED_SHIFT     (1)
    00097 # define LEDS_INVERSE  (0)
    00098 # define LED_NUMBER    (2)
    00099 #elif BOARD_TYPE == BOARD_XXO
    00100
    00101 /* We just define the first three LEDs in row 1
    00102  * use a special display driver, that is frequently
    00103  * updated to handle the full LED matrix.
    00104  */
    00105
    00106 #define LED_INIT() \
    00107     do {\
    00108         DDRB |= (_BV(PB0) | _BV(PB1) | _BV(PB2) | _BV(PB3));\
    00109         PORTB |= (_BV(PB0) | _BV(PB1) | _BV(PB2) | _BV(PB3));\
    00110     } while(0)
    00111
    00112
    00113 #define LED_SET(x) \
    00114   switch (x) { \
    00115   case 0: PORTB &= ~_BV(0); break; \
    00116   case 1: PORTB &= ~_BV(1); break; \
    00117   case 2: PORTB &= ~_BV(2); break; \
    00118   }
    00119
    00120 #define LED_CLR(x) \
    00121   switch (x) { \
    00122   case 0: PORTB |= _BV(0); break; \
    00123   case 1: PORTB |= _BV(1); break; \
    00124   case 2: PORTB |= _BV(2); break; \
    00125   }
    00126
    00127 #define LED_SET_VALUE(x) \
    00128   do { \
    00129   if (x & 1) PORTB &= ~_BV(0); else PORTB |= _BV(0); \
    00130   if (x & 2) PORTB &= ~_BV(1); else PORTB |= _BV(1); \
    00131   if (x & 4) PORTB &= ~_BV(2); else PORTB |= _BV(2); \
    00132   } while (0)
    00133
    00134 #define LED_GET_VALUE() ( \
    00135   ((PORTB & _BV(0))? 0: 1) | \
    00136   ((PORTB & _BV(1))? 0: 2) | \
    00137   ((PORTB & _BV(2))? 0: 4) \
    00138               )
    00139
    00140 #define LED_VAL(msk,val) do{}while(0)
    00142 #define LED_TOGGLE(ln) \
    00143   switch (ln) { \
    00144   case 0: PORTB ^= _BV(5); break; \
    00145   case 1: PORTB ^= _BV(7); break; \
    00146   case 2: PORTB ^= _BV(6); break; \
    00147   }
    00148
    00149 #define LED_NUMBER (3)
    00150 #define LED_ACTIVITY (0)
    00151
    00152 #else
    00153 # define LED_NUMBER    (0)
    00154 # define NO_LEDS       (1)
    00155 #endif
    00156 #define NO_KEYS        (1)
    00157
    00158 /*=== Host Interface ================================================*/
    00159 #if BOARD_TYPE == BOARD_RADIOFARO_V1 || BOARD_TYPE == BOARD_ZIGDUINO
    00160 # define HIF_TYPE    HIF_UART_0
    00161 #else
    00162 # define HIF_TYPE    HIF_UART_1
    00163 #endif
    00164
    00165 #define TRX_RESET_LOW()   do { TRXPR &= ~_BV(TRXRST); } while (0)
    00166 #define TRX_RESET_HIGH()  do { TRXPR |= _BV(TRXRST); } while (0)
    00167 #define TRX_SLPTR_LOW()   do { TRXPR &= ~_BV(SLPTR); } while (0)
    00168 #define TRX_SLPTR_HIGH()  do { TRXPR |= _BV(SLPTR); } while (0)
    00169
    00170 /*=== TIMER Interface ===============================================*/
    00171 #define HWTMR_PRESCALE  (1)
    00172 #define HWTIMER_TICK    ((1.0*HWTMR_PRESCALE)/F_CPU)
    00173 #define HWTIMER_TICK_NB (0xFFFFUL)
    00174 #define HWTIMER_REG     (TCNT1)
    00175 #define TIMER_TICK      (HWTIMER_TICK_NB * HWTIMER_TICK)
    00176 #define TIMER_POOL_SIZE (4)
    00177 #define TIMER_INIT() \
    00178     do{ \
    00179         TCCR1B |= (_BV(CS10)); \
    00180         TIMSK1 |= _BV(TOIE1); \
    00181     }while(0)
    00182 #define TIMER_IRQ_vect   TIMER1_OVF_vect
    00183
    00184 #endif /* BOARD_DERFA_H */