diff --git a/cpu/cc2430/8051def.h b/cpu/cc2430/8051def.h index cabcccbd0..add1f7eda 100644 --- a/cpu/cc2430/8051def.h +++ b/cpu/cc2430/8051def.h @@ -70,8 +70,13 @@ typedef unsigned int size_t; * @see uip_arch.h * @see uip_arch-asm.S */ -#define UIP_ARCH_ADD32 1 -#define UIP_ARCH_CHKSUM 1 +/* + * DO NOT USE UIP_ARCH flags! + * uip_arch code was copied from z80 directory but NOT ported + */ + +#define UIP_ARCH_ADD32 0 +#define UIP_ARCH_CHKSUM 0 #define UIP_ARCH_IPCHKSUM #define CC_CONF_ASSIGN_AGGREGATE(dest, src) \ diff --git a/cpu/cc2430/cc2430_sfr.h b/cpu/cc2430/cc2430_sfr.h index 0a8fb0161..d3191ed12 100644 --- a/cpu/cc2430/cc2430_sfr.h +++ b/cpu/cc2430/cc2430_sfr.h @@ -700,4 +700,6 @@ __xdata __at (0xDFD9) unsigned char RFD_SHADOW; __xdata __at (0xDFF9) unsigned char U1BUF_SHADOW; +__xdata __at (0xDFBA) unsigned int ADC_SHADOW; + #endif /*REG_CC2430*/ diff --git a/cpu/cc2430/dev/dma.c b/cpu/cc2430/dev/dma.c index 494778e77..f4a12bb89 100644 --- a/cpu/cc2430/dev/dma.c +++ b/cpu/cc2430/dev/dma.c @@ -35,7 +35,7 @@ dma_init(void) /*---------------------------------------------------------------------------*/ #ifdef HAVE_DMA /** - * Configure a DMA channel. + * Configure a DMA channel except word mode. * * \param channel channel ID; * \param src source address; @@ -55,6 +55,33 @@ xDMAHandle dma_config(uint8_t channel, void *src, dma_inc_t src_inc, void *dst, dma_inc_t dst_inc, uint16_t length, dma_vlen_t vlen_mode, dma_type_t t_mode, dma_trigger_t trigger, struct process * proc) +{ + return dma_config2(channel,src,src_inc, dst, dst_inc, length, 0, vlen_mode, t_mode, trigger, proc); +} + +/*---------------------------------------------------------------------------*/ +/** + * Configure a DMA channel. + * + * \param channel channel ID; + * \param src source address; + * \param src_inc source increment mode; + * \param dst dest address; + * \param dst_inc dest increment mode; + * \param length maximum length; + * \param word_mode set to 1 for 16-bits per transfer; + * \param vlen_mode variable length mode; + * \param t_mode DMA transfer mode; + * \param trigger DMA trigger; + * \param proc process that is upon interrupt; + * + * \return Handle to DMA channel + * \return 0 invalid channel + */ +xDMAHandle +dma_config2(uint8_t channel, void *src, dma_inc_t src_inc, void *dst, dma_inc_t dst_inc, + uint16_t length, uint8_t word_mode, dma_vlen_t vlen_mode, dma_type_t t_mode, dma_trigger_t trigger, + struct process * proc) { if((!channel) || (channel > 4)) { return 0; @@ -70,7 +97,7 @@ dma_config(uint8_t channel, void *src, dma_inc_t src_inc, void *dst, dma_inc_t d dma_conf[channel].dst_l = ((uint16_t) dst); dma_conf[channel].len_h = vlen_mode + (length >> 8); dma_conf[channel].len_l = length; - dma_conf[channel].t_mode = (t_mode << 5) + trigger; + dma_conf[channel].t_mode = ((word_mode&0x1)<<7) | (t_mode << 5) | trigger; dma_conf[channel].addr_mode = (src_inc << 6) + (dst_inc << 4) + 2; /*DMA has priority*/ /*Callback is defined*/ @@ -176,7 +203,7 @@ dma_config_print(xDMAHandle channel) uint8_t *ptr = (uint8_t *)&(dma_conf[ch_id]); for(i = 0; i< 8; i++) { if(i != 0) { - printf(":%x", *ptr++); + printf(":%02x", *ptr++); } } printf("\n"); @@ -216,7 +243,6 @@ dma_ISR(void) __interrupt (DMA_VECTOR) spi_rx_dma_callback(); } #endif - #ifdef HAVE_DMA for(i = 0; i < 4; i++) { if((DMAIRQ & (1 << i + 1)) != 0) { diff --git a/cpu/cc2430/dev/hwconf.h b/cpu/cc2430/dev/hwconf.h new file mode 100644 index 000000000..b795b5657 --- /dev/null +++ b/cpu/cc2430/dev/hwconf.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2005, Swedish Institute of Computer Science + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the Contiki operating system. + * + * @(#)$Id: hwconf.h,v 1.1 2009/12/22 09:28:15 zdshelby Exp $ + */ +#ifndef __HWCONF_H__ +#define __HWCONF_H__ + +#include "sys/cc.h" + +#include +extern uint8_t p0ien; +extern uint8_t p2ien; + +#define HWCONF_PIN(name, port, bit) \ +static CC_INLINE void name##_SELECT() { P##port##SEL &= ~(1 << bit);} \ +static CC_INLINE void name##_SELECT_IO() { P##port##SEL &= ~(1 << bit);} \ +static CC_INLINE void name##_SELECT_PM() { P##port##SEL |= 1 << bit;} \ +static CC_INLINE void name##_SET() { P##port##_##bit = 1; } \ +static CC_INLINE void name##_CLEAR() { P##port##_##bit = 0; } \ +static CC_INLINE unsigned char name##_READ() { return P##port##_##bit; } \ +static CC_INLINE void name##_MAKE_OUTPUT() { P##port##DIR |= 1 << bit;} \ +static CC_INLINE void name##_MAKE_INPUT() { P##port##DIR &= ~(1 << bit); } + +#define HWCONF_IRQ_XXX(name, port, bit) \ +static CC_INLINE void name##_ENABLE_IRQ() { \ + if ( port == 2 ) { PICTL |= P2IEN; p2ien |= 1<=4)) { PICTL |= P0IENH; p0ien |= 1<=4)) { \ + p0ien &= ~(1< +#include "contiki-conf.h" + +#ifdef LPM_CONF_ON +#define LPM_ON LPM_CONF_ON +#else +#define LPM_ON LPM1 +#endif /* LPM_CONF_ON */ + +#ifdef LPM_CONF_OFF +#define LPM_OFF LPM_CONF_OFF +#else +#define LPM_OFF LPM1_EXIT +#endif /* LPM_CONF_OFF */ + +#define LPM_SLEEP() do { if(lpm_status == LPM_STATUS_ON) LPM_ON; } while(0) +#define LPM_AWAKE() do { if(lpm_status == LPM_STATUS_ON) LPM_OFF; } while(0) + +extern unsigned char lpm_status; + +void lpm_on(void); +void lpm_off(void); + +#define LPM_STATUS_OFF 0 +#define LPM_STATUS_ON 1 + + +#endif /* __LPM_H__ */ diff --git a/cpu/cc2430/dev/uart.c b/cpu/cc2430/dev/uart.c index f1ad42ec7..32e5a9da3 100644 --- a/cpu/cc2430/dev/uart.c +++ b/cpu/cc2430/dev/uart.c @@ -13,9 +13,19 @@ static int (*uart1_input_handler)(unsigned char c); void uart0_init(uint32_t speed) { - if(speed != 115200) { - return; + if(speed == 115200) { + U0BAUD=216; /*115200*/ + U0GCR =11; /*LSB first and 115200*/ } + else if(speed == 38400) { + U0BAUD=59; /*38400*/ + U0GCR =10; /*LSB first and 38400*/ + } + else if(speed == 9600) { + U0BAUD= 59; /* 9600 */ + U0GCR = 8; /*LSB first and 9600*/ + } + else { return; } #ifdef UART0_ALTERNATIVE_2 PERCFG |= U0CFG; /*alternative port 2 = P1.5-2*/ @@ -39,20 +49,6 @@ uart0_init(uint32_t speed) P0DIR &= ~0x14; /*CTS & RX in*/ #endif - if(speed == 115200) { - U0BAUD=216; /*115200*/ - U0GCR =11; /*LSB first and 115200*/ - } - - if(speed == 38400) { - U0BAUD=59; /*38400*/ - U0GCR =10; /*LSB first and 38400*/ - } - - if(speed == 9600) { - U0BAUD= 59; /* 9600 */ - U0GCR = 8; /*LSB first and 9600*/ - } #ifdef UART0_RTSCTS U0UCR = 0x42; /*defaults: 8N1, RTS/CTS, high stop bit*/ diff --git a/cpu/cc2430/io.h b/cpu/cc2430/io.h new file mode 100644 index 000000000..c14ed21f0 --- /dev/null +++ b/cpu/cc2430/io.h @@ -0,0 +1,10 @@ +#ifndef __IO_H__ +#define __IO_H__ + +#include + +#ifndef BV +#define BV(x) (1<<(x)) +#endif + +#endif /* __IO_H__ */