Can we enable more than 8 GPIO interrupts? It seems like GPIO_MAX_CHANNELS is 8 but we need more than 8 interrupts in our application.
How do we do this?
Can we enable more than 8 GPIO interrupts? It seems like GPIO_MAX_CHANNELS is 8 but we need more than 8 interrupts in our application.
How do we do this?
I don't think you can. :(
I ran into this same issue with a project: we had two joysticks each with 5 input contacts (up, down, left, right and push to select), for a total of 10 inputs. The solution we ended up using was to put each input on its own GPIO pin, and then use an 11th pin just for the interrupt. We connected each of the 10 inputs to the 11th pin using a diode. In effect, the 11th pin became a shared interrupt. Whenever any one of the 10 inputs was engaged, it would trigger an interrupt on the 11th pin.
The down side was that it required a little bit of added software logic to make it work. We used an RTOS in this project, and there was one thread dedicated to monitoring the inputs. Normally this thread would be asleep. Whenever any input was engaged, we'd get a high-to-low interrupt, which would wake it up. The thread would then keep scanning all the GPIO inputs in a loop to see which inputs were pressed down until the 11th input went high again, which would only occur once all the inputs were released. At that point the thread would sleep again. This was not ideal, but it it was better than the alternative which was to have the thread constantly polling the GPIOs.
We considered using an I/O expander (which talks to the MCU via I2C and has an interrupt pin), but that would have had more overhead since the only way to poll the GPIO pins would be by performing an I2C transfer. (By contrast, polling the internal GPIOs just requires at most reading two registers.)
-Bill
I don't think you can. :(
I ran into this same issue with a project: we had two joysticks each with 5 input contacts (up, down, left, right and push to select), for a total of 10 inputs. The solution we ended up using was to put each input on its own GPIO pin, and then use an 11th pin just for the interrupt. We connected each of the 10 inputs to the 11th pin using a diode. In effect, the 11th pin became a shared interrupt. Whenever any one of the 10 inputs was engaged, it would trigger an interrupt on the 11th pin.
The down side was that it required a little bit of added software logic to make it work. We used an RTOS in this project, and there was one thread dedicated to monitoring the inputs. Normally this thread would be asleep. Whenever any input was engaged, we'd get a high-to-low interrupt, which would wake it up. The thread would then keep scanning all the GPIO inputs in a loop to see which inputs were pressed down until the 11th input went high again, which would only occur once all the inputs were released. At that point the thread would sleep again. This was not ideal, but it it was better than the alternative which was to have the thread constantly polling the GPIOs.
We considered using an I/O expander (which talks to the MCU via I2C and has an interrupt pin), but that would have had more overhead since the only way to poll the GPIO pins would be by performing an I2C transfer. (By contrast, polling the internal GPIOs just requires at most reading two registers.)
-Bill