Subversion Repositories Code-Repo

Rev

Rev 275 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 275 Rev 277
Line 1... Line 1...
1
#include "defines.h"
1
#include "defines.h"
2
#include "INTERRUPTS.h"
2
#include "INTERRUPTS.h"
3
#include "I2C1.h"
3
#include "I2C1.h"
4
#include "I2C2.h"
4
#include "I2C2.h"
5
#include "IO.h"
5
#include "IO.h"
-
 
6
#include "CPS.h"
6
 
7
 
7
void Interrupt_Init() {
8
void Interrupt_Init() {
8
 
9
 
9
}
10
}
10
 
11
 
Line 18... Line 19...
18
    INTCONbits.PEIE = 0;
19
    INTCONbits.PEIE = 0;
19
    INTCONbits.GIE = 0;
20
    INTCONbits.GIE = 0;
20
}
21
}
21
 
22
 
22
void interrupt InterruptHandler(void) {
23
void interrupt InterruptHandler(void) {
-
 
24
    uint8_t tmr0_rollover = 0;
23
    // We need to check the interrupt flag of each enabled high-priority interrupt to
25
    // 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.
26
    //  see which device generated this interrupt.  Then we can call the correct handler.
25
 
27
 
26
//    // Check to see if we have an SPI2 interrupt
28
//    // Check to see if we have an SPI2 interrupt
27
//    if (PIR3bits.SSP2IF) {
29
//    if (PIR3bits.SSP2IF) {
Line 32... Line 34...
32
//        PIR3bits.SSP2IF = 0;
34
//        PIR3bits.SSP2IF = 0;
33
//
35
//
34
//        return;
36
//        return;
35
//    }
37
//    }
36
 
38
 
-
 
39
 
-
 
40
    // Check to see if we have an interrupt on Timer 0 (CPS)
-
 
41
    if (INTCONbits.TMR0IF) {
-
 
42
        CPS_Timer_0_Interrupt_Handler();
-
 
43
        INTCONbits.TMR0IF = 0;
-
 
44
        return;
-
 
45
    }
-
 
46
    
37
    // Check to see if we have an I2C1 interrupt
47
    // Check to see if we have an I2C1 interrupt
38
    if (PIR1bits.SSP1IF) {
48
    if (PIR1bits.SSP1IF) {
39
 
-
 
40
        // Call the handler
49
        // Call the handler
41
        I2C1_Interrupt_Handler();
50
        I2C1_Interrupt_Handler();
42
 
51
 
43
        // Clear the interrupt flag
52
        // Clear the interrupt flag
44
        PIR1bits.SSP1IF = 0;
53
        PIR1bits.SSP1IF = 0;
45
 
54
 
-
 
55
        if (INTCONbits.TMR0IF) {
-
 
56
            tmr0_rollover = 1;
46
        return;
57
        }
47
    }
58
    }
48
 
59
 
49
    // Check to see if we have an I2C2 interrupt
60
    // Check to see if we have an I2C2 interrupt
50
    if (PIR4bits.SSP2IF) {
61
    if (PIR4bits.SSP2IF) {
51
        // Call the handler
62
        // Call the handler
52
        I2C2_Interrupt_Handler();
63
        I2C2_Interrupt_Handler();
53
 
64
 
54
        // Clear the interrupt flag
65
        // Clear the interrupt flag
55
        PIR4bits.SSP2IF = 0;
66
        PIR4bits.SSP2IF = 0;
56
 
67
 
-
 
68
        if (INTCONbits.TMR0IF) {
-
 
69
            tmr0_rollover = 1;
57
        return;
70
        }
-
 
71
    }
-
 
72
 
-
 
73
 
-
 
74
    // If Timer 0 rolls over while servicing another interrupt handler,
-
 
75
    //  reset the timers as the sample will be inaccurate.
-
 
76
    if (tmr0_rollover) {
-
 
77
        INTCONbits.TMR0IF = 0;
-
 
78
        CPS_Reset();
58
    }
79
    }
59
 
80
 
60
//    // Check to see if we have an IO interrupt
81
//    // Check to see if we have an IO interrupt
61
//    if (INTCONbits.IOCIF) {
82
//    if (INTCONbits.IOCIF) {
62
//        // Call the handler
83
//        // Call the handler