为了方便在APP中跳转到Boot重新进行升级,有两种办法,7840同样可以使用。
1. 调用reset接口进行复位,复位后会先进Boot,再自动跳转到App。
NVIC_SystemReset();
2. 直接使用跳转指令,参考Boot跳转到App代码,把跳转地址改一下即可,然后在App中调用JumpTOBoot。
代码如下:
#define IAP_BOOTLOAD_ADDRESS 0x8000000 /* define bootload start address */
typedef void (*pFunction)(void);
static pFunction s_jumpToApplication;void JumpTOBoot(void)
{uint32_t JumpAddress;if (((*(__IO uint32_t *)APP_ADDRESS) & 0x2FFE0000) == 0x20000000){__ASM("CPSID I"); // 关全局中断JumpAddress = *(__IO uint32_t *)(IAP_BOOTLOAD_ADDRESS + 4); // Jump to user applications_jumpToApplication = (pFunction)JumpAddress; // Initialize user application's Stack Pointer__set_MSP(*(__IO uint32_t *)IAP_BOOTLOAD_ADDRESS);s_jumpToApplication(); /* jump to app */}else{printf("top of stack pointer is unvalid! enter Boot update!\r\n");return;}while (1);
}