static void CheckIspMode(void)
{
// enable peripheral clock of RTC
RCU_REG_VAL(RCU_RTC) |= BIT(RCU_BIT_POS(RCU_RTC));
if(RTC_BKP0 == INTO_IAP)
{
// enable peripheral clocks of RTC and PMU
RCU_REG_VAL(RCU_PMU) |= BIT(RCU_BIT_POS(RCU_PMU));
// enable backup domain write
PMU_CTL |= PMU_CTL_BKPWEN;
RTC_BKP0 = 0;
__disable_irq();
__set_PRIMASK(1);
// 加个延时, 万一出现问题允许刚复位的时候SWD连接进来
for (volatile int i = 0; i < 2000000; i++) {
__NOP();
}
register void (*SysMemBootJump)(void);
register uint32_t SysMemBootJumpAddr = *(uint32_t *)(0x1FFF0000 + 4);
// 初始化堆栈指针
__set_MSP(*(__IO uint32_t*)0x1FFF0000);
SysMemBootJump = (void (*)(void))SysMemBootJumpAddr;
// 跳转到系统存储器
SysMemBootJump();
while(1);
}
}
|