Doubt regarding drivers implementation

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
0x3333
Posts: 41
Joined: Thu Mar 07, 2019 10:19 pm
Has thanked: 7 times
Been thanked: 3 times

Doubt regarding drivers implementation

Postby 0x3333 » Wed May 01, 2019 3:23 am

Hi!

I'm working in a project that needs more uart than available. As the requirements are for 9600 baud and 6 devices, low bandwidth, I'll implement a software uart, the same concept as the classical "generic software uart" by Colin Gittins(IAR).

I'm thinking creating a SoftUart driver, so far so good, but I'd like o use GPT as timer and EXT as interrupt for RX.

The question is, would it be useful to add to Chibios? if so, is that possible to use a driver inside another one? I couldn't find a similar usage.

If not useful to Chibios, I'll write it more "Savage"...

Thanks.

faisal
Posts: 242
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 35 times
Been thanked: 32 times

Re: Doubt regarding drivers implementation

Postby faisal » Wed May 01, 2019 3:56 am

If you make it a buffered driver, you can use the hal_serial.h abstraction, as it uses virtual method tables for the implementation. If you need per character interrupts, that would be more like hal_uart - and that is tied to a specific lld file.

0x3333
Posts: 41
Joined: Thu Mar 07, 2019 10:19 pm
Has thanked: 7 times
Been thanked: 3 times

Re: Doubt regarding drivers implementation

Postby 0x3333 » Wed May 01, 2019 5:10 pm

My use case is more like a UART, chat based than serial. That is what I was thinking about, using virtual methods and the same interface. The doubt is if is possible/allowed to use another driver inside it.

User avatar
Giovanni
Site Admin
Posts: 11949
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 537 times
Been thanked: 449 times
Contact:

Re: Doubt regarding drivers implementation

Postby Giovanni » Wed May 01, 2019 6:33 pm

Hi,

We have a soft (fallback) I2C already, it would be possible to create a similar UART implementation but it would be difficult for the reason Faisal mentioned, the serial driver is meant to be asynchronous and buffered, it would be hard to create a SW UART operating asynchronously at decent speeds.

It would require some kind of state machine sitting on top of a timer, may be a GPT instance.

A stand-alone UART library would be easier.

Giovanni

0x3333
Posts: 41
Joined: Thu Mar 07, 2019 10:19 pm
Has thanked: 7 times
Been thanked: 3 times

Re: Doubt regarding drivers implementation

Postby 0x3333 » Thu May 02, 2019 4:09 am

You're right. I'll create a standalone implementation, and eventually see how it performs. I'll let you guys posted.

Thanks.


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 1 guest