[riot-notifications] [RIOT-OS/RIOT] [RFC, WIP] periph/uart: improve API (#16633)

Marian Buschsieweke notifications at github.com
Fri Jul 9 20:18:41 CEST 2021

### Contribution description

The `periph/uart` API aims to be a low-level API and has to be implement again and again for every different hardware implementation. For this reason, it makes sense to streamline the API to aid driver development. Convenience features that can be implemented hardware independent on top once really should be implemented there.

The `uart_poweron()` function is barely used. Without having checked the implementation, I would bet that at least one third of the implementations are broken. It is also unlikely that hardware is wasting power on retaining configuration register contents of powered down UART peripherals. Hence, low level UART implementations will often have to spent RAM on storing a backup of the configuration to restore on power on again. This is wasteful, as the configuration has to be already be stored somewhere else in the firmware (typically in ROM), as it needs to be provided during the call to `uart_init()`.

Hence: Drop `uart_poweron()` and expect users to call `uart_init()` again when to repower the UART.

The same arguments apply to `uart_init_pins()` and `uart_deinit_pins()`. And since `uart_init()` is called now anyway after each power down - which initializes the pins again anyway - there definitely is no need for it anymore. And since many implementations of `gpio_init()` would automatically disconnect the GPIOs from the UART, there is no need for `uart_deinit_pins()` for them. Instead, the API now asks `uart_poweroff()` to disconnect the TXD/RXD GPIOs from the UART peripheral, if this is needed to free them up again for us with `gpio_init()`. 

### Testing procedure

So far, only the API changes should be discussed. There will be code changes once an agreement is reached.

### Issues/PRs references

Depends on an includes: https://github.com/RIOT-OS/RIOT/pull/16632
You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * periph/uart: Fix doc, use errno for return values
  * periph/uart: Improve API

-- File Changes --

    M drivers/include/periph/uart.h (103)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210709/2eac2e7e/attachment.htm>

More information about the notifications mailing list