Merge remote-tracking branch 'origin/master'

This commit is contained in:
Oliver Schmidt 2011-04-10 13:23:13 +02:00
commit c6c0d6247b
27 changed files with 252 additions and 50 deletions

View File

@ -39,6 +39,7 @@
*/ */
#include "contiki.h" #include "contiki.h"
#include "io.h"
#include "dev/cc2420.h" #include "dev/cc2420.h"
#include "dev/cc2420-aes.h" #include "dev/cc2420-aes.h"
#include "dev/spi.h" #include "dev/spi.h"

View File

@ -41,8 +41,12 @@
#if defined(__AVR__) #if defined(__AVR__)
#include <avr/io.h> #include <avr/io.h>
#elif defined(__MSP430__) #elif defined(__MSP430__)
#ifdef __IAR_SYSTEMS_ICC__
#include <io430.h>
#else
#include <io.h> #include <io.h>
#endif #endif
#endif
#include "dev/leds.h" #include "dev/leds.h"
#include "dev/spi.h" #include "dev/spi.h"

View File

@ -33,9 +33,9 @@
#ifndef __ME_TABS_H__ #ifndef __ME_TABS_H__
#define __ME_TABS_H__ #define __ME_TABS_H__
const unsigned short me_encode_tab[256]; extern const unsigned short me_encode_tab[256];
const unsigned char me_decode_tab[256]; extern const unsigned char me_decode_tab[256];
const unsigned char me_valid_tab[256]; extern const unsigned char me_valid_tab[256];
#endif /* __ME_TABS_H__ */ #endif /* __ME_TABS_H__ */

View File

@ -82,10 +82,10 @@ int neighbor_info_subscribe(neighbor_info_subscriber_t);
/** /**
* Get link ETX value for a specific neighbor. * Get link metric value for a specific neighbor.
* *
* \return Returns ETX if the neighbor exists, and 0 if not. * \return Returns link metric if the neighbor exists, and 0 if not.
*/ */
link_metric_t neighbor_info_get_etx(const rimeaddr_t *addr); link_metric_t neighbor_info_get_metric(const rimeaddr_t *addr);
#endif /* NEIGHBOR_INFO_H */ #endif /* NEIGHBOR_INFO_H */

View File

@ -142,6 +142,8 @@ remove_worst_parent(rpl_dag_t *dag, rpl_rank_t min_worst_rank)
static int static int
should_send_dao(rpl_dag_t *dag, rpl_dio_t *dio, rpl_parent_t *p) should_send_dao(rpl_dag_t *dag, rpl_dio_t *dio, rpl_parent_t *p)
{ {
/* if MOP is set to no downward routes no DAO should be sent */
if(dag->mop == RPL_MOP_NO_DOWNWARD_ROUTES) return 0;
return dio->dtsn > p->dtsn && p == dag->preferred_parent; return dio->dtsn > p->dtsn && p == dag->preferred_parent;
} }
/************************************************************************/ /************************************************************************/
@ -340,19 +342,28 @@ rpl_select_parent(rpl_dag_t *dag)
best = NULL; best = NULL;
for(p = list_head(dag->parents); p != NULL; p = p->next) { for(p = list_head(dag->parents); p != NULL; p = p->next) {
if(best == NULL) { if(p->rank == INFINITE_RANK) {
/* ignore this neighbor */
} else if(best == NULL) {
best = p; best = p;
} else { } else {
best = dag->of->best_parent(best, p); best = dag->of->best_parent(best, p);
} }
} }
if(best == NULL) {
/* need to handle update of best... */
return NULL;
}
if(dag->preferred_parent != best) { if(dag->preferred_parent != best) {
dag->preferred_parent = best; /* Cache the value. */ dag->preferred_parent = best; /* Cache the value. */
dag->of->update_metric_container(dag); dag->of->update_metric_container(dag);
rpl_set_default_route(dag, &best->addr); rpl_set_default_route(dag, &best->addr);
/* The DAO parent set changed - schedule a DAO transmission. */ /* The DAO parent set changed - schedule a DAO transmission. */
rpl_schedule_dao(dag); if(dag->mop != RPL_MOP_NO_DOWNWARD_ROUTES) {
rpl_schedule_dao(dag);
}
rpl_reset_dio_timer(dag, 1); rpl_reset_dio_timer(dag, 1);
PRINTF("RPL: New preferred parent, rank changed from %u to %u\n", PRINTF("RPL: New preferred parent, rank changed from %u to %u\n",
(unsigned)dag->rank, dag->of->calculate_rank(best, 0)); (unsigned)dag->rank, dag->of->calculate_rank(best, 0));
@ -638,7 +649,8 @@ rpl_process_parent_event(rpl_dag_t *dag, rpl_parent_t *p)
rpl_reset_dio_timer(dag, 1); rpl_reset_dio_timer(dag, 1);
} }
if(!acceptable_rank(dag, dag->of->calculate_rank(NULL, parent_rank))) { if(parent_rank == INFINITE_RANK ||
!acceptable_rank(dag, dag->of->calculate_rank(NULL, parent_rank))) {
/* The candidate parent is no longer valid: the rank increase resulting /* The candidate parent is no longer valid: the rank increase resulting
from the choice of it as a parent would be too high. */ from the choice of it as a parent would be too high. */
return 0; return 0;

View File

@ -170,7 +170,12 @@
#define RPL_MOP_NON_STORING 1 #define RPL_MOP_NON_STORING 1
#define RPL_MOP_STORING_NO_MULTICAST 2 #define RPL_MOP_STORING_NO_MULTICAST 2
#define RPL_MOP_STORING_MULTICAST 3 #define RPL_MOP_STORING_MULTICAST 3
#ifdef RPL_CONF_MOP
#define RPL_MOP_DEFAULT RPL_CONF_MOP
#else
#define RPL_MOP_DEFAULT RPL_MOP_STORING_NO_MULTICAST #define RPL_MOP_DEFAULT RPL_MOP_STORING_NO_MULTICAST
#endif
/* /*
* The ETX in the metric container is expressed as a fixed-point value * The ETX in the metric container is expressed as a fixed-point value

View File

@ -571,7 +571,10 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_SAM_BIT, iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_SAM_BIT,
&UIP_IP_BUF->srcipaddr, &uip_lladdr); &UIP_IP_BUF->srcipaddr, &uip_lladdr);
/* No context found for this address */ /* No context found for this address */
} else if(uip_is_addr_link_local(&UIP_IP_BUF->srcipaddr)) { } else if(uip_is_addr_link_local(&UIP_IP_BUF->srcipaddr) &&
UIP_IP_BUF->destipaddr.u16[1] == 0 &&
UIP_IP_BUF->destipaddr.u16[2] == 0 &&
UIP_IP_BUF->destipaddr.u16[3] == 0) {
iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_SAM_BIT, iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_SAM_BIT,
&UIP_IP_BUF->srcipaddr, &uip_lladdr); &UIP_IP_BUF->srcipaddr, &uip_lladdr);
} else { } else {
@ -619,7 +622,10 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT, iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT,
&UIP_IP_BUF->destipaddr, (uip_lladdr_t *)rime_destaddr); &UIP_IP_BUF->destipaddr, (uip_lladdr_t *)rime_destaddr);
/* No context found for this address */ /* No context found for this address */
} else if(uip_is_addr_link_local(&UIP_IP_BUF->destipaddr)) { } else if(uip_is_addr_link_local(&UIP_IP_BUF->destipaddr) &&
UIP_IP_BUF->destipaddr.u16[1] == 0 &&
UIP_IP_BUF->destipaddr.u16[2] == 0 &&
UIP_IP_BUF->destipaddr.u16[3] == 0) {
iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT, iphc1 |= compress_addr_64(SICSLOWPAN_IPHC_DAM_BIT,
&UIP_IP_BUF->destipaddr, (uip_lladdr_t *)rime_destaddr); &UIP_IP_BUF->destipaddr, (uip_lladdr_t *)rime_destaddr);
} else { } else {

View File

@ -742,14 +742,20 @@ void rf230_warm_reset(void) {
/* CCA energy threshold = -91dB + 2*SR_CCA_ED_THRESH. Reset defaults to -77dB */ /* CCA energy threshold = -91dB + 2*SR_CCA_ED_THRESH. Reset defaults to -77dB */
/* Use RF230 base of -91; RF231 base is -90 according to datasheet */ /* Use RF230 base of -91; RF231 base is -90 according to datasheet */
#ifdef RF230_CONF_CCA_THRES
#if RF230_CONF_CCA_THRES < -91 #if RF230_CONF_CCA_THRES < -91
#warning
#warning RF230_CONF_CCA_THRES below hardware limit, setting to -91dBm #warning RF230_CONF_CCA_THRES below hardware limit, setting to -91dBm
#warning
hal_subregister_write(SR_CCA_ED_THRES,0); hal_subregister_write(SR_CCA_ED_THRES,0);
#elif RF230_CONF_CCA_THRES > -61 #elif RF230_CONF_CCA_THRES > -61
#warning
#warning RF230_CONF_CCA_THRES above hardware limit, setting to -61dBm #warning RF230_CONF_CCA_THRES above hardware limit, setting to -61dBm
#warning
hal_subregister_write(SR_CCA_ED_THRES,15); hal_subregister_write(SR_CCA_ED_THRES,15);
#else #else
hal_subregister_write(SR_CCA_ED_THRES,(RF230_CONF_CCA_THRES+91)/2); hal_subregister_write(SR_CCA_ED_THRES,(RF230_CONF_CCA_THRES+91)/2);
#endif
#endif #endif
/* Use automatic CRC unless manual is specified */ /* Use automatic CRC unless manual is specified */

View File

@ -70,9 +70,29 @@
#define UART2_UCTS ((volatile uint32_t *) ( UART2_BASE + UCTS )) #define UART2_UCTS ((volatile uint32_t *) ( UART2_BASE + UCTS ))
#define UART2_UBRCNT ((volatile uint32_t *) ( UART2_BASE + UBRCNT )) #define UART2_UBRCNT ((volatile uint32_t *) ( UART2_BASE + UBRCNT ))
extern volatile uint32_t u1_head, u1_tail; /* The mc1322x has a 32 byte hardware FIFO for transmitted characters.
* Currently it is always filled from a larger RAM buffer. It would be
* possible to eliminate that overhead by filling directly from a chain
* of data buffer pointers, but printf's would be not so easy.
*/
#define UART1_TX_BUFFERSIZE 1024
extern volatile uint32_t u1_tx_head, u1_tx_tail;
void uart1_putc(char c); void uart1_putc(char c);
/* The mc1322x has a 32 byte hardware FIFO for received characters.
* If a larger rx buffersize is specified the FIFO will be extended into RAM.
* RAM transfers will occur on interrupt when the FIFO is nearly full.
* If a smaller buffersize is specified hardware flow control will be
* initiated at that FIFO level.
* Set to 32 for no flow control or RAM buffer.
*/
#define UART1_RX_BUFFERSIZE 128
#if UART1_RX_BUFFERSIZE > 32
extern volatile uint32_t u1_rx_head, u1_rx_tail;
#define uart1_can_get() ((u1_rx_head!=u1_rx_tail) || (*UART1_URXCON > 0))
#else
#define uart1_can_get() (*UART1_URXCON > 0) #define uart1_can_get() (*UART1_URXCON > 0)
#endif
uint8_t uart1_getc(void); uint8_t uart1_getc(void);

View File

@ -36,43 +36,91 @@
#include <mc1322x.h> #include <mc1322x.h>
#include <stdint.h> #include <stdint.h>
volatile char u1_tx_buf[1024]; volatile char u1_tx_buf[UART1_TX_BUFFERSIZE];
volatile uint32_t u1_head, u1_tail; volatile uint32_t u1_tx_head, u1_tx_tail;
#if UART1_RX_BUFFERSIZE > 32
volatile char u1_rx_buf[UART1_RX_BUFFERSIZE-32];
volatile uint32_t u1_rx_head, u1_rx_tail;
#endif
void uart1_isr(void) { void uart1_isr(void) {
#if UART1_RX_BUFFERSIZE > 32
if (*UART1_USTAT & ( 1 << 6)) { //receive interrupt
while( *UART1_URXCON != 0 ) { //flush the hardware fifo into the software buffer
uint32_t u1_rx_tail_next;
u1_rx_tail_next = u1_rx_tail+1;
if (u1_rx_tail_next >= sizeof(u1_rx_buf))
u1_rx_tail_next = 0;
if (u1_rx_head != u1_rx_tail_next) {
u1_rx_buf[u1_rx_tail]= *UART1_UDATA;
u1_rx_tail = u1_rx_tail_next;
}
}
return;
}
#endif
while( *UART1_UTXCON != 0 ) { while( *UART1_UTXCON != 0 ) {
if (u1_head == u1_tail) { if (u1_tx_head == u1_tx_tail) {
#if UART1_RX_BUFFERSIZE > 32
*UART1_UCON |= (1 << 13); /*disable tx interrupt */
#else
disable_irq(UART1); disable_irq(UART1);
#endif
return; return;
} }
*UART1_UDATA = u1_tx_buf[u1_tail];
u1_tail++; *UART1_UDATA = u1_tx_buf[u1_tx_tail];
if (u1_tail >= sizeof(u1_tx_buf)) u1_tx_tail++;
u1_tail = 0; if (u1_tx_tail >= sizeof(u1_tx_buf))
u1_tx_tail = 0;
} }
} }
void uart1_putc(char c) { void uart1_putc(char c) {
/* disable UART1 since */ /* disable UART1 since */
/* UART1 isr modifies u1_head and u1_tail */ /* UART1 isr modifies u1_tx_head and u1_tx_tail */
disable_irq(UART1); #if UART1_RX_BUFFERSIZE > 32
*UART1_UCON |= (1 << 13); /*disable tx interrupt */
#else
disable_irq(UART1);
#endif
if( (u1_head == u1_tail) && if( (u1_tx_head == u1_tx_tail) &&
(*UART1_UTXCON != 0)) { (*UART1_UTXCON != 0)) {
*UART1_UDATA = c; *UART1_UDATA = c;
} else { } else {
u1_tx_buf[u1_head] = c; u1_tx_buf[u1_tx_head] = c;
u1_head += 1; u1_tx_head += 1;
if (u1_head >= sizeof(u1_tx_buf)) if (u1_tx_head >= sizeof(u1_tx_buf))
u1_head = 0; u1_tx_head = 0;
if (u1_head == u1_tail) { /* drop chars when no room */ if (u1_tx_head == u1_tx_tail) { /* drop chars when no room */
if (u1_head) { u1_head -=1; } else { u1_head = sizeof(u1_tx_buf); } if (u1_tx_head) { u1_tx_head -=1; } else { u1_tx_head = sizeof(u1_tx_buf); }
} }
#if UART1_RX_BUFFERSIZE > 32
*UART1_UCON &= ~(1 << 13); /*enable tx interrupt */
#else
enable_irq(UART1); enable_irq(UART1);
#endif
} }
} }
uint8_t uart1_getc(void) { uint8_t uart1_getc(void) {
#if UART1_RX_BUFFERSIZE > 32
/* First pull from the ram buffer */
uint8_t c=0;
if (u1_rx_head != u1_rx_tail) {
c = u1_rx_buf[u1_rx_head++];
if (u1_rx_head >= sizeof(u1_rx_buf))
u1_rx_head=0;
return c;
}
#endif
/* Then pull from the hardware fifo */
while(uart1_can_get() == 0) { continue; } while(uart1_can_get() == 0) { continue; }
return *UART1_UDATA; return *UART1_UDATA;
} }

View File

@ -47,26 +47,43 @@ void default_vreg_init(void) {
void uart1_init(uint16_t inc, uint16_t mod, uint8_t samp) { void uart1_init(uint16_t inc, uint16_t mod, uint8_t samp) {
/* UART must be disabled to set the baudrate */ /* UART must be disabled to set the baudrate */
*UART1_UCON = 0; *UART1_UCON = 0;
*UART1_UBRCNT = ( inc << 16 ) | mod; *UART1_UBRCNT = ( inc << 16 ) | mod;
/* TX and CTS as outputs */
GPIO->PAD_DIR_SET.GPIO_14 = 1;
GPIO->PAD_DIR_SET.GPIO_16 = 1;
/* RX and RTS as inputs */
GPIO->PAD_DIR_RESET.GPIO_15 = 1;
GPIO->PAD_DIR_RESET.GPIO_17 = 1;
/* see Section 11.5.1.2 Alternate Modes */ /* see Section 11.5.1.2 Alternate Modes */
/* you must enable the peripheral first BEFORE setting the function in GPIO_FUNC_SEL */ /* you must enable the peripheral first BEFORE setting the function in GPIO_FUNC_SEL */
/* From the datasheet: "The peripheral function will control operation of the pad IF */ /* From the datasheet: "The peripheral function will control operation of the pad IF */
/* THE PERIPHERAL IS ENABLED. */ /* THE PERIPHERAL IS ENABLED. */
*UART1_UCON = (1 << 0) | (1 << 1); /* enable receive, transmit */
#if UART1_RX_BUFFERSIZE > 32
*UART1_UCON = (1 << 0) | (1 << 1) ; /* enable receive, transmit, and both interrupts */
*UART1_URXCON = 30; /* interrupt when fifo is nearly full */
u1_rx_head = 0; u1_rx_tail = 0;
#elif UART1_RX_BUFFERSIZE < 32 /* enable receive, transmit, flow control, disable rx interrupt */
*UART1_UCON = (1 << 0) | (1 << 1) | (1 << 12) | (1 << 14);
*UART1_UCTS = UART1_RX_BUFFERSIZE; /* drop cts when tx buffer at trigger level */
*GPIO_FUNC_SEL1 = ( (0x01 << (0*2)) | (0x01 << (1*2)) ); /* set GPIO17-16 to UART1 CTS and RTS */
#else
*UART1_UCON = (1 << 0) | (1 << 1) | (1 << 14); /* enable receive, transmit, disable rx interrupt */
#endif
if(samp == UCON_SAMP_16X) if(samp == UCON_SAMP_16X)
set_bit(*UART1_UCON,UCON_SAMP); set_bit(*UART1_UCON,UCON_SAMP);
*GPIO_FUNC_SEL0 = ( (0x01 << (14*2)) | (0x01 << (15*2)) ); /* set GPIO15-14 to UART (UART1 TX and RX)*/ *GPIO_FUNC_SEL0 = ( (0x01 << (14*2)) | (0x01 << (15*2)) ); /* set GPIO15-14 to UART (UART1 TX and RX)*/
/* interrupt when there are this number or more bytes free in the TX buffer*/ /* interrupt when there are this number or more bytes free in the TX buffer*/
*UART1_UTXCON = 16; *UART1_UTXCON = 16;
u1_tx_head = 0; u1_tx_tail = 0;
u1_head = 0; u1_tail = 0;
/* tx and rx interrupts are enabled in the UART by default */
/* see status register bits 13 and 14 */
/* enable UART1 interrupts in the interrupt controller */ /* enable UART1 interrupts in the interrupt controller */
enable_irq(UART1); enable_irq(UART1);
} }

View File

@ -25,6 +25,40 @@ CONTIKI_TARGET_SOURCEFILES += $(MSP430) \
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES) CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)
### Compiler definitions ### Compiler definitions
ifdef IAR
CC = icc430
LD = xlink
AS = iasm430
AR = xar
OBJCOPY = ielftool
STRIP = strip
ifndef IAR_PATH
# This works with cygwin...
IAR_BIN_PATH = $(shell dirname `which $(CC)`)
IAR_PATH_C = $(shell dirname $(IAR_BIN_PATH))
IAR_PATH = $(shell cygpath -m $(IAR_PATH_C))
endif
CFLAGSNO = --dlib_config $(IAR_PATH)/LIB/DLIB/dl430xlfn.h -Ohz --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40 --core=430X $(CFLAGSWERROR) --data_model large --double=32
CUSTOM_RULE_C_TO_O = 1
%.o: %.c
$(CC) $(CFLAGS) $< -o $@
CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
$(OBJECTDIR)/%.o: %.c
$(CC) $(CFLAGS) $< -o $@
# @$(FINALIZE_DEPENDENCY)
CUSTOM_RULE_C_TO_CO = 1
%.co: %.c
$(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@
AROPTS = -o
LDFLAGS += -B $(IAR_PATH)/lib/dlib/dl430xlfn.r43 -f $(IAR_PATH)/config/lnk430f5437.xcl -l contiki-$(TARGET).map -Fintel-extended -s __program_start
else
GCC = 1
CC = msp430-gcc CC = msp430-gcc
LD = msp430-gcc LD = msp430-gcc
AS = msp430-as AS = msp430-as
@ -33,12 +67,16 @@ NM = msp430-nm
OBJCOPY = msp430-objcopy OBJCOPY = msp430-objcopy
STRIP = msp430-strip STRIP = msp430-strip
BSL = msp430-bsl BSL = msp430-bsl
ifdef WERROR
CFLAGSWERROR=-Werror
endif
CFLAGSNO = -Wall -mmcu=$(MCU) -g $(CFLAGSWERROR) CFLAGSNO = -Wall -mmcu=$(MCU) -g $(CFLAGSWERROR)
CFLAGS += $(CFLAGSNO) -Os CFLAGS += $(CFLAGSNO) -Os
LDFLAGS += -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map LDFLAGS += -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map
endif
ifdef WERROR
CFLAGSWERROR=-Werror
endif
CFLAGS += $(CFLAGSNO)
### These flags can reduce the code size and RAM usage with up to 10% ### These flags can reduce the code size and RAM usage with up to 10%

View File

@ -35,7 +35,14 @@
#include "sys/cc.h" #include "sys/cc.h"
#ifdef __GNUC__
#include <io.h> #include <io.h>
#include <signal.h>
#endif
#ifdef __IAR_SYSTEMS_ICC__
#include <io430.h>
#endif
#define HWCONF_PIN(name, port, bit) \ #define HWCONF_PIN(name, port, bit) \
static CC_INLINE void name##_SELECT() {P##port##SEL &= ~(1 << bit);} \ static CC_INLINE void name##_SELECT() {P##port##SEL &= ~(1 << bit);} \

View File

@ -33,7 +33,6 @@
#ifndef __LPM_H__ #ifndef __LPM_H__
#define __LPM_H__ #define __LPM_H__
#include <io.h>
#include "contiki-conf.h" #include "contiki-conf.h"
#ifdef LPM_CONF_ON #ifdef LPM_CONF_ON

View File

@ -35,9 +35,15 @@
* *
*/ */
#include <msp430x14x.h> #include "contiki.h"
#ifdef __IAR_SYSTEMS_ICC__
#include <io430.h>
#else
#include <stdlib.h>
#include <io.h> #include <io.h>
#include <signal.h> #include <signal.h>
#endif
#include "dev/flash.h" #include "dev/flash.h"
#include "dev/watchdog.h" #include "dev/watchdog.h"

View File

@ -69,7 +69,11 @@ void splx_(spl_t);
spl_t splhigh_(void); spl_t splhigh_(void);
#define splhigh() splhigh_() #define splhigh() splhigh_()
#ifdef __IAR_SYSTEMS_ICC__
#define splx(sr) sr = __get_SR_register()
#else
#define splx(sr) __asm__ __volatile__("bis %0, r2" : : "r" (sr)) #define splx(sr) __asm__ __volatile__("bis %0, r2" : : "r" (sr))
#endif
/* Workaround for bug in msp430-gcc compiler */ /* Workaround for bug in msp430-gcc compiler */
#if defined(__MSP430__) && defined(__GNUC__) && MSP430_MEMCPY_WORKAROUND #if defined(__MSP430__) && defined(__GNUC__) && MSP430_MEMCPY_WORKAROUND

View File

@ -34,6 +34,10 @@
#include <stdio.h> #include <stdio.h>
#include "sys/mt.h" #include "sys/mt.h"
#ifdef __IAR_SYSTEMS_ICC__
#define __asm__ asm
#endif
static unsigned short *sptmp; static unsigned short *sptmp;
static struct mtarch_thread *running; static struct mtarch_thread *running;
@ -97,8 +101,14 @@ sw(void)
__asm__("push r14"); __asm__("push r14");
__asm__("push r15"); __asm__("push r15");
#ifdef __IAR_SYSTEMS_ICC__
/* use IAR intrinsic functions */
running->sp = (unsigned short *) __get_SP_register();
__set_SP_register((unsigned short) sptmp);
#else
__asm__("mov.w r1,%0" : "=r" (running->sp)); __asm__("mov.w r1,%0" : "=r" (running->sp));
__asm__("mov.w %0,r1" : : "m" (sptmp)); __asm__("mov.w %0,r1" : : "m" (sptmp));
#endif
__asm__("pop r15"); __asm__("pop r15");
__asm__("pop r14"); __asm__("pop r14");

View File

@ -39,7 +39,7 @@ struct mtarch_thread {
unsigned short stack[MTARCH_STACKSIZE]; unsigned short stack[MTARCH_STACKSIZE];
unsigned short *sp; unsigned short *sp;
void *data; void *data;
void *function; void (* function)(void *);
}; };
struct mt_thread; struct mt_thread;

View File

@ -38,8 +38,14 @@
* Adam Dunkels <adam@sics.se> * Adam Dunkels <adam@sics.se>
*/ */
#ifdef __GNUC__
#include <io.h> #include <io.h>
#include <signal.h> #include <signal.h>
#endif
#ifdef __IAR_SYSTEMS_ICC__
#include <io430.h>
#endif
#include "sys/energest.h" #include "sys/energest.h"
#include "sys/rtimer.h" #include "sys/rtimer.h"

View File

@ -41,7 +41,6 @@
#ifndef __RTIMER_ARCH_H__ #ifndef __RTIMER_ARCH_H__
#define __RTIMER_ARCH_H__ #define __RTIMER_ARCH_H__
#include <io.h>
#include "sys/rtimer.h" #include "sys/rtimer.h"
#define RTIMER_ARCH_SECOND (4096U*8) #define RTIMER_ARCH_SECOND (4096U*8)

View File

@ -32,6 +32,7 @@
*/ */
#include "dev/watchdog.h" #include "dev/watchdog.h"
#include <stdlib.h>
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
@ -57,5 +58,7 @@ watchdog_stop(void)
void void
watchdog_reboot(void) watchdog_reboot(void)
{ {
// Death by watchdog.
exit(-1);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -136,7 +136,7 @@ collect_common_send(void)
nbr = uip_ds6_nbr_lookup(&preferred_parent->addr); nbr = uip_ds6_nbr_lookup(&preferred_parent->addr);
if(nbr != NULL) { if(nbr != NULL) {
rimeaddr_copy(&parent, (rimeaddr_t *)&nbr->ipaddr.u8[8]); rimeaddr_copy(&parent, (rimeaddr_t *)&nbr->ipaddr.u8[8]);
parent_etx = neighbor_info_get_etx((rimeaddr_t *) &nbr->lladdr) / 2; parent_etx = neighbor_info_get_metric((rimeaddr_t *) &nbr->lladdr) / 2;
} }
} }
rtmetric = dag->rank; rtmetric = dag->rank;

View File

@ -33,6 +33,7 @@
#include "lib/sensors.h" #include "lib/sensors.h"
#include "dev/irq.h" #include "dev/irq.h"
#include "dev/lpm.h" #include "dev/lpm.h"
#include <io.h>
#include <signal.h> #include <signal.h>
#define ADC12MCTL_NO(adcno) ((unsigned char *) ADC12MCTL0_)[adcno] #define ADC12MCTL_NO(adcno) ((unsigned char *) ADC12MCTL0_)[adcno]

View File

@ -34,6 +34,7 @@
#include "dev/radio-sensor.h" #include "dev/radio-sensor.h"
#include "dev/irq.h" #include "dev/irq.h"
#include "dev/tr1001.h" #include "dev/tr1001.h"
#include <io.h>
const struct sensors_sensor radio_sensor; const struct sensors_sensor radio_sensor;

View File

@ -30,9 +30,10 @@
* *
* @(#)$Id: sound-sensor.c,v 1.5 2010/02/08 00:00:45 nifi Exp $ * @(#)$Id: sound-sensor.c,v 1.5 2010/02/08 00:00:45 nifi Exp $
*/ */
#include <stdlib.h>
#include "dev/sound-sensor.h" #include "dev/sound-sensor.h"
#include "dev/irq.h" #include "dev/irq.h"
#include <stdlib.h>
#include <io.h>
#define MIC_MIN_SENS 150 #define MIC_MIN_SENS 150
#define SAMPLE 1 #define SAMPLE 1

View File

@ -48,6 +48,7 @@
#include "lib/random.h" #include "lib/random.h"
#include "net/netstack.h" #include "net/netstack.h"
#include "net/mac/frame802154.h" #include "net/mac/frame802154.h"
#include "lib/include/uart1.h"
#if WITH_UIP6 #if WITH_UIP6
#include "net/sicslowpan.h" #include "net/sicslowpan.h"
@ -490,7 +491,6 @@ main(void)
cop_service(); cop_service();
#endif #endif
/* TODO: replace this with a uart rx interrupt */
if(uart1_input_handler != NULL) { if(uart1_input_handler != NULL) {
if(uart1_can_get()) { if(uart1_can_get()) {
uart1_input_handler(uart1_getc()); uart1_input_handler(uart1_getc());

View File

@ -60,7 +60,7 @@ const char *netmask;
int slipfd = 0; int slipfd = 0;
uint16_t basedelay=0,delaymsec=0; uint16_t basedelay=0,delaymsec=0;
uint32_t startsec,startmsec,delaystartsec,delaystartmsec; uint32_t startsec,startmsec,delaystartsec,delaystartmsec;
int timestamp = 0; int timestamp = 0, flowcontrol=0;
int ssystem(const char *fmt, ...) int ssystem(const char *fmt, ...)
__attribute__((__format__ (__printf__, 1, 2))); __attribute__((__format__ (__printf__, 1, 2)));
@ -172,7 +172,7 @@ serial_to_tun(FILE *inslip, int outfd)
if(inbufptr >= sizeof(uip.inbuf)) { if(inbufptr >= sizeof(uip.inbuf)) {
inbufptr = 0; inbufptr = 0;
if(timestamp) stamptime(); if(timestamp) stamptime();
fprintf(stderr, "*** dropping too large packet\n"); fprintf(stderr, "*** dropping large %d byte packet\n",inbufptr);
} }
ret = fread(&c, 1, 1, inslip); ret = fread(&c, 1, 1, inslip);
#ifdef linux #ifdef linux
@ -459,7 +459,10 @@ stty_telos(int fd)
/* Nonblocking read. */ /* Nonblocking read. */
tty.c_cc[VTIME] = 0; tty.c_cc[VTIME] = 0;
tty.c_cc[VMIN] = 0; tty.c_cc[VMIN] = 0;
tty.c_cflag &= ~CRTSCTS; if (flowcontrol)
tty.c_cflag |= CRTSCTS;
else
tty.c_cflag &= ~CRTSCTS;
tty.c_cflag &= ~HUPCL; tty.c_cflag &= ~HUPCL;
tty.c_cflag &= ~CLOCAL; tty.c_cflag &= ~CLOCAL;
@ -616,12 +619,16 @@ main(int argc, char **argv)
prog = argv[0]; prog = argv[0];
setvbuf(stdout, NULL, _IOLBF, 0); /* Line buffered output. */ setvbuf(stdout, NULL, _IOLBF, 0); /* Line buffered output. */
while((c = getopt(argc, argv, "B:D:Lhs:t:v::d::a:p:T")) != -1) { while((c = getopt(argc, argv, "B:H:D:Lhs:t:v::d::a:p:T")) != -1) {
switch(c) { switch(c) {
case 'B': case 'B':
baudrate = atoi(optarg); baudrate = atoi(optarg);
break; break;
case 'H':
flowcontrol=1;
break;
case 'L': case 'L':
timestamp=1; timestamp=1;
break; break;
@ -671,6 +678,7 @@ fprintf(stderr,"usage: %s [options] ipaddress\n", prog);
fprintf(stderr,"example: tunslip6 -L -v2 -s ttyUSB1 aaaa::1/64\n"); fprintf(stderr,"example: tunslip6 -L -v2 -s ttyUSB1 aaaa::1/64\n");
fprintf(stderr,"Options are:\n"); fprintf(stderr,"Options are:\n");
fprintf(stderr," -B baudrate 9600,19200,38400,57600,115200 (default)\n"); fprintf(stderr," -B baudrate 9600,19200,38400,57600,115200 (default)\n");
fprintf(stderr," -H Hardware CTS/RTS flow control (default disabled)\n");
fprintf(stderr," -L Log output format (adds time stamps)\n"); fprintf(stderr," -L Log output format (adds time stamps)\n");
fprintf(stderr," -s siodev Serial device (default /dev/ttyUSB0)\n"); fprintf(stderr," -s siodev Serial device (default /dev/ttyUSB0)\n");
fprintf(stderr," -T Make tap interface (default is tun interface)\n"); fprintf(stderr," -T Make tap interface (default is tun interface)\n");
@ -696,7 +704,7 @@ exit(1);
argv += (optind - 1); argv += (optind - 1);
if(argc != 2 && argc != 3) { if(argc != 2 && argc != 3) {
err(1, "usage: %s [-B baudrate] [-L] [-s siodev] [-t tundev] [-T] [-v verbosity] [-d delay] [-a serveraddress] [-p serverport] ipaddress", prog); err(1, "usage: %s [-B baudrate] [-H] [-L] [-s siodev] [-t tundev] [-T] [-v verbosity] [-d delay] [-a serveraddress] [-p serverport] ipaddress", prog);
} }
ipaddr = argv[1]; ipaddr = argv[1];