Skip to content

Commit 3ab5dce

Browse files
committed
STM32L1 : correct ST HAL API call
- RCC init: unused clock was enabled without any init parameters - RCC init: one PLL parameter was missing - ADC: a parameter setting was missing to init clock - GPIO: mode was not allowed by ST HAL API - ll_utils: compilation issue
1 parent 12d2795 commit 3ab5dce

File tree

7 files changed

+13
-23
lines changed

7 files changed

+13
-23
lines changed

targets/TARGET_STM/TARGET_STM32L1/TARGET_MOTE_L152RC/device/system_stm32l1xx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
529529
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
530530

531531
/* Enable HSE and HSI48 oscillators and activate PLL with HSE as source */
532-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI;
532+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
533533
if (bypass == 0)
534534
{
535535
RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 8 MHz xtal on OSC_IN/OSC_OUT */
@@ -586,7 +586,7 @@ uint8_t SetSysClock_PLL_HSI(void)
586586
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
587587

588588
/* Enable HSI oscillator and activate PLL with HSI as source */
589-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE;
589+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
590590
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
591591
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
592592
// SYSCLK = 32 MHz ((16 MHz * 4) / 2)

targets/TARGET_STM/TARGET_STM32L1/TARGET_NUCLEO_L152RE/device/system_stm32l1xx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
526526
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
527527

528528
/* Enable HSE and HSI48 oscillators and activate PLL with HSE as source */
529-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI;
529+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
530530
if (bypass == 0)
531531
{
532532
RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 8 MHz xtal on OSC_IN/OSC_OUT */
@@ -583,7 +583,7 @@ uint8_t SetSysClock_PLL_HSI(void)
583583
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
584584

585585
/* Enable HSI oscillator and activate PLL with HSI as source */
586-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE;
586+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
587587
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
588588
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
589589
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;

targets/TARGET_STM/TARGET_STM32L1/TARGET_NZ32_SC151/device/system_stm32l1xx.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,7 @@
9797
/** @addtogroup STM32L1xx_System_Private_Defines
9898
* @{
9999
*/
100-
#if !defined (HSE_VALUE)
101-
#define HSE_VALUE ((uint32_t)16000000) /*!< Default value of the External oscillator in Hz.
102-
This value can be provided and adapted by the user application. */
103-
#endif /* HSE_VALUE */
100+
#define HSE_VALUE ((uint32_t)16000000) /*!< NZ32-SC151 has a 16MHz External crystal */
104101

105102
#if !defined (HSI_VALUE)
106103
#define HSI_VALUE ((uint32_t)16000000) /*!< Default value of the Internal oscillator in Hz.
@@ -526,7 +523,7 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
526523
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
527524

528525
/* Enable HSE and HSI48 oscillators and activate PLL with HSE as source */
529-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI;
526+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
530527
if (bypass == 0)
531528
{
532529
RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 16 MHz xtal on OSC_IN/OSC_OUT */
@@ -584,7 +581,7 @@ uint8_t SetSysClock_PLL_HSI(void)
584581
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
585582

586583
/* Enable HSI oscillator and activate PLL with HSI as source */
587-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE;
584+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
588585
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
589586
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
590587
// SYSCLK = 32 MHz ((16 MHz * 4) / 2)

targets/TARGET_STM/TARGET_STM32L1/TARGET_XDOT_L151CC/device/system_stm32l1xx.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,7 @@
9898
/** @addtogroup STM32L1xx_System_Private_Defines
9999
* @{
100100
*/
101-
#if !defined (HSE_VALUE)
102-
#define HSE_VALUE ((uint32_t)24000000) /*!< Default value of the External oscillator in Hz.
103-
This value can be provided and adapted by the user application. */
104-
#endif /* HSE_VALUE */
101+
#define HSE_VALUE ((uint32_t)24000000) /*!< XDOT-L151CC has a 24MHz External crystal */
105102

106103
#if !defined (HSI_VALUE)
107104
#define HSI_VALUE ((uint32_t)16000000) /*!< Default value of the Internal oscillator in Hz.
@@ -527,7 +524,7 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
527524
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
528525

529526
/* Enable HSE and HSI48 oscillators and activate PLL with HSE as source */
530-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI;
527+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
531528
if (bypass == 0)
532529
{
533530
RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 24 MHz xtal on OSC_IN/OSC_OUT */
@@ -585,7 +582,7 @@ uint8_t SetSysClock_PLL_HSI(void)
585582
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
586583

587584
/* Enable HSI oscillator and activate PLL with HSI as source */
588-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE;
585+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
589586
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
590587
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
591588
// SYSCLK = 32 MHz ((16 MHz * 4) / 2)

targets/TARGET_STM/TARGET_STM32L1/analogin_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void analogin_init(analogin_t *obj, PinName pin)
7070
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
7171
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
7272
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
73+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
7374
HAL_RCC_OscConfig(&RCC_OscInitStruct);
7475

7576
AdcHandle.Instance = (ADC_TypeDef *)(obj->adc);

targets/TARGET_STM/TARGET_STM32L1/device/stm32l1xx_ll_utils.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@
3939
#include "stm32l1xx_ll_utils.h"
4040
#include "stm32l1xx_ll_system.h"
4141
#include "stm32l1xx_ll_pwr.h"
42-
#ifdef USE_FULL_ASSERT
43-
#include "stm32_assert.h"
44-
#else
45-
#define assert_param(expr) ((void)0U)
46-
#endif
4742

4843
/** @addtogroup STM32L1xx_LL_Driver
4944
* @{

targets/TARGET_STM/TARGET_STM32L1/gpio_irq_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
304304
mode = STM_MODE_IT_FALLING;
305305
obj->event = EDGE_FALL;
306306
} else { // NONE or RISE
307-
mode = STM_MODE_IT_EVT_RESET;
307+
mode = STM_MODE_INPUT;
308308
obj->event = EDGE_NONE;
309309
}
310310
}
@@ -313,7 +313,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
313313
mode = STM_MODE_IT_RISING;
314314
obj->event = EDGE_RISE;
315315
} else { // NONE or FALL
316-
mode = STM_MODE_IT_EVT_RESET;
316+
mode = STM_MODE_INPUT;
317317
obj->event = EDGE_NONE;
318318
}
319319
}

0 commit comments

Comments
 (0)