Changeset - 20618713ba15
[Not reviewed]
default
0 1 0
matthewreed - 7 years ago 2017-10-05 14:15:30

Updated flash to support newest HAL library
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/flash.c
Show inline comments
 
@@ -43,27 +43,27 @@ static void __flash_write(flash_settings
 
 
    // Erase mem
 
    HAL_FLASH_Unlock();
 
 
    // Erase the FLASH pages
 
    FLASH_EraseInitTypeDef erase;
 
    erase.TypeErase = TYPEERASE_PAGES;
 
    erase.TypeErase = FLASH_TYPEERASE_PAGES;
 
    erase.PageAddress = (uint32_t) eeprom;
 
    erase.NbPages = 1;
 
    uint32_t SectorError = 0;
 
    HAL_FLASHEx_Erase(&erase, &SectorError);
 
    CLEAR_BIT(FLASH->CR, FLASH_CR_PER);
 
 
    // write to flash and calculate the checksum
 
    uint16_t checksum = MAGIC_NUMBER;
 
    uint16_t i;
 
    for(i = 0; i < (sizeof(flash_settings_t)/2); i++)
 
    {
 
        HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, (uint32_t)&eeprom[i], tosave->data[i]);
 
        HAL_FLASH_Program(FLASH_PROC_PROGRAMHALFWORD, (uint32_t)&eeprom[i], tosave->data[i]);
 
        checksum ^= tosave->data[i];
 
    }
 
 
    // write the checksum
 
    HAL_FLASH_Program(TYPEPROGRAM_HALFWORD, (uint32_t)&eeprom[i+1], checksum);
 
    HAL_FLASH_Program(FLASH_PROC_PROGRAMHALFWORD, (uint32_t)&eeprom[i+1], checksum);
 
 
    HAL_FLASH_Lock();
 
}
0 comments (0 inline, 0 general)