Cypress S25FL032P (SPIFI)
The S25FL032P is a 3.0 Volt (2.7V to 3.6V), single-power-supply Flash memory device. The device consists of 64
uniform 64 KB sectors with the two (Top or Bottom) 64 KB sectors further split up into thirty-two 4KB sub sectors.
This driver is implemented in source
files s25fl032p_nxpspifi.c/.h and provides communications support with the device over the NXP SPIFI interface.
Device Information
Basic Usage
The code snippet below shows how to create and initialize an instance of the serial flash driver.
#include "mcu_spifi.h"
#include "Drivers/Spansion/s25fl032p_nxpspifi.h"
#include <assert.h>
static SPIFI spifi; /* Allocate driver for the SPIFI peripheral */
static S25FL032P mem; /* Allocate driver for the flash device */
void APP_Example(void)
{
STATUS status;
status = SPIFI_Open(&spifi, 0); /* Init the SPIFI peripheral */
assert(status == SUCCESS);
status = S25FL032P_Open(&mem, &spifi); /* Open the memory driver */
assert(status == SUCCESS);
}
The SPIFI peripheral allows for the serial flash memory to be mapped into the MCU memory space. The code snippet below shows
how to enable th automatic reading of the device.
#include "Drivers/Spansion/s25fl032p_nxpspifi.h"
#include <assert.h>
void APP_Example(void)
{
ALIGNED(4) BYTE buf[32];
STATUS status;
status = S25FL032P_EnterAutoRead(&mem); /* Enter automatic read mode */
assert(status == SUCCESS);
/* In automatic read mode, reading mapped
addresses will now come from the flash
device. */
memcpy(buf, (void*)MAPPED_ADDRESS, 32);
}
The code snippet below shows how to erase and program a set of data to the first data sector within the device.
#include "Drivers/Spansion/s25fl032p_nxpspifi.h"
#include <assert.h>
ALIGNED(4) const BYTE data[] {
0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8
};
void APP_Example(void)
{
STATUS status;
/* If the device is in automatic read mode,
it must be exited before erasing or
programming can occur. */
status = S25FL032P_ExitAutoRead(&mem);
assert(status == SUCCESS);
status = S25FL032P_Erase4KB(&mem, 0); /* Erase the first 4KB sector */
assert(status == SUCCESS);
status = S25FL032P_Program(&mem, /* Program some data */
0, /* Starting address to be written */
data, /* Pointer to the data */
sizeof(data)); /* Number of bytes to be programmed */
assert(status == SUCCESS);
}