/** * @brief Configures the high and low thresholds of the analog watchdog. * @param ADCx: where x can be 1 to select the ADC1 peripheral. * @param HighThreshold: the ADC analog watchdog High threshold value. * This parameter must be a 12bit value. * @param LowThreshold: the ADC analog watchdog Low threshold value. * This parameter must be a 12bit value. * @retval None */ void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold, uint16_t LowThreshold) { /* Check the parameters */ assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_ADC_THRESHOLD(HighThreshold)); assert_param(IS_ADC_THRESHOLD(LowThreshold)); /* Set the ADCx high and low threshold */ ADCx->TR = LowThreshold | ((uint32_t)HighThreshold << 16); }
/** * @brief Configures the high and low thresholds of the analog watchdog. * @param ADCx: where x can be 1, 2 to select the ADC peripheral. * @param HighThreshold: the ADC analog watchdog High threshold value. * This parameter must be a 12bit value. * @param LowThreshold: the ADC analog watchdog Low threshold value. * This parameter must be a 12bit value. * @retval : None */ void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold, uint16_t LowThreshold) { uint32_t tempThreshold; /* Check the parameters */ assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_ADC_THRESHOLD(HighThreshold)); assert_param(IS_ADC_THRESHOLD(LowThreshold)); /* Get the ADCx high threshold */ tempThreshold = HighThreshold; /* Set the ADCx high threshold and the ADCx low threshold */ ADCx->ADCMPR = (tempThreshold<<16) | LowThreshold; }
/******************************************************************************* * 函数名称: ADC_AnalogWatchdogThresholdsConfig * 功能描述: 配置模拟看门狗的高、低阀值. * 输入参数: (1)ADCx:其中x可以是1、2或3,用来选择ADC外围模块. * (2)HighThreshold: ADC模拟看门狗最高阀值。该参数是一个12位的数值 * (3)LowThreshold: ADC模拟看门狗最低阀值。该参数是一个12位的数值 * 输出参数: 无 * 返回参数: 无 *******************************************************************************/ void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, u16 HighThreshold, u16 LowThreshold) { /* Check the parameters [检查参数] */ assert_param(IS_ADC_ALL_PERIPH(ADCx)); assert_param(IS_ADC_THRESHOLD(HighThreshold)); assert_param(IS_ADC_THRESHOLD(LowThreshold)); /* Set the ADCx high threshold [设置ADCx的高阀值]*/ ADCx->HTR = HighThreshold; /* Set the ADCx low threshold [设置ADCx的低阀值]*/ ADCx->LTR = LowThreshold; }