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_8h_source.html,v 1.1.1.4 2013/04/09 21:11:39 awachtler Exp $ */
00072 #ifndef BOARD_ICT230_H
00073 #define BOARD_ICT230_H
00074 #define BOARD_TYPE  (BOARD_ICT230)
00075 #define BOARD_NAME  "ict230"
00076 
00077 /*=== Compile time parameters ========================================*/
00078 #ifndef DEFAULT_SPI_RATE
00079 # define DEFAULT_SPI_RATE  (SPI_RATE_1_2)
00080 #endif
00081 
00082 #ifndef PB0
00083 # define PB0 (0)
00084 # define PB1 (1)
00085 # define PB2 (2)
00086 # define PB3 (3)
00087 # define PB4 (4)
00088 # define PB5 (5)
00089 # define PB6 (6)
00090 # define PB7 (7)
00091 #endif
00092 
00093 /*=== Hardware Components ============================================*/
00094 #define RADIO_TYPE (RADIO_AT86RF230)    
00096 /*=== TRX pin access macros ==========================================*/
00097 
00098 #define DDR_TRX_RESET   DDRB            
00099 #define PORT_TRX_RESET  PORTB           
00100 #define MASK_TRX_RESET  (_BV(PB6))      
00101 #define CUSTOM_RESET_TIME_MS (10)       
00103 #define PORT_TRX_SLPTR  PORTB           
00104 #define DDR_TRX_SLPTR   DDRB            
00105 #define MASK_TRX_SLPTR  (_BV(PB5))    
00107 /*=== IRQ access macros ==============================================*/
00108 # define TRX_IRQ         _BV(INT4)    
00109 # define TRX_IRQ_vect    INT4_vect    
00112 # define TRX_IRQ_INIT()  do{\
00113                             EICRB  |= (_BV(ISC41)|_BV(ISC40));\
00114                           } while(0) 
00117 #define DI_TRX_IRQ() {EIMSK &= (~(TRX_IRQ));}
00118 
00119 #define EI_TRX_IRQ() {EIMSK |= (TRX_IRQ);}
00120 
00122 #define TRX_TSTAMP_REG TCNT1
00123 
00124 /*=== SPI access macros ==============================================*/
00125 #define DDR_SPI  (DDRB)     
00126 #define PORT_SPI (PORTB)    
00128 #define SPI_MOSI _BV(PB2)   
00129 #define SPI_MISO _BV(PB3)   
00130 #define SPI_SCK  _BV(PB1)   
00131 #define SPI_SS   _BV(PB4)   
00133 #define SPI_DATA_REG SPDR   
00139 static inline void SPI_INIT(uint8_t spirate)
00140 {
00141     /* first configure SPI Port, then SPCR */
00142     DDR_SPI  |=  SPI_MOSI | SPI_SCK | SPI_SS;
00143     DDR_SPI  |= _BV(PB0); /* need to make /SS pin to output in
00144                              in order to run safely in SPI
00145                              Master mode */
00146     DDR_SPI  &= ~SPI_MISO;
00147     PORT_SPI |= SPI_SCK | SPI_SS;
00148 
00149     SPCR = (_BV(SPE) | _BV(MSTR));
00150 
00151     /* set spi rate */
00152     SPCR &= ~(_BV(SPR1) | _BV(SPR0) );
00153     SPSR &= ~_BV(SPI2X);
00154 
00155     SPCR |= (spirate & 0x03);
00156     SPSR |= ((spirate >> 2) & 0x01);
00157 
00158 }
00159 
00161 #define SPI_SELN_LOW()       uint8_t sreg = SREG; cli(); PORT_SPI &=~SPI_SS
00162 
00163 #define SPI_SELN_HIGH()      PORT_SPI |= SPI_SS; SREG = sreg
00164 
00165 #define SPI_WAITFOR()        do { while((SPSR & _BV(SPIF)) == 0);} while(0)
00166 
00167 /*=== LED access macros ==============================================*/
00168 
00169 /* stick settings */
00170 #define LED_PORT      PORTD
00171 #define LED_DDR       DDRD
00172 #define LED_MASK      (0xc0)
00173 #define LED_SHIFT     (6)
00174 #define LEDS_INVERSE  (1)
00175 #define LED_NUMBER    (2)
00176 
00177 /*=== KEY access macros ==============================================*/
00178 #define PORT_KEY     PORTD
00179 #define PIN_KEY      PIND
00180 #define DDR_KEY      DDRD
00181 #define MASK_KEY     (0x01)
00182 #define SHIFT_KEY    (0)
00183 #define INVERSE_KEYS (1)
00184 #define PULLUP_KEYS  (1)
00185 
00186 /*=== Host Interface ================================================*/
00187 #define HIF_TYPE    HIF_UART_1
00188 
00189 
00190 /*=== TIMER Interface ===============================================*/
00191 #define HWTMR_PRESCALE  (8)
00192 #define HWTIMER_TICK    ((1.0*HWTMR_PRESCALE)/F_CPU)
00193 #define HWTIMER_TICK_NB (1000UL)
00194 #define HWTIMER_REG     (TCNT1)
00195 #define TIMER_TICK      (HWTIMER_TICK_NB * HWTIMER_TICK)
00196 #define TIMER_POOL_SIZE (4)
00197 
00206 # define TIMER_INIT() \
00207     do{ \
00208         TCCR1B |= (_BV(CS11) | _BV(WGM12)); \
00209         TIMSK1 |= _BV(OCIE1A); \
00210         OCR1A = 1000; \
00211     }while(0)
00212 
00213 # define TIMER_IRQ_vect   TIMER1_COMPA_vect
00214 
00215 #endif /* BOARD_ICT230_H */

This documentation for µracoli was generated on Tue Apr 9 2013 by  doxygen 1.7.1