Added timeout wait functions to core

This commit is contained in:
Ea-r-th
2025-09-17 20:07:17 -07:00
parent 75132eb040
commit 8ce717033a
4 changed files with 77 additions and 31 deletions

View File

@@ -39,4 +39,24 @@ void SHAL_delay_ms(uint32_t ms){
while(ms-- > 0){
SHAL_delay_us(1000);
}
}
bool SHAL_wait_for_condition_us(condition_fn_t condition, uint32_t timeout_us){
while (timeout_us--) {
if (condition()) {
return true; // Condition met
}
SHAL_delay_us(1); // Wait 1 µs
}
return false; // Timeout
}
bool SHAL_wait_for_condition_ms(condition_fn_t condition, uint32_t timeout_ms){
while (timeout_ms--) {
if (condition()) {
return true; // Condition met
}
SHAL_delay_ms(1); // Wait 1 µs
}
return false; // Timeout
}