HAL state machines

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
Post Reply
liamstask
Posts: 34
Joined: Wed Dec 08, 2010 5:42 pm

HAL state machines

Post 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?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: HAL state machines

Post 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
liamstask
Posts: 34
Joined: Wed Dec 08, 2010 5:42 pm

Re: HAL state machines

Post by liamstask »

Woops - I obviously didn't look closely enough. Sorry for the noise!
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: HAL state machines

Post by Giovanni »

No need to apologize, thanks also to your past noises :-) the project improved and evolved.

Giovanni
Post Reply