8000 drivers/dht: Allow open-drain-high call to be DHT specific if needed. · micropython/micropython@f102ac5 · GitHub
[go: up one dir, main page]

Skip to content

Commit f102ac5

Browse files
committed
drivers/dht: Allow open-drain-high call to be DHT specific if needed.
Some ports (eg esp8266) need to have specific behaviour for driving a DHT reliably.
1 parent eb446ec commit f102ac5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/dht/dht.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
#include "extmod/machine_pulse.h"
3333
#include "drivers/dht/dht.h"
3434

35+
// Allow the open-drain-high call to be DHT specific for ports that need it
36+
#ifndef mp_hal_pin_od_high_dht
37+
#define mp_hal_pin_od_high_dht mp_hal_pin_od_high
38+
#endif
39+
3540
STATIC mp_obj_t dht_readinto(mp_obj_t pin_in, mp_obj_t buf_in) {
3641
mp_hal_pin_obj_t pin = mp_hal_get_pin_obj(pin_in);
3742
mp_hal_pin_open_drain(pin);
@@ -44,15 +49,15 @@ STATIC mp_obj_t dht_readinto(mp_obj_t pin_in, mp_obj_t buf_in) {
4449
}
4550

4651
// issue start command
47-
mp_hal_pin_od_high(pin);
52+
mp_hal_pin_od_high_dht(pin);
4853
mp_hal_delay_ms(250);
4954
mp_hal_pin_od_low(pin);
5055
mp_hal_delay_ms(18);
5156

5257
mp_uint_t irq_state = mp_hal_quiet_timing_enter();
5358

5459
// release the line so the device can respond
55-
mp_hal_pin_od_high(pin);
60+
mp_hal_pin_od_high_dht(pin);
5661
mp_hal_delay_us_fast(10);
5762

5863
// wait for device to respond

0 commit comments

Comments
 (0)
0