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

# board_ict230.h

Go to the documentation of this file.

    00001 /* Copyright (c) 2007 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_ict230.h,v 1.10 2009/06/30 19:27:22 awachtler Exp $ */
    00072 #define BOARD_NAME_ICT230 "ict230"
    00073
    00074 #ifndef BOARD_ICT230_H
    00075 #define BOARD_ICT230_H
    00076
    00077 #define BOARD_TYPE  (ICT_RF230)
    00078 #define BOARD_NAME  BOARD_NAME_ICT230
    00079
    00080
    00081 /*=== Compile time parameters ========================================*/
    00082 #ifndef MAX_FRAME_SIZE
    00083 # define MAX_FRAME_SIZE (127)
    00084 #endif
    00085
    00086 #ifndef DEFAULT_SPI_RATE
    00087 # define DEFAULT_SPI_RATE  (SPI_RATE_1_2)
    00088 #endif
    00089
    00090 #ifndef PB0
    00091 # define PB0 (0)
    00092 # define PB1 (1)
    00093 # define PB2 (2)
    00094 # define PB3 (3)
    00095 # define PB4 (4)
    00096 # define PB5 (5)
    00097 # define PB6 (6)
    00098 # define PB7 (7)
    00099 #endif
    00100
    00101 /*=== Hardware Components ============================================*/
    00102 #define CPU_TYPE   (CPU_M1281)
    00103 #define RADIO_TYPE (RADIO_AT86RF230)
    00105 /*=== TRX pin access macros ==========================================*/
    00106
    00107 #define DDR_TRX_RESET   DDRB
    00108 #define PORT_TRX_RESET  PORTB
    00109 #define MASK_TRX_RESET  (_BV(PB6))
    00110 #define CUSTOM_RESET_TIME_MS (10)
    00112 #define PORT_TRX_SLPTR  PORTB
    00113 #define DDR_TRX_SLPTR   DDRB
    00114 #define MASK_TRX_SLPTR  (_BV(PB5))
    00116 /*=== IRQ access macros ==============================================*/
    00117 # define TRX_IRQ         _BV(INT4)
    00118 # define TRX_IRQ_vect    INT4_vect
    00121 # define TRX_IRQ_INIT()  do{\
    00122                             EICRB  |= (_BV(ISC41)|_BV(ISC40));\
    00123                           } while(0)
    00126 #define DI_TRX_IRQ() {EIMSK &= (~(TRX_IRQ));}
    00127
    00128 #define EI_TRX_IRQ() {EIMSK |= (TRX_IRQ);}
    00129
    00131 #define TRX_TSTAMP_REG TCNT1
    00132
    00133 /*=== SPI access macros ==============================================*/
    00134 #define DDR_SPI  (DDRB)
    00135 #define PORT_SPI (PORTB)
    00137 #define SPI_MOSI _BV(PB2)
    00138 #define SPI_MISO _BV(PB3)
    00139 #define SPI_SCK  _BV(PB1)
    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  |= _BV(PB0); /* need to make /SS pin to output in
    00153                              in order to run safely in SPI
    00154                              Master mode */
    00155     DDR_SPI  &= ~SPI_MISO;
    00156     PORT_SPI |= SPI_SCK | SPI_SS;
    00157
    00158     SPCR = (_BV(SPE) | _BV(MSTR));
    00159
    00160     /* set spi rate */
    00161     SPCR &= ~(_BV(SPR1) | _BV(SPR0) );
    00162     SPSR &= ~_BV(SPI2X);
    00163
    00164     SPCR |= (spirate & 0x03);
    00165     SPSR |= ((spirate >> 2) & 0x01);
    00166
    00167 }
    00168
    00170 #define SPI_SELN_LOW()       uint8_t sreg = SREG; cli(); PORT_SPI &=~SPI_SS
    00171
    00172 #define SPI_SELN_HIGH()      PORT_SPI |= SPI_SS; SREG = sreg
    00173
    00174 #define SPI_WAITFOR()        do { while((SPSR & _BV(SPIF)) == 0);} while(0)
    00175
    00176 /*=== LED access macros ==============================================*/
    00177
    00178 /* stick settings */
    00179 #define LED_PORT      PORTD
    00180 #define LED_DDR       DDRD
    00181 #define LED_MASK      (0xc0)
    00182 #define LED_SHIFT     (6)
    00183 #define LEDS_INVERSE  (1)
    00184 #define LED_NUMBER    (2)
    00185
    00186 /*=== KEY access macros ==============================================*/
    00187 #define PORT_KEY     PORTD
    00188 #define PIN_KEY      PIND
    00189 #define DDR_KEY      DDRD
    00190 #define MASK_KEY     (0x01)
    00191 #define SHIFT_KEY    (0)
    00192 #define INVERSE_KEYS (1)
    00193 #define PULLUP_KEYS  (1)
    00194
    00195 /*=== Host Interface ================================================*/
    00196 #define HIF_TYPE    HIF_UART_1
    00197
    00198
    00199 /*=== TIMER Interface ===============================================*/
    00200 #define HWTMR_PRESCALE  (8)
    00201 #define HWTIMER_TICK    ((1.0*HWTMR_PRESCALE)/F_CPU)
    00202 #define HWTIMER_TICK_NB (1000UL)
    00203 #define HWTIMER_REG     (TCNT1)
    00204 #define TIMER_TICK      (HWTIMER_TICK_NB * HWTIMER_TICK)
    00205 #define TIMER_POOL_SIZE (4)
    00206
    00215 # define TIMER_INIT() \
    00216     do{ \
    00217         TCCR1B |= (_BV(CS11) | _BV(WGM12)); \
    00218         TIMSK1 |= _BV(OCIE1A); \
    00219         OCR1A = 1000; \
    00220     }while(0)
    00221
    00222 # define TIMER_IRQ_vect   TIMER1_COMPA_vect
    00223
    00224 /*=== OSCCAL tuning =================================================*/
    00225
    00226 #ifndef TUNED_OSCCAL
    00227 # define TUNED_OSCCAL (0xbf)  /* default is 0xb1, but @2.9V 0xbf is better */
    00228 #endif
    00229 #endif /* BOARD_ICT230_H */