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"
315 Kevin 3
#include "STEPPER.h"
312 Kevin 4
 
5
void IOC_Init(void) {
6
    INTCONbits.IOCIE = 1;
7
 
8
    // Enable interrupt on both edges on RA3 and RA4
9
    IOCAPbits.IOCAP3 = 1;
10
    IOCANbits.IOCAN3 = 1;
11
    IOCAPbits.IOCAP4 = 1;
12
    IOCANbits.IOCAN4 = 1;
13
}
14
 
15
void IOC_Interrupt_Handler(void) {
16
    if (IOCAFbits.IOCAF3) {
17
 
314 Kevin 18
        if (SW_1_PORT) {
312 Kevin 19
            switch (Get_Cur_Mode()) {
20
                case SINGLE_STEP:
315 Kevin 21
                    STEPPER_Step();
312 Kevin 22
                    break;
23
                case AUTO_STEP:
315 Kevin 24
                    STEPPER_Toggle_Auto();
312 Kevin 25
                    break;
315 Kevin 26
                case SET_DELAY:
27
                    STEPPER_Set_Next_Delay();
28
                    break;
312 Kevin 29
                case SET_MICROSTEP:
315 Kevin 30
                    STEPPER_Set_Next_Step();
312 Kevin 31
                    break;
32
            }
33
        }
34
 
314 Kevin 35
        // Delay to debounce button on any edge
315 Kevin 36
         __delay_ms(200);
37
 
312 Kevin 38
        IOCAFbits.IOCAF3 = 0;
39
    }
40
 
41
    if (IOCAFbits.IOCAF4) {
42
 
314 Kevin 43
        if (SW_2_PORT) {
312 Kevin 44
            Set_Next_Mode();
45
        }
46
 
314 Kevin 47
        // Delay to debounce button on any edge
48
        __delay_ms(200);
312 Kevin 49
 
50
        IOCAFbits.IOCAF4 = 0;
51
    }
52
}