Skip to content

Commit d8079e3

Browse files
authored
[bsp][mm32f526x] 1.fix adc device; (#9978)
1 parent 70982ae commit d8079e3

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

bsp/mm32f526x/drivers/drv_adc.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2025-01-22 chasel first version
9+
* 2025-02-10 chasel fix adc calibration did not clear flag bits
910
*/
1011
#include <rtdevice.h>
1112
#include "board.h"
@@ -94,14 +95,8 @@ static rt_err_t mm32_get_adc_value(struct rt_adc_device *device, rt_int8_t chann
9495

9596
ADC_SoftwareStartConvCmd(adc_x, ENABLE);
9697

97-
rt_uint32_t cnt = 0;
98-
/* @warning There is a bug here, please fix me. */
99-
while(ADC_GetFlagStatus(adc_x, ADC_FLAG_EOS) == 0) {
100-
rt_thread_mdelay(1);
101-
if (cnt++ > 5)
102-
break;
103-
}
104-
ADC_ClearFlag(adc_x, ADC_FLAG_EOS);
98+
while(ADC_GetFlagStatus(adc_x, ADC_FLAG_EOC) == 0);
99+
ADC_ClearFlag(adc_x, ADC_FLAG_EOC);
105100

106101
*value = ADC_GetChannelConvertedValue(adc_x, channel);
107102
return RT_EOK;

0 commit comments

Comments
 (0)