#include "derivative.h"


#pragma TRAP_PROC
/****************************************************************************
* TPM1_ISR() -
*
* Description : Timer 1 Interrupt for LED Flashing
*			  :
* Example     :  
* Input 	  :
* Output	  : 
* Modify      : 
* Return      : 
****************************************************************************/ 
void TPM1_ISR(void) 
{
  if (FlagModify.bits.PWM){
    FlagModify.bits.PWM = 0;
    Util_Modify_PWM();
  }
 	TPM1SC_TOF = 0;
}

#pragma TRAP_PROC
void ADC1_ISR(void)
{
  signeddword buffer;

  if (ADCChannel == 0){
    buffer = AverageVoltage[RED];
    buffer += AD1R;
    AverageVoltage[RED]= buffer/2;
    ADCChannel = ADCGREEN;
  }
  
  else if (ADCChannel == ADCGREEN){
    buffer = AverageVoltage[GREEN];
    buffer += AD1R;
    AverageVoltage[GREEN]= buffer/2;
    ADCChannel = ADCBLUE;
  }
  
  else if (ADCChannel == ADCBLUE){
    buffer = AverageVoltage[BLUE];
    buffer += AD1R;
    AverageVoltage[BLUE]= buffer/2;
    ADCChannel = ADCTEMP;
  }

	AD1SC1 = 0;         // disable ADC
}

