Rev 312 | Blame | Last modification | View Log | Download | RSS feed
#include "defines.h"#include "IOC.h"void IOC_Init(void) {INTCONbits.IOCIE = 1;// Enable interrupt on both edges on RA3 and RA4IOCAPbits.IOCAP3 = 1;IOCANbits.IOCAN3 = 1;IOCAPbits.IOCAP4 = 1;IOCANbits.IOCAN4 = 1;}void IOC_Interrupt_Handler(void) {if (IOCAFbits.IOCAF3) {if (SW_1_PORT) {switch (Get_Cur_Mode()) {case SINGLE_STEP:STEP_LAT = 1;__delay_ms(2);STEP_LAT = 0;break;case AUTO_STEP:break;case SET_MICROSTEP:Set_Next_Step();break;}}// Delay to debounce button on any edge__delay_ms(200);IOCAFbits.IOCAF3 = 0;}if (IOCAFbits.IOCAF4) {if (SW_2_PORT) {Set_Next_Mode();}// Delay to debounce button on any edge__delay_ms(200);IOCAFbits.IOCAF4 = 0;}}