MAX32665 SDK Documentation  0.2
Software Development Kit Overview and API Documentation
MX25 SPI Multi-I/O Flash Memory Driver

Modules

 MX25 SPI Command Definitions
 

Macros

#define MX25_Read_DUMMY   8
 Dummy byte sent on a standard read command per the MX25 datasheet. More...
 
#define MX25_DREAD_DUMMY   4
 Dummy data sent on a fast-read (Dual) read command per the MX25 datasheet. More...
 
#define MX25_QREAD_DUMMY   6
 Dummy data sent on a fast-read (Quad) read command per the MX25 datasheet. More...
 
#define MX25_WIP_MASK   0x01
 Status Register.
 
#define MX25_WEL_MASK   0x02
 Write Enable Latch mask.
 
#define MX25_QE_MASK   0x40
 Quad-SPI enable mask.
 
#define MX25_WP_MASK   0x80
 Write protect enable mask.
 

Enumerations

enum  MX25_Erase_t {
  MX25_Erase_4K,
  MX25_Erase_32K,
  MX25_Erase_64K
}
 Enumeration type to select the size for an Erase command. More...
 

Functions

int MX25_Init (void)
 Initialize SPI configuration and reset n25q. More...
 
int MX25_Reset (void)
 Reset the MX25 flash memory. More...
 
uint32_t MX25_ID (void)
 Read manufacturer ID. More...
 
int MX25_Quad (int enable)
 Enable/Disable the Quad Enable(QE) bit in the status register. More...
 
int MX25_Read (uint32_t address, uint8_t *rx_buf, uint32_t rx_len, spixfc_width_t width)
 Read data out by using 4-wire SPI mode. More...
 
int MX25_Write_Protect (int enable)
 enable write protection More...
 
int MX25_Program_Page (uint32_t address, const uint8_t *tx_buf, uint32_t tx_len, spixfc_width_t width)
 Program the memory to tx_buf and length tx_len, applies to both SPI and QPI modes. More...
 
int MX25_Bulk_Erase (void)
 Bulk erase the MX25 flash memory. More...
 
int MX25_Erase (uint32_t address, MX25_Erase_t size)
 Erase memory segments. More...
 
int MX25_Read_SR (uint8_t *buf)
 Read status register. More...
 
int MX25_Write_SR (uint8_t value)
 Write status register. More...
 

Detailed Description

Macro Definition Documentation

◆ MX25_Read_DUMMY

#define MX25_Read_DUMMY   8

◆ MX25_DREAD_DUMMY

#define MX25_DREAD_DUMMY   4

◆ MX25_QREAD_DUMMY

#define MX25_QREAD_DUMMY   6

Enumeration Type Documentation

◆ MX25_Erase_t

Enumerator
MX25_Erase_4K 

4KB Sector Erase

MX25_Erase_32K 

32KB Block Erase

MX25_Erase_64K 

64KB Block Erase

Function Documentation

◆ MX25_Init()

int MX25_Init ( void  )
Returns
E_SUCCESS No error in function.
Error Code Non-zero error code if unsuccessful.

◆ MX25_Reset()

int MX25_Reset ( void  )
Returns
E_SUCCESS No error in function.
Error Code Non-zero error code if unsuccessful.

◆ MX25_ID()

uint32_t MX25_ID ( void  )
Returns
ID of the device, or 0 if an error occurred

◆ MX25_Quad()

int MX25_Quad ( int  enable)
Parameters
enable
  • 1 enables Quad Mode.
  • 0 disables Quad Mode.
Returns
E_SUCCESS No error in function.
Error Code Non-zero error code if unsuccessful.

◆ MX25_Read()

int MX25_Read ( uint32_t  address,
uint8_t *  rx_buf,
uint32_t  rx_len,
spixfc_width_t  width 
)
Parameters
addressStart address to read from
rx_bufPointer to the buffer of receiving data
rx_lenSize of the data to read
widthspi_width_t for how many data lines to use
Returns
E_SUCCESS No error in function.
Error Code Non-zero error code if unsuccessful.

◆ MX25_Write_Protect()

int MX25_Write_Protect ( int  enable)
Parameters
enableWrite protect state
Returns
E_SUCCESS No error in function.
Error Code Non-zero error code if unsuccessful.

◆ MX25_Program_Page()

int MX25_Program_Page ( uint32_t  address,
const uint8_t *  tx_buf,
uint32_t  tx_len,
spixfc_width_t  width 
)
  • SPI mode: All operations are in 4-wire SPI mode.
  • QPI mode: All operations are in quad SPI mode.
    Parameters
    addressStart address to program.
    tx_bufPointer to the buffer of data to write.
    tx_lenSize of the data to write.
    widthspi_width_t for how many data lines to use.
    Returns
    E_SUCCESS No error in function.
    Error Code Non-zero error code if unsuccessful.

◆ MX25_Bulk_Erase()

int MX25_Bulk_Erase ( void  )
Warning
Bulk erase typically takes between 100 to 150 seconds.
Returns
E_SUCCESS No error in function.
Error Code Non-zero error code if unsuccessful.

◆ MX25_Erase()

int MX25_Erase ( uint32_t  address,
MX25_Erase_t  size 
)
Parameters
addressStart address to begin erasing.
sizeSize to erase, see MX25_Erase_t.
Returns
E_SUCCESS No error in function.
Error Code Non-zero error code if unsuccessful.

◆ MX25_Read_SR()

int MX25_Read_SR ( uint8_t *  buf)
Parameters
bufPointer to store the value of the status register.

◆ MX25_Write_SR()

int MX25_Write_SR ( uint8_t  value)
Parameters
valueValue to write to the status register.