1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

10649 Commits

Author SHA1 Message Date
bors[bot]
561e19303d
Merge #19718 #19737 #19746
19718: drivers/dht: busy wait reimplementation r=benpicco a=hugueslarrive

### Contribution description

In PR #19674, I also provided quick and dirty fixes to restore functionality on esp8266 and enable operation on AVR. While reviewing PR #18591, it became apparent to me that this driver needed a refresh, particularly its migration to ztimer.

The cause of the malfunction on esp8266 was that since the default switch to ztimer as the backend for xtimer, XTIMER_BACKOFF was no longer taken into account. Therefore, the correction I provided in PR #19674 simply made explicit what was previously done implicitly with xtimer and now needs to be done explicitly with ztimer (spinning instead of sleeping).

Moreover, it was unnecessarily complex to measure the pulse duration in a busy-wait implementation, which required 2 calls to ztimer_now() and  32-bit operations expensive on 8-bit architecture. Instead, it is sufficient to read the state of the bus at the threshold moment.

Finally, in practice, it is possible to reduce the read interval (down to less than 0.5s for DHT22) by "harassing" the DHT with start signals until it responds.

This re-implementation brings the following improvements:
- Many backports from `@maribu's` IRQ based implementation (#18591):
  - Use of ztimer
  - Use of errno.h
  - Use of a dht_data structure to pass arguments, to facilitate integration
  - Adaptation of the bit parsing technique to parse bits into the data array
- Reintroduction of DHT11/DHT22 differentiation.
- Separation of `dht_read()` steps into functions for better readability and the ability to share certain functions among different implementations
- Sensor presence check in `dht_init()`
- ~~Automatic adjustment to a minimum data hold time~~
- Default input mode changed to open drain (a pull-up resistor should be placed close to the output if necessary but not close to the input)
- 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

Regarding the changes in the start signal sequence and the removal of the `_reset()` function:
![nano_dht_read_2](https://github.com/RIOT-OS/RIOT/assets/67432403/95966813-2b5f-4a0f-a388-8ac630526ab2)

~~In the previous implementation, there was an unnecessary spike at the beginning of the signal sequence, corresponding to START_HIGH_TIME. This spike has been removed in the re-implementation, as it is unnecessary. Instead, the MCU now simply pulls the signal low for START_LOW_TIME and then releases the bus, which is sufficient for initiating communication with the DHT sensor.~~ Actually, it is necessary to raise the bus level; otherwise, the _wait_for_level() called immediately after to check the response of the DHT may read the port before the signal level is raised, resulting in a false positive.

Additionally, the previous implementation had an issue where the MCU switched back to output mode and went high immediately after reading the 40 bits of data. However, the DHT sensor was still transmitting 2 or 3 additional bytes of '0' at that point, causing a conflict. This issue has been resolved in the re-implementation:
![nano_dht_read_optimized](https://github.com/RIOT-OS/RIOT/assets/67432403/ff124839-5ec5-4df3-bab7-5348d8160a25)

~~Regarding the optimization for AVR, I have performed measurements of `_wait_for_level()` until timeout (85 loops):~~
~~- on esp8266-esp-12x: 264 µs, which is 3.11 µs per loop~~
~~- on nucleo-f303k8: 319 µs, which is 3.75 µs per loop~~
~~- on arduino-nano: 3608 µs, which is 42.45 µs per loop~~
~~Duration measurements on the Arduino Nano:~~


19737: dist/tools/openocd: start debug-server in background and wait r=benpicco a=fabian18



19746: buildsystem: Always expose CPU_RAM_BASE & SIZE flags r=benpicco a=Teufelchen1

### Contribution description

Hello 🐧 

This moves the definition of `CPU_RAM_BASE/SIZE` from being only available in certain situation to be always available.
Reason for change is to simplify common code in the cpu folder.

In cooperation with `@benpicco` 

### Testing procedure

Passing CI


### Issues/PRs references

First usage will be in the PMP driver. Although there is more code in RIOT that could be refactored to use these defines instead of hacks / hardcoded values.

Co-authored-by: Hugues Larrive <hlarrive@pm.me>
Co-authored-by: Fabian Hüßler <fabian.huessler@ml-pa.com>
Co-authored-by: Teufelchen1 <bennet.blischke@outlook.com>
2023-06-20 10:40:01 +00:00
Teufelchen1
791d4e3a4d buildsystem: Always expose CPU_RAM_BASE & SIZE flags 2023-06-20 12:16:06 +02:00
bors[bot]
ef82aa6acc
Merge #19651
19651: sys/stdio_semihosting: model in Kconfig r=MrKevinWeiss a=aabadie



Co-authored-by: Alexandre Abadie <alexandre.abadie@inria.fr>
2023-06-19 07:07:59 +00:00
3b505a2883
pkg/tinyusb: sys: fix stdio buffered inclusion in Kconfig 2023-06-17 15:12:31 +02:00
Mingjie Shen
fe92f676b4 gnrc/rpl: fix incorrect addition overflow check
Checking for overflow of integer addition by comparing against one of
the arguments of the addition does not work when the result of the
addition is automatically promoted to a larger type.

Fix by using an explicit cast to make sure that the result of the
addition is not implicitly converted to a larger type.
2023-06-17 02:25:11 -04:00
f72cb049eb
sys/Kconfig.stdio: model stdio_semihosting in Kconfig 2023-06-16 11:36:42 +02:00
1826331529
sys/usbus: move dependency resolution in its own Makefile.dep 2023-06-15 10:27:38 +02:00
03d2792f8b
sys/congure: move dependency resolution in its own Makefile.dep 2023-06-15 10:27:38 +02:00
d9047a063f
sys/ut_process: move dependency resolution in its own Makefile.dep 2023-06-15 10:27:38 +02:00
bec4c3e0b3
sys/evtimer: move dependency resolution in its own Makefile.dep 2023-06-15 10:27:37 +02:00
6cfafbde6c
sys/uri_parser: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:57 +02:00
ff4b2d1680
sys/fido2: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:57 +02:00
9bd7950a1a
sys/suit: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:57 +02:00
d617d864e6
sys/riotboot: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:56 +02:00
1f4adb2775
sys/uuid: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:56 +02:00
8256424480
sys/benchmark: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:55 +02:00
9386e08ecf
sys/event: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:55 +02:00
c164007425
sys/vfs*: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:54 +02:00
c8d4256c84
sys/random: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:54 +02:00
db19f6f546
sys/puf_sram: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:54 +02:00
50ed85a2fa
sys/entropy_source: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:53 +02:00
113200f9b2
sys/can: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:53 +02:00
9fb5708efe
sys/pm_layered: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:52 +02:00
643c239b27
sys/phydat: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:52 +02:00
1c57e7355d
sys/senml: cleanup dependency resolution 2023-06-15 10:24:52 +02:00
090ccc5d21
sys/saul_reg: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:51 +02:00
ab61a0f978
sys/sched_round_robin: move deps resolution in its own Makefile.dep 2023-06-15 10:24:51 +02:00
79207fa17b
sys/schedstatistics: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:50 +02:00
16b2606bac
sys/cpp11-compat: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:50 +02:00
cc27ff217b
sys/log_color: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:50 +02:00
2b658246b0
sys/luid: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:49 +02:00
fb167c7a9c
sys/sema*: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:49 +02:00
7ce942ab54
sys/isrpipe: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:48 +02:00
4e3290bece
sys/od: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:48 +02:00
1070a66ead
sys/trickle: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:48 +02:00
932ad3fc1f
sys/ssp: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:47 +02:00
85c640d415
sys/trace: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:47 +02:00
384469bc38
sys/eepreg: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:46 +02:00
f9bc119ac9
sys/coding: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:46 +02:00
a554738a0c
sys/arduino: move dependency resolution in its own Makefile.dep 2023-06-15 10:24:45 +02:00
9d58ff8ca2
sys: cleanup shell dependency resolution 2023-06-15 10:24:45 +02:00
bors[bot]
5e7c6c2ff7
Merge #19697 #19725
19697: drivers/sx127x: reduce use of floats r=benpicco a=maribu

### Contribution description

Convert the floating point arithmetic to integer arithmetic.


19725: buildsystem: add target debug-client r=benpicco a=fabian18



Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
Co-authored-by: Fabian Hüßler <fabian.huessler@ml-pa.com>
2023-06-13 19:08:40 +00:00
bors[bot]
c463bc9c11
Merge #18156
18156: pkg/opendsme: add initial support for IEEE 802.15.4 DSME time-slotted MAC r=jia200x a=jia200x



Co-authored-by: Jose Alamos <jose@alamos.cc>
2023-06-13 12:11:07 +00:00
Marian Buschsieweke
826095d56e
drivers/sx127x: reduce use of floats 2023-06-12 13:54:06 +02:00
bors[bot]
98370beb4f
Merge #19721
19721: nanocoap, gcoap: homogenize name of the module r=benpicco a=benpicco



Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2023-06-08 19:03:32 +00:00
bors[bot]
2268caa811
Merge #19212 #19360 #19401 #19645 #19720
19212: shell/rtc: use rtc_tm_normalize() to sanitize input r=benpicco a=benpicco



19360: gcoap: make use coap_build_reply() in gcoap_resp_init() r=benpicco a=benpicco



19401: shell/cmds: add genfile command r=benpicco a=benpicco



19645: sys/isrpipe: Replace xtimer with ztimer_usec r=benpicco a=MrKevinWeiss



### Contribution description

Getting ready for the xtimer dep.


### Testing procedure

Green murdock, there is no explicit test for isrpipe but since it runs xtimer compat it should operate the same.

### Issues/PRs references



19720: tests: remove unnecessary use of floating point r=benpicco a=benpicco



Co-authored-by: Benjamin Valentin <benjamin.valentin@bht-berlin.de>
Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
Co-authored-by: MrKevinWeiss <weiss.kevin604@gmail.com>
Co-authored-by: Benjamin Valentin <benpicco@beuth-hochschule.de>
2023-06-08 16:02:09 +00:00
Benjamin Valentin
d4042eedde gcoap: homogenize name of the module 2023-06-08 16:33:05 +02:00
Benjamin Valentin
661829f43f nanocoap: homogenize name of the module 2023-06-08 16:29:12 +02:00
Benjamin Valentin
aba5e9bcde gcoap: make use coap_build_reply() in gcoap_resp_init() 2023-06-08 15:29:03 +02:00
Benjamin Valentin
94353145a2 shell/cmds: add genfile command 2023-06-08 13:11:43 +02:00