Tool/software: TI-RTOS
I am trying to use the GPIO's for reading a switch state(On / Off type) by using interrupts (Interrupts enabled on both edges). When the switch is turned on / off there were multiple interrupts fired in each cases and to suppress it, I disabled the interrupt up on any interrupt and re-enabled it once the interrupt is handled. However when I read the GPIO values inside the interrupt, I get inconsistent results.
For example, when the switch is turned off and the interrupt is fired, the GPIO read value inside the interrupt handler is expected to be zero, but this is not the case. Similarly when the switch is turned on, the GPIO read value gives inconsistent results (i.e sometimes it is 0 and sometimes 1).
Is this the right approach to reach switch state using GPIO's ? Or should I read the GPIO values in a loop comparing old state ?