Just few notes for posterity. Currently I am working on a SW project requiring something like the HAL and decided to explore new directions, I must say that I am liking the result.
Basically it is about making the various drivers API more consistent and convenient to use (not that it is hard to use right now...). The driver model is based on the following common API.
Code: Select all
msg_txxxStart(drv, drvconfig)
void xxxStop(drv)
void xxxStartOperation(drv, opconfig)
void xxxStopOperation(drv)
msg_t xxxSynchronize(drvm timeout)
Start and stop are similar to the current ones except start may fail. The different thing is:
xxxStartOperation()
It activates the driver to asynchronously perform the operation encoded in "opconfig" structure which is something similar to the current ADC conversion group structure.
This structure contains all the required information for the operation to be performed such as:
- pointers to buffers
- size of transfers
- callback pointers (no more in the driver config, it is per-operation)
- flags like circular mode false/true
- low level settings like ADC channels, if applicable
- etc
The really new one is xxxSynchronize() which waits for the ongong operation to terminate (by itself or using xxxStopOperation()) and returns an operation status. Another thing I did is to make the driver configuration structure also contain DMA/IRQ settings and do not assume those are defined into an mcuconf.h file, this reduces the driver dependencies on a lot of things.
Another change is to de-focus on API classes for simplicity, xxxStartOperation() and xxxStopOperation() would work in any context (X-class always), of course xxxSynchronize() would be limited to threads.
Most I/O drivers could be reduced to this kind of API, the rework would be huge and break a lot of things so currently I am just writing this as note, food for thought.
Giovanni