cpu/nrf5x/uart: run STOPTX task after finished tx#18954
cpu/nrf5x/uart: run STOPTX task after finished tx#18954maribu merged 1 commit intoRIOT-OS:masterfrom
Conversation
maribu
left a comment
There was a problem hiding this comment.
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-worldshows a power consumption of 400uA on thenrf52dkboard, even though stdin isn't wired and, thus, RX of theperiph_uartisn't wired.This PR makes sure that
TASKS_STARTTXis called before a transmission. After completion theTASKS_STOPTXis run allowing for entering low power mode.Testing procedure
nrf51andnrf52CPUs should be able to transmit octets usingperiph_uartwith and without theuart_nonblockingfeature.Issues/PRs references