环境参数: eCos模版:redboot 硬件平台: STM32F103ZET6
void do_reset(int argc, char *argv[]) { diag_printf("... Resetting."); CYGACC_CALL_IF_DELAY_US(2*100000); diag_printf("\n"); CYGACC_CALL_IF_RESET(); diag_printf("!! oops, RESET not working on this platform\n"); }
#define CYGACC_CALL_IF_RESET() CYGACC_CALL_VV0(__call_if_reset_t*, CYGNUM_CALL_IF_RESET)() __call_voidVV0(CYGNUM_CALL_IF_RESET, __call_if_reset_t, void)
static __call_if_reset_t reset; static void reset(void) { CYGARC_HAL_SAVE_GP(); // With luck, the platform defines some magic that will cause a hardware // reset. #ifdef HAL_PLATFORM_RESET HAL_PLATFORM_RESET(); #endif #ifdef HAL_PLATFORM_RESET_ENTRY // If that's not the case (above is an empty statement) there may // be defined an address we can jump to - and effectively // reinitialize the system. Not quite as good as a reset, but it // is often enough. goto *HAL_PLATFORM_RESET_ENTRY; #else #error " no RESET_ENTRY" #endif CYG_FAIL("Reset failed"); CYGARC_HAL_RESTORE_GP(); }
#define HAL_PLATFORM_RESET_ENTRY &hal_reset_vsrhal_reset_vsr指向程序的主入口函数void hal_reset_vsr( void ),关于该函数,注释说明如下:
//========================================================================== // Main entry point // // Enter here from reset via slot 1 of VSR table. The stack pointer is // already set to the value in VSR slot 0, usually the top of internal // SRAM.下面着重讲下第一种(1)复位方式,它涉及到芯片的具体操作。
#define HAL_PLATFORM_RESET() { HAL_WRITE_UINT32(CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_AIRCR, CYGARC_REG_NVIC_AIRCR_KEY| CYGARC_REG_NVIC_AIRCR_SYSRESETREQ ); for(;;); }
_register_ = CYGARC_REG_NVIC_BASE+CYGARC_REG_NVIC_AIRCR = 0xE000E000 + 0xD0C = 0xE000ED0C _value_ = CYGARC_REG_NVIC_AIRCR_KEY | CYGARC_REG_NVIC_AIRCR_SYSRESETREQ = (0x5FA<<16) + (1<<2)
原文:http://blog.csdn.net/u013686019/article/details/43983097