From 77ec0bfa0f8d0ab2199fa3119188de4d558050f5 Mon Sep 17 00:00:00 2001 From: Joakim Eriksson Date: Wed, 25 May 2011 17:21:51 +0200 Subject: [PATCH] fixed the z1 platform and generic code used by z1 to work with IAR compiler --- core/cfs/cfs-coffee.c | 6 +-- core/dev/cc2420-aes.c | 7 ++- core/dev/cc2420.c | 2 +- core/dev/sht11-sensor.c | 9 +++- core/dev/sht11.c | 6 +++ cpu/msp430/cc2420-arch-sfd.c | 11 ++++- cpu/msp430/clock.c | 15 +++++-- cpu/msp430/dev/hwconf.h | 2 +- cpu/msp430/dev/uart0.h | 2 +- cpu/msp430/dev/uart0x.c | 21 ++++++++- cpu/msp430/dev/uart1.h | 2 +- cpu/msp430/flash.c | 2 +- cpu/msp430/leds-arch.c | 10 +++-- cpu/msp430/msp430.c | 3 +- cpu/msp430/msp430.h | 60 -------------------------- cpu/msp430/msp430def.h | 19 ++++++++ cpu/msp430/rtimer-arch.c | 14 ++++-- cpu/msp430/slip_uart0.c | 2 +- cpu/msp430/spix.c | 8 +++- cpu/msp430/uip-ipchksum.c | 8 ++++ cpu/msp430/watchdog.c | 11 +++++ platform/z1/Makefile.common | 10 ++++- platform/z1/checkpoint-arch.c | 6 +++ platform/z1/contiki-conf.h | 5 --- platform/z1/contiki-z1-main.c | 9 ++-- platform/z1/dev/adxl345.c | 9 +++- platform/z1/dev/adxl345.h | 11 ++++- platform/z1/dev/battery-sensor.c | 8 +++- platform/z1/dev/button-sensor.c | 16 ++++++- platform/z1/dev/cc2420-arch.c | 11 +++-- platform/z1/dev/i2cmaster.c | 14 +++++- platform/z1/dev/i2cmaster.h | 17 +++++++- platform/z1/dev/light-sensor.c | 9 +++- platform/z1/dev/light.c | 9 +++- platform/z1/dev/potentiometer-sensor.c | 10 ++++- platform/z1/dev/sky-sensors.c | 4 ++ platform/z1/dev/temperature-sensor.c | 7 +++ platform/z1/dev/tmp102.c | 8 +++- platform/z1/dev/xmem.c | 7 ++- platform/z1/dev/z1-phidgets.c | 9 +++- platform/z1/msp430.c | 49 ++++++++++----------- platform/z1/platform-conf.h | 16 ++++++- 42 files changed, 318 insertions(+), 146 deletions(-) delete mode 100644 cpu/msp430/msp430.h diff --git a/core/cfs/cfs-coffee.c b/core/cfs/cfs-coffee.c index c8ece1da3..4fa55b109 100644 --- a/core/cfs/cfs-coffee.c +++ b/core/cfs/cfs-coffee.c @@ -191,7 +191,7 @@ struct file_header { uint8_t deprecated_eof_hint; uint8_t flags; char name[COFFEE_NAME_LENGTH]; -} __attribute__((packed)); +}; /* This is needed because of a buggy compiler. */ struct log_param { @@ -1141,7 +1141,7 @@ cfs_read(int fd, void *buf, unsigned size) r = bytes_left; } fdp->offset += r; - buf += r; + buf = (char *)buf + r; } #endif /* COFFEE_MICRO_LOGS */ @@ -1208,7 +1208,7 @@ cfs_write(int fd, const void *buf, unsigned size) /* A log record was written. */ bytes_left -= i; fdp->offset += i; - buf += i; + buf = (char *)buf + i; /* Update the file end for a potential log merge that might occur while writing log records. */ diff --git a/core/dev/cc2420-aes.c b/core/dev/cc2420-aes.c index 9cf59a901..8f406c996 100644 --- a/core/dev/cc2420-aes.c +++ b/core/dev/cc2420-aes.c @@ -39,7 +39,12 @@ */ #include "contiki.h" -#include "io.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else +#include +#include +#endif #include "dev/cc2420.h" #include "dev/cc2420-aes.h" #include "dev/spi.h" diff --git a/core/dev/cc2420.c b/core/dev/cc2420.c index 6f3d808f7..1074123d9 100644 --- a/core/dev/cc2420.c +++ b/core/dev/cc2420.c @@ -42,7 +42,7 @@ #include #elif defined(__MSP430__) #ifdef __IAR_SYSTEMS_ICC__ -#include +#include #else #include #endif diff --git a/core/dev/sht11-sensor.c b/core/dev/sht11-sensor.c index fa0738cb2..92f5c463a 100644 --- a/core/dev/sht11-sensor.c +++ b/core/dev/sht11-sensor.c @@ -33,9 +33,14 @@ #include -#include - #include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else +#include +#include +#endif + #include "lib/sensors.h" #include "dev/sht11.h" #include "dev/sht11-sensor.h" diff --git a/core/dev/sht11.c b/core/dev/sht11.c index d3e4a80e4..d49ad10e3 100644 --- a/core/dev/sht11.c +++ b/core/dev/sht11.c @@ -34,9 +34,15 @@ * temperature sensors. */ +#include "contiki.h" #include +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include +#include +#endif #include #include "sht11-arch.h" diff --git a/cpu/msp430/cc2420-arch-sfd.c b/cpu/msp430/cc2420-arch-sfd.c index 6e84a8d15..b1fd06962 100644 --- a/cpu/msp430/cc2420-arch-sfd.c +++ b/cpu/msp430/cc2420-arch-sfd.c @@ -29,12 +29,16 @@ * @(#)$Id: cc2420-arch-sfd.c,v 1.5 2010/12/16 22:49:12 adamdunkels Exp $ */ +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include +#endif #include "dev/spi.h" #include "dev/cc2420.h" -#include "contiki-conf.h" extern volatile uint8_t cc2420_sfd_counter; extern volatile uint16_t cc2420_sfd_start_time; @@ -42,7 +46,12 @@ extern volatile uint16_t cc2420_sfd_end_time; /*---------------------------------------------------------------------------*/ /* SFD interrupt for timestamping radio packets */ +#ifdef __IAR_SYSTEMS_ICC__ +#pragma vector=TIMERB1_VECTOR +__interrupt void +#else interrupt(TIMERB1_VECTOR) +#endif cc24240_timerb1_interrupt(void) { int tbiv; diff --git a/cpu/msp430/clock.c b/cpu/msp430/clock.c index 5965e1e92..034902538 100644 --- a/cpu/msp430/clock.c +++ b/cpu/msp430/clock.c @@ -32,10 +32,13 @@ */ +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include - -#include "contiki-conf.h" +#endif #include "sys/energest.h" #include "sys/clock.h" @@ -53,7 +56,13 @@ static volatile clock_time_t count = 0; /* last_tar is used for calculating clock_fine */ static volatile uint16_t last_tar = 0; /*---------------------------------------------------------------------------*/ -interrupt(TIMERA1_VECTOR) timera1 (void) { +#ifdef __IAR_SYSTEMS_ICC__ +#pragma vector=TIMERA1_VECTOR +__interrupt void +#else +interrupt(TIMERA1_VECTOR) +#endif +timera1 (void) { ENERGEST_ON(ENERGEST_TYPE_IRQ); watchdog_start(); diff --git a/cpu/msp430/dev/hwconf.h b/cpu/msp430/dev/hwconf.h index 9c764c5b9..bf3ed705f 100644 --- a/cpu/msp430/dev/hwconf.h +++ b/cpu/msp430/dev/hwconf.h @@ -41,7 +41,7 @@ #endif #ifdef __IAR_SYSTEMS_ICC__ -#include +#include #endif #define HWCONF_PIN(name, port, bit) \ diff --git a/cpu/msp430/dev/uart0.h b/cpu/msp430/dev/uart0.h index bfe8f76cc..7b5692730 100644 --- a/cpu/msp430/dev/uart0.h +++ b/cpu/msp430/dev/uart0.h @@ -41,7 +41,7 @@ #ifndef __UART0_H__ #define __UART0_H__ -#include "msp430.h" +#include "contiki.h" #define UART0_BAUD2UBR(baud) ((MSP430_CPU_SPEED)/(baud)) diff --git a/cpu/msp430/dev/uart0x.c b/cpu/msp430/dev/uart0x.c index f8abd5b3b..323dd880b 100644 --- a/cpu/msp430/dev/uart0x.c +++ b/cpu/msp430/dev/uart0x.c @@ -34,8 +34,14 @@ */ #include + +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include +#endif #include "sys/energest.h" #include "dev/uart0.h" @@ -139,7 +145,13 @@ uart0_init(unsigned long ubr) #endif /* TX_WITH_INTERRUPT */ } /*---------------------------------------------------------------------------*/ + +#ifdef __IAR_SYSTEMS_ICC__ +#pragma vector=USCIAB0RX_VECTOR +__interrupt void +#else interrupt(USCIAB0RX_VECTOR) +#endif uart0_rx_interrupt(void) { uint8_t c; @@ -160,19 +172,24 @@ uart0_rx_interrupt(void) } /*---------------------------------------------------------------------------*/ #if TX_WITH_INTERRUPT +#ifdef __IAR_SYSTEMS_ICC__ +#pragma vector=USCIAB0TX_VECTOR +__interrupt void +#else interrupt(USCIAB0TX_VECTOR) +#endif uart0_tx_interrupt(void) { ENERGEST_ON(ENERGEST_TYPE_IRQ); if((IFG2 & UCA0TXIFG)){ - + if(ringbuf_elements(&txbuf) == 0) { transmitting = 0; } else { UCA0TXBUF = ringbuf_get(&txbuf); } } - + /* In a stand-alone app won't work without this. Is the UG misleading? */ IFG2 &= ~UCA0TXIFG; diff --git a/cpu/msp430/dev/uart1.h b/cpu/msp430/dev/uart1.h index d1c8169c8..fce43e60f 100644 --- a/cpu/msp430/dev/uart1.h +++ b/cpu/msp430/dev/uart1.h @@ -41,7 +41,7 @@ #ifndef __UART1_H__ #define __UART1_H__ -#include "msp430.h" +#include "contiki.h" #define UART1_BAUD2UBR(baud) ((MSP430_CPU_SPEED)/(baud)) diff --git a/cpu/msp430/flash.c b/cpu/msp430/flash.c index febe777d1..a55b2dec1 100644 --- a/cpu/msp430/flash.c +++ b/cpu/msp430/flash.c @@ -37,7 +37,7 @@ #include "contiki.h" #ifdef __IAR_SYSTEMS_ICC__ -#include +#include #else #include #include diff --git a/cpu/msp430/leds-arch.c b/cpu/msp430/leds-arch.c index 1b244cc45..c193fbe82 100644 --- a/cpu/msp430/leds-arch.c +++ b/cpu/msp430/leds-arch.c @@ -39,10 +39,14 @@ * $Revision: 1.1 $ */ -#include "contiki-conf.h" -#include "dev/leds.h" - +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include +#endif + +#include "dev/leds.h" /*---------------------------------------------------------------------------*/ void diff --git a/cpu/msp430/msp430.c b/cpu/msp430/msp430.c index afa19163d..785710394 100644 --- a/cpu/msp430/msp430.c +++ b/cpu/msp430/msp430.c @@ -30,11 +30,10 @@ * * @(#)$Id: msp430.c,v 1.15 2011/01/05 13:36:38 joxe Exp $ */ +#include "contiki.h" #include #include #include -#include "msp430.h" -#include "msp430def.h" #include "dev/watchdog.h" #include "net/uip.h" diff --git a/cpu/msp430/msp430.h b/cpu/msp430/msp430.h deleted file mode 100644 index f6501aa19..000000000 --- a/cpu/msp430/msp430.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2007, 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: msp430.h,v 1.4 2011/01/05 13:36:38 joxe Exp $ - */ - -/** - * \file - * MSP430 definitions - * \author - * Adam Dunkels - */ - -#ifndef __MSP430_H__ -#define __MSP430_H__ - -#include "contiki-conf.h" - -#ifdef F_CPU -#define MSP430_CPU_SPEED F_CPU -#else -#define MSP430_CPU_SPEED 2457600UL -#endif - -#define MSP430_REQUIRE_CPUON 0 -#define MSP430_REQUIRE_LPM1 1 -#define MSP430_REQUIRE_LPM2 2 -#define MSP430_REQUIRE_LPM3 3 - -void msp430_add_lpm_req(int req); -void msp430_remove_lpm_req(int req); - -#endif /* __MSP430_H__ */ diff --git a/cpu/msp430/msp430def.h b/cpu/msp430/msp430def.h index ca2a7b4f6..86b8e9f86 100644 --- a/cpu/msp430/msp430def.h +++ b/cpu/msp430/msp430def.h @@ -35,12 +35,14 @@ #ifdef HAVE_STDINT_H #include #else +#ifndef uint8_t typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned long uint32_t; typedef signed char int8_t; typedef short int16_t; typedef long int32_t; +#endif #endif /* !HAVE_STDINT_H */ /* These names are deprecated, use C99 names. */ @@ -106,4 +108,21 @@ void *w_memset(void *out, int value, size_t n); #endif /* memcpy */ #endif /* __GNUC__ && __MSP430__ && MSP430_MEMCPY_WORKAROUND */ + +/* Moved from the msp430.h file with other msp430 related defines */ + +#ifdef F_CPU +#define MSP430_CPU_SPEED F_CPU +#else +#define MSP430_CPU_SPEED 2457600UL +#endif + +#define MSP430_REQUIRE_CPUON 0 +#define MSP430_REQUIRE_LPM1 1 +#define MSP430_REQUIRE_LPM2 2 +#define MSP430_REQUIRE_LPM3 3 + +void msp430_add_lpm_req(int req); +void msp430_remove_lpm_req(int req); + #endif /* MSP430DEF_H */ diff --git a/cpu/msp430/rtimer-arch.c b/cpu/msp430/rtimer-arch.c index f60dd59e5..2b5820573 100644 --- a/cpu/msp430/rtimer-arch.c +++ b/cpu/msp430/rtimer-arch.c @@ -38,14 +38,16 @@ * Adam Dunkels */ +#include "contiki.h" + #ifdef __GNUC__ #include #include #endif #ifdef __IAR_SYSTEMS_ICC__ -#include -#endif +#include +#endif #include "sys/energest.h" #include "sys/rtimer.h" @@ -61,7 +63,13 @@ #endif /*---------------------------------------------------------------------------*/ -interrupt(TIMERA0_VECTOR) timera0 (void) { +#ifdef __IAR_SYSTEMS_ICC__ +#pragma vector=TIMERA0_VECTOR +__interrupt void +#else +interrupt(TIMERA0_VECTOR) +#endif +timera0 (void) { ENERGEST_ON(ENERGEST_TYPE_IRQ); watchdog_start(); diff --git a/cpu/msp430/slip_uart0.c b/cpu/msp430/slip_uart0.c index cf91913a0..3b4721e92 100644 --- a/cpu/msp430/slip_uart0.c +++ b/cpu/msp430/slip_uart0.c @@ -36,7 +36,7 @@ #include "contiki-conf.h" #ifdef __IAR_SYSTEMS_ICC__ -#include +#include #else #include #include diff --git a/cpu/msp430/spix.c b/cpu/msp430/spix.c index 294d5ce14..b474af322 100644 --- a/cpu/msp430/spix.c +++ b/cpu/msp430/spix.c @@ -29,9 +29,13 @@ * @(#)$Id: spix.c,v 1.1 2010/08/24 16:23:20 joxe Exp $ */ +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include - -#include "contiki-conf.h" +#include +#endif /* * This is SPI initialization code for the MSP430X architecture. diff --git a/cpu/msp430/uip-ipchksum.c b/cpu/msp430/uip-ipchksum.c index dd2031a2a..5ed3736f3 100644 --- a/cpu/msp430/uip-ipchksum.c +++ b/cpu/msp430/uip-ipchksum.c @@ -41,6 +41,13 @@ #define asmv(arg) __asm__ __volatile__(arg) /*---------------------------------------------------------------------------*/ #ifdef UIP_ARCH_IPCHKSUM +#ifdef __IAR_SYSTEMS_ICC__ +u16_t +uip_ipchksum(void) +{ + return 0; +} +#else u16_t uip_ipchksum(void) { @@ -66,4 +73,5 @@ uip_ipchksum(void) return (sum == 0) ? 0xffff : sum; } #endif +#endif /*---------------------------------------------------------------------------*/ diff --git a/cpu/msp430/watchdog.c b/cpu/msp430/watchdog.c index 6c2569d85..94a4ddcde 100644 --- a/cpu/msp430/watchdog.c +++ b/cpu/msp430/watchdog.c @@ -30,8 +30,14 @@ * * @(#)$Id: watchdog.c,v 1.12 2010/11/12 15:54:41 nifi Exp $ */ + +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include +#endif #include "dev/watchdog.h" static int counter = 0; @@ -70,7 +76,12 @@ printstring(char *s) #endif /* CONTIKI_TARGET_SKY */ #endif /* PRINT_STACK_ON_REBOOT */ /*---------------------------------------------------------------------------*/ +#ifdef __IAR_SYSTEMS_ICC__ +#pragma vector=WDT_VECTOR +__interrupt void +#else interrupt(WDT_VECTOR) +#endif watchdog_interrupt(void) { #ifdef CONTIKI_TARGET_SKY diff --git a/platform/z1/Makefile.common b/platform/z1/Makefile.common index 88cd70d84..8b27f320a 100644 --- a/platform/z1/Makefile.common +++ b/platform/z1/Makefile.common @@ -1,7 +1,15 @@ # $Id: Makefile.z1,v 1.5 2011/02/26 enricmcalvo Exp $ PROJECT_SOURCEFILES += i2cmaster.c adxl345.c + +ifdef GCC CFLAGS+=-Os -g +endif + +ifdef IAR +CFLAGS+=-e --vla +endif + CLEAN += symbols.c symbols.h #CFLAGS += -ffunction-sections #LDFLAGS += -Wl,--gc-sections,--undefined=_reset_vector__,--undefined=InterruptVectors,--undefined=_copy_data_init__,--undefined=_clear_bss_init__,--undefined=_end_of_init__ @@ -28,7 +36,7 @@ ifdef nodemac CFLAGS += -DMACID=$(nodemac) endif -CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) $(CONTIKI_TARGET_MAIN) +CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) CONTIKI_TARGET_SOURCEFILES += contiki-z1-platform.c MCU=msp430x2617 diff --git a/platform/z1/checkpoint-arch.c b/platform/z1/checkpoint-arch.c index 2960f077c..f96376bd9 100644 --- a/platform/z1/checkpoint-arch.c +++ b/platform/z1/checkpoint-arch.c @@ -47,8 +47,14 @@ #include "dev/leds.h" #include "dev/watchdog.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include +#endif + + #include #define DEBUG 1 diff --git a/platform/z1/contiki-conf.h b/platform/z1/contiki-conf.h index cc0e128d9..6e62e4d3c 100644 --- a/platform/z1/contiki-conf.h +++ b/platform/z1/contiki-conf.h @@ -108,11 +108,6 @@ #define ELFLOADER_CONF_DATAMEMORY_SIZE 0x400 #define ELFLOADER_CONF_TEXTMEMORY_SIZE 0x800 -#define CCIF -#define CLIF - -#define CC_CONF_INLINE inline - #define AODV_COMPLIANCE #define AODV_NUM_RT_ENTRIES 32 diff --git a/platform/z1/contiki-z1-main.c b/platform/z1/contiki-z1-main.c index 332a9a4d4..498d77d14 100644 --- a/platform/z1/contiki-z1-main.c +++ b/platform/z1/contiki-z1-main.c @@ -29,14 +29,17 @@ * @(#)$Id: contiki-z1-main.c,v 1.4 2010/08/26 22:08:11 nifi Exp $ */ -#include #include #include #include -#include - #include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else +#include +#include +#endif #include "dev/cc2420.h" #include "dev/leds.h" diff --git a/platform/z1/dev/adxl345.c b/platform/z1/dev/adxl345.c index c38a3a19b..6ddbcbc10 100644 --- a/platform/z1/dev/adxl345.c +++ b/platform/z1/dev/adxl345.c @@ -40,7 +40,6 @@ #include -#include #include "contiki.h" #include "adxl345.h" #include "cc2420.h" @@ -374,7 +373,13 @@ PROCESS_THREAD(accmeter_process, ev, data) { #if 1 static struct timer suppressTimer1, suppressTimer2; -interrupt(PORT1_VECTOR) port1_isr (void) { +#ifdef __IAR_SYSTEMS_ICC__ +#pragma vector=PORT1_VECTOR +__interrupt void +#else +interrupt (PORT1_VECTOR) +#endif +port1_isr (void) { ENERGEST_ON(ENERGEST_TYPE_IRQ); /* ADXL345_IFG.x goes high when interrupt occurs, use to check what interrupted */ if ((ADXL345_IFG & ADXL345_INT1_PIN) && !(ADXL345_IFG & BV(CC2420_FIFOP_PIN))){ diff --git a/platform/z1/dev/adxl345.h b/platform/z1/dev/adxl345.h index e9a9021d8..c7b23be21 100644 --- a/platform/z1/dev/adxl345.h +++ b/platform/z1/dev/adxl345.h @@ -63,10 +63,19 @@ #define L_OFF(x) (LEDS_PxOUT |= x) //XXX Temporary place for defines that are lacking in mspgcc4's gpio.h +#ifdef __GNUC__ #ifndef P1SEL2_ - #define P1SEL2_ 0x0041 /* Port 1 Selection 2 */ + #define P1SEL2_ 0x0041 /* Port 1 Selection 2*/ sfrb(P1SEL2, P1SEL2_); #endif +#endif +#ifdef __IAR_SYSTEMS_ICC__ +#ifndef P1SEL2_ +#define P1SEL2_ (0x0041u) /* Port 1 Selection 2*/ +DEFC( P1SEL2 , P1SEL2_) +#endif +#endif + /* Used in accm_read_axis(), eg accm_read_axis(X_AXIS);*/ enum ADXL345_AXIS { diff --git a/platform/z1/dev/battery-sensor.c b/platform/z1/dev/battery-sensor.c index c3b82ae3d..31182d37f 100644 --- a/platform/z1/dev/battery-sensor.c +++ b/platform/z1/dev/battery-sensor.c @@ -35,10 +35,16 @@ * Updated : $Date: 2010/08/25 19:30:52 $ * $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/z1/dev/button-sensor.c b/platform/z1/dev/button-sensor.c index f6f90adc1..1d824fc58 100644 --- a/platform/z1/dev/button-sensor.c +++ b/platform/z1/dev/button-sensor.c @@ -30,10 +30,18 @@ * * @(#)$Id: button-sensor.c,v 1.2 2010/08/26 16:01:20 joxe Exp $ */ + +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else +#include +#include +#endif + #include "lib/sensors.h" #include "dev/hwconf.h" #include "dev/button-sensor.h" -#include const struct sensors_sensor button_sensor; @@ -44,7 +52,13 @@ HWCONF_PIN(BUTTON, 2, 5); HWCONF_IRQ(BUTTON, 2, 5); /*---------------------------------------------------------------------------*/ + +#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/z1/dev/cc2420-arch.c b/platform/z1/dev/cc2420-arch.c index 1588131a1..7e3529cdf 100644 --- a/platform/z1/dev/cc2420-arch.c +++ b/platform/z1/dev/cc2420-arch.c @@ -29,12 +29,17 @@ * @(#)$Id: cc2420-arch.c,v 1.1 2010/11/07 08:38:51 enricmcalvo Exp $ */ -#include -#include - #include "contiki.h" #include "contiki-net.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else +#include +#include +#endif + + #include "dev/spi.h" #include "dev/cc2420.h" diff --git a/platform/z1/dev/i2cmaster.c b/platform/z1/dev/i2cmaster.c index 0fbb9a567..14f43f8dc 100644 --- a/platform/z1/dev/i2cmaster.c +++ b/platform/z1/dev/i2cmaster.c @@ -201,7 +201,12 @@ i2c_transmit_n(u8_t byte_ctr, u8_t *tx_buf) { } /*----------------------------------------------------------------------------*/ -interrupt (USCIAB1TX_VECTOR) +#ifdef __IAR_SYSTEMS_ICC__ +#pragma vector=USCIAB1TX_VECTOR +__interrupt void +#else +interrupt (USCIAB1TX_VECTOR) +#endif i2c_tx_interrupt (void) { // TX Part if (UC1IFG & UCB1TXIFG) { // TX int. condition @@ -232,7 +237,12 @@ i2c_tx_interrupt (void) { #endif } -interrupt(USCIAB1RX_VECTOR) +#ifdef __IAR_SYSTEMS_ICC__ +#pragma vector=USCIAB1RX_VECTOR +__interrupt void +#else +interrupt (USCIAB1RX_VECTOR) +#endif i2c_rx_interrupt(void) { if (UCB1STAT & UCNACKIFG){ PRINTFDEBUG("!!! NACK received in RX\n"); diff --git a/platform/z1/dev/i2cmaster.h b/platform/z1/dev/i2cmaster.h index ef46b581f..86ae82ef9 100644 --- a/platform/z1/dev/i2cmaster.h +++ b/platform/z1/dev/i2cmaster.h @@ -42,12 +42,18 @@ #define __I2CMASTER_H__ #include -#include +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include -#include +#include +#endif #include #include + + void i2c_enable(void); void i2c_receiveinit(u8_t slave_address); @@ -59,10 +65,17 @@ void i2c_transmit_n(u8_t byte_ctr, u8_t *tx_buf); u8_t i2c_busy(void); //XXX Temporary place for defines that are lacking in mspgcc4's gpio.h +#ifdef __GNUC__ #ifndef P5SEL2_ #define P5SEL2_ 0x0045 /* Port 5 Selection 2*/ sfrb(P5SEL2, P5SEL2_); #endif +#endif +#ifdef __IAR_SYSTEMS_ICC__ +#define P5SEL2_ (0x0045u) /* Port 5 Selection 2*/ +DEFC( P5SEL2 , P5SEL2_) +#endif + //XXX Should these defines be in the contiki-conf.h to make it more platform-independent? #define I2C_PxDIR P5DIR #define I2C_PxIN P5IN diff --git a/platform/z1/dev/light-sensor.c b/platform/z1/dev/light-sensor.c index b4fb8ed5d..d4ab0a883 100644 --- a/platform/z1/dev/light-sensor.c +++ b/platform/z1/dev/light-sensor.c @@ -32,13 +32,18 @@ */ #include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else +#include +#include +#endif + #include "lib/sensors.h" #include "dev/sky-sensors.h" #include "dev/light-sensor.h" #include "dev/potentiometer-sensor.h" -#include - /* Photodiode 1 (P64) on INCH_4 */ /* Photodiode 2 (P65) on INCH_5 */ //Enric#define INPUT_CHANNEL ((1 << INCH_4) | (1 << INCH_5)) diff --git a/platform/z1/dev/light.c b/platform/z1/dev/light.c index 970504d2a..237546e98 100644 --- a/platform/z1/dev/light.c +++ b/platform/z1/dev/light.c @@ -40,9 +40,14 @@ #include -#include - #include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else +#include +#include +#endif + #include "dev/light.h" /* diff --git a/platform/z1/dev/potentiometer-sensor.c b/platform/z1/dev/potentiometer-sensor.c index 107b400ba..660cb7f65 100644 --- a/platform/z1/dev/potentiometer-sensor.c +++ b/platform/z1/dev/potentiometer-sensor.c @@ -36,7 +36,15 @@ #include "dev/potentiometer-sensor.h" #include "dev/sky-sensors.h" + +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include +#include +#endif + /* Configure ADC12_2 to sample channel 11 (voltage) and use */ /* the Vref+ as reference (SREF_1) since it is a stable reference */ @@ -44,7 +52,7 @@ #define INPUT_REFERENCE SREF_0 #define POTENTIOMETER_MEM ADC12MEM4 -const struct sensors_sensor battery_sensor; +const struct sensors_sensor potentiometer_sensor; /*---------------------------------------------------------------------------*/ static int value(int type) diff --git a/platform/z1/dev/sky-sensors.c b/platform/z1/dev/sky-sensors.c index cdd35d264..f3523a86a 100644 --- a/platform/z1/dev/sky-sensors.c +++ b/platform/z1/dev/sky-sensors.c @@ -39,7 +39,11 @@ */ #include "contiki.h" #include "lib/sensors.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include +#endif #define ADC12MCTL_NO(adcno) ((unsigned char *) ADC12MCTL0_)[adcno] diff --git a/platform/z1/dev/temperature-sensor.c b/platform/z1/dev/temperature-sensor.c index 6b1899b07..bf38f9709 100644 --- a/platform/z1/dev/temperature-sensor.c +++ b/platform/z1/dev/temperature-sensor.c @@ -40,7 +40,14 @@ #include "dev/temperature-sensor.h" #include "dev/sky-sensors.h" + +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include +#include +#endif #define INPUT_CHANNEL (1 << INCH_10) #define INPUT_REFERENCE SREF_1 diff --git a/platform/z1/dev/tmp102.c b/platform/z1/dev/tmp102.c index 05a2ae6fa..e6e5157b0 100644 --- a/platform/z1/dev/tmp102.c +++ b/platform/z1/dev/tmp102.c @@ -40,8 +40,14 @@ #include -#include #include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else +#include +#include +#endif + #include "i2cmaster.h" #include "tmp102.h" diff --git a/platform/z1/dev/xmem.c b/platform/z1/dev/xmem.c index f97497614..433ccd2f1 100644 --- a/platform/z1/dev/xmem.c +++ b/platform/z1/dev/xmem.c @@ -43,10 +43,13 @@ #include #include +#include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include - -#include "contiki.h" +#endif #include "dev/spi.h" #include "dev/xmem.h" diff --git a/platform/z1/dev/z1-phidgets.c b/platform/z1/dev/z1-phidgets.c index edf58b73b..5a3412062 100644 --- a/platform/z1/dev/z1-phidgets.c +++ b/platform/z1/dev/z1-phidgets.c @@ -37,8 +37,15 @@ * Updated : $Date: 2010/11/05 10:31:57 $ * $Revision: 1.3 $ */ -#include + #include "contiki.h" +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else +#include +#include +#endif + #include "lib/sensors.h" #include "dev/z1-phidgets.h" diff --git a/platform/z1/msp430.c b/platform/z1/msp430.c index 3b11984a7..a46902743 100644 --- a/platform/z1/msp430.c +++ b/platform/z1/msp430.c @@ -30,10 +30,19 @@ * * @(#)$Id: msp430.c,v 1.1 2010/08/24 16:26:38 joxe Exp $ */ + +#include "contiki.h" + +#ifdef __IAR_SYSTEMS_ICC__ +#include +#else #include #include #include -#include "msp430.h" +#define asmv(arg) __asm__ __volatile__(arg) +#endif + +#include "msp430def.h" #include "dev/watchdog.h" #include "net/uip.h" @@ -259,8 +268,10 @@ init_ports(void) } /*---------------------------------------------------------------------------*/ /* msp430-ld may align _end incorrectly. Workaround in cpu_init. */ +#ifdef __GNUC__ extern int _end; /* Not in sys/unistd.h */ static char *cur_break = (char *)&_end; +#endif void msp430_cpu_init(void) @@ -270,39 +281,16 @@ msp430_cpu_init(void) init_ports(); msp430_quick_synch_dco(); eint(); +#ifdef __GNUC__ if((uintptr_t)cur_break & 1) { /* Workaround for msp430-ld bug! */ cur_break++; } +#endif } /*---------------------------------------------------------------------------*/ -#define asmv(arg) __asm__ __volatile__(arg) #define STACK_EXTRA 32 -/* - * Allocate memory from the heap. Check that we don't collide with the - * stack right now (some other routine might later). A watchdog might - * be used to check if cur_break and the stack pointer meet during - * runtime. - */ -void * -sbrk(int incr) -{ - char *stack_pointer; - - asmv("mov r1, %0" : "=r" (stack_pointer)); - stack_pointer -= STACK_EXTRA; - if(incr > (stack_pointer - cur_break)) - return (void *)-1; /* ENOMEM */ - - void *old_break = cur_break; - cur_break += incr; - /* - * If the stack was never here then [old_break .. cur_break] should - * be filled with zeros. - */ - return old_break; -} /*---------------------------------------------------------------------------*/ /* * Mask all interrupts that can be masked. @@ -312,8 +300,13 @@ splhigh_(void) { /* Clear the GIE (General Interrupt Enable) flag. */ int sr; +#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. */ } /*---------------------------------------------------------------------------*/ @@ -323,8 +316,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/platform/z1/platform-conf.h b/platform/z1/platform-conf.h index 9f70a0090..aeec90ae8 100644 --- a/platform/z1/platform-conf.h +++ b/platform/z1/platform-conf.h @@ -45,6 +45,20 @@ */ #define ZOLERTIA_Z1 1 /* Enric */ +#ifdef __IAR_SYSTEMS_ICC__ +#include +#include +#define dint() __disable_interrupt() +#define eint() __enable_interrupt() +#define __MSP430F2617__ 1 +#define __MSP430__ 1 +#define CC_CONF_INLINE +#define BV(x) (1 << x) +#else +#define CC_CONF_INLINE inline +#endif + + /* CPU target speed in Hz */ /* CPU target speed in Hz */ #define F_CPU 8000000uL // 8MHz by default @@ -58,8 +72,6 @@ #define CCIF #define CLIF -#define CC_CONF_INLINE inline - #define HAVE_STDINT_H #define MSP430_MEMCPY_WORKAROUND 1 #include "msp430def.h"