mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #5210 from bcostm/L4_add_adc_calib
STM32: add ADC calibration for L4, F1, F3 devicespull/5283/merge
commit
80ff7071b4
|
|
@ -33,6 +33,7 @@
|
||||||
#include "mbed_wait_api.h"
|
#include "mbed_wait_api.h"
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
#include "pinmap.h"
|
#include "pinmap.h"
|
||||||
|
#include "mbed_error.h"
|
||||||
#include "PeripheralPins.h"
|
#include "PeripheralPins.h"
|
||||||
|
|
||||||
int adc_inited = 0;
|
int adc_inited = 0;
|
||||||
|
|
@ -93,7 +94,13 @@ void analogin_init(analogin_t *obj, PinName pin)
|
||||||
obj->handle.Init.DiscontinuousConvMode = DISABLE;
|
obj->handle.Init.DiscontinuousConvMode = DISABLE;
|
||||||
obj->handle.Init.NbrOfDiscConversion = 0;
|
obj->handle.Init.NbrOfDiscConversion = 0;
|
||||||
obj->handle.Init.ExternalTrigConv = ADC_SOFTWARE_START;
|
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) {
|
if (HAL_ADC_Init(&obj->handle) != HAL_OK) {
|
||||||
error("Cannot initialize ADC");
|
error("Cannot initialize ADC");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calibrate ADC
|
||||||
|
HAL_ADCEx_Calibration_Start(&obj->handle, ADC_SINGLE_ENDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint16_t adc_read(analogin_t *obj)
|
static inline uint16_t adc_read(analogin_t *obj)
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,9 @@ void analogin_init(analogin_t *obj, PinName pin)
|
||||||
if (HAL_ADC_Init(&obj->handle) != HAL_OK) {
|
if (HAL_ADC_Init(&obj->handle) != HAL_OK) {
|
||||||
error("Cannot initialize ADC\n");
|
error("Cannot initialize ADC\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calibrate ADC
|
||||||
|
HAL_ADCEx_Calibration_Start(&obj->handle, ADC_SINGLE_ENDED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue