From 03532e8fc969b333f6c8631dcfec9a4e36616ba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nima=20Askari=20-----=20=D9=86=DB=8C=D9=85=D8=A7=20=D8=B9?= =?UTF-8?q?=D8=B3=DA=A9=D8=B1=DB=8C?= Date: Fri, 5 Mar 2021 11:17:26 +0330 Subject: [PATCH] Update ee.c --- ee.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ee.c b/ee.c index fe0399b..f02c5ae 100644 --- a/ee.c +++ b/ee.c @@ -251,23 +251,23 @@ bool ee_write(uint32_t startVirtualAddress, uint32_t len, uint8_t *data) HAL_FLASH_Unlock(); #ifdef FLASH_TYPEPROGRAM_BYTE for (uint32_t i = 0; i < len ; i++) - { - if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, ((i + startVirtualAddress)) + _EE_ADDR_INUSE, (uint64_t)(data[i])) != HAL_OK) - { - HAL_FLASH_Lock(); - return false; - } - } + { + if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, ((i + startVirtualAddress)) + _EE_ADDR_INUSE, (uint64_t)(data[i])) != HAL_OK) + { + HAL_FLASH_Lock(); + return false; + } + } #endif #ifdef FLASH_TYPEPROGRAM_HALFWORD for (uint32_t i = 0; i < len ; i+=2) - { - if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, ((i + startVirtualAddress)) + _EE_ADDR_INUSE, (uint64_t)(data[i] | (data[i+1] << 8))) != HAL_OK) - { - HAL_FLASH_Lock(); - return false; - } - } + { + if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, ((i + startVirtualAddress)) + _EE_ADDR_INUSE, (uint64_t)(data[i] | (data[i+1] << 8))) != HAL_OK) + { + HAL_FLASH_Lock(); + return false; + } + } #endif #ifdef FLASH_TYPEPROGRAM_DOUBLEWORD for (uint32_t i = 0; i < len; i += 8) @@ -287,8 +287,8 @@ bool ee_write(uint32_t startVirtualAddress, uint32_t len, uint8_t *data) } } #endif - HAL_FLASH_Lock(); - return true; + HAL_FLASH_Lock(); + return true; } //########################################################################################################## bool ee_writeToRam(uint32_t startVirtualAddress, uint32_t len, uint8_t* data)