Skip to content

Commit 881a8e3

Browse files
committed
STM32L1 ADC internal channels update
1 parent 4d3a544 commit 881a8e3

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

targets/TARGET_STM/TARGET_STM32L1/analogin_device.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@
3535
#include "pinmap.h"
3636
#include "mbed_error.h"
3737
#include "PeripheralPins.h"
38-
#include <stdbool.h>
3938

4039
void analogin_init(analogin_t *obj, PinName pin)
4140
{
42-
static bool adc_hsi_inited = false;
43-
RCC_OscInitTypeDef RCC_OscInitStruct;
4441
uint32_t function = (uint32_t)NC;
4542

4643
// ADC Internal Channels "pins" (Temperature, Vref, Vbat, ...)
@@ -92,10 +89,9 @@ void analogin_init(analogin_t *obj, PinName pin)
9289
error("Cannot initialize ADC");
9390
}
9491

95-
// This section is done only once
96-
if (!adc_hsi_inited) {
97-
adc_hsi_inited = true;
92+
if (!__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY)) {
9893
// Enable the HSI (to clock the ADC)
94+
RCC_OscInitTypeDef RCC_OscInitStruct;
9995
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
10096
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
10197
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

targets/TARGET_STM/TARGET_STM32L1/device/stm32l1xx_hal_adc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
/* Includes ------------------------------------------------------------------*/
4545
#include "stm32l1xx_hal_def.h"
4646

47+
/* Include low level driver */
48+
#include "stm32l1xx_ll_adc.h"
49+
4750
/** @addtogroup STM32L1xx_HAL_Driver
4851
* @{
4952
*/

0 commit comments

Comments
 (0)