More specifically, is there a function that will tell me if an interrupt has already been enabled for a pin?
In this case, I have two pins on Port B used for interrupts. If an interrupt occurs, I want to know if the corresponding interrupt has been set. If not, I can safely ignore the flag.
Thanks
Solved! Go to Solution.
Hi Alice,
I understand what you are trying to say and that's how I started the code. However, what I found was that, if I have two pins on the same port that are to be used for interrupts, all interrupts came into the same ISR and that the GPIO_DRV_PinIntEnable() routine enables for all pins on the port. That made the situation difficult as there are times when I wanted to ignore any activity on some of the pins. Essentially, I wanted one pin active or another. My solution was to define the pin as an input, but with the interrupt property set to kPortIntDisabled. Then when I want to handle input from that port I used:
PORT_HAL_SetPinIntMode(RTC_Port, GPIO_EXTRACT_PIN(RTC_Pin), kPortIntFallingEdge);
routine. It's sort of a hack as all other manipulation with this pin is done with the GPIO or GAL routines. But this works for me.
Thanks
Hello David,
In KSDK , Enable a specific pin interrupt in GPIO initialization structures.
For example :
Does this answer can help you ?
BR
Alice
Hi Alice,
I understand what you are trying to say and that's how I started the code. However, what I found was that, if I have two pins on the same port that are to be used for interrupts, all interrupts came into the same ISR and that the GPIO_DRV_PinIntEnable() routine enables for all pins on the port. That made the situation difficult as there are times when I wanted to ignore any activity on some of the pins. Essentially, I wanted one pin active or another. My solution was to define the pin as an input, but with the interrupt property set to kPortIntDisabled. Then when I want to handle input from that port I used:
PORT_HAL_SetPinIntMode(RTC_Port, GPIO_EXTRACT_PIN(RTC_Pin), kPortIntFallingEdge);
routine. It's sort of a hack as all other manipulation with this pin is done with the GPIO or GAL routines. But this works for me.
Thanks
Hello David:
Good to know you found the solution. For your case with only one pin active then your approach is correct. As mentioned by Alice the driver takes initialization from the GPIO pins structures, but for updating the configuration at runtime then the easiest way is with the HAL or by modifying the pin's structure and calling GPIO_DRV_InputPinInit() or GPIO_DRV_OutputPinInit().
When having more than 1 pin of the same port with interrupts enabled, then inside the ISR you can check the corresponding flags with GPIO_DRV_IsPinIntPending().
Regards!
Jorge Gonzalez