-
Notifications
You must be signed in to change notification settings - Fork 0
Flash memory support
Loviisa Flash Driver (LFD) is a separate module that provides a framework for multiple flash memory drivers including internal and external flash modules. Because of the specific of flash memory access that shall be performed rapidly for relatively large blocks, Loviisa flash driver framework doesn't use events/messaging model working with direct calls.
LFD supports multiple flash drivers, each of them shall provide five methods with standard signatures:
LVS_ERROR_T flash_erase_method(unsigned int address); erases flash page starting from the given address
LVS_ERROR_T flash_init_method(); initializes flash memory
LVS_DRV_FLASH_CONFIG* flash_get_config_method(void); retrieves basic flash parameters
LVS_ERROR_T flash_write_method(unsigned int address, unsigned char* data, int size); writes data block to flash
LVS_ERROR_T flash_read_method(unsigned int address, unsigned char* data, int size); reads data block from flash
Names of methods can be any, just provided to LVS_DRV_DEFINE_FLASH definition.
typedef struct __LVS_DRV_FLASH_CONFIG
{
unsigned long base_address; // Start address, shall differ for each supported flash
unsigned long size; // Size of flash memory
unsigned int page_size; // Page size for erase operation
} LVS_DRV_FLASH_CONFIG;Flash driver must use:
LVS_DRV_DEFINE_FLASH(name, mInit, mGetConfig, mErase, mRead, mWrite) to define flash memory bank with given name and provide five methods to access it like described above.
LVS_DRV_USE_FLASH(name) is for declaration of the flash memory outside of the flash driver.
LVS_DRV_INIT_FLASH(name) must be called by initialization routine to setup the flash bank and device.
Program shall use the following three methods to access flash memory:
LVS_ERROR_T lvs_FlashErase(unsigned long address);
LVS_ERROR_T lvs_FlashWrite(unsigned long address, unsigned char* data, int size);
LVS_ERROR_T lvs_FlashRead(unsigned long address, unsigned char* data, int size);The methods used for all memory devices and banks used in the system selecting proper device with using base address (and size) provided by Get Configuration method of each flash memory driver. It lets higher level modules use several flash devices for a single purpose (for example for the file system).