Skip to content

rp2040: Bugfix UART initialisation: Mixup of Zephyr constants and rpi-hal constants #52348

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

Merged

Conversation

68ec020
Copy link
Contributor

@68ec020 68ec020 commented Nov 17, 2022

rpi-hal function "uart_set_format" expects data width in the range of 5..8. So you can't use the Zephyr abstraction constant UART_CFG_DATA_BITS_8 directly, because its value is 3. There is already a translation in "uart_rpi_configure", but it is not used for the default initialisation. So I reused "uart_rpi_configure". There is only one downside: It also sets the baud rate, which is already done in "uart_rpi_init".

@68ec020 68ec020 requested a review from yonsch as a code owner November 17, 2022 20:18
@zephyrbot zephyrbot added the area: UART Universal Asynchronous Receiver-Transmitter label Nov 17, 2022
@zephyrbot zephyrbot requested a review from dcpleung November 17, 2022 20:18
@68ec020 68ec020 force-pushed the rp2040-uart-initialization branch 3 times, most recently from 73cda38 to 971e4a8 Compare November 17, 2022 20:34
dcpleung
dcpleung previously approved these changes Nov 17, 2022
@dcpleung dcpleung requested a review from nordicjm November 17, 2022 20:38
@dcpleung
Copy link
Member

@WebmasterTD

rpi-hal function "uart_set_format" expects data width in the range
of 5..8. So I created a new function “uart_rpi_set_format” which
contains common parts of “uart_rpi_configure”.

Signed-off-by: Jan Hilsdorf <[email protected]>
@68ec020
Copy link
Contributor Author

68ec020 commented Nov 18, 2022

I decided I didn't like the baud rate being set twice. So a change the code a bit. I created a new function "uart_rpi_set_format" which contains everything from "uart_rpi_configure" which is format related. This function is then used in "uart_rpi_init" and "uart_rpi_configure".

@yonsch
Copy link
Collaborator

yonsch commented Nov 18, 2022

@68ec020 Thanks. Did you check that dynamic configuration still works?

@68ec020
Copy link
Contributor Author

68ec020 commented Nov 18, 2022

I just wrote a small test program to switch between 115200 and 9600 every second. It works as expected.

@stephanosio stephanosio merged commit a429528 into zephyrproject-rtos:main Nov 19, 2022
@68ec020 68ec020 deleted the rp2040-uart-initialization branch November 19, 2022 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: UART Universal Asynchronous Receiver-Transmitter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants