예제 #1
0
/*******************************************************************************
* Function Name  : ADC1_2_IRQHandler
* Description    : This function handles ADC1 and ADC2 global interrupts requests.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void ADC_IRQHandler(void)
{
  if((ADC1->SR & ADC_FLAG_JEOC) == ADC_FLAG_JEOC)
  {
    //It clear JEOC flag
    ADC1->SR &= ~(rt_uint32_t)(ADC_FLAG_JEOC | ADC_FLAG_JSTRT);
    MCLIB_Mesure_Structure.Mec_Angle = GET_MECHANICAL_ANGLE;
//    if (SVPWMEOCEvent())
		if (State != IDLE)
    {   
//      MCL_Calc_BusVolt();
			
      switch (State)
      {
          case RUN:          
            FOC_Model();       
          break;       
    
          case START: 
						ENC_Start_Up();	
          break; 
    
          default:
          break;
      }
			
      #ifdef BRAKE_RESISTOR
        if((wGlobal_Flags & BRAKE_ON) == BRAKE_ON)
        {
          rt_uint16_t aux;
					
          aux = ADC_GetInjectedConversionValue(ADC1, ADC_InjectedChannel_2);
        
          if (aux < BRAKE_HYSTERESIS)
          {
           wGlobal_Flags &= ~BRAKE_ON;
           MCL_Set_Brake_Off();
          }
        }
      #endif      
    }
  }
  else 
  {  
    if(ADC_GetITStatus(ADC1, ADC_IT_AWD) == SET)
    {
#ifdef BRAKE_RESISTOR
      //Analog watchdog interrupt has been generated 
     MCL_Set_Brake_On(); 
     wGlobal_Flags |= BRAKE_ON;
#else
     if(MCL_Chk_BusVolt()==OVER_VOLT)  // ·ÀÖ¹¸ÉÈÅ
        MCL_SetFault(OVER_VOLTAGE);
#endif

     ADC_ClearFlag(ADC1, ADC_FLAG_AWD);
    }    
  }
	
}
예제 #2
0
//--------------------------------------------------------------------
 void ADC1_IRQHandler(void)
{
		static portBASE_TYPE xHigherPriorityTaskWoken;

		//ADC_ITConfig(ADC1, ADC_IT_AWD, DISABLE);

		if(ADC_GetITStatus(ADC1,ADC_IT_AWD)!= RESET)
		{
ADC1->CR1 &= (~(uint32_t)ADC_IT_AWD);

			xHigherPriorityTaskWoken = pdFALSE;

			xSemaphoreGiveFromISR( xVibro_Semaphore, &xHigherPriorityTaskWoken );


			 if( xHigherPriorityTaskWoken != pdFALSE )
			 {
				portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
			 }
			/* Clear ADC1 AWD pending interrupt bit */



			portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
		}
		ADC_ClearITPendingBit(ADC1, ADC_IT_AWD);
}
예제 #3
0
void ADC1_IRQHandler(void)
{
  if(ADC_GetITStatus(ADC1, ADC_IT_EOC) != RESET)
  {
    /* Get converted value */
    ADCVal = ADC_GetConversionValue(ADC1);
    /* Clear EOC Flag */
    ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);
  }
}
예제 #4
0
void ADC_IRQHandler(void)
{
    if (ADC_GetITStatus(ADC1, ADC_IT_EOC)) {
    	ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);

        adc_value = ADC_GetConversionValue(ADC1);

        adc_complete = true;
    }
}
예제 #5
0
void ADC1_2_IRQHandler(void)
{
    if(ADC_GetITStatus(ADC1,ADC_IT_EOC) == SET)
    {

        ADC_ClearITPendingBit(ADC1,ADC_IT_EOC);


    }
}
예제 #6
0
/**
  * @brief  This function handles ADC1 global interrupts requests.
  * @param  None
  * @retval None
  */
void ADC1_COMP_IRQHandler(void)
{
  if(ADC_GetITStatus(ADC1, ADC_IT_EOC) != RESET)
  {
    /* Get converted value */
    ADCVal = ADC_GetConversionValue(ADC1);
    /* Output converted value on DAC_OUT1 */
    DAC_SetChannel1Data(DAC_Align_12b_R, ADCVal);
    /* Clear EOC Flag */
    ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);
  }
}
예제 #7
0
/**
  * @brief  This function handles ADC1 global interrupts requests.
  * @param  None
  * @retval None
  */
void ADC1_IRQHandler(void)
{
  if(ADC_GetITStatus(ADC1, ADC_IT_AWD) != RESET)
  {
    /*  Turn on LED1 */
    STM_EVAL_LEDOn(LED1);
    /* Clear ADC1 AWD pending interrupt bit */
    ADC_ClearITPendingBit(ADC1, ADC_IT_AWD);
    /*  Turn Off LED1 */
    STM_EVAL_LEDOff(LED1);
  }
}
예제 #8
0
/**
    @brief Extern C IRQ handler for ADC1 with all necessary physical bit manipulation
*/
void ADC1_IRQHandler(void)
{
    // Check if it is end of conversion
    if (ADC_GetITStatus(ADC1, ADC_IT_EOC)) {
        // Process EOC interrupt
        Analog::adc[0]->end_of_conversion();
        // Clear specific IRQ pending bit for this specific ADC1_IRQ
        ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);
    }
    // Check if it is end of injected conversion
    else if(ADC_GetITStatus(ADC1, ADC_IT_JEOC)){
        // Process EOC interrupt
        //Analog::adc[0]->end_of_jconversion();
        // Clear specific IRQ pending bit for this specific ADC1_IRQ
        ADC_ClearITPendingBit(ADC1, ADC_IT_JEOC);
    }
    // Check if it is end of injected conversion
    else if(ADC_GetITStatus(ADC1, ADC_IT_AWD)){
        // Process EOC interrupt
        //Analog::adc[0]->end_of_jconversion();
        // Clear specific IRQ pending bit for this specific ADC1_IRQ
        ADC_ClearITPendingBit(ADC1, ADC_IT_AWD);
    }
}
예제 #9
0
/**
  * @brief  This function handles ADC1-2 interrupt requests.- Should only be from the analog watchdog
  * @param  None
  * @retval None
  */
__attribute__((externally_visible)) void ADC1_2_IRQHandler(void) {
	if(ADC_GetITStatus(ADC2, ADC_IT_AWD)) {			//Analogue watchdog was triggered
		if(file_opened) {
			char c[]="\r\nLow Battery\r\n";
			uint8_t a;
			f_write(&FATFS_logfile,c,sizeof(c),&a);	//Write the error to the file
			f_sync(&FATFS_logfile);			//Flush buffers
			f_truncate(&FATFS_logfile);		//Truncate the lenght - fix pre allocation
			f_close(&FATFS_logfile);		//Close any opened file
		}
		red_flash();					//Flash red led
		shutdown();					//Shutdown to save battery
	}
	ADC_ClearITPendingBit(ADC2, ADC_IT_EOC);
	ADC_ClearITPendingBit(ADC2, ADC_IT_JEOC);
	ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);
	ADC_ClearITPendingBit(ADC1, ADC_IT_JEOC);		//None of these should ever happen, but best to be safe
	ADC_ClearITPendingBit(ADC1, ADC_IT_AWD);		//make sure flags are clear
}
예제 #10
0
파일: adc.c 프로젝트: glocklueng/smart-car
void ADC_IRQHandler(void)
{
	static uint16_t adc_val[5] = {0};
	uint16_t ave;
	if(ADC_GetITStatus(ADC1, ADC_IT_EOC) == SET){
		adc_val[4] = adc_val[3];
		adc_val[3] = adc_val[2];
		adc_val[4] = adc_val[1];
		adc_val[1] = adc_val[0];
		adc_val[0] = ADC1->DR;
		ave = (adc_val[0]+adc_val[1]+adc_val[2]+adc_val[3]+adc_val[4])/5;
		if(adc_valid_flag == 1){
			if(ave > adc_threshold){
				adc_flag = 0;
			}
			else{
				adc_flag = 1;
			}
		}
	}
}
예제 #11
0
//End of conversion interrupt handler!
void ADC1_COMP_IRQHandler(void){
	//Check for end of conversion
	if(ADC_GetITStatus(ADC1, ADC_IT_EOC)){
		//Clear interrupt bit
		ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);
		//Switch statement dependent on current channel. First
		//channel is initialised as zero.
		switch(CChan){
		case 0:
			Conversions[0] = ADC_GetConversionValue(ADC1);
			CChan = 1;
			break;
		case 1:
			Conversions[1] = ADC_GetConversionValue(ADC1);
			CChan = 2;
			break;
		case 2:
			Conversions[2] = ADC_GetConversionValue(ADC1);
			CChan = 0;
			Converted = 1;
			break;
		}
	}
}