- many backports from @maribu's IRQ based implementation (#18591)
- use of ztimer and errno.h
- separation of dht_read() steps into functions for better readability
- reintroduction of DHT11/DHT22 differentiation
- sensor presence checking in dht_init()
- default input mode changed to open drain
- AVR support without platform-specific handling by avoiding
ztimer_spin() and using the overflow of an 8-bit variable as a
pre-timeout to minimize time-consuming ztimer_now() calls
- add a new DHT11_2022 type for 0.01 °C resolution devices
- data caching removed
This makes life easier when calling e.g. `saul_reg_write()` with data
stored in flash.
As now the signatures for reading and writing differ (in that `const`
qualifier only), `saul_notsup()` is split into `saul_write_notsup()`
and `saul_read_notsup()`. However, one is implemented as a symbol alias
of the other, so that ROM consumption remains unchanged.
The DHT11/DHT21/DHT22 cannot be sampled more than once a second. Previously,
a global cache was added to the SAUL adaption of the dht driver to answer with
stored values for one second after the last read. This however had two
disadvantages:
- The global cache was shared for all DHTXX devices connected. As a result
incorrect values were delivered when reading out multiple sensors over SAUL
with less than 1 second delay in between
- A user of the low level API will had to implement the same caching strategy,
resulting in code duplication
By moving the hold logic to the driver, both limitations can be overcome.
Previously the DHT11/DHT21/DHT22 driver ended up in an infinite loop locking up
RIOT when a communication error occurred. This commit adds a simple timeout to
the communication in order to prevent these lock ups.
A memset was used to clear two of the SAUL values in phydat_t::val
The change is to replace that by the following
res->val[1] = 0;
res->val[2] = 0;
which makes the code more obvious.
- added default dht_params.h file
- added dht_auto_init(void) function
- changed init function to init(dev, params)
- s/gpio/pin/ in device descriptor
- moved FEATURE_REQUIRED to drivers/Makefile.dep