Class M25PxxIo
- java.lang.Object
-
- cbsw.adept.xilinx.M25PxxIo
-
class M25PxxIo extends java.lang.Object
Programmatic interface for SPI flash memories
The IO interface addresses are set in Java Preferences:
/M25Pxx/rxBase
Receive buffer address/M25Pxx/txBase
Transmit buffer address
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static byte
BE
(package private) java.nio.ByteBuffer
byteBuffer
(package private) byte[]
bytes
(package private) RegisterIo
io
(package private) int
pageSize
(package private) static byte
PP
(package private) java.util.prefs.Preferences
prefs
(package private) static byte
RDID
(package private) static byte
RDSR
(package private) static byte
READ
(package private) static byte
SE
(package private) javax.swing.JTextArea
textArea
(package private) int
txPages
(package private) static byte
WRDI
(package private) static byte
WREN
-
Constructor Summary
Constructors Constructor Description M25PxxIo(RegisterIo io)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(byte code, short opLength)
Appends dataless operation to transaction buffervoid
append(byte code, short opLength, byte[] buf)
Appends operation to transaction buffer with data(package private) void
bulkErase(boolean poll, javax.swing.JTextField statusTF)
Does bulk erase operationvoid
clear()
Clears the transaction buffervoid
getRxBuffer(int offset, byte[] buf)
Reads data from the RX buffervoid
op(int offset, boolean waitflag)
Writes instruction to buffer.(package private) void
pp(int start)
Does oage program operation(package private) void
program(byte[] buf, javax.swing.JTextField statusTF)
Reads the flash data from file and programs flash.(package private) void
read(int start)
Does read operation(package private) void
sectorErase(int start)
Does sector erase operationvoid
setTextArea(javax.swing.JTextArea textArea)
Registers a text areavoid
showRxBuffer(int offset, byte[] buf)
Displays data from the RX buffervoid
showText(java.lang.String txt)
Displays text in the registered text area
-
-
-
Field Detail
-
prefs
java.util.prefs.Preferences prefs
-
io
RegisterIo io
-
textArea
javax.swing.JTextArea textArea
-
bytes
byte[] bytes
-
byteBuffer
java.nio.ByteBuffer byteBuffer
-
pageSize
final int pageSize
- See Also:
- Constant Field Values
-
txPages
final int txPages
- See Also:
- Constant Field Values
-
PP
static final byte PP
- See Also:
- Constant Field Values
-
READ
static final byte READ
- See Also:
- Constant Field Values
-
WRDI
static final byte WRDI
- See Also:
- Constant Field Values
-
RDSR
static final byte RDSR
- See Also:
- Constant Field Values
-
WREN
static final byte WREN
- See Also:
- Constant Field Values
-
RDID
static final byte RDID
- See Also:
- Constant Field Values
-
BE
static final byte BE
- See Also:
- Constant Field Values
-
SE
static final byte SE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
M25PxxIo
public M25PxxIo(RegisterIo io)
Constructor
- Parameters:
io
- The IO interface
-
-
Method Detail
-
setTextArea
public void setTextArea(javax.swing.JTextArea textArea)
Registers a text area
- Parameters:
textArea
- The text area
-
showText
public void showText(java.lang.String txt)
Displays text in the registered text area
- Parameters:
txt
- The text to display
-
clear
public void clear()
Clears the transaction buffer
-
append
public void append(byte code, short opLength)
Appends dataless operation to transaction buffer
- Parameters:
code
- OpcodeopLength
- Length field of the operation in bytes
-
append
public void append(byte code, short opLength, byte[] buf)
Appends operation to transaction buffer with data
- Parameters:
code
- OpcodeopLength
- Length field of the operation in bytesbuf
- Data to write
-
op
public void op(int offset, boolean waitflag)
Writes instruction to buffer.
End of commands is marked by x"0000" in the next length field.
- Parameters:
offset
- Offset into buffer where to start writingwaitflag
- If true, activate the IO wait feature
-
bulkErase
void bulkErase(boolean poll, javax.swing.JTextField statusTF)
Does bulk erase operation
May take tens of seconds depending on memory type
- Parameters:
poll
- If true, poll until operation has completedstatusTF
- Text field where to write status
-
sectorErase
void sectorErase(int start)
Does sector erase operation
- Parameters:
start
- Start address of sector
-
read
void read(int start)
Does read operation
- Parameters:
start
- Start address
-
pp
void pp(int start)
Does oage program operation
Currently this is just a test operation that writes a fixed pattern.
- Parameters:
start
- Start address
-
program
void program(byte[] buf, javax.swing.JTextField statusTF)
Reads the flash data from file and programs flash.
It is most efficient to minimise the number of DEPP transactions therefore buffer several pages into the same DEPP message.
The FPGA buffer is 16Kb so we could do up to 7 pages at a time but we must also take account of the programming time which must not exceed the 10ms DEPP timeout since we are using DEPP wait to synchronise with timeout of 10ms.
- Parameters:
buf
- Buffer containing data to writestatusTF
- Test field where to display status
-
showRxBuffer
public void showRxBuffer(int offset, byte[] buf)
Displays data from the RX buffer
- Parameters:
offset
- Offset in buffer from where to start readingbuf
- Buffer to receive data
-
getRxBuffer
public void getRxBuffer(int offset, byte[] buf)
Reads data from the RX buffer
- Parameters:
offset
- Offset in buffer from where to start readingbuf
- Buffer to receive data
-
-