Understanding PAL and ChibiOS Events

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
JSStabl
Posts: 78
Joined: Tue Feb 25, 2020 4:06 pm
Has thanked: 3 times
Been thanked: 2 times

Understanding PAL and ChibiOS Events

Post by JSStabl »

I read this great tutorial about the PAL Event System and how to execute threads based on a GPIO port. https://www.playembedded.org/blog/buttons-stm32/

However some things are unclear to me. According to the chibiOS documentation, threads register to events by using an event listener. (Taken from here: http://chibios.org/dokuwiki/doku.php?id ... nel_events). However in the tutorial no event listeners a used. Just a simple wait function. How does the implementation in the tutorial differ from the one explained in the wiki? What happens if multiple threads execute the palWaitPadTimeout function for the same event? (That seems to work). Is there a similar way to enable a event for the end of an SPI receive?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Understanding PAL and ChibiOS Events

Post by Giovanni »

Hi,

PAL events and RTOS events are two different and unrelated things, the article on play embedded is correct. RTOS events are a generic mechanism used by some other drivers.

Giovanni
JSStabl
Posts: 78
Joined: Tue Feb 25, 2020 4:06 pm
Has thanked: 3 times
Been thanked: 2 times

Re: Understanding PAL and ChibiOS Events

Post by JSStabl »

Thanks for the explanation, I figured the play article is correct, since it works. I just wanted to understand why it works the way it does :)
Maybe something can be done to differentiate the two different event types?

How does the PAL events deal with multiple threads waiting for the same event? I couldn't find any more documentation on it.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Understanding PAL and ChibiOS Events

Post by Giovanni »

All waiting threads are woken together on event.

Giovanni
Post Reply