Update ee.c

This commit is contained in:
Nima Askari ----- نیما عسکری 2021-03-05 11:17:26 +03:30 committed by GitHub
parent 2b14f9ae9b
commit 03532e8fc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

32
ee.c
View File

@ -251,23 +251,23 @@ bool ee_write(uint32_t startVirtualAddress, uint32_t len, uint8_t *data)
HAL_FLASH_Unlock(); HAL_FLASH_Unlock();
#ifdef FLASH_TYPEPROGRAM_BYTE #ifdef FLASH_TYPEPROGRAM_BYTE
for (uint32_t i = 0; i < len ; i++) 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) if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, ((i + startVirtualAddress)) + _EE_ADDR_INUSE, (uint64_t)(data[i])) != HAL_OK)
{ {
HAL_FLASH_Lock(); HAL_FLASH_Lock();
return false; return false;
} }
} }
#endif #endif
#ifdef FLASH_TYPEPROGRAM_HALFWORD #ifdef FLASH_TYPEPROGRAM_HALFWORD
for (uint32_t i = 0; i < len ; i+=2) 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) 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(); HAL_FLASH_Lock();
return false; return false;
} }
} }
#endif #endif
#ifdef FLASH_TYPEPROGRAM_DOUBLEWORD #ifdef FLASH_TYPEPROGRAM_DOUBLEWORD
for (uint32_t i = 0; i < len; i += 8) 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 #endif
HAL_FLASH_Lock(); HAL_FLASH_Lock();
return true; return true;
} }
//########################################################################################################## //##########################################################################################################
bool ee_writeToRam(uint32_t startVirtualAddress, uint32_t len, uint8_t* data) bool ee_writeToRam(uint32_t startVirtualAddress, uint32_t len, uint8_t* data)