Class M25PxxIo
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
FieldsModifier and TypeFieldDescription(package private) static final byte(package private) ByteBuffer(package private) byte[](package private) RegisterIo(package private) final int(package private) static final byte(package private) Preferences(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) JTextArea(package private) final int(package private) static final byte(package private) static final byte -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(byte code, short opLength) Appends dataless operation to transaction buffervoidappend(byte code, short opLength, byte[] buf) Appends operation to transaction buffer with data(package private) voidbulkErase(boolean poll, JTextField statusTF) Does bulk erase operationvoidclear()Clears the transaction buffervoidgetRxBuffer(int offset, byte[] buf) Reads data from the RX buffervoidop(int offset, boolean waitflag) Writes instruction to buffer.(package private) voidpp(int start) Does oage program operation(package private) voidprogram(byte[] buf, JTextField statusTF) Reads the flash data from file and programs flash.(package private) voidread(int start) Does read operation(package private) voidread(int start, int len) Does read operationvoidsave(FileOutputStream fo, int npages) (package private) voidsectorErase(int start) Does sector erase operationvoidsetTextArea(JTextArea textArea) Registers a text areavoidshowRxBuffer(int offset, byte[] buf) Displays data from the RX buffervoidDisplays text in the registered text area
-
Field Details
-
prefs
Preferences prefs -
io
RegisterIo io -
textArea
JTextArea textArea -
bytes
byte[] bytes -
byteBuffer
ByteBuffer byteBuffer -
pageSize
final int pageSize- See Also:
-
txPages
final int txPages- See Also:
-
PP
static final byte PP- See Also:
-
READ
static final byte READ- See Also:
-
WRDI
static final byte WRDI- See Also:
-
RDSR
static final byte RDSR- See Also:
-
WREN
static final byte WREN- See Also:
-
RDID
static final byte RDID- See Also:
-
BE
static final byte BE- See Also:
-
SE
static final byte SE- See Also:
-
-
Constructor Details
-
M25PxxIo
-
-
Method Details
-
setTextArea
Registers a text area
- Parameters:
textArea- The text area
-
showText
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
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
-
read
void read(int start, int len) Does read operation
- Parameters:
start- Start page
-
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
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
-
save
- Throws:
IOException
-