8000 esp8266/esp_mphal: Provide mp_hal_pin_od_high_dht so DHT works reliably. · dpgeorge/micropython@18d3a5d · GitHub
[go: up one dir, main page]

Skip to content

Commit 18d3a5d

Browse files
committed
esp8266/esp_mphal: Provide mp_hal_pin_od_high_dht so DHT works reliably.
The original behaviour of open-drain-high was to use the open-drain mode of the GPIO pin, and this seems to make driving a DHT more reliable. See issue micropython#4233.
1 parent f102ac5 commit 18d3a5d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ports/esp8266/esp_mphal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ void mp_hal_pin_open_drain(mp_hal_pin_obj_t pin);
9191
if ((p) == 16) { WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1)); } \
9292
else { gpio_output_set(0, 0, 0, 1 << (p)); /* set as input to avoid glitches */ } \
9393
} while (0)
94+
// The DHT driver requires using the open-drain feature of the GPIO to get it to work reliably
95+
#define mp_hal_pin_od_high_dht(p) do { \
96+
if ((p) == 16) { WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1)); } \
97+
else { gpio_output_set(1 << (p), 0, 1 << (p), 0); } \
98+
} while (0)
9499
#define mp_hal_pin_read(p) pin_get(p)
95100
#define mp_hal_pin_write(p, v) pin_set((p), (v))
96101

0 commit comments

Comments
 (0)
0