eCos初探之redboot重启命令:reset
环境参数: 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)
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。