I need to debounce a switch on a GPIO port. I tried using waiting on a semaphore, having a task post (release) the semaphore after the debounce time but that doesn't seem to work in an ISR. Which I guess is reasonable because it seems that the task scheduler interacts with the semaphore calls and the ISR is not a task... or is this an error on my side.
I considered lwevents but I think they are plagued by the same problem. Is there 'best practice' someone could recommend for syncing the ISR to the debounced IRQ?
in the GPIO ISR
wait on semaphore or event
clear interrupt flag
post semaphore or event to ISR
time wait (ticks)
Or should I just
diasable the interrupts
wait for the debounce task to run,
re-enable interrupts to ISR
I can probably get the last method to work but it is not very elegant.