Browse Source

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.
pull/4415/head
Damien George 6 years ago
parent
commit
f102ac54e9
  1. 9
      drivers/dht/dht.c

9
drivers/dht/dht.c

@ -32,6 +32,11 @@
#include "extmod/machine_pulse.h"
#include "drivers/dht/dht.h"
// Allow the open-drain-high call to be DHT specific for ports that need it
#ifndef mp_hal_pin_od_high_dht
#define mp_hal_pin_od_high_dht mp_hal_pin_od_high
#endif
STATIC mp_obj_t dht_readinto(mp_obj_t pin_in, mp_obj_t buf_in) {
mp_hal_pin_obj_t pin = mp_hal_get_pin_obj(pin_in);
mp_hal_pin_open_drain(pin);
@ -44,7 +49,7 @@ STATIC mp_obj_t dht_readinto(mp_obj_t pin_in, mp_obj_t buf_in) {
}
// issue start command
mp_hal_pin_od_high(pin);
mp_hal_pin_od_high_dht(pin);
mp_hal_delay_ms(250);
mp_hal_pin_od_low(pin);
mp_hal_delay_ms(18);
@ -52,7 +57,7 @@ STATIC mp_obj_t dht_readinto(mp_obj_t pin_in, mp_obj_t buf_in) {
mp_uint_t irq_state = mp_hal_quiet_timing_enter();
// release the line so the device can respond
mp_hal_pin_od_high(pin);
mp_hal_pin_od_high_dht(pin);
mp_hal_delay_us_fast(10);
// wait for device to respond

Loading…
Cancel
Save