I'm using inline asm to create and use "custom" chanend in a task (to have many-to-one/one-to-many links and save resources) with an event. It works fine, but I would like to use it with a conventional XC select-case statement to handle other events like timers or ports.
By taking a look to the disassembly of some basic xc task code, I saw that there is a clre instruction at the beginning of the select implementation, so:
- I can't setup my event before the select
- I need to add my event setup code in the setup part of the select implementation
But how to add custom asm code in that part of the code ?
And is it possible to create a custom case block to handle the event (in a "clean" way) ? I found a possible working solution by using a label just before the select and branching to it after the execution of my code. It's not very clean, but it should work if I find a way to enable the chanend event.
Any solution is welcome !
Thanks !
Some code for illustration...
Code: Select all
void task()
{
// Setup
// inline asm to setup chanend
while (1) {
asm("selectsetup:");
select { // insert custom asm to setup my chanend event
case custom: // Custom case statement to handle chanend event
{
// Handle chanend event
}
case t when timerafter(time) :> void: // Juste for example
{
// Code
}
}}
// Code to process chanend event
asm("chanendvector:");
... // Custom code
asm("bu selectsetup");
}