-
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: efm32: provide non-standard UART modes #9127
Conversation
Ping @kYc0o |
f28ab62
to
71a4d7e
Compare
cpu/efm32/periph/uart.c
Outdated
@@ -104,6 +109,9 @@ int uart_init(uart_t dev, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg) | |||
|
|||
init.enable = leuartDisable; | |||
init.baudrate = baudrate; | |||
init.databits = LEUART_DataBits2Def((uart_config[dev].mode >> 0) & 0xf); | |||
init.stopbits = LEUART_StopBits2Def((uart_config[dev].mode >> 4) & 0xf); | |||
init.parity = LEUART_Parity2Def((uart_config[dev].mode >> 8) & 0xf); |
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.
So, the baud rate will only change on init, then it stays like that as I see? Which means once the UART is attached to a device it cannot be detached is it?
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.
Yes, that's true. #5899 proposes a runtime option, but it is not merged/fixed/proposed.
STM32 Kinetis does the same, iirc.
pkg/gecko_sdk/Makefile
Outdated
@@ -1,6 +1,6 @@ | |||
PKG_NAME=gecko_sdk | |||
PKG_URL=https://github.com/basilfx/RIOT-gecko-sdk | |||
PKG_VERSION=d381e526d68a2d0c951f37040c1c2e168ac66cd6 | |||
PKG_VERSION=ee01ab57eaaa8805916601dd444d1b63f03037de |
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 see there's an update to the gecko sdk. Is this intended here?
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.
Yeah, the update is intended, as they provide the utility methods to convert bits to enums.
I also wonder how is this configurable at compile time. The only way to change the behaviour is to modify the source code, which seems not super practical. Maybe you can add an |
71a4d7e
to
02ba86b
Compare
@kYc0o As we discussed on IRC, I have updated this PR to make this feature optional (in favor of code size, because the current boards/configuration doesn't make use of this feature). I did not make it configurable for each UART interface, since I think that if this is a desired feature, we should fix #5899. I opted for a solution that I can reuse to make other parts of EFM32 optional, like disabling support for low-power peripherals (if not used). So the last two commits may seem like a lot, I want to re-use them and provide a uniform interface/place for EFM32 specific features/toggles. Note that Murdock won't test the code, but if you manually test it and provide |
c6fc3c7
to
a4734cd
Compare
Ok, I think we're good here. You may squash. |
a4734cd
to
be29e0a
Compare
Squashed and rebased. |
be29e0a
to
6789c49
Compare
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.
ACK and go!
Contribution description
I need non-standard UART modes for some (KNX) transceivers that want 8E1. This PR adds them as an option to the
uart_config
struct, similar to how it was done for some Kinetis boards. The default remains 8N1, for both USART and LEUART.Conversion methods were added to Gecko-SDK (see this commit), which minimizes the changes in the RIOT code and provides a clean abstraction for both USART and LEUART.
Issues/PRs references
#5899, #7165