sta-core/src/hal/delay.cpp
2022-04-14 15:19:05 +02:00

33 lines
457 B
C++

#include <sta/hal/delay.hpp>
#ifdef STA_HAL_DELAY_ENABLE
#include <main.h>
namespace sta
{
void delayMs(uint32_t ms)
{
HAL_Delay(ms);
}
} // namespace sta
#ifdef STA_HAL_DELAY_US_TIM
#include <tim.h>
namespace sta
{
void delayUs(uint32_t us)
{
__HAL_TIM_SET_COUNTER(&STA_HAL_DELAY_US_TIM, 0);
while (__HAL_TIM_GET_COUNTER(&STA_HAL_DELAY_US_TIM) < us);
}
} // namespace sta
#endif // STA_HAL_DELAY_US_TIM
#endif // STA_HAL_DELAY_ENABLE