Contiki 2.6
|
00001 /* 00002 * Copyright (c) 2010, Swedish Institute of Computer Science. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. 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 * 3. Neither the name of the Institute 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 INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 00018 * 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 INSTITUTE OR CONTRIBUTORS BE LIABLE 00021 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00023 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00024 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00025 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00026 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00027 * SUCH DAMAGE. 00028 */ 00029 00030 /** 00031 * \file 00032 * Platform configuration for the wismote platform. 00033 */ 00034 00035 #ifndef __PLATFORM_CONF_H__ 00036 #define __PLATFORM_CONF_H__ 00037 00038 /* 00039 * Definitions below are dictated by the hardware and not really 00040 * changeable! 00041 */ 00042 00043 #define PLATFORM_HAS_LEDS 1 00044 #define PLATFORM_HAS_BUTTON 1 00045 00046 /* CPU target speed in Hz */ 00047 #define F_CPU 16000000uL 00048 00049 /* Our clock resolution, this is the same as Unix HZ. */ 00050 #define CLOCK_CONF_SECOND 128UL 00051 #define RTIMER_CONF_SECOND (4096U*8) 00052 00053 #define BAUD2UBR(baud) (baud) 00054 00055 #define CCIF 00056 #define CLIF 00057 00058 #define HAVE_STDINT_H 00059 #include "msp430def.h" 00060 00061 00062 /* Types for clocks and uip_stats */ 00063 typedef unsigned short uip_stats_t; 00064 typedef unsigned long clock_time_t; 00065 typedef unsigned long off_t; 00066 00067 /* the low-level radio driver */ 00068 #define NETSTACK_CONF_RADIO cc2520_driver 00069 00070 #define ROM_ERASE_UNIT_SIZE 512 00071 #define XMEM_ERASE_UNIT_SIZE (64*1024L) 00072 00073 00074 #define CFS_CONF_OFFSET_TYPE long 00075 00076 00077 /* Use the first 64k of external flash for node configuration */ 00078 #define NODE_ID_XMEM_OFFSET (0 * XMEM_ERASE_UNIT_SIZE) 00079 00080 /* Use the second 64k of external flash for codeprop. */ 00081 #define EEPROMFS_ADDR_CODEPROP (1 * XMEM_ERASE_UNIT_SIZE) 00082 00083 #define CFS_XMEM_CONF_OFFSET (2 * XMEM_ERASE_UNIT_SIZE) 00084 #define CFS_XMEM_CONF_SIZE (1 * XMEM_ERASE_UNIT_SIZE) 00085 00086 #define CFS_RAM_CONF_SIZE 4096 00087 00088 /* 00089 * SPI bus configuration for the wismote 00090 */ 00091 00092 /* SPI input/output registers. */ 00093 #define SPI_TXBUF UCB0TXBUF 00094 #define SPI_RXBUF UCB0RXBUF 00095 00096 /* USART0 Tx ready? */ 00097 #define SPI_WAITFOREOTx() while ((UCB0STAT & UCBUSY) != 0) 00098 /* USART0 Rx ready? */ 00099 #define SPI_WAITFOREORx() while ((UCB0IFG & UCRXIFG) == 0) 00100 /* USART0 Tx buffer ready? */ 00101 #define SPI_WAITFORTxREADY() while ((UCB0IFG & UCTXIFG) == 0) 00102 /* /\* USART0 Tx ready? *\/ */ 00103 /* #define SPI_WAITFOREOTx() while (!(UCB0IFG & UCRXIFG)) */ 00104 /* /\* USART0 Rx ready? *\/ */ 00105 /* #define SPI_WAITFOREORx() while (!(UCB0IFG & UCRXIFG)) */ 00106 /* /\* USART0 Tx buffer ready? *\/ */ 00107 /* #define SPI_WAITFORTxREADY() while (!(UCB0IFG & UCRXIFG)) */ 00108 /* #define SPI_BUSY_WAIT() while ((UCB0STAT & UCBUSY) == 1) */ 00109 00110 #define MOSI 1 /* P3.1 - Output: SPI Master out - slave in (MOSI) */ 00111 #define MISO 2 /* P3.2 - Input: SPI Master in - slave out (MISO) */ 00112 #define SCK 3 /* P3.3 - Output: SPI Serial Clock (SCLK) */ 00113 /* #define SCK 1 /\* P3.1 - Output: SPI Serial Clock (SCLK) *\/ */ 00114 /* #define MOSI 2 /\* P3.2 - Output: SPI Master out - slave in (MOSI) *\/ */ 00115 /* #define MISO 3 /\* P3.3 - Input: SPI Master in - slave out (MISO) *\/ */ 00116 00117 /* 00118 * SPI bus - M25P80 external flash configuration. 00119 */ 00120 00121 #define FLASH_PWR //3 /* P4.3 Output */ 00122 #define FLASH_CS //4 /* P4.4 Output */ 00123 #define FLASH_HOLD //7 /* P4.7 Output */ 00124 00125 /* Enable/disable flash access to the SPI bus (active low). */ 00126 00127 #define SPI_FLASH_ENABLE() //( P4OUT &= ~BV(FLASH_CS) ) 00128 #define SPI_FLASH_DISABLE() //( P4OUT |= BV(FLASH_CS) ) 00129 00130 #define SPI_FLASH_HOLD() // ( P4OUT &= ~BV(FLASH_HOLD) ) 00131 #define SPI_FLASH_UNHOLD() //( P4OUT |= BV(FLASH_HOLD) ) 00132 00133 /* 00134 * SPI bus - CC2520 pin configuration. 00135 */ 00136 00137 #define CC2520_CONF_SYMBOL_LOOP_COUNT 2604 /* 326us msp430X @ 16MHz */ 00138 00139 /* P1.6 - Input: FIFOP from CC2520 */ 00140 #define CC2520_FIFOP_PORT(type) P1##type 00141 #define CC2520_FIFOP_PIN 6 00142 /* P1.5 - Input: FIFO from CC2520 */ 00143 #define CC2520_FIFO_PORT(type) P1##type 00144 #define CC2520_FIFO_PIN 5 00145 /* P1.7 - Input: CCA from CC2520 */ 00146 #define CC2520_CCA_PORT(type) P1##type 00147 #define CC2520_CCA_PIN 7 00148 /* P2.0 - Input: SFD from CC2520 */ 00149 #define CC2520_SFD_PORT(type) P2##type 00150 #define CC2520_SFD_PIN 0 00151 /* P3.0 - Output: SPI Chip Select (CS_N) */ 00152 #define CC2520_CSN_PORT(type) P3##type 00153 #define CC2520_CSN_PIN 0 00154 /* P4.3 - Output: VREG_EN to CC2520 */ 00155 #define CC2520_VREG_PORT(type) P4##type 00156 #define CC2520_VREG_PIN 3 00157 /* P4.4 - Output: RESET_N to CC2520 */ 00158 #define CC2520_RESET_PORT(type) P4##type 00159 #define CC2520_RESET_PIN 4 00160 00161 #define CC2520_IRQ_VECTOR PORT1_VECTOR 00162 00163 /* Pin status.CC2520 */ 00164 #define CC2520_FIFOP_IS_1 (!!(CC2520_FIFOP_PORT(IN) & BV(CC2520_FIFOP_PIN))) 00165 #define CC2520_FIFO_IS_1 (!!(CC2520_FIFO_PORT(IN) & BV(CC2520_FIFO_PIN))) 00166 #define CC2520_CCA_IS_1 (!!(CC2520_CCA_PORT(IN) & BV(CC2520_CCA_PIN))) 00167 #define CC2520_SFD_IS_1 (!!(CC2520_SFD_PORT(IN) & BV(CC2520_SFD_PIN))) 00168 00169 /* The CC2520 reset pin. */ 00170 #define SET_RESET_INACTIVE() (CC2520_RESET_PORT(OUT) |= BV(CC2520_RESET_PIN)) 00171 #define SET_RESET_ACTIVE() (CC2520_RESET_PORT(OUT) &= ~BV(CC2520_RESET_PIN)) 00172 00173 /* CC2520 voltage regulator enable pin. */ 00174 #define SET_VREG_ACTIVE() (CC2520_VREG_PORT(OUT) |= BV(CC2520_VREG_PIN)) 00175 #define SET_VREG_INACTIVE() (CC2520_VREG_PORT(OUT) &= ~BV(CC2520_VREG_PIN)) 00176 00177 /* CC2520 rising edge trigger for external interrupt 0 (FIFOP). */ 00178 #define CC2520_FIFOP_INT_INIT() do { \ 00179 CC2520_FIFOP_PORT(IES) &= ~BV(CC2520_FIFOP_PIN); \ 00180 CC2520_CLEAR_FIFOP_INT(); \ 00181 } while(0) 00182 00183 /* FIFOP on external interrupt 0. */ 00184 /* FIFOP on external interrupt 0. */ 00185 #define CC2520_ENABLE_FIFOP_INT() do { P1IE |= BV(CC2520_FIFOP_PIN); } while (0) 00186 #define CC2520_DISABLE_FIFOP_INT() do { P1IE &= ~BV(CC2520_FIFOP_PIN); } while (0) 00187 #define CC2520_CLEAR_FIFOP_INT() do { P1IFG &= ~BV(CC2520_FIFOP_PIN); } while (0) 00188 00189 /* 00190 * Enables/disables CC2520 access to the SPI bus (not the bus). 00191 * (Chip Select) 00192 */ 00193 00194 /* ENABLE CSn (active low) */ 00195 #define CC2520_SPI_ENABLE() do{ UCB0CTL1 &= ~UCSWRST; clock_delay(5); P3OUT &= ~BIT0;clock_delay(5);}while(0) 00196 /* DISABLE CSn (active low) */ 00197 #define CC2520_SPI_DISABLE() do{clock_delay(5);UCB0CTL1 |= UCSWRST;clock_delay(1); P3OUT |= BIT0;clock_delay(5);}while(0) 00198 #define CC2520_SPI_IS_ENABLED() ((CC2520_CSN_PORT(OUT) & BV(CC2520_CSN_PIN)) != BV(CC2520_CSN_PIN)) 00199 00200 #endif /* __PLATFORM_CONF_H__ */