This commit is contained in:
3B Scientific GmbH 2022-05-18 16:37:24 +02:00 committed by GitHub
commit 6ae95011b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 1060 additions and 1 deletions

View File

@ -62,6 +62,7 @@ Z1FIRMWARE = firmware/z1/blink.z1
WISMOTEFIRMWARE = firmware/wismote/blink.wismote
TYNDALLFIRMWARE = firmware/tyndall/blink.tyndall
EXP5438FIRMWARE = firmware/exp5438/testcase-bits.exp5438
LCD122DIPFIRMWARE = firmware/lcd122dip/testcase-lcd.lcd122dip
else
ESBFIRMWARE = ${FIRMWAREFILE}
SKYFIRMWARE = ${FIRMWAREFILE}
@ -69,6 +70,7 @@ Z1FIRMWARE = ${FIRMWAREFILE}
WISMOTEFIRMWARE = ${FIRMWAREFILE}
TYNDALLFIRMWARE = ${FIRMWAREFILE}
EXP5438FIRMWARE = ${FIRMWAREFILE}
LCD122DIPFIRMWARE = ${FIRMWAREFILE}
endif
ifdef MAPFILE
@ -81,7 +83,7 @@ TIMERTEST := tests/timertest.firmware
SCRIPTS := ${addprefix scripts/,autorun.sc duty.sc}
BINARY := README.txt license.txt CHANGE_LOG.txt images/*.jpg images/*.png firmware/*/*.firmware ${SCRIPTS}
PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli config debug platform ${addprefix platform/,esb sky jcreate sentillausb z1 tyndall ti wismote} plugin profiler emulink net ui util extutil/highlight extutil/jfreechart}
PACKAGES := se/sics/mspsim ${addprefix se/sics/mspsim/,core chip cli config debug platform ${addprefix platform/,esb sky jcreate sentillausb z1 tyndall ti wismote lcd122dip} plugin profiler emulink net ui util extutil/highlight extutil/jfreechart}
SOURCES := ${wildcard *.java $(addsuffix /*.java,$(PACKAGES))}
@ -110,6 +112,9 @@ $(JARFILE): $(OBJECTS)
$(JAR) cfm $(JARFILE) JarManifest.txt images/*.jpg -C $(BUILD) .
-@$(RM) JarManifest.txt
%.lcd122dip: jar
java -jar $(JARFILE) -platform=lcd122dip $@ $(ARGS)
%.esb: jar
java -jar $(JARFILE) -platform=esb $@ $(ARGS)
@ -145,16 +150,22 @@ runskyprof: compile
runtelos: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.sky.TelosNode $(SKYFIRMWARE) $(MAPARGS) $(ARGS)
runz1: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.z1.Z1Node $(Z1FIRMWARE) $(MAPARGS) $(ARGS)
runtyndall: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.tyndall.TyndallNode $(TYNDALLFIRMWARE) $(MAPARGS) $(ARGS)
runwismote: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.wismote.WismoteNode $(WISMOTEFIRMWARE) $(MAPARGS) $(ARGS)
runexp5438: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.ti.Exp5438Node $(EXP5438FIRMWARE) $(MAPARGS) $(ARGS)
runlcd122dip: compile
$(JAVA) $(JAVAARGS) se.sics.mspsim.platform.lcd122dip.LCD122DIPNode $(LCD122DIPFIRMWARE) $(MAPARGS) $(ARGS)
test: cputest
cputest: $(CPUTEST)

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

View File

@ -0,0 +1,174 @@
/**
* Copyright (c) 2014, 3B Scientific GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of MSPSim.
*
* -----------------------------------------------------------------
*
* Author: Björn Rennfanz <bjoern.rennfanz@3bscientific.com>
*
*/
package se.sics.mspsim.chip;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.util.ArrayList;
import se.sics.mspsim.core.Chip;
import se.sics.mspsim.core.IOPort;
import se.sics.mspsim.core.MSP430Core;
public class EA122DIP extends Chip implements PT6520Listener
{
// Controllers
private PT6520 pt6520Left;
private PT6520 pt6520Right;
// Listeners
private ArrayList<EA122DIPListener> displayListeners = new ArrayList<EA122DIPListener>();
/**
* Construct a EA122DIP emulated display
*/
public EA122DIP(MSP430Core cpu, Rectangle position)
{
super("EA122DIP", cpu);
// Create controller for left side
pt6520Left = new PT6520("PT6520Left", cpu, new Rectangle(position.x, position.y, position.width / 2, position.height));
pt6520Left.addListener(this);
// Create controller for right side
pt6520Right = new PT6520("PT6520Right", cpu, new Rectangle(position.x + (position.width / 2), position.y, position.width / 2, position.height));
pt6520Right.addListener(this);
}
public void addListener(EA122DIPListener newListener)
{
// Add to collection
displayListeners.add(newListener);
}
public void removeListener(EA122DIPListener oldListener)
{
// Remove from collection
displayListeners.remove(oldListener);
}
/**
* Notify about display change
*/
private void notifyListener()
{
// Iterate through all listeners
for (EA122DIPListener listener : displayListeners)
{
// Notify for display change
listener.displayChanged();
}
}
/**
* Set data port
*/
public void setDataPort(IOPort port)
{
// Setup controller ports
pt6520Left.setDataPort(port);
pt6520Right.setDataPort(port);
}
/**
* Set read and write pin
*/
public void setReadWritePin(IOPort port, int pin)
{
// Setup controller ports
pt6520Left.setReadWritePin(port, pin);
pt6520Right.setReadWritePin(port, pin);
}
/**
* Set command pin
*/
public void setCommandPin(IOPort port, int pin)
{
// Setup controller ports
pt6520Left.setCommandPin(port, pin);
pt6520Right.setCommandPin(port, pin);
}
/**
* Set controller one enable pin
*/
public void setEnableLeftPin(IOPort port, int pin)
{
// Setup controller ports
pt6520Left.setEnablePin(port, pin);
}
/**
* Set controller two enable pin
*/
public void setEnableRightPin(IOPort port, int pin)
{
// Setup controller ports
pt6520Right.setEnablePin(port, pin);
}
@Override
public int getConfiguration(int parameter)
{
// TODO Auto-generated method stub
return 0;
}
@Override
public int getModeMax()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public void displayChanged()
{
// Notify display has changed
notifyListener();
}
/**
* Draws buffer image to given graphics
*/
public void drawDisplay(Graphics g)
{
// Get display from controllers
pt6520Left.drawDisplay(g);
pt6520Right.drawDisplay(g);
}
}

View File

@ -0,0 +1,44 @@
/**
* Copyright (c) 2014, 3B Scientific GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of MSPSim.
*
* -----------------------------------------------------------------
*
* Author: Björn Rennfanz <bjoern.rennfanz@3bscientific.com>
*
*/
package se.sics.mspsim.chip;
public interface EA122DIPListener
{
/**
* Notify listener that display has changed
*/
public void displayChanged();
}

View File

@ -0,0 +1,142 @@
/**
* Copyright (c) 2014, 3B Scientific GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of MSPSim.
*
* -----------------------------------------------------------------
*
* Author: Björn Rennfanz <bjoern.rennfanz@3bscientific.com>
*
*/
package se.sics.mspsim.chip;
import se.sics.mspsim.core.EmulationLogger.WarningType;
import se.sics.mspsim.core.IOPort;
import se.sics.mspsim.core.MSP430Core;
import se.sics.mspsim.core.PortListener;
import se.sics.mspsim.core.TimeEvent;
public class LatchButton extends Button implements PortListener
{
// The Operation modes of the beeper
public static final int MODE_LATCH_OFF = 0;
public static final int MODE_LATCH_ON = 1;
private static final int MODE_MAX = MODE_LATCH_ON;
// Private members
private boolean latchEnabled;
private IOPort latchPort;
private int latchPin;
private boolean pressReleaseSchedule;
private Button that = this;
private MSP430Core cpu;
private TimeEvent pressRelease = new TimeEvent(0, "LatchButton Release Event")
{
// Event handler to release button
public void execute(long t)
{
// Call super class
that.setPressed(false);
// Reset event flag
pressReleaseSchedule = false;
}
};
public LatchButton(String id, MSP430Core cpu, IOPort buttonPort, int buttonPin, IOPort latchPort, int latchEnablePin, boolean polarity)
{
// Call super class constructor
super(id, cpu, buttonPort, buttonPin, polarity);
setMode(MODE_LATCH_OFF);
// Save members
this.latchPin = latchEnablePin;
this.latchPort = latchPort;
this.cpu = cpu;
// Attach event listener
this.latchPort.addPortListener(this);
// Release event
pressReleaseSchedule = false;
}
@Override
public int getModeMax()
{
return MODE_MAX;
}
/**
* {@inheritDoc}
*/
@Override
public void portWrite(IOPort source, int data)
{
// Check if source matches latch port
if (source == latchPort)
{
// Latch is active low
if ((data & (1 << latchPin)) == 0)
{
// Latch enableds
latchEnabled = true;
// Set mode to latch enabled
setMode(MODE_LATCH_ON);
}
else
{
// Latch disabled
latchEnabled = false;
// Set mode to latch enabled
setMode(MODE_LATCH_OFF);
}
}
}
/**
* {@inheritDoc}
*/
@Override
public void setPressed(boolean isPressed)
{
if ((latchEnabled) && (isPressed) && (!pressReleaseSchedule))
{
// Call super class
super.setPressed(true);
// Set flags and schedule release event
cpu.scheduleTimeEventMillis(pressRelease, 200.0);
pressReleaseSchedule = true;
}
}
}

View File

@ -0,0 +1,386 @@
/**
* Copyright (c) 2014, 3B Scientific GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of MSPSim.
*
* -----------------------------------------------------------------
*
* Author: Björn Rennfanz <bjoern.rennfanz@3bscientific.com>
*
*/
package se.sics.mspsim.chip;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import se.sics.mspsim.core.Chip;
import se.sics.mspsim.core.IOPort;
import se.sics.mspsim.core.MSP430Core;
import se.sics.mspsim.core.PortListener;
public class PT6520 extends Chip implements PortListener
{
// Private constants
private static final int DISPLAY_WIDTH = 61;
private static final int DISPLAY_HEIGHT = 32;
private static final int DISPLAY_LINES_PER_PAGE = 8;
private static final int DISPLAY_PAGES = DISPLAY_HEIGHT / DISPLAY_LINES_PER_PAGE;
private static final int DISPLAY_MAX_COLUMN = 79;
private static final int DISPLAY_NORMAL_STATUS = 0x00;
private static final int DISPLAY_BIT7 = 7;
private static final int DISPLAY_CMD_SETPAGE = 0xB8;
private static final int DISPLAY_CMD_SETPAGE_MASK = 0xFC;
private static final int DISPLAY_CMD_STARTLINE = 0xC0;
private static final int DISPLAY_CMD_STARTLINE_MASK = 0xE0;
private static final int DISPLAY_CMD_ON = 0xAF;
private static final int DISPLAY_CMD_OFF = 0xAE;
private static final int DISPLAY_RGB_OFF = 0x40ff40;
private static final int DISPLAY_RGB_ON = 0x000000;
// Display buffers
private int[][] displayMemory;
private boolean displayMemorySet;
private BufferedImage displayImage;
private Rectangle displayPosition;
// Listener
private ArrayList<PT6520Listener> displayListeners = new ArrayList<PT6520Listener>();
// Logic
private int selectedPage;
private int selectedColumn;
private int selectedStartLine;
// Data
private IOPort dataPort;
private int data;
// Enable pin
private IOPort enablePort;
private int enablePin;
// Command pin
private IOPort commandPort;
private int commandPin;
private boolean commandEnable;
// Read or write pin
private IOPort readWritePort;
private int readWritePin;
private boolean readEnable;
/**
* Construct a PT6520 emulated display
*/
public PT6520(String id, MSP430Core cpu, Rectangle position)
{
super(id, cpu);
// Initialize display memory and image
displayMemory = new int[DISPLAY_PAGES][DISPLAY_MAX_COLUMN + 1];
displayImage = new BufferedImage(DISPLAY_WIDTH, DISPLAY_HEIGHT, BufferedImage.TYPE_INT_RGB);
refreshDisplay();
// Remember position
displayPosition = position;
}
public void addListener(PT6520Listener newListener)
{
// Add to collection
displayListeners.add(newListener);
}
public void removeListener(PT6520Listener oldListener)
{
// Remove from collection
displayListeners.remove(oldListener);
}
/**
* Notify about display change
*/
private void notifyListener()
{
// Iterate through all listeners
for (PT6520Listener listener : displayListeners)
{
// Notify for display change
listener.displayChanged();
}
}
@Override
public int getConfiguration(int parameter)
{
return 0;
}
@Override
public int getModeMax()
{
return 0;
}
/**
* Set data port of display controller
*/
public void setDataPort(IOPort port)
{
// Save reference
this.dataPort = port;
// Setup listener
this.dataPort.addPortListener(this);
}
/**
* Set enable pin of display controller
*/
public void setEnablePin(IOPort port, int pin)
{
// Save reference
this.enablePort = port;
this.enablePin = pin;
// Setup listener
this.enablePort.addPortListener(this);
}
/**
* Set command pin of display controller
*/
public void setCommandPin(IOPort port, int pin)
{
// Save reference
this.commandPort = port;
this.commandPin = pin;
// Setup listener
this.commandPort.addPortListener(this);
}
/**
* Set read/write pin of display controller
*/
public void setReadWritePin(IOPort port, int pin)
{
// Save reference
this.readWritePort = port;
this.readWritePin = pin;
// Setup listener
this.readWritePort.addPortListener(this);
}
@Override
public void portWrite(IOPort source, int data)
{
// Check if data was set
if (source == dataPort)
{
// Save data
this.data = data;
}
// Check if command was set
if (source == commandPort)
{
// Save command enable flag
commandEnable = ((data & (1 << commandPin)) == 0);
}
// Check if read or write was set
if (source == readWritePort)
{
// Save read / write flag
readEnable = ((data & (1 << readWritePin)) != 0);
}
// Check if enable is set
if (source == enablePort)
{
// Check if enable pin is set
if ((data & (1 << enablePin)) != 0)
{
// Check if we in command mode
if (commandEnable)
{
// Check read status
if (readEnable)
{
// Write normal status to pin
setPortData(dataPort, DISPLAY_NORMAL_STATUS);
}
else
{
// Check for display commands
if ((this.data & (1 << DISPLAY_BIT7)) != 0)
{
if (this.data == DISPLAY_CMD_ON)
{
// Log display power on
log("Display power on command.");
}
else
{
if (this.data == DISPLAY_CMD_OFF)
{
// Log display power on
log("Display power off command.");
}
else
{
if ((this.data & DISPLAY_CMD_STARTLINE_MASK) == DISPLAY_CMD_STARTLINE)
{
// Save selected start line
selectedStartLine = (this.data & ~DISPLAY_CMD_STARTLINE_MASK);
}
else
{
if ((this.data & DISPLAY_CMD_SETPAGE_MASK) == DISPLAY_CMD_SETPAGE)
{
// Save selected page
selectedPage = (this.data & ~DISPLAY_CMD_SETPAGE_MASK);
}
else
{
// Log not supported command
log("Not supported command 0x" + Integer.toHexString(data));
}
}
}
}
}
else
{
// Save selected column
selectedColumn = (this.data & 0x7F);
}
}
}
else
{
// Check read status
if (readEnable)
{
// Write data to port
setPortData(dataPort, displayMemory[selectedPage][selectedColumn]);
}
else
{
// Save data to display memory and refresh
displayMemory[selectedPage][selectedColumn] = this.data;
displayMemorySet = true;
}
}
}
else
{
// Check if display data was set
if (displayMemorySet)
{
// Refresh display
refreshDisplay();
// Set display data set flag
displayMemorySet = false;
// Increment column counter.
selectedColumn = Math.min(selectedColumn + 1, DISPLAY_MAX_COLUMN);
}
}
}
}
/**
* Set bitmask to given IOPort
*/
private void setPortData(IOPort port, int data)
{
// Set each bit on given port
for (int pin = 0; pin < 8; pin++)
{
// Set pin status from bitmask
port.setPinState(pin, ((data & (1 << pin)) != 0) ? IOPort.PinState.HI : IOPort.PinState.LOW);
}
}
/**
* Refresh buffer bitmap from memory
*/
private void refreshDisplay()
{
// Redraw display memory
for (int page = 0; page < DISPLAY_PAGES; page++)
{
for (int x = 0; x < DISPLAY_WIDTH; x++)
{
for (int y = 0; y < DISPLAY_LINES_PER_PAGE; y++)
{
int currentLine = (y + (page * DISPLAY_LINES_PER_PAGE));
if (currentLine < selectedStartLine)
{
// Draw blank display
displayImage.setRGB(x, currentLine, DISPLAY_RGB_OFF);
}
else
{
// Draw content of memory
displayImage.setRGB(x, currentLine, (((displayMemory[page][x] & (1 << y)) != 0) ? DISPLAY_RGB_ON : DISPLAY_RGB_OFF));
}
}
}
}
// Notify listeners
notifyListener();
}
/**
* Draws buffer image to given graphics
*/
public void drawDisplay(Graphics g)
{
// Draw to graphics with scaling
g.drawImage(displayImage, displayPosition.x + displayPosition.width, displayPosition.y + displayPosition.height, displayPosition.x, displayPosition.y, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, null);
}
}

View File

@ -0,0 +1,44 @@
/**
* Copyright (c) 2014, 3B Scientific GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of MSPSim.
*
* -----------------------------------------------------------------
*
* Author: Björn Rennfanz <bjoern.rennfanz@3bscientific.com>
*
*/
package se.sics.mspsim.chip;
public interface PT6520Listener
{
/**
* Notify listener that display has changed
*/
public void displayChanged();
}

View File

@ -0,0 +1,89 @@
/**
* Copyright (c) 2014, 3B Scientific GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of MSPSim.
*
* -----------------------------------------------------------------
*
* Author: Björn Rennfanz <bjoern.rennfanz@3bscientific.com>
*
*/
package se.sics.mspsim.platform.lcd122dip;
import java.awt.Color;
import java.awt.Graphics;
import se.sics.mspsim.platform.AbstractNodeGUI;
public class LCD122DIPGui extends AbstractNodeGUI {
// Private final statics
private static final long serialVersionUID = 2884239980128494468L;
// Private members
private final LCD122DIPNode node;
/**
* Construct an NETlog GUI
*/
public LCD122DIPGui(LCD122DIPNode node)
{
super("EA122DIP", "images/msp430f149-lcd122dip.jpg");
this.node = node;
}
/**
* {@inheritDoc}
*/
@Override
protected void startGUI()
{
}
/**
* {@inheritDoc}
*/
@Override
protected void stopGUI()
{
}
@Override
protected void paintComponent(Graphics g)
{
// Get draw color
Color old = g.getColor();
super.paintComponent(g);
// Draw LCD content
node.getLcd().drawDisplay(g);
// Restore draw color
g.setColor(old);
}
}

View File

@ -0,0 +1,169 @@
/**
* Copyright (c) 2014, 3B Scientific GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of MSPSim.
*
* -----------------------------------------------------------------
*
* Author: Björn Rennfanz <bjoern.rennfanz@3bscientific.com>
*
*/
package se.sics.mspsim.platform.lcd122dip;
import java.awt.Rectangle;
import java.io.IOException;
import se.sics.mspsim.chip.EA122DIP;
import se.sics.mspsim.chip.EA122DIPListener;
import se.sics.mspsim.config.MSP430f149Config;
import se.sics.mspsim.core.IOPort;
import se.sics.mspsim.core.MSP430;
import se.sics.mspsim.core.USART;
import se.sics.mspsim.extutil.jfreechart.DataChart;
import se.sics.mspsim.extutil.jfreechart.DataSourceSampler;
import se.sics.mspsim.platform.GenericNode;
import se.sics.mspsim.ui.SerialMon;
import se.sics.mspsim.util.ArgumentManager;
public class LCD122DIPNode extends GenericNode implements EA122DIPListener
{
// Port 1
private static final int DISPLAY_E0_PIN = 7;
private static final int DISPLAY_E1_PIN = 5;
// Port 6
private static final int DISPLAY_RW_PIN = 4;
private static final int DISPLAY_CMD_PIN = 6;
// Private hardware members
private EA122DIP ea122dip;
// Private cpu members
private IOPort port1;
private IOPort port2;
private IOPort port6;
// AWT gui
private LCD122DIPGui gui;
// Public getters
public EA122DIP getLcd()
{
return ea122dip;
}
public LCD122DIPNode()
{
super("LCD122DIP", new MSP430f149Config());
}
public void setupNodePorts()
{
// Setup ports
port1 = cpu.getIOUnit(IOPort.class, "P1");
port2 = cpu.getIOUnit(IOPort.class, "P2");
port6 = cpu.getIOUnit(IOPort.class, "P6");
// Setup display
ea122dip = new EA122DIP(cpu, new Rectangle(125, 140, 950, 230));
ea122dip.addListener(this);
// Setup display ports
ea122dip.setDataPort(port2);
ea122dip.setCommandPin(port6, DISPLAY_CMD_PIN);
ea122dip.setReadWritePin(port6, DISPLAY_RW_PIN);
ea122dip.setEnableLeftPin(port1, DISPLAY_E1_PIN);
ea122dip.setEnableRightPin(port1, DISPLAY_E0_PIN);
}
@Override
public void setupNode()
{
setupNodePorts();
if (stats != null) {
stats.addMonitor(this);
stats.addMonitor(cpu);
}
// Check if gui is enabled
if (!config.getPropertyAsBoolean("nogui", true))
{
setupGUI();
// Add some windows for listening to serial output
USART usart = cpu.getIOUnit(USART.class, "USART1");
if (usart != null)
{
SerialMon serial = new SerialMon(usart, "USART1 Port Output");
registry.registerComponent("serialgui", serial);
}
if (stats != null)
{
// A HACK for some "graphs"!!!
DataChart dataChart = new DataChart(registry, "Duty Cycle", "Duty Cycle");
registry.registerComponent("dutychart", dataChart);
DataSourceSampler dss = dataChart.setupChipFrame(cpu);
dataChart.addDataSource(dss, "CPU", stats.getDataSource(cpu.getID(), MSP430.MODE_ACTIVE));
}
}
}
public void setupGUI()
{
if (gui == null)
{
gui = new LCD122DIPGui(this);
registry.registerComponent("nodegui", gui);
}
}
public static void main(String[] args) throws IOException
{
LCD122DIPNode node = new LCD122DIPNode();
ArgumentManager config = new ArgumentManager();
config.handleArguments(args);
node.setupArgs(config);
}
@Override
public void displayChanged()
{
// Repaint in maximum of 20ms
gui.repaint(20);
}
@Override
public int getModeMax()
{
return 0;
}
}