mirror of
https://github.com/esphome/esphome.git
synced 2026-08-26 16:10:29 +00:00
[gpio] Fix one_wire reset busy-waiting with interrupts off when delay wraps (#18733)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user