| Summary |
#include <file_config.h>
BOOL ReadData ( /* Optional, NULL for memory-mapped Flash */
U32 adr, /* data page address */
U32 sz, /* size of the data page */
U8* buf); /* buffer to read data to */
|
| Description | The function ReadData reads data from a Flash memory device to a buffer. The parameter adr specifies the starting address and must be 4-byte aligned. The parameter sz specifies the size to read and must be a multiple of 4. The parameter buf stores the data that have been read. The function is part of the Flash Driver. The prototype is defined in the file File_Config.h. Developers must customize the function. This function is optional. For parallel memory-mapped Flash device set the value for this function to NULL in the driver control block. This instructs RL-FlashFS to use the internal function memcpy to read data. |
| Example |
/* Embedded Flash Device Driver Control Block */
EFS_DRV sf0_drv = {
Init,
UnInit,
ReadData,
ProgramPage,
EraseSector,
EraseChip
};
/* Read a block of Data from SPI Flash Memory. */
static BOOL ReadData (U32 adr, U32 sz, U8 *buf) {
spi->SetSS (0);
spi->Send (SPI_READ_DATA);
spi->Send ((U8)(adr >> 16));
spi->Send ((U8)(adr >> 8));
spi->Send ((U8)(adr >> 0));
spi->RecBuf (buf, sz);
spi->SetSS (1);
return (__TRUE);
}
/* Embedded Flash Device Driver Control Block */
EFS_DRV sf0_drv = {
Init,
UnInit,
NULL, /* use internal memcpy function to read data */
ProgramPage,
EraseSector,
EraseChip
};
|