I am new to embedded programming. I am trying to switch blue LED ON when SW1 is pressed and if SW1 is pressed again it should get OFF. For doing this I want to use interrupt. Please check my code because LED is getting on pressing but not getting OFF on pressing again.
#include <stdint.h>
#include <stdbool.h>
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/interrupt.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
int count = 0;
int main(void)
{
SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_2);
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE,GPIO_PIN_4);
GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIOIntDisable(GPIO_PORTF_BASE, GPIO_PIN_4);
GPIOIntClear(GPIO_PORTF_BASE, GPIO_PIN_4);
IntEnable(INT_GPIOF);
GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_FALLING_EDGE);
GPIOIntEnable(GPIO_PORTF_BASE,GPIO_PIN_4);
while(1)
{
}
}
void GPIO_PORTF_Handler(void)
{
if(count == 0)
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2,0x04);
count = 1;
}
if(count == 1)
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_2,0x00);
count = 0;
}
}