# board_ravrf.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_ravrf.h,v 1.10 2011/01/09 14:23:18 awachtler Exp $ */
    00077 #ifndef BOARD_RAVRF_H
    00078 #define BOARD_RAVRF_H
    00079
    00080 #if defined(ravrf230) || defined(ravrf230a)
    00081 # define BOARD_TYPE (BOARD_RAVRF230)
    00082 # define BOARD_NAME "ravrf230a"
    00083 # define RADIO_TYPE (RADIO_AT86RF230A)
    00084 #elif defined(ravrf230b)
    00085 # define BOARD_TYPE (BOARD_RAVRF230B)
    00086 # define BOARD_NAME "ravrf230b"
    00087 # define RADIO_TYPE (RADIO_AT86RF230B)
    00088 #endif
    00089
    00090 /*=== Compile time parameters ========================================*/
    00091 #ifndef DEFAULT_SPI_RATE
    00092 # define DEFAULT_SPI_RATE  (SPI_RATE_1_2)
    00093 #endif
    00094
    00095 /*=== Hardware Components ============================================*/
    00096 #ifndef RADIO_TYPE
    00097 #define RADIO_TYPE (RADIO_AT86RF230A)
    00098 #endif
    00099
    00100 /*=== TRX pin access macros ==========================================*/
    00101
    00102 #define DDR_TRX_RESET   DDRB
    00103 #define PORT_TRX_RESET  PORTB
    00104 #define MASK_TRX_RESET  (_BV(PB1))
    00105 /* check in board.h if standard definitions of TRX_RESET_INIT,
    00106    TRX_RESET_HIGH, TRX_RESET_LOW are Ok, otherwise define here */
    00107
    00108 #define PORT_TRX_SLPTR  PORTB
    00109 #define DDR_TRX_SLPTR   DDRB
    00110 #define MASK_TRX_SLPTR  (_BV(PB3))
    00111 /* check in board.h if standard definitions of TRX_SLPTR_INIT,
    00112    TRX_SLPTR_HIGH, TRX_SLPTR_LOW are Ok, otherwise define here */
    00113
    00114 /*=== IRQ access macros ==============================================*/
    00115 # define TRX_IRQ         _BV(ICIE1)
    00116 # define TRX_IRQ_vect    TIMER1_CAPT_vect
    00119 # define TRX_IRQ_INIT()  do{\
    00120                             TCCR1B |= (_BV(ICNC1) | _BV(ICES1));\
    00121                             TIFR1 = _BV(ICF1);\
    00122                           } while(0)
    00125 #define DI_TRX_IRQ() {TIMSK1 &= (~(TRX_IRQ));}
    00126
    00127 #define EI_TRX_IRQ() {TIMSK1 |= (TRX_IRQ);}
    00128
    00130 #define TRX_TSTAMP_REG ICR1
    00131
    00132 /*=== SPI access macros ==============================================*/
    00133 #define SPI_TYPE  SPI_TYPE_SPI
    00134 #define DDR_SPI  (DDRB)
    00135 #define PORT_SPI (PORTB)
    00137 #define SPI_MOSI _BV(PB5)
    00138 #define SPI_MISO _BV(PB6)
    00139 #define SPI_SCK  _BV(PB7)
    00140 #define SPI_SS   _BV(PB4)
    00142 #define SPI_DATA_REG SPDR
    00148 static inline void SPI_INIT(uint8_t spirate)
    00149 {
    00150     /* first configure SPI Port, then SPCR */
    00151     DDR_SPI  |= SPI_MOSI | SPI_SCK | SPI_SS;
    00152     DDR_SPI  &= ~SPI_MISO;
    00153     PORT_SPI |= SPI_SCK | SPI_SS;
    00154
    00155     SPCR = (_BV(SPE) | _BV(MSTR));
    00156
    00157     SPCR &= ~(_BV(SPR1) | _BV(SPR0) );
    00158     SPSR &= ~_BV(SPI2X);
    00159
    00160     SPCR |= (spirate & 0x03);
    00161     SPSR |= ((spirate >> 2) & 0x01);
    00162
    00163 }
    00164
    00166 #define SPI_SELN_LOW()       uint8_t sreg = SREG; cli(); PORT_SPI &=~SPI_SS
    00167
    00168 #define SPI_SELN_HIGH()      PORT_SPI |= SPI_SS; SREG = sreg
    00169
    00170 #define SPI_WAITFOR()        do { while((SPSR & _BV(SPIF)) == 0);} while(0)
    00171
    00172 /*=== LED access macros ==============================================*/
    00173 #define NO_LEDS       (1)
    00175 /*=== KEY access macros ==============================================*/
    00176 #define NO_KEYS       (1)
    00178 /*=== Host Interface ================================================*/
    00179
    00180 #define HIF_TYPE    HIF_UART_0
    00181
    00182 /*=== TIMER Interface ===============================================*/
    00183 #define HWTMR_PRESCALE  (1)
    00184 #define HWTIMER_TICK    ((1.0*HWTMR_PRESCALE)/F_CPU)
    00185 #define HWTIMER_TICK_NB (0xFFFFUL)
    00186 #define HWTIMER_REG     (TCNT1)
    00187 #define TIMER_TICK      (HWTIMER_TICK_NB * HWTIMER_TICK)
    00188 #define TIMER_POOL_SIZE (4)
    00189 #define TIMER_INIT() \
    00190     do{ \
    00191         TCCR1B |= (_BV(CS10)); \
    00192         TIMSK1 |= _BV(TOIE1); \
    00193     }while(0)
    00194
    00196 #define TIMER_IRQ_vect   TIMER1_OVF1_vect
    00197
    00198 #endif /* BOARD_RAVRF_H*/