boot.c 966 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "boot.h"
  2. #include "iap.h"
  3. #include <stdint.h>
  4. void run_app(void)
  5. {
  6. pFunction Jump_To_Application;
  7. __IO uint32_t JumpAddress;
  8. // CAN_DeInit(CAN1);
  9. if (((*(__IO uint32_t *)APP_START_ADDR) & 0x2FFE0000) == 0x20000000)
  10. {
  11. JumpAddress = *(__IO uint32_t *)(APP_START_ADDR + 4);
  12. Jump_To_Application = (pFunction)JumpAddress;
  13. __set_MSP(*(__IO uint32_t *)APP_START_ADDR);
  14. Jump_To_Application();
  15. }
  16. }
  17. uint8_t check_addr_sp(uint32_t addr)
  18. {
  19. int ret;
  20. if (((*(uint32_t *)addr) & 0x2FFE0000) == 0x20000000) // 检查栈顶地址是否合法
  21. {
  22. ret = VALID;
  23. }
  24. else
  25. {
  26. ret = INVALID;
  27. }
  28. return ret;
  29. }
  30. uint8_t check_addr_pc(uint32_t addr)
  31. {
  32. int ret;
  33. if (((*(uint32_t *)(addr + 4)) & 0xFF000000) == 0x08000000) // 检查中断向量表地址是否合法
  34. {
  35. ret = VALID;
  36. }
  37. else
  38. {
  39. ret = INVALID;
  40. }
  41. return ret;
  42. }