HAL Event Sources / Listeners etc?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
avrhack
Posts: 140
Joined: Tue Dec 24, 2013 1:42 pm
Has thanked: 17 times
Been thanked: 3 times

HAL Event Sources / Listeners etc?

Post by avrhack »

Apologies if I've missed this - I have looked in the documentation at length and the FAQ on this site - but I can't see anything that tells me what events the various HAL drivers can generate.

I've noticed they do indeed generate events, but at the moment I'm having to work through each drivers code and headers to figure out what can appear, combined with examining the testhal code which in some cases also uses events.

Is there any documentation on this as it doesn't seem to be part of the reference manual for each HAL module?

Thanks.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: HAL Event Sources / Listeners etc?

Post by Giovanni »

Hi,

Probably the documentation could be better organized. Anyway, only few drivers generate events, most use direct callbacks.

Those using events are Serial, Serial_USB, CAN and (optionally) MAC:
http://chibios.sourceforge.net/html/gro ... n_e_l.html
http://chibios.sourceforge.net/html/group___m_a_c.html
http://chibios.sourceforge.net/html/group___c_a_n.html

Look in the xxxDriver structure for the available event sources.

Giovanni
avrhack
Posts: 140
Joined: Tue Dec 24, 2013 1:42 pm
Has thanked: 17 times
Been thanked: 3 times

Re: HAL Event Sources / Listeners etc?

Post by avrhack »

Great thanks Giovanni - and especially for the super-fast reply! Funnily enough CAN and Serial were the two I was experimenting with, so I hadn't realised that it was relatively few that used events; it seems like an excellent model so I'd be interested in the rationale for not using more widely?

Overall though, really impressed with your work on ChiBIOS. I've been programming AVRs for years and never use an OS; decided to move to ARM only a week ago and did some research and using ChiBIOS has made the learning curve much, much quicker than it would otherwise have been, as well as making the code much more structured and reliable because of the threading and other core kernel components.

Brilliant!
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: HAL Event Sources / Listeners etc?

Post by Giovanni »

Hi,

Events are used in those drivers meant to interact with threads directly (asynchronous communication usually), other drivers simply have callbacks. From a callback events can still be generated if the user wants to operate that way.

Note that a callback not necessarily triggers a context switch in order to do its operation, events always wake up another thread so are a little bit less efficient.

Giovanni
avrhack
Posts: 140
Joined: Tue Dec 24, 2013 1:42 pm
Has thanked: 17 times
Been thanked: 3 times

Re: HAL Event Sources / Listeners etc?

Post by avrhack »

Makes perfect sense now thanks. You can tell I'm still getting to grips with ChiBIOS can't you? :)
Post Reply