/** * Jump to CM vector table * * \param code_addr Application start address (vector table address) */ #if defined (__CC_ARM) /* Keil µVision 4 */ __asm__ void jump_to_app(void *code_addr) { mov r1, r0 ldr r0, [r1, # 4] ldr sp, [r1] blx r0 } #elif defined (__ICCARM__) /* IAR Ewarm 5.41+ */ void jump_to_app(void *code_addr) { UNUSED(code_addr); __asm( "mov r1, r0 \n" "ldr r0, [r1, #4] \n" "ldr sp, [r1] \n" "blx r0" ); } #elif defined (__GNUC__) /* GCC CS3 2009q3-68 */ void jump_to_app(void *code_addr) { __asm__( "mov r1, r0 \n" "ldr r0, [r1, #4] \n" "ldr sp, [r1] \n" "blx r0" ); } #else /* General C, no stack reset */ void jump_to_app(void *code_addr) { void (*pFct)(void) = NULL; /* Point on __main address located in the second word in vector table */ pFct = (void (*)(void))(*(uint32_t *)((uint32_t)code_addr + 4)); pFct(); }
//------------------------------------------------------------------------------ /// Jump to the first address to execute application //------------------------------------------------------------------------------ static void GoToJumpAddress(unsigned int jumpAddr, unsigned int matchType) { typedef void(*fctType)(volatile unsigned int, volatile unsigned int); void(*pFct)(volatile unsigned int r0_val, volatile unsigned int r1_val); pFct = (fctType)jumpAddr; pFct(0/*dummy value in r0*/, matchType/*matchType in r1*/); while(1);//never reach }