bootloader.c 1002 B

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