|
Message
From: cvs at opencores.org<cvs@o...>
Date: Tue Jun 5 17:36:37 CEST 2007
Subject: [cvs-checkins] MODIFIED: jop ...
Date: 00/07/06 05:17:36 Added: jop/java/target/src/app/lego/lib Buttons.java DigitalInputs.java FutureUse.java Leds.java Microphone.java Motor.java Sensors.java Speaker.java package.html Log: Adding the Lego Java Programs Revision Changes Path 1.3 jop/java/target/src/app/lego/lib/Buttons.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/app/lego/lib/Buttons.java.diff?r1=1.2&r2=1.3 (In the diff below, changes in quantity of whitespace are not shown.) Index: Buttons.java =================================================================== RCS file: Buttons.java diff -N Buttons.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Buttons.java 5 Jun 2007 15:36:37 -0000 1.3 @@ -0,0 +1,34 @@ +package lego.lib; + +import com.jopdesign.sys.*; + +/** + * Provides button states (BTN0-BTN3). + * @author Peter Hilber (peter.hilber@s...) + * + */ +public class Buttons +{ + public static final int IO_BUTTONS = Const.IO_LEGO + 4; + + /** + * Reads whether button is depressed. + * @param index Valid indices are 0, 1, 2, 3. + */ + public static boolean getButton(int index) + { + //if (index<0 || index>3) + // throw new RuntimeException("Invalid button index specified!"); + return ((Native.rd(IO_BUTTONS) >> index) & 1) != 0; + } + + /** + * Reads all button states into the respective bits. + * @return The buttons are numbered from 0 to 3. + * All other bits are set to zero. + */ + public static int getButtons() + { + return Native.rd(IO_BUTTONS); + } +} 1.3 jop/java/target/src/app/lego/lib/DigitalInputs.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/app/lego/lib/DigitalInputs.java.diff?r1=1.2&r2=1.3 (In the diff below, changes in quantity of whitespace are not shown.) Index: DigitalInputs.java =================================================================== RCS file: DigitalInputs.java diff -N DigitalInputs.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ DigitalInputs.java 5 Jun 2007 15:36:37 -0000 1.3 @@ -0,0 +1,34 @@ +package lego.lib; + +import com.jopdesign.sys.*; + +/** + * Provides access to general purpose digital inputs (I0-I2). + * @author Peter Hilber (peter.hilber@s...) + * + */ +public class DigitalInputs +{ + public static final int IO_DIGITALINPUTS = Const.IO_LEGO + 5; + + /** + * Read digital input. + * @param index Valid indices are 0, 1, 2. + */ + public static boolean getDigitalInput(int index) + { + //if (index<0 || index>3) + // throw new RuntimeException("Invalid button index specified!"); + return ((Native.rd(IO_DIGITALINPUTS) >> index) & 1) != 0; + } + + /** + * Reads all digital inputs into the respective bits. + * @return The digital inputs are numbered from 0 to 2. + * All other bits are set to zero. + */
+ public static int getDigitalInputs()
+ {
+ return Native.rd(IO_DIGITALINPUTS);
+ }
+}
1.3 jop/java/target/src/app/lego/lib/FutureUse.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/app/lego/lib/FutureUse.java.diff?r1=1.2&r2=1.3
(In the diff below, changes in quantity of whitespace are not shown.)
Index: FutureUse.java
===================================================================
RCS file: FutureUse.java
diff -N FutureUse.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ FutureUse.java 5 Jun 2007 15:36:37 -0000 1.3
@@ -0,0 +1,36 @@
+package lego.lib;
+
+import com.jopdesign.sys.*;
+
+/**
+ * Provides access to as yet unused pins connected to the JOP through
+ * the PLD (IN0-IN9). XXX name
+ * Depending whether they are configured as input or output in
+ * lego_pld_pack.vhd, they can be read or written.
+ * When writing or reading to a pin configured for the opposite use,
+ * nothing will happen.
+ * @author Peter Hilber (peter.hilber@s...)
+ *
+ */
+public class FutureUse
+{
+ public static final int IO_FUTUREUSE = Const.IO_LEGO + 6;
+
+ /**
+ * Returns the unused pins IN0-IN9 of the PLD in the corresponding bits.
+ * Pins configured as output are read as 0.
+ */
+ public static int readPins()
+ {
+ return Native.rd(IO_FUTUREUSE);
+ }
+
+ /**
+ * Writes the corresponding bits to the unused pins IN0-IN9 of the PLD.
+ * Pins configured as input are unaffected.
+ */
+ public static void writePins(int value)
+ {
+ Native.wr(value, IO_FUTUREUSE);
+ }
+}
1.3 jop/java/target/src/app/lego/lib/Leds.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/app/lego/lib/Leds.java.diff?r1=1.2&r2=1.3
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Leds.java
===================================================================
RCS file: Leds.java
diff -N Leds.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Leds.java 5 Jun 2007 15:36:37 -0000 1.3
@@ -0,0 +1,63 @@
+package lego.lib;
+
+import com.jopdesign.sys.*;
+
+/**
+ * Provides access to diagnostic LEDs (LED0-LED3).
+ * @author Peter Hilber (peter.hilber@s...)
+ *
+ */
+public class Leds
+{
+ public static final int IO_LEDS = Const.IO_LEGO + 0;
+ protected static int value;
+
+ /**
+ * Turns the LED on and off several times a second (if called that often).
+ * @param index 0-3.
+ */
+ public static final void blinkUpdate(int index)
+ {
+ setLed(index, (Native.rd(Const.IO_US_CNT) & 0x40000) != 0);
+ }
+
+ /**
+ * Sets diagnostic LEDs.
+ * @param state LEDs 0-3 state is set by the corresponding bits.
+ * All other bits are ignored.
+ */
+ public static final void setLeds(int state)
+ {
+ value = state;
+ Native.wr(state, IO_LEDS);
+ }
+
+ /**
+ * Returns the state of the diagnostic LEDs.
+ * @return State of the LEDs 0-3 in the corresponding bit.
+ * All other bits are set to zero.
+ */
+ public static final int getLeds()
+ {
+ return value;
+ }
+
+ /**
+ * Returns the state of a diagnostic LED.
+ * @param index 0-3.
+ */
+ public static final boolean getLed(int index)
+ {
+ return ((value >> index) & 1) != 0;
+ }
+
+ /**
+ * Sets the state of a diagnostic LED.
+ * @param index 0-3.
+ * @param on
+ */
+ public static final void setLed(int index, boolean on)
+ {
+ setLeds((getLeds() & ~(1<<index)) | ((on?1:0)<<index));
+ }
+}
1.3 jop/java/target/src/app/lego/lib/Microphone.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/app/lego/lib/Microphone.java.diff?r1=1.2&r2=1.3
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Microphone.java
===================================================================
RCS file: Microphone.java
diff -N Microphone.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Microphone.java 5 Jun 2007 15:36:37 -0000 1.3
@@ -0,0 +1,24 @@
+package lego.lib;
+
+import com.jopdesign.sys.*;
+
+/**
+ * Provides access to microphone ADC input (MIC1).
+ * @author Peter Hilber (peter.hilber@s...)
+ *
+ */
+public class Microphone
+{
+ //public static final int IO_MICROPHONE = Const.IO_MICRO;
+ public static final int IO_MICROPHONE = Const.IO_LEGO + 1;
+
+ /**
+ * Returns the value last read from the microphone.
+ * @return 9 bit ADC value.
+ * XXX Expected value range.
+ */
+ public static int readMicrophone()
+ {
+ return Native.rd(IO_MICROPHONE);
+ }
+}
1.3 jop/java/target/src/app/lego/lib/Motor.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/app/lego/lib/Motor.java.diff?r1=1.2&r2=1.3
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Motor.java
===================================================================
RCS file: Motor.java
diff -N Motor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Motor.java 5 Jun 2007 15:36:37 -0000 1.3
@@ -0,0 +1,285 @@
+package lego.lib;
+
+import com.jopdesign.sys.*;
+
+/**
+ * Motor steering (Motor 0-2) and back-EMF motor speed measurement
+ * (only Motor 0-1 due to pin constraints).
+ * @author Peter Hilber (peter.hilber@s...)
+ */
+public class Motor {
+
+ public static final int[] IO_OUTPUT_MOTOR =
+ { Const.IO_LEGO+1, Const.IO_LEGO+2, Const.IO_LEGO+3 };
+
+ public static final int[] IO_INPUT_MOTOR =
+ { Const.IO_LEGO+2, Const.IO_LEGO+3 };
+
+ public static final int[] IO_SYNCHRONIZED_INPUT_MOTOR =
+ { Const.IO_LEGO+8, Const.IO_LEGO+9 };
+
+ /**
+ * Motor turned off.
+ */
+ public static final int STATE_OFF = 0;
+ /**
+ * Motor turns "forward".
+ */
+ public static final int STATE_FORWARD = 1;
+ /**
+ * Motor turns "backward".
+ */
+ public static final int STATE_BACKWARD = 2;
+ /**
+ * Brakes the motor.
+ */
+ public static final int STATE_BRAKE = 3;
+
+ protected static final int MASK_STATE = 0x3;
+ protected static final int MASK_DUTYCYCLE = 0x3FFF;
+ protected static final int MASK_MEASURE = 0x1;
+
+ protected static final int OFFSET_DUTYCYCLE = 2;
+ protected static final int OFFSET_MEASURE = 2 + 14;
+
+ protected static final int OFFSET_BACKEMF1 = 9;
+ protected static final int MASK_BACKEMF = 0x1ff;
+
+ protected static int[] readValue = new int[2];
+ protected static int[] writeValue = new int[3];
+
+ /**
+ * Index of the Motor this instance steers.
+ */
+ protected int index;
+
+ /**
+ * Maximum duty cycle value.
+ */
+ public static final int MAX_DUTYCYCLE = MASK_DUTYCYCLE;
+
+ protected static final int DUTYCYCLE_PERCENTAGE_FACTOR = (MAX_DUTYCYCLE * 65536) / 100;
+ protected static final int DUTYCYCLE_PERCENTAGE_SHIFT = 16;
+
+ /**
+ * Back-EMF value expected to be measured when motor is idle.
+ */
+ public static final int BACKEMF_IDLE_VALUE = 0x100;
+
+ /**
+ * Index of the Motor this instance steers.
+ * @return 0-2.
+ */
+ public int getIndex()
+ {
+ return index;
+ }
+
+ /**
+ *
+ * @param index 0-2.
+ * @param state {@linkplain #STATE_OFF}, {@linkplain #STATE_FORWARD}, {@linkplain #STATE_BACKWARD} or {@linkplain #STATE_BRAKE}.
+ * @param measure When true, back-EMF measurement is made when running forward or backward.
+ * This necessitates to stop the motor for short times (which is also made for motors without
+ * back-EMF measurement capability).
+ * @param dutyCycle 0-{@linkplain #MAX_DUTYCYCLE}.
+ */
+ public static void setMotor(int index, int state, boolean measure, int dutyCycle)
+ {
+ Native.wr((state & MASK_STATE) | ((dutyCycle & MASK_DUTYCYCLE) << OFFSET_DUTYCYCLE) | (((measure?1:0) & MASK_MEASURE) << OFFSET_MEASURE), IO_OUTPUT_MOTOR[index]);
+ }
+
+ /**
+ *
+ * @param index 0-2.
+ * @param state {@linkplain #STATE_OFF}, {@linkplain #STATE_FORWARD}, {@linkplain #STATE_BACKWARD} or {@linkplain #STATE_BRAKE}.
+ * @param measure When true, back-EMF measurement is made when running forward or backward.
+ * This necessitates to stop the motor for short times (which is also made for motors without
+ * back-EMF measurement capability).
+ * @param percentage Overshooting is handled.
+ */
+ public static void setMotorPercentage(int index, int state, boolean measure, int percentage)
+ {
+ Native.wr((state & MASK_STATE) | ((dutyCyclePercentageToDutyCycle(percentage) & MASK_DUTYCYCLE) << OFFSET_DUTYCYCLE) | (((measure?1:0) & MASK_MEASURE) << OFFSET_MEASURE), IO_OUTPUT_MOTOR[index]);
+ }
+
+ /**
+ *
+ * @param index Index of the Motor this instance steers (0-2).
+ */
+ public Motor(int index)
+ {
+ this.index = index;
+ }
+
+ /**
+ *
+ * @param state {@linkplain #STATE_OFF}, {@linkplain #STATE_FORWARD}, {@linkplain #STATE_BACKWARD} or {@linkplain #STATE_BRAKE}.
+ * @param measure When true, back-EMF measurement is made when running forward or backward.
+ * This necessitates to stop the motor for short times (which is also made for motors without
+ * back-EMF measurement capability).
+ * @param dutyCycle 0-{@linkplain #MAX_DUTYCYCLE}.
+ */
+ public void setMotor(int state, boolean measure, int dutyCycle)
+ {
+ writeValue[index] = (state & MASK_STATE) | ((dutyCycle & MASK_DUTYCYCLE) << OFFSET_DUTYCYCLE) | (((measure?1:0) & MASK_MEASURE) << OFFSET_MEASURE);
+ Native.wr(writeValue[index], IO_OUTPUT_MOTOR[index]);
+ }
+
+ /**
+ *
+ * @param state {@linkplain #STATE_OFF}, {@linkplain #STATE_FORWARD}, {@linkplain #STATE_BACKWARD} or {@linkplain #STATE_BRAKE}.
+ * @param measure When true, back-EMF measurement is made when running forward or backward.
+ * This necessitates to stop the motor for short times (which is also made for motors without
+ * back-EMF measurement capability).
+ * @param percentage Overshooting is handled.
+ */
+ public void setMotorPercentage(int state, boolean measure, int percentage)
+ {
+ writeValue[index] = (state & MASK_STATE) | ((dutyCyclePercentageToDutyCycle(percentage) & MASK_DUTYCYCLE) << OFFSET_DUTYCYCLE) | (((measure?1:0) & MASK_MEASURE) << OFFSET_MEASURE);
+ Native.wr(writeValue[index], IO_OUTPUT_MOTOR[index]);
+ }
+
+ /**
+ *
+ * @param state {@linkplain #STATE_OFF}, {@linkplain #STATE_FORWARD}, {@linkplain #STATE_BACKWARD} or {@linkplain #STATE_BRAKE}.
+ */
+ public void setState(int state)
+ {
+ writeValue[index] = (state & MASK_STATE) | (writeValue[index] & ~MASK_STATE);
+ Native.wr(writeValue[index], IO_OUTPUT_MOTOR[index]);
+ }
+
+ /**
+ *
+ * @param dutyCycle 0-{@linkplain #MAX_DUTYCYCLE}.
+ */
+ public void setDutyCycle(int dutyCycle)
+ {
+ writeValue[index] = ((dutyCycle & MASK_DUTYCYCLE) << OFFSET_DUTYCYCLE) | (writeValue[index] & ~(MASK_DUTYCYCLE << OFFSET_DUTYCYCLE));
+ Native.wr(writeValue[index], IO_OUTPUT_MOTOR[index]);
+ }
+
+ /**
+ *
+ * @param percentage Overshooting is handled.
+ * @return Duty cycle value between 0 and {@linkplain #MAX_DUTYCYCLE}.
+ */
+ public static int dutyCyclePercentageToDutyCycle(int percentage)
+ {
+ return ((Math.max(0, Math.min(percentage, 100)) * DUTYCYCLE_PERCENTAGE_FACTOR) >> DUTYCYCLE_PERCENTAGE_SHIFT);
+ }
+
+ /**
+ *
+ * @param percentage Overshooting is handled.
+ */
+ public void setDutyCyclePercentage(int percentage)
+ {
+ setDutyCycle(dutyCyclePercentageToDutyCycle(percentage));
+ }
+
+ /**
+ * @param measure When true, back-EMF measurement is made when running forward or backward.
+ * This necessitates to stop the motor for short times (which is also made for motors without
+ * back-EMF measurement capability).
+ */
+ public void setMeasure(boolean measure)
+ {
+ writeValue[index] = (((measure?1:0) & MASK_MEASURE) << OFFSET_MEASURE) | (writeValue[index] & ~(MASK_MEASURE << OFFSET_MEASURE));
+ Native.wr(writeValue[index], IO_OUTPUT_MOTOR[index]);
+ }
+
+ /**
+ *
+ * @return 0-{@linkplain #MAX_DUTYCYCLE}.
+ */
+ public int getDutyCycle()
+ {
+ return (writeValue[index] >> OFFSET_DUTYCYCLE) & MASK_DUTYCYCLE;
+ }
+
+ /**
+ *
+ * @return When true, back-EMF measurement is made when running forward or backward.
+ * This necessitates to stop the motor for short times (which is also made for motors without
+ * back-EMF measurement capability).
+ */
+ public boolean getMeasure()
+ {
+ return ((writeValue[index] >> OFFSET_MEASURE) & MASK_MEASURE) != 0;
+ }
+
+ /**
+ *
+ * @return {@linkplain #STATE_OFF}, {@linkplain #STATE_FORWARD}, {@linkplain #STATE_BACKWARD} or {@linkplain #STATE_BRAKE}.
+ */
+ public int getState()
+ {
+ return ((writeValue[index]) & MASK_STATE);
+ }
+
+ /**
+ * Reads and returns the raw back-EMF values last measured by the ADC.
+ * Reading back-EMF values is only supported for Motor 0 and Motor 1.
+ * @return 9 bit ADC value. XXX typical range
+ */
+ public int[] readBackEMF()
+ {
+ int value = Native.rd(IO_INPUT_MOTOR[index]);
+ return new int[] { value & MASK_BACKEMF, (value >> OFFSET_BACKEMF1) & MASK_BACKEMF };
+ }
+
+ /**
+ * Reads and returns the back-EMF values last measured by the ADC.
+ * Reading back-EMF values is only supported for Motor 0 and Motor 1.
+ * @return The values returned are the differences of the 9 bit ADC value and {@linkplain #BACKEMF_IDLE_VALUE}.
+ */
+ public int[] readNormalizedBackEMF()
+ {
+ int[] raw = readBackEMF();
+ return new int[] { raw[0]-BACKEMF_IDLE_VALUE, raw[1]-BACKEMF_IDLE_VALUE };
+ }
+
+ /**
+ * Returns the back-EMF values for the motor last read by an
+ * invocation of the class method {@linkplain #synchronizedReadBackEMF()}.
+ * Reading back-EMF values is only supported for Motor 0 and Motor 1.
+ * @return 9 bit ADC value.
+ */
+ public int[] getSynchronizedBackEMF()
+ {
+ return new int[] { readValue[index] & MASK_BACKEMF, (readValue[index] >> OFFSET_BACKEMF1) & MASK_BACKEMF };
+ }
+
+ /**
+ * Gets the back-EMF values last measured by the ADC.
+ * The Motor 0 and Motor 1 back-EMF values are guaranteed to be synchronized.
+ * <p>
+ * 9*4 bits for the 4 back-EMF values cannot be transferred in a single cycle.
+ * Therefore, the hardware won't update both values after the values for the
+ * first motor have been read until the values for the second motor have been
+ * read, too.
+ */
+ public static /*synchronized*/ void synchronizedReadBackEMF() // TODO make synchronized?
+ {
+ for (int i = 0; i < 2; i++)
+ readValue[i] = Native.rd(IO_SYNCHRONIZED_INPUT_MOTOR[i]);
+ }
+
+ /**
+ * Gets the back-EMF values last measured by the ADC.
+ * The Motor 0 and Motor 1 back-EMF values are guaranteed to be synchronized.
+ * <p>
+ * 9*4 bits for the 4 back-EMF values cannot be transferred in a single cycle.
+ * Therefore, the hardware won't update both values after the values for the
+ * first motor have been read until the values for the second motor have been
+ * read, too.
+ * @return The values returned are the differences of the 9 bit ADC value and {@linkplain #BACKEMF_IDLE_VALUE}.
+ */
+ public int[] getSynchronizedNormalizedBackEMF()
+ {
+ int[] raw = getSynchronizedBackEMF();
+ return new int[] { raw[0]-BACKEMF_IDLE_VALUE, raw[1]-BACKEMF_IDLE_VALUE };
+ }
+}
1.3 jop/java/target/src/app/lego/lib/Sensors.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/app/lego/lib/Sensors.java.diff?r1=1.2&r2=1.3
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Sensors.java
===================================================================
RCS file: Sensors.java
diff -N Sensors.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Sensors.java 5 Jun 2007 15:36:37 -0000 1.3
@@ -0,0 +1,78 @@
+package lego.lib;
+
+import com.jopdesign.sys.*;
+
+/**
+ * Provides access to sensor ADC values (sensors S0-S2).
+ * @author Peter Hilber (peter.hilber@s...)
+ *
+ */
+public class Sensors
+{
+ public static final int IO_SENSORS = Const.IO_LEGO;
+
+ /**
+ * XXX
+ */
+ public static final int MIN_VALUE = 135;
+
+ /**
+ * XXX
+ */
+ public static final int MAX_VALUE = 361;
+ public static final int VALUE_RANGE = MAX_VALUE - MIN_VALUE;
+
+ /**
+ * percentage calculation factor * 2**20
+ */
+ protected static final int PERCENTAGE_CALC_FACTOR = 463972;
+ protected static final int PERCENTAGE_CALC_FACTOR_SHIFT = 20;
+
+ protected static int value = 0;
+
+ protected static final int[] OFFSET_SENSOR = { 0, 9, 2*9 };
+ protected static final int MASK_SENSOR = 0x1FF;
+
+ /**
+ * Reads all sensor values into a buffer during the same cycle.
+ * The buffered values may be read using {@linkplain #getBufferedSensor(int)}.
+ */
+ public static void synchronizedReadSensors()
+ {
+ value = Native.rd(IO_SENSORS);
+ }
+
+ /**
+ * Return the value read from the respective sensor.
+ * @param index 0-2.
+ * @return 9 bit ADC value. Expected value range is {@linkplain #MIN_VALUE}-{@linkplain #MAX_VALUE}.
+ */
+ public static int readSensor(int index)
+ {
+
+ return (Native.rd(IO_SENSORS) >> OFFSET_SENSOR[index]) & MASK_SENSOR;
+ }
+
+ /**
+ * Return the value read from the respective sensor as a percentage value.
+ * @param index 0-2.
+ * @return 0-100.
+ * Values smaller than {@linkplain #MIN_VALUE} or greater than
+ * {@linkplain #MAX_VALUE} are cut.
+ */
+ public static int readSensorValueAsPercentage(int index)
+ {
+ //return (Math.min(Math.max(readSensor(index)-MIN_VALUE, 0), MAX_VALUE) * 100) / VALUE_RANGE;
+ return (Math.min(Math.max(readSensor(index)-MIN_VALUE, 0), MAX_VALUE) * PERCENTAGE_CALC_FACTOR) >> PERCENTAGE_CALC_FACTOR_SHIFT;
+ }
+
+ /**
+ * Returns value read by {@linkplain #synchronizedReadSensors()}
+ * @param index 0-2.
+ * @return 9 bit ADC value. Expected value range is {@linkplain #MIN_VALUE}-{@linkplain #MAX_VALUE}.
+ */
+ public static int getBufferedSensor(int index)
+ {
+ return (value >> OFFSET_SENSOR[index]) & MASK_SENSOR;
+ }
+}
1.3 jop/java/target/src/app/lego/lib/Speaker.java
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/app/lego/lib/Speaker.java.diff?r1=1.2&r2=1.3
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Speaker.java
===================================================================
RCS file: Speaker.java
diff -N Speaker.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Speaker.java 5 Jun 2007 15:36:37 -0000 1.3
@@ -0,0 +1,35 @@
+package lego.lib;
+
+import com.jopdesign.sys.*;
+
+/**
+ * Provides access to the speaker output.
+ * @author Alexander Dejaco (alexander.dejaco@s...)
+ * @author Peter Hilber (peter.hilber@s...)
+ *
+ */
+public class Speaker
+{
+ public static final int IO_SPEAKER= Const.IO_LEGO + 7;
+
+ public static final int MAX_VALUE = 0xff;
+
+ protected static int value;
+
+ /**
+ * Sets speaker output.
+ */
+ public static final void write(boolean value)
+ {
+ Native.wr(value ? MAX_VALUE : 0, IO_SPEAKER);
+ }
+
+ /**
+ * Sets speaker output.
+ * @param value Valid input range is 0..0xff.
+ */
+ public static final void write(int value)
+ {
+ Native.wr(value, IO_SPEAKER);
+ }
+}
1.3 jop/java/target/src/app/lego/lib/package.html
http://www.opencores.org/cvsweb.shtml/jop/java/target/src/app/lego/lib/package.html.diff?r1=1.2&r2=1.3
(In the diff below, changes in quantity of whitespace are not shown.)
Index: package.html
===================================================================
RCS file: package.html
diff -N package.html
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ package.html 5 Jun 2007 15:36:37 -0000 1.3
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head></head>
+<body bgcolor="white">
+Provides interfaces to the JOP Lego board periphery.
+<p>
+The package uses the Native.rd() and Native.wr() instructions provided by the JOP
+processor to communicate with the VHDL counterpart.
+The VHDL counterpart is realized as a (simple)
+<a href="http://www.opencores.org/projects.cgi/web/simpcon/overview">SimpCon</a> slave.
+The slaves top level entity is contained in vhdl/scio/sc_lego.vhd, and instantiated as
+jop/scio/sc_lego.
+<p>
+Conventions:
+<ul>
+<li>When writing, all non-relevant bits will be ignored.
+<li>When reading, all non-relevant bits will be zero.
+</ul>
+<p>
+In the JOP sources, the package is located in java/target/src/app/lego/lib.
+<p>
+Related documentation:
+<ul>
+<li>XXX
+</ul>
+</body>
+</html>
|
 |