kopia lustrzana https://github.com/micropython/micropython
stm32/flash: Remove commented-out flash functions.
Signed-off-by: Damien George <damien@micropython.org>pull/13141/head
rodzic
7002a19be2
commit
cd0f75069c
|
@ -355,35 +355,6 @@ int flash_erase(uint32_t flash_dest, uint32_t num_word32) {
|
||||||
return mp_hal_status_to_neg_errno(status);
|
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) {
|
int flash_write(uint32_t flash_dest, const uint32_t *src, uint32_t num_word32) {
|
||||||
#if MICROPY_HW_STM32WB_FLASH_SYNCRONISATION
|
#if MICROPY_HW_STM32WB_FLASH_SYNCRONISATION
|
||||||
// Acquire lock on the flash peripheral.
|
// 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);
|
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();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
@ -159,25 +159,6 @@ static void flash_bdev_irq_handler(void) {
|
||||||
return;
|
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
|
// This code erases the flash directly, waiting for it to finish
|
||||||
if (!(flash_flags & FLASH_FLAG_ERASED)) {
|
if (!(flash_flags & FLASH_FLAG_ERASED)) {
|
||||||
flash_erase(flash_cache_sector_start, flash_cache_sector_size / 4);
|
flash_erase(flash_cache_sector_start, flash_cache_sector_size / 4);
|
||||||
|
|
Ładowanie…
Reference in New Issue