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 #4233.
This commit is contained in:
parent
f102ac54e9
commit
18d3a5df26
|
@ -91,6 +91,11 @@ void mp_hal_pin_open_drain(mp_hal_pin_obj_t pin);
|
|||
if ((p) == 16) { WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1)); } \
|
||||
else { gpio_output_set(0, 0, 0, 1 << (p)); /* set as input to avoid glitches */ } \
|
||||
} while (0)
|
||||
// The DHT driver requires using the open-drain feature of the GPIO to get it to work reliably
|
||||
#define mp_hal_pin_od_high_dht(p) do { \
|
||||
if ((p) == 16) { WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & ~1)); } \
|
||||
else { gpio_output_set(1 << (p), 0, 1 << (p), 0); } \
|
||||
} while (0)
|
||||
#define mp_hal_pin_read(p) pin_get(p)
|
||||
#define mp_hal_pin_write(p, v) pin_set((p), (v))
|
||||
|
||||
|
|
Loading…
Reference in New Issue