How to install 2 interrupts (Falling/Rising) for 1 input GPIO (Switch) (MQX)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to install 2 interrupts (Falling/Rising) for 1 input GPIO (Switch) (MQX)

跳至解决方案
1,599 次查看
vinhpham
Contributor I

Hi all,

I'm working on GPIO module, Vybrid Tower Board (MQX OS). I want to install 2 interrupts (falling/rising) on GPIO input switch BSP_SW1. So how to register 2 interrupt service routine on this gpio?

Thanks!

标记 (3)
1 解答
1,086 次查看
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Let me see if I understand correctly. You want to install 2 different callbacks, one for rising and other for falling edge pro the BSP_SW1, right?

So far the the MQX API only supports one callback. I would do it in the next way:

1.- Install one general callback that is generated  for rising and falling edge.

2.- In that callback check the state of the pin and execute one routine or other depending on the state of the pin.

You have to keep in mind that there is one interrupt vector per PORT. Therefore you have to implement a more complex handler if you want to detect the pin that caused the interrupt.

Best Regards,

Alejandro

在原帖中查看解决方案

2 回复数
1,087 次查看
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Let me see if I understand correctly. You want to install 2 different callbacks, one for rising and other for falling edge pro the BSP_SW1, right?

So far the the MQX API only supports one callback. I would do it in the next way:

1.- Install one general callback that is generated  for rising and falling edge.

2.- In that callback check the state of the pin and execute one routine or other depending on the state of the pin.

You have to keep in mind that there is one interrupt vector per PORT. Therefore you have to implement a more complex handler if you want to detect the pin that caused the interrupt.

Best Regards,

Alejandro

1,086 次查看
vinhpham
Contributor I

Thank Alejandro Lozano. Your answer is good.

0 项奖励
回复