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
 
314 Kevin 17
        if (SW_1_PORT) {
312 Kevin 18
            switch (Get_Cur_Mode()) {
19
                case SINGLE_STEP:
20
                    STEP_LAT = 1;
314 Kevin 21
                    __delay_ms(2);
312 Kevin 22
                    STEP_LAT = 0;
23
                    break;
24
                case AUTO_STEP:
25
 
26
                    break;
27
                case SET_MICROSTEP:
314 Kevin 28
                    Set_Next_Step();
312 Kevin 29
                    break;
30
            }
31
        }
32
 
314 Kevin 33
        // Delay to debounce button on any edge
34
        __delay_ms(200);
312 Kevin 35
 
36
        IOCAFbits.IOCAF3 = 0;
37
    }
38
 
39
    if (IOCAFbits.IOCAF4) {
40
 
314 Kevin 41
        if (SW_2_PORT) {
312 Kevin 42
            Set_Next_Mode();
43
        }
44
 
314 Kevin 45
        // Delay to debounce button on any edge
46
        __delay_ms(200);
312 Kevin 47
 
48
        IOCAFbits.IOCAF4 = 0;
49
    }
50
}