From a84dc139ea9c6e50f6bdd24d06ad16cd4cb35b2b Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Thu, 1 Mar 2012 17:02:40 +0100 Subject: [PATCH 01/23] avoid awt thread floods from mspsim cli output --- .../se/sics/cooja/mspmote/plugins/MspCLI.java | 45 ++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspCLI.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspCLI.java index 6b375e0fa..e088676d5 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspCLI.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/plugins/MspCLI.java @@ -37,6 +37,7 @@ import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.io.PrintStream; +import java.util.List; import javax.swing.JMenuItem; import javax.swing.JOptionPane; @@ -44,7 +45,6 @@ import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; -import javax.swing.SwingUtilities; import se.sics.cooja.ClassDescription; import se.sics.cooja.GUI; @@ -53,6 +53,7 @@ import se.sics.cooja.MotePlugin; import se.sics.cooja.PluginType; import se.sics.cooja.Simulation; import se.sics.cooja.VisPlugin; +import se.sics.cooja.dialogs.UpdateAggregator; import se.sics.cooja.mspmote.MspMote; import se.sics.mspsim.cli.CommandContext; import se.sics.mspsim.cli.LineListener; @@ -77,8 +78,8 @@ public class MspCLI extends VisPlugin implements MotePlugin { final Container panel = getContentPane(); - logArea = new JTextArea(4, 30); - logArea.setTabSize(4); + logArea = new JTextArea(4, 20); + logArea.setTabSize(8); logArea.setEditable(false); panel.add(new JScrollPane(logArea), BorderLayout.CENTER); @@ -176,27 +177,41 @@ public class MspCLI extends VisPlugin implements MotePlugin { } }); + + cliResponseAggregator.start(); + panel.add(commandField, BorderLayout.SOUTH); + setSize(500,500); } public void closePlugin() { + cliResponseAggregator.stop(); } public void addCLIData(final String text) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - String current = logArea.getText(); - int len = current.length(); - if (len > 4096) { - current = current.substring(len - 4096); - } - current = len > 0 ? (current + '\n' + text) : text; - logArea.setText(current); - logArea.setCaretPosition(current.length()); - } - }); + cliResponseAggregator.add(text); } + private static final int UPDATE_INTERVAL = 250; + private UpdateAggregator cliResponseAggregator = new UpdateAggregator(UPDATE_INTERVAL) { + protected void handle(List ls) { + String current = logArea.getText(); + int len = current.length(); + if (len > 4096) { + current = current.substring(len - 4096); + } + + /* Add */ + StringBuilder sb = new StringBuilder(current); + for (String l: ls) { + sb.append(l); + sb.append('\n'); + } + logArea.setText(sb.toString()); + logArea.setCaretPosition(sb.length()); + } + }; + private String trim(String text) { return (text != null) && ((text = text.trim()).length() > 0) ? text : null; } From a243dad433fea4ae819c91cadb7dbf83135e56ad Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Tue, 6 Mar 2012 09:18:44 +0100 Subject: [PATCH 02/23] minor bugfix: side panel height was wrong when plugin started --- tools/cooja/java/se/sics/cooja/plugins/TimeLine.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java b/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java index c1d13bda2..18b6f4782 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java +++ b/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java @@ -229,6 +229,12 @@ public class TimeLine extends VisPlugin { }); eventCheckboxes.add(eventCheckBox); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + recalculateMoteHeight(); + } + }); + /* Panel: timeline canvas w. scroll pane and add mote button */ timeline = new Timeline(); timelineScrollPane = new JScrollPane( @@ -1346,6 +1352,7 @@ public class TimeLine extends VisPlugin { return true; } + private int mousePixelPositionX = -1; private int mousePixelPositionY = -1; private int mouseDownPixelPositionX = -1; From ea42d590eaf03d55058e242d23d9e9874e4f88c8 Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Tue, 6 Mar 2012 09:22:12 +0100 Subject: [PATCH 03/23] removed unnecessary overrided methods --- .../sics/cooja/mspmote/interfaces/MspMoteID.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java index b330ab326..4bc64c175 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java @@ -183,22 +183,6 @@ public class MspMoteID extends MoteID { this.deleteObserver(observer); } - public Collection getConfigXML() { - ArrayList config = new ArrayList(); - Element element = new Element("id"); - element.setText(Integer.toString(getMoteID())); - config.add(element); - return config; - } - - public void setConfigXML(Collection configXML, boolean visAvailable) { - for (Element element : configXML) { - if (element.getName().equals("id")) { - setMoteID(Integer.parseInt(element.getText())); - } - } - } - public void removed() { super.removed(); if (moteMem.variableExists("node_id")) { From e22bf837fc3b4072f053e62301a4a2fcbca56e6b Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Tue, 6 Mar 2012 09:23:29 +0100 Subject: [PATCH 04/23] bugfix: mspsim may not have pc information, causing exception in buffer listener bugfix: mote interfaces were incorrectly initialized twice, causing an mote id error in tinyos --- .../src/se/sics/cooja/mspmote/MspMote.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java index 217836800..001ff7990 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/MspMote.java @@ -387,7 +387,9 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc public boolean setConfigXML(Simulation simulation, Collection configXML, boolean visAvailable) { setSimulation(simulation); - myMoteInterfaceHandler = createMoteInterfaceHandler(); + if (myMoteInterfaceHandler == null) { + myMoteInterfaceHandler = createMoteInterfaceHandler(); + } /* Create watchpoint container */ try { @@ -497,18 +499,23 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc } if (di == null) { /* Return PC value */ - MapEntry mapEntry = ((SimpleProfiler)myCpu.getProfiler()).getCallMapEntry(0); - if (mapEntry != null) { - String file = mapEntry.getFile(); - if (file != null) { - if (file.indexOf('/') >= 0) { - file = file.substring(file.lastIndexOf('/')+1); + SimpleProfiler sp = (SimpleProfiler)myCpu.getProfiler(); + try { + MapEntry mapEntry = sp.getCallMapEntry(0); + if (mapEntry != null) { + String file = mapEntry.getFile(); + if (file != null) { + if (file.indexOf('/') >= 0) { + file = file.substring(file.lastIndexOf('/')+1); + } } + String name = mapEntry.getName(); + return file + ":?:" + name; } - String name = mapEntry.getName(); - return file + ":?:" + name; + return String.format("*%02x", myCpu.reg[MSP430Constants.PC]); + } catch (Exception e) { + return null; } - return String.format("*%02x", myCpu.reg[MSP430Constants.PC]); } int lineNo = di.getLine(); From 1d13e93db72112a1d476b6b428510961c1257e8d Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Tue, 6 Mar 2012 09:47:34 +0100 Subject: [PATCH 05/23] capturing exceptions from radio logger - some packet analyzers seems to be buggy --- tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java b/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java index 8ad26cc18..62751dcc7 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java +++ b/tools/cooja/java/se/sics/cooja/plugins/RadioLogger.java @@ -549,8 +549,9 @@ public class RadioLogger extends VisPlugin { private boolean analyzePacket(PacketAnalyzer.Packet packet, StringBuffer brief, StringBuffer verbose) { if (analyzers == null) return false; - boolean analyze = true; - while (analyze) { + try { + boolean analyze = true; + while (analyze) { analyze = false; for (int i = 0; i < analyzers.size(); i++) { PacketAnalyzer analyzer = analyzers.get(i); @@ -570,6 +571,10 @@ public class RadioLogger extends VisPlugin { } } } + } catch (Exception e) { + logger.debug("Error when analyzing packet: " + e.getMessage(), e); + return false; + } return brief.length() > 0; } From 40c32990e33207cd295b41bb3a2e4df37503c3e6 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Tue, 6 Mar 2012 12:33:16 +0100 Subject: [PATCH 06/23] Added missing arguments to usage information --- examples/ipv6/native-border-router/slip-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ipv6/native-border-router/slip-config.c b/examples/ipv6/native-border-router/slip-config.c index daad4907a..84d256127 100644 --- a/examples/ipv6/native-border-router/slip-config.c +++ b/examples/ipv6/native-border-router/slip-config.c @@ -157,7 +157,7 @@ exit(1); argv += optind - 1; if(argc != 2 && argc != 3) { - err(1, "usage: %s [-B baudrate] [-H] [-L] [-s siodev] [-t tundev] [-T] [-v verbosity] [-d delay] 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); } slip_config_ipaddr = argv[1]; From 99f3d5ada239ba27f4b21b62c9b338304871cbb5 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Tue, 6 Mar 2012 12:33:47 +0100 Subject: [PATCH 07/23] Added missing include --- core/net/rime/timesynch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/net/rime/timesynch.c b/core/net/rime/timesynch.c index 83ca2fd30..5a184ce6b 100644 --- a/core/net/rime/timesynch.c +++ b/core/net/rime/timesynch.c @@ -48,6 +48,7 @@ #include "lib/random.h" #include "net/rime.h" #include "net/rime/timesynch.h" +#include #if TIMESYNCH_CONF_ENABLED static int authority_level; From 5288ac12b510cf4fa404266e42e7c7955e042e1a Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Tue, 6 Mar 2012 12:47:53 +0100 Subject: [PATCH 08/23] Deferred mote height calculation until components are initialized --- .../java/se/sics/cooja/plugins/TimeLine.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java b/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java index 18b6f4782..6244740a8 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java +++ b/tools/cooja/java/se/sics/cooja/plugins/TimeLine.java @@ -229,12 +229,6 @@ public class TimeLine extends VisPlugin { }); eventCheckboxes.add(eventCheckBox); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - recalculateMoteHeight(); - } - }); - /* Panel: timeline canvas w. scroll pane and add mote button */ timeline = new Timeline(); timelineScrollPane = new JScrollPane( @@ -268,6 +262,7 @@ public class TimeLine extends VisPlugin { getContentPane().add(splitPane); + recalculateMoteHeight(); pack(); setSize(gui.getDesktopPane().getWidth(), 150); setLocation(0, gui.getDesktopPane().getHeight() - 150); @@ -1198,9 +1193,11 @@ public class TimeLine extends VisPlugin { if (showWatchpoints) { h += EVENT_PIXEL_HEIGHT; } - paintedMoteHeight = h; - timelineMoteRuler.repaint(); - timeline.repaint(); + if (h != paintedMoteHeight) { + paintedMoteHeight = h; + timelineMoteRuler.repaint(); + timeline.repaint(); + } } public void closePlugin() { From 7110075108c0a443f490cf8c85772bc6762845fc Mon Sep 17 00:00:00 2001 From: David Kopf Date: Tue, 6 Mar 2012 09:10:12 -0500 Subject: [PATCH 09/23] Make static buffer the default, add comments. --- examples/ipv6/rpl-border-router/border-router.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/ipv6/rpl-border-router/border-router.c b/examples/ipv6/rpl-border-router/border-router.c index 33d9f754b..3c3a60de5 100644 --- a/examples/ipv6/rpl-border-router/border-router.c +++ b/examples/ipv6/rpl-border-router/border-router.c @@ -72,14 +72,26 @@ AUTOSTART_PROCESSES(&border_router_process); #include "webserver-nogui.h" AUTOSTART_PROCESSES(&border_router_process,&webserver_nogui_process); #else -/* Use simple webserver with only one page */ +/* Use simple webserver with only one page for minimum footprint. + * Multiple connections can result in interleaved tcp segments since + * a single static buffer is used for all segments. + */ #include "httpd-simple.h" - +/* The internal webserver can provide additional information if + * enough program flash is available. + */ #define WEBSERVER_CONF_LOADTIME 0 #define WEBSERVER_CONF_FILESTATS 0 #define WEBSERVER_CONF_NEIGHBOR_STATUS 0 +/* Adding links requires a larger RAM buffer. To avoid static allocation + * the stack can be used for formatting; however tcp retransmissions + * and multiple connections can result in garbled segments. + * TODO:use PSOCk_GENERATOR_SEND and tcp state storage to fix this. + */ #define WEBSERVER_CONF_ROUTE_LINKS 0 +#if WEBSERVER_CONF_ROUTE_LINKS #define BUF_USES_STACK 1 +#endif PROCESS(webserver_nogui_process, "Web server"); PROCESS_THREAD(webserver_nogui_process, ev, data) From f891774c1f4aff763139fdc57a196bdd7172ada5 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Tue, 6 Mar 2012 15:25:58 +0100 Subject: [PATCH 10/23] Deferred listening on memory until after mote id has been set --- .../cooja/mspmote/interfaces/MspMoteID.java | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java index 4bc64c175..b3f0d455e 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java @@ -30,9 +30,6 @@ */ package se.sics.cooja.mspmote.interfaces; - -import java.util.ArrayList; -import java.util.Collection; import java.util.Observable; import java.util.Observer; @@ -40,7 +37,6 @@ import javax.swing.JLabel; import javax.swing.JPanel; import org.apache.log4j.Logger; -import org.jdom.Element; import se.sics.cooja.Mote; import se.sics.cooja.MoteTimeEvent; @@ -76,41 +72,6 @@ public class MspMoteID extends MoteID { public MspMoteID(Mote m) { this.mote = (MspMote) m; this.moteMem = (MspMoteMemory) mote.getMemory(); - - final MoteTimeEvent writeIDEvent = new MoteTimeEvent(mote, 0) { - public void execute(long t) { - setMoteID(moteID); - } - }; - - cpuMonitor = new CPUMonitor() { - public void cpuAction(int type, int adr, int data) { - if (type != MEMORY_WRITE) { - return; - } - if (data == moteID) { - return; - } - Simulation s = mote.getSimulation(); - if (writeIDEvent.isScheduled()) { - return; - } - s.scheduleEvent(writeIDEvent, s.getSimulationTime()); - } - }; - - if (moteMem.variableExists("node_id")) { - this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor); - } - if (moteMem.variableExists("TOS_NODE_ID")) { - this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor); - } - if (moteMem.variableExists("ActiveMessageAddressC__addr")) { - this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor); - } - if (moteMem.variableExists("ActiveMessageAddressC$addr")) { - this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor); - } } public int getMoteID() { @@ -149,6 +110,42 @@ public class MspMoteID extends MoteID { if (moteMem.variableExists("ActiveMessageAddressC$addr")) { moteMem.setIntValueOf("ActiveMessageAddressC$addr", newID); } + if (cpuMonitor == null) { + final MoteTimeEvent writeIDEvent = new MoteTimeEvent(mote, 0) { + public void execute(long t) { + setMoteID(moteID); + } + }; + + cpuMonitor = new CPUMonitor() { + public void cpuAction(int type, int address, int data) { + if (type != MEMORY_WRITE) { + return; + } + if (data == moteID) { + return; + } + if (writeIDEvent.isScheduled()) { + return; + } + Simulation s = mote.getSimulation(); + s.scheduleEvent(writeIDEvent, s.getSimulationTime()); + } + }; + + if (moteMem.variableExists("node_id")) { + this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor); + } + if (moteMem.variableExists("TOS_NODE_ID")) { + this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor); + } + if (moteMem.variableExists("ActiveMessageAddressC__addr")) { + this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor); + } + if (moteMem.variableExists("ActiveMessageAddressC$addr")) { + this.mote.getCPU().addWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor); + } + } notifyObservers(); } @@ -185,17 +182,20 @@ public class MspMoteID extends MoteID { public void removed() { super.removed(); - if (moteMem.variableExists("node_id")) { - this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor); - } - if (moteMem.variableExists("TOS_NODE_ID")) { - this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor); - } - if (moteMem.variableExists("ActiveMessageAddressC__addr")) { - this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor); - } - if (moteMem.variableExists("ActiveMessageAddressC$addr")) { - this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor); + if (cpuMonitor != null) { + if (moteMem.variableExists("node_id")) { + this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("node_id"), cpuMonitor); + } + if (moteMem.variableExists("TOS_NODE_ID")) { + this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("TOS_NODE_ID"), cpuMonitor); + } + if (moteMem.variableExists("ActiveMessageAddressC__addr")) { + this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), cpuMonitor); + } + if (moteMem.variableExists("ActiveMessageAddressC$addr")) { + this.mote.getCPU().removeWatchPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), cpuMonitor); + } + cpuMonitor = null; } } } From 2eee14a1d8c9cd26d034411c3669706dfb88a7f0 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Tue, 6 Mar 2012 15:29:31 +0100 Subject: [PATCH 11/23] Allow compiler flag SMALL to be set to disable SMALL-build. Patch by Andre Frimberger. --- cpu/msp430/Makefile.msp430 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/msp430/Makefile.msp430 b/cpu/msp430/Makefile.msp430 index c38800417..c173730f8 100644 --- a/cpu/msp430/Makefile.msp430 +++ b/cpu/msp430/Makefile.msp430 @@ -98,7 +98,7 @@ CFLAGS += -Os -fno-strict-aliasing LDFLAGS += -mmcu=$(MCU) -Wl,-Map=contiki-$(TARGET).map ### These flags can reduce the code size and RAM usage with up to 10% -ifdef SMALL +ifeq ($(SMALL),1) CFLAGS += -ffunction-sections # CFLAGS += -fdata-sections LDFLAGS += -Wl,--gc-sections,--undefined=_reset_vector__,--undefined=InterruptVectors,--undefined=_copy_data_init__,--undefined=_clear_bss_init__,--undefined=_end_of_init__ From 2ef46ac47ac0778d3276f1ac85239939876006bb Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Sun, 5 Feb 2012 06:21:35 +0100 Subject: [PATCH 12/23] Bugfix for separate NON requests and updated separate resonse API.\nEnabled multiple BLOCKING_REQUESTs in the same scope. --- apps/er-coap-07/er-coap-07-engine.c | 4 +-- apps/er-coap-07/er-coap-07-engine.h | 14 +++++---- apps/er-coap-07/er-coap-07-separate.c | 29 +++++++------------ apps/er-coap-07/er-coap-07-separate.h | 4 +-- examples/er-rest-example/Makefile | 10 +++++-- .../er-rest-example/rest-server-example.c | 20 +++++++++---- 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/apps/er-coap-07/er-coap-07-engine.c b/apps/er-coap-07/er-coap-07-engine.c index b9f790e29..47bbccd90 100644 --- a/apps/er-coap-07/er-coap-07-engine.c +++ b/apps/er-coap-07/er-coap-07-engine.c @@ -202,8 +202,8 @@ handle_incoming_data(void) } else { - coap_error_code = INTERNAL_SERVER_ERROR_5_00; - coap_error_message = "Service callback undefined"; + coap_error_code = NOT_IMPLEMENTED_5_01; + coap_error_message = "NoServiceCallbck"; // no a to fit 16 bytes } /* if (service callback) */ } else { diff --git a/apps/er-coap-07/er-coap-07-engine.h b/apps/er-coap-07/er-coap-07-engine.h index f971c2ec7..9f3f0cbba 100644 --- a/apps/er-coap-07/er-coap-07-engine.h +++ b/apps/er-coap-07/er-coap-07-engine.h @@ -81,12 +81,14 @@ PT_THREAD(coap_blocking_request(struct request_state_t *state, process_event_t e blocking_response_handler request_callback)); #define COAP_BLOCKING_REQUEST(server_addr, server_port, request, chunk_handler) \ -static struct request_state_t request_state; \ -PT_SPAWN(process_pt, &request_state.pt, \ - coap_blocking_request(&request_state, ev, \ - server_addr, server_port, \ - request, chunk_handler) \ - ); +{ \ + static struct request_state_t request_state; \ + PT_SPAWN(process_pt, &request_state.pt, \ + coap_blocking_request(&request_state, ev, \ + server_addr, server_port, \ + request, chunk_handler) \ + ); \ +} /*-----------------------------------------------------------------------------------*/ #endif /* COAP_SERVER_H_ */ diff --git a/apps/er-coap-07/er-coap-07-separate.c b/apps/er-coap-07/er-coap-07-separate.c index b5f9c5c3a..942c8c0c1 100644 --- a/apps/er-coap-07/er-coap-07-separate.c +++ b/apps/er-coap-07/er-coap-07-separate.c @@ -72,13 +72,6 @@ int coap_separate_handler(resource_t *resource, void *request, void *response) coap_init_message(ack, COAP_TYPE_ACK, 0, coap_req->mid); /* Serializing into IPBUF: Only overwrites header parts that are already parsed into the request struct. */ coap_send_message(&UIP_IP_BUF->srcipaddr, UIP_UDP_BUF->srcport, (uip_appdata), coap_serialize_message(ack, uip_appdata)); - - /* Change response to separate response. */ - coap_res->type = COAP_TYPE_CON; - coap_res->mid = coap_get_mid(); - - /* Update MID in transaction for identification. */ - t->mid = coap_res->mid; } /* Pre-handlers could skip the handling by returning 0. */ @@ -86,26 +79,26 @@ int coap_separate_handler(resource_t *resource, void *request, void *response) } int -coap_separate_response(void *response, coap_separate_t *separate_store) +coap_separate_response(void *request, coap_separate_t *separate_store) { - coap_packet_t *const coap_res = (coap_packet_t *) response; - coap_transaction_t *const t = coap_get_transaction_by_mid(coap_res->mid); + coap_packet_t *const coap_req = (coap_packet_t *) request; + coap_transaction_t *const t = coap_get_transaction_by_mid(coap_req->mid); if (t) { uip_ipaddr_copy(&separate_store->addr, &t->addr); separate_store->port = t->port; - separate_store->mid = coap_res->mid; - separate_store->type = coap_res->type; + separate_store->type = coap_req->type==COAP_TYPE_CON ? COAP_TYPE_CON : COAP_TYPE_NON; + separate_store->mid = coap_get_mid(); // if it was NON, we burned one MID in the engine... - memcpy(separate_store->token, coap_res->token, coap_res->token_len); - separate_store->token_len = coap_res->token_len; + memcpy(separate_store->token, coap_req->token, coap_req->token_len); + separate_store->token_len = coap_req->token_len; - separate_store->block2_num = coap_res->block2_num; - separate_store->block2_more = coap_res->block2_more; - separate_store->block2_size = coap_res->block2_size; - separate_store->block2_offset = coap_res->block2_offset; + separate_store->block2_num = coap_req->block2_num; + separate_store->block2_more = coap_req->block2_more; + separate_store->block2_size = coap_req->block2_size; + separate_store->block2_offset = coap_req->block2_offset; /* Signal the engine to skip automatic response and clear transaction by engine. */ coap_error_code = MANUAL_RESPONSE; diff --git a/apps/er-coap-07/er-coap-07-separate.h b/apps/er-coap-07/er-coap-07-separate.h index 8d677ea0d..23d7de84d 100644 --- a/apps/er-coap-07/er-coap-07-separate.h +++ b/apps/er-coap-07/er-coap-07-separate.h @@ -52,14 +52,12 @@ typedef struct coap_separate { uint8_t token_len; uint8_t token[COAP_TOKEN_LEN]; + /* separate + blockwise is untested! */ uint32_t block2_num; uint8_t block2_more; uint16_t block2_size; uint32_t block2_offset; - /* Add fields for addition information to be saved here, e.g.: */ - char buffer[17]; - } coap_separate_t; int coap_separate_handler(resource_t *resource, void *request, void *response); diff --git a/examples/er-rest-example/Makefile b/examples/er-rest-example/Makefile index 3a9c02c58..c10d11482 100644 --- a/examples/er-rest-example/Makefile +++ b/examples/er-rest-example/Makefile @@ -17,10 +17,14 @@ UIP_CONF_IPV6=1 # configure CoAP implementation (3|7) WITH_COAP=7 -# must be CFLAGS not variables -# minimal-net does not support RPL, avoid redefine warnings +# new variable since slip-radio ifneq ($(TARGET), minimal-net) -CFLAGS += -DUIP_CONF_IPV6_RPL=1 +UIP_CONF_RPL=1 +else +# minimal-net does not support RPL under Linux and is mostly used to test CoAP only +${info INFO: compiling without RPL} +UIP_CONF_RPL=0 +CFLAGS += -DUIP_CONF_ND6_DEF_MAXDADNS=0 endif # linker optimizations diff --git a/examples/er-rest-example/rest-server-example.c b/examples/er-rest-example/rest-server-example.c index 65ccdc48e..7d327ecc8 100644 --- a/examples/er-rest-example/rest-server-example.c +++ b/examples/er-rest-example/rest-server-example.c @@ -355,12 +355,22 @@ chunks_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre #include "er-coap-07-transactions.h" /* * CoAP-specific example for separate responses. - * This resource is . + * Note the call "rest_set_pre_handler(&resource_separate, coap_separate_handler);" in the main process. + * The pre-handler takes care of the empty ACK and updates the MID and message type for CON requests. + * The resource handler must store all information that required to finalize the response later. */ RESOURCE(separate, METHOD_GET, "debug/separate", "title=\"Separate demo\""); +/* A structure to store the required information */ +typedef struct application_separate_store { + /* Provided by Erbium to store generic request information such as remote address and token. */ + coap_separate_t request_metadata; + /* Add fields for addition information to be stored for finalizing, e.g.: */ + char buffer[16]; +} application_separate_store_t; + static uint8_t separate_active = 0; -static coap_separate_t separate_store[1]; +static application_separate_store_t separate_store[1]; void separate_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) @@ -380,7 +390,7 @@ separate_handler(void* request, void* response, uint8_t *buffer, uint16_t prefer separate_active = 1; /* Take over and skip response by engine. */ - coap_separate_response(response, separate_store); + coap_separate_response(request, &separate_store->request_metadata); /* * At the moment, only the minimal information is stored in the store (client address, port, token, MID, type, and Block2). @@ -397,10 +407,10 @@ separate_finalize_handler() if (separate_active) { coap_transaction_t *transaction = NULL; - if ( (transaction = coap_new_transaction(separate_store->mid, &separate_store->addr, separate_store->port)) ) + if ( (transaction = coap_new_transaction(separate_store->request_metadata.mid, &separate_store->request_metadata.addr, separate_store->request_metadata.port)) ) { coap_packet_t response[1]; /* This way the packet can be treated as pointer as usual. */ - coap_init_message(response, separate_store->type, CONTENT_2_05, separate_store->mid); + coap_init_message(response, separate_store->request_metadata.type, CONTENT_2_05, separate_store->request_metadata.mid); coap_set_payload(response, separate_store->buffer, strlen(separate_store->buffer)); From cd802979da17385d1a46b941d47e06117a900646 Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Mon, 6 Feb 2012 06:21:33 +0100 Subject: [PATCH 13/23] Fixed token bug in separate response and extended API (thanks to Klaus Hartke for the bug report). --- apps/er-coap-07/er-coap-07-separate.c | 14 ++++++----- apps/er-coap-07/er-coap-07-separate.h | 5 ++-- .../er-rest-example/rest-server-example.c | 25 +++++++++++++------ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/apps/er-coap-07/er-coap-07-separate.c b/apps/er-coap-07/er-coap-07-separate.c index 942c8c0c1..528b0c112 100644 --- a/apps/er-coap-07/er-coap-07-separate.c +++ b/apps/er-coap-07/er-coap-07-separate.c @@ -57,15 +57,12 @@ int coap_separate_handler(resource_t *resource, void *request, void *response) { coap_packet_t *const coap_req = (coap_packet_t *) request; - coap_packet_t *const coap_res = (coap_packet_t *) response; PRINTF("Separate response for /%s MID %u\n", resource->url, coap_res->mid); /* Only ack CON requests. */ if (coap_req->type==COAP_TYPE_CON) { - coap_transaction_t *const t = coap_get_transaction_by_mid(coap_res->mid); - /* send separate ACK. */ coap_packet_t ack[1]; /* ACK with empty code (0) */ @@ -79,7 +76,7 @@ int coap_separate_handler(resource_t *resource, void *request, void *response) } int -coap_separate_response(void *request, coap_separate_t *separate_store) +coap_separate_yield(void *request, coap_separate_t *separate_store) { coap_packet_t *const coap_req = (coap_packet_t *) request; coap_transaction_t *const t = coap_get_transaction_by_mid(coap_req->mid); @@ -96,9 +93,7 @@ coap_separate_response(void *request, coap_separate_t *separate_store) separate_store->token_len = coap_req->token_len; separate_store->block2_num = coap_req->block2_num; - separate_store->block2_more = coap_req->block2_more; separate_store->block2_size = coap_req->block2_size; - separate_store->block2_offset = coap_req->block2_offset; /* Signal the engine to skip automatic response and clear transaction by engine. */ coap_error_code = MANUAL_RESPONSE; @@ -110,3 +105,10 @@ coap_separate_response(void *request, coap_separate_t *separate_store) return 0; } } + +void +coap_separate_resume(void *response, coap_separate_t *separate_store, uint8_t code) +{ + coap_init_message(response, separate_store->type, code, separate_store->mid); + coap_set_header_token(response, separate_store->token, separate_store->token_len); +} diff --git a/apps/er-coap-07/er-coap-07-separate.h b/apps/er-coap-07/er-coap-07-separate.h index 23d7de84d..7eade7e56 100644 --- a/apps/er-coap-07/er-coap-07-separate.h +++ b/apps/er-coap-07/er-coap-07-separate.h @@ -54,13 +54,12 @@ typedef struct coap_separate { /* separate + blockwise is untested! */ uint32_t block2_num; - uint8_t block2_more; uint16_t block2_size; - uint32_t block2_offset; } coap_separate_t; int coap_separate_handler(resource_t *resource, void *request, void *response); -int coap_separate_response(void *response, coap_separate_t *separate_store); +int coap_separate_yield(void *request, coap_separate_t *separate_store); +void coap_separate_resume(void *response, coap_separate_t *separate_store, uint8_t code); #endif /* COAP_SEPARATE_H_ */ diff --git a/examples/er-rest-example/rest-server-example.c b/examples/er-rest-example/rest-server-example.c index 7d327ecc8..624756ad0 100644 --- a/examples/er-rest-example/rest-server-example.c +++ b/examples/er-rest-example/rest-server-example.c @@ -349,7 +349,7 @@ chunks_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre } #endif -#if REST_RES_SEPARATE && WITH_COAP > 3 +#if defined (PLATFORM_HAS_BUTTON) && REST_RES_SEPARATE && WITH_COAP > 3 /* Required to manually (=not by the engine) handle the response transaction. */ #include "er-coap-07-separate.h" #include "er-coap-07-transactions.h" @@ -390,7 +390,8 @@ separate_handler(void* request, void* response, uint8_t *buffer, uint16_t prefer separate_active = 1; /* Take over and skip response by engine. */ - coap_separate_response(request, &separate_store->request_metadata); + coap_separate_yield(request, &separate_store->request_metadata); + /* Be aware to respect the Block2 option, which is also stored in the coap_separate_t. */ /* * At the moment, only the minimal information is stored in the store (client address, port, token, MID, type, and Block2). @@ -410,10 +411,18 @@ separate_finalize_handler() if ( (transaction = coap_new_transaction(separate_store->request_metadata.mid, &separate_store->request_metadata.addr, separate_store->request_metadata.port)) ) { coap_packet_t response[1]; /* This way the packet can be treated as pointer as usual. */ - coap_init_message(response, separate_store->request_metadata.type, CONTENT_2_05, separate_store->request_metadata.mid); + + /* Restore the request information for the response. */ + coap_separate_resume(response, &separate_store->request_metadata, CONTENT_2_05); coap_set_payload(response, separate_store->buffer, strlen(separate_store->buffer)); + /* + * Be aware to respect the Block2 option, which is also stored in the coap_separate_t. + * As it is a critical option, this example resource pretends to handle it for compliance. + */ + coap_set_header_block2(response, separate_store->request_metadata.block2_num, 0, separate_store->request_metadata.block2_size); + /* Warning: No check for serialization error. */ transaction->packet_len = coap_serialize_message(response, transaction->packet); coap_send_transaction(transaction); @@ -692,14 +701,16 @@ PROCESS_THREAD(rest_server_example, ev, data) #if REST_RES_PUSHING rest_activate_periodic_resource(&periodic_resource_pushing); #endif -#if REST_RES_SEPARATE && WITH_COAP > 3 +#if defined (PLATFORM_HAS_BUTTON) && REST_RES_EVENT + rest_activate_event_resource(&resource_event); +#endif +#if defined (PLATFORM_HAS_BUTTON) && REST_RES_SEPARATE && WITH_COAP > 3 + /* Use this pre-handler for separate response resources. */ rest_set_pre_handler(&resource_separate, coap_separate_handler); rest_activate_resource(&resource_separate); #endif - -#if defined (PLATFORM_HAS_BUTTON) && REST_RES_EVENT +#if defined (PLATFORM_HAS_BUTTON) && (REST_RES_EVENT || (REST_RES_SEPARATE && WITH_COAP > 3)) SENSORS_ACTIVATE(button_sensor); - rest_activate_event_resource(&resource_event); #endif #if defined (PLATFORM_HAS_LEDS) #if REST_RES_LEDS From f38962a3c424ac07276eb2947128e508d0a275cc Mon Sep 17 00:00:00 2001 From: Ivan Delamer Date: Wed, 7 Mar 2012 12:50:10 -0700 Subject: [PATCH 14/23] Do not remove infinite default routers when PROBE fails. --- core/net/uip-ds6.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/net/uip-ds6.c b/core/net/uip-ds6.c index 1f54ca072..ad4f9ab9c 100644 --- a/core/net/uip-ds6.c +++ b/core/net/uip-ds6.c @@ -224,7 +224,9 @@ uip_ds6_periodic(void) if(locnbr->nscount >= UIP_ND6_MAX_UNICAST_SOLICIT) { PRINTF("PROBE END\n"); if((locdefrt = uip_ds6_defrt_lookup(&locnbr->ipaddr)) != NULL) { - uip_ds6_defrt_rm(locdefrt); + if (!locdefrt->isinfinite) { + uip_ds6_defrt_rm(locdefrt); + } } uip_ds6_nbr_rm(locnbr); } else if(stimer_expired(&locnbr->sendns) && (uip_len == 0)) { From dd967e62f5e8b6d158a54bcd6f62a00c80462ec8 Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Wed, 7 Mar 2012 22:22:58 +0100 Subject: [PATCH 15/23] Applied patch provided by Franck Rousseau restoring UIP_LLH_LEN. --- core/net/uip6.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/net/uip6.c b/core/net/uip6.c index 027532c61..942e0dfae 100644 --- a/core/net/uip6.c +++ b/core/net/uip6.c @@ -1048,7 +1048,7 @@ uip_process(uint8_t flag) if(flag == UIP_UDP_TIMER) { if(uip_udp_conn->lport != 0) { uip_conn = NULL; - uip_sappdata = uip_appdata = &uip_buf[UIP_IPUDPH_LEN]; + uip_sappdata = uip_appdata = &uip_buf[UIP_IPUDPH_LEN + UIP_LLH_LEN]; uip_len = uip_slen = 0; uip_flags = UIP_POLL; UIP_UDP_APPCALL(); @@ -1447,7 +1447,7 @@ uip_process(uint8_t flag) send. */ #if UIP_UDP_CHECKSUMS uip_len = uip_len - UIP_IPUDPH_LEN; - uip_appdata = &uip_buf[UIP_IPUDPH_LEN]; + uip_appdata = &uip_buf[UIP_IPUDPH_LEN + UIP_LLH_LEN]; if(UIP_UDP_BUF->udpchksum != 0 && uip_udpchksum() != 0xffff) { UIP_STAT(++uip_stat.udp.drop); UIP_STAT(++uip_stat.udp.chkerr); @@ -1500,7 +1500,7 @@ uip_process(uint8_t flag) uip_conn = NULL; uip_flags = UIP_NEWDATA; - uip_sappdata = uip_appdata = &uip_buf[UIP_IPUDPH_LEN]; + uip_sappdata = uip_appdata = &uip_buf[UIP_IPUDPH_LEN + UIP_LLH_LEN]; uip_slen = 0; UIP_UDP_APPCALL(); From 684c3edfa62cad96ae5f07fe26f46d238404cfa4 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Wed, 7 Mar 2012 01:14:54 +0100 Subject: [PATCH 16/23] Cross compiler interrupt service routine compatibility definitions for MSP430 based platforms based on isr_compat.h by Steve Underwood. --- cpu/msp430/button.c | 4 +- cpu/msp430/cc2420-arch-sfd.c | 9 +-- cpu/msp430/cc2420-arch.c | 11 +--- cpu/msp430/cc2520-arch-sfd.c | 9 +-- cpu/msp430/cc2520-arch.c | 9 +-- cpu/msp430/f1xxx/clock.c | 9 +-- cpu/msp430/f1xxx/rtimer-arch.c | 9 +-- cpu/msp430/f1xxx/uart1.c | 17 +----- cpu/msp430/f2xxx/uart0.c | 18 +----- cpu/msp430/f2xxx/uart1.c | 8 +-- cpu/msp430/f5xxx/clock.c | 9 +-- cpu/msp430/f5xxx/rtimer-arch.c | 9 +-- cpu/msp430/f5xxx/uart0.c | 11 +--- cpu/msp430/f5xxx/uart1.c | 9 +-- cpu/msp430/isr_compat.h | 87 ++++++++++++++++++++++++++++ cpu/msp430/watchdog.c | 9 +-- platform/esb/dev/button-sensor.c | 5 +- platform/esb/dev/ir.c | 3 +- platform/esb/dev/irq.c | 7 +-- platform/esb/dev/rs232.c | 4 +- platform/esb/dev/tr1001-gcr.c | 4 +- platform/esb/dev/tr1001.c | 4 +- platform/msb430/dev/cc1020.c | 3 +- platform/msb430/dev/dma.c | 3 +- platform/msb430/dev/msb430-uart1.c | 4 +- platform/sky/dev/button-sensor.c | 9 +-- platform/wismote/dev/button-sensor.c | 9 +-- platform/z1/dev/adxl345.c | 10 +--- platform/z1/dev/button-sensor.c | 10 +--- platform/z1/dev/cc2420-arch.c | 4 +- platform/z1/dev/i2cmaster.c | 23 ++------ 31 files changed, 157 insertions(+), 182 deletions(-) create mode 100644 cpu/msp430/isr_compat.h diff --git a/cpu/msp430/button.c b/cpu/msp430/button.c index 31eb9c006..6a29275bb 100644 --- a/cpu/msp430/button.c +++ b/cpu/msp430/button.c @@ -31,6 +31,7 @@ #include "contiki.h" #include "dev/button.h" +#include "isr_compat.h" #define BUTTON_PORT 2 #define BUTTON_PIN 7 @@ -57,8 +58,7 @@ button_init(struct process *proc) P2IE &= ~BV(BUTTON_PIN); } -interrupt(PORT2_VECTOR) -__button_interrupt(void) +ISR(PORT2, __button_interrupt) { static struct timer debouncetimer; diff --git a/cpu/msp430/cc2420-arch-sfd.c b/cpu/msp430/cc2420-arch-sfd.c index 21e41b9d8..856a5d2e0 100644 --- a/cpu/msp430/cc2420-arch-sfd.c +++ b/cpu/msp430/cc2420-arch-sfd.c @@ -32,6 +32,7 @@ #include "contiki.h" #include "dev/spi.h" #include "dev/cc2420.h" +#include "isr_compat.h" extern volatile uint8_t cc2420_sfd_counter; extern volatile uint16_t cc2420_sfd_start_time; @@ -39,13 +40,7 @@ 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) +ISR(TIMERB1, cc2420_timerb1_interrupt) { int tbiv; ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/cpu/msp430/cc2420-arch.c b/cpu/msp430/cc2420-arch.c index abc44fa9a..e6ad9657a 100644 --- a/cpu/msp430/cc2420-arch.c +++ b/cpu/msp430/cc2420-arch.c @@ -34,6 +34,7 @@ #include "dev/spi.h" #include "dev/cc2420.h" +#include "isr_compat.h" #ifdef CC2420_CONF_SFD_TIMESTAMPS #define CONF_SFD_TIMESTAMPS CC2420_CONF_SFD_TIMESTAMPS @@ -48,14 +49,7 @@ #endif /*---------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=CC2420_IRQ_VECTOR -__interrupt void -#else -interrupt(CC2420_IRQ_VECTOR) -#endif - -cc24240_port1_interrupt(void) +ISR(CC2420_IRQ, cc2420_port1_interrupt) { ENERGEST_ON(ENERGEST_TYPE_IRQ); @@ -65,7 +59,6 @@ cc24240_port1_interrupt(void) ENERGEST_OFF(ENERGEST_TYPE_IRQ); } - /*---------------------------------------------------------------------------*/ void cc2420_arch_init(void) diff --git a/cpu/msp430/cc2520-arch-sfd.c b/cpu/msp430/cc2520-arch-sfd.c index e24090d09..ff47a48c8 100644 --- a/cpu/msp430/cc2520-arch-sfd.c +++ b/cpu/msp430/cc2520-arch-sfd.c @@ -30,6 +30,7 @@ #include "contiki.h" #include "dev/spi.h" #include "dev/cc2520.h" +#include "isr_compat.h" extern volatile uint8_t cc2520_sfd_counter; extern volatile uint16_t cc2520_sfd_start_time; @@ -37,13 +38,7 @@ extern volatile uint16_t cc2520_sfd_end_time; /*---------------------------------------------------------------------------*/ /* SFD interrupt for timestamping radio packets */ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=TIMERB1_VECTOR -__interrupt void -#else -interrupt(TIMERB1_VECTOR) -#endif -cc2520_timerb1_interrupt(void) +ISR(TIMERB1, cc2520_timerb1_interrupt) { int tbiv; ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/cpu/msp430/cc2520-arch.c b/cpu/msp430/cc2520-arch.c index f6613dade..e8792b86a 100644 --- a/cpu/msp430/cc2520-arch.c +++ b/cpu/msp430/cc2520-arch.c @@ -32,6 +32,7 @@ #include "dev/spi.h" #include "dev/cc2520.h" +#include "isr_compat.h" #ifdef CC2520_CONF_SFD_TIMESTAMPS #define CONF_SFD_TIMESTAMPS CC2520_CONF_SFD_TIMESTAMPS @@ -46,13 +47,7 @@ #endif /*---------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=CC2520_IRQ_VECTOR -__interrupt void -#else -interrupt(CC2520_IRQ_VECTOR) -#endif -cc2520_port1_interrupt(void) +ISR(CC2520_IRQ, cc2520_port1_interrupt) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/cpu/msp430/f1xxx/clock.c b/cpu/msp430/f1xxx/clock.c index b133eaa6e..8e0be8728 100644 --- a/cpu/msp430/f1xxx/clock.c +++ b/cpu/msp430/f1xxx/clock.c @@ -35,6 +35,7 @@ #include "sys/etimer.h" #include "rtimer-arch.h" #include "dev/watchdog.h" +#include "isr_compat.h" #define INTERVAL (RTIMER_ARCH_SECOND / CLOCK_SECOND) @@ -46,13 +47,7 @@ static volatile clock_time_t count = 0; /* last_tar is used for calculating clock_fine */ static volatile uint16_t last_tar = 0; /*---------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=TIMERA1_VECTOR -__interrupt void -#else -interrupt(TIMERA1_VECTOR) -#endif -timera1 (void) +ISR(TIMERA1, timera1) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/cpu/msp430/f1xxx/rtimer-arch.c b/cpu/msp430/f1xxx/rtimer-arch.c index 9584ee4e7..a1ef89a6f 100644 --- a/cpu/msp430/f1xxx/rtimer-arch.c +++ b/cpu/msp430/f1xxx/rtimer-arch.c @@ -44,6 +44,7 @@ #include "sys/rtimer.h" #include "sys/process.h" #include "dev/watchdog.h" +#include "isr_compat.h" #define DEBUG 0 #if DEBUG @@ -54,13 +55,7 @@ #endif /*---------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=TIMERA0_VECTOR -__interrupt void -#else -interrupt(TIMERA0_VECTOR) -#endif -timera0 (void) +ISR(TIMERA0, timera0) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/cpu/msp430/f1xxx/uart1.c b/cpu/msp430/f1xxx/uart1.c index f9bf8ce52..123b542ad 100644 --- a/cpu/msp430/f1xxx/uart1.c +++ b/cpu/msp430/f1xxx/uart1.c @@ -39,6 +39,7 @@ #include "dev/watchdog.h" #include "sys/ctimer.h" #include "lib/ringbuf.h" +#include "isr_compat.h" static int (*uart1_input_handler)(unsigned char c); static volatile uint8_t rx_in_progress; @@ -236,13 +237,7 @@ 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) +ISR(UART1RX, uart1_rx_interrupt) { uint8_t c; ENERGEST_ON(ENERGEST_TYPE_IRQ); @@ -273,13 +268,7 @@ uart1_rx_interrupt(void) #endif /* !RX_WITH_DMA */ /*---------------------------------------------------------------------------*/ #if TX_WITH_INTERRUPT -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=UART1TX_VECTOR -__interrupt void -#else -interrupt(UART1TX_VECTOR) -#endif -uart1_tx_interrupt(void) +ISR(UART1TX, uart1_tx_interrupt) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/cpu/msp430/f2xxx/uart0.c b/cpu/msp430/f2xxx/uart0.c index e79abacc1..d0ad49730 100644 --- a/cpu/msp430/f2xxx/uart0.c +++ b/cpu/msp430/f2xxx/uart0.c @@ -41,6 +41,7 @@ #include "dev/watchdog.h" #include "lib/ringbuf.h" #include "dev/leds.h" +#include "isr_compat.h" static int (*uart0_input_handler)(unsigned char c); @@ -138,14 +139,7 @@ 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) +ISR(USCIAB0RX, uart0_rx_interrupt) { uint8_t c; @@ -165,13 +159,7 @@ 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) +ISR(USCIAB0TX, uart0_tx_interrupt) { ENERGEST_ON(ENERGEST_TYPE_IRQ); if((IFG2 & UCA0TXIFG)){ diff --git a/cpu/msp430/f2xxx/uart1.c b/cpu/msp430/f2xxx/uart1.c index d300e455a..b2ab64101 100644 --- a/cpu/msp430/f2xxx/uart1.c +++ b/cpu/msp430/f2xxx/uart1.c @@ -37,8 +37,8 @@ #include "sys/energest.h" #include "dev/uart1.h" #include "dev/watchdog.h" - #include "lib/ringbuf.h" +#include "isr_compat.h" static int (*uart1_input_handler)(unsigned char c); @@ -120,8 +120,7 @@ uart1_init(unsigned long ubr) } /*---------------------------------------------------------------------------*/ -interrupt(USCIAB1RX_VECTOR) -uart1_rx_interrupt(void) +ISR(USCIAB1RX, uart1_rx_interrupt) { uint8_t c; ENERGEST_ON(ENERGEST_TYPE_IRQ); @@ -141,8 +140,7 @@ uart1_rx_interrupt(void) } /*---------------------------------------------------------------------------*/ #if TX_WITH_INTERRUPT -interrupt(USCIAB1TX_VECTOR) -uart1_tx_interrupt(void) +ISR(USCIAB1TX, uart1_tx_interrupt) { ENERGEST_ON(ENERGEST_TYPE_IRQ); if(IFG2 & UCA0TXIFG) { diff --git a/cpu/msp430/f5xxx/clock.c b/cpu/msp430/f5xxx/clock.c index 49d693dde..d0cca7e83 100644 --- a/cpu/msp430/f5xxx/clock.c +++ b/cpu/msp430/f5xxx/clock.c @@ -35,6 +35,7 @@ #include "sys/etimer.h" #include "rtimer-arch.h" #include "dev/watchdog.h" +#include "isr_compat.h" #define INTERVAL (RTIMER_ARCH_SECOND / CLOCK_SECOND) @@ -46,13 +47,7 @@ static volatile clock_time_t count = 0; /* last_tar is used for calculating clock_fine, last_ccr might be better? */ static volatile uint16_t last_tar = 0; /*---------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=TIMER1_A1_VECTOR -__interrupt void -#else -interrupt(TIMER1_A1_VECTOR) -#endif -timera1 (void) +ISR(TIMER1_A1, timera1) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/cpu/msp430/f5xxx/rtimer-arch.c b/cpu/msp430/f5xxx/rtimer-arch.c index 910d76b9c..80f50ae8d 100644 --- a/cpu/msp430/f5xxx/rtimer-arch.c +++ b/cpu/msp430/f5xxx/rtimer-arch.c @@ -41,6 +41,7 @@ #include "sys/rtimer.h" #include "sys/process.h" #include "dev/watchdog.h" +#include "isr_compat.h" #define DEBUG 0 #if DEBUG @@ -51,13 +52,7 @@ #endif /*---------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=TIMER1_A0_VECTOR -__interrupt void -#else -interrupt(TIMER1_A0_VECTOR) -#endif -timera0 (void) +ISR(TIMER1_A0, timera0) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/cpu/msp430/f5xxx/uart0.c b/cpu/msp430/f5xxx/uart0.c index 7c1e26b31..563da896f 100644 --- a/cpu/msp430/f5xxx/uart0.c +++ b/cpu/msp430/f5xxx/uart0.c @@ -38,6 +38,7 @@ #include "sys/energest.h" #include "dev/uart0.h" #include "dev/watchdog.h" +#include "isr_compat.h" static int (*uart0_input_handler)(unsigned char c); @@ -98,18 +99,12 @@ uart0_init(unsigned long ubr) UCA0IE |= UCRXIE; /* Enable UCA0 RX interrupt */ } /*---------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=USCI_A0_VECTOR -__interrupt void -#else -interrupt(USCI_A0_VECTOR) -#endif -uart0_rx_interrupt(void) +ISR(USCI_A0, uart0_rx_interrupt) { uint8_t c; ENERGEST_ON(ENERGEST_TYPE_IRQ); - if (UCA0IV == 2) { + if(UCA0IV == 2) { if(UCA0STAT & UCRXERR) { c = UCA0RXBUF; /* Clear error flags by forcing a dummy read. */ } else { diff --git a/cpu/msp430/f5xxx/uart1.c b/cpu/msp430/f5xxx/uart1.c index f8e6d6a68..8680b1867 100644 --- a/cpu/msp430/f5xxx/uart1.c +++ b/cpu/msp430/f5xxx/uart1.c @@ -38,6 +38,7 @@ #include "sys/energest.h" #include "dev/uart1.h" #include "dev/watchdog.h" +#include "isr_compat.h" static int (*uart1_input_handler)(unsigned char c); @@ -103,13 +104,7 @@ uart1_init(unsigned long ubr) UCA1IE |= UCRXIE; /* Enable UCA1 RX interrupt */ } /*---------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=USCI_A1_VECTOR -__interrupt void -#else -interrupt(USCI_A1_VECTOR) -#endif -uart1_rx_interrupt(void) +ISR(USCI_A1, uart1_rx_interrupt) { uint8_t c; diff --git a/cpu/msp430/isr_compat.h b/cpu/msp430/isr_compat.h new file mode 100644 index 000000000..5d1a2dcff --- /dev/null +++ b/cpu/msp430/isr_compat.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2005 Steve Underwood + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + */ + +#ifndef _ISR_COMPAT_H_ +#define _ISR_COMPAT_H_ + +/* Cross compiler interrupt service routine compatibility definitions */ +/* This code currently allows for: + MSPGCC - the GNU tools for the MSP430 + Quadravox AQ430 + IAR Version 1 (old syntax) + IAR Versions 2, 3, 4, 5 (new syntax) + Rowley Crossworks + Code Composer Essentials + + These macros allow us to define interrupt routines for all + compilers with a common syntax: + + ISR(, ) + { + } + + e.g. + + ISR(ADC12, adc_service_routine) + { + ADC12CTL0 &= ~ENC; + ADC12CTL0 |= ENC; + } +*/ + +/* 2012-03-02: minor update to support IAR version 4 and 5 */ + +/* A tricky #define to stringify _Pragma parameters */ +#define __PRAGMA__(x) _Pragma(#x) + +#if defined(__GNUC__) && defined(__MSP430__) + /* This is the MSPGCC compiler */ +#define ISR(a,b) interrupt(a ## _VECTOR) b(void) +#elif defined(__AQCOMPILER__) + /* This is the Quadravox compiler */ +#define ISR(a,b) void _INTERRUPT[a ## _VECTOR] b(void) +#elif defined(__IAR_SYSTEMS_ICC__) && (((__TID__ >> 8) & 0x7f) == 43) && (__VER__ < 200) + /* This is V1.xx of the IAR compiler. */ +#define ISR(a,b) interrupt[a ## _VECTOR] void b(void) +#elif defined(__IAR_SYSTEMS_ICC__) && (((__TID__ >> 8) & 0x7f) == 43) && (__VER__ < 600) + /* This is V2.xx, V3.xx, V4.xx, V5.xx of the IAR compiler. */ +#define ISR(a,b) \ +__PRAGMA__(vector=a ##_VECTOR) \ +__interrupt void b(void) +#elif defined(__CROSSWORKS_MSP430) + /* This is the Rowley Crossworks compiler */ +#define ISR(a,b) void b __interrupt[a ## _VECTOR](void) +#elif defined(__TI_COMPILER_VERSION__) + /* This is the Code Composer Essentials compiler. */ +#define ISR(a,b) __interrupt void b(void); \ +a ## _ISR(b) \ +__interrupt void b(void) +#else + #error Compiler not recognised. +#endif + +#endif diff --git a/cpu/msp430/watchdog.c b/cpu/msp430/watchdog.c index 6ac86994c..b38db161d 100644 --- a/cpu/msp430/watchdog.c +++ b/cpu/msp430/watchdog.c @@ -33,6 +33,7 @@ #include "contiki.h" #include "dev/watchdog.h" +#include "isr_compat.h" static int counter = 0; @@ -70,13 +71,7 @@ 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) +ISR(WDT, watchdog_interrupt) { #ifdef CONTIKI_TARGET_SKY #if PRINT_STACK_ON_REBOOT diff --git a/platform/esb/dev/button-sensor.c b/platform/esb/dev/button-sensor.c index 4956fb51f..eb6a81f8a 100644 --- a/platform/esb/dev/button-sensor.c +++ b/platform/esb/dev/button-sensor.c @@ -33,7 +33,7 @@ #include "dev/button-sensor.h" #include "dev/hwconf.h" -#include +#include "isr_compat.h" const struct sensors_sensor button_sensor; @@ -43,8 +43,7 @@ HWCONF_PIN(BUTTON, 2, 7); HWCONF_IRQ(BUTTON, 2, 7); /*---------------------------------------------------------------------------*/ -interrupt(PORT2_VECTOR) - irq_p2(void) +ISR(PORT2, irq_p2) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/platform/esb/dev/ir.c b/platform/esb/dev/ir.c index 5a5bdefb1..56ac46a27 100644 --- a/platform/esb/dev/ir.c +++ b/platform/esb/dev/ir.c @@ -78,6 +78,7 @@ Contributors: Thomas Pietsch, Bjoern Lichtblau #include "dev/leds.h" #include "dev/beep.h" +#include "isr_compat.h" PROCESS(ir_process, "IR receiver"); process_event_t ir_event_received; @@ -202,7 +203,7 @@ static void clearDataAvailableBit(void){ recvdata &= 0xEFFF; } /// Timer B0 interrupt service routine -interrupt(TIMERB1_VECTOR) Timer_B1 (void) { +ISR(TIMERB1, Timer_B1) { /*P2OUT = (P2OUT & 0xf7) | (8 - (P2OUT & 0x08));*/ diff --git a/platform/esb/dev/irq.c b/platform/esb/dev/irq.c index d16d4de87..bf5ef6649 100644 --- a/platform/esb/dev/irq.c +++ b/platform/esb/dev/irq.c @@ -34,6 +34,7 @@ #include "lib/sensors.h" #include "dev/irq.h" #include "dev/lpm.h" +#include "isr_compat.h" #define ADC12MCTL_NO(adcno) ((unsigned char *) ADC12MCTL0_)[adcno] @@ -42,8 +43,7 @@ static int (* port1_irq[8])(void); static unsigned char adcflags; /*---------------------------------------------------------------------------*/ -interrupt(PORT1_VECTOR) - irq_p1(void) +ISR(PORT1, irq_p1) { int i; ENERGEST_ON(ENERGEST_TYPE_IRQ); @@ -58,8 +58,7 @@ interrupt(PORT1_VECTOR) ENERGEST_OFF(ENERGEST_TYPE_IRQ); } /*---------------------------------------------------------------------------*/ -interrupt (ADC_VECTOR) - irq_adc(void) +ISR(ADC, irq_adc) { int i; ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/platform/esb/dev/rs232.c b/platform/esb/dev/rs232.c index 79c9d737b..239ee3181 100644 --- a/platform/esb/dev/rs232.c +++ b/platform/esb/dev/rs232.c @@ -47,12 +47,12 @@ #include #include "contiki-esb.h" +#include "isr_compat.h" static int (* input_handler)(unsigned char) = NULL; /*---------------------------------------------------------------------------*/ -interrupt(UART1RX_VECTOR) - rs232_rx_usart1(void) +ISR(UART1RX, rs232_rx_usart1) { ENERGEST_ON(ENERGEST_TYPE_IRQ); /* Check status register for receive errors. - before reading RXBUF since diff --git a/platform/esb/dev/tr1001-gcr.c b/platform/esb/dev/tr1001-gcr.c index 744d6b358..4defcc9bf 100644 --- a/platform/esb/dev/tr1001-gcr.c +++ b/platform/esb/dev/tr1001-gcr.c @@ -59,6 +59,7 @@ #include "lib/crc16.h" #include "net/netstack.h" #include "net/rime/rimestats.h" +#include "isr_compat.h" #include @@ -385,8 +386,7 @@ tr1001_init(void) return 1; } /*---------------------------------------------------------------------------*/ -interrupt (UART0RX_VECTOR) - tr1001_rxhandler(void) +ISR(UART0RX, tr1001_rxhandler) { ENERGEST_ON(ENERGEST_TYPE_IRQ); tr1001_default_rxhandler_pt(RXBUF0); diff --git a/platform/esb/dev/tr1001.c b/platform/esb/dev/tr1001.c index 13cfe42bd..de6ded2f1 100644 --- a/platform/esb/dev/tr1001.c +++ b/platform/esb/dev/tr1001.c @@ -59,6 +59,7 @@ #include "lib/crc16.h" #include "net/netstack.h" #include "net/rime/rimestats.h" +#include "isr_compat.h" #include @@ -376,8 +377,7 @@ tr1001_init(void) return 1; } /*---------------------------------------------------------------------------*/ -interrupt (UART0RX_VECTOR) - tr1001_rxhandler(void) +ISR(UART0RX, tr1001_rxhandler) { ENERGEST_ON(ENERGEST_TYPE_IRQ); tr1001_default_rxhandler_pt(RXBUF0); diff --git a/platform/msb430/dev/cc1020.c b/platform/msb430/dev/cc1020.c index 1e8e1a0a6..b050c7931 100644 --- a/platform/msb430/dev/cc1020.c +++ b/platform/msb430/dev/cc1020.c @@ -52,6 +52,7 @@ #include "net/rime/rimestats.h" #include "dev/dma.h" #include "sys/energest.h" +#include "isr_compat.h" #define DEBUG 0 #if DEBUG @@ -458,7 +459,7 @@ PROCESS_THREAD(cc1020_receiver_process, ev, data) PROCESS_END(); } -interrupt(UART0RX_VECTOR) cc1020_rxhandler(void) +ISR(UART0RX, cc1020_rxhandler) { static signed char syncbs; static union { diff --git a/platform/msb430/dev/dma.c b/platform/msb430/dev/dma.c index 811416e76..ce175ee12 100644 --- a/platform/msb430/dev/dma.c +++ b/platform/msb430/dev/dma.c @@ -41,10 +41,11 @@ #include "contiki-msb430.h" #include "dev/cc1020.h" #include "dev/dma.h" +#include "isr_compat.h" static void (*callbacks[DMA_LINES])(void); -interrupt(DACDMA_VECTOR) irq_dacdma(void) +ISR(DACDMA, irq_dacdma) { if(DMA0CTL & DMAIFG) { DMA0CTL &= ~(DMAIFG | DMAIE); diff --git a/platform/msb430/dev/msb430-uart1.c b/platform/msb430/dev/msb430-uart1.c index 997648931..d8ce6a44c 100644 --- a/platform/msb430/dev/msb430-uart1.c +++ b/platform/msb430/dev/msb430-uart1.c @@ -55,6 +55,7 @@ Berlin, 2007 #include #include "dev/msb430-uart1.h" #include "dev/lpm.h" +#include "isr_compat.h" #ifndef U1ME #define U1ME ME2 @@ -204,8 +205,7 @@ uart_get_mode(void) return uart_mode; } /*---------------------------------------------------------------------------*/ -interrupt(UART1RX_VECTOR) -uart_rx(void) +ISR(UART1RX, uart_rx) { uart_handler_t handler = uart_handler[uart_mode]; int c; diff --git a/platform/sky/dev/button-sensor.c b/platform/sky/dev/button-sensor.c index 30a281eb0..51f0acf93 100644 --- a/platform/sky/dev/button-sensor.c +++ b/platform/sky/dev/button-sensor.c @@ -34,6 +34,7 @@ #include "lib/sensors.h" #include "dev/hwconf.h" #include "dev/button-sensor.h" +#include "isr_compat.h" const struct sensors_sensor button_sensor; @@ -44,13 +45,7 @@ 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) +ISR(PORT2, irq_p2) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/platform/wismote/dev/button-sensor.c b/platform/wismote/dev/button-sensor.c index 51bf38c2f..e0e6c9375 100644 --- a/platform/wismote/dev/button-sensor.c +++ b/platform/wismote/dev/button-sensor.c @@ -31,6 +31,7 @@ #include "lib/sensors.h" #include "dev/hwconf.h" #include "dev/button-sensor.h" +#include "isr_compat.h" const struct sensors_sensor button_sensor; @@ -41,13 +42,7 @@ 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) +ISR(PORT2, irq_p2) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/platform/z1/dev/adxl345.c b/platform/z1/dev/adxl345.c index c19ad0031..df653d7f8 100644 --- a/platform/z1/dev/adxl345.c +++ b/platform/z1/dev/adxl345.c @@ -44,6 +44,7 @@ #include "adxl345.h" #include "cc2420.h" #include "i2cmaster.h" +#include "isr_compat.h" /* Callback pointers when interrupt occurs */ void (*accm_int1_cb)(uint8_t reg); @@ -375,13 +376,8 @@ PROCESS_THREAD(accmeter_process, ev, data) { #if 1 static struct timer suppressTimer1, suppressTimer2; -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=PORT1_VECTOR -__interrupt void -#else -interrupt (PORT1_VECTOR) -#endif -port1_isr (void) { +ISR(PORT1, port1_isr) +{ 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/button-sensor.c b/platform/z1/dev/button-sensor.c index bea5b3669..0c1fff35e 100644 --- a/platform/z1/dev/button-sensor.c +++ b/platform/z1/dev/button-sensor.c @@ -35,6 +35,7 @@ #include "lib/sensors.h" #include "dev/hwconf.h" #include "dev/button-sensor.h" +#include "isr_compat.h" const struct sensors_sensor button_sensor; @@ -45,14 +46,7 @@ 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) +ISR(PORT2, irq_p2) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/platform/z1/dev/cc2420-arch.c b/platform/z1/dev/cc2420-arch.c index 5fcfa07b4..2e3d2f18a 100644 --- a/platform/z1/dev/cc2420-arch.c +++ b/platform/z1/dev/cc2420-arch.c @@ -33,6 +33,7 @@ #include "contiki-net.h" #include "dev/spi.h" #include "dev/cc2420.h" +#include "isr_compat.h" #ifndef CONF_SFD_TIMESTAMPS #define CONF_SFD_TIMESTAMPS 0 @@ -45,8 +46,7 @@ /*---------------------------------------------------------------------------*/ #if 0 // this is now handled in the ADXL345 accelerometer code as it uses irq on port1 too. -interrupt(CC2420_IRQ_VECTOR) -cc24240_port1_interrupt(void) +ISR(CC2420_IRQ, cc24240_port1_interrupt) { ENERGEST_ON(ENERGEST_TYPE_IRQ); if(cc2420_interrupt()) { diff --git a/platform/z1/dev/i2cmaster.c b/platform/z1/dev/i2cmaster.c index 54871467a..c2bad507d 100644 --- a/platform/z1/dev/i2cmaster.c +++ b/platform/z1/dev/i2cmaster.c @@ -39,6 +39,7 @@ */ #include "i2cmaster.h" +#include "isr_compat.h" signed char tx_byte_ctr, rx_byte_ctr; unsigned char rx_buf[2]; @@ -201,13 +202,8 @@ i2c_transmit_n(uint8_t byte_ctr, uint8_t *tx_buf) { } /*----------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=USCIAB1TX_VECTOR -__interrupt void -#else -interrupt (USCIAB1TX_VECTOR) -#endif -i2c_tx_interrupt (void) { +ISR(USCIAB1TX, i2c_tx_interrupt) +{ // TX Part if (UC1IFG & UCB1TXIFG) { // TX int. condition if (tx_byte_ctr == 0) { @@ -237,18 +233,11 @@ i2c_tx_interrupt (void) { #endif } -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=USCIAB1RX_VECTOR -__interrupt void -#else -interrupt (USCIAB1RX_VECTOR) -#endif -i2c_rx_interrupt(void) { - if (UCB1STAT & UCNACKIFG){ +ISR(USCIAB1RX, i2c_rx_interrupt) +{ + if(UCB1STAT & UCNACKIFG) { PRINTFDEBUG("!!! NACK received in RX\n"); UCB1CTL1 |= UCTXSTP; UCB1STAT &= ~UCNACKIFG; } } - - From a8e8e6f51d080a2682e04c8fd833fa1b7a51aaa7 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Wed, 7 Mar 2012 01:16:17 +0100 Subject: [PATCH 17/23] io and signal have been moved into contiki include file --- platform/msb430/dev/adc.c | 2 -- platform/msb430/dev/cc1020-internal.h | 2 +- platform/msb430/dev/cc1020.c | 1 - platform/msb430/dev/infomem.c | 2 -- 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/platform/msb430/dev/adc.c b/platform/msb430/dev/adc.c index 18b1ebdfa..fb14d3723 100644 --- a/platform/msb430/dev/adc.c +++ b/platform/msb430/dev/adc.c @@ -38,8 +38,6 @@ */ #include "contiki.h" -#include - #include "contiki-msb430.h" void diff --git a/platform/msb430/dev/cc1020-internal.h b/platform/msb430/dev/cc1020-internal.h index f33f95a4d..f0053ea97 100644 --- a/platform/msb430/dev/cc1020-internal.h +++ b/platform/msb430/dev/cc1020-internal.h @@ -1,7 +1,7 @@ #ifndef CC1020_INTERNAL_H #define CC1020_INTERNAL_H -#include +#include "contiki.h" #define CC1020_MAIN 0x00 #define CC1020_INTERFACE 0x01 diff --git a/platform/msb430/dev/cc1020.c b/platform/msb430/dev/cc1020.c index b050c7931..f5c9ba291 100644 --- a/platform/msb430/dev/cc1020.c +++ b/platform/msb430/dev/cc1020.c @@ -41,7 +41,6 @@ #include #include -#include #include "contiki.h" #include "contiki-msb430.h" diff --git a/platform/msb430/dev/infomem.c b/platform/msb430/dev/infomem.c index 1bb0da23d..53cd27448 100644 --- a/platform/msb430/dev/infomem.c +++ b/platform/msb430/dev/infomem.c @@ -51,10 +51,8 @@ Berlin, 2007 * across both blocks are not allowed. */ #include -#include #include #include "contiki-conf.h" -#include #include "infomem.h" void From 11fecd86daa00ddbef01c22d2b3f05021ee4e1c0 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Wed, 7 Mar 2012 02:23:40 +0100 Subject: [PATCH 18/23] Moved i2cmaster and adxl345 to contiki target source files --- platform/z1/Makefile.common | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/platform/z1/Makefile.common b/platform/z1/Makefile.common index ed98d22c9..8374573fa 100644 --- a/platform/z1/Makefile.common +++ b/platform/z1/Makefile.common @@ -1,7 +1,5 @@ # $Id: Makefile.z1,v 1.5 2011/02/26 enricmcalvo Exp $ -PROJECT_SOURCEFILES += i2cmaster.c adxl345.c - ifdef GCC CFLAGS+=-Os -g endif @@ -13,9 +11,6 @@ LDFLAGS += -Wl,--defsym -Wl,__P1SEL2=0x0041 -Wl,--defsym -Wl,__P5SEL2=0x0045 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__ - ARCH=msp430.c leds.c watchdog.c xmem.c \ spi.c cc2420.c cc2420-aes.c cc2420-arch.c cc2420-arch-sfd.c\ @@ -39,6 +34,7 @@ CFLAGS += -DMACID=$(nodemac) endif CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) +CONTIKI_TARGET_SOURCEFILES += i2cmaster.c adxl345.c CONTIKI_TARGET_SOURCEFILES += contiki-z1-platform.c MCU=msp430x2617 From 09e45cb12cfc0e0d6a2948cb1172da33846e6252 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Wed, 7 Mar 2012 02:26:48 +0100 Subject: [PATCH 19/23] contiki-z1-platform is added by Makefile.z1 --- platform/z1/Makefile.common | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/z1/Makefile.common b/platform/z1/Makefile.common index 8374573fa..c6080da94 100644 --- a/platform/z1/Makefile.common +++ b/platform/z1/Makefile.common @@ -35,7 +35,6 @@ endif CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) CONTIKI_TARGET_SOURCEFILES += i2cmaster.c adxl345.c -CONTIKI_TARGET_SOURCEFILES += contiki-z1-platform.c MCU=msp430x2617 include $(CONTIKI)/cpu/msp430/Makefile.msp430 From 569477b10cba3ed851a9245c5add35ab2a83829c Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Wed, 7 Mar 2012 02:36:13 +0100 Subject: [PATCH 20/23] contiki-sky-platform is added by Makefile.sky --- platform/sky/Makefile.common | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/platform/sky/Makefile.common b/platform/sky/Makefile.common index d5f0c82d1..621ceaf36 100644 --- a/platform/sky/Makefile.common +++ b/platform/sky/Makefile.common @@ -20,9 +20,7 @@ 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 +CONTIKI_TARGET_SOURCEFILES += $(ARCH) $(UIPDRIVERS) MCU=msp430x1611 include $(CONTIKI)/cpu/msp430/Makefile.msp430 From ff7a977dc7804e4a1da3bb1f2c1a438ef54d3d2a Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Wed, 7 Mar 2012 23:03:15 +0100 Subject: [PATCH 21/23] Improved support for the IAR compiler for the MSP430 platforms --- cpu/msp430/Makefile.msp430 | 19 +++++++++++++++++-- platform/esb/Makefile.esb | 9 +++++++-- platform/jcreate/platform-jcreate-conf.h | 2 -- .../sentilla-usb/platform-sentilla-usb-conf.h | 2 -- platform/sky/Makefile.common | 10 +++------- platform/wismote/Makefile.wismote | 8 ++------ platform/z1/Makefile.common | 3 ++- 7 files changed, 31 insertions(+), 22 deletions(-) diff --git a/cpu/msp430/Makefile.msp430 b/cpu/msp430/Makefile.msp430 index c173730f8..7d71d4029 100644 --- a/cpu/msp430/Makefile.msp430 +++ b/cpu/msp430/Makefile.msp430 @@ -71,10 +71,19 @@ CUSTOM_RULE_C_TO_O = 1 %.o: %.c $(CC) $(CFLAGS) $< -o $@ +define FINALIZE_CYGWIN_DEPENDENCY +sed -e 's/ \([A-Z]\):\\/ \/cygdrive\/\L\1\//' -e 's/\\/\//g' \ + <$(@:.o=.P) >$(@:.o=.d); \ +rm -f $(@:.o=.P) +endef + CUSTOM_RULE_C_TO_OBJECTDIR_O = 1 $(OBJECTDIR)/%.o: %.c - $(CC) $(CFLAGS) $< -o $@ -# @$(FINALIZE_DEPENDENCY) + $(CC) $(CFLAGS) $< --dependencies=m $(@:.o=.P) -o $@ +ifeq ($(HOST_OS),Windows) + @$(FINALIZE_CYGWIN_DEPENDENCY) +endif + CUSTOM_RULE_C_TO_CO = 1 %.co: %.c $(CC) $(CFLAGS) -DAUTOSTART_ENABLE $< -o $@ @@ -82,6 +91,7 @@ CUSTOM_RULE_C_TO_CO = 1 AROPTS = -o else + GCC = 1 CC = msp430-gcc LD = msp430-gcc @@ -129,8 +139,13 @@ PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)} %.firmware: %.${TARGET} mv $< $@ +ifdef IAR +%.ihex: %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a + $(LD) $(LDFLAGSNO) -Fintel-extended -yn $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ +else %.ihex: %.$(TARGET) $(OBJCOPY) $^ -O ihex $@ +endif %.mspsim: %.${TARGET} java -jar ${CONTIKI}/tools/mspsim/mspsim.jar -platform=${TARGET} $< diff --git a/platform/esb/Makefile.esb b/platform/esb/Makefile.esb index 8aaf31edd..4fa71d2d3 100644 --- a/platform/esb/Makefile.esb +++ b/platform/esb/Makefile.esb @@ -17,7 +17,7 @@ endif CONTIKI_TARGET_SOURCEFILES += $(SENSORS) $(ESB) \ contiki-esb-default-init-lowlevel.c \ contiki-esb-default-init-apps.c \ - rs232.c rs232-putchar.c fader.c $(CONTIKI_TARGET_MAIN) + rs232.c rs232-putchar.c fader.c ifdef WITH_CODEPROP CONTIKI_TARGET_DIRS += ../../apps/codeprop @@ -30,7 +30,7 @@ CFLAGS+=-Os -g endif ifdef IAR -CFLAGS+=-e --vla -Ohz --multiplier=16s --core=430 --double=32 +CFLAGS += -D__MSP430F149__=1 -e --vla -Ohz --multiplier=16s --core=430 --double=32 CFLAGSNO = --dlib_config "$(IAR_PATH)/LIB/DLIB/dl430fn.h" $(CFLAGSWERROR) endif @@ -53,6 +53,11 @@ include $(CONTIKI)/platform/$(TARGET)/apps/Makefile.apps MCU=msp430x149 include $(CONTIKI)/cpu/msp430/Makefile.msp430 +ifdef IAR +LDFLAGSNO += -B -xm "$(IAR_PATH)/lib/dlib/dl430fn.r43" -f "$(IAR_PATH)/config/lnk430f149.xcl" -l contiki-$(TARGET).map -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +LDFLAGS += $(LDFLAGSNO) -Felf -yn +endif # IAR + contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o} # $(AR) rcf $@ $^ diff --git a/platform/jcreate/platform-jcreate-conf.h b/platform/jcreate/platform-jcreate-conf.h index 620127f6b..8344f4a1b 100644 --- a/platform/jcreate/platform-jcreate-conf.h +++ b/platform/jcreate/platform-jcreate-conf.h @@ -60,8 +60,6 @@ #define CCIF #define CLIF -#define CC_CONF_INLINE inline - #define HAVE_STDINT_H #include "msp430def.h" diff --git a/platform/sentilla-usb/platform-sentilla-usb-conf.h b/platform/sentilla-usb/platform-sentilla-usb-conf.h index 67bbee5a7..579c654a3 100644 --- a/platform/sentilla-usb/platform-sentilla-usb-conf.h +++ b/platform/sentilla-usb/platform-sentilla-usb-conf.h @@ -59,8 +59,6 @@ #define CCIF #define CLIF -#define CC_CONF_INLINE inline - #define HAVE_STDINT_H #include "msp430def.h" diff --git a/platform/sky/Makefile.common b/platform/sky/Makefile.common index 621ceaf36..77e13ee84 100644 --- a/platform/sky/Makefile.common +++ b/platform/sky/Makefile.common @@ -17,7 +17,6 @@ endif ifdef IAR CFLAGS += -D__MSP430F1611__=1 -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) @@ -30,12 +29,9 @@ contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o} 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 +LDFLAGSNO += -B -xm "$(IAR_PATH)/lib/dlib/dl430fn.r43" -f "$(IAR_PATH)/config/lnk430f1611.xcl" -l contiki-$(TARGET).map -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +LDFLAGS += $(LDFLAGSNO) -Felf -yn +endif # IAR NUMPAR=20 IHEXFILE=tmpimage.ihex diff --git a/platform/wismote/Makefile.wismote b/platform/wismote/Makefile.wismote index c3ead6982..1a675f7ad 100644 --- a/platform/wismote/Makefile.wismote +++ b/platform/wismote/Makefile.wismote @@ -34,19 +34,15 @@ MCU=msp430x5437 include $(CONTIKI)/cpu/msp430/Makefile.msp430 ifdef IAR -LDFLAGS += -B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl" -l contiki-$(TARGET).map -Fintel-extended -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +LDFLAGSNO += -B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl" -l contiki-$(TARGET).map -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +LDFLAGS += $(LDFLAGSNO) -Felf -yn endif contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o} # $(AR) rcf $@ $^ -ifdef IAR -%.hex: %.$(TARGET) - mv $< $@ -else %.hex: %.ihex mv $< $@ -endif %.upload: %.hex msp430flasher -n msp430x5437 -e ERASE_MAIN -w $< -v -z [VCC] diff --git a/platform/z1/Makefile.common b/platform/z1/Makefile.common index c6080da94..2c21dc75e 100644 --- a/platform/z1/Makefile.common +++ b/platform/z1/Makefile.common @@ -41,7 +41,8 @@ include $(CONTIKI)/cpu/msp430/Makefile.msp430 # Add LDFLAGS after IAR_PATH is set ifdef IAR -LDFLAGS += -B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f2617.xcl" -l contiki-$(TARGET).map -Fintel-extended -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +LDFLAGSNO += -B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f2617.xcl" -l contiki-$(TARGET).map -s __program_start -D_STACK_SIZE=80 -D_DATA16_HEAP_SIZE=80 -D_DATA20_HEAP_SIZE=80 +LDFLAGS += $(LDFLAGSNO) -Felf -yn endif contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o} From 87cd18539bf15c96944416050882a3572b56d916 Mon Sep 17 00:00:00 2001 From: Matthias Kovatsch Date: Thu, 8 Mar 2012 00:48:04 +0100 Subject: [PATCH 22/23] Eliminated RPL_CONF_ADJUST_LLH_LEN correction by using uip_l3_icmp_hdr_len instead of uip_l2_l3_icmp_hdr_len. --- core/net/rpl/rpl-icmp6.c | 13 +++---------- platform/avr-ravenusb/contiki-conf.h | 1 - platform/minimal-net/contiki-conf.h | 1 - 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/core/net/rpl/rpl-icmp6.c b/core/net/rpl/rpl-icmp6.c index 114b673e4..14af70293 100755 --- a/core/net/rpl/rpl-icmp6.c +++ b/core/net/rpl/rpl-icmp6.c @@ -244,11 +244,7 @@ dio_input(void) PRINTF("RPL: Neighbor already in neighbor cache\n"); } - buffer_length = uip_len - uip_l2_l3_icmp_hdr_len; - -#if RPL_CONF_ADJUST_LLH_LEN - buffer_length += UIP_LLH_LEN; /* Add jackdaw, minimal-net ethernet header */ -#endif + buffer_length = uip_len - uip_l3_icmp_hdr_len; /* Process the DIO base option. */ i = 0; @@ -579,11 +575,8 @@ dao_input(void) PRINTF("\n"); buffer = UIP_ICMP_PAYLOAD; - buffer_length = uip_len - uip_l2_l3_icmp_hdr_len; + buffer_length = uip_len - uip_l3_icmp_hdr_len; -#if RPL_CONF_ADJUST_LLH_LEN - buffer_length += UIP_LLH_LEN; /* Add jackdaw, minimal-net ethernet header */ -#endif pos = 0; instance_id = buffer[pos++]; @@ -801,7 +794,7 @@ dao_ack_input(void) uint8_t status; buffer = UIP_ICMP_PAYLOAD; - buffer_length = uip_len - uip_l2_l3_icmp_hdr_len; + buffer_length = uip_len - uip_l3_icmp_hdr_len; instance_id = buffer[0]; sequence = buffer[2]; diff --git a/platform/avr-ravenusb/contiki-conf.h b/platform/avr-ravenusb/contiki-conf.h index 127ef8ac0..663703997 100644 --- a/platform/avr-ravenusb/contiki-conf.h +++ b/platform/avr-ravenusb/contiki-conf.h @@ -392,7 +392,6 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len); #define RF230_MAX_TX_POWER 15 #define RF230_MIN_RX_POWER 30 */ -#define RPL_CONF_ADJUST_LLH_LEN 1 #define UIP_CONF_ROUTER 1 #define UIP_CONF_ND6_SEND_RA 0 #define UIP_CONF_ND6_REACHABLE_TIME 600000 diff --git a/platform/minimal-net/contiki-conf.h b/platform/minimal-net/contiki-conf.h index 8ae127a4b..ea61ac464 100644 --- a/platform/minimal-net/contiki-conf.h +++ b/platform/minimal-net/contiki-conf.h @@ -97,7 +97,6 @@ typedef unsigned short uip_stats_t; * They should all attach to a minimal-net rpl border that uses the same primary interface. * For multihop testing, configure intermediate notes as routers. */ -#define RPL_CONF_ADJUST_LLH_LEN 1 #define HARD_CODED_ADDRESS "bbbb::10" //the prefix is ignored for a rpl node #define UIP_CONF_ROUTER 0 #define UIP_CONF_ND6_SEND_RA 0 From c2e07c9798c97483bddd96fb2854830d4816e27c Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Thu, 8 Mar 2012 22:39:53 +0100 Subject: [PATCH 23/23] Improved support for the IAR compiler. io and signal have been moved into contiki include file. --- platform/exp5438/Makefile.exp5438 | 28 +++++-------------------- platform/exp5438/cc2420-arch.c | 17 ++------------- platform/exp5438/clock.c | 17 ++------------- platform/exp5438/contiki-exp5438-main.c | 7 ------- platform/exp5438/flash.c | 7 ------- platform/exp5438/hal_lcd.c | 5 ----- platform/exp5438/leds-arch.c | 6 ------ platform/exp5438/msp430.c | 6 ------ platform/exp5438/platform-conf.h | 13 ------------ platform/exp5438/rtimer-arch.c | 17 +++------------ platform/exp5438/spix.c | 7 +------ platform/exp5438/uart1x.c | 16 ++------------ platform/exp5438/watchdog.c | 15 ++----------- 13 files changed, 17 insertions(+), 144 deletions(-) diff --git a/platform/exp5438/Makefile.exp5438 b/platform/exp5438/Makefile.exp5438 index 3f4d54820..a3e57fc90 100644 --- a/platform/exp5438/Makefile.exp5438 +++ b/platform/exp5438/Makefile.exp5438 @@ -1,19 +1,8 @@ # $Id: Makefile.z1,v 1.4 2010/11/07 08:40:24 enricmcalvo Exp $ # msp430flasher -n msp430x5437 -w "Firmware.txt" -v -z [VCC] -ifndef IAR -GCC=1 -endif - -ifdef GCC -CFLAGS+=-Os -g -else -IAR=1 -endif - ifdef IAR -CFLAGS+=-e --vla -Ohz --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40 --core=430X --data_model small --double=32 -D__MSP430F5438A__ -CFLAGS += --diag_suppress=Pa050 +CFLAGS+=-e --vla -Ohz --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40 --core=430X --data_model small --double=32 -D__MSP430F5438A__=1 #CFLAGS+=--no_cse --no_unroll --no_inline --no_code_motion --no_tbaa --debug -D__MSP430F5438A__ -e --double=32 --dlib_config 'C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.0 Evaluation\430\LIB\DLIB\dl430xsfn.h' --core=430X --data_model=small -Ol --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40 endif @@ -43,7 +32,7 @@ help: @echo make help - shows this help @echo make TARGET=exp5438 savetarget - stores selection of target to avoid using TARGET= on every make invokation @echo make program.upload - compiles and uploads program to connected board - @echo make program.upload GCC=1 - uses the mspgcc compiler instead of IAR + @echo make program.upload IAR=1 - uses the IAR compiler instead of mspgcc @echo make program.upload NODEID=x - uploads with node_id set to x CONTIKI_TARGET_DIRS = . dev apps net @@ -70,19 +59,12 @@ contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o} ifdef IAR STACKSIZE=300 -LDFLAGS_ELF=-B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl" -l contiki-$(TARGET).map -Felf -yn -s __program_start -D_STACK_SIZE=$(STACKSIZE) -D_DATA16_HEAP_SIZE=$(STACKSIZE) -D_DATA20_HEAP_SIZE=$(STACKSIZE) +LDFLAGSNO += -B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl" -l contiki-$(TARGET).map -s __program_start -D_STACK_SIZE=$(STACKSIZE) -D_DATA16_HEAP_SIZE=$(STACKSIZE) -D_DATA20_HEAP_SIZE=$(STACKSIZE) +LDFLAGS += $(LDFLAGSNO) -Felf -yn +endif -LDFLAGS_HEX=-B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl" -l contiki-$(TARGET).map -Fintel-extended -s __program_start -D_STACK_SIZE=$(STACKSIZE) -D_DATA16_HEAP_SIZE=$(STACKSIZE) -D_DATA20_HEAP_SIZE=$(STACKSIZE) - -LDFLAGS+=$(LDFLAGS_ELF) - -%.hex: %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a - $(LD) $(LDFLAGS_HEX) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ - -else %.hex: %.ihex mv $< $@ -endif %.upload: %.hex msp430flasher -n msp430x5438a -e ERASE_MAIN -w $< -v -z [VCC] diff --git a/platform/exp5438/cc2420-arch.c b/platform/exp5438/cc2420-arch.c index 090dd1611..044e894dd 100644 --- a/platform/exp5438/cc2420-arch.c +++ b/platform/exp5438/cc2420-arch.c @@ -31,19 +31,12 @@ #include "contiki.h" - -#ifdef __IAR_SYSTEMS_ICC__ -#include -#else -#include -#include -#endif - #include "contiki-net.h" #include "dev/spi.h" #include "dev/cc2420.h" #include "dev/leds.h" +#include "isr_compat.h" #ifndef CONF_SFD_TIMESTAMPS #define CONF_SFD_TIMESTAMPS 0 @@ -54,13 +47,7 @@ #endif /*---------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=CC2420_IRQ_VECTOR -__interrupt void -#else -interrupt(CC2420_IRQ_VECTOR) -#endif -cc24240_fifop_interrupt(void) +ISR(CC2420_IRQ, cc24240_fifop_interrupt) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/platform/exp5438/clock.c b/platform/exp5438/clock.c index a7a419380..0b0973c97 100644 --- a/platform/exp5438/clock.c +++ b/platform/exp5438/clock.c @@ -32,18 +32,11 @@ */ #include "contiki-conf.h" - -#ifdef __IAR_SYSTEMS_ICC__ -#include -#else -#include -#include -#endif - #include "sys/energest.h" #include "sys/clock.h" #include "sys/etimer.h" #include "rtimer-arch.h" +#include "isr_compat.h" #include "dev/leds.h" @@ -57,13 +50,7 @@ static volatile clock_time_t count = 0; /* last_tar is used for calculating clock_fine, last_ccr might be better? */ static unsigned short last_tar = 0; /*---------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=TIMER1_A1_VECTOR -__interrupt void -#else -interrupt(TIMER1_A1_VECTOR) -#endif -timera1 (void) +ISR(TIMER1_A1, timera1) { ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/platform/exp5438/contiki-exp5438-main.c b/platform/exp5438/contiki-exp5438-main.c index 92bb570a0..f411ae697 100644 --- a/platform/exp5438/contiki-exp5438-main.c +++ b/platform/exp5438/contiki-exp5438-main.c @@ -30,13 +30,6 @@ */ #include "contiki.h" -#ifdef __IAR_SYSTEMS_ICC__ -#include -#else -#include -#include -#endif - #include #include #include diff --git a/platform/exp5438/flash.c b/platform/exp5438/flash.c index fe6922734..6f9ca6da6 100644 --- a/platform/exp5438/flash.c +++ b/platform/exp5438/flash.c @@ -36,13 +36,6 @@ */ #include "contiki.h" -#ifdef __IAR_SYSTEMS_ICC__ -#include -#else -#include -#include -#endif - #include #include "dev/flash.h" diff --git a/platform/exp5438/hal_lcd.c b/platform/exp5438/hal_lcd.c index 14163f25f..e2475010f 100644 --- a/platform/exp5438/hal_lcd.c +++ b/platform/exp5438/hal_lcd.c @@ -35,11 +35,6 @@ ******************************************************************************/ #include "contiki-conf.h" -#ifdef __IAR_SYSTEMS_ICC__ -#include -#else -#include -#endif #include "hal_MSP-EXP430F5438.h" #include "hal_lcd_fonts.h" diff --git a/platform/exp5438/leds-arch.c b/platform/exp5438/leds-arch.c index c48f0c376..63cd53262 100644 --- a/platform/exp5438/leds-arch.c +++ b/platform/exp5438/leds-arch.c @@ -42,12 +42,6 @@ #include "contiki-conf.h" #include "dev/leds.h" -#ifdef __IAR_SYSTEMS_ICC__ -#include -#else -#include -#endif - /* LED ports */ #define LEDS_CONF_RED 0x01 #define LEDS_CONF_GREEN 0x02 diff --git a/platform/exp5438/msp430.c b/platform/exp5438/msp430.c index c12b6b24d..9c91aa6c2 100644 --- a/platform/exp5438/msp430.c +++ b/platform/exp5438/msp430.c @@ -31,12 +31,6 @@ * @(#)$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 -#endif #include "dev/watchdog.h" #include "dev/leds.h" #include "net/uip.h" diff --git a/platform/exp5438/platform-conf.h b/platform/exp5438/platform-conf.h index f28c7d1ca..5d853a686 100644 --- a/platform/exp5438/platform-conf.h +++ b/platform/exp5438/platform-conf.h @@ -44,19 +44,6 @@ * changeable! */ #define TYNDALL 1 -/* Test for IAR compiler */ -#ifdef __IAR_SYSTEMS_ICC__ -#include -#include -#define dint() __disable_interrupt() -#define eint() __enable_interrupt() -#define __MSP430F5437__ 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 */ #define F_CPU 8000000uL // 8MHz by default diff --git a/platform/exp5438/rtimer-arch.c b/platform/exp5438/rtimer-arch.c index 7a1e327d7..24867a9f2 100644 --- a/platform/exp5438/rtimer-arch.c +++ b/platform/exp5438/rtimer-arch.c @@ -39,17 +39,11 @@ */ #include "contiki.h" -#ifdef __IAR_SYSTEMS_ICC__ -#include -#else -#include -#include -#endif - #include "sys/energest.h" #include "sys/rtimer.h" #include "sys/process.h" #include "dev/watchdog.h" +#include "isr_compat.h" #define DEBUG 0 #if DEBUG @@ -60,13 +54,8 @@ #endif /*---------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=TIMER1_A0_VECTOR -__interrupt void -#else -interrupt(TIMER1_A0_VECTOR) -#endif - timera0 (void) { +ISR(TIMER1_A0, timera0) +{ ENERGEST_ON(ENERGEST_TYPE_IRQ); watchdog_start(); diff --git a/platform/exp5438/spix.c b/platform/exp5438/spix.c index 2f511e650..478931775 100644 --- a/platform/exp5438/spix.c +++ b/platform/exp5438/spix.c @@ -30,17 +30,12 @@ */ #include "contiki-conf.h" -#ifdef __IAR_SYSTEMS_ICC__ -#include -#else -#include -#endif /* * This is SPI initialization code for the MSP430X architecture. * */ -unsigned char spi_busy = 0; +/* unsigned char spi_busy = 0; */ /*---------------------------------------------------------------------------*/ /* * Initialize SPI bus. diff --git a/platform/exp5438/uart1x.c b/platform/exp5438/uart1x.c index 7d0c08977..3c1b41b99 100644 --- a/platform/exp5438/uart1x.c +++ b/platform/exp5438/uart1x.c @@ -36,13 +36,6 @@ */ #include "contiki.h" -#ifdef __IAR_SYSTEMS_ICC__ -#include -#else -#include -#include -#endif - #include #include "sys/energest.h" @@ -50,6 +43,7 @@ #include "dev/watchdog.h" #include "lib/ringbuf.h" #include "dev/leds.h" +#include "isr_compat.h" static int (*uart1_input_handler)(unsigned char c); @@ -114,13 +108,7 @@ uart1_init(unsigned long ubr) UCA1IE |= UCRXIE; /* Enable UCA1 RX interrupt */ } /*---------------------------------------------------------------------------*/ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma vector=USCI_A1_VECTOR -__interrupt void -#else -interrupt(USCI_A1_VECTOR) -#endif -uart1_rx_interrupt(void) +ISR(USCI_A1, uart1_rx_interrupt) { uint8_t c; diff --git a/platform/exp5438/watchdog.c b/platform/exp5438/watchdog.c index fc0dbef47..4a5b222d7 100644 --- a/platform/exp5438/watchdog.c +++ b/platform/exp5438/watchdog.c @@ -32,13 +32,8 @@ */ #include "contiki-conf.h" -#ifdef __IAR_SYSTEMS_ICC__ -#include -#else -#include -#include -#endif #include "dev/watchdog.h" +#include "isr_compat.h" static int counter = 0; @@ -76,13 +71,7 @@ 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) +ISR(WDT, watchdog_interrupt) { #ifdef CONTIKI_TARGET_SKY #if PRINT_STACK_ON_REBOOT