Class 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 buffer
      void 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 operation
      void clear()
      Clears the transaction buffer
      void getRxBuffer​(int offset, byte[] buf)
      Reads data from the RX buffer
      void 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 operation
      void setTextArea​(javax.swing.JTextArea textArea)
      Registers a text area
      void showRxBuffer​(int offset, byte[] buf)
      Displays data from the RX buffer
      void showText​(java.lang.String txt)
      Displays text in the registered text area
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 - Opcode
        opLength - 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 - Opcode
        opLength - Length field of the operation in bytes
        buf - 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 writing
        waitflag - 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 completed
        statusTF - 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 write
        statusTF - 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 reading
        buf - 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 reading
        buf - Buffer to receive data