void __ISR(_INPUT_CAPTURE_5_VECTOR) INT_IC5_Handler(void) { mIC5ClearIntFlag(); //Read captured timer values if(mIC5CaptureReady()) { IC5_CT_Rise = mIC5ReadCapture(); IC5_CT_Fall = mIC5ReadCapture(); } //Determine period if(IC5_CT_Rise > IC5_CT_Fall) period5 = (IC5_CT_Fall + PER_REG) - IC5_CT_Rise; else period5 = IC5_CT_Fall - IC5_CT_Rise; //Turn period into Aux percentage 0.0 or 100.0% if(period5 > (int)MID_THRESH_L) IC_AUX = 100; else if(period5 < (int)MID_THRESH_L) IC_AUX = 0; ReadCapture5(garbage); //clear any remaining capture values }
void __ISR(_INPUT_CAPTURE_5_VECTOR, IPL4AUTO) HCSR04_Interrupt(void){ // TODO: http://ww1.microchip.com/downloads/en/DeviceDoc/XC32-v131-ReleaseNotes.html#ISR_Context_improvements if(up){ curr = mIC5ReadCapture(); if(curr < last) lastDistance = (curr + ((~0)-last)); else lastDistance = curr - last; lastDistance *= scale; reading = 0; } else{ up = 1; last = mIC5ReadCapture(); } INTClearFlag(INT_IC5); }