board_midgee.h

Go to the documentation of this file.
00001 /* Copyright (c) 2012
00002     Daniel Thiele,
00003     Axel Wachtler
00004    All rights reserved.
00005 
00006    Redistribution and use in source and binary forms, with or without
00007    modification, are permitted provided that the following conditions
00008    are met:
00009 
00010    * Redistributions of source code must retain the above copyright
00011      notice, this list of conditions and the following disclaimer.
00012    * Redistributions in binary form must reproduce the above copyright
00013      notice, this list of conditions and the following disclaimer in the
00014      documentation and/or other materials provided with the distribution.
00015    * Neither the name of the authors nor the names of its contributors
00016      may be used to endorse or promote products derived from this software
00017      without specific prior written permission.
00018 
00019    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00020    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00023    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00024    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00025    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00026    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00027    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00028    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029    POSSIBILITY OF SUCH DAMAGE. */
00030 
00031 /* $Id: board__midgee_8h_source.html,v 1.1.1.3 2013/04/09 21:11:31 awachtler Exp $ */
00067 #ifndef BOARD_MIDGEE_H
00068 #define BOARD_MIDGEE_H  (1)
00069 
00070 # define BOARD_TYPE (BOARD_MIDGEE)
00071 # define BOARD_NAME "Midgee"     
00072 # define RADIO_TYPE (RADIO_AT86RF232)  
00074 /*=== Compile time parameters ========================================*/
00075 
00076 #ifndef DEFAULT_SPI_RATE
00077 # define DEFAULT_SPI_RATE  (SPI_RATE_1_2)
00078 #endif
00079 
00080 /*=== Hardware Components ============================================*/
00081 
00082 /*=== TRX pin access macros ==========================================*/
00083 
00084 #define DDR_TRX_RESET   DDRC          
00085 #define PORT_TRX_RESET  PORTC         
00086 #define MASK_TRX_RESET  ((1<<2))      
00087 /* check in board.h if standard definitions of TRX_RESET_INIT,
00088    TRX_RESET_HIGH, TRX_RESET_LOW are Ok, otherwise define here */
00089 
00090 #define PORT_TRX_SLPTR  PORTC         
00091 #define DDR_TRX_SLPTR   DDRC          
00092 #define MASK_TRX_SLPTR  ((1<<0))    
00096 /*=== IRQ access macros ==============================================*/
00097 
00098 #define TRX_IRQ_PORT (PORTB)
00099 #define TRX_IRQ_DDR (DDRB)
00100 #define TRX_IRQ_PIN (PINB)
00101 #define TRX_IRQ_bp  (0)
00102 
00103 # define TRX_IRQ_vect    TIMER1_CAPT_vect    
00107 # define TRX_IRQ_INIT()  do{ TCCR1B = (1<<ICES1) | (1<<CS10); } while(0) 
00108 #define DI_TRX_IRQ() { TIMSK1 &= ~(1<<ICIE1); }
00109 #define EI_TRX_IRQ() { TIMSK1 |= (1<<ICIE1); }
00110 
00111 /*=== SPI access macros ==============================================*/
00112 #define SPI_TYPE  SPI_TYPE_SPI
00113 #define DDR_SPI  (DDRB)   
00114 #define PORT_SPI (PORTB)  
00116 #define SPI_MOSI (1<<PB3)  
00117 #define SPI_MISO (1<<PB4)  
00118 #define SPI_SCK  (1<<PB5)  
00119 #define SPI_SS   (1<<PB2)  
00122 #define SPI_DATA_REG SPDR    
00128 static inline void SPI_INIT(uint8_t spirate)
00129 {
00130     /* first configure SPI Port, then SPCR */
00131     
00132     PORT_SPI |= SPI_SS | SPI_MISO | SPI_MOSI | SPI_SCK;
00133     DDR_SPI  |= SPI_MOSI | SPI_SCK | SPI_SS;
00134     DDR_SPI  &= ~SPI_MISO;
00135 
00136     SPCR = ((1<<SPE) | (1<<MSTR));
00137     
00138     SPCR &= ~((1<<SPR1) | (1<<SPR0) );
00139     SPSR &= ~(1<<SPI2X);
00140 
00141     SPCR |= (spirate & 0x03);
00142     SPSR |= ((spirate >> 2) & 0x01);
00143 }
00144 
00146 #define SPI_SELN_LOW()       uint8_t sreg = SREG; cli(); PORT_SPI &=~SPI_SS
00147 
00148 #define SPI_SELN_HIGH()      PORT_SPI |= SPI_SS; SREG = sreg
00149 
00150 #define SPI_WAITFOR()        do { while((SPSR & (1<<SPIF)) == 0);} while(0)
00151 
00152 /*=== LED access macros ==============================================*/
00153 
00154 #define LED_PORT      PORTD      
00155 #define LED_DDR       DDRD       
00156 #define LED_MASK      (0x10)     
00157 #define LED_SHIFT     (3)        
00158 #define LEDS_INVERSE  (0)        
00160 #define LED_NUMBER    (2)        
00162 /* special handling for this board to enable light measurement */
00163 #define LED_PIN       PIND       
00164 #define LED_ANODE_bp   (4)      
00165 #define LED_CATHODE_bp (3)      
00167 /* special handling required */
00168 #define LED_INIT() do{ LED_PORT &= ~((1<<LED_CATHODE_bp) | (1<<LED_ANODE_bp)); \
00169             LED_DDR |= ((1<<LED_CATHODE_bp) | (1<<LED_ANODE_bp)); }while(0)
00170 
00171 /*=== KEY access macros ==============================================*/
00172 #define NO_KEYS       (1)        
00174 /*=== Host Interface ================================================*/
00175 
00176 #define HIF_TYPE    HIF_NONE
00177 
00178 /*=== TIMER Interface ===============================================*/
00179 
00180 /* setup timer with a tick of 1ms (assuming F_CPU = 8MHz fixed) */
00181 
00182 #define HWTMR_PRESCALE  (8)
00183 #define HWTIMER_TICK    ((1.0*HWTMR_PRESCALE)/F_CPU)
00184 #define HWTIMER_TICK_NB (1000UL)
00185 #define HWTIMER_REG     (TCNT1)
00186 #define TIMER_TICK      (HWTIMER_TICK_NB * HWTIMER_TICK)
00187 #define TIMER_POOL_SIZE (4)
00188 #define TIMER_INIT() \
00189     do{ \
00190         TCCR1B = 0; \
00191         OCR1A = HWTIMER_TICK_NB; \
00192         TCCR1B |= ((1<<WGM12) | (1<<CS11)); \
00193         TIMSK1 |= (1<<OCIE1A); \
00194     }while(0)
00195 # define TIMER_IRQ_vect   TIMER1_COMPA_vect
00196 
00197 /*=== Special Hardware Ressources ===================================*/
00198 
00199 #endif /* BOARD_ROSE231_H */

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