Files
BlindCane/Core/App/Helper/task_helper.hpp
chauyin c3e0edd72d
All checks were successful
Build and Upload Artifact / build and upload-artifact (push) Successful in 19m51s
TaskHelper int 修改为 uint32_t
2025-05-12 14:24:59 +08:00

20 lines
462 B
C++

#pragma once
#include "stm32h5xx_hal.h"
#include <cstdint>
#include <stdexcept>
class TaskHelper {
public:
template <typename Func>
static void WaitFor(Func func, uint32_t timeoutMilliseconds) {
auto start = HAL_GetTick();
while (!func()) {
uint32_t now = HAL_GetTick();
if ((now - start) > timeoutMilliseconds) {
throw std::runtime_error("Operation timed out");
}
}
}
};