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:
- 34:601effb7b7fe
- Parent:
- 33:5b90257d2d57
- Child:
- 35:fc800d35c1ba
diff -r 5b90257d2d57 -r 601effb7b7fe Flash/flash_programming.cpp
--- a/Flash/flash_programming.cpp Sun Jan 21 13:04:06 2018 +0000
+++ b/Flash/flash_programming.cpp Wed Feb 14 03:56:34 2018 +0000
@@ -38,7 +38,7 @@
return ReturnValue;
}
-int FP_WriteRelayStates(uint8_t RelayState1, uint8_t RelayState2) {
+int FP_WriteRelayStates(uint8_t RelayState1, uint8_t RelayState2, uint8_t RelayState3) {
uint8_t CurrentPage = FP_GetPage(RELAY_BASE_ADDRESS);
uint32_t CurrentAddress = RELAY1_ADDRESS;
@@ -53,7 +53,8 @@
HAL_FLASH_Unlock();
if ((FP_ReadValue(RELAY1_ADDRESS) == RelayState1) &&
- (FP_ReadValue(RELAY2_ADDRESS) == RelayState2)) {
+ (FP_ReadValue(RELAY2_ADDRESS) == RelayState2) &&
+ (FP_ReadValue(RELAY3_ADDRESS) == RelayState3)) {
printf("Relay values don't change, no need to write\r\n");
HAL_FLASH_Lock();
return PASSED;
@@ -61,7 +62,7 @@
if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK) {
printf("Erase error, error num %d\r\n", HAL_FLASH_GetError());
}
- while (CurrentAddress < (RELAY2_ADDRESS + STEP_ADDRESS)) {
+ while (CurrentAddress < (RELAY3_ADDRESS + STEP_ADDRESS)) {
switch (CurrentAddress) {
case (RELAY1_ADDRESS): if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, CurrentAddress, RelayState1) == HAL_OK) {
printf("Write Relay 1 State OK\r\n");
@@ -76,6 +77,12 @@
else {
printf("Write Relay 2 State failed, error num %d\r\n", HAL_FLASH_GetError());
}
+ case (RELAY3_ADDRESS): if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, CurrentAddress, RelayState3) == HAL_OK) {
+ printf("Write Relay 3 State OK\r\n");
+ }
+ else {
+ printf("Write Relay 3 State failed, error num %d\r\n", HAL_FLASH_GetError());
+ }
break;
default: break;
}
@@ -83,7 +90,7 @@
}
CurrentAddress = RELAY1_ADDRESS;
- while (CurrentAddress < (RELAY2_ADDRESS + STEP_ADDRESS)) {
+ while (CurrentAddress < (RELAY3_ADDRESS + STEP_ADDRESS)) {
switch (CurrentAddress) {
case (RELAY1_ADDRESS): if (FP_ReadValue(CurrentAddress) == RelayState1) {
printf("Read back Relay 1 State: %d\r\n", FP_ReadValue(CurrentAddress));
@@ -103,6 +110,15 @@
return FAILED;
}
break;
+ case (RELAY3_ADDRESS): if (FP_ReadValue(CurrentAddress) == RelayState3) {
+ printf("Read back Relay 3 State: %d\r\n", FP_ReadValue(CurrentAddress));
+ }
+ else {
+ printf("Write Relay 3 State failed, wrong read back value\r\n");
+ HAL_FLASH_Lock();
+ return FAILED;
+ }
+ break;
default: break;
}
CurrentAddress = CurrentAddress + STEP_ADDRESS;