Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
312 Kevin 1
#include "defines.h"
2
#include "IOC.h"
3
 
4
void IOC_Init(void) {
5
    INTCONbits.IOCIE = 1;
6
 
7
    // Enable interrupt on both edges on RA3 and RA4
8
    IOCAPbits.IOCAP3 = 1;
9
    IOCANbits.IOCAN3 = 1;
10
    IOCAPbits.IOCAP4 = 1;
11
    IOCANbits.IOCAN4 = 1;
12
}
13
 
14
void IOC_Interrupt_Handler(void) {
15
    if (IOCAFbits.IOCAF3) {
16
 
17
        if (SW_1_PORT == 1) {
18
            switch (Get_Cur_Mode()) {
19
                case SINGLE_STEP:
20
                    STEP_LAT = 1;
21
                    __delay_us(2);
22
                    STEP_LAT = 0;
23
                    break;
24
                case AUTO_STEP:
25
 
26
                    break;
27
                case SET_MICROSTEP:
28
 
29
                    break;
30
            }
31
        }
32
 
33
        __delay_ms(100);
34
 
35
        IOCAFbits.IOCAF3 = 0;
36
    }
37
 
38
    if (IOCAFbits.IOCAF4) {
39
 
40
        if (SW_2_PORT == 1) {
41
            Set_Next_Mode();
42
        }
43
 
44
        __delay_ms(100);
45
 
46
        IOCAFbits.IOCAF4 = 0;
47
    }
48
}