mirror of
https://github.com/esphome/esphome.git
synced 2026-10-01 00:40:21 +00:00
[core] Use constexpr for compile-time constants (#14071)
This commit is contained in:
@@ -846,9 +846,9 @@ void IRAM_ATTR HOT delay_microseconds_safe(uint32_t us) {
|
||||
// avoids CPU locks that could trigger WDT or affect WiFi/BT stability
|
||||
uint32_t start = micros();
|
||||
|
||||
const uint32_t lag = 5000; // microseconds, specifies the maximum time for a CPU busy-loop.
|
||||
// it must be larger than the worst-case duration of a delay(1) call (hardware tasks)
|
||||
// 5ms is conservative, it could be reduced when exact BT/WiFi stack delays are known
|
||||
constexpr uint32_t lag = 5000; // microseconds, specifies the maximum time for a CPU busy-loop.
|
||||
// it must be larger than the worst-case duration of a delay(1) call (hardware tasks)
|
||||
// 5ms is conservative, it could be reduced when exact BT/WiFi stack delays are known
|
||||
if (us > lag) {
|
||||
delay((us - lag) / 1000UL); // note: in disabled-interrupt contexts delay() won't actually sleep
|
||||
while (micros() - start < us - lag)
|
||||
|
||||
Reference in New Issue
Block a user