add GPIOF interrupt handler
This commit is contained in:
parent
4fd7019fd3
commit
fa41ddb977
36
main.c
36
main.c
|
@ -23,18 +23,34 @@ void GPIO_PORT_F_init(void)
|
||||||
GPIO_PORTF_IEV_R = 0x00; // Falling edge event
|
GPIO_PORTF_IEV_R = 0x00; // Falling edge event
|
||||||
GPIO_PORTF_IM_R |= 0x11; // Unmask interrupts for PF0 and PF4
|
GPIO_PORTF_IM_R |= 0x11; // Unmask interrupts for PF0 and PF4
|
||||||
}
|
}
|
||||||
void systick_setting(void) // SYSTICK SETUP FUNCTION
|
void systick_setting(void) // SYSTICK SETUP FUNCTION
|
||||||
{
|
{
|
||||||
STRELOAD = SYSTICK_RELOAD_VALUE(1000); // RELOAD VALUE FOR 1ms
|
STRELOAD = SYSTICK_RELOAD_VALUE(1000); // RELOAD VALUE FOR 1ms
|
||||||
STCTRL |= (1 << 0) | (1 << 2); // Enable SysTick with system clock
|
STCTRL |= (1 << 0) | (1 << 2); // Enable SysTick with system clock
|
||||||
STCURRENT = 0; // Clear current value
|
STCURRENT = 0; // Clear current value
|
||||||
}
|
}
|
||||||
|
|
||||||
void delay(int us) //DEFINING DELAY FUNCTION
|
void delay(int us) //DEFINING DELAY FUNCTION
|
||||||
{
|
{
|
||||||
STRELOAD = SYSTICK_RELOAD_VALUE(us); // RELOAD VALUE FOR REQUIRED DELAY
|
STRELOAD = SYSTICK_RELOAD_VALUE(us); // RELOAD VALUE FOR REQUIRED DELAY
|
||||||
STCURRENT = 0; // Clear STCURRENT
|
STCURRENT = 0; // Clear STCURRENT
|
||||||
STCTRL |= (1 << 0) | (1 << 2); // Enable SysTick
|
STCTRL |= (1 << 0) | (1 << 2); // Enable SysTick
|
||||||
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue