Subversion Repositories Code-Repo

Rev

Rev 232 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include "defines.h"
#include "base_INTERRUPTS.h"
#include "base_I2C.h"

void Interrupt_Init() {
    // Enable MSSP1 interrupt
    PIE1bits.SSP1IE = 1;
}

void Interrupt_Enable() {
    // Enable global and peripheral interrupts
    INTCONbits.PEIE = 1;
    INTCONbits.GIE = 1;
}

void Interrupt_Disable() {
    INTCONbits.PEIE = 0;
    INTCONbits.GIE = 0;
}

void interrupt InterruptHandler(void) {
    // We need to check the interrupt flag of each enabled high-priority interrupt to
    //  see which device generated this interrupt.  Then we can call the correct handler.

//    // Check to see if we have an SPI2 interrupt
//    if (PIR3bits.SSP2IF) {
//        // Call the handler
//        SPI2_Recv_Interrupt_Handler();
//
//        // Clear the interrupt flag
//        PIR3bits.SSP2IF = 0;
//
//        return;
//    }

    // Check to see if we have an I2C interrupt
    if (PIR1bits.SSP1IF) {

        // Call the handler
        I2C_Interrupt_Handler();

        // Clear the interrupt flag
        PIR1bits.SSP1IF = 0;

        return;
    }

//    // Check to see if we have an interrupt on USART1 RX
//    if (PIR1bits.RC1IF) {
//        // Call the interrupt handler
//        UART1_Recv_Interrupt_Handler();
//
//        // Clear the interrupt flag
//        PIR1bits.RC1IF = 0;
//
//        return;
//    }

//    // Check to see if we have an interrupt on USART1 TX
//    if (PIR1bits.TX1IF) {
//        // Call the interrupt handler
//        UART1_Send_Interrupt_Handler();
//
//        // Clear the interrupt flag
//        PIR1bits.TX1IF = 0;
//
//        return;
//    }

//    // Check to see if we have an interrupt on USART2 RX
//    if (PIR3bits.RC2IF) {
//        DBG_PRINT_INT("INT: UART2 RX\r\n");
//        // Call the interrupt handler
//        uart_2_recv_interrupt_handler();
//
//        // Clear the interrupt flag
//        PIR3bits.RC2IF = 0;
//    }
}