From: Tilman Sauerbeck Date: Sun, 7 Jul 2019 07:49:05 +0000 (+0200) Subject: common: Implement jump_to_application(). X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;h=206f765a129a285e5db70505d2c1154564046ac8;p=gps-watch.git common: Implement jump_to_application(). --- diff --git a/src/common/startup.c b/src/common/startup.c index daa8906..0a5507a 100644 --- a/src/common/startup.c +++ b/src/common/startup.c @@ -150,3 +150,17 @@ Dummy_Handler (void) for (;;) { } } + +void +jump_to_application (volatile uint32_t *address) +{ + volatile uint32_t *vtor = (uint32_t *) 0xe000ed08; + *vtor = (uint32_t) address; + + asm volatile ("" ::: "memory"); + asm volatile ("msr msp, %0" :: "r" (*(address + 0)) : "sp"); + asm volatile ("bx %0" :: "r" (*(address + 1))); + + for (;;) { + } +}