Exemplo n.º 1
0
void irq_handler( irq_t interrupt )
{
   uint16_t tmp; // General purpose temporal variable
   
   switch(interrupt)
   {
   case INT_NUM_ADC12:
      tmp = adc_int_handler(ADC12IV);
      event_emit(NORMAL_PRIORITY, ADC12_EVENT, tmp);
      break;
   }
}
Exemplo n.º 2
0
interrupt
#else
#pragma code
#pragma interrupt InterruptHandlerHigh
#endif
void InterruptHandlerHigh() {
    // 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 I2C interrupt
    if (PIR1bits.SSPIF) {
        // clear the interrupt flag
        PIR1bits.SSPIF = 0;        
        // call the handler
        i2c_master_handler();
    }

    // check to see if we have an interrupt on timer 0
    if (INTCONbits.TMR0IF) {
        INTCONbits.TMR0IF = 0; // clear this interrupt flag
        // call whatever handler you want (this is "user" defined)
        timer0_int_handler();

    }

    if(PIR1bits.ADIF) //ADC conversion complete
    {
        PIR1bits.ADIF = 0; //clear it
        adc_int_handler();

    }

     if (PIR1bits.RCIF)
     {
         #if ENABLE_GPIO
         MAIN_THREAD = 0;
         UART_RECEIVE_THREAD = 1;
         #endif
         uart_recv_int_handler();

         

     }
    // here is where you would check other interrupt flags.

    // The *last* thing I do here is check to see if we can
    // allow the processor to go to sleep
    // This code *DEPENDS* on the code in messages.c being
    // initialized using "init_queues()" -- if you aren't using
    // this, then you shouldn't have this call here
    SleepIfOkay();
}
Exemplo n.º 3
0
interrupt low_priority
#else
#pragma code
#pragma interruptlow InterruptHandlerLow
#endif
void InterruptHandlerLow() {
    
    #ifdef SENSOR_PIC
    if (PIR1bits.ADIF) {
        PIR1bits.ADIF = 0;
        adc_int_handler();
    }
    #endif //SENSOR_PIC

    // check to see if we have an interrupt on USART RX
    if (PIR1bits.RCIF) {
        PIR1bits.RCIF = 0; //clear interrupt flag

#if !defined(SENSOR_PIC) && !defined(MOTOR_PIC)
        if(wifly_setup){
            uart_recv_int_handler();
        }
        else{
#endif
            uart_recv_wifly_debug_handler();
#if !defined(SENSOR_PIC) && !defined(MOTOR_PIC)
        }
#endif
        
    }
    if (PIR1bits.TXIF)
    {
        PIR1bits.TXIF = 0; // clear interrupt flag
        if (PIE1bits.TXIE)
            uart_send_int_handler();
    }
#ifndef MOTOR_PIC
    if (PIR1bits.TMR1IF) {
        PIR1bits.TMR1IF = 0; //clear interrupt flag
        timer1_int_handler();
    }
#endif

#ifdef SENSOR_PIC
    if (PIR1bits.TMR2IF){
        PIR1bits.TMR2IF = 0; //Clear the interrupt flag
        timer2_int_handler();
    }
#endif
}
Exemplo n.º 4
0
interrupt
#else
#pragma code
#pragma interrupt InterruptHandlerHigh
#endif
void InterruptHandlerHigh() {
    // 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 I2C interrupt
    if (PIR1bits.SSPIF) {
        // clear the interrupt flag
        PIR1bits.SSPIF = 0;
        // call the handler
        DEBUG_ON(I2C_ISR);
        i2c_int_handler();
        DEBUG_OFF(I2C_ISR);
    }

    // check to see if we have an interrupt on timer 0
    if (INTCONbits.TMR0IF) {
        DEBUG_ON(TIMER0_ISR);
        INTCONbits.TMR0IF = 0; // clear this interrupt flag
        // call whatever handler you want (this is "user" defined)
        timer0_int_handler();
        DEBUG_OFF(TIMER0_ISR);
    }

    // here is where you would check other interrupt flags.
    if (PIR1bits.ADIF) {
        // clear the interrupt flag
        DEBUG_OFF(ADC_START);  
        PIR1bits.ADIF = 0;
        // call the handler
        //DEBUG_ON(ADC_START);
        adc_int_handler();
        //DEBUG_OFF(ADC_START);
    }

    // The *last* thing I do here is check to see if we can
    // allow the processor to go to sleep
    // This code *DEPENDS* on the code in messages.c being
    // initialized using "init_queues()" -- if you aren't using
    // this, then you shouldn't have this call here
    SleepIfOkay();
}