public interface IcspMaster extends Closeable
ICSP (In-Circuit Serial Programming) is a protocol intended for programming
of PIC MCUs. It is a serial protocol over three wires: PGC (clock), PGD
(data) and MCLR (reset), where PGC and MCLR are controlled by the master and
PGD is shared by the master and slave, depending on the transaction state.
IcspMaster instances are obtained by calling IOIO.openIcspMaster().
This interface is very low level: it allows direct access to the atomic operations of the ICSP protocol:
enterProgramming() /
exitProgramming(), respectively).executeInstruction(int)).readVisi()).The ICSP module uses fixed pins for its lines. See the user guide for details for your specific board. ICSP is a special feature, introduced for the purpose of programming a IOIO board with another IOIO board. It does not necessarily play nicely when used concurrently with other features, in the sense that it may introduce latencies in other modules. It is thus recommended not to use ICSP in conjunction with latency-sensitive features.
The instance is alive since its creation. If the connection with the IOIO
drops at any point, the instance transitions to a disconnected state, in
which every attempt to use it (except Closeable.close()) will throw a
ConnectionLostException. Whenever Closeable.close() is invoked the
instance may no longer be used. Any resources associated with it are freed
and can be reused.
Typical usage:
IcspMaster icsp = ioio.openIcspMaster();
icsp.enterProgramming();
icsp.executeInstruction(0x212340); // mov #0x1234, w0
icsp.executeInstruction(0x883C20); // mov w0, 0x784 (VISI)
icsp.executeInstruction(0x000000); // nop
icsp.readVisi();
int visi = icsp.waitVisiResult(); // should read 0x1234
icsp.exitProgramming();
icsp.close(); // free ICSP module and pins
IOIO.openIcspMaster()| Modifier and Type | Method and Description |
|---|---|
void |
enterProgramming()
Initiate a sequence that will put the slave device in programming mode.
|
void |
executeInstruction(int instruction)
Execute a single instruction on the slave MCU.
|
void |
exitProgramming()
Initiate a sequence that will put the slave device out of programming
mode.
|
void |
readVisi()
Request a read of the VISI register on the slave MCU.
|
int |
waitVisiResult()
Wait and return a result of a call to
readVisi(). |
void enterProgramming()
throws ConnectionLostException
ConnectionLostException - Connection to the IOIO has been lost.void exitProgramming()
throws ConnectionLostException
ConnectionLostException - Connection to the IOIO has been lost.void executeInstruction(int instruction)
throws ConnectionLostException
instruction - a 24-bit PIC instruction.ConnectionLostException - Connection to the IOIO has been lost.void readVisi()
throws ConnectionLostException,
java.lang.InterruptedException
waitVisiResult().
This method may block if the read queue on the IOIO is full, but this
should be for short periods only.ConnectionLostException - Connection to the IOIO has been lost.java.lang.InterruptedException - Interrupted while blocking.int waitVisiResult()
throws ConnectionLostException,
java.lang.InterruptedException
readVisi().
Results will be returned in the same order as requested.
The call will block until there is data, until interrupted, or until
connection to the IOIO has been lost.ConnectionLostException - Connection to the IOIO has been lost.java.lang.InterruptedException - Interrupted while blocking.