|
@@ -27,26 +27,57 @@ void iRtCap_Init(void)
|
|
|
void iRtCap_Isr(uint8_t devIndex)
|
|
|
{
|
|
|
uint32_t base = Caps[devIndex].CapBase;
|
|
|
- if (TIMER_INTF(base) & 0x01)
|
|
|
+ uint8_t capValues[5]={0,0,0,0,0};
|
|
|
+ uint8_t results[5]={0,1,2,3,4};
|
|
|
+ uint16_t tmpIntf;
|
|
|
+
|
|
|
+ tmpIntf = TIMER_INTF(base);
|
|
|
+ for (int i = 1; i < 5; i++)
|
|
|
{
|
|
|
- if (Caps[devIndex].CountMaxISR.Enable && Caps[devIndex].CountMaxISR.Action != 0)
|
|
|
+ if (tmpIntf & (0x01 << i ))
|
|
|
{
|
|
|
- Caps[devIndex].CountMaxISR.Action();
|
|
|
+ capValues[i] = iCap_GetCaptureValue(devIndex,(i));
|
|
|
}
|
|
|
- TIMER_INTF(base) &= ~0x01;
|
|
|
+ }
|
|
|
+ if (tmpIntf & 0x01)
|
|
|
+ {
|
|
|
+ capValues[0] = iCap_GetPeriod(devIndex) >> 1;
|
|
|
}
|
|
|
|
|
|
- for (int i = 0; i < 4; i++)
|
|
|
- {
|
|
|
- if (TIMER_INTF(base) & (0x01 << (i + 1)))
|
|
|
+ for(int i = 0; i < 4; i++)
|
|
|
+ {
|
|
|
+ for(int j = 0;j < (4-i); j++)
|
|
|
{
|
|
|
- if (Caps[devIndex].ChannelISR[i].Enable && Caps[devIndex].ChannelISR[i].Action != 0)
|
|
|
- {
|
|
|
- Caps[devIndex].ChannelISR[i].Action();
|
|
|
- }
|
|
|
- TIMER_INTF(base) &= ~(0x01 << (i + 1));
|
|
|
+ if(capValues[results[j]]< capValues[results[j + 1]])
|
|
|
+ {
|
|
|
+ uint8_t tmp = results[j];
|
|
|
+ results[j] = results[j + 1];
|
|
|
+ results[j + 1] = tmp;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+ for(int i = 0; i < 5; i++)
|
|
|
+ {
|
|
|
+ if (tmpIntf & (0x01 << results[i]))
|
|
|
+ {
|
|
|
+ if(results[i]==0)
|
|
|
+ {
|
|
|
+ if (Caps[devIndex].CountMaxISR.Enable && Caps[devIndex].CountMaxISR.Action != 0)
|
|
|
+ {
|
|
|
+ Caps[devIndex].CountMaxISR.Action();
|
|
|
+ }
|
|
|
+ TIMER_INTF(base) &= ~0x01;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (Caps[devIndex].ChannelISR[results[i]-1].Enable && Caps[devIndex].ChannelISR[results[i]-1].Action != 0)
|
|
|
+ {
|
|
|
+ Caps[devIndex].ChannelISR[results[i]-1].Action();
|
|
|
+ }
|
|
|
+ TIMER_INTF(base) &= ~(0x01 << results[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|