STM32L0 ADC internal channels update

pull/6987/head
jeromecoutant 2018-05-22 10:52:50 +02:00
parent 06bca28268
commit 4d3a54443d
2 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -44,6 +44,9 @@
/* Includes ------------------------------------------------------------------*/
#include "stm32l0xx_hal_def.h"
/* Include low level driver */
#include "stm32l0xx_ll_adc.h"
/** @addtogroup STM32L0xx_HAL_Driver
* @{
*/