[DEV] The new SIO driver
Posted: Mon Aug 31, 2020 10:31 am
Hello,
I wanted to discuss this topic, the new SIO driver.
It is the 3rd driver that uses the USART, we already had the SERIAL and UART drivers so why a 3rd one?
My reasoning:
- Serial is easy to use but it suffers from bad performance because SW FIFOs.
- Serial does not leverage HW FIFOs very well because it assumes SW FIFOs (you cannot do a serial driver without those, are part of the model).
- Serial is not able to use callbacks nor to be used from ISR (easily).
- Events handling is hard in serial driver.
- UART is hard to use and is meant to handle very specific scenarios.
Now the SIO driver:
- It implements a stream like serial so you can use chprintf() and so on.
- It is callback-able.
- If callbacks are not used then interrupts are not enabled and can be used in polled mode.
- Read and write are always asynchronous.
- It has synchronization APIs for synchronous operations.
- It leverages internal FIFOs and thresholds so it can operate at high speed with few interrupts served (depends on the FIFO depth and threshold settings),
- A Serial driver equivalent can be built on top of a SIO implementation. We could create an adapter driver later, serial could be removed too (much later).
- It can also use DMAs with SIO but DMA API has to be called from application, SIO does not use DMA directly. UART driver could also be emulated using some kind of wrapper driver.
- It uses that new HAL paradigm we discussed in another topic.
The code is on SVN now, I am starting tests. Probably it will change some more in next days.
Giovanni
I wanted to discuss this topic, the new SIO driver.
It is the 3rd driver that uses the USART, we already had the SERIAL and UART drivers so why a 3rd one?
My reasoning:
- Serial is easy to use but it suffers from bad performance because SW FIFOs.
- Serial does not leverage HW FIFOs very well because it assumes SW FIFOs (you cannot do a serial driver without those, are part of the model).
- Serial is not able to use callbacks nor to be used from ISR (easily).
- Events handling is hard in serial driver.
- UART is hard to use and is meant to handle very specific scenarios.
Now the SIO driver:
- It implements a stream like serial so you can use chprintf() and so on.
- It is callback-able.
- If callbacks are not used then interrupts are not enabled and can be used in polled mode.
- Read and write are always asynchronous.
- It has synchronization APIs for synchronous operations.
- It leverages internal FIFOs and thresholds so it can operate at high speed with few interrupts served (depends on the FIFO depth and threshold settings),
- A Serial driver equivalent can be built on top of a SIO implementation. We could create an adapter driver later, serial could be removed too (much later).
- It can also use DMAs with SIO but DMA API has to be called from application, SIO does not use DMA directly. UART driver could also be emulated using some kind of wrapper driver.
- It uses that new HAL paradigm we discussed in another topic.
The code is on SVN now, I am starting tests. Probably it will change some more in next days.
Giovanni