Midnight Sun Firmware
|
Flash library. More...
Macros | |
#define | FLASH_MEMORY_ALIGNMENT 4U |
Flash memory must be aligned to 4-bytes since STM32 is 32-bit device. | |
#define | FLASH_BASE_ADDR (0x08000000U) |
Flash memory begins at 0x0800 0000 as per ARM specification. | |
#define | FLASH_PAGE_SIZE 0x800U |
Flash page size is 2Kbyte as per table 63. in STM32L433xx datasheet. | |
#define | FLASH_PAGE_TO_ADDR(page) (FLASH_BASE_ADDR + ((page)*FLASH_PAGE_SIZE)) |
Convert page number to a memory address. | |
#define | FLASH_ADDR_TO_PAGE(addr) (((addr)-FLASH_BASE_ADDR) / FLASH_PAGE_SIZE) |
Convert memory address to a page number. | |
#define | FLASH_TIMEOUT_MS 100U |
Maximum time permitted for a flash transaction. | |
#define | NUM_FLASH_PAGES 128U |
Total number of flash pages in the STM32L433CCU6. | |
Functions | |
StatusCode | flash_init () |
Initialize flash API. More... | |
StatusCode | flash_read (uintptr_t address, uint8_t *buffer, size_t buffer_len) |
Read from the flash memory and store data into a buffer. More... | |
StatusCode | flash_write (uintptr_t address, uint8_t *buffer, size_t buffer_len) |
Write a buffer of data into the flash memory. More... | |
StatusCode | flash_erase (uint8_t start_page, uint8_t num_pages) |
Erase pages of flash memory. More... | |
Flash library.
StatusCode flash_erase | ( | uint8_t | start_page, |
uint8_t | num_pages | ||
) |
Erase pages of flash memory.
start_page | First page to erase |
num_pages | Number of pages to erase |
StatusCode flash_init | ( | ) |
Initialize flash API.
This initializes the mutex used in the flash API
StatusCode flash_read | ( | uintptr_t | address, |
uint8_t * | buffer, | ||
size_t | buffer_len | ||
) |
Read from the flash memory and store data into a buffer.
address | Memory address to read from. This value MUST be 4-byte aligned |
buffer | Pointer to the buffer to store data |
buffer_len | Length of the buffer. This value MUST be 4-byte aligned |
StatusCode flash_write | ( | uintptr_t | address, |
uint8_t * | buffer, | ||
size_t | buffer_len | ||
) |
Write a buffer of data into the flash memory.
This does not rewrite the flash memory. Once written, the data must be cleared by erasing the entire page
address | Memory address to store the buffer. This value MUST be 4-byte aligned |
buffer | Pointer to the buffer of data to store |
buffer_len | Length of the buffer to write. This MUST also be 4-byte aligned |