Drivers

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Tinker
Posts: 14
Joined: Tue Feb 28, 2012 6:55 pm

Drivers

Post by Tinker »

Is there a concept in ChibiOS of character devices vs. block devices? I notice there is a SerialVMT but I don't see it used anywhere else.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Drivers

Post by Giovanni »

Hi,

No, the device drivers in ChibiOS are not divided in char oriented and block oriented. There is too diversity in an embedded OS and trying to constrain all the possible device drivers types into just two generic categories would require heavy abstraction layers, heavy in terms of footprint and reduced efficiency.

In general each device driver model implements its own paradigm even if all device driver classes inherits from a generic device driver model and all share some common methods like: xxxStart(), xxxStop(), xxxInit(), xxxInitObject().

About SerialVMT, it is used by the macros that wrap the access to virtual methods of the Serial device driver class, user code should not access it directly. See the macro chIOGetAndClearFlags() in chioch.h for example.
The serial driver inherits and implements an interface defined in chioch.h this is why you don't see the VMT used in the context of the serial driver, it is accessed by ancestor interfaces.

Sorry for the Java/C++ like terminology but that part cannot be easily explained in other way. ChibiOS is strongly object oriented even if it is written in C.

Giovanni
Tinker
Posts: 14
Joined: Tue Feb 28, 2012 6:55 pm

Re: Drivers

Post by Tinker »

Hi,

Makes sense. Is there anything I can do if I want to abstract a character I/O serial device, or a block I/O device? (Say, serial, but preserving frames) I also noticed there's a SequencialStream class, but I haven't seen if it's used anywhere.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Drivers

Post by Giovanni »

Streams-like data are already abstracted, there is a hierarchy of classes already in place and it is the preferred way to handle generic streams.

A similar abstraction does not currently exist for block devices (MMC_SPI and SDC) but it could be introduced, it is not a bad idea.

Giovanni
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: Drivers

Post by barthess »

Hi Tinker,
If looking for examples of file stream abstraction realization you can check out my EEPROM driver https://github.com/barthess/24aa
Post Reply