Flash IAP driver. More...
#include <FlashIAP.h>
Public Member Functions | |
int | init () |
Initialize a flash IAP device. More... | |
int | deinit () |
Deinitialize a flash IAP device. More... | |
int | read (void *buffer, uint32_t addr, uint32_t size) |
Read data from a flash device. More... | |
int | program (const void *buffer, uint32_t addr, uint32_t size) |
Program data to pages. More... | |
int | erase (uint32_t addr, uint32_t size) |
Erase sectors. More... | |
uint32_t | get_sector_size (uint32_t addr) const |
Get the sector size at the defined address. More... | |
uint32_t | get_flash_start () const |
Get the flash start address. More... | |
uint32_t | get_flash_size () const |
Get the flash size. More... | |
uint32_t | get_page_size () const |
Get the program page size. More... | |
uint8_t | get_erase_value () const |
Get the flash erase value. More... | |
Flash IAP driver.
It invokes flash HAL functions.
Definition at line 59 of file FlashIAP.h.
int deinit | ( | ) |
Deinitialize a flash IAP device.
int erase | ( | uint32_t | addr, |
uint32_t | size | ||
) |
Erase sectors.
The state of an erased sector is undefined until it has been programmed
addr | Address of a sector to begin erasing, must be a multiple of the sector size |
size | Size to erase in bytes, must be a multiple of the sector size |
uint8_t get_erase_value | ( | ) | const |
Get the flash erase value.
Get the value we read after erase operation
uint32_t get_flash_size | ( | ) | const |
Get the flash size.
uint32_t get_flash_start | ( | ) | const |
Get the flash start address.
uint32_t get_page_size | ( | ) | const |
Get the program page size.
The page size defines the writable page size
uint32_t get_sector_size | ( | uint32_t | addr | ) | const |
Get the sector size at the defined address.
Sector size might differ at address ranges. An example <0-0x1000, sector size=1024; 0x10000-0x20000, size=2048>
addr | Address of or inside the sector to query |
int init | ( | ) |
Initialize a flash IAP device.
Should be called once per lifetime of the object.
int program | ( | const void * | buffer, |
uint32_t | addr, | ||
uint32_t | size | ||
) |
Program data to pages.
The sectors must have been erased prior to being programmed
buffer | Buffer of data to be written |
addr | Address of a page to begin writing to |
size | Size to write in bytes, must be a multiple of program size |
int read | ( | void * | buffer, |
uint32_t | addr, | ||
uint32_t | size | ||
) |
Read data from a flash device.
This method invokes memcpy - reads number of bytes from the address
buffer | Buffer to write to |
addr | Flash address to begin reading from |
size | Size to read in bytes |