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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
691件の閲覧回数
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

タグ(3)
0 件の賞賛
返信
1 解決策
553件の閲覧回数
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 件の賞賛
返信
1 返信
554件の閲覧回数
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 件の賞賛
返信