# board_stk541.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_stk541.h,v 1.21 2011/01/09 14:23:18 awachtler Exp $ */
    00087 #if defined(psk230)
    00088 # define BOARD_TYPE (BOARD_PSK230)
    00089 # define BOARD_NAME "psk230"
    00090 # define RADIO_TYPE (RADIO_AT86RF230A)
    00091 #elif defined(psk230b)
    00092 # define BOARD_TYPE (BOARD_PSK230B)
    00093 # define BOARD_NAME "psk230b"
    00094 # define RADIO_TYPE (RADIO_AT86RF230B)
    00095 #elif defined(psk231)
    00096 # define BOARD_TYPE (BOARD_PSK231)
    00097 # define BOARD_NAME "psk231"
    00098 # define RADIO_TYPE (RADIO_AT86RF231)
    00099 #elif defined(psk212)
    00100 # define BOARD_TYPE (BOARD_PSK212)
    00101 # define BOARD_NAME "psk212"
    00102 # define RADIO_TYPE (RADIO_AT86RF212)
    00103 #endif
    00104
    00105 #ifndef BOARD_STK541_H
    00106 #define BOARD_STK541_H
    00107
    00108 /*=== Compile time parameters ========================================*/
    00109 #ifndef DEFAULT_SPI_RATE
    00110 # define DEFAULT_SPI_RATE  (SPI_RATE_1_2)
    00111 #endif
    00112
    00113 /*=== radio interface definition =====================================*/
    00114 #if BOARD_TYPE == BOARD_PSK230 || BOARD_TYPE == BOARD_PSK230B
    00115 # include "base_rdk230.h"
    00116 #else
    00117 # include "base_rdk2xx.h"
    00118 #endif
    00119
    00120 /*=== LED access macros ==============================================*/
    00121 #define LED_PORT      PORTE
    00122 #define LED_DDR       DDRE
    00123 #define LED_MASK      (0x1c)
    00124 #define LED_SHIFT     (2)
    00125 #define LEDS_INVERSE  (1)
    00126 #define LED_NUMBER    (3)
    00127 /*=== KEY access macros ==============================================*/
    00128 #define PORT_KEY      PORTE
    00129 #define PIN_KEY       PINE
    00130 #define DDR_KEY       DDRE
    00131 #define MASK_KEY      (0x20)
    00132 #define SHIFT_KEY     (5)
    00133 #define INVERSE_KEYS  (1)
    00134 #define PULLUP_KEYS   (1)
    00135
    00136 /*=== Host Interface ================================================*/
    00137 #define HIF_TYPE      (HIF_FT245)
    00138 #define HIF_IO_ENABLE XRAM_ENABLE
    00139
    00140 #define USB_FIFO_AD  0xF000
    00141 #define HIF_USB_READ()  (*(volatile uint8_t*)(USB_FIFO_AD))
    00142 #define HIF_USB_WRITE(x) do { (*(volatile uint8_t*)(USB_FIFO_AD)) = (x); }while(0)
    00143 #define XRAM_ENABLE() do {\
    00144     DDRC = 0xFF;\
    00145     PORTC = 0x00;\
    00146     XMCRA |= (1 << SRE);\
    00147     XMCRB = (1 << XMBK);\
    00148     } while(0)
    00149
    00150 #define HIF_NO_DATA   (0x0100)
    00151 #define FT245_DDR    DDRE
    00152 #define FT245_PORT   PORTE
    00153 #define FT245_PIN    PINE
    00154 #define FT245_TXE    _BV(6)
    00155 #define FT245_RXF    _BV(7)
    00156 #define FT245_INIT() do { \
    00157            XMCRA |= (1 << SRE); \
    00158            XMCRB = (1 << XMBK);\
    00159            FT245_DDR &= ~(FT245_TXE|FT245_RXF);\
    00160            FT245_PORT |= (FT245_TXE|FT245_RXF);\
    00161         } while(0)
    00162 #define TX_IS_READY        (0)
    00163 #define TX_IS_BLOCKED      (FT245_TXE)
    00164 #define RX_HAS_DATA        (0)
    00165 #define RX_HAS_NO_DATA     (FT245_RXF)
    00166 #define FT245_RX_DATA()  ((FT245_PIN & FT245_RXF))
    00167 #define FT245_TX_DATA()  ((FT245_PIN & FT245_TXE))
    00168
    00169 /*=== TIMER Interface ===============================================*/
    00170 #define HWTMR_PRESCALE  (1)
    00171 #define HWTIMER_TICK    ((1.0*HWTMR_PRESCALE)/F_CPU)
    00172 #define HWTIMER_TICK_NB (0xFFFFUL+1)
    00173 #define HWTIMER_REG     (TCNT1)
    00174 #define TIMER_TICK      (HWTIMER_TICK_NB * HWTIMER_TICK)
    00175 #define TIMER_POOL_SIZE (4)
    00176
    00178 #define TIMER_IRQ_vect   TIMER1_OVF_vect
    00179
    00189 # define TIMER_INIT() \
    00190     do{ \
    00191         TCCR1B |= (_BV(CS10));\
    00192         TIMSK1 |= _BV(TOIE1); \
    00193     }while(0)
    00194
    00195
    00196 /*=== DBG interface =================================================*/
    00197 # define DBG_PORT PORTD
    00198 # define DBG_DDR DDRD
    00199 # define DBG_PIN (1<<PD0)
    00200
    00201 #endif /* BOARD_STK541_H */