diff --git a/core/dev/ds2411.c b/core/dev/ds2411.c index e4f938cb9..c93c465ed 100644 --- a/core/dev/ds2411.c +++ b/core/dev/ds2411.c @@ -50,9 +50,12 @@ #include -#include - #include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else +#include +#endif #include "dev/ds2411.h" diff --git a/cpu/msp430/Makefile.msp430 b/cpu/msp430/Makefile.msp430 index 796a8fd31..186a82565 100644 --- a/cpu/msp430/Makefile.msp430 +++ b/cpu/msp430/Makefile.msp430 @@ -41,8 +41,12 @@ IAR_PATH_C = $(shell dirname "$(IAR_BIN_PATH)") IAR_PATH = $(shell cygpath -m "$(IAR_PATH_C)") endif +#defaults on the MSP430X core include file here (xlfn.h) +ifndef CFLAGSNO CFLAGSNO = --dlib_config "$(IAR_PATH)/LIB/DLIB/dl430xlfn.h" $(CFLAGSWERROR) # 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 +endif + CUSTOM_RULE_C_TO_O = 1 %.o: %.c $(CC) $(CFLAGS) $< -o $@ diff --git a/cpu/msp430/cc2420-arch.c b/cpu/msp430/cc2420-arch.c index 124895571..dc1f67b81 100644 --- a/cpu/msp430/cc2420-arch.c +++ b/cpu/msp430/cc2420-arch.c @@ -29,10 +29,15 @@ * @(#)$Id: cc2420-arch.c,v 1.10 2010/12/16 22:49:33 adamdunkels Exp $ */ +#include "contiki.h" + +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include +#endif -#include "contiki.h" #include "contiki-net.h" #include "dev/spi.h" @@ -51,7 +56,13 @@ #endif /*---------------------------------------------------------------------------*/ +#ifdef __IAR_SYSTEMS_ICC__ +#pragma vector=CC2420_IRQ_VECTOR +__interrupt void +#else interrupt(CC2420_IRQ_VECTOR) +#endif + cc24240_port1_interrupt(void) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/cpu/msp430/dev/uart1.c b/cpu/msp430/dev/uart1.c index 855235ac0..363984eb1 100644 --- a/cpu/msp430/dev/uart1.c +++ b/cpu/msp430/dev/uart1.c @@ -34,9 +34,13 @@ */ #include +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include - +#endif #include #include "sys/energest.h" @@ -248,7 +252,12 @@ uart1_init(unsigned long ubr) /*---------------------------------------------------------------------------*/ #if !RX_WITH_DMA +#ifdef __IAR_SYSTEMS_ICC__ +#pragma vector=UART1RX_VECTOR +__interrupt void +#else interrupt(UART1RX_VECTOR) +#endif uart1_rx_interrupt(void) { uint8_t c; diff --git a/cpu/msp430/msp430.c b/cpu/msp430/msp430.c index 785710394..7ea736bd6 100644 --- a/cpu/msp430/msp430.c +++ b/cpu/msp430/msp430.c @@ -31,9 +31,14 @@ * @(#)$Id: msp430.c,v 1.15 2011/01/05 13:36:38 joxe Exp $ */ #include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include #include +#define asmv(arg) __asm__ __volatile__(arg) +#endif #include "dev/watchdog.h" #include "net/uip.h" @@ -182,8 +187,10 @@ init_ports(void) } /*---------------------------------------------------------------------------*/ /* msp430-ld may align _end incorrectly. Workaround in cpu_init. */ +#if defined(__MSP430__) && defined(__GNUC__) extern int _end; /* Not in sys/unistd.h */ static char *cur_break = (char *)&_end; +#endif /*---------------------------------------------------------------------------*/ /* add/remove_lpm_req - for requiring a specific LPM mode. currently Contiki */ @@ -215,14 +222,17 @@ msp430_cpu_init(void) init_ports(); msp430_init_dco(); eint(); +#if defined(__MSP430__) && defined(__GNUC__) if((uintptr_t)cur_break & 1) { /* Workaround for msp430-ld bug! */ cur_break++; } +#endif + msp430_dco_required = 0; } /*---------------------------------------------------------------------------*/ -#define asmv(arg) __asm__ __volatile__(arg) +# #define STACK_EXTRA 32 /* @@ -231,6 +241,7 @@ msp430_cpu_init(void) * be used to check if cur_break and the stack pointer meet during * runtime. */ +#if defined(__MSP430__) && defined(__GNUC__) void * sbrk(int incr) { @@ -249,6 +260,7 @@ sbrk(int incr) */ return old_break; } +#endif /*---------------------------------------------------------------------------*/ /* * Mask all interrupts that can be masked. @@ -256,10 +268,15 @@ sbrk(int incr) int splhigh_(void) { - /* Clear the GIE (General Interrupt Enable) flag. */ int sr; + /* Clear the GIE (General Interrupt Enable) flag. */ +#ifdef __IAR_SYSTEMS_ICC__ + sr = __get_SR_register(); + __bic_SR_register(GIE); +#else asmv("mov r2, %0" : "=r" (sr)); asmv("bic %0, r2" : : "i" (GIE)); +#endif return sr & GIE; /* Ignore other sr bits. */ } /*---------------------------------------------------------------------------*/ @@ -269,8 +286,12 @@ splhigh_(void) void splx_(int sr) { +#ifdef __IAR_SYSTEMS_ICC__ + __bis_SR_register(sr); +#else /* If GIE was set, restore it. */ asmv("bis %0, r2" : : "r" (sr)); +#endif } /*---------------------------------------------------------------------------*/ /* this code will always start the TimerB if not already started */ diff --git a/cpu/msp430/slip_uart1.c b/cpu/msp430/slip_uart1.c index cbce71584..1a1ec519b 100644 --- a/cpu/msp430/slip_uart1.c +++ b/cpu/msp430/slip_uart1.c @@ -33,11 +33,13 @@ * Machine dependent MSP430 SLIP routines for UART1. */ +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include - -#include "contiki.h" - +#endif #include "dev/slip.h" #include "dev/uart1.h" /*---------------------------------------------------------------------------*/ diff --git a/cpu/msp430/spi.c b/cpu/msp430/spi.c index 7705f5164..0e59a6993 100644 --- a/cpu/msp430/spi.c +++ b/cpu/msp430/spi.c @@ -29,10 +29,15 @@ * @(#)$Id: spi.c,v 1.1 2006/06/17 22:41:21 adamdunkels Exp $ */ -#include - #include "contiki-conf.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else +#include +#endif + + /* * On the Tmote sky access to I2C/SPI/UART0 must always be * exclusive. Set spi_busy so that interrupt handlers can check if diff --git a/platform/sky/Makefile.common b/platform/sky/Makefile.common index ee46cf188..ebfbea6e9 100644 --- a/platform/sky/Makefile.common +++ b/platform/sky/Makefile.common @@ -14,7 +14,19 @@ ifdef UIP_CONF_IPV6 CFLAGS += -DWITH_UIP6=1 endif -CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) $(CONTIKI_TARGET_MAIN) +ifdef GCC +CFLAGS+=-Os -g +endif + +ifdef IAR +CFLAGS+=-e --vla -Ohz --multiplier=16s --core=430 --double=32 +CFLAGSNO = --dlib_config "$(IAR_PATH)/LIB/DLIB/dl430fn.h" $(CFLAGSWERROR) + +endif + + +CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) #$(CONTIKI_TARGET_MAIN) +CONTIKI_TARGET_SOURCEFILES += contiki-sky-platform.c MCU=msp430x1611 include $(CONTIKI)/cpu/msp430/Makefile.msp430 @@ -23,6 +35,14 @@ contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o} # $(AR) rcf $@ $^ +ifdef IAR +ifdef ELF +LDFLAGS += -B -xm "$(IAR_PATH)/lib/dlib/dl430fn.r43" -f "$(IAR_PATH)/config/lnk430f1611.xcl" -l contiki-$(TARGET).map -Felf -yn -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +else +LDFLAGS += -B -xm "$(IAR_PATH)/lib/dlib/dl430fn.r43" -f "$(IAR_PATH)/config/lnk430f1611.xcl" -l contiki-$(TARGET).map -Fintel-extended -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +endif +endif + NUMPAR=20 IHEXFILE=tmpimage.ihex diff --git a/platform/sky/checkpoint-arch.c b/platform/sky/checkpoint-arch.c index c958c4a2a..dc6ef445d 100644 --- a/platform/sky/checkpoint-arch.c +++ b/platform/sky/checkpoint-arch.c @@ -56,8 +56,12 @@ #include "cfs/cfs.h" #include "cfs/cfs-coffee.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include +#endif #include #define DEBUG 0 diff --git a/platform/sky/contiki-sky-main.c b/platform/sky/contiki-sky-main.c index 15b3db66f..f4a5ceab3 100644 --- a/platform/sky/contiki-sky-main.c +++ b/platform/sky/contiki-sky-main.c @@ -31,11 +31,14 @@ #include #include +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include - -#include "contiki.h" +#endif #include "dev/cc2420.h" #include "dev/ds2411.h" diff --git a/platform/sky/dev/battery-sensor.c b/platform/sky/dev/battery-sensor.c index c3b82ae3d..f2662e5ef 100644 --- a/platform/sky/dev/battery-sensor.c +++ b/platform/sky/dev/battery-sensor.c @@ -36,9 +36,14 @@ * $Revision: 1.11 $ */ +#include "contiki.h" #include "dev/battery-sensor.h" #include "dev/sky-sensors.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include +#endif /* Configure ADC12_2 to sample channel 11 (voltage) and use */ /* the Vref+ as reference (SREF_1) since it is a stable reference */ diff --git a/platform/sky/dev/button-sensor.c b/platform/sky/dev/button-sensor.c index a633f9063..57e974980 100644 --- a/platform/sky/dev/button-sensor.c +++ b/platform/sky/dev/button-sensor.c @@ -33,7 +33,12 @@ #include "lib/sensors.h" #include "dev/hwconf.h" #include "dev/button-sensor.h" + +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include +#endif const struct sensors_sensor button_sensor; @@ -44,7 +49,12 @@ HWCONF_PIN(BUTTON, 2, 7); HWCONF_IRQ(BUTTON, 2, 7); /*---------------------------------------------------------------------------*/ +#ifdef __IAR_SYSTEMS_ICC__ +#pragma vector=PORT2_VECTOR +__interrupt void +#else interrupt(PORT2_VECTOR) +#endif irq_p2(void) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/platform/sky/dev/i2c.c b/platform/sky/dev/i2c.c index d03c1db6a..da1afbc1d 100644 --- a/platform/sky/dev/i2c.c +++ b/platform/sky/dev/i2c.c @@ -41,10 +41,14 @@ */ #include - -#include - #include + +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else +#include +#endif + #include #include diff --git a/platform/sky/dev/light-sensor.c b/platform/sky/dev/light-sensor.c index 9ca72d432..493076f54 100644 --- a/platform/sky/dev/light-sensor.c +++ b/platform/sky/dev/light-sensor.c @@ -36,7 +36,11 @@ #include "dev/sky-sensors.h" #include "dev/light-sensor.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include +#endif /* Photodiode 1 (P64) on INCH_4 */ /* Photodiode 2 (P65) on INCH_5 */ diff --git a/platform/sky/dev/sky-sensors.c b/platform/sky/dev/sky-sensors.c index cdd35d264..97d8ced26 100644 --- a/platform/sky/dev/sky-sensors.c +++ b/platform/sky/dev/sky-sensors.c @@ -38,8 +38,13 @@ * $Revision: 1.3 $ */ #include "contiki.h" -#include "lib/sensors.h" + +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include +#endif +#include "lib/sensors.h" #define ADC12MCTL_NO(adcno) ((unsigned char *) ADC12MCTL0_)[adcno] diff --git a/platform/sky/dev/xmem.c b/platform/sky/dev/xmem.c index 46315d3fa..1ce480d1d 100644 --- a/platform/sky/dev/xmem.c +++ b/platform/sky/dev/xmem.c @@ -39,13 +39,18 @@ * unwritten data will read as zeros (UNIX style). */ + +#include "contiki.h" #include #include +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include +#endif -#include "contiki.h" #include "dev/spi.h" #include "dev/xmem.h" diff --git a/platform/sky/platform-conf.h b/platform/sky/platform-conf.h index 5ddb30cb0..b0d50f323 100644 --- a/platform/sky/platform-conf.h +++ b/platform/sky/platform-conf.h @@ -50,6 +50,21 @@ #define PLATFORM_HAS_LEDS 1 #define PLATFORM_HAS_BUTTON 1 +#ifdef __IAR_SYSTEMS_ICC__ +#include +#include +#define dint() __disable_interrupt() +#define eint() __enable_interrupt() +#define __MSP430F1611__ 1 +#define __MSP430__ 1 +#define CC_CONF_INLINE +#define BV(x) (1 << x) +#else +#define CC_CONF_INLINE inline +#define MSP430_MEMCPY_WORKAROUND 1 +#endif + + /* CPU target speed in Hz */ #define F_CPU 3900000uL /*2457600uL*/ @@ -61,10 +76,7 @@ #define CCIF #define CLIF -#define CC_CONF_INLINE inline - #define HAVE_STDINT_H -#define MSP430_MEMCPY_WORKAROUND 1 #include "msp430def.h"