Is there an "elegant" way to handle event interrupts in a 'MQX + PE' application?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there an "elegant" way to handle event interrupts in a 'MQX + PE' application?

Jump to solution
469 Views
lfschrickte
Contributor IV

Hi folks,

If you configure an Event via PE interface in the BSP project, (let's say, a TimerUnit TimerCounterRestart event) is there a way to handle this event in the application directly, instead of programming it in the function generated by PE in the BSP project?

I've figured out two possible approaches:

1. Disable PE event and install the interrupt manually via MQX functions in the application. Cons: I'll need to check which interrupt happened manually and there is a risk of creating some conflict with PE generated code.

2. Configure the event, and when a TU1_OnCounterRestart event happens, set bits on an app MQX event, post to an app semaphore or call an app function, all of them, as said, in the application (and declared as external symbol in the bsp.a compilation)

Is there any other way to do this? I wish I could keep one BSP configured for more than one project in the same board. Otherwise, I will need to have one BSP per project, even if I'm using the same board!

Thank you!

Luiz Fernando

0 Kudos
1 Solution
331 Views
matthewkendall
Contributor V

Approach 2 (call an app function) is what I have done. TU1_Interrupt() (automatically generated by PE in TU1.c) calls TU1_OnCounterRestart() (automatically generated by PE in Events.c). That function is nothing more than a /* Write your code here */ block. Rather than writing the code there, if you just call appTU1OnChannel() or similar, then your app can either implement that function or stub it out as needed.

If you wanted to get fancy you could have some #defines in user_config.h to conditionalise the call, so apps that did not need the feature needn't have the stub. You would have to recompile the BSP for each project, but it would be compiled from the same set of source files, just with a different user_config.h (which is how all other project-specific differences are handled).

View solution in original post

0 Kudos
1 Reply
332 Views
matthewkendall
Contributor V

Approach 2 (call an app function) is what I have done. TU1_Interrupt() (automatically generated by PE in TU1.c) calls TU1_OnCounterRestart() (automatically generated by PE in Events.c). That function is nothing more than a /* Write your code here */ block. Rather than writing the code there, if you just call appTU1OnChannel() or similar, then your app can either implement that function or stub it out as needed.

If you wanted to get fancy you could have some #defines in user_config.h to conditionalise the call, so apps that did not need the feature needn't have the stub. You would have to recompile the BSP for each project, but it would be compiled from the same set of source files, just with a different user_config.h (which is how all other project-specific differences are handled).

0 Kudos