diff options
| author | Chasel <[email protected]> | 2025-02-12 14:26:35 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-02-12 14:26:35 +0800 |
| commit | d8079e384330a0df489c09910689104c8d9b3fbe (patch) | |
| tree | 1ec3b31e574535cb2bb4c3fd1184171b21084d7e | |
| parent | 70982aea87876b13cda19ff1fb4bbe507cf4d3a0 (diff) | |
[bsp][mm32f526x] 1.fix adc device; (#9978)
| -rw-r--r-- | bsp/mm32f526x/drivers/drv_adc.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/bsp/mm32f526x/drivers/drv_adc.c b/bsp/mm32f526x/drivers/drv_adc.c index 0ed76c8168..233921fe39 100644 --- a/bsp/mm32f526x/drivers/drv_adc.c +++ b/bsp/mm32f526x/drivers/drv_adc.c @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes * 2025-01-22 chasel first version + * 2025-02-10 chasel fix adc calibration did not clear flag bits */ #include <rtdevice.h> #include "board.h" @@ -94,14 +95,8 @@ static rt_err_t mm32_get_adc_value(struct rt_adc_device *device, rt_int8_t chann ADC_SoftwareStartConvCmd(adc_x, ENABLE); - rt_uint32_t cnt = 0; - /* @warning There is a bug here, please fix me. */ - while(ADC_GetFlagStatus(adc_x, ADC_FLAG_EOS) == 0) { - rt_thread_mdelay(1); - if (cnt++ > 5) - break; - } - ADC_ClearFlag(adc_x, ADC_FLAG_EOS); + while(ADC_GetFlagStatus(adc_x, ADC_FLAG_EOC) == 0); + ADC_ClearFlag(adc_x, ADC_FLAG_EOC); *value = ADC_GetChannelConvertedValue(adc_x, channel); return RT_EOK; |
