generated from Template/H563ZI-HAL-CMake-Template
Some checks failed
Build and Upload Artifact / build and upload-artifact (push) Has been cancelled
19 lines
482 B
C++
19 lines
482 B
C++
#pragma once
|
|
|
|
#include "stm32h5xx_hal.h"
|
|
#include <cstdint>
|
|
#include <stdexcept>
|
|
|
|
namespace TaskHelper {
|
|
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");
|
|
}
|
|
}
|
|
}
|
|
}; // namespace TaskHelper
|