Hi,
You don't need to write IRQ handlers, the various drivers declare their own handlers internally and give you callbacks. The structure el0 and el1 are used to associate an event source to a thread, once registered there is no need to touch those again. The demo application is an example of various ways to do the same thing, using events or callbacks or direct synchronization.
Giovanni
[NEW] Improved PAL driver with synchronous API
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
The different ways to use PAL triggers?
Hello Giovanni / ChibiOS,
The ChibiOS seems excellent, well thought and well supported RTOS/HAL! Thank you for all the work on it!
Sorry to necro this old thread, but this seems to match my query the best. I feel inadequate starting with the PAL callbacks and events...
In the HAL-event-demo there are some routes: the palWaitLineTimeout is obvious and clear, but not useful for me, when I need to wait on several different lines and work differently on each of them. And there are also other threads abound.
The callback API is very clear! Excellent.
But the example implementation leans on callback-broadcast-event-catch-trigger-thread(s). It seems very proficient also, but very intimidating.
==> Can the PAL callback be used directly, in simple fast use case? instead of main-(or other )thread event waiting and event rerouting? If I set, can I work directly on it with ? Or do I need to declare the events, fire them from the bound callback, and then sort them somewhere in a chEvtWait-thread? Like the main-thread in PAL_USE_CALLBACKS example. I can understand this might be required because of interrupt priority/MCU/core needs, but that isn't close to my heart at this time.
The Events look to be good and efficient low level mechanism, but it isn't packaged very neat, and looks quite intimidating for beginner ChibiOSer. I would need to define numerous events, and would have largish Event switch case... I'd rather prefer simpler approach with direct interrupt-callback? If the above is possible, then the HAL-event-demo would benefit from having third use case "PAL_USE_EVENTS".
Sorry, and thanks for possible tips!
The ChibiOS seems excellent, well thought and well supported RTOS/HAL! Thank you for all the work on it!
Sorry to necro this old thread, but this seems to match my query the best. I feel inadequate starting with the PAL callbacks and events...
In the HAL-event-demo there are some routes: the palWaitLineTimeout is obvious and clear, but not useful for me, when I need to wait on several different lines and work differently on each of them. And there are also other threads abound.
The callback API is very clear! Excellent.
But the example implementation leans on callback-broadcast-event-catch-trigger-thread(s). It seems very proficient also, but very intimidating.
==> Can the PAL callback be used directly, in simple fast use case? instead of main-(or other )thread event waiting and event rerouting? If I set
Code: Select all
palSetLineCallback(BUTTON_A, button_A_cb, NULL);
Code: Select all
void button_A_cb() { setLedA(LED::ON); }
The Events look to be good and efficient low level mechanism, but it isn't packaged very neat, and looks quite intimidating for beginner ChibiOSer. I would need to define numerous events, and would have largish Event switch case... I'd rather prefer simpler approach with direct interrupt-callback? If the above is possible, then the HAL-event-demo would benefit from having third use case "PAL_USE_EVENTS".
Sorry, and thanks for possible tips!
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: [NEW] Improved PAL driver with synchronous API
Hi,
It is not that complex, in ChibiOS all callbacks are called from ISRs, you can use in there any function that can be called from ISRs, in ChibiOS those functions are tagged by the "I" or "X" name suffixes (please look at docs about suffixes or in the online book).
Manipulating a GPIO is one of those things you can do directly from callbacks, just call normal PAL functions even if not suffixed, PAL is a special case, it is register-level code and it is all inlined, very fast.
No need to use the RTOS events at all, those are just part of the example.
Giovanni
It is not that complex, in ChibiOS all callbacks are called from ISRs, you can use in there any function that can be called from ISRs, in ChibiOS those functions are tagged by the "I" or "X" name suffixes (please look at docs about suffixes or in the online book).
Manipulating a GPIO is one of those things you can do directly from callbacks, just call normal PAL functions even if not suffixed, PAL is a special case, it is register-level code and it is all inlined, very fast.
No need to use the RTOS events at all, those are just part of the example.
Giovanni
Re: [NEW] Improved PAL driver with synchronous API
Oh my, thank you for the lightning fast reply!
The use case is slightly more complex than I represented: storing data into (global) data structures, just a pair of lines of processing. Later utilizing that in same or lower priority threads. But I understand your answer, to at least at least make the effort to test this in practice!
And for learning, I'll be sure to make also event distribution practice, to get over it. And to understand the I and X levels. Any playembedded level articles on those? Mille grazie!
The use case is slightly more complex than I represented: storing data into (global) data structures, just a pair of lines of processing. Later utilizing that in same or lower priority threads. But I understand your answer, to at least at least make the effort to test this in practice!
And for learning, I'll be sure to make also event distribution practice, to get over it. And to understand the I and X levels. Any playembedded level articles on those? Mille grazie!
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: [NEW] Improved PAL driver with synchronous API
Events are a bit hard hard (because extremely flexible), better start from something else. The PAL demo is an example of Events anyway.
You should look PlayEmbedded for basic articles, the book in the documentation section and the various articles also on chibios.org.
Giovanni
You should look PlayEmbedded for basic articles, the book in the documentation section and the various articles also on chibios.org.
Giovanni
Return to “Development and Feedback”
Who is online
Users browsing this forum: No registered users and 39 guests