Subversion Repositories Code-Repo

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
283 Kevin 1
#include "defines.h"
2
#include "INTERRUPTS.h"
3
#include "I2C1.h"
285 Kevin 4
#include "UART.h"
283 Kevin 5
 
6
void Interrupt_Init() {
7
}
8
 
9
void Interrupt_Enable() {
10
    // Enable global and peripheral interrupts
11
    INTCONbits.PEIE = 1;
12
    INTCONbits.GIE = 1;
13
}
14
 
15
void Interrupt_Disable() {
16
    INTCONbits.PEIE = 0;
17
    INTCONbits.GIE = 0;
18
}
19
 
20
void interrupt InterruptHandler(void) {
21
    // We need to check the interrupt flag of each enabled high-priority interrupt to
22
    //  see which device generated this interrupt.  Then we can call the correct handler.
23
 
24
    // Check to see if we have an I2C interrupt
25
    if (PIR1bits.SSP1IF) {
26
 
27
        // Call the handler
28
        I2C1_Interrupt_Handler();
29
 
30
        // Clear the interrupt flag
31
        PIR1bits.SSP1IF = 0;
32
 
33
        return;
34
    }
285 Kevin 35
 
36
    if (PIR1bits.RCIF) {
37
 
38
        // Call the handler
39
        UART_RX_Interrupt_Handler();
40
 
41
        // Clear the interrupt flag
42
        PIR1bits.RCIF = 0;
43
 
44
        return;
45
    }
46
 
47
    if (PIR1bits.TXIF) {
48
 
49
        // Call the handler
50
        UART_TX_Interrupt_Handler();
51
 
52
        // Clear the interrupt flag
53
        PIR1bits.TXIF = 0;
54
 
55
        return;
56
    }
57
 
283 Kevin 58
}