From 8927e4118090c3c7f03ed43a7f6167955a84afff Mon Sep 17 00:00:00 2001 From: Debian Date: Sat, 15 Apr 2023 17:05:12 -0600 Subject: [PATCH 1/2] Reset stuck low detection --- shared-module/onewireio/OneWire.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared-module/onewireio/OneWire.c b/shared-module/onewireio/OneWire.c index aeb4dcb00d..ff5caa2bac 100644 --- a/shared-module/onewireio/OneWire.c +++ b/shared-module/onewireio/OneWire.c @@ -59,8 +59,10 @@ bool common_hal_onewireio_onewire_reset(onewireio_onewire_obj_t *self) { common_hal_mcu_delay_us(70); bool value = common_hal_digitalio_digitalinout_get_value(&self->pin); common_hal_mcu_delay_us(410); + // test if bus returned high (idle) and not stck at low + bool idle = common_hal_digitalio_digitalinout_get_value(&self->pin); common_hal_mcu_enable_interrupts(); - return value; + return value || !idle; } bool common_hal_onewireio_onewire_read_bit(onewireio_onewire_obj_t *self) { From 61f868a14e253c02c95bbbc925042004ac8f131f Mon Sep 17 00:00:00 2001 From: CanyonCasa Date: Mon, 17 Apr 2023 12:02:45 -0600 Subject: [PATCH 2/2] Update shared-module/onewireio/OneWire.c Co-authored-by: Scott Shawcroft --- shared-module/onewireio/OneWire.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-module/onewireio/OneWire.c b/shared-module/onewireio/OneWire.c index ff5caa2bac..f00cf572dd 100644 --- a/shared-module/onewireio/OneWire.c +++ b/shared-module/onewireio/OneWire.c @@ -59,7 +59,7 @@ bool common_hal_onewireio_onewire_reset(onewireio_onewire_obj_t *self) { common_hal_mcu_delay_us(70); bool value = common_hal_digitalio_digitalinout_get_value(&self->pin); common_hal_mcu_delay_us(410); - // test if bus returned high (idle) and not stck at low + // test if bus returned high (idle) and not stuck at low bool idle = common_hal_digitalio_digitalinout_get_value(&self->pin); common_hal_mcu_enable_interrupts(); return value || !idle;