|
| fs_spi_EraseSector| Summary | |
#include <file_config.h>
int fs_spi_EraseSector (
U32 adr); /* address of sector to erase */
| | Description | | The fs_spi_EraseSector function is a user-provided routine that erases the spi data flash sector specified by adr address. The fs_spi_EraseSector function is part of RL-FlashFS. The prototype is defined in file_config.h. You can customize the function in fs_spi_flashprg.c. | | Return Value | | The fs_spi_EraseSector function returns a value of 0 if successful or a value of 1 if unsuccessful. | | See Also | | finit, fs_spi_Init, fs_spi_ProgramPage, fs_spi_ReadData | | Example | |
int fs_spi_EraseSector (U32 adr) {
U8 sr;
/* Write Enable */
spi_ss (0);
spi_send (SPI_WRITE_ENABLE);
spi_ss (1);
/* Erase Sector */
spi_ss (0);
spi_send (SPI_SECTOR_ERASE);
spi_send ((U8)(adr >> 16));
spi_send ((U8)(adr >> 8));
spi_send ((U8)(adr >> 0));
spi_ss (1);
/* Wait until done */
spi_ss (0);
spi_send (SPI_READ_SR);
do {
sr = spi_send (0xFF);
} while (sr & SR_WIP);
spi_ss (1);
/* Check for Error */
if (sr & SR_E_FAIL) {
spi_ss (0);
spi_send (SPI_CLEAR_SR_FLAGS);
spi_ss (1);
return (1);
}
return (0);
}
|
|
|