/** @(#)reset_mcu.c <17-Oct-2013 14:23:08 bob p> * \date Last Time-stamp: <09-Feb-2021 10:37:10 bob p> * * \file reset_mcu.c * \brief Force the MCU to reset. * * Alternative for chips without reset command: * * asm(" ldr r1, [r0,#0]"); // Get the stack pointer value from the program's reset vector * asm(" mov sp, r1"); // Copy the value to the stack pointer * asm(" ldr r0, [r0,#4]"); // Get the program counter value from the program's reset vector * asm(" blx r0"); // jump to the start address */ /*lint -save */ #include "compiler.h" #define DEFINE_SPACE_RESET_MCU_H (1) #include "reset_mcu.h" void __attribute__ ((noreturn)) reset_mcu( void ) { /* * A DSB is required before generating self-reset to ensure all * outstanding transfers are completed. The use of the CPSID I * instruction is optional. */ irq_disable(); sync_barrier_data(); #if( defined( MKL27 ) && (MKL27 == TARGET_CPU) ) SCB_AIRCR = (SCB_AIRCR_VECTKEY(0x05FAU) | SCB_AIRCR_SYSRESETREQ_MASK); #else __NVIC_SystemReset(); #endif for(;;) { ; } } /*lint -restore */