GlobLib
HAL and API libraries for MCUs and hardware.
|
This module contains functions for modifing internal flash memory. More...
Files | |
file | stm32f103cb_flash.h |
Header file for stm32f103cb FLASH. | |
Functions | |
mcu_error | FLASH_clearPage (uint32_t pageNumber) |
Clear a page (1kb) of flash. More... | |
mcu_error | FLASH_write (uint32_t pageNumber, uint32_t address, uint32_t data) |
Write a single word to flash. More... | |
mcu_error | FLASH_writes (uint32_t pageNumber, uint32_t address, uint32_t *data, uint16_t size) |
Write multiple words to flash, address incremented automatically. More... | |
uint32_t | FLASH_read (uint32_t pageNumber, uint32_t address) |
Read a single word from flash memory. More... | |
mcu_error | FLASH_reads (uint32_t pageNumber, uint32_t address, uint32_t *data, uint16_t size) |
Read multiple words from flash. More... | |
mcu_error | FLASH_readPage (uint32_t pageNumber, uint32_t *data) |
Read an entire page from flash. More... | |
uint8_t | FLASH_pageEmpty (uint32_t pageNumber) |
Determine if a given page is empty. More... | |
uint8_t | FLASH_firstEmptyPage (void) |
Get the first empty page is flash. More... | |
This module contains functions for modifing internal flash memory.
The STM32f1x3 has 128kb of programmable flash memory. This space can also be used to store user values at runtime. It has the following restrictions
It can be benificial to occasionally clear all flash memory, this ensures the data occupying the flash memory is being used. This can be acheived with "make erase" from program directory.
Flash memory can only be changed from 1 to 0. This means each location needs to be reset with FLASH_clearPage() before it is writted again.
This module provides access to the flash memory. Typically pages toward the module (pages 120 - 127) should be used. The exact location of the free portion not used by code can be found by looking at the "text" section when the program is compiled.
Each page contains 256 words (32 bit) segments which can be used.
mcu_error FLASH_clearPage | ( | uint32_t | pageNumber | ) |
Clear a page (1kb) of flash.
This needs to be used if the same memory location is used multiple times.
Flash memory can only be changed from 1 to 0. This means each location needs to be reset with FLASH_clearPage() before it is written again.
pageNumber | The page to clear (0-127) |
Definition at line 22 of file stm32f103cb_flash.c.
uint8_t FLASH_firstEmptyPage | ( | void | ) |
Get the first empty page is flash.
Definition at line 158 of file stm32f103cb_flash.c.
uint8_t FLASH_pageEmpty | ( | uint32_t | pageNumber | ) |
Determine if a given page is empty.
pageNumber | The page to check. (0-127) |
Definition at line 142 of file stm32f103cb_flash.c.
uint32_t FLASH_read | ( | uint32_t | pageNumber, |
uint32_t | address | ||
) |
Read a single word from flash memory.
pageNumber | The page to read from. (0-127) |
address | The word in that page (0-255) |
Definition at line 88 of file stm32f103cb_flash.c.
mcu_error FLASH_readPage | ( | uint32_t | pageNumber, |
uint32_t * | data | ||
) |
Read an entire page from flash.
pageNumber | The page to read from. (0-127) |
data | Pointer to a memory container large enough to hold the data |
Definition at line 119 of file stm32f103cb_flash.c.
mcu_error FLASH_reads | ( | uint32_t | pageNumber, |
uint32_t | address, | ||
uint32_t * | data, | ||
uint16_t | size | ||
) |
Read multiple words from flash.
pageNumber | The page to read from. (0-127) |
address | The word in that page to start from (0-255) |
data | Pointer to a memory container large enough to hold the data |
size | The size of parameter data |
Definition at line 96 of file stm32f103cb_flash.c.
mcu_error FLASH_write | ( | uint32_t | pageNumber, |
uint32_t | address, | ||
uint32_t | data | ||
) |
Write a single word to flash.
A word can only be written to a location once before FLASH_clearPage() is used to reset the memory location
It is possible to use a word address greater than 255. This means that the data will be located in the next page.
pageNumber | The page to write to (0-127) |
address | The word in that page (0-255) |
data | The data to write to the location |
Definition at line 41 of file stm32f103cb_flash.c.
mcu_error FLASH_writes | ( | uint32_t | pageNumber, |
uint32_t | address, | ||
uint32_t * | data, | ||
uint16_t | size | ||
) |
Write multiple words to flash, address incremented automatically.
A word can only be written to a location once before FLASH_clearPage() is used to reset the memory location
It is possible to use a word address greater than 255. This means that the data will be located in the next page.
pageNumber | The page to write to (0-127) |
address | The word in that page (0-255) |
data | Pointer to the data to write to the location |
size | The size of parameter data |
Definition at line 61 of file stm32f103cb_flash.c.