-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/nrf5x/uart: run STOPTX task after finished tx #18954
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, trusting your testing. I have one style suggestion. Please squash right away.
This reduces power consumption for UARTs that are configured in tx-only mode.
9b4f684
to
3da1fac
Compare
is there any way to test if this affects parallel printing? (two threads printing at the same time, one stopping tx after finishing, killing tx for the other) |
Well, parallel printing would crash anyway - for the nrf52 the driver is using DMA. To remove this race, we would need mutexes, I guess? |
I'll try to come up with a solution. Something like this:
What do you think? Do you have better ideas? |
Note that UART is slow. If the DMA is still busy with shuffling many many bytes out of the slow UART, it likely is better to just switch to another thread. I'd just go for a I'd also say that parallel UART access is a rare corner case. So most of the time the |
LGTM as well. Regarding the Mutex: IMHO there is no need for the (low-level) UART driver to be thread safe. This should be handled by the module acutually using the UART, e.g. STDIO or something like a Modbus library etc. However this should of course be documented (if it is not already) :-) |
Agreed! Having this implemented once e.g. in stdio rather than for each and every UART driver makes much more sense. |
Also one might want to use periph_uart in ISR context, and that won't work too well with mutexes involved, right?! |
Is stdio thread-safe? I see exactly this case: a thread is interrupted while printing to stdout and the ISR also logs something to stdout. |
But how to handle ISRs calling |
|
So keep this PR like it is and wait for Murdock? |
Murdock is green. I would merge, if nobody objects? The nrf5x |
Thank you all :) |
Contribution description
The
examples/hello-world
shows a power consumption of 400uA on thenrf52dk
board, even though stdin isn't wired and, thus, RX of theperiph_uart
isn't wired.This PR makes sure that
TASKS_STARTTX
is called before a transmission. After completion theTASKS_STOPTX
is run allowing for entering low power mode.Testing procedure
nrf51
andnrf52
CPUs should be able to transmit octets usingperiph_uart
with and without theuart_nonblocking
feature.Issues/PRs references