Skip to content

Nuvoton: Refine UART init/deinit #8900

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
merged 4 commits into from
Dec 4, 2018

Conversation

ccli8
Copy link
Contributor

@ccli8 ccli8 commented Nov 29, 2018

Description

This PR refines UART init/deinit, especially when there are multiple serial_t structs sharing the same H/W UART. It includes:

  1. Remove unused pin_tx/pin_rx fields from serial_s struct
  2. Avoid re-configuring the shared H/W UART in serial_init()
  3. Check configuration option for default UART baudrate setting
  4. Fix init/deinit time of stdio_uart

Targets

  • NUMAKER_PFM_NANO130

  • NUMAKER_PFM_NUC472

  • NUMAKER_PFM_M453

  • NUMAKER_PFM_M487/NUMAKER_IOT_M487

  • NUMAKER_PFM_M2351

    [x] Fix
    [ ] Refactor
    [ ] Target update
    [ ] Functionality change
    [ ] Docs update
    [ ] Test update
    [ ] Breaking change

… UART

The same H/W UART may be shared by multiple serial_t objects. This fix tries to avoid
re-configuring the same H/W UART in serial_init() when there are multiple serial_t
objects constructed. To re-configure UART, call serial_baud() and serial_format()
explicitly. This can avoid confusion when e.g. a newly constructed serial_t object
changes baudrate unexpectedly in serial_init().
With support for checking H/W UART initialized or not, we can simplify stdio management:
1. When serial_init(&stdio_uart) calls in, just set the 'stdio_uart_inited' flag.
2. When serial_free(&stdio_uart) calls in, just clear the 'stdio_uart_inited' flag.
Except above, we needn't make special handling with 'stdio_uart'.
@0xc0170 0xc0170 requested a review from a team November 29, 2018 09:01
Copy link

@deepikabhavnani deepikabhavnani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

Copy link
Contributor

@cmonr cmonr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@cmonr
Copy link
Contributor

cmonr commented Dec 4, 2018

CI started

@mbed-ci
Copy link

mbed-ci commented Dec 4, 2018

Test run: SUCCESS

Summary: 4 of 4 test jobs passed
Build number : 1
Build artifacts
Build logs

@cmonr cmonr merged commit 0f0e63a into ARMmbed:master Dec 4, 2018
@ccli8 ccli8 deleted the nuvoton_refine_uart branch December 5, 2018 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants