HardFOC Core
API reference
Loading...
Searching...
No Matches
Functions
handler_utils Namespace Reference

Functions

void RouteLogToLogger (int level, const char *tag, const char *format, va_list args) noexcept
 Route a driver log message to the Logger singleton.
 
void DelayMs (uint32_t ms) noexcept
 RTOS-aware millisecond delay.
 
void DelayUs (uint32_t us) noexcept
 Microsecond delay with automatic fallback to RTOS delay for large values.
 

Function Documentation

◆ DelayMs()

void handler_utils::DelayMs ( uint32_t  ms)
inlinenoexcept

RTOS-aware millisecond delay.

On ESP-IDF / FreeRTOS, yields via the scheduler so TLE/MAX reset settle times (datasheet ≥10 ms) are real wall time — not a short volatile busy-wait that was ~3×–10× too short at 200–240 MHz.

A non-zero ms always sleeps at least one tick, the rule os_convert_msec_to_delay_ticks() in hf-utils-rtos-wrap follows: below 1 kHz pdMS_TO_TICKS() rounds a short delay down to 0 ticks, which would only yield. HardFOC runs FreeRTOS at 1 kHz, where 1 ms is 1 tick.

Parameters
msDelay duration in milliseconds.

◆ DelayUs()

void handler_utils::DelayUs ( uint32_t  us)
inlinenoexcept

Microsecond delay with automatic fallback to RTOS delay for large values.

For delays >= 1 ms, delegates to DelayMs (scheduler / HAL), rounded up to whole milliseconds so a datasheet minimum such as 2.5 ms is not cut to 2 ms. Shorter delays use esp_rom_delay_us on ESP-IDF or a denser busy-wait elsewhere so SPI CS setup / inter-frame gaps are not no-ops.

Parameters
usDelay duration in microseconds.

◆ RouteLogToLogger()

void handler_utils::RouteLogToLogger ( int  level,
const char *  tag,
const char *  format,
va_list  args 
)
inlinenoexcept

Route a driver log message to the Logger singleton.

Maps integer log levels to Logger methods:

  • 0 → Error
  • 1 → Warn
  • 2 → Info
  • 3+ → Debug
Parameters
levelInteger log level from the driver callback.
tagLogging tag (null-terminated string).
formatprintf-style format string.
argsVariadic argument list matching format.