STM32: adjust flash.get_page_size() to minimum programable size

Users of FlashIAP usually get the minimum programable size
by calling flash.get_page_size(), so let's return the minimum
to allows a most efficient usage of flash.

For F4 devices, this is 1 byte.
For L0 and L1 devices, this is a word (4 bytes).
For L4 devices, this is a double word (8 bytes).
pull/4980/head
Laurent MEUNIER 2017-08-24 11:49:22 +02:00
parent 3de2ce9c10
commit e6631c02a4
4 changed files with 9 additions and 6 deletions

View File

@ -129,9 +129,10 @@ uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
uint32_t flash_get_page_size(const flash_t *obj) uint32_t flash_get_page_size(const flash_t *obj)
{ {
// not applicable for STM32F4 // Flash of STM32F4 devices can be programed 1 byte at a time
return (0x4000); // minimum sector size return (1);
} }
uint32_t flash_get_start_address(const flash_t *obj) uint32_t flash_get_start_address(const flash_t *obj)
{ {
return FLASH_BASE; return FLASH_BASE;

View File

@ -128,7 +128,8 @@ uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address) {
} }
uint32_t flash_get_page_size(const flash_t *obj) { uint32_t flash_get_page_size(const flash_t *obj) {
return FLASH_PAGE_SIZE; /* Page size is the minimum programable size, which 4 bytes */
return 4;
} }
uint32_t flash_get_start_address(const flash_t *obj) { uint32_t flash_get_start_address(const flash_t *obj) {

View File

@ -127,7 +127,8 @@ uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
uint32_t flash_get_page_size(const flash_t *obj) uint32_t flash_get_page_size(const flash_t *obj)
{ {
return FLASH_PAGE_SIZE; /* Page size is the minimum programable size, which 4 bytes */
return 4;
} }
uint32_t flash_get_start_address(const flash_t *obj) uint32_t flash_get_start_address(const flash_t *obj)

View File

@ -221,8 +221,8 @@ uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address) {
* @return The size of a page * @return The size of a page
*/ */
uint32_t flash_get_page_size(const flash_t *obj) { uint32_t flash_get_page_size(const flash_t *obj) {
/* considering 1 sector = 1 page */ /* Page size is the minimum programable size, which 8 bytes */
return FLASH_PAGE_SIZE; return 8;
} }
/** Get start address for the flash region /** Get start address for the flash region