[riot-notifications] [RIOT-OS/RIOT] stm32/periph/uart: set flow control bits before enabling uart (#15725)

seeseemelk notifications at github.com
Fri Jan 8 11:38:01 CET 2021


<!--
The RIOT community cares a lot about code quality.
Therefore, before describing what your contribution is about, we would like
you to make sure that your modifications are compliant with the RIOT
coding conventions, see https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions.
-->

### Contribution description

<!--
Put here the description of your contribution:
- describe which part(s) of RIOT is (are) involved
- if it's a bug fix, describe the bug that it solves and how it is solved
- you can also give more information to reviewers about how to test your changes
-->
The STM32 datasheets specify that in order to enable hardware flow control, the `CTSE` and `RTSE` bits should be set. It also states that these have to be set _before_ the `UE` bit is set.
In RIOT, the `CTSE` and `RTSE` bits were set _after_ the `UE` bit was already set. Because of this, the state of `RTSE` and `CTSE` were never actually changed. By moving the bit of code that sets `CTSE` and `RTSE` to a point before `UE` is set, hardware flow control is being enabled correctly. 


### Testing procedure

<!--
Details steps to test your contribution:
- which test/example to compile for which board and is there a 'test' command
- how to know that it was not working/available in master
- the expected success test output
-->
The bug was found and tested using a custom board developed internally. This board uses a modem which requires hardware flow control.

We noticed no data was being transmitted when using RIOT's hardware flow control. When manually controlling the flow control pins using the gpio functions, data was flowing but with some bytes randomly disappearing.
After this change, data was flowing and there was no more loss of data.

When running the current code using a debugger, it can be seen that `RTSE` and `CTSE` stay low even after RIOT sets them. With this change, `RTSE` and `CTSE` are set after `uart_init()` has been executed.



<!--

### Issues/PRs references
Examples: Fixes #1234. See also #5678. Depends on PR #9876.

Please use keywords (e.g., fixes, resolve) with the links to the issues you
resolved, this way they will be automatically closed when your pull request
is merged. See https://help.github.com/articles/closing-issues-using-keywords/.
-->

You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/15725

-- Commit Summary --

  * stm32/periph/uart: set flow control bits before enabling uart

-- File Changes --

    M cpu/stm32/periph/uart.c (18)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/15725.patch
https://github.com/RIOT-OS/RIOT/pull/15725.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/15725
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210108/62304947/attachment.htm>


More information about the notifications mailing list