mirror of https://github.com/ARMmbed/mbed-os.git
STM32L0 ADC internal channels update
parent
06bca28268
commit
4d3a54443d
|
|
@ -35,11 +35,9 @@
|
|||
#include "pinmap.h"
|
||||
#include "mbed_error.h"
|
||||
#include "PeripheralPins.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
void analogin_init(analogin_t *obj, PinName pin)
|
||||
{
|
||||
static bool adc_calibrated = false;
|
||||
uint32_t function = (uint32_t)NC;
|
||||
|
||||
// ADC Internal Channels "pins" (Temperature, Vref, Vbat, ...)
|
||||
|
|
@ -92,9 +90,7 @@ void analogin_init(analogin_t *obj, PinName pin)
|
|||
error("Cannot initialize ADC");
|
||||
}
|
||||
|
||||
// ADC calibration is done only once
|
||||
if (!adc_calibrated) {
|
||||
adc_calibrated = true;
|
||||
if (!HAL_ADCEx_Calibration_GetValue(&obj->handle, ADC_SINGLE_ENDED)) {
|
||||
HAL_ADCEx_Calibration_Start(&obj->handle, ADC_SINGLE_ENDED);
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +167,9 @@ uint16_t adc_read(analogin_t *obj)
|
|||
return 0;
|
||||
}
|
||||
|
||||
ADC1->CHSELR = 0; // [TODO] Workaround. To be removed after Cube driver is corrected.
|
||||
/* Reset ADC channel selection register */
|
||||
ADC1->CHSELR = 0;
|
||||
|
||||
HAL_ADC_ConfigChannel(&obj->handle, &sConfig);
|
||||
|
||||
HAL_ADC_Start(&obj->handle); // Start conversion
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@
|
|||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32l0xx_hal_def.h"
|
||||
|
||||
/* Include low level driver */
|
||||
#include "stm32l0xx_ll_adc.h"
|
||||
|
||||
/** @addtogroup STM32L0xx_HAL_Driver
|
||||
* @{
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue