代码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)
- {}
- }
|