[gpio] Fix one_wire reset busy-waiting with interrupts off when delay wraps (#18733)

This commit is contained in:
J. Nick Koston
2026-08-24 16:20:25 -05:00
committed by GitHub
parent 19866c60ee
commit 2a05372a51
@@ -55,8 +55,11 @@ int HOT IRAM_ATTR GPIOOneWireBus::reset_int() {
delayMicroseconds(1);
}
// delay J
delayMicroseconds(start + 480 - micros());
// delay J: finish the 480us slot, but never spin if it already elapsed
// (unsigned wrap here would busy-wait for minutes with interrupts off)
uint32_t elapsed = micros() - start;
if (elapsed < 480)
delayMicroseconds(480 - elapsed);
this->pin_.digital_write(true);
this->pin_.pin_mode(gpio::FLAG_OUTPUT);
return r ? 1 : 0;