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 uart_write_byte() & uart_write_string() functions #15499
Conversation
dda5e79
to
a153a16
Compare
You may want to extend |
Good idea, that makes the code a bit nicer to read. |
* @param[in] data byte to write | ||
* | ||
*/ | ||
void uart_write_byte(uart_t uart, uint8_t data); |
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.
Can't this simply be a static inline around uart_write
?
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.
Sure, moved it there.
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.
I'm somehow unsure about this PR, it cutters the API a bit against for some convenience functions that are actually quite simple, and already implementable with one liners uart_write(uart, (uint8_t*)s, strlen(s));
and uart_write(uart, &data, 1);
RIOT/drivers/include/periph/uart.h
Lines 14 to 17 in 0ad56d4
* This is a basic UART (Universal Asynchronous Receiver Transmitter) interface | |
* to allow platform independent access to the MCU's serial communication | |
* abilities. This interface is intentionally designed to be as simple as | |
* possible, to allow for easy implementation and maximum portability. |
So I'm kind of looking to be convinced :) (but if someone else ACKs it I won't say anything either)
Well unless an optimized version is to be provided, there is no additional implementation work to be done. My original idea (besides convenience and nicer looking code) was that only using |
We don't need to check if the configuration is valid for every call to `uart_write()`. Other implementations don't check this either.
0151c03
to
6892635
Compare
I'm also a bit unsure about this PR. Can we maybe split it:
IMO, I think that should be good enough.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Contribution description
When implementing the serial bootloader feature, I added some UART convenience functions.
uart_write_byte()
to send a single byte over UARTuart_write_string()
to send a string of text. This is especially useful for debugging with no stdioBoth are implemented as common fallback functions in
drivers/periph_common
but can be implemented by the CPU.An implementation for sam0 is provided for
uart_write_byte()
.Testing procedure
Issues/PRs references