Add both SW1 and SW2 Interrupts

This commit is contained in:
Abhijit Kshirsagar Kshirsagar 2023-09-04 12:44:36 +05:30
parent dd679556d5
commit 5f32671262
1 changed files with 18 additions and 3 deletions

View File

@ -26,8 +26,19 @@ int main(void)
void SW2_Handler(void) void SW2_Handler(void)
{ {
GPIO_PORTF_DATA_R ^= 0x8; //GPIO_PORTF_ICR_R = 0x11;
GPIO_PORTF_ICR_R = 0xff; if(GPIO_PORTF_MIS_R & 0x01)
{
//PIN0 (SW2) pressed
GPIO_PORTF_DATA_R |= 0x8;
}
else if (GPIO_PORTF_MIS_R & 0x10)
{
GPIO_PORTF_DATA_R &= ~0x8;
}
GPIO_PORTF_ICR_R = 0x11;
} }
@ -58,6 +69,10 @@ void GPIO_PORTF_Init(void)
//Need to enable interrupt on SW1 //Need to enable interrupt on SW1
SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF; SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOF;
GPIO_PORTF_LOCK_R = 0x4C4F434B; /* unlock commit register */
GPIO_PORTF_CR_R = 0xFF; /* make PORTF0 configurable */
GPIO_PORTF_DEN_R = 0x1F; GPIO_PORTF_DEN_R = 0x1F;
GPIO_PORTF_PUR_R = 0x11; GPIO_PORTF_PUR_R = 0x11;
GPIO_PORTF_DIR_R = 0x0E; GPIO_PORTF_DIR_R = 0x0E;
@ -80,7 +95,7 @@ void GPIO_PORTF_Init(void)
GPIO_PORTF_ICR_R = 0xff; GPIO_PORTF_ICR_R = 0xff;
//GPIOIM -- Interrupt Mask --> 1 for unmasked (enabled)--> 0x01 //GPIOIM -- Interrupt Mask --> 1 for unmasked (enabled)--> 0x01
GPIO_PORTF_IM_R = 0x10; GPIO_PORTF_IM_R = 0x11;
//GPIORIS -- Raw Int Status //GPIORIS -- Raw Int Status
//GPIOMIS -- Masked Int Status //GPIOMIS -- Masked Int Status