Exemplo n.º 1
0
/**
 * ADC1+2 interrupt hander
 */
void adc1_2_irq_handler(void)
{
    uint8_t channel = 0;
    uint16_t value  = 0;
    struct adc_buf * buf;

#ifdef USE_AD1
    // Clear Injected End Of Conversion
    ADC_ClearITPendingBit(ADC1, ADC_IT_JEOC);
    for(channel = 0; channel < NB_ADC1_CHANNELS; channel++) {
        buf = adc1_buffers[channel];
        if(buf) {
            value = ADC_GetInjectedConversionValue(ADC1, adc_injected_channels[channel]);
            adc_push_sample(buf, value);
        }
    }
    adc_new_data_trigger = 1;
#endif
#ifdef USE_AD2
    // Clear Injected End Of Conversion
    ADC_ClearITPendingBit(ADC2, ADC_IT_JEOC);
    for(channel = 0; channel < NB_ADC2_CHANNELS; channel++) {
        buf = adc2_buffers[channel];
        if(buf) {
            value = ADC_GetInjectedConversionValue(ADC2, adc_injected_channels[channel]);
            adc_push_sample(buf, value);
        }
    }
    adc_new_data_trigger = 1;
#endif
}
Exemplo n.º 2
0
/*******************************************************************************
* Function Name  : ADC_Configuration
* Description    : ADC2 配置
* Input          : PC5

*******************************************************************************/
void ADC_Configuration(void)
{
  ADC_InitTypeDef ADC_InitStructure;
  
  /* Configure the ADC2 */
  ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
  ADC_InitStructure.ADC_ScanConvMode = ENABLE;
  ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
  ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_NbrOfChannel = 1;
  ADC_Init(ADC2, &ADC_InitStructure);
  
  /* ADC2 regular channel5 configuration */ 
  ADC_RegularChannelConfig(ADC2, ADC_Channel_10, 1, ADC_SampleTime_239Cycles5);
  
  /* Enable ADC2 */
  ADC_Cmd(ADC2, ENABLE);
  /* Enable ADC2 reset calibaration register */   
  ADC_ResetCalibration(ADC2);
  /* Check the end of ADC2 reset calibration register */
  while(ADC_GetResetCalibrationStatus(ADC2));
  /* Start ADC2 calibaration */
  ADC_StartCalibration(ADC2);
  /* Check the end of ADC2 calibration */
  while(ADC_GetCalibrationStatus(ADC2));  
  /* Start ADC2 Software Conversion */ 
  ADC_SoftwareStartConvCmd(ADC2, ENABLE);
  
  ADC_ITConfig(ADC2, ADC_IT_EOC, ENABLE); 
  ADC_ClearITPendingBit(ADC2,ADC_IT_EOC);
}
Exemplo n.º 3
0
static void AD_Reset()
{
	ADC_InitTypeDef ADC_InitStructure;

	ADC_DeInit(ADC1);

	/* ADC configuration ------------------------------------------------------*/
	ADC_InitStructure.ADC_Mode = ADC_Mode_RegInjecSimult; //ADC_Mode_RegSimult;
	ADC_InitStructure.ADC_ScanConvMode = ENABLE;
	ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
	ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T3_TRGO;
	ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
	ADC_InitStructure.ADC_NbrOfChannel = 1;

	ADC_Init(ADC1, &ADC_InitStructure);

	ADC_ExternalTrigConvCmd(ADC1, ENABLE);

	ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1, ADC_SampleTime_239Cycles5);

	ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);
	ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE);

	/* enable and calibrate ADCs */
	ADC_Enable(ADC1);

}
Exemplo n.º 4
0
void ADC1_2_IRQHandler(void)
{
  ADCReData=ADC_GetConversionValue(ADC2);
  
  ADCInt=340*ADCReData/4096;
  
  
   delay_nus(10000);
   if(ADCInt>100)
   {
   Display_LedNum(ADCInt);
   GPIO_SetBits(GPIOC, HEX_D7);
   }
   else
   {
     if(ADCInt<10)
     {
       Hex_test(7,0);
     }
     Display_LedNum(ADCInt);
     Hex_test(6,0);
     GPIO_SetBits(GPIOC, HEX_D7);
   }
       
  ADC_ClearITPendingBit(ADC2,ADC_IT_EOC);
}
Exemplo n.º 5
0
void ADC3_IRQHandler(void)
{
	//over current, turn off relay
	GPIO_SetBits(GPIOD, GPIO_Pin_13);
	ADC_ClearITPendingBit(ADC3, ADC_IT_AWD);
	printf("power 2 software protection!");
}
Exemplo n.º 6
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);
}
Exemplo n.º 7
0
void ADC0_IRQHandler(void)
{
	ADC_ClearITPendingBit(ADC0,A,ADC_IT_AI);
	UART_printf("!!!\r\n");
	
	
	
}
Exemplo n.º 8
0
extern "C" void ADC_IRQHandler()
{
    // Assume interrupt comes from analog watchdog
    ADC_ClearITPendingBit(ADC1, ADC_IT_AWD);
    ADC_ITConfig(ADC1, ADC_IT_AWD, DISABLE);    // No longer need this interrupt
    // Do something...
    DAC_data_handler = panic_sound;
}
Exemplo n.º 9
0
void ADC1_IRQHandler()
{
	if (adc_chan < ADC_MAX_RESULT_COUNT) {
		adc_result[adc_chan] = ADC_GetConversionValue(ADC1);
		adc_chan++;
	}

	ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);
}
void ADC_IRQHandler(void)
{
	ADC_ClearITPendingBit(ADC1,ADC_IT_EOC);
	adcread=true;

//	sys.physIO.doutDebug1.setState(1);
	sys.physIO.doutDebug1.setState(0);

}
Exemplo n.º 11
0
/**
  * @brief  This function handles ADC1 and ADC2 global interrupts requests.
  * @param  None
  * @retval : None
  */
void ADC1_2_IRQHandler(void)
{
  /* Toggle LED */
  GPIO_WriteBit(GPIO_LED, GPIO_Pin_6, Bit_SET);
  GPIO_WriteBit(GPIO_LED, GPIO_Pin_6, Bit_RESET); 
  
  /* Clear ADC1 AWD pending interrupt bit */
  ADC_ClearITPendingBit(ADC1, ADC_IT_AWD);
}
Exemplo n.º 12
0
void ADC1_2_IRQHandler(void)
{
	//over current, turn off relay
	//int temp = ADC_GetConversionValue(ADC2);
	//printf("i1 = %d\n", temp);
	GPIO_SetBits(GPIOD, GPIO_Pin_12);
	ADC_ClearITPendingBit(ADC2, ADC_IT_AWD);
	printf("power 1 software protection!");
}
Exemplo n.º 13
0
void ADC1_2_IRQHandler(void)
{
  if (ADC_GetFlagStatus(ADC1, ADC_FLAG_JEOC))
  {
		SLOW_ADC_Process();
    ADC_ClearITPendingBit(ADC1, ADC_IT_JEOC);
  }
  //HAL_LED_G_TOG();
}
Exemplo n.º 14
0
void ADC1_2_IRQHandler(void)
#endif
{
  /* Toggle LED1 */
  STM_EVAL_LEDOn(LED1);
  STM_EVAL_LEDOff(LED1);
  
  /* Clear ADC1 AWD pending interrupt bit */
  ADC_ClearITPendingBit(ADC1, ADC_IT_AWD);
}
Exemplo n.º 15
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;
    }
}
Exemplo n.º 16
0
void ADC1_2_IRQHandler(void)
{
    if(ADC_GetITStatus(ADC1,ADC_IT_EOC) == SET)
    {

        ADC_ClearITPendingBit(ADC1,ADC_IT_EOC);


    }
}
Exemplo n.º 17
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
}
Exemplo n.º 18
0
//
// ADC1 ISR:
//
void ADC1_2_IRQHandler(void)
{
	//Limpa fonte de interupcao:
	ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);


	//Toma o resultado da conversao A/D
	vfbVal = vfbScale * (float)ADC_GetConversionValue(ADC1);

}
Exemplo n.º 19
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);
  }
}
Exemplo n.º 20
0
/**
  * @brief  This function handles ADC1 and ADC2 global interrupts requests.
  * @param  None
  * @retval : None
  */
void ADC1_2_IRQHandler(void)
{
  /* Set PC.06 pin */
  GPIO_WriteBit(GPIOC, GPIO_Pin_6, Bit_SET);
  /* Get injected channel11 converted value */
  ADC_InjectedConvertedValueTab[Index++] = ADC_GetInjectedConversionValue(ADC1, ADC_InjectedChannel_1);
  /* Clear ADC1 JEOC pending interrupt bit */
  ADC_ClearITPendingBit(ADC1, ADC_IT_JEOC);
  /* Reset PC.06 pin */
  GPIO_WriteBit(GPIOC, GPIO_Pin_6, Bit_RESET);
}
Exemplo n.º 21
0
int main(void)
{
	//Enable clocks
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

	//Configure PA0, PA1 and PA2 as analog inputs
	G.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2;
	G.GPIO_Mode = GPIO_Mode_AN;
	G.GPIO_OType = GPIO_OType_PP;
	G.GPIO_PuPd = GPIO_PuPd_NOPULL;
	G.GPIO_Speed = GPIO_Speed_2MHz;
	GPIO_Init(GPIOA, &G);

	//Configure ADC in 12bit mode with upward scanning
	A.ADC_ContinuousConvMode = DISABLE;
	A.ADC_DataAlign = ADC_DataAlign_Right;
	A.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
	A.ADC_Resolution = ADC_Resolution_12b;
	A.ADC_ScanDirection = ADC_ScanDirection_Upward;
	ADC_Init(ADC1, &A);
	ADC_Cmd(ADC1, ENABLE);

	//Enable end of conversion interrupt
	ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);
	ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE);

	//Enable ADC1 interrupt
	N.NVIC_IRQChannel = ADC1_COMP_IRQn;
	N.NVIC_IRQChannelPriority = 1;
	N.NVIC_IRQChannelCmd = ENABLE;
	NVIC_Init(&N);

	//Configure the channels to be converted, in this case C0, C1 and
	//C2, corresponding to PA0, PA1 and PA2 respectively
	ADC_ChannelConfig(ADC1, ADC_Channel_0, ADC_SampleTime_239_5Cycles);
	ADC_ChannelConfig(ADC1, ADC_Channel_1, ADC_SampleTime_239_5Cycles);
	ADC_ChannelConfig(ADC1, ADC_Channel_2, ADC_SampleTime_239_5Cycles);

	//Wait for the ADC to be ready!
	while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_ADRDY));

	while(1)
	{
		//Start conversion
		ADC_StartOfConversion(ADC1);

		//Wait for conversion
		while(!Converted);

		//Reset converted flag (placement of breakpoint!
		Converted = 0;
	}
}
Exemplo n.º 22
0
 void Vibro_Process( void *pvParameters ) //
 {
 	while(1)
 	{
 		if( xVibro_Semaphore != NULL)
 		{
 			if( xSemaphoreTake( xVibro_Semaphore, portMAX_DELAY ) == pdTRUE )
 			{
 				ADC_ClearITPendingBit(ADC1, ADC_IT_AWD);
 				vTaskDelay(500);
 				Set_Random_Color();
 				//vTaskDelay(1500);
 				ADC_ClearITPendingBit(ADC1, ADC_IT_AWD);
 				ADC_ITConfig(ADC1, ADC_IT_AWD, ENABLE);

 				//xSemaphoreGive(xVibro_Semaphore);
 				//taskYIELD();
 			}
 		}
 	}
 }
Exemplo n.º 23
0
void ADC_IRQHandler(void) // 20khz
{
	int freq = 20000;
	float period = 1.0 / freq;
	while(!ADC_GetFlagStatus(ADC2, ADC_FLAG_JEOC));
	ADC_ClearITPendingBit(ADC1, ADC_IT_JEOC);
	GPIO_ResetBits(GPIOC,GPIO_Pin_4);//messpin

	for(int i = 0; i < hal.fast_rt_func_count; i++){
		hal.fast_rt[i](period);
	}
}
Exemplo n.º 24
0
/**************************************************************************************
 Func: ADC中断函数
 Time: 2014-6-18
 Ver.: V1.0
 Note;
**************************************************************************************/
void ADC1_2_IRQHandler(void) //模拟狗相关
{
	ADC_ITConfig(ADC1,ADC_IT_AWD,DISABLE);
	if(SET == ADC_GetFlagStatus(ADC1,ADC_FLAG_AWD))
	{
		ADC_ClearFlag(ADC1,ADC_FLAG_AWD);
		ADC_ClearITPendingBit(ADC1,ADC_IT_AWD);
		if(Tos_TaskGetState(TOUCH_Tos_TaskID)==_TTS_Stop)Tos_TaskRecover(TOUCH_Tos_TaskID);
	else Tos_TaskTimeout(TOUCH_Tos_TaskID,10);//防止在任务没有挂起就发生dma发送中断了
	}
	
}
Exemplo n.º 25
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);
  }
}
Exemplo n.º 26
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);
  }
}
Exemplo n.º 27
0
/**
 * ADC1 interrupt hander
 */
void adc1_2_irq_handler(void)
{
	ADC_ClearITPendingBit(ADC1, ADC_IT_JEOC);

	adc_data.battery_voltage =
		ADC_GetInjectedConversionValue(ADC1, ADC_BATTERY_VOLTAGE);
	adc_data.current =
		ADC_GetInjectedConversionValue(ADC1, ADC_CURRENT);
	adc_data.temp =
		ADC_GetInjectedConversionValue(ADC1, ADC_TEMP);

	adc_data.trigger = true;
}
Exemplo n.º 28
0
/**
  * @brief  This function handles ADC1 and ADC2 global interrupts requests.
  * @param  None
  * @retval None
  */
void ADC1_2_IRQHandler(void)
{
  /* Clear ADC1 JEOC pending interrupt bit */
  ADC_ClearITPendingBit(ADC1, ADC_IT_JEOC);
  
  /* Get injected channel10 and channel11 converted value */
  ADC_InjectedConvertedValueTab[Index++] = ADC_GetInjectedConversionValue(ADC1, ADC_InjectedChannel_1);
  ADC_InjectedConvertedValueTab[Index++] = ADC_GetInjectedConversionValue(ADC1, ADC_InjectedChannel_2);
  
  if (Index == 32)
  {
    Index = 0;
  }
}
Exemplo n.º 29
0
/**
  * @brief  This function handles ADC1 global interrupts requests.
  * @param  None
  * @retval None
  */
void ADC1_2_IRQHandler(void)
{
  if(ADC_GetFlagStatus(ADC1, ADC_FLAG_AWD2) != RESET)
  {
    /*  Turn Off LED4 */
    STM_EVAL_LEDOn(LED4);

    /* Clear ADC1 AWD pending interrupt bit */
    ADC_ClearITPendingBit(ADC1, ADC_IT_AWD2);

    /*  Turn on LED4 */
    STM_EVAL_LEDOff(LED4);    
  }
}
Exemplo n.º 30
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);
    }
}