Subversion Repositories Code-Repo

Rev

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

Rev 127 Rev 147
Line 1... Line 1...
1
#include "maindefs.h"
1
#include "defines.h"
2
#include "interrupts.h"
2
#include "interrupts.h"
3
#include "uart.h"
3
#include "uart.h"
4
#include "i2c.h"
4
#include "i2c.h"
5
#include "spi.h"
5
#include "spi.h"
6
#include "adc.h"
6
#include "adc.h"
-
 
7
#include "timers.h"
7
 
8
 
8
//----------------------------------------------------------------------------
9
//----------------------------------------------------------------------------
9
// Note: This code for processing interrupts is configured to allow for high and
10
// Note: This code for processing interrupts is configured to allow for high and
10
//       low priority interrupts.  The high priority interrupt can interrupt the
11
//       low priority interrupts.  The high priority interrupt can interrupt the
11
//       the processing of a low priority interrupt.  However, only one of each type
12
//       the processing of a low priority interrupt.  However, only one of each type
Line 25... Line 26...
25
    IPR3bits.SSP2IP = 1;    // MSSP2 (SPI2) interrupt
26
    IPR3bits.SSP2IP = 1;    // MSSP2 (SPI2) interrupt
26
 
27
 
27
    // Low priority interrupts
28
    // Low priority interrupts
28
    
29
    
29
//    INTCON2bits.TMR0IP = 0; // Timer0 interrupt
30
//    INTCON2bits.TMR0IP = 0; // Timer0 interrupt
30
//    IPR1bits.TMR1IP = 0;    // Timer1 interrupt
31
    IPR1bits.TMR1IP = 0;    // Timer1 interrupt
31
//    IPR2bits.TMR3IP = 0; // Timer 3 interrupt
32
//    IPR2bits.TMR3IP = 0; // Timer 3 interrupt
32
    IPR1bits.ADIP = 0;      // ADC interupt
33
//    IPR1bits.ADIP = 0;      // ADC interupt
33
//    INTCON2bits.RBIP = 0;   // Port B interrupt
34
//    INTCON2bits.RBIP = 0;   // Port B interrupt
34
//    INTCON3bits.INT1IP = 0; // INT1 interrupt
35
//    INTCON3bits.INT1IP = 0; // INT1 interrupt
35
    
36
    
36
    // Enable Port B interrupt
37
    // Enable Port B interrupt
37
//    INTCONbits.RBIE = 1;
38
//    INTCONbits.RBIE = 1;
Line 102... Line 103...
102
 
103
 
103
void InterruptHandlerHigh() {
104
void InterruptHandlerHigh() {
104
    // We need to check the interrupt flag of each enabled high-priority interrupt to
105
    // We need to check the interrupt flag of each enabled high-priority interrupt to
105
    //  see which device generated this interrupt.  Then we can call the correct handler.
106
    //  see which device generated this interrupt.  Then we can call the correct handler.
106
 
107
 
107
    // Check to see if we have an SPI2 interrupt
108
//    // Check to see if we have an SPI2 interrupt
108
    if (PIR3bits.SSP2IF) {
109
//    if (PIR3bits.SSP2IF) {
109
        // Call the handler
110
//        // Call the handler
110
        SPI2_Recv_Interrupt_Handler();
111
//        SPI2_Recv_Interrupt_Handler();
111
 
112
//
112
        // Clear the interrupt flag
113
//        // Clear the interrupt flag
113
        PIR3bits.SSP2IF = 0;
114
//        PIR3bits.SSP2IF = 0;
114
 
115
//
115
        return;
116
//        return;
116
    }
117
//    }
117
 
118
 
118
    // Check to see if we have an I2C interrupt
119
    // Check to see if we have an I2C interrupt
119
    if (PIR1bits.SSPIF) {
120
    if (PIR1bits.SSPIF) {
120
        // Call the handler
121
        // Call the handler
121
        I2C_Interrupt_Handler();
122
        I2C_Interrupt_Handler();
Line 193... Line 194...
193
//
194
//
194
//        // Clear this interrupt flag
195
//        // Clear this interrupt flag
195
//        INTCONbits.TMR0IF = 0;
196
//        INTCONbits.TMR0IF = 0;
196
//    }
197
//    }
197
 
198
 
198
//    // Check to see if we have an interrupt on timer 1
199
    // Check to see if we have an interrupt on timer 1
199
//    if (PIR1bits.TMR1IF) {
200
    if (PIR1bits.TMR1IF) {
200
//        // Call the interrupt handler
201
        // Call the interrupt handler
201
//        timer1_interrupt_handler();
202
        Timer1_Interrupt_Handler();
202
//
203
 
203
//        // Clear the interrupt flag
204
        // Clear the interrupt flag
204
//        PIR1bits.TMR1IF = 0;
205
        PIR1bits.TMR1IF = 0;
205
//    }
206
    }
206
 
207
 
207
//    // Check to see if we have an interrupt on timer 3
208
//    // Check to see if we have an interrupt on timer 3
208
//    if (PIR2bits.TMR3IF) {
209
//    if (PIR2bits.TMR3IF) {
209
//        DBG_PRINT_INT("INT: Timer 3\r\n");
210
//        DBG_PRINT_INT("INT: Timer 3\r\n");
210
//        timer3_interrupt_handler();
211
//        timer3_interrupt_handler();
211
//
212
//
212
//        PIR2bits.TMR3IF = 0;
213
//        PIR2bits.TMR3IF = 0;
213
//    }
214
//    }
214
 
215
 
215
    // Check to see if we have an interrupt on ADC
216
//    // Check to see if we have an interrupt on ADC
216
    if (PIR1bits.ADIF) {
217
//    if (PIR1bits.ADIF) {
217
        // Call the interrupt handler
218
//        // Call the interrupt handler
218
        ADC_Interrupt_Handler();
219
//        ADC_Interrupt_Handler();
219
 
220
//
220
        // Clear the interrupt flag
221
//        // Clear the interrupt flag
221
        PIR1bits.ADIF = 0;
222
//        PIR1bits.ADIF = 0;
222
    }
223
//    }
223
}
224
}
224
 
225