代码x 实现app_jump_to_image()函数
typedef void(*func_0_t)(void);
volatile uint32_t sp_base;
volatile uint32_t pc_base;
void app_jump_to_image(void * addr)
{
uint32_t * vectorTable = (uint32_t *)addr;
sp_base = vectorTable[0];
pc_base = vectorTable[1];
/* set new MSP and PSP.
* when the SP is changed, the address of variables in stack would be remapped according to the new SP.
*/
__set_MSP(sp_base);
__set_PSP(sp_base);
#if __VTOR_PRESENT == 1
SCB->VTOR = (uint32_t)addr; /* the func's param is kept in R1 register, which would not be changed per the SP update. */
#endif
/* jump to application. */
((func_0_t)(pc_base))();
//pc_func();
/* the code should never reach here. */
while (1)
{}
}
|
———————————————— 版权声明:本文为CSDN博主「suyong_yq」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/suyong_yq/article/details/126348057