Macronix Low Power Serial NOR Flash in SPI mode.
Dependents: MX25Rxx35F_Serial_NOR_Flash_Testbench MX25Rxx35F_Serial_NOR_Flash_Testbench Coragem_all_sensors 1_Test_Flash_ADC_RTT
Diff: SPI_MX25R.h
- Revision:
- 0:a16ad6f5c788
- Child:
- 1:8403da5975cb
diff -r 000000000000 -r a16ad6f5c788 SPI_MX25R.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SPI_MX25R.h Wed Jul 08 20:59:40 2015 +0000 @@ -0,0 +1,104 @@ +#ifndef _SPI_MX25R_H_ +#define _SPI_MX25R_H_ + +#include "mbed.h" + +/** + * SPI_MX25R SPI-Flash Memory + * Macronix Serial Flash Low Power Memories + */ + +class SPI_MX25R +{ +public: + /** + * Macronix MX25R Low Power and Wide Vcc SPI-Flash Memory Family + * + * @param SI/SIO0 SPI_MOSI pin + * @param SO/SI01 SPI_MISO pin + * @param SCLK SPI_CLK pin + * @param CSb SPI_CS pin + */ + SPI_MX25R(PinName mosi, PinName miso, PinName sclk, PinName cs) ; + + ~SPI_MX25R() ; + /* + * not all functions have been created yet. + */ + + SPI m_spi; + DigitalOut m_cs ; + int _mode ; + +/// Write Enable + void writeEnable(void) ; + +/// Write Disable + void writeDisable(void) ; + +/// Reset Enable + void resetEnable(void) ; + +/// Reset + void reset(void) ; + +/// Enter High Performance mode + void hpmode(void) ; + +/// Enter High Performance mode + void lpmode(void) ; + + /// Chip Erase + void chipErase(void) ; + +/** Page Program + * + * @param int addr start address + * @param uint8_t *data data buffer + * @param int numData the number of data to be written + */ + void programPage(int addr, uint8_t *data, int numData) ; + +/** Sector Erase + * + * @param int addr specify the sector to be erased + */ + void sectorErase(int addr) ; + + /** Block Erase + * + * @param int addr specify the sector to be erased + */ + void blockErase(int addr) ; + + /** 32KB Block Erase + * + * @param int addr specify the sector to be erased + */ + void blockErase32KB(int addr) ; + + /** Read Status Register + * + * @returns uint8_t status register value + */ + uint8_t readStatus(void) ; + + /** Read ID + * + * @returns uint32_t Manufacturer ID, Mem Type, Device ID + */ + uint32_t readID(void) ; + + /** Read Configuration Register + * + * @returns uint32_t configuration register value + */ + uint32_t readConfig(void) ; + + uint8_t read8(int addr) ; + uint32_t rd32(int addr) ; + void write8(int addr, uint8_t data) ; + private: + +} ; +#endif // _SPI_MX25R_H_ \ No newline at end of file