mirror of https://github.com/ARMmbed/mbed-os.git
Add ADC calibration for STM32F1 and F3 devices
parent
4824e18a95
commit
fca97146cd
|
|
@ -33,6 +33,7 @@
|
|||
#include "mbed_wait_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
#include "mbed_error.h"
|
||||
#include "PeripheralPins.h"
|
||||
|
||||
int adc_inited = 0;
|
||||
|
|
@ -93,7 +94,13 @@ void analogin_init(analogin_t *obj, PinName pin)
|
|||
obj->handle.Init.DiscontinuousConvMode = DISABLE;
|
||||
obj->handle.Init.NbrOfDiscConversion = 0;
|
||||
obj->handle.Init.ExternalTrigConv = ADC_SOFTWARE_START;
|
||||
HAL_ADC_Init(&obj->handle);
|
||||
|
||||
if (HAL_ADC_Init(&obj->handle) != HAL_OK) {
|
||||
error("Cannot initialize ADC\n");
|
||||
}
|
||||
|
||||
// Calibrate ADC
|
||||
HAL_ADCEx_Calibration_Start(&obj->handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,6 +130,9 @@ void analogin_init(analogin_t *obj, PinName pin)
|
|||
if (HAL_ADC_Init(&obj->handle) != HAL_OK) {
|
||||
error("Cannot initialize ADC");
|
||||
}
|
||||
|
||||
// Calibrate ADC
|
||||
HAL_ADCEx_Calibration_Start(&obj->handle, ADC_SINGLE_ENDED);
|
||||
}
|
||||
|
||||
static inline uint16_t adc_read(analogin_t *obj)
|
||||
|
|
|
|||
Loading…
Reference in New Issue