add GPIOF interrupt handler

This commit is contained in:
Sanyog Nevase Nevase 2024-09-20 21:32:19 +05:30
parent 4fd7019fd3
commit fa41ddb977
1 changed files with 26 additions and 10 deletions

16
main.c
View File

@ -38,3 +38,19 @@ void delay(int us) //DEFINING DELAY FUNCTION
while ((STCTRL & (1 << 16)) == 0); // Wait until flag is set while ((STCTRL & (1 << 16)) == 0); // Wait until flag is set
STCTRL &= 0x0; // Stop the timer STCTRL &= 0x0; // Stop the timer
} }
void GPIOF_interruptHandler(void) // Interrupt handler for GPIO Port F
{
delay(200000); // DEBOUNCE DELAY
if (GPIO_PORTF_RIS_R & 0x10) // CHECK IF SWITCH 1 CAUSED INTERRUPT
{
GPIO_PORTF_DATA_R ^= 0x02; // TOGGLE RED LED
GPIO_PORTF_ICR_R = 0x10; // CLEAR INTERRUPT FLAG FOR SWITCH 1
}
if (GPIO_PORTF_RIS_R & 0x01) // CHECK IF SWITCH 2 CAUSED INTERRUPT
{
GPIO_PORTF_DATA_R ^= 0x02; // TOGGLE RED LED
GPIO_PORTF_ICR_R = 0x01; // CLEAR INTERRUPT FLAG FOR SWITCH 1
}
}