stm32f3: unify implementation with f0 adc_enable_analog_watchdog_on_selected_channel

- match the same logic as the f0 api
- use ADC_CFGR1_AWD1CH_VAL macro to mask the channel bits
- don't check if channel is < 18q
- enable the awd in addition to setting the selection to single channel monitoring (in following with the signature and @brief 'enable'
This commit is contained in:
Jacob Walser 2019-09-24 22:16:33 -04:00 committed by Karl Palsson
parent 854da9635e
commit a759a0d9c9

View File

@ -282,14 +282,10 @@ void adc_enable_analog_watchdog_on_all_channels(uint32_t adc)
void adc_enable_analog_watchdog_on_selected_channel(uint32_t adc,
uint8_t channel)
{
uint32_t reg32;
ADC_CFGR1(adc) = (ADC_CFGR1(adc) & ~ADC_CFGR1_AWD1CH) |
ADC_CFGR1_AWD1CH_VAL(channel);
reg32 = (ADC_CFGR1(adc) & ~ADC_CFGR1_AWD1CH); /* Clear bit [4:0]. */
if (channel < 18) {
reg32 |= channel;
}
ADC_CFGR1(adc) = reg32;
ADC_CFGR1(adc) |= ADC_CFGR1_AWD1SGL;
ADC_CFGR1(adc) |= ADC_CFGR1_AWD1EN | ADC_CFGR1_AWD1SGL;
}