[riot-notifications] [RIOT] drivers: peripheral UART driver interface overhaul (#3265)

Hauke Petersen notifications at github.com
Mon Jun 29 11:37:41 CEST 2015


TX is indeed the slightly more advanced part of the UART driver. But I see no problem for implementing `printf` or `flush` in a sensible way with the existing interface:

In the syscalls/uart_syscalls implementation, we define a ringbuffer for TX data. When ever `printf` is called, the following happens:

- add data to ringubffer
- call `uart_tx_begin()`

The TX callback should look more or less like this:
```c
int tx_cb(arg *arg)
{
    if (tx_buf.avail > 0) {
        char data = ringbuffer_get_one(&tx_buf);
        uart_write(DEV, data);
        return 1;
    }
    return 0;
```

`flush` could be easily implemented by looping of `while (tx_buf.avail > 0)` with some delay like something ~10ms or so in between.

> Is it possible to change the rx/tx callbacks after initializing the module?
Are there any use cases where it would be desirable to change callbacks without reinitializing?

There is no way at the moment, but neither do I really see a use case for this. But you can of course always call `uart_init` again.

---
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/3265#issuecomment-116574119
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20150629/754c80fc/attachment.html>


More information about the notifications mailing list