/******************************************************************************* * File Name : Reboot.c * Description : * Created on : 2018Äê7ÔÂ23ÈÕ * Author : ¶Å¼ü *******************************************************************************/ /******************************************************************************* * Include Files * *******************************************************************************/ #include "stm32f4xx_hal.h" #include "Reboot.h" #include "HIDO_Timer.h" /******************************************************************************* * Macro * *******************************************************************************/ /******************************************************************************* * Type Definition * *******************************************************************************/ /******************************************************************************* * Local Variable * *******************************************************************************/ static HIDO_UINT32 l_u32RebootTimerID = 0; /******************************************************************************* * Local Function Declaration * *******************************************************************************/ /******************************************************************************* * Local Function * *******************************************************************************/ /******************************************************************************* * Function Name : Reboot_TimerCallback * Description : ¸´Î»¶¨Ê±Æ÷»Øµ÷º¯Êý * Input : _pArg ¶¨Ê±Æ÷²ÎÊý * Output : None * Return : None * Author : ¶Å¼ü * Modified Date: : 2018Äê7ÔÂ23ÈÕ *******************************************************************************/ static HIDO_VOID Reboot_TimerCallback(HIDO_VOID *_pArg) { __ASM("CPSID I"); SCB->AIRCR = ((HIDO_UINT32) 0x05FA0000) | (HIDO_UINT32) 0x04; __DSB(); } /******************************************************************************* * Global Function * *******************************************************************************/ /******************************************************************************* * Function Name : Reboot_TimerCallback * Description : ¸´Î»¶¨Ê±Æ÷»Øµ÷º¯Êý * Input : _u32DelayMs ÑÓʱµÄºÁÃëÊý * Output : None * Return : None * Author : ¶Å¼ü * Modified Date: : 2018Äê7ÔÂ23ÈÕ *******************************************************************************/ HIDO_VOID Reboot(HIDO_UINT32 _u32DelayMs) { if(0 == _u32DelayMs) { Reboot_TimerCallback(HIDO_NULL); } else { HIDO_TimerStart(l_u32RebootTimerID, HIDO_TIMER_TYPE_ONCE, HIDO_TIMER_TICK_MS(_u32DelayMs), Reboot_TimerCallback, HIDO_NULL); } } /******************************************************************************* * Function Name : Reboot_Init * Description : ¸´Î»³õʼ»¯½Ó¿Ú * Input : _pArg ¶¨Ê±Æ÷²ÎÊý * Output : None * Return : HIDO_OK ³É¹¦ * HIDO_ERR ʧ°Ü * Author : ¶Å¼ü * Modified Date: : 2018Äê7ÔÂ23ÈÕ *******************************************************************************/ HIDO_INT32 Reboot_Init(void) { if(HIDO_TimerCreate(&l_u32RebootTimerID) != HIDO_OK) { return HIDO_ERR; } return HIDO_OK; }