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

This commit is contained in:
J. Nick Koston
2026-08-31 11:22:13 +12:00
committed by Jesse Hills
parent 67f7532940
commit a5d8c45b67
@@ -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;