Hy,
I'm trying to write a high level triggered ISR, for port F, pins 0 and 4.
What I would like to do is to have a certain code executed when PF0 is high, different code when PF4 and different when both of them are high.
At the moment if PF4 is high, PF0 can interrupt it and run the code for PF0 but not vice versa.
And also if bouth of them are high, only the PF0 code will run.
My initialization function is:
void INT_Light_sensor_init(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //Enable clock on port F
GPIO_PORTF_LOCK_R = 0x4C4F434B; //Unlock PortF PF0
GPIO_PORTF_CR_R |= 0x1F; //Allow changes to PF4-0
IntMasterDisable(); //Global disable of interrupts
IntDisable(INT_GPIOF); //GPIO Port F disable of interrupts
GPIOIntDisable(GPIO_PORTF_BASE,GPIO_PIN_0 | GPIO_PIN_4); //Disable GPIO pin interrupt
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4); //Set PF0 and PF4 as GPIO Input
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4, GPIO_LOW_LEVEL); //Set Low level interrupt type
GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4, GPIO_DIR_MODE_IN); //Set direction input for PF0 and PF4
GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU); //Configure PUR for PF0 and PF4
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_0 | GPIO_INT_PIN_4); //Enable GPIO pin interrupt
IntPrioritySet(INT_GPIOF,0x40); //Priority 2 = "010"0.0000
IntEnable(INT_GPIOF); //GPIO Port F enable of interrupts
IntMasterEnable(); //Global enable of interrupts
}
And my ISR function is:
void GPIOPortF_Handler(void)
{
unsigned long Light_sensor_status = 0;
Light_sensor_status = GPIOIntStatus(GPIO_PORTF_BASE,false);
GPIOIntClear(GPIO_PORTF_BASE,GPIO_INT_PIN_0 | GPIO_INT_PIN_4);
if(Light_sensor_status & GPIO_INT_PIN_0)
{
//Go Left
Motion_Go_Left();
}
else if(Light_sensor_status & GPIO_INT_PIN_4)
{
//Go Right
Motion_Go_Right();
}
else if(Light_sensor_status & (GPIO_INT_PIN_0 | GPIO_INT_PIN_4))
{
//Go straight ahead
Motion_Cruise();
}
}
So, the question is: Is there a way to set sub priorities within the same port?
Can an ISR handle two interrupt sources at the same time (PF0 and PF4) ?
Regards,
Alex