From 0ac2bdbb76fc7289eb5f1c1a087a1aaf5f199454 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Tue, 12 Mar 2013 14:24:25 +0100 Subject: [PATCH 1/2] Added DS2411 to the WiSMote platform setup --- se/sics/mspsim/chip/DS2411.java | 19 +++++++++++++------ .../mspsim/platform/wismote/WismoteNode.java | 12 ++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/se/sics/mspsim/chip/DS2411.java b/se/sics/mspsim/chip/DS2411.java index 57027ab..51101e2 100644 --- a/se/sics/mspsim/chip/DS2411.java +++ b/se/sics/mspsim/chip/DS2411.java @@ -27,20 +27,15 @@ * * This file is part of MSPSim. * - * $Id: DS2411.java 177 2008-03-11 15:32:12Z nifi $ - * * ----------------------------------------------------------------- * * DS2411 - MAC Address chip * * Author : Joakim Eriksson * Created : Sun Oct 21 22:00:00 2007 - * Updated : $Date: 2008-03-11 16:32:12 +0100 (ti, 11 mar 2008) $ - * $Revision: 177 $ */ package se.sics.mspsim.chip; - import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.MSP430Core; @@ -77,7 +72,7 @@ public class DS2411 extends Chip { if (!lastPin) { state = STATE.RESETTING; stateChanged(state.ordinal()); - if (DEBUG) log("Reseting..."); + if (DEBUG) log("Resetting..."); } break; case SIGNAL_READY: @@ -103,6 +98,14 @@ public class DS2411 extends Chip { writeByte = writeBuf[writePos]; } break; + case IDLE: + break; + case RESETTING: + break; + case WAIT_SENDING: + break; + case SENDING: + break; } } }; @@ -175,6 +178,8 @@ public class DS2411 extends Chip { cpu.scheduleTimeEventMillis(stateEvent, 0.400); } break; + case WAIT_FOR_RESET: + break; case RESETTING: if (high) { state = STATE.SIGNAL_READY; @@ -186,6 +191,8 @@ public class DS2411 extends Chip { pos = 0; } break; + case SIGNAL_READY: + break; case READY: /* we should read a byte during the READY - 60us - 120us time slot*/ if (!high) { diff --git a/se/sics/mspsim/platform/wismote/WismoteNode.java b/se/sics/mspsim/platform/wismote/WismoteNode.java index d2b2853..942bb41 100644 --- a/se/sics/mspsim/platform/wismote/WismoteNode.java +++ b/se/sics/mspsim/platform/wismote/WismoteNode.java @@ -38,6 +38,7 @@ package se.sics.mspsim.platform.wismote; import java.io.IOException; import se.sics.mspsim.chip.Button; import se.sics.mspsim.chip.CC2520; +import se.sics.mspsim.chip.DS2411; import se.sics.mspsim.chip.Leds; import se.sics.mspsim.config.MSP430f5437Config; import se.sics.mspsim.core.EmulationException; @@ -52,6 +53,10 @@ import se.sics.mspsim.util.ArgumentManager; public class WismoteNode extends GenericNode implements PortListener, USARTListener { + // Port 1. + public static final int DS2411_DATA_PIN = 1; + public static final int DS2411_DATA = 1 << DS2411_DATA_PIN; + /* P1.6 - Input: FIFOP from CC2520 */ /* P1.5 - Input: FIFO from CC2520 */ /* P1.7 - Input: CCA from CC2520 */ @@ -88,6 +93,7 @@ public class WismoteNode extends GenericNode implements PortListener, USARTListe private Leds leds; private Button button; private WismoteGui gui; + private DS2411 ds2411; public WismoteNode() { super("Wismote", new MSP430f5437Config()); @@ -121,6 +127,9 @@ public class WismoteNode extends GenericNode implements PortListener, USARTListe public void portWrite(IOPort source, int data) { switch (source.getPort()) { + case 1: + ds2411.dataPin((data & DS2411_DATA) != 0); + break; case 2: //System.out.println("LEDS RED1 = " + ((data & LEDS_CONF_RED1) > 0)); leds.setLeds(LEDS_RED1, (data & LEDS_CONF_RED1) == 0 && (source.getDirection() & LEDS_CONF_RED1) != 0); @@ -149,9 +158,12 @@ public class WismoteNode extends GenericNode implements PortListener, USARTListe // if (flashFile != null) { // setFlash(new FileM25P80(cpu, flashFile)); // } + ds2411 = new DS2411(cpu); IOPort port1 = cpu.getIOUnit(IOPort.class, "P1"); port1.addPortListener(this); + ds2411.setDataPort(port1, DS2411_DATA_PIN); + IOPort port2 = cpu.getIOUnit(IOPort.class, "P2"); port2.addPortListener(this); cpu.getIOUnit(IOPort.class, "P3").addPortListener(this); From 7f35e627fd7e0f770ca88319981143388978737e Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Thu, 6 Dec 2012 18:59:29 +0100 Subject: [PATCH 2/2] Corrected leds placement on WiSMote platform --- se/sics/mspsim/chip/Leds.java | 6 +++--- .../mspsim/platform/wismote/WismoteGui.java | 8 ++++---- .../mspsim/platform/wismote/WismoteNode.java | 19 ++++++++----------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/se/sics/mspsim/chip/Leds.java b/se/sics/mspsim/chip/Leds.java index 0ea51ed..f789059 100644 --- a/se/sics/mspsim/chip/Leds.java +++ b/se/sics/mspsim/chip/Leds.java @@ -93,15 +93,15 @@ public class Leds extends Chip { return ledColors.length; } - public int getModeMax() { + @Override public int getModeMax() { return 0; } - public String info() { + @Override public String info() { return "Leds: " + (ledColors.length <= 8 ? Utils.binary8(leds) : Utils.binary16(leds)); } - public int getConfiguration(int parameter) { + @Override public int getConfiguration(int parameter) { return 0; } diff --git a/se/sics/mspsim/platform/wismote/WismoteGui.java b/se/sics/mspsim/platform/wismote/WismoteGui.java index 4d57ff2..55aee70 100755 --- a/se/sics/mspsim/platform/wismote/WismoteGui.java +++ b/se/sics/mspsim/platform/wismote/WismoteGui.java @@ -45,9 +45,9 @@ import se.sics.mspsim.platform.AbstractNodeGUI; public class WismoteGui extends AbstractNodeGUI { private static final long serialVersionUID = -8713047619139235630L; - private static final int RED1_X = 192; + private static final int RED1_X = 172; private static final int GREEN_X = 182; - private static final int RED2_X = 172; + private static final int RED2_X = 192; private static final int LED_Y = 40; private static final int LED_HEIGHT = 11; private static final int LED_WIDTH = 7; @@ -60,8 +60,8 @@ public class WismoteGui extends AbstractNodeGUI { private static final Color BUTTON_C = new Color(0x60ffffff); - private static final Rectangle LEDS_BOUNDS = new Rectangle(RED2_X - 2, - LED_Y - 1, RED1_X - RED2_X + LED_HEIGHT, LED_WIDTH); + private static final Rectangle LEDS_BOUNDS = new Rectangle(RED1_X - 2, + LED_Y - 1, RED2_X - RED1_X + LED_HEIGHT, LED_WIDTH); private final WismoteNode node; private final StateChangeListener ledsListener = new StateChangeListener() { diff --git a/se/sics/mspsim/platform/wismote/WismoteNode.java b/se/sics/mspsim/platform/wismote/WismoteNode.java index 942bb41..c40ef2a 100644 --- a/se/sics/mspsim/platform/wismote/WismoteNode.java +++ b/se/sics/mspsim/platform/wismote/WismoteNode.java @@ -76,14 +76,14 @@ public class WismoteNode extends GenericNode implements PortListener, USARTListe public static final int BUTTON_PIN = 7; /* P8.6 - Red (left) led */ - private static final int LEDS_CONF_RED2 = 1 << 6; - private static final int LEDS_RED2 = 1 << 2; + private static final int LEDS_CONF_RED1 = 1 << 6; + private static final int LEDS_RED1 = 1 << 0; /* P5.2 - Green (middle) led */ - private static final int LEDS_CONF_GREEN = 1 << 2; + private static final int LEDS_CONF_GREEN = 1 << 4; private static final int LEDS_GREEN = 1 << 1; /* P2.4 - Red (right) led */ - private static final int LEDS_CONF_RED1 = 1 << 4; - private static final int LEDS_RED1 = 1 << 0; + private static final int LEDS_CONF_RED2 = 1 << 2; + private static final int LEDS_RED2 = 1 << 2; private static final int[] LEDS = { 0xff2020, 0x20ff20, 0xff2020 }; @@ -131,8 +131,7 @@ public class WismoteNode extends GenericNode implements PortListener, USARTListe ds2411.dataPin((data & DS2411_DATA) != 0); break; case 2: - //System.out.println("LEDS RED1 = " + ((data & LEDS_CONF_RED1) > 0)); - leds.setLeds(LEDS_RED1, (data & LEDS_CONF_RED1) == 0 && (source.getDirection() & LEDS_CONF_RED1) != 0); + leds.setLeds(LEDS_GREEN, (data & LEDS_CONF_GREEN) == 0 && (source.getDirection() & LEDS_CONF_GREEN) != 0); break; case 3: // Chip select = active low... @@ -144,12 +143,10 @@ public class WismoteNode extends GenericNode implements PortListener, USARTListe radio.setVRegOn((data & CC2520_VREG) != 0); break; case 5: - //System.out.println("LEDS GREEN = " + ((data & LEDS_CONF_GREEN) > 0)); - leds.setLeds(LEDS_GREEN, (data & LEDS_CONF_GREEN) == 0 && (source.getDirection() & LEDS_CONF_GREEN) != 0); + leds.setLeds(LEDS_RED2, (data & LEDS_CONF_RED2) == 0 && (source.getDirection() & LEDS_CONF_RED2) != 0); break; case 8: - //System.out.println("LEDS RED2 = " + ((data & LEDS_CONF_RED2) > 0)); - leds.setLeds(LEDS_RED2, (data & LEDS_CONF_RED2) == 0 && (source.getDirection() & LEDS_CONF_RED2) != 0); + leds.setLeds(LEDS_RED1, (data & LEDS_CONF_RED1) == 0 && (source.getDirection() & LEDS_CONF_RED1) != 0); break; } }