[AVR] Should I develop a UART or SIO driver to support custom protocols?

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
teknoman117
Posts: 8
Joined: Tue Aug 19, 2025 1:00 am

[AVR] Should I develop a UART or SIO driver to support custom protocols?

Postby teknoman117 » Fri Aug 22, 2025 2:24 am

Hello all!

Still very new here, so far I've only used the AVR port of ChibiOS on a controller embedded into one of my personal robotics projects. Yes, I'll be upgrading to something more powerful in the future, but it's in there, it's powerful enough for what I currently need it to do, etc.

Anyways,

The AVR board (an Arduino Uno R3) communicates with the host computer via its UART over the integrated USB<->UART adapter. The protocol I wrote for it uses COBS/R as the framing format. The only serial/uart driver implemented for the AVR port is the Serial driver, so the receive side is essentially just a thread that calls the following in a loop:

Code: Select all

auto byte = chnGetTimeout(channel, TIME_INFINITE);


Obviously the channel driver is way overkill for this, and ideally I'd like to manage my own ring buffer so that I can do the COBS decoding in the ISR and avoid waking up a packet handling thread for every byte, only waking it up when a framing marker is received.

I'm still trying to understand the difference between the use cases for the SIO driver and the UART driver. Both seem to be intended to interact directly with the underlying peripheral hardware, using the integrated FIFO and potentially DMA on platforms with those features. The ATmega of course has neither. There's technically a single byte receive buffer, but no transmit buffer.

So my question is, if I'm going to try my hand at implementing a new driver for the internal UART, in 2025 should I be implementing a UART driver or an SIO driver? Also, with respect to the fact that the AVR doesn't have FIFOs or DMA...

User avatar
Giovanni
Site Admin
Posts: 14704
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1146 times
Been thanked: 960 times

Re: [AVR] Should I develop a UART or SIO driver to support custom protocols?

Postby Giovanni » Fri Aug 22, 2025 5:49 am

Hi,

The UART driver is packet-oriented, its API is designed for transferring blocks of known size, the Setial driver is for byte-oriented asynchronous communications.

The SIO driver is new, it is meant to be VERY close to the HW, basically it is a SW abstraction of a UART unit. Using the SIO driver it is possible to cover use cases of both UART and Serial. There is a module that emulates a Serial driver on top of SIO, something similar could be done for emulating the UART driver.

For new developments I would recommend SIO.

Giovanni


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 157 guests