/PIC Stuff/PICX_16F1825_Stepper_Driver/IOC.c |
---|
0,0 → 1,48 |
#include "defines.h" |
#include "IOC.h" |
void IOC_Init(void) { |
INTCONbits.IOCIE = 1; |
// Enable interrupt on both edges on RA3 and RA4 |
IOCAPbits.IOCAP3 = 1; |
IOCANbits.IOCAN3 = 1; |
IOCAPbits.IOCAP4 = 1; |
IOCANbits.IOCAN4 = 1; |
} |
void IOC_Interrupt_Handler(void) { |
if (IOCAFbits.IOCAF3) { |
if (SW_1_PORT == 1) { |
switch (Get_Cur_Mode()) { |
case SINGLE_STEP: |
STEP_LAT = 1; |
__delay_us(2); |
STEP_LAT = 0; |
break; |
case AUTO_STEP: |
break; |
case SET_MICROSTEP: |
break; |
} |
} |
__delay_ms(100); |
IOCAFbits.IOCAF3 = 0; |
} |
if (IOCAFbits.IOCAF4) { |
if (SW_2_PORT == 1) { |
Set_Next_Mode(); |
} |
__delay_ms(100); |
IOCAFbits.IOCAF4 = 0; |
} |
} |