MX25R6435F Library
Dependents: Demo_MX25Rxx35F_Serial_NOR_Flash_Testbench mbed-lorawan-pulga mbed-lorawan-pulga-serial_rx mbed-lorawan-pulga-gps-added_shared
Fork of SPI_MX25R by
Diff: SPI_MX25R.h
- Revision:
- 2:f72110475fec
- Parent:
- 1:8403da5975cb
- Child:
- 3:b6bb8d236251
diff -r 8403da5975cb -r f72110475fec SPI_MX25R.h --- a/SPI_MX25R.h Mon Jul 20 20:45:33 2015 +0000 +++ b/SPI_MX25R.h Thu Jul 23 17:11:27 2015 +0000 @@ -1,17 +1,58 @@ #ifndef _SPI_MX25R_H_ #define _SPI_MX25R_H_ - + #include "mbed.h" - + +/** + * Macronix Serial Flash Low Power Memories + * SPI_MX25R Series SPI-Flash Memory + */ +#define CS_LOW 0 // SPI CS# (Chip Select) Setting +#define CS_HIGH 1 // SPI CS# (Chip Select) Setting +#define DUMMY 0x00 // Dummy byte which can be changed to any value /** - * SPI_MX25R SPI-Flash Memory - * Macronix Serial Flash Low Power Memories + * MX25R Series Register Command Table. + * x2 and x4 commands not currently supported with FRDM K64F platform */ - +#define CMD_READ 0x03 // x1 Normal Read Data Byte +#define CMD_FREAD 0x0B // x1 Fast Read Data Byte +#define CMD_2READ 0xBB // x2 2READ +#define CMD_DREAD 0x3B // x2 DREAD +#define CMD_4READ 0xEB // x4 4READ +#define CMD_QREAD 0x6B // x4 QREAD +#define CMD_PP 0x02 // Page Program +#define CMD_4PP 0x38 // x4 PP +#define CMD_SE 0x20 // 4KB Sector Erase +#define CMD_32KBE 0x52 // 32KB Block Erase +#define CMD_BE 0xD8 // 64KB Block Erase +#define CMD_CE 0xC7 // Chip Erase +#define CMD_RDSFDP 0x5A // Read SFDP +#define CMD_WREN 0x06 // Write Enable +#define CMD_WRDI 0x04 // Write Disable +#define CMD_RDSR 0x05 // Read Status Register +#define CMD_RDCR 0x15 // Read Configuration Register +#define CMD_WRSR 0x01 // Write Status Register +#define CMD_PESUS 0xB0 // Program/Erase Suspend +#define CMD_PERES 0x30 // Program/Erase Resume +#define CMD_DP 0xB9 // Enter Deep Power Down +#define CMD_SBL 0xC0 // Set Burst Length +#define CMD_RDID 0x9F // Read Manufacturer and JDEC Device ID +#define CMD_REMS 0x90 // Read Electronic Manufacturer and Device ID +#define CMD_RES 0xAB // Read Electronic ID +#define CMD_ENSO 0xB1 // Enter Secure OTP +#define CMD_EXSO 0xC1 // Exit Secure OTP +#define CMD_RDSCUR 0x2B // Read Security Register +#define CMD_WRSCUR 0x2F // Write Security Register +#define CMD_NOP 0x00 // No Operation +#define CMD_RSTEN 0x66 // Reset Enable +#define CMD_RST 0x99 // Reset +#define CMD_RRE 0xFF // Release Read Enhanced Mode + + class SPI_MX25R { public: - /** +/** * Macronix MX25R Low Power and Wide Vcc SPI-Flash Memory Family * * @param SI/SIO0 SPI_MOSI pin @@ -22,7 +63,7 @@ SPI_MX25R(PinName mosi, PinName miso, PinName sclk, PinName cs) ; ~SPI_MX25R() ; - + SPI m_spi; DigitalOut m_cs ; int _mode ; @@ -38,37 +79,40 @@ /// Reset void reset(void) ; - + /// Program or Erase Suspend void pgmersSuspend(void) ; /// Program or Erase Resume void pgmersResume(void) ; - + /// Enter Deep Power Down void deepPowerdown(void) ; - + /// Set Burst Length void setBurstlength(void) ; - + /// Release from Read Enhanced Mode void releaseReadenhaced(void) ; - + /// No Operation void noOperation(void) ; - + /// Enter OTP Area void enterSecureOTP(void) ; /// Exit OTP Area void exitSecureOTP(void) ; - + /// Chip Erase void chipErase(void) ; /// Write Status and Configuration Reg 1 and 2 void writeStatusreg(int addr) ; +/// Write Security Reg + void writeSecurityreg(int addr) ; + /** Page Program * * @param int addr start address @@ -83,31 +127,49 @@ */ void sectorErase(int addr) ; - /** Block Erase +/** Block Erase * * @param int addr specify the sector to be erased */ void blockErase(int addr) ; - /** 32KB Block Erase +/** 32KB Block Erase * * @param int addr specify the sector to be erased */ void blockErase32KB(int addr) ; - /** Read Status Register +/** Read Status Register * * @returns uint8_t status register value */ uint8_t readStatus(void) ; - /** Read ID +/** Read Security Register + * + * @returns uint8_t security register value + */ + uint8_t readSecurity(void) ; + +/** Read Manufacturer and JEDEC Device ID * * @returns uint32_t Manufacturer ID, Mem Type, Device ID */ uint32_t readID(void) ; - /** Read Configuration Register +/** Read Electronic Manufacturer and Device ID + * + * @returns uint32_t Manufacturer ID, Device ID + */ + uint32_t readREMS(void) ; + +/** Read Electronic ID + * + * @returns uint8_t Device ID + */ + uint8_t readRES(void) ; + +/** Read Configuration Register * * @returns uint32_t configuration register value */ @@ -117,6 +179,6 @@ uint8_t read8(int addr) ; void write8(int addr, uint8_t data) ; private: - + } ; #endif // _SPI_MX25R_H_ \ No newline at end of file