__ASM __STATIC_INLINE void jump_to_addr(uint32_t new_msp, uint32_t new_lr, uint32_t addr)
{
MSR MSP, R0;
MOV LR, R1;
BX R2;
}
void jt_jump_to_app(void)
{
sd_mbr_command_t command =
{
.command = SD_MBR_COMMAND_IRQ_FORWARD_ADDRESS_SET,
.params.irq_forward_address_set.address = 0x1000,
};
sd_mbr_command(&command);
const uint32_t current_isr_num = (__get_IPSR() & IPSR_ISR_Msk);
const uint32_t new_msp = *((uint32_t *)(VECT_TAB_OFFSET)); // The app's Stack Pointer is found as the first word of the vector table.
const uint32_t reset_handler = *((uint32_t *)(VECT_TAB_OFFSET + sizeof(uint32_t))); // The app's Reset Handler is found as the second word of the vector table.
const uint32_t new_lr = 0xFFFFFFFF;
__set_CONTROL(0x00000000); // Set CONTROL to its reset value 0.
__set_PRIMASK(0x00000000); // Set PRIMASK to its reset value 0.
__set_BASEPRI(0x00000000); // Set BASEPRI to its reset value 0.
__set_FAULTMASK(0x00000000); // Set FAULTMASK to its reset value 0.
jump_to_addr(new_msp, new_lr, reset_handler);
}