Rom_check.c 622 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "Rom_check.h"
  2. #include "stm32f1xx_hal.h"
  3. #include "flash_if.h"
  4. #include "RefreshMenu.h"
  5. #include "crc.h"
  6. uint8_t RomCheck(void)
  7. {
  8. uint32_t index,crc_result;
  9. uint32_t romSize_byte,romSize_words;
  10. __HAL_CRC_DR_RESET(&hcrc);
  11. //romSize_byte = 0x35c0;
  12. romSize_byte = (downLoad.packageSize - 4);
  13. romSize_words = romSize_byte / 4;
  14. for(index = 0; index < romSize_words; index++)
  15. {
  16. CRC->DR = (*((uint32_t *)APPLICATION_ADDRESS + index));
  17. }
  18. crc_result = CRC->DR;
  19. if(crc_result != *(uint32_t *)(APPLICATION_ADDRESS + romSize_byte))
  20. {
  21. return ERROR;
  22. }
  23. return SUCCESS ;
  24. }