Subversion Repositories Code-Repo

Rev

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

Rev Author Line No. Line
163 Kevin 1
#include <xc.h>
2
#include "defines.h"
3
#include "base_INTERRUPTS.h"
4
#include "base_UART.h"
5
#include "base_CPS.h"
6
 
7
void Interrupt_Enable() {
8
    INTCONbits.GIE = 1;
9
    INTCONbits.PEIE = 1;
10
}
11
 
12
void Interrupt_Disable() {
13
    INTCONbits.GIE = 0;
14
    INTCONbits.PEIE = 0;
15
}
16
 
17
void interrupt InterruptHandler(void) {
18
    char tmr0_rollover = 0;
19
 
20
    // Check to see if we have an interrupt on Timer 0 (CPS)
21
    if (INTCONbits.TMR0IF) {
22
        CPS_Timer_0_Interrupt_Handler();
23
        INTCONbits.TMR0IF = 0;
24
    }
25
 
26
//    // Check to see if we have an I2C interrupt
27
//    if (PIR1bits.SSPIF) {
28
//        I2C_Interrupt_Handler();
29
//        PIR1bits.SSPIF = 0;
30
//    }
31
 
32
#ifndef UART_TX_ONLY
33
    // Check to see if we have an interrupt on USART1 RX
34
    if (PIR1bits.RCIF) {
35
        UART_Recv_Interrupt_Handler();
36
        PIR1bits.RCIF = 0;
37
        if (INTCONbits.TMR0IF)
38
            tmr0_rollover = 1;
39
    }
40
#endif
41
 
42
    // Check to see if we have an interrupt on USART1 TX
43
    if (PIR1bits.TXIF) {
44
        UART_Send_Interrupt_Handler();
45
//        PIR1bits.TXIF = 0;
46
        if (INTCONbits.TMR0IF)
47
            tmr0_rollover = 1;
48
    }
49
 
50
    // If Timer 0 rolls over while servicing another interrupt handler,
51
    //  reset the timers as the sample will be inaccurate.
52
    if (tmr0_rollover) {
53
        CPS_Reset();
54
    }
55
}