Page 1 of 1

HAL state machines

Posted: Sat Jun 18, 2011 11:03 pm
by liamstask
A thought about the 'state' member variables in many of the HAL driver models structs.

In some cases (at least for GPT), the state variable is only used within chDbgAssert() to validate the drivers' state. If this is the case, one small optimization might be to only define and manage the appropriate state variables when chDbgAssert() is enabled in the build. In a 'release' configuration this would save a byte of RAM and a (tiny) bit of CPU, for each relevant driver model. Would this be sensible?

Re: HAL state machines

Posted: Sun Jun 19, 2011 7:28 am
by Giovanni
Hi,

The state is checked in the low level driver in xxxStart/xxxStop functions, often also the ISR code performs checks on the state. Some drivers also export to the application an xxxGetDriverState() API when the driver state has to be accessed externally.

Giovanni

Re: HAL state machines

Posted: Sun Jun 19, 2011 5:00 pm
by liamstask
Woops - I obviously didn't look closely enough. Sorry for the noise!

Re: HAL state machines

Posted: Mon Jun 20, 2011 5:50 pm
by Giovanni
No need to apologize, thanks also to your past noises :-) the project improved and evolved.

Giovanni