Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
260 Kevin 1
#include "defines.h"
2
#include "INTERRUPTS.h"
3
#include "I2C1.h"
4
#include "I2C2.h"
273 Kevin 5
#include "IO.h"
260 Kevin 6
 
7
void Interrupt_Init() {
8
 
9
}
10
 
11
void Interrupt_Enable() {
12
    // Enable global and peripheral interrupts
13
    INTCONbits.PEIE = 1;
14
    INTCONbits.GIE = 1;
15
}
16
 
17
void Interrupt_Disable() {
18
    INTCONbits.PEIE = 0;
19
    INTCONbits.GIE = 0;
20
}
21
 
22
void interrupt InterruptHandler(void) {
23
    // We need to check the interrupt flag of each enabled high-priority interrupt to
24
    //  see which device generated this interrupt.  Then we can call the correct handler.
25
 
26
//    // Check to see if we have an SPI2 interrupt
27
//    if (PIR3bits.SSP2IF) {
28
//        // Call the handler
29
//        SPI2_Recv_Interrupt_Handler();
30
//
31
//        // Clear the interrupt flag
32
//        PIR3bits.SSP2IF = 0;
33
//
34
//        return;
35
//    }
36
 
37
    // Check to see if we have an I2C1 interrupt
38
    if (PIR1bits.SSP1IF) {
39
 
40
        // Call the handler
41
        I2C1_Interrupt_Handler();
42
 
43
        // Clear the interrupt flag
44
        PIR1bits.SSP1IF = 0;
45
 
46
        return;
47
    }
48
 
49
    // Check to see if we have an I2C2 interrupt
50
    if (PIR4bits.SSP2IF) {
51
        // Call the handler
52
        I2C2_Interrupt_Handler();
53
 
54
        // Clear the interrupt flag
55
        PIR4bits.SSP2IF = 0;
56
 
57
        return;
58
    }
59
 
275 Kevin 60
//    // Check to see if we have an IO interrupt
61
//    if (INTCONbits.IOCIF) {
62
//        // Call the handler
63
//        IO_Interrupt();
64
//
65
//        return;
66
//    }
273 Kevin 67
 
260 Kevin 68
//    // Check to see if we have an interrupt on USART1 RX
69
//    if (PIR1bits.RC1IF) {
70
//        // Call the interrupt handler
71
//        UART1_Recv_Interrupt_Handler();
72
//
73
//        // Clear the interrupt flag
74
//        PIR1bits.RC1IF = 0;
75
//
76
//        return;
77
//    }
78
 
79
//    // Check to see if we have an interrupt on USART1 TX
80
//    if (PIR1bits.TX1IF) {
81
//        // Call the interrupt handler
82
//        UART1_Send_Interrupt_Handler();
83
//
84
//        // Clear the interrupt flag
85
//        PIR1bits.TX1IF = 0;
86
//
87
//        return;
88
//    }
89
 
90
//    // Check to see if we have an interrupt on USART2 RX
91
//    if (PIR3bits.RC2IF) {
92
//        DBG_PRINT_INT("INT: UART2 RX\r\n");
93
//        // Call the interrupt handler
94
//        uart_2_recv_interrupt_handler();
95
//
96
//        // Clear the interrupt flag
97
//        PIR3bits.RC2IF = 0;
98
//    }
99
}