diff options
| author | Damien George <damien@micropython.org> | 2023-11-01 16:05:21 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-01-08 12:31:03 +1100 |
| commit | cd0f75069cf7488d5b26760c3c9a2f357df919f3 (patch) | |
| tree | df4fdf3c233e52146e5f8c891dc196619787a5fd | |
| parent | 7002a19be2bbc598b6dcdef4db2dd37e7e7753c5 (diff) | |
stm32/flash: Remove commented-out flash functions.
Signed-off-by: Damien George <damien@micropython.org>
| -rw-r--r-- | ports/stm32/flash.c | 73 | ||||
| -rw-r--r-- | ports/stm32/flashbdev.c | 19 |
2 files changed, 0 insertions, 92 deletions
diff --git a/ports/stm32/flash.c b/ports/stm32/flash.c index a8f50dbcb..04448a118 100644 --- a/ports/stm32/flash.c +++ b/ports/stm32/flash.c @@ -355,35 +355,6 @@ int flash_erase(uint32_t flash_dest, uint32_t num_word32) { return mp_hal_status_to_neg_errno(status); } -/* -// erase the sector using an interrupt -void flash_erase_it(uint32_t flash_dest, uint32_t num_word32) { - // check there is something to write - if (num_word32 == 0) { - return; - } - - // unlock - HAL_FLASH_Unlock(); - - // Clear pending flags (if any) - __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | - FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR); - - // erase the sector(s) - FLASH_EraseInitTypeDef EraseInitStruct; - EraseInitStruct.TypeErase = TYPEERASE_SECTORS; - EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3; // voltage range needs to be 2.7V to 3.6V - EraseInitStruct.Sector = flash_get_sector_info(flash_dest, NULL, NULL); - EraseInitStruct.NbSectors = flash_get_sector_info(flash_dest + 4 * num_word32 - 1, NULL, NULL) - EraseInitStruct.Sector + 1; - if (HAL_FLASHEx_Erase_IT(&EraseInitStruct) != HAL_OK) { - // error occurred during sector erase - HAL_FLASH_Lock(); // lock the flash - return; - } -} -*/ - int flash_write(uint32_t flash_dest, const uint32_t *src, uint32_t num_word32) { #if MICROPY_HW_STM32WB_FLASH_SYNCRONISATION // Acquire lock on the flash peripheral. @@ -498,47 +469,3 @@ int flash_write(uint32_t flash_dest, const uint32_t *src, uint32_t num_word32) { return mp_hal_status_to_neg_errno(status); } - -/* - use erase, then write -void flash_erase_and_write(uint32_t flash_dest, const uint32_t *src, uint32_t num_word32) { - // check there is something to write - if (num_word32 == 0) { - return; - } - - // unlock - HAL_FLASH_Unlock(); - - // Clear pending flags (if any) - __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | - FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR); - - // erase the sector(s) - FLASH_EraseInitTypeDef EraseInitStruct; - EraseInitStruct.TypeErase = TYPEERASE_SECTORS; - EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3; // voltage range needs to be 2.7V to 3.6V - EraseInitStruct.Sector = flash_get_sector_info(flash_dest, NULL, NULL); - EraseInitStruct.NbSectors = flash_get_sector_info(flash_dest + 4 * num_word32 - 1, NULL, NULL) - EraseInitStruct.Sector + 1; - uint32_t SectorError = 0; - if (HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError) != HAL_OK) { - // error occurred during sector erase - HAL_FLASH_Lock(); // lock the flash - return; - } - - // program the flash word by word - for (int i = 0; i < num_word32; i++) { - if (HAL_FLASH_Program(TYPEPROGRAM_WORD, flash_dest, *src) != HAL_OK) { - // error occurred during flash write - HAL_FLASH_Lock(); // lock the flash - return; - } - flash_dest += 4; - src += 1; - } - - // lock the flash - HAL_FLASH_Lock(); -} -*/ diff --git a/ports/stm32/flashbdev.c b/ports/stm32/flashbdev.c index bcff94b15..19edde210 100644 --- a/ports/stm32/flashbdev.c +++ b/ports/stm32/flashbdev.c @@ -159,25 +159,6 @@ static void flash_bdev_irq_handler(void) { return; } - // This code uses interrupts to erase the flash - /* - if (flash_erase_state == 0) { - flash_erase_it(flash_cache_sector_start, flash_cache_sector_size / 4); - flash_erase_state = 1; - return; - } - - if (flash_erase_state == 1) { - // wait for erase - // TODO add timeout - #define flash_erase_done() (__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY) == RESET) - if (!flash_erase_done()) { - return; - } - flash_erase_state = 2; - } - */ - // This code erases the flash directly, waiting for it to finish if (!(flash_flags & FLASH_FLAG_ERASED)) { flash_erase(flash_cache_sector_start, flash_cache_sector_size / 4); |
