board_tiny230.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__tiny230_8h_source.html,v 1.1.1.4 2013/04/09 21:12:02 awachtler Exp $ */
00072 #ifndef BOARD_TINY230_H
00073 #define BOARD_TINY230_H
00074 
00075 #if defined(tiny230)
00076 # define BOARD_NAME "tiny230"
00077 # define BOARD_TYPE (BOARD_TINY230)       
00078 # define RADIO_TYPE (RADIO_AT86RF230B)    
00079 #elif defined(tiny231)
00080 # define BOARD_NAME "tiny231"
00081 # define BOARD_TYPE (BOARD_TINY231)       
00082 # define RADIO_TYPE (RADIO_AT86RF231)    
00083 #endif
00084 
00085 /*=== Compile time parameters ========================================*/
00086 #ifndef DEFAULT_SPI_RATE
00087 # define DEFAULT_SPI_RATE  (SPI_RATE_1_2)
00088 #endif
00089 
00090 /*=== Hardware Components ============================================*/
00091 #ifndef RADIO_TYPE
00092 #define RADIO_TYPE (RADIO_AT86RF230B)    
00093 #endif
00094 
00095 /*=== TRX pin access macros ==========================================*/
00096 
00097 #define DDR_TRX_RESET   DDRB            
00098 #define PORT_TRX_RESET  PORTB           
00099 #define MASK_TRX_RESET  (_BV(PB0))      
00100 /* check in board.h if standard definitions of TRX_RESET_INIT,
00101    TRX_RESET_HIGH, TRX_RESET_LOW are Ok, otherwise define here */
00102 
00103 #define PORT_TRX_SLPTR  PORTB           
00104 #define DDR_TRX_SLPTR   DDRB            
00105 #define MASK_TRX_SLPTR  (_BV(PB1))      
00106 /* check in board.h if standard definitions of TRX_SLPTR_INIT,
00107    TRX_SLPTR_HIGH, TRX_SLPTR_LOW are Ok, otherwise define here */
00108 
00109 /*=== IRQ access macros ==============================================*/
00110 # define TRX_IRQ         _BV(INT0)      
00111 # define TRX_IRQ_vect    INT0_vect      
00114 # define TRX_IRQ_INIT()  do{\
00115                             MCUCR = _BV(ISC00) | _BV(ISC01);\
00116                             GIMSK  |= _BV(INT0);\
00117                           } while(0) 
00120 #define DI_TRX_IRQ() {GIMSK &= (~(TRX_IRQ));}
00121 
00122 #define EI_TRX_IRQ() {GIMSK |= (TRX_IRQ);}
00123 
00125 #define TRX_TSTAMP_REG TCNT1
00126 
00127 /*=== SPI access macros ==============================================*/
00128 #define SPI_TYPE  SPI_TYPE_USI
00129 #define DDR_SPI  (DDRA)   
00130 #define PORT_SPI (PORTA)  
00132 #define SPI_MOSI _BV(PA5)  
00133 #define SPI_MISO _BV(PA6)  
00134 #define SPI_SCK  _BV(PA4)  
00135 #define SPI_SS   _BV(PA7)  
00137 #define SPI_DATA_REG USIDR  
00143 static inline void SPI_INIT(uint8_t spirate)
00144 {
00145     /* first configure SPI Port, then SPCR */
00146     DDR_SPI  |= SPI_MOSI | SPI_SCK | SPI_SS;
00147     DDR_SPI  &= ~SPI_MISO;
00148     PORT_SPI |=  SPI_SS | SPI_MISO;
00149 }
00150 
00152 #define SPI_SELN_LOW()       uint8_t sreg = SREG; cli(); PORT_SPI &=~SPI_SS
00153 
00154 #define SPI_SELN_HIGH()      PORT_SPI |= SPI_SS; SREG = sreg
00155 
00156 #define SPI_WAITFOR()  \
00157     do \
00158     { \
00159         USISR = _BV(USIOIF); \
00160         do \
00161         { \
00162             USICR = _BV(USIWM0)|_BV(USICS1)|_BV(USICLK)|_BV(USITC); \
00163         } while ((USISR & _BV(USIOIF)) == 0); \
00164     } while(0)
00165 
00166 /*=== LED access macros ==============================================*/
00167 #define LED_PORT      PORTA      
00168 #define LED_DDR       DDRA       
00169 #define LED_MASK      (0x03)     
00170 #define LED_SHIFT     (0)        
00171 #define LEDS_INVERSE  (0)        
00173 #define LED_NUMBER    (2)        
00176 /*=== KEY access macros ==============================================*/
00177 //#define NO_KEYS       (1)        /**< if defined, no KEYS are connected */
00178 #define PORT_KEY      PORTA      
00179 #define PIN_KEY       PINA       
00180 #define DDR_KEY       DDRA       
00181 #define MASK_KEY      (0x04)     
00182 #define SHIFT_KEY     (2)        
00183 #define INVERSE_KEYS  (1)        
00185 #define PULLUP_KEYS  (1)
00186 
00187 #define SLEEP_ON_KEY_INIT() \
00188         do{\
00189             PCMSK0 |= _BV(PCINT2);\
00190         }while(0)
00191 
00192 #define SLEEP_ON_KEY() \
00193         do{\
00194             GIMSK |= _BV(PCIE0);\
00195             set_sleep_mode(SLEEP_MODE_PWR_DOWN);\
00196             sleep_mode();\
00197             GIMSK &= ~_BV(PCIE0);\
00198         } while(0)
00199 
00200 #define SLEEP_ON_KEY_vect PCINT0_vect
00201 
00202 
00203 /*=== Host Interface ================================================*/
00205 #define HIF_TYPE    HIF_NONE
00206 
00207 /*=== TIMER Interface ===============================================*/
00208 #define HWTMR_PRESCALE  (1)
00209 #define HWTIMER_TICK    ((1.0*HWTMR_PRESCALE)/F_CPU) 
00212 #define HWTIMER_TICK_NB (0xffffUL) 
00214 #define HWTIMER_REG (TCNT1) 
00216 #define TIMER_TICK (HWTIMER_TICK * HWTIMER_TICK_NB)
00217 
00220 #define TIMER_POOL_SIZE (1) 
00223 #define TIMER_INIT() \
00224     do{\
00225         TCCR1B |= _BV(CS10);\
00226         TIMSK1 |= _BV(TOIE1);\
00227     }while(0)
00228 
00230 #define TIMER_IRQ_vect  TIM1_OVF_vect
00231 
00232 #endif /* BOARD_TINY230_H*/

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