Skip to content

Commit e1f4d69

Browse files
committed
STM32L0 : correct ST HAL API call
- RCC init: unused clock was enabled without any init parameters - ADC: a parameter setting was missing - GPIO: mode was not allowed by ST HAL API - tick: init value was too high for 16b
1 parent 2c5249b commit e1f4d69

File tree

8 files changed

+14
-13
lines changed

8 files changed

+14
-13
lines changed

targets/TARGET_STM/TARGET_STM32L0/TARGET_DISCO_L053C8/device/system_stm32l0xx.c

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

369369
/* Enable HSE and HSI48 oscillators and activate PLL with HSE as source */
370-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
370+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48;
371371
if (bypass == 0)
372372
{
373373
RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 8 MHz xtal on OSC_IN/OSC_OUT */
@@ -427,7 +427,7 @@ uint8_t SetSysClock_PLL_HSI(void)
427427
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
428428

429429
/* Enable HSI and HSI48 oscillators and activate PLL with HSI as source */
430-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48;
430+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
431431
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
432432
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
433433
#if !defined (STM32L031xx) && !defined (STM32L041xx) && !defined(STM32L051xx) && !defined(STM32L061xx) && !defined(STM32L071xx) && !defined(STM32L081xx) && \

targets/TARGET_STM/TARGET_STM32L0/TARGET_NUCLEO_L011K4/device/system_stm32l0xx.c

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

369369
/* Enable HSE and HSI48 oscillators and activate PLL with HSE as source */
370-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
370+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48;
371371
if (bypass == 0)
372372
{
373373
RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 8 MHz xtal on OSC_IN/OSC_OUT */
@@ -427,7 +427,7 @@ uint8_t SetSysClock_PLL_HSI(void)
427427
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
428428

429429
/* Enable HSI and HSI48 oscillators and activate PLL with HSI as source */
430-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48;
430+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
431431
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
432432
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
433433
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;

targets/TARGET_STM/TARGET_STM32L0/TARGET_NUCLEO_L031K6/device/system_stm32l0xx.c

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

377377
/* Enable HSE and HSI48 oscillators and activate PLL with HSE as source */
378-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
378+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48;
379379
if (bypass == 0)
380380
{
381381
RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 8 MHz xtal on OSC_IN/OSC_OUT */
@@ -435,7 +435,7 @@ uint8_t SetSysClock_PLL_HSI(void)
435435
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
436436

437437
/* Enable HSI and HSI48 oscillators and activate PLL with HSI as source */
438-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48;
438+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
439439
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
440440
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
441441
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;

targets/TARGET_STM/TARGET_STM32L0/TARGET_NUCLEO_L053R8/device/system_stm32l0xx.c

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

369369
/* Enable HSE and HSI48 oscillators and activate PLL with HSE as source */
370-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
370+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48;
371371
if (bypass == 0)
372372
{
373373
RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 8 MHz xtal on OSC_IN/OSC_OUT */
@@ -427,7 +427,7 @@ uint8_t SetSysClock_PLL_HSI(void)
427427
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
428428

429429
/* Enable HSI and HSI48 oscillators and activate PLL with HSI as source */
430-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48;
430+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
431431
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
432432
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
433433
#if !defined (STM32L031xx) && !defined (STM32L041xx) && !defined(STM32L051xx) && !defined(STM32L061xx) && !defined(STM32L071xx) && !defined(STM32L081xx) && \

targets/TARGET_STM/TARGET_STM32L0/TARGET_NUCLEO_L073RZ/device/system_stm32l0xx.c

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

369369
/* Enable HSE and HSI48 oscillators and activate PLL with HSE as source */
370-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
370+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48;
371371
if (bypass == 0)
372372
{
373373
RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 8 MHz xtal on OSC_IN/OSC_OUT */
@@ -427,7 +427,7 @@ uint8_t SetSysClock_PLL_HSI(void)
427427
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
428428

429429
/* Enable HSI and HSI48 oscillators and activate PLL with HSI as source */
430-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI48;
430+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48;
431431
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
432432
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
433433
#if !defined (STM32L031xx) && !defined (STM32L041xx) && !defined(STM32L051xx) && !defined(STM32L061xx) && !defined(STM32L071xx) && !defined(STM32L081xx) && \

targets/TARGET_STM/TARGET_STM32L0/analogin_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ static inline uint16_t adc_read(analogin_t *obj)
105105
AdcHandle.Instance = (ADC_TypeDef *)(obj->adc);
106106

107107
// Configure ADC channel
108+
sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
108109
switch (obj->channel) {
109110
case 0:
110111
sConfig.Channel = ADC_CHANNEL_0;

targets/TARGET_STM/TARGET_STM32L0/gpio_irq_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
239239
mode = STM_MODE_IT_FALLING;
240240
obj->event = EDGE_FALL;
241241
} else { // NONE or RISE
242-
mode = STM_MODE_IT_EVT_RESET;
242+
mode = STM_MODE_INPUT;
243243
obj->event = EDGE_NONE;
244244
}
245245
}
@@ -248,7 +248,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
248248
mode = STM_MODE_IT_RISING;
249249
obj->event = EDGE_RISE;
250250
} else { // NONE or FALL
251-
mode = STM_MODE_IT_EVT_RESET;
251+
mode = STM_MODE_INPUT;
252252
obj->event = EDGE_NONE;
253253
}
254254
}

targets/TARGET_STM/hal_tick_16b.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
114114

115115
// Configure time base
116116
TimMasterHandle.Instance = TIM_MST;
117-
TimMasterHandle.Init.Period = 0xFFFFFFFF;
117+
TimMasterHandle.Init.Period = 0xFFFF;
118118
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
119119
TimMasterHandle.Init.ClockDivision = 0;
120120
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;

0 commit comments

Comments
 (0)