/******************************************************************************* * File Name : Delay.c * Description : * Created on : 2019Äê8ÔÂ29ÈÕ * Author : www.hido-studio.com *******************************************************************************/ /******************************************************************************* * Include Files * *******************************************************************************/ #include "Delay.h" #include "stm32f4xx_hal.h" #include "HIDO_Lock.h" /******************************************************************************* * Macro * *******************************************************************************/ /******************************************************************************* * Type Definition * *******************************************************************************/ /******************************************************************************* * Local Variable * *******************************************************************************/ static TIM_HandleTypeDef *l_pstTimer; /******************************************************************************* * Local Function Declaration * *******************************************************************************/ /******************************************************************************* * Local Function * *******************************************************************************/ /******************************************************************************* * Global Function * *******************************************************************************/ /******************************************************************************* * Function Name : * Description : * Input : * Output : * Return : * Author : www.hido-studio.com * Modified Date: : 2019Äê7ÔÂ25ÈÕ *******************************************************************************/ void Delay_Us(HIDO_UINT16 _u16Us) { /* ʱ¼äÌ«¶Ì¿ÉÄÜ×¥²»µ½ */ if (_u16Us < 10) { _u16Us = 10; } //HIDO_Lock(); __HAL_TIM_SET_AUTORELOAD(l_pstTimer, _u16Us); __HAL_TIM_SET_COUNTER(l_pstTimer, 0); __HAL_TIM_CLEAR_FLAG(l_pstTimer, TIM_FLAG_UPDATE); //HIDO_UnLock(); while (!__HAL_TIM_GET_FLAG(l_pstTimer, TIM_FLAG_UPDATE)) { } } /******************************************************************************* * Function Name : * Description : * Input : * Output : * Return : * Author : www.hido-studio.com * Modified Date: : 2019Äê7ÔÂ25ÈÕ *******************************************************************************/ void Delay_TimerRegister(HIDO_VOID *_pTimer) { l_pstTimer = (TIM_HandleTypeDef *)_pTimer; } /******************************************************************************* * Function Name : * Description : * Input : * Output : * Return : * Author : www.hido-studio.com * Modified Date: : 2019Äê7ÔÂ25ÈÕ *******************************************************************************/ HIDO_INT32 Delay_Init(void) { HAL_TIM_Base_Start(l_pstTimer); return HIDO_OK; }