lpcware

how to use spifi lib

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by asv-lab on Sun Jan 05 04:43:56 MST 2014
how to use spifi api, read write erase?

//---------------------------------------------------------------------------------------------------//
void at25df_Read(void* buffer, uint32_t addrsoffsetstruct, uint32_t sizett) {

opers.dest = (char *) (obj.base + addrsoffsetstruct);
opers.length = sizett;
opers.scratch = NULL;
opers.protect = 0;
opers.options = S_VERIFY_PROG;

// Read Device
if (pSpifi->spifi_program(&obj, (char *) buffer, &opers)) {
UART_printf("ERROR Read.....\r\n");

} else {
UART_printf("Read flash ok.....\r\n");
}

}
//---------------------------------------------------------------------------------------------------//
void at25df_Erase(uint32_t addrsoffsetstruct, uint32_t sizett) {

opers.dest = (char *) (obj.base + addrsoffsetstruct);
opers.length = sizett;
opers.scratch = NULL;
opers.options = S_VERIFY_ERASE;
opers.protect = 0;

// Erase Device
if (pSpifi->spifi_erase(&obj, &opers)) {
UART_printf("ERROR Erace.....\r\n");

} else {
UART_printf("Erace flash ok.....\r\n");
}

}
//---------------------------------------------------------------------------------------------------//
void at25df_Write(void* buffer, uint32_t addrsoffsetstruct, uint32_t sizett) {

opers.length = sizett;
opers.scratch = NULL;
opers.protect = 0;
opers.options = S_CALLER_ERASE;
opers.dest = (char *) (obj.base + addrsoffsetstruct);

if (pSpifi->spifi_program(&obj, (char *) buffer, &opers)) {
UART_printf("ERROR write....\r\n");
} else {
UART_printf("Write flash ok.....\r\n");
}

}
//---------------------------------------------------------------------------------------------------//

Thanks

Outcomes