Drivers
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Drivers
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
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
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.
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.
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Drivers
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
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
Hi Tinker,
If looking for examples of file stream abstraction realization you can check out my EEPROM driver https://github.com/barthess/24aa
If looking for examples of file stream abstraction realization you can check out my EEPROM driver https://github.com/barthess/24aa