board_ibdt.h

Go to the documentation of this file.
00001 /* Copyright (c) 2010 Daniel Thiele
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__ibdt_8h_source.html,v 1.1.1.4 2013/04/09 21:12:13 awachtler Exp $ */
00054 #ifndef BOARD_IBDT_H
00055 #define BOARD_IBDT_H
00056 
00057 /*=== Hardware Components ============================================*/
00058 
00059 #if defined(ibdt212)
00060 
00061 #define BOARD_TYPE BOARD_IBDT212
00062 #define BOARD_NAME  "ibdt212"
00063 #ifndef RADIO_TYPE
00064 #define RADIO_TYPE (RADIO_AT86RF212)
00065 #endif
00066 
00067 #elif defined(ibdt231)
00068 
00069 #define BOARD_TYPE BOARD_IBDT231
00070 #define BOARD_NAME  "ibdt231"
00071 #ifndef RADIO_TYPE
00072 #define RADIO_TYPE (RADIO_AT86RF231)
00073 #endif
00074 
00075 #elif defined(ibdt232)
00076 
00077 #define BOARD_TYPE BOARD_IBDT232
00078 #define BOARD_NAME  "ibdt232"
00079 #ifndef RADIO_TYPE
00080 #define RADIO_TYPE (RADIO_AT86RF232)
00081 #endif
00082 
00083 #else
00084 #error "Unsupported BOARD_TYPE"
00085 #endif
00086 
00087 /*=== Compile time parameters ========================================*/
00088 
00089 #ifndef DEFAULT_SPI_RATE
00090 # define DEFAULT_SPI_RATE  (SPI_RATE_1_2)
00091 #endif
00092 
00093 /*=== TRX pin access macros ==========================================*/
00094 
00095 #define DDR_TRX_RESET   DDRD            
00096 #define PORT_TRX_RESET  PORTD           
00097 #define MASK_TRX_RESET  (_BV(PD6))      
00098 /* check in board.h if standard definitions of TRX_RESET_INIT,
00099    TRX_RESET_HIGH, TRX_RESET_LOW are Ok, otherwise define here */
00100 
00101 #define PORT_TRX_SLPTR  PORTD           
00102 #define DDR_TRX_SLPTR   DDRD            
00103 #define MASK_TRX_SLPTR  (_BV(PD7))      
00104 /* check in board.h if standard definitions of TRX_SLPTR_INIT,
00105    TRX_SLPTR_HIGH, TRX_SLPTR_LOW are Ok, otherwise define here */
00106 
00107 /*=== IRQ access macros ==============================================*/
00108 # define TRX_IRQ         _BV(INT2)      
00109 # define TRX_IRQ_vect    INT2_vect      
00112 # define TRX_IRQ_INIT()  do{\
00113                             EICRA = _BV(ISC20) | _BV(ISC21);\
00114                             EIMSK  |= (TRX_IRQ);\
00115                           } while(0) 
00118 #define DI_TRX_IRQ() {EIMSK &= (~(TRX_IRQ));}
00119 
00120 #define EI_TRX_IRQ() {EIMSK |= (TRX_IRQ);}
00121 
00123 #define TRX_TSTAMP_REG TCNT1
00124 
00125 /*=== SPI access macros ==============================================*/
00126 #define SPI_TYPE  SPI_TYPE_SPI
00127 #define DDR_SPI  (DDRB)   
00128 #define PORT_SPI (PORTB)  
00130 #define SPI_MOSI _BV(PB5)  
00131 #define SPI_MISO _BV(PB6)  
00132 #define SPI_SCK  _BV(PB7)  
00133 #define SPI_SS   _BV(PB4)  
00135 #define SPI_DATA_REG SPDR  
00141 static inline void SPI_INIT(uint8_t spirate)
00142 {
00143     /* first configure SPI Port, then SPCR */
00144     DDR_SPI  |= SPI_MOSI | SPI_SCK | SPI_SS;
00145     DDR_SPI  &= ~SPI_MISO;
00146     PORT_SPI |= SPI_SCK | SPI_SS;
00147 
00148     SPCR = (_BV(SPE) | _BV(MSTR));
00149 
00150     SPCR &= ~(_BV(SPR1) | _BV(SPR0) );
00151     SPSR &= ~_BV(SPI2X);
00152 
00153     SPCR |= (spirate & 0x03);
00154     SPSR |= ((spirate >> 2) & 0x01);
00155 
00156 }
00157 
00159 #define SPI_SELN_LOW()       uint8_t sreg = SREG; cli(); PORT_SPI &=~SPI_SS
00160 
00161 #define SPI_SELN_HIGH()      PORT_SPI |= SPI_SS; SREG = sreg
00162 
00163 #define SPI_WAITFOR()        do { while((SPSR & _BV(SPIF)) == 0);} while(0)
00164 
00165 /*=== LED access macros ==============================================*/
00166 #define LED_PORT      PORTD      
00167 #define LED_DDR       DDRD       
00168 #define LED_MASK      (0x30)     
00169 #define LED_SHIFT     (4)        
00170 #define LEDS_INVERSE  (1)        
00172 #define LED_NUMBER    (2)        
00175 /*=== KEY access macros ==============================================*/
00176 //#define NO_KEYS       (1)        /**< if defined, no KEYS are connected */
00177 #define PORT_KEY      PORTD      
00178 #define PIN_KEY       PIND       
00179 #define DDR_KEY       DDRD       
00180 #define MASK_KEY      (0x0C)     
00181 #define SHIFT_KEY     (2)        
00182 #define INVERSE_KEYS  (1)        
00184 #define PULLUP_KEYS  (1)
00185 
00186 #define SLEEP_ON_KEY_INIT() \
00187         do{\
00188             PCMSK0 |= _BV(PCINT2);\
00189         }while(0)
00190 
00191 #define SLEEP_ON_KEY() \
00192         do{\
00193             EIMSK |= _BV(PCIE0);\
00194             set_sleep_mode(SLEEP_MODE_PWR_DOWN);\
00195             sleep_mode();\
00196             EIMSK &= ~_BV(PCIE0);\
00197         } while(0)
00198 
00199 #define SLEEP_ON_KEY_vect PCINT0_vect
00200 
00201 
00202 /*=== Host Interface ================================================*/
00204 #define HIF_TYPE    HIF_UART_0
00205 
00206 /*=== TIMER Interface ===============================================*/
00207 /* setup timer of 1ms */
00208 #define HWTMR_PRESCALE  (64)
00209 #define HWTIMER_TICK    ((1.0*HWTMR_PRESCALE)/F_CPU) 
00212 #define HWTIMER_TICK_NB (0.001/HWTIMER_TICK) 
00214 #define HWTIMER_REG (TCNT1) 
00216 #define TIMER_TICK (HWTIMER_TICK * HWTIMER_TICK_NB)
00217 
00220 #define TIMER_POOL_SIZE (8) 
00223 #define TIMER_INIT() \
00224     do{\
00225         TCCR0B = _BV(CS01) | _BV(CS00);\
00226         TCCR0B |= _BV(WGM02); \
00227         OCR0A = HWTIMER_TICK_NB; \
00228         TIMSK0 |= _BV(OCIE0A);\
00229     }while(0)
00230 
00232 #define TIMER_IRQ_vect  TIMER0_COMPA_vect
00233 
00234 #endif /* BOARD_IBDT_H*/

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