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 alec cohen

SPI_MX25R.h

Committer:
alec1
Date:
2015-07-08
Revision:
0:a16ad6f5c788
Child:
1:8403da5975cb

File content as of revision 0:a16ad6f5c788:

#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_