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

4140 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
Hugues Larrive
a582da1f31 drivers/dht: busy wait reimplementation
- 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
2023-06-20 12:07:48 +02:00
bors[bot]
829af7c105
Merge #19703 #19724 #19735
19703: cpu/sam0_eth: interrupt based link detection/auto-negotiation r=benpicco a=benpicco



19724: dist/tools/openocd: add OPENOCD_SERVER_ADDRESS variable r=benpicco a=fabian18



19735: nrf5x_common: Clear I2C periph shorts r=benpicco a=bergzand

### Contribution description

The I2C peripheral's shortcuts are used with the read and write register to automatically stop the I2C transaction or to continue with the next stage.

With simple I2C read and write bytes these shorts are not used, but are also not cleared by the function in all cases, causing it to use the shortcut configuration set by a previous function call. This patch ensures that the shorts are always set by the read and write functions

### Testing procedure

Should be possible to spot with a logic analyzer and the I2C periph test. Maybe the HIL test can also detect it :)

### Issues/PRs references

None

Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
Co-authored-by: Fabian Hüßler <fabian.huessler@ml-pa.com>
Co-authored-by: Koen Zandberg <koen@bergzand.net>
2023-06-14 12:34:33 +00:00
bors[bot]
61d7c4028e
Merge #19734
19734: drivers/pcf857x: allow to define PCF857x_BASE_ADDR at compile time r=maribu a=hugueslarrive



Co-authored-by: Hugues Larrive <hlarrive@pm.me>
2023-06-14 07:38:17 +00:00
Hugues Larrive
85e41a1f18 drivers/pcf857x: allow to define PCF857x_BASE_ADDR at compile time 2023-06-14 05:38:20 +02:00
Marian Buschsieweke
826095d56e
drivers/sx127x: reduce use of floats 2023-06-12 13:54:06 +02:00
bors[bot]
d7e4f939c2
Merge #19695
19695: drivers/hih6130: avoid using floats r=maribu a=maribu

### Contribution description

- avoid using floating point arithmetic
- use ztimer instead of xtimer
- use fmt to print fixed point numbers in the test app


Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
2023-06-08 13:02:12 +00:00
Marian Buschsieweke
bb366c476a
drivers/hih6130: avoid using floats 2023-06-08 14:33:38 +02:00
Marian Buschsieweke
5dd548860c
drivers/mrf24j40: add note about missing wake pin handling
Fixes https://github.com/RIOT-OS/RIOT/issues/19711
2023-06-07 15:10:33 +02:00
Benjamin Valentin
9627b0d264 drivers/mii: add Interrupt Control/Status register 2023-06-05 12:46:08 +02:00
Benjamin Valentin
e469ecb593 drivers/mii: add missing MII_EXPANSION bit 2023-06-05 11:42:55 +02:00
bors[bot]
d16f8f1032
Merge #19696 #19698
19696: drivers/mq3: avoid use of floats r=maribu a=maribu



19698: tests/pkg/lvgl: avoid using floats r=maribu a=maribu



Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
2023-06-02 05:48:07 +00:00
Marian Buschsieweke
e29499cf3a
drivers/mq3: avoid use of floats 2023-06-01 16:52:26 +02:00
77a11be676
drivers/kw41zrf: boards/openlabs-kw41z-mini: cleanup Kconfig 2023-06-01 12:19:44 +02:00
bors[bot]
e71054def9
Merge #19691 #19694
19691: drivers/bmx055: fix crazy use of FPU r=maribu a=maribu

### Contribution description

As the title says...


19694: tests/drivers/epd_bw_spi_disp_dev: fix accidental use of FPU r=maribu a=maribu



Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
2023-06-01 02:53:25 +00:00
Marian Buschsieweke
6ddf76103a
drivers/bmx055: fix crazy use of FPU 2023-05-31 16:32:14 +02:00
Benjamin Valentin
7457c4545a drivers/shtcx: fix assertion and shtcx_saul_info idx 2023-05-31 14:42:44 +02:00
bors[bot]
00b5bc12a2
Merge #19610 #19670 #19678 #19679 #19680 #19681
19610: drivers/periph/rtc: improve doc on rtc_set_alarm r=maribu a=maribu

### Contribution description

- point out behavior on denormalized time stamps
- use errno codes to indicate errors (and adapt the few instances of actual error handling to use them)


19670: cpu/stm32: stm32f4 BRR from BSRR r=maribu a=kfessel

### Contribution description

sometimes one wants to save one instruction :) 
just write the bits we need to write.

### Testing procedure

tests/periph/gpio_ll tests this 

### Issues/PRs references

`@maribu` might know some reference

maybe #19407

19678: gnrc_sixlowpan_iphc: fix NULL pointer dereference r=maribu a=miri64



19679: gnrc_sixlowpan_frag_sfr: fix ARQ scheduler race-condition r=maribu a=miri64



19680: gnrc_sixlowpan_frag_rb: fix OOB write in _rbuf_add r=maribu a=miri64



19681: sys/xtimer: improve documentation r=maribu a=maribu

### Contribution description

- Add a warning that xtimer is deprecated, so that new code hopefully starts using ztimer
- Add a hint that `ztimer_xtimer_compat` can be used even after `xtimer` is gone


Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
Co-authored-by: Karl Fessel <karl.fessel@ovgu.de>
Co-authored-by: Martine Lenders <m.lenders@fu-berlin.de>
2023-05-30 17:11:06 +00:00
Marian Buschsieweke
51127f674a
drivers/periph/rtc: improve doc on rtc_set_alarm
- point out behavior on denormalized time stamps
- use errno codes to indicate errors (and adapt the few instances of
  actual error handling to use them)
2023-05-30 17:41:36 +02:00
bors[bot]
993c10a2a2
Merge #19556 #19662
19556: tools/mspdebug: fix `make debug` and `make debugserver` r=aabadie a=maribu

### Contribution description

The semantics of `make debug` and `make debugserver` have changed in the years since the MSP430 integration. This brings the implementation back into line with the current semantics

- `make debug` now starts both mspdebug and GDB, no need to run `make debugserver` prior to `make debug` anymore
- `make debug` no longer flashes the target to not waste flash erase cycles
- GDB mutliarch support is added
- support for selecting a debug adapter by its serial is added


19662: driver/lc709203f: remove unnecessary use of float r=aabadie a=kfessel

### Contribution description

removes a unnecessary use of float

### Testing procedure

read and test if you got that hardware (I don't)

### Issues/PRs references

#19614 

Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
Co-authored-by: Karl Fessel <karl.fessel@ovgu.de>
2023-05-24 15:54:23 +00:00
bors[bot]
7b324d7a4f
Merge #19650 #19660
19650: drivers/nrf24l01p: model in kconfig r=aabadie a=aabadie



19660: cpu/rpx0xx: Fix kconfig model r=aabadie a=MrKevinWeiss



### Contribution description

Broken master due to incorrect model of the periph_pio in kconfig.

### Testing procedure

Green murdock (now that the board is added to the list)

### Issues/PRs references

Look at the master CI...

Co-authored-by: Alexandre Abadie <alexandre.abadie@inria.fr>
Co-authored-by: MrKevinWeiss <weiss.kevin604@gmail.com>
2023-05-24 13:09:20 +00:00
Karl Fessel
2c3920ab62 driver/lc709203f: remove unnecessary use of float 2023-05-24 14:22:24 +02:00
1dc6e0e32b
drivers/nrf24l01p: model in Kconfig 2023-05-24 10:18:53 +02:00
MrKevinWeiss
adbf951481
cpu/rpx0xx: Fix kconfig model 2023-05-24 09:53:23 +02:00
bors[bot]
40d0f64a04
Merge #19549 #19608 #19657
19549: pkg/littlefs2: bump version to 2.6 r=benpicco a=benpicco




19608: build system: fix `make compile-commands BUILD_IN_DOCKER=1` r=benpicco a=maribu

### Contribution description

Just run `make compile-commands` outside of docker, as the compile commands generated in the docker container won't be helpful for tools outside of the container anyway.


19657: drivers/mpu9x50: clean up code r=benpicco a=maribu

### Contribution description

Avoid using floating point arithmetic and some minor cleanups.


Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
2023-05-23 23:35:57 +00:00
Marian Buschsieweke
533af18119
drivers/mpu9x50: clean up code
Avoid using floating point arithmetic and some minor cleanups.
2023-05-23 21:40:40 +02:00
bors[bot]
f3150120f7
Merge #17425
17425: cpu/rpx0xx: initial PIO support r=maribu a=fabian18



Co-authored-by: Fabian Hüßler <fabian.huessler@st.ovgu.de>
2023-05-23 07:02:45 +00:00
Fabian Hüßler
116c579cb5 cpu/rpx0xx: Add PIO I2C implementation 2023-05-23 08:49:37 +02:00
Fabian Hüßler
18315d3ddc cpu/rpx0xx: Add PIO implementation 2023-05-23 08:49:37 +02:00
bors[bot]
e4490f1793
Merge #19647
19647: drivers/mtd_spi_nor: fix hang and debug msgs r=aabadie a=Enoch247

### Contribution description

This patch adds a missing release of the SPI bus on error

### Testing procedure

This was discovered while attempting to bring up a board where I had the pin definitions wrong for a SPI flash part. Once the driver was fixed I was able to get the debug messages and not hang other drivers using the same bus.

### Issues/PRs references

None known

Co-authored-by: Joshua DeWeese <jdeweese@primecontrols.com>
2023-05-22 20:02:16 +00:00
Joshua DeWeese
ff450cd7f4 drivers/mtd_spi_nor: fix hang
This patch releases the SPI bus when the memory devices is not found.
This frees the bus for other devices to use the bus. It also allows
future attempts to init the device.
2023-05-22 12:22:01 -04:00
Joshua DeWeese
33cb2f489b drivers/mtd_spi_nor: fix debug msg
This patch adds some missing newline chars to debug output ensuring the
lines get flushed and don't run together.
2023-05-22 12:21:59 -04:00
Marian Buschsieweke
b9484852f1
drivers/sx126x: fix argument validation in spreading factor
The lowest possible value is `LORA_SF5` and not `LORA_SF6`. This fixes
the argument validation to allow setting `LORA_SF5` as spreading factor.

Fixes https://github.com/RIOT-OS/RIOT/issues/17861
2023-05-22 15:06:07 +02:00
bors[bot]
8fc1187278
Merge #17830 #19635
17830: periph/timer: fix Kconfig menu title r=aabadie a=gschorcht

### Contribution description

This PR is a very small fix of inconsistent peripheral driver entry in `Kconfig` for `periph/timer`.

In Kconfig menu `(Top) → Drivers → Peripherals drivers` all entries start with the peripheral name in alphabetical order with only one exception, the timer entry. This entry is called `Configure timer peripheral driver`:
```
[ ] CPU unique ID
[ ] EEPROM peripheral driver
[ ] Flashpage peripheral driver  ----
[*] GPIO peripheral driver  --->
[ ] HWRNG peripheral driver
[ ] PWM peripheral driver
[*] Power Management (PM) peripheral driver
[*]     Auto initialize Power Management (PM) peripheral
[ ] Quadrature Decoder (QDEC) peripheral driver
[ ] RTC peripheral driver  ----
[ ] SPI peripheral driver  ----
[*] UART peripheral driver  --->
[*] Configure timer peripheral driver  --->
```
This is confusing and doesn't help to find the right entry. This PR
1. changes the entry to `Timer peripheral driver` and
2. corrects the alphabetical order.

### Testing procedure

Use command
```
TEST_KCONFIG=1 make -C tests/periph_timer menuconfig
```
and check the output. in menu `(Top) → Drivers → Peripherals drivers`. It should be with this PR:
```
[ ] CPU unique ID
[ ] EEPROM peripheral driver
[ ] Flashpage peripheral driver  ----
[*] GPIO peripheral driver  --->
[ ] HWRNG peripheral driver
[ ] PWM peripheral driver
[*] Power Management (PM) peripheral driver
[*]     Auto initialize Power Management (PM) peripheral
[ ] Quadrature Decoder (QDEC) peripheral driver
[ ] RTC peripheral driver  ----
[ ] SPI peripheral driver  ----
[*] Timer peripheral driver  --->
[*] UART peripheral driver  --->
```
### Issues/PRs references


19635: drivers/mrf24j40: cleanup function r=aabadie a=maribu

### Contribution description

`_set_csma_params()` spends some time to prepare a value in `uint8_t tmp`, which then is never used. Likely this is a leftover of moving code to `mrf24j40_set_csma_max_retries()`. This drops the leftover code.


Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
2023-05-20 18:43:44 +00:00
Marian Buschsieweke
c10b8838f1
drivers/mrf24j40: cleanup function
`_set_csma_params()` spends some time to prepare a value in
`uint8_t tmp`, which then is never used. Likely this is a leftover
of moving code to `mrf24j40_set_csma_max_retries()`. This drops the
leftover code.
2023-05-20 16:59:25 +02:00
bors[bot]
a08b90c648
Merge #19633
19633: drivers/slipdev: fix logic bug r=fabian18 a=maribu

### Contribution description

A typo resulted in a boolean expression to always be true and the `_poweron()` function to always exit early. This fixes the issue.


Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
2023-05-20 00:35:17 +00:00
bors[bot]
24593ce18c
Merge #19631 #19632
19631: drivers/dfplayer: fix bug in utility function r=maribu a=maribu

### Contribution description

Apparently, those functions have never been used. Otherwise this obvious bug wouldn't have sailed unnoticed for so long.



19632: drivers/pcf857x: fix error handling r=maribu a=maribu

### Contribution description

This fixes a typo/copy paste error in the error handling.


Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
2023-05-19 21:54:05 +00:00
Marian Buschsieweke
adfe9ac306
drivers/slipdev: fix logic bug
A typo resulted in a boolean expression to always be true and the
`_poweron()` function to always exit early. This fixes the issue.
2023-05-19 23:01:30 +02:00
Marian Buschsieweke
bc1c831d39
drivers/pcf857x: fix error handling
This fixes a typo/copy paste error in the error handling.
2023-05-19 21:59:40 +02:00
Marian Buschsieweke
5683281b5d
drivers/dfplayer: fix bug in utility function
Apparently, those functions have never been used. Otherwise this
obvious bug wouldn't have sailed unnoticed for so long.
2023-05-19 21:51:44 +02:00
bors[bot]
a46b49a24c
Merge #19605 #19624 #19625
19605: drivers/at86rf2xx: setting rx timestamp based on symbol counter for ATmega*RFR2 r=maribu a=chudov



19624: pkg/tensorflow-lite: remove deprecated package r=maribu a=aabadie

Use tflite-micro instead



19625: sys/hashes: remove deprecated aes cmac hashing r=maribu a=aabadie



Co-authored-by: chudov <chudov@gmail.com>
Co-authored-by: Alexandre Abadie <alexandre.abadie@inria.fr>
2023-05-19 17:05:02 +00:00
chudov
c52f6e71c2 drivers/at86rf2xx: rx timestamp generation for ATmegaRFR2
Signed-off-by: chudov <chudov@gmail.com>
2023-05-19 15:33:15 +02:00
Marian Buschsieweke
dcb49cb46d
drivers/lpsxxx: avoid float arithmetics
Fixes https://github.com/RIOT-OS/RIOT/issues/17486
2023-05-19 09:23:30 +02:00
2dbf57fa46
drivers/pcf857x: fix path to saul test application 2023-05-13 19:08:40 +02:00
Fabian Hüßler
500d257a52 drivers/periph_common: Add PIO to periph init 2023-05-12 23:03:05 +02:00
Fabian Hüßler
d8cf31b094 drivers/include/periph: Add PIO driver interface 2023-05-12 23:03:05 +02:00
f9d247791d
treewide: replace occurrences of tests/driver_ with new path 2023-05-06 15:38:21 +02:00
Gunar Schorcht
714b3e3384 drivers/mtd_default: add external declarations for mtd*
The `mtd_default` module defines `MTD_NUMOF` if not existing based on the `MTD_*` defines which are usually set to the corresponding MTD device pointer variables `mtd*`. However, these MTD device pointer variables are not always made known by external variable declarations. An example are SD Card Interfaces which are defined via the `mtd_sdcard_default` module. As a consequence, an application that uses `mtd_default` has still to be modified. Therefore, `mtd_default` also declares up to 6 `mtd*` MTD device pointer variables.
2023-05-02 23:07:29 +02:00
bors[bot]
c4b27d8241
Merge #19523 #19527 #19530 #19532 #19533 #19535
19523: boards/iotlab-m3: enable l3g4200d_ng r=benpicco a=benpicco



19527: drivers/sdcard_spi: small cleanup r=benpicco a=gschorcht

### Contribution description

This PR provides a small cleanup:
- the copy of `sdcard_spi_params_t` is removed (commit bfc2a51f70)
- the documentation was changed to fit the 100 characters per line. (commit 36f0162b34)

It is not necessary to hold a complete copy `sdcard_spi_params_t` in the device descriptor. Constant parameters can be used directly from ROM instead. This saves 24 bytes of RAM.

### Testing procedure

Use any board with SD Card SPI interface. The driver test should still work, for example:
```
BOARD=esp32-wrover-kit make -j8 -C tests/driver_sdcard_spi flash term
```
```
main(): This is RIOT! (Version: 2023.07-devel-176-g7213c-drivers/sdcard_spi_cleanup)
SD-card spi driver test application
insert SD-card and use 'init' command to set card to spi mode
WARNING: using 'write' or 'copy' commands WILL overwrite data on your sd-card and
almost for sure corrupt existing filesystems, partitions and contained data!
> init
Initializing SD-card at SPI_0...
[OK]
> 
```

### Issues/PRs references


19530: sys/xtimer: add missing "modules.h" include to `xtimer.h` r=benpicco a=kaspar030



19532: tests/unittests: tests-core-mbox: add missing `container.h` include r=benpicco a=kaspar030



19533: core: move macros/math.h to core/lib/include/macros r=benpicco a=kaspar030



19535: nanocoap_sock: defuse nanocoap_sock_get() API footgun r=benpicco a=benpicco



Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: Kaspar Schleiser <kaspar@schleiser.de>
2023-05-02 13:37:57 +00:00
Marian Buschsieweke
c3500eb6e0
tree wide: fix typos in comments found by codespell
This will not change generated binaries, only the Doxygen output and
source code will have less typos.
2023-05-02 09:52:06 +02:00