Skip to content

drivers/ds18: move to ztimer#21804

Merged
Enoch247 merged 1 commit intoRIOT-OS:masterfrom
krzysztof-cabaj:drivers-ds18-move-to-ztimer
Oct 28, 2025
Merged

drivers/ds18: move to ztimer#21804
Enoch247 merged 1 commit intoRIOT-OS:masterfrom
krzysztof-cabaj:drivers-ds18-move-to-ztimer

Conversation

@krzysztof-cabaj
Copy link
Copy Markdown
Contributor

Contribution description

This PR moves in the drivers/ds18 and tests/drivers/ds18 deprecated xtimer to ztimer.
Moreover, it moves licenses to SPDX format.

Testing procedure

I tested working code on nucleo-f439zi using tests/drivers/ds18.
Observed output, each new reading appears in 2 seconds, when I touched ds18 sensor:

Temperature [ºC]:  23.12
+-------------------------------------+
Temperature [ºC]:  25.93
+-------------------------------------+
Temperature [ºC]:  27.68
+-------------------------------------+
Temperature [ºC]:  28.62
+-------------------------------------+
Temperature [ºC]:  29.18
+-------------------------------------+
Temperature [ºC]:  29.56
+-------------------------------------+
Temperature [ºC]:  29.75
+-------------------------------------+
Temperature [ºC]:  29.93
+-------------------------------------+
Temperature [ºC]:  30.00
+-------------------------------------+
Temperature [ºC]:  30.12
+-------------------------------------+
Temperature [ºC]:  31.00
+-------------------------------------+
Temperature [ºC]:  30.43
+-------------------------------------+

Issues/PRs references

#18560

@github-actions github-actions bot added Area: tests Area: tests and testing framework Area: drivers Area: Device drivers labels Oct 18, 2025
@crasbe crasbe added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation and removed CI: skip compile test If set, CI server will run only non-compile jobs, but no compile jobs or their dependent jobs CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Oct 18, 2025
@riot-ci
Copy link
Copy Markdown

riot-ci commented Oct 18, 2025

Murdock results

✔️ PASSED

56660dd drivers/ds18: move to ztimer

Success Failures Total Runtime
10549 0 10551 12m:18s

Artifacts

@krzysztof-cabaj krzysztof-cabaj force-pushed the drivers-ds18-move-to-ztimer branch from ad46da8 to dc2a805 Compare October 18, 2025 20:50
@crasbe crasbe requested a review from Enoch247 October 20, 2025 13:51
@crasbe
Copy link
Copy Markdown
Contributor

crasbe commented Oct 20, 2025

Can you give me a short rundown on how to use the test? The Readme is... not super helpful.

How is the Onewire pin set?

@krzysztof-cabaj
Copy link
Copy Markdown
Contributor Author

The Onewire pin is configured in drivers/ds18/include/ds18_params.h - default is GPIO_PIN(0, 0) - PA0.

When you flash the application it shows in endless loop temperature reading each 2 s.

@krzysztof-cabaj krzysztof-cabaj force-pushed the drivers-ds18-move-to-ztimer branch from dc2a805 to 673cce4 Compare October 20, 2025 15:09
Copy link
Copy Markdown
Contributor

@Enoch247 Enoch247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works on my hardware. Here is how I tested:

diff --git a/tests/drivers/ds18/Makefile b/tests/drivers/ds18/Makefile
index 6ec1631e03..1e3cddba93 100644
--- a/tests/drivers/ds18/Makefile
+++ b/tests/drivers/ds18/Makefile
@@ -2,6 +2,10 @@ include ../Makefile.drivers_common
 
 BOARD_WHITELIST := sensebox_samd21 samr21-xpro nucleo-l152re nucleo-l432kc nucleo-l073rz b-l072z-lrwan arduino-nano
 
+BOARD = stm32f429i-disc1
+BOARD_WHITELIST += stm32f429i-disc1
+CFLAGS += -DDS18_PARAM_PIN="GPIO_PIN(PORT_C, 0)"
+
 USEMODULE += ds18
 USEMODULE += ztimer_sec
 USEMODULE += printf_float

@crasbe
Copy link
Copy Markdown
Contributor

crasbe commented Oct 21, 2025

Perhaps we can use the opportunity to improve the documentation a bit:

diff --git a/tests/drivers/ds18/Readme.md b/tests/drivers/ds18/Readme.md
index 108faa555a..6737dbf9a4 100644
--- a/tests/drivers/ds18/Readme.md
+++ b/tests/drivers/ds18/Readme.md
@@ -1,7 +1,21 @@
 ## About
-This is a test application for the Maxime [DS18B20](https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf) 1-Wire temperature
-sensor.
+This is a test application for the Maxim
+[DS18B20](https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf)
+1-Wire temperature sensor.

 ## Usage
-The application will initialize the DS18B20 sensor and every 2 seconds will read
-the temperature and print the measurement to STDOUT.
\ No newline at end of file
+The application will initialize the DS18B20 sensor, read
+the temperature and print the measurement to STDOUT every two seconds.
+
+The default GPIO pin is (0,0), which equates for example to PA0 for STM32s.
+You can change the pin by setting the according CFLAG in the Makefile
+or on the command line:
+
+```shell
+CFLAGS+=-DDS18_PARAM_PIN="GPIO_PIN(PORT_C,0)" BOARD=nucleo-l152re make flash term -j
+```
+
+Please note that only certain boards are tested and therefore whitelisted
+due to the timing requirements of the underlying code.
+If your board is not on that whitelist, you can either extend the list in
+the Makefile. The test might still fail for your specific board though!

It would also be nice if you could rename the Readme.md to README.md to fit the standard format.

@github-actions github-actions bot added the Area: doc Area: Documentation label Oct 21, 2025
@krzysztof-cabaj
Copy link
Copy Markdown
Contributor Author

README.md renamed and updated!

@krzysztof-cabaj krzysztof-cabaj force-pushed the drivers-ds18-move-to-ztimer branch 2 times, most recently from 6d7a89e to c90b96d Compare October 21, 2025 12:11
Copy link
Copy Markdown
Contributor

@crasbe crasbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash :)

@krzysztof-cabaj krzysztof-cabaj force-pushed the drivers-ds18-move-to-ztimer branch from c90b96d to aeeebd9 Compare October 21, 2025 12:14
@crasbe crasbe enabled auto-merge October 21, 2025 12:17
@crasbe crasbe added this pull request to the merge queue Oct 21, 2025
github-merge-queue bot pushed a commit that referenced this pull request Oct 21, 2025
@Enoch247 Enoch247 removed this pull request from the merge queue due to a manual request Oct 21, 2025
Copy link
Copy Markdown
Contributor

@Enoch247 Enoch247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my review comments. Just a few nits.

@krzysztof-cabaj krzysztof-cabaj force-pushed the drivers-ds18-move-to-ztimer branch 2 times, most recently from 207f39b to d8dde79 Compare October 21, 2025 16:26
@benpicco
Copy link
Copy Markdown
Contributor

You could have saved your time - xtimer_usleep() is just a wrapper around ztimer_sleep(ZTIMER_USEC) nowadays, so this should produce the exact same binary.

@krzysztof-cabaj
Copy link
Copy Markdown
Contributor Author

I would like to sum up all information, and agree final solution.

  1. README.md should contain minimal information which helps execution of test - information that DS18_PARAM_PIN define should be configured.
  2. README.md should not contain details how to configure DS18_PARAM_PIN.
    In my opinion link to driver configuration provided by @Enoch247 would be beneficial.
  3. Actually, accordingly to the xtimer_compat.h xtimer_usleep() is inline as ztimer_sleep(ZTIMER_USEC).
    However, in my opinion, as xtimer is deprecated and used only in around 100 files, it should be directly moved to ztimer.

All comments are welcome.

If there is no veto - I prepare new version of READM.md in following days.

@krzysztof-cabaj krzysztof-cabaj force-pushed the drivers-ds18-move-to-ztimer branch from d8dde79 to 56660dd Compare October 25, 2025 14:06
@krzysztof-cabaj
Copy link
Copy Markdown
Contributor Author

I commit new version of README.md, which I believe, should fix all raised issues.

Murdock is happy.

Can we finalize this PR?

@Enoch247
Copy link
Copy Markdown
Contributor

Did you intend to squash to a single commit? When I first reviewed this PR, I believe you had broken it into several commits, but now there is only one.

@krzysztof-cabaj
Copy link
Copy Markdown
Contributor Author

krzysztof-cabaj commented Oct 27, 2025

After approval. @crasbe asked me for squashing commits.

@crasbe
Copy link
Copy Markdown
Contributor

crasbe commented Oct 28, 2025

If there is no veto - I prepare new version of READM.md in following days.

That's fine with me 👍

@Enoch247
Copy link
Copy Markdown
Contributor

After approval. @crasbe asked me for squashing commits.

Ahh, ok. Thanks for the clarification.

Copy link
Copy Markdown
Contributor

@Enoch247 Enoch247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for submitting.

@Enoch247 Enoch247 added this pull request to the merge queue Oct 28, 2025
Merged via the queue into RIOT-OS:master with commit 167b5e3 Oct 28, 2025
27 checks passed
@benpicco benpicco added this to the Release 2025.10 milestone Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: doc Area: Documentation Area: drivers Area: Device drivers Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants