I have a requirement to use a (STM32) serial port with either the serial or the UART drivers, dependent on a startup configuration option.
The main requirement not handled by the serial driver is the ability to process received data on a character-by character basis. On some devices its also necessary to know when the transmit buffer is empty.
I was able to add these features to the serial driver quite easily, as attached. The extra code is small enough that it could be left permanently enabled; adding a #define to enable it would also be straightforward.
Use in 'UART' mode is very similar to that of the existing UART driver - I've added four callbacks for the important events. If these are non-NULL, they are used; otherwise the normal serial driver processing takes place. I've assumed 'all or nothing' on the callbacks, although it may be possible to use just those which are wanted without confusing the queue routines. It should even be possible to swap modes on the fly, by simply updating the callbacks.
The serial driver is interrupt driven, which is fine for me - I mostly use the UART driver interrupt-driven anyway, due to DMA conflicts. Plus using DMA to receive single characters is probably less efficient than direct reception using interrupts.
Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
3 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest