Firmware/src/hardware.c
void init_adc_single_measure(void)
{
  ADC_InitTypeDef  ADC_InitStructure;
  
  RCC_ADCCLKConfig(RCC_PCLK2_Div2);//12 mhz
  RCC_APB2PeriphClockCmd(BATERRY_ADC_RCC | RCC_APB2Periph_AFIO,ENABLE);
  
  ADC_DeInit(BATERRY_ADC_NAME);
  ADC_StructInit(&ADC_InitStructure);

  ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
  ADC_InitStructure.ADC_ScanConvMode = DISABLE;
  ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
  ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_NbrOfChannel = 1;
  ADC_Init(BATERRY_ADC_NAME, &ADC_InitStructure);

  ADC_DMACmd(BATERRY_ADC_NAME, DISABLE);  
  ADC_Cmd(BATERRY_ADC_NAME, ENABLE);
  
  ADC_ResetCalibration(BATERRY_ADC_NAME);
  while(ADC_GetResetCalibrationStatus(BATERRY_ADC_NAME)){}; 
  ADC_StartCalibration(BATERRY_ADC_NAME);   
  while(ADC_GetCalibrationStatus(BATERRY_ADC_NAME)){};
}
//Init ADC for single software triggered measure
Init ADC for single software triggered measure
Init ADC for single software triggered measure
void init_adc_single_measure(void)
{
  ADC_InitTypeDef  ADC_InitStructure;
  RCC_ADCCLKConfig(RCC_PCLK2_Div2);
  RCC_APB2PeriphClockCmd(BATERRY_ADC_RCC | RCC_APB2Periph_AFIO,ENABLE);
  ADC_DeInit(BATERRY_ADC_NAME);
  ADC_StructInit(&ADC_InitStructure);
  ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
  ADC_InitStructure.ADC_ScanConvMode = DISABLE;
  ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
  ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_NbrOfChannel = 1;
  ADC_Init(BATERRY_ADC_NAME, &ADC_InitStructure);
  ADC_DMACmd(BATERRY_ADC_NAME, DISABLE);  
  ADC_Cmd(BATERRY_ADC_NAME, ENABLE);
  ADC_ResetCalibration(BATERRY_ADC_NAME);
  while(ADC_GetResetCalibrationStatus(BATERRY_ADC_NAME)){}; 
  ADC_StartCalibration(BATERRY_ADC_NAME);   
  while(ADC_GetCalibrationStatus(BATERRY_ADC_NAME)){};
}
void init_adc_single_measure ( void ) { ADC_InitTypeDef ADC_InitStructure ; RCC_ADCCLKConfig ( RCC_PCLK2_Div2 ) ; RCC_APB2PeriphClockCmd ( BATERRY_ADC_RCC | RCC_APB2Periph_AFIO , ENABLE ) ; ADC_DeInit ( BATERRY_ADC_NAME ) ; ADC_StructInit ( & ADC_InitStructure ) ; ADC_InitStructure . ADC_Mode = ADC_Mode_Independent ; ADC_InitStructure . ADC_ScanConvMode = DISABLE ; ADC_InitStructure . ADC_ContinuousConvMode = DISABLE ; ADC_InitStructure . ADC_ExternalTrigConv = ADC_ExternalTrigConv_None ; ADC_InitStructure . ADC_DataAlign = ADC_DataAlign_Right ; ADC_InitStructure . ADC_NbrOfChannel = 1 ; ADC_Init ( BATERRY_ADC_NAME , & ADC_InitStructure ) ; ADC_DMACmd ( BATERRY_ADC_NAME , DISABLE ) ; ADC_Cmd ( BATERRY_ADC_NAME , ENABLE ) ; ADC_ResetCalibration ( BATERRY_ADC_NAME ) ; while ( ADC_GetResetCalibrationStatus ( BATERRY_ADC_NAME ) ) { } ; ADC_StartCalibration ( BATERRY_ADC_NAME ) ; while ( ADC_GetCalibrationStatus ( BATERRY_ADC_NAME ) ) { } ; }
Init ADC for single software triggered measure
Init ADC for single software triggered measure
//12 mhz