void CfgAdcSampleChannel(ADC_HandleTypeDef *pAdcHandleCfg,UINT32 sample_channel,UINT32 rank)
{
ADC_ChannelConfTypeDef sConfig = {0};
sConfig.Channel = sample_channel; // 输入通道号
sConfig.Rank = ADC_REGULAR_RANK_1; // ADC常规转换组里的编号
sConfig.SamplingTime = ADC_SAMPLETIME_391CYCLES; // 采样时间,单位为ADCCLK周期数
sConfig.SingleDiff = ADC_SINGLE_ENDED; // 选择单端采样
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
HAL_ADC_ConfigChannel(pAdcHandleCfg, &sConfig);
}
|