Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/periph/uart: add periph_uart_tx_ondemand feature #20108

Merged
merged 4 commits into from Dec 14, 2023

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Nov 24, 2023

Contribution description

We have a one-wire bus where the idle level is LOW:

image

If two sensors pull the bus high at the same time, no-one will be able to send anything.
To make this work with standard UART where idle is LOW, we employ a little hack in which we de-mux the UART TX pin when we are not sending and only mux it to TX when we want to send a frame.

This generates a spurious 0 byte after the de-muxing, but since our DOSE frames are well delimited, this noise outside the frame is no issue.

Testing procedure

This bus is really slow (2400 Baud) but it works:

2023-11-22 18:03:53,026 - INFO # > ping -i 5000 fe80::a844:d9ff:fe07:5dc6
2023-11-22 18:03:53,026 - INFO # 
2023-11-22 18:03:54,465 - INFO # 12 bytes from fe80::a844:d9ff:fe07:5dc6%5: icmp_seq=0 ttl=64 time=1417.622 ms
2023-11-22 18:03:59,459 - INFO # 12 bytes from fe80::a844:d9ff:fe07:5dc6%5: icmp_seq=1 ttl=64 time=1412.560 ms
2023-11-22 18:04:04,499 - INFO # 12 bytes from fe80::a844:d9ff:fe07:5dc6%5: icmp_seq=2 ttl=64 time=1433.686 ms
2023-11-22 18:04:04,499 - INFO # 
2023-11-22 18:04:04,501 - INFO # --- fe80::a844:d9ff:fe07:5dc6 PING statistics ---
2023-11-22 18:04:04,513 - INFO # 3 packets transmitted, 3 packets received, 0% packet loss
2023-11-22 18:04:04,515 - INFO # round-trip min/avg/max = 1412.560/1421.289/1433.686 ms

Issues/PRs references

previous attempt at this was #14300

@github-actions github-actions bot added Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: drivers Area: Device drivers Area: cpu Area: CPU/MCU ports labels Nov 24, 2023
@@ -19,6 +19,7 @@
#ifndef SOFT_UART_PARAMS_H
#define SOFT_UART_PARAMS_H

#include "board.h"
Copy link
Contributor Author

@benpicco benpicco Nov 24, 2023

Choose a reason for hiding this comment

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

This is not exactly related to this PR, but without it SOFT_UART_PARAM_xx set in board.h would not get applied.

I first thought of using the software UART to invert the line polarity, but then I found I can use a real UART instead if I re-configure the TX pin.

@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 10, 2023
@benpicco benpicco requested a review from maribu December 10, 2023 01:13
@riot-ci
Copy link

riot-ci commented Dec 10, 2023

Murdock results

✔️ PASSED

9cde80e drivers_dose: enable TX UART on-demand

Success Failures Total Runtime
8081 0 8082 10m:04s

Artifacts

@benpicco benpicco force-pushed the drivers/dose-uart_ondemand_tx branch from 1ea4955 to ce92bcc Compare December 14, 2023 17:26
@benpicco benpicco force-pushed the drivers/dose-uart_ondemand_tx branch from ce92bcc to 9cde80e Compare December 14, 2023 17:30
@github-actions github-actions bot added the Area: Kconfig Area: Kconfig integration label Dec 14, 2023
@benpicco benpicco added this pull request to the merge queue Dec 14, 2023
Merged via the queue into RIOT-OS:master with commit 208790a Dec 14, 2023
26 checks passed
@benpicco benpicco deleted the drivers/dose-uart_ondemand_tx branch December 14, 2023 23:22
@MrKevinWeiss MrKevinWeiss added this to the Release 2024.01 milestone Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports Area: drivers Area: Device drivers Area: Kconfig Area: Kconfig integration CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants