Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: easy-connect-v16 Watchdog FP MQTTPacket RecordType-v-16 watersenor_and_temp_code
Diff: Flash/flash_programming.cpp
- Revision:
- 38:64e3e9acb49c
- Parent:
- 35:fc800d35c1ba
- Child:
- 43:dcde0e66874a
--- a/Flash/flash_programming.cpp Wed Feb 14 14:56:00 2018 +0000 +++ b/Flash/flash_programming.cpp Mon Feb 19 14:18:22 2018 +0000 @@ -232,4 +232,43 @@ } HAL_FLASH_Lock(); return PASSED; +} + +int FP_WriteConfigValues(uint32_t SaturationDoVoltage) { + uint8_t CurrentPage = FP_GetPage(SAT_DO_VOLT_ADDRESS); + uint32_t CurrentAddress = SAT_DO_VOLT_ADDRESS; + EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES; + EraseInitStruct.Banks = FLASH_BANK_1; + EraseInitStruct.Page = CurrentPage; + EraseInitStruct.NbPages = 1; + + if (FP_ClearFlags() != PASSED) { + return FAILED; + } + HAL_FLASH_Unlock(); + + if ((FP_ReadValue(SAT_DO_VOLT_ADDRESS) == SaturationDoVoltage)) { + printf("Configuration values doesn't change, no need to write\r\n"); + HAL_FLASH_Lock(); + return PASSED; + } + if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK) { + printf("Erase error, error num %d\r\n", HAL_FLASH_GetError()); + } + if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, CurrentAddress, SaturationDoVoltage) == HAL_OK) { + printf("Write SaturationDoVoltage OK\r\n"); + } + else { + printf("Write SaturationDoVoltage failed, error num %d\r\n", HAL_FLASH_GetError()); + } + if (FP_ReadValue(CurrentAddress) == SaturationDoVoltage) { + printf("Read back SaturationDoVoltage: %d\r\n", FP_ReadValue(CurrentAddress)); + } + else { + printf("Write SaturationDoVoltage failed, wrong read back value\r\n"); + HAL_FLASH_Lock(); + return FAILED; + } + HAL_FLASH_Lock(); + return PASSED; } \ No newline at end of file