Page 1 of 1
Drivers
Posted: Tue Feb 28, 2012 7:53 pm
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.
Re: Drivers
Posted: Tue Feb 28, 2012 8:10 pm
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
Re: Drivers
Posted: Tue Feb 28, 2012 11:28 pm
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.
Re: Drivers
Posted: Wed Feb 29, 2012 8:59 am
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
Re: Drivers
Posted: Fri Mar 02, 2012 6:03 pm
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