SAMV71 Xplained Ultra Software Package 1.3

s25fl1.h File Reference

Go to the source code of this file.

Defines

#define USE_QSPI_DMA
#define Size(pAt25)   ((pAt25)->pDesc->size)
#define PageSize(pAt25)   ((pAt25)->pDesc->pageSize)
#define BlockSize(pAt25)   ((pAt25)->pDesc->blockSize)
#define Name(pAt25)   ((pAt25)->pDesc->name)
#define ManId(pAt25)   (((pAt25)->pDesc->jedecId) & 0xFF)
#define PageNumber(pAt25)   (Size(pAt25) / PageSize(pAt25))
#define BlockNumber(pAt25)   (Size(pAt25) / BlockSize(pAt25))
#define PagePerBlock(pAt25)   (BlockSize(pAt25) / PageSize(pAt25))
#define BlockEraseCmd(pAt25)   ((pAt25)->pDesc->blockEraseCmd)
#define ERROR_PROTECTED   1
#define ERROR_BUSY   2
#define ERROR_PROGRAM   3
#define ERROR_SPI   4
#define STATUS_RDYBSY   (1 << 0)
#define STATUS_RDYBSY_READY   (0 << 0)
#define STATUS_RDYBSY_BUSY   (1 << 0)
#define STATUS_WEL   (1 << 1)
#define STATUS_WEL_DISABLED   (0 << 1)
#define STATUS_WEL_ENABLED   (1 << 1)
#define STATUS_SWP   (3 << 2)
#define STATUS_SWP_PROTALL   (3 << 2)
#define STATUS_SWP_PROTSOME   (1 << 2)
#define STATUS_SWP_PROTNONE   (0 << 2)
#define STATUS_WPP   (1 << 4)
#define STATUS_WPP_NOTASSERTED   (0 << 4)
#define STATUS_WPP_ASSERTED   (1 << 4)
#define STATUS_EPE   (1 << 5)
#define STATUS_EPE_SUCCESS   (0 << 5)
#define STATUS_EPE_ERROR   (1 << 5)
#define STATUS_SPRL   (1 << 7)
#define STATUS_SPRL_UNLOCKED   (0 << 7)
#define STATUS_SPRL_LOCKED   (1 << 7)
#define STATUS_QUAD_ENABLE   (1 << 1)
#define STATUS_WRAP_ENABLE   (0 << 4)
#define STATUS_LATENCY_CTRL   (0xF << 0)
#define STATUS_WRAP_BYTE   (1 << 5)
#define BLOCK_PROTECT_Msk   (7 << 2)
#define TOP_BTM_PROTECT_Msk   (1 << 5)
#define SEC_PROTECT_Msk   (1 << 6)
#define CHIP_PROTECT_Msk   (0x1F << 2)
#define READ_ARRAY   0x0B
#define READ_ARRAY_LF   0x03
#define READ_ARRAY_DUAL   0x3B
#define READ_ARRAY_QUAD   0x6B
#define READ_ARRAY_DUAL_IO   0xBB
#define READ_ARRAY_QUAD_IO   0xEB
#define BLOCK_ERASE_4K   0x20
#define BLOCK_ERASE_32K   0x52
#define BLOCK_ERASE_64K   0xD8
#define CHIP_ERASE_1   0x60
#define CHIP_ERASE_2   0xC7
#define BYTE_PAGE_PROGRAM   0x02
#define SEQUENTIAL_PROGRAM_1   0xAD
#define SEQUENTIAL_PROGRAM_2   0xAF
#define WRITE_ENABLE   0x06
#define WRITE_DISABLE   0x04
#define PROTECT_SECTOR   0x36
#define UNPROTECT_SECTOR   0x39
#define READ_SECTOR_PROT   0x3C
#define READ_STATUS_1   0x05
#define READ_STATUS_2   0x35
#define READ_STATUS_3   0x33
#define WRITE_STATUS   0x01
#define READ_JEDEC_ID   0x9F
#define DEEP_PDOWN   0xB9
#define RES_DEEP_PDOWN   0xAB
#define SOFT_RESET_ENABLE   0x66
#define SOFT_RESET   0x99
#define WRAP_ENABLE   0x77
#define CONT_MODE_RESET   0xFF
#define ATMEL_SPI_FLASH   0x1F
#define ST_SPI_FLASH   0x20
#define WINBOND_SPI_FLASH   0xEF
#define MACRONIX_SPI_FLASH   0xC2
#define SST_SPI_FLASH   0xBF

Functions

uint32_t S25FL1D_ReadJedecId (void)
 Reads and returns the serial flash device ID.
void S25FL1D_InitFlashInterface (uint8_t Mode)
void S25FL1D_SoftReset (void)
void S25FL1D_ContReadModeReset (void)
 Issue 'CContinuous Read Mode' command, the device can return to normal SPI command mode, in which all commands can be accepts.
unsigned char S25FL1D_Unprotect (void)
 Unprotected the contents of the serial flash device.
unsigned char S25FL1D_Protect (uint32_t StartAddr, uint32_t Size)
 Unprotected the contents of the serial flash device.
void S25FL1D_QuadMode (uint8_t Enable)
 Enables critical writes operation on a serial flash device, such as sector protection, status register, etc.
void S25FL1D_EnableWrap (uint8_t ByetAlign)
 Enables critical writes operation on a serial flash device, such as sector protection, status register, etc.
void S25FL1D_SetReadLatencyControl (uint8_t Latency)
 Enables critical writes operation on a serial flash device, such as sector protection, status register, etc.
unsigned char S25FL1D_EraseChip (void)
 Erases all the content of the memory chip.
unsigned char S25FL1D_EraseSector (unsigned int address)
 Erases the specified block of the serial firmware dataflash.
unsigned char S25FL1D_Erase64KBlock (unsigned int address)
 Erases the specified 64KB block of the serial firmware dataflash.
unsigned char S25FL1D_Write (uint32_t *pData, uint32_t size, uint32_t address, uint8_t Secure)
 Writes data at the specified address on the serial firmware dataflash. The page(s) to program must have been erased prior to writing. This function handles page boundary crossing automatically.
unsigned char S25FL1D_Read (uint32_t *pData, uint32_t size, uint32_t address)
 Reads data from the specified address on the serial flash.
unsigned char S25FL1D_ReadDual (uint32_t *pData, uint32_t size, uint32_t address)
 Reads data from the specified address on the serial flash.
unsigned char S25FL1D_ReadQuad (uint32_t *pData, uint32_t size, uint32_t address)
 Reads data from the specified address on the serial flash.
unsigned char S25FL1D_ReadDualIO (uint32_t *pData, uint32_t size, uint32_t address, uint8_t ContMode, uint8_t Secure)
 Reads data from the specified address on the serial flash.
unsigned char S25FL1D_ReadQuadIO (uint32_t *pData, uint32_t size, uint32_t address, uint8_t ContMode, uint8_t Secure)
 Reads data from the specified address on the serial flash.

Detailed Description

Interface for the S25fl1 Serial Flash driver.

Definition in file s25fl1.h.


Define Documentation

#define ATMEL_SPI_FLASH   0x1F

SPI Flash Manufacturer JEDEC ID

Definition at line 186 of file s25fl1.h.

#define BLOCK_ERASE_32K   0x52

Block erase command code (32K block).

Definition at line 139 of file s25fl1.h.

#define BLOCK_ERASE_4K   0x20

Block erase command code (4K block).

Definition at line 137 of file s25fl1.h.

#define BLOCK_ERASE_64K   0xD8

Block erase command code (64K block).

Definition at line 141 of file s25fl1.h.

#define BYTE_PAGE_PROGRAM   0x02

Byte/page program command code.

Definition at line 147 of file s25fl1.h.

#define CHIP_ERASE_1   0x60

Chip erase command code 1.

Definition at line 143 of file s25fl1.h.

#define CHIP_ERASE_2   0xC7

Chip erase command code 2.

Definition at line 145 of file s25fl1.h.

#define CONT_MODE_RESET   0xFF

Continuous Read Mode Reset command code.

Definition at line 183 of file s25fl1.h.

#define DEEP_PDOWN   0xB9

Deep power-down command code.

Definition at line 173 of file s25fl1.h.

#define ERROR_BUSY   2

Device is busy executing a command.

Definition at line 61 of file s25fl1.h.

#define ERROR_PROGRAM   3

There was a problem while trying to program page data.

Definition at line 63 of file s25fl1.h.

#define ERROR_PROTECTED   1

Device is protected, operation cannot be carried out.

Definition at line 59 of file s25fl1.h.

#define ERROR_SPI   4

There was an SPI communication error.

Definition at line 65 of file s25fl1.h.

#define PROTECT_SECTOR   0x36

Protect sector command code.

Definition at line 157 of file s25fl1.h.

#define READ_ARRAY   0x0B

Read array command code.

Definition at line 125 of file s25fl1.h.

#define READ_ARRAY_DUAL   0x3B

Fast Read array command code.

Definition at line 129 of file s25fl1.h.

#define READ_ARRAY_DUAL_IO   0xBB

Fast Read array command code.

Definition at line 133 of file s25fl1.h.

#define READ_ARRAY_LF   0x03

Read array (low frequency) command code.

Definition at line 127 of file s25fl1.h.

#define READ_ARRAY_QUAD   0x6B

Fast Read array command code.

Definition at line 131 of file s25fl1.h.

#define READ_ARRAY_QUAD_IO   0xEB

Fast Read array command code.

Definition at line 135 of file s25fl1.h.

#define READ_JEDEC_ID   0x9F

Read manufacturer and device ID command code.

Definition at line 171 of file s25fl1.h.

#define READ_SECTOR_PROT   0x3C

Read sector protection registers command code.

Definition at line 161 of file s25fl1.h.

#define READ_STATUS_1   0x05

Read status register command code.

Definition at line 163 of file s25fl1.h.

#define READ_STATUS_2   0x35

Read status register command code.

Definition at line 165 of file s25fl1.h.

#define READ_STATUS_3   0x33

Read status register command code.

Definition at line 167 of file s25fl1.h.

#define RES_DEEP_PDOWN   0xAB

Resume from deep power-down command code.

Definition at line 175 of file s25fl1.h.

#define SEQUENTIAL_PROGRAM_1   0xAD

Sequential program mode command code 1.

Definition at line 149 of file s25fl1.h.

#define SEQUENTIAL_PROGRAM_2   0xAF

Sequential program mode command code 2.

Definition at line 151 of file s25fl1.h.

#define SOFT_RESET   0x99

Resume from deep power-down command code.

Definition at line 179 of file s25fl1.h.

#define SOFT_RESET_ENABLE   0x66

Resume from deep power-down command code.

Definition at line 177 of file s25fl1.h.

#define STATUS_EPE   (1 << 5)

Erase/program error bit.

Definition at line 94 of file s25fl1.h.

#define STATUS_EPE_ERROR   (1 << 5)

Erase or program error detected.

Definition at line 98 of file s25fl1.h.

#define STATUS_EPE_SUCCESS   (0 << 5)

Erase or program operation was successful.

Definition at line 96 of file s25fl1.h.

#define STATUS_LATENCY_CTRL   (0xF << 0)

Latency control bits

Definition at line 112 of file s25fl1.h.

#define STATUS_QUAD_ENABLE   (1 << 1)

Quad enable bit

Definition at line 107 of file s25fl1.h.

#define STATUS_RDYBSY   (1 << 0)

Device ready/busy status bit.

Definition at line 68 of file s25fl1.h.

#define STATUS_RDYBSY_BUSY   (1 << 0)

Device is busy with internal operations.

Definition at line 72 of file s25fl1.h.

#define STATUS_RDYBSY_READY   (0 << 0)

Device is ready.

Definition at line 70 of file s25fl1.h.

#define STATUS_SPRL   (1 << 7)

Sector protection registers locked bit.

Definition at line 100 of file s25fl1.h.

#define STATUS_SPRL_LOCKED   (1 << 7)

Sector protection registers are locked.

Definition at line 104 of file s25fl1.h.

#define STATUS_SPRL_UNLOCKED   (0 << 7)

Sector protection registers are unlocked.

Definition at line 102 of file s25fl1.h.

#define STATUS_SWP   (3 << 2)

Software protection status bit-field.

Definition at line 80 of file s25fl1.h.

#define STATUS_SWP_PROTALL   (3 << 2)

All sectors are software protected.

Definition at line 82 of file s25fl1.h.

#define STATUS_SWP_PROTNONE   (0 << 2)

No sector is software protected.

Definition at line 86 of file s25fl1.h.

#define STATUS_SWP_PROTSOME   (1 << 2)

Some sectors are software protected.

Definition at line 84 of file s25fl1.h.

#define STATUS_WEL   (1 << 1)

Write enable latch status bit.

Definition at line 74 of file s25fl1.h.

#define STATUS_WEL_DISABLED   (0 << 1)

Device is not write enabled.

Definition at line 76 of file s25fl1.h.

#define STATUS_WEL_ENABLED   (1 << 1)

Device is write enabled.

Definition at line 78 of file s25fl1.h.

#define STATUS_WPP   (1 << 4)

Write protect pin status bit.

Definition at line 88 of file s25fl1.h.

#define STATUS_WPP_ASSERTED   (1 << 4)

Write protect signal is asserted.

Definition at line 92 of file s25fl1.h.

#define STATUS_WPP_NOTASSERTED   (0 << 4)

Write protect signal is not asserted.

Definition at line 90 of file s25fl1.h.

#define STATUS_WRAP_ENABLE   (0 << 4)

Quad enable bit

Definition at line 109 of file s25fl1.h.

#define UNPROTECT_SECTOR   0x39

Unprotected sector command code.

Definition at line 159 of file s25fl1.h.

#define WRAP_ENABLE   0x77

Resume from deep power-down command code.

Definition at line 181 of file s25fl1.h.

#define WRITE_DISABLE   0x04

Write disable command code.

Definition at line 155 of file s25fl1.h.

#define WRITE_ENABLE   0x06

Write enable command code.

Definition at line 153 of file s25fl1.h.

#define WRITE_STATUS   0x01

Write status register command code.

Definition at line 169 of file s25fl1.h.


Function Documentation

void S25FL1D_EnableWrap ( uint8_t  ByetAlign  ) 

Enables critical writes operation on a serial flash device, such as sector protection, status register, etc.

pS25fl1 Pointer to an S25FL1 driver instance.

Definition at line 568 of file s25fl1.c.

Here is the call graph for this function:

unsigned char S25FL1D_Erase64KBlock ( unsigned int  address  ) 

Erases the specified 64KB block of the serial firmware dataflash.

Parameters:
pS25fl1 Pointer to an S25FL1 driver instance.
address Address of the block to erase.
Returns:
0 if successful; otherwise returns ERROR_PROTECTED if the device is protected or ERROR_BUSY if it is busy executing a command.

Definition at line 793 of file s25fl1.c.

Here is the call graph for this function:

unsigned char S25FL1D_EraseChip ( void   ) 

Erases all the content of the memory chip.

Parameters:
pS25fl1 Pointer to an S25FL1 driver instance.
Returns:
0 if the device has been unprotected; otherwise returns ERROR_PROTECTED.

Definition at line 712 of file s25fl1.c.

Here is the call graph for this function:

unsigned char S25FL1D_EraseSector ( unsigned int  address  ) 

Erases the specified block of the serial firmware dataflash.

Parameters:
pS25fl1 Pointer to an S25FL1 driver instance.
address Address of the block to erase.
Returns:
0 if successful; otherwise returns ERROR_PROTECTED if the device is protected or ERROR_BUSY if it is busy executing a command.

Definition at line 750 of file s25fl1.c.

unsigned char S25FL1D_Protect ( uint32_t  StartAddr,
uint32_t  Size 
)

Unprotected the contents of the serial flash device.

Parameters:
pS25fl1 Pointer to an S25FL1 driver instance.
Returns:
0 if the device has been unprotected; otherwise returns S25FL1D_ERROR_PROTECTED.

Definition at line 677 of file s25fl1.c.

void S25FL1D_QuadMode ( uint8_t  Enable  ) 

Enables critical writes operation on a serial flash device, such as sector protection, status register, etc.

pS25fl1 Pointer to an S25FL1 driver instance.

Definition at line 535 of file s25fl1.c.

Here is the call graph for this function:

unsigned char S25FL1D_Read ( uint32_t *  pData,
uint32_t  size,
uint32_t  address 
)

Reads data from the specified address on the serial flash.

Parameters:
pS25fl1 Pointer to an S25FL1 driver instance.
pData Data buffer.
size Number of bytes to read.
address Read address.
Returns:
0 if successful; otherwise, fail.

Definition at line 912 of file s25fl1.c.

Here is the call graph for this function:

unsigned char S25FL1D_ReadDual ( uint32_t *  pData,
uint32_t  size,
uint32_t  address 
)

Reads data from the specified address on the serial flash.

Parameters:
pS25fl1 Pointer to an S25FL1 driver instance.
pData Data buffer.
size Number of bytes to read.
address Read address.
Returns:
0 if successful; otherwise, fail.

Definition at line 954 of file s25fl1.c.

Here is the call graph for this function:

unsigned char S25FL1D_ReadDualIO ( uint32_t *  pData,
uint32_t  size,
uint32_t  address,
uint8_t  ContMode,
uint8_t  Secure 
)

Reads data from the specified address on the serial flash.

Parameters:
pS25fl1 Pointer to an S25FL1 driver instance.
pData Data buffer.
size Number of bytes to read.
address Read address.
Returns:
0 if successful; otherwise, fail.

Definition at line 1042 of file s25fl1.c.

Here is the call graph for this function:

uint32_t S25FL1D_ReadJedecId ( void   ) 

Reads and returns the serial flash device ID.

Parameters:
pS25fl1 Pointer to an S25FL1 driver instance.

Definition at line 521 of file s25fl1.c.

unsigned char S25FL1D_ReadQuad ( uint32_t *  pData,
uint32_t  size,
uint32_t  address 
)

Reads data from the specified address on the serial flash.

Parameters:
pS25fl1 Pointer to an S25FL1 driver instance.
pData Data buffer.
size Number of bytes to read.
address Read address.
Returns:
0 if successful; otherwise, fail.

Definition at line 999 of file s25fl1.c.

Here is the call graph for this function:

unsigned char S25FL1D_ReadQuadIO ( uint32_t *  pData,
uint32_t  size,
uint32_t  address,
uint8_t  ContMode,
uint8_t  Secure 
)

Reads data from the specified address on the serial flash.

Parameters:
pS25fl1 Pointer to an S25FL1 driver instance.
pData Data buffer.
size Number of bytes to read.
address Read address.
Returns:
0 if successful; otherwise, fail.

Definition at line 1094 of file s25fl1.c.

Here is the call graph for this function:

void S25FL1D_SetReadLatencyControl ( uint8_t  Latency  ) 

Enables critical writes operation on a serial flash device, such as sector protection, status register, etc.

pS25fl1 Pointer to an S25FL1 driver instance.

Definition at line 594 of file s25fl1.c.

Here is the call graph for this function:

unsigned char S25FL1D_Unprotect ( void   ) 

Unprotected the contents of the serial flash device.

Parameters:
pS25fl1 Pointer to an S25FL1 driver instance.
Returns:
0 if the device has been unprotected; otherwise returns S25FL1D_ERROR_PROTECTED.

Definition at line 637 of file s25fl1.c.

unsigned char S25FL1D_Write ( uint32_t *  pData,
uint32_t  size,
uint32_t  address,
uint8_t  Secure 
)

Writes data at the specified address on the serial firmware dataflash. The page(s) to program must have been erased prior to writing. This function handles page boundary crossing automatically.

Parameters:
pS25fl1 Pointer to an S25FL1 driver instance.
pData Data buffer.
size Number of bytes in buffer.
address Write address.
Returns:
0 if successful; otherwise, returns ERROR_PROGRAM is there has been an error during the data programming.

Definition at line 846 of file s25fl1.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines