Merge pull request #7 from nfi/wismote-ds2411

Added DS2411 to the WiSMote platform setup
This commit is contained in:
mspsim 2013-03-15 06:42:30 -07:00
commit 4e095bcde7
4 changed files with 40 additions and 24 deletions

View File

@ -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) {

View File

@ -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;
}

View File

@ -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() {

View File

@ -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 */
@ -71,14 +76,14 @@ public class WismoteNode extends GenericNode implements PortListener, USARTListe
public static final int BUTTON_PIN = 4;
/* 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 };
@ -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,9 +127,11 @@ 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);
leds.setLeds(LEDS_GREEN, (data & LEDS_CONF_GREEN) == 0 && (source.getDirection() & LEDS_CONF_GREEN) != 0);
break;
case 3:
// Chip select = active low...
@ -135,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;
}
}
@ -149,9 +155,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);