// // Created by Engineer on 2024/1/11. // #include "delay_helper.h" #include "tim.h" void DelaySetup(void) { HAL_TIM_Base_Start(&TIM_DELAY); } void DelayUs(const uint16_t nus) { __HAL_TIM_SET_COUNTER(&TIM_DELAY, 0); while (__HAL_TIM_GET_COUNTER(&TIM_DELAY) < nus) { } } void DelayMs(const uint32_t nms) { for (uint32_t i = 0; i < nms; ++i) { DelayUs(1000); } } void DelayS(const uint32_t ns) { for (uint32_t i = 0; i < ns; ++i) { DelayMs(1000); } }