mirror of https://github.com/contiki-ng/mspsim
minor fix
This commit is contained in:
parent
fdc856247f
commit
45dc922144
|
|
@ -54,7 +54,7 @@ public class CC2520SPI {
|
|||
SPICommand[] commands = new SPICommand[256];
|
||||
|
||||
CC2520SPI() {
|
||||
|
||||
/* set up the commands */
|
||||
for (int i = 0; i < spiCommands.length; i++) {
|
||||
SPICommand c = spiCommands[i];
|
||||
int maxv = 1 << (8 - c.bitCount);
|
||||
|
|
@ -70,8 +70,18 @@ public class CC2520SPI {
|
|||
}
|
||||
}
|
||||
|
||||
SPICommand getCommand(int cmd) {
|
||||
if (cmd < 256 && commands[cmd] != null)
|
||||
return commands[cmd];
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
new CC2520SPI();
|
||||
CC2520SPI spi = new CC2520SPI();
|
||||
SPICommand cmd = spi.getCommand(0xff);
|
||||
/* commands that take infinite number of bytes have the bitfield ... */
|
||||
System.out.println("Has ... => " + cmd.getBitField("..."));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package se.sics.mspsim.chip;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class SPICommand {
|
||||
/*
|
||||
|
|
@ -93,6 +94,9 @@ public class SPICommand {
|
|||
if (start != 0) {
|
||||
System.out.println("Bitfield: " + currentName + ": [" +
|
||||
start + " - " + (c - 1) + "]");
|
||||
if (bitFields == null)
|
||||
bitFields = new ArrayList<SPICommand.BitField>();
|
||||
bitFields.add(new BitField(currentName, start, c - 1));
|
||||
}
|
||||
|
||||
System.out.printf("Value %x\n", value);
|
||||
|
|
@ -113,11 +117,20 @@ public class SPICommand {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* for any command that is executable (finite commands) */
|
||||
public boolean executeSPICommand(int[] spiData) {
|
||||
System.out.println("Command " + name + " not implemented...");
|
||||
return true;
|
||||
}
|
||||
|
||||
public BitField getBitField(String arg) {
|
||||
for (BitField b : bitFields) {
|
||||
if (b.name.equals(arg)) return b;
|
||||
}
|
||||
/* not existing ... */
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SPICommand c = new SPICommand("MEMXCP 0 1 0 1 0 1 0 p c c c c c c c c a a a a e e e e a a a a a a a a e e e e e e e e") {
|
||||
public boolean executeSPICommand(int[] spiData) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue