Skip to content

Commit 5047bd3

Browse files
authored
Merge pull request #14608 from JeanMarcR/STM32H7_NEW_CUBE
STM32H7 update drivers version to CUBE V1.9.0
2 parents 986add7 + 00d6093 commit 5047bd3

File tree

190 files changed

+12308
-6456
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+12308
-6456
lines changed

targets/TARGET_STM/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ This table summarizes the STM32Cube versions currently used in Mbed OS master br
6969
| F7 | 1.16.1 | https://github.com/STMicroelectronics/STM32CubeF7 |
7070
| G0 | 1.4.1 | https://github.com/STMicroelectronics/STM32CubeG0 |
7171
| G4 | 1.4.0 | https://github.com/STMicroelectronics/STM32CubeG4 |
72-
| H7 | 1.8.0 | https://github.com/STMicroelectronics/STM32CubeH7 |
72+
| H7 | 1.9.0 | https://github.com/STMicroelectronics/STM32CubeH7 |
7373
| L0 | 1.12.0 | https://github.com/STMicroelectronics/STM32CubeL0 |
7474
| L1 | 1.10.2 | https://github.com/STMicroelectronics/STM32CubeL1 |
7575
| L4 | 1.17.0 | https://github.com/STMicroelectronics/STM32CubeL4 |

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h723xx.h

Lines changed: 124 additions & 16 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h725xx.h

Lines changed: 124 additions & 16 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h730xx.h

Lines changed: 123 additions & 15 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h730xxq.h

Lines changed: 123 additions & 15 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h733xx.h

Lines changed: 124 additions & 16 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h735xx.h

Lines changed: 124 additions & 16 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h742xx.h

Lines changed: 117 additions & 21 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h743xx.h

Lines changed: 119 additions & 23 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h745xx.h

Lines changed: 123 additions & 23 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h747xx.h

Lines changed: 125 additions & 25 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h750xx.h

Lines changed: 120 additions & 29 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h753xx.h

Lines changed: 119 additions & 23 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h755xx.h

Lines changed: 123 additions & 23 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h757xx.h

Lines changed: 125 additions & 25 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h7a3xx.h

Lines changed: 145 additions & 16 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h7a3xxq.h

Lines changed: 145 additions & 16 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h7b0xx.h

Lines changed: 145 additions & 22 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h7b0xxq.h

Lines changed: 145 additions & 22 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h7b3xx.h

Lines changed: 145 additions & 16 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h7b3xxq.h

Lines changed: 145 additions & 16 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/CMSIS/stm32h7xx.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,16 @@
101101
#endif /* USE_HAL_DRIVER */
102102

103103
/**
104-
* @brief CMSIS Device version number V1.9.0
104+
* @brief CMSIS Device version number V1.10.0
105105
*/
106106
#define __STM32H7xx_CMSIS_DEVICE_VERSION_MAIN (0x01) /*!< [31:24] main version */
107-
#define __STM32H7xx_CMSIS_DEVICE_VERSION_SUB1 (0x09) /*!< [23:16] sub1 version */
107+
#define __STM32H7xx_CMSIS_DEVICE_VERSION_SUB1 (0x0A) /*!< [23:16] sub1 version */
108108
#define __STM32H7xx_CMSIS_DEVICE_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
109109
#define __STM32H7xx_CMSIS_DEVICE_VERSION_RC (0x00) /*!< [7:0] release candidate */
110-
#define __STM32H7xx_CMSIS_DEVICE_VERSION ((__CMSIS_DEVICE_VERSION_MAIN << 24)\
111-
|(__CMSIS_DEVICE_HAL_VERSION_SUB1 << 16)\
112-
|(__CMSIS_DEVICE_HAL_VERSION_SUB2 << 8 )\
113-
|(__CMSIS_DEVICE_HAL_VERSION_RC))
110+
#define __STM32H7xx_CMSIS_DEVICE_VERSION ((__STM32H7xx_CMSIS_DEVICE_VERSION_MAIN << 24)\
111+
|(__STM32H7xx_CMSIS_DEVICE_VERSION_SUB1 << 16)\
112+
|(__STM32H7xx_CMSIS_DEVICE_VERSION_SUB2 << 8 )\
113+
|(__STM32H7xx_CMSIS_DEVICE_VERSION_RC))
114114

115115
/**
116116
* @}

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/Legacy/stm32_hal_legacy.h

Lines changed: 75 additions & 102 deletions
Large diffs are not rendered by default.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
/* Private typedef -----------------------------------------------------------*/
4848
/* Private define ------------------------------------------------------------*/
4949
/**
50-
* @brief STM32H7xx HAL Driver version number V1.9.0
50+
* @brief STM32H7xx HAL Driver version number V1.10.0
5151
*/
5252
#define __STM32H7xx_HAL_VERSION_MAIN (0x01UL) /*!< [31:24] main version */
53-
#define __STM32H7xx_HAL_VERSION_SUB1 (0x09UL) /*!< [23:16] sub1 version */
53+
#define __STM32H7xx_HAL_VERSION_SUB1 (0x0AUL) /*!< [23:16] sub1 version */
5454
#define __STM32H7xx_HAL_VERSION_SUB2 (0x00UL) /*!< [15:8] sub2 version */
5555
#define __STM32H7xx_HAL_VERSION_RC (0x00UL) /*!< [7:0] release candidate */
5656
#define __STM32H7xx_HAL_VERSION ((__STM32H7xx_HAL_VERSION_MAIN << 24)\
@@ -507,14 +507,14 @@ uint32_t HAL_GetUIDw2(void)
507507
* @brief Configure the internal voltage reference buffer voltage scale.
508508
* @param VoltageScaling specifies the output voltage to achieve
509509
* This parameter can be one of the following values:
510-
* @arg SYSCFG_VREFBUF_VOLTAGE_SCALE0: VREF_OUT1 around 2.048 V.
511-
* This requires VDDA equal to or higher than 2.4 V.
512-
* @arg SYSCFG_VREFBUF_VOLTAGE_SCALE1: VREF_OUT2 around 2.5 V.
510+
* @arg SYSCFG_VREFBUF_VOLTAGE_SCALE0: VREF_OUT1 around 2.5 V.
513511
* This requires VDDA equal to or higher than 2.8 V.
514-
* @arg SYSCFG_VREFBUF_VOLTAGE_SCALE2: VREF_OUT3 around 1.5 V.
515-
* This requires VDDA equal to or higher than 1.8 V.
516-
* @arg SYSCFG_VREFBUF_VOLTAGE_SCALE3: VREF_OUT4 around 1.8 V.
512+
* @arg SYSCFG_VREFBUF_VOLTAGE_SCALE1: VREF_OUT2 around 2.048 V.
513+
* This requires VDDA equal to or higher than 2.4 V.
514+
* @arg SYSCFG_VREFBUF_VOLTAGE_SCALE2: VREF_OUT3 around 1.8 V.
517515
* This requires VDDA equal to or higher than 2.1 V.
516+
* @arg SYSCFG_VREFBUF_VOLTAGE_SCALE3: VREF_OUT4 around 1.5 V.
517+
* This requires VDDA equal to or higher than 1.8 V.
518518
* @retval None
519519
*/
520520
void HAL_SYSCFG_VREFBUF_VoltageScalingConfig(uint32_t VoltageScaling)
@@ -769,7 +769,7 @@ void HAL_SYSCFG_DisableCM4BOOT(void)
769769
/**
770770
* @brief Enables the I/O Compensation Cell.
771771
* @note The I/O compensation cell can be used only when the device supply
772-
* voltage ranges from 2.4 to 3.6 V.
772+
* voltage ranges from 1.62 to 2.0 V and from 2.7 to 3.6 V.
773773
* @retval None
774774
*/
775775
void HAL_EnableCompensationCell(void)
@@ -780,7 +780,7 @@ void HAL_EnableCompensationCell(void)
780780
/**
781781
* @brief Power-down the I/O Compensation Cell.
782782
* @note The I/O compensation cell can be used only when the device supply
783-
* voltage ranges from 2.4 to 3.6 V.
783+
* voltage ranges from 1.62 to 2.0 V and from 2.7 to 3.6 V.
784784
* @retval None
785785
*/
786786
void HAL_DisableCompensationCell(void)
@@ -1021,6 +1021,7 @@ void HAL_DisableDomain2DBGStandbyMode(void)
10211021
}
10221022
#endif /*DUAL_CORE*/
10231023

1024+
#if defined(DBGMCU_CR_DBG_STOPD3)
10241025
/**
10251026
* @brief Enable the Debug Module during Domain3/SRDomain STOP mode
10261027
* @retval None
@@ -1029,6 +1030,7 @@ void HAL_EnableDomain3DBGStopMode(void)
10291030
{
10301031
SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD3);
10311032
}
1033+
10321034
/**
10331035
* @brief Disable the Debug Module during Domain3/SRDomain STOP mode
10341036
* @retval None
@@ -1037,7 +1039,9 @@ void HAL_DisableDomain3DBGStopMode(void)
10371039
{
10381040
CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD3);
10391041
}
1042+
#endif /*DBGMCU_CR_DBG_STOPD3*/
10401043

1044+
#if defined(DBGMCU_CR_DBG_STANDBYD3)
10411045
/**
10421046
* @brief Enable the Debug Module during Domain3/SRDomain STANDBY mode
10431047
* @retval None
@@ -1055,6 +1059,7 @@ void HAL_DisableDomain3DBGStandbyMode(void)
10551059
{
10561060
CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD3);
10571061
}
1062+
#endif /*DBGMCU_CR_DBG_STANDBYD3*/
10581063

10591064
/**
10601065
* @brief Set the FMC Memory Mapping Swapping config.

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ typedef enum
6969
/** @defgroup SYSCFG_VREFBUF_VoltageScale VREFBUF Voltage Scale
7070
* @{
7171
*/
72-
#define SYSCFG_VREFBUF_VOLTAGE_SCALE0 VREFBUF_CSR_VRS_OUT2 /*!< Voltage reference scale 0 (VREF_OUT2) */
73-
#define SYSCFG_VREFBUF_VOLTAGE_SCALE1 VREFBUF_CSR_VRS_OUT1 /*!< Voltage reference scale 1 (VREF_OUT1) */
74-
#define SYSCFG_VREFBUF_VOLTAGE_SCALE2 VREFBUF_CSR_VRS_OUT4 /*!< Voltage reference scale 2 (VREF_OUT4) */
75-
#define SYSCFG_VREFBUF_VOLTAGE_SCALE3 VREFBUF_CSR_VRS_OUT3 /*!< Voltage reference scale 3 (VREF_OUT3) */
72+
#define SYSCFG_VREFBUF_VOLTAGE_SCALE0 VREFBUF_CSR_VRS_OUT1 /*!< Voltage reference scale 0 (VREF_OUT1) */
73+
#define SYSCFG_VREFBUF_VOLTAGE_SCALE1 VREFBUF_CSR_VRS_OUT2 /*!< Voltage reference scale 1 (VREF_OUT2) */
74+
#define SYSCFG_VREFBUF_VOLTAGE_SCALE2 VREFBUF_CSR_VRS_OUT3 /*!< Voltage reference scale 2 (VREF_OUT3) */
75+
#define SYSCFG_VREFBUF_VOLTAGE_SCALE3 VREFBUF_CSR_VRS_OUT4 /*!< Voltage reference scale 3 (VREF_OUT4) */
7676

7777

7878
#define IS_SYSCFG_VREFBUF_VOLTAGE_SCALE(__SCALE__) (((__SCALE__) == SYSCFG_VREFBUF_VOLTAGE_SCALE0) || \
@@ -1093,10 +1093,14 @@ void HAL_DisableDomain2DBGStopMode(void);
10931093
void HAL_EnableDomain2DBGStandbyMode(void);
10941094
void HAL_DisableDomain2DBGStandbyMode(void);
10951095
#endif /*DUAL_CORE*/
1096+
#if defined(DBGMCU_CR_DBG_STOPD3)
10961097
void HAL_EnableDomain3DBGStopMode(void);
10971098
void HAL_DisableDomain3DBGStopMode(void);
1099+
#endif /*DBGMCU_CR_DBG_STOPD3*/
1100+
#if defined(DBGMCU_CR_DBG_STANDBYD3)
10981101
void HAL_EnableDomain3DBGStandbyMode(void);
10991102
void HAL_DisableDomain3DBGStandbyMode(void);
1103+
#endif /*DBGMCU_CR_DBG_STANDBYD3*/
11001104
void HAL_EXTI_EdgeConfig(uint32_t EXTI_Line , uint32_t EXTI_Edge );
11011105
void HAL_EXTI_GenerateSWInterrupt(uint32_t EXTI_Line);
11021106
#if defined(DUAL_CORE)

targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_adc.c

Lines changed: 69 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @file stm32h7xx_hal_adc.c
44
* @author MCD Application Team
55
* @brief This file provides firmware functions to manage the following
6-
* functionalities of the Analog to Digital Convertor (ADC)
6+
* functionalities of the Analog to Digital Converter (ADC)
77
* peripheral:
88
* + Initialization and de-initialization functions
99
* ++ Initialization and Configuration of ADC
@@ -26,7 +26,7 @@
2626
[..]
2727
(+) 16-bit, 14-bit, 12-bit, 10-bit or 8-bit configurable resolution.
2828
Note: On devices STM32H72xx and STM32H73xx, these resolution are applicable to instances ADC1 and ADC2.
29-
ADC3 is featuring resolutions 12-bit, 10-bit, 8-bit, 6-bit.
29+
ADC3 is featuring resolutions 12-bit, 10-bit, 8-bit, 6-bit.
3030
3131
(+) Interrupt generation at the end of regular conversion and in case of
3232
analog watchdog or overrun events.
@@ -510,7 +510,7 @@ HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef *hadc)
510510
/* Note: Variable divided by 2 to compensate partially */
511511
/* CPU processing cycles, scaling in us split to not */
512512
/* exceed 32 bits register capacity and handle low frequency. */
513-
wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US / 10UL) * (SystemCoreClock / (100000UL * 2UL)));
513+
wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US / 10UL) * ((SystemCoreClock / (100000UL * 2UL)) + 1UL));
514514
while (wait_loop_index != 0UL)
515515
{
516516
wait_loop_index--;
@@ -1054,32 +1054,31 @@ HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc)
10541054
HAL_ADC_ConfigChannel() or HAL_ADCEx_InjectedConfigChannel() )
10551055
*/
10561056
ADC_CLEAR_COMMON_CONTROL_REGISTER(hadc);
1057-
}
1058-
1059-
/* DeInit the low level hardware.
1060-
1061-
For example:
1062-
__HAL_RCC_ADC_FORCE_RESET();
1063-
__HAL_RCC_ADC_RELEASE_RESET();
1064-
__HAL_RCC_ADC_CLK_DISABLE();
10651057

1066-
Keep in mind that all ADCs use the same clock: disabling
1067-
the clock will reset all ADCs.
1058+
/* ========== Hard reset ADC peripheral ========== */
1059+
/* Performs a global reset of the entire ADC peripherals instances */
1060+
/* sharing the same common ADC instance: ADC state is forced to */
1061+
/* a similar state as after device power-on. */
1062+
/* Note: A possible implementation is to add RCC bus reset of ADC */
1063+
/* (for example, using macro */
1064+
/* __HAL_RCC_ADC..._FORCE_RESET()/..._RELEASE_RESET()/..._CLK_DISABLE()) */
1065+
/* in function "void HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc)": */
10681066

1069-
*/
10701067
#if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
1071-
if (hadc->MspDeInitCallback == NULL)
1072-
{
1073-
hadc->MspDeInitCallback = HAL_ADC_MspDeInit; /* Legacy weak MspDeInit */
1074-
}
1068+
if (hadc->MspDeInitCallback == NULL)
1069+
{
1070+
hadc->MspDeInitCallback = HAL_ADC_MspDeInit; /* Legacy weak MspDeInit */
1071+
}
10751072

1076-
/* DeInit the low level hardware: RCC clock, NVIC */
1077-
hadc->MspDeInitCallback(hadc);
1073+
/* DeInit the low level hardware: RCC clock, NVIC */
1074+
hadc->MspDeInitCallback(hadc);
10781075
#else
1079-
/* DeInit the low level hardware: RCC clock, NVIC */
1080-
HAL_ADC_MspDeInit(hadc);
1076+
/* DeInit the low level hardware: RCC clock, NVIC */
1077+
HAL_ADC_MspDeInit(hadc);
10811078
#endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
10821079

1080+
}
1081+
10831082
/* Set ADC error code to none */
10841083
ADC_CLEAR_ERRORCODE(hadc);
10851084

@@ -1646,13 +1645,17 @@ HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef *hadc, uint32_t Ti
16461645
{
16471646
if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0UL))
16481647
{
1649-
/* Update ADC state machine to timeout */
1650-
SET_BIT(hadc->State, HAL_ADC_STATE_TIMEOUT);
1648+
/* New check to avoid false timeout detection in case of preemption */
1649+
if((hadc->Instance->ISR & tmp_Flag_End) == 0UL)
1650+
{
1651+
/* Update ADC state machine to timeout */
1652+
SET_BIT(hadc->State, HAL_ADC_STATE_TIMEOUT);
16511653

1652-
/* Process unlocked */
1653-
__HAL_UNLOCK(hadc);
1654+
/* Process unlocked */
1655+
__HAL_UNLOCK(hadc);
16541656

1655-
return HAL_TIMEOUT;
1657+
return HAL_TIMEOUT;
1658+
}
16561659
}
16571660
}
16581661
}
@@ -1757,13 +1760,17 @@ HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef *hadc, uint32_t EventTy
17571760
{
17581761
if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0UL))
17591762
{
1760-
/* Update ADC state machine to timeout */
1761-
SET_BIT(hadc->State, HAL_ADC_STATE_TIMEOUT);
1763+
/* New check to avoid false timeout detection in case of preemption */
1764+
if(__HAL_ADC_GET_FLAG(hadc, EventType) == 0UL)
1765+
{
1766+
/* Update ADC state machine to timeout */
1767+
SET_BIT(hadc->State, HAL_ADC_STATE_TIMEOUT);
17621768

1763-
/* Process unlocked */
1764-
__HAL_UNLOCK(hadc);
1769+
/* Process unlocked */
1770+
__HAL_UNLOCK(hadc);
17651771

1766-
return HAL_TIMEOUT;
1772+
return HAL_TIMEOUT;
1773+
}
17671774
}
17681775
}
17691776
}
@@ -2274,7 +2281,7 @@ HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef *hadc)
22742281
/* Disable ADC peripheral if conversions are effectively stopped */
22752282
if (tmp_hal_status == HAL_OK)
22762283
{
2277-
/* Disable ADC DMA (ADC DMA configuration of continous requests is kept) */
2284+
/* Disable ADC DMA (ADC DMA configuration of continuous requests is kept) */
22782285
MODIFY_REG(hadc->Instance->CFGR, ADC_CFGR_DMNGT_0 | ADC_CFGR_DMNGT_1, 0UL);
22792286

22802287
/* Disable the DMA channel (in case of DMA in circular mode or stop */
@@ -3056,7 +3063,7 @@ HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef *hadc, ADC_ChannelConf
30563063
/* Note: Variable divided by 2 to compensate partially */
30573064
/* CPU processing cycles, scaling in us split to not */
30583065
/* exceed 32 bits register capacity and handle low frequency. */
3059-
wait_loop_index = ((LL_ADC_DELAY_TEMPSENSOR_STAB_US / 10UL) * (SystemCoreClock / (100000UL * 2UL)));
3066+
wait_loop_index = ((LL_ADC_DELAY_TEMPSENSOR_STAB_US / 10UL) * ((SystemCoreClock / (100000UL * 2UL)) + 1UL));
30603067
while (wait_loop_index != 0UL)
30613068
{
30623069
wait_loop_index--;
@@ -3124,7 +3131,7 @@ HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef *hadc, ADC_ChannelConf
31243131
* The setting of these parameters is conditioned to ADC state.
31253132
* For parameters constraints, see comments of structure
31263133
* "ADC_AnalogWDGConfTypeDef".
3127-
* @note On this STM32 serie, analog watchdog thresholds cannot be modified
3134+
* @note On this STM32 series, analog watchdog thresholds cannot be modified
31283135
* while ADC conversion is on going.
31293136
* @param hadc ADC handle
31303137
* @param AnalogWDGConfig Structure of ADC analog watchdog configuration
@@ -3641,13 +3648,17 @@ HAL_StatusTypeDef ADC_ConversionStop(ADC_HandleTypeDef *hadc, uint32_t Conversio
36413648
{
36423649
if ((HAL_GetTick() - tickstart) > ADC_STOP_CONVERSION_TIMEOUT)
36433650
{
3644-
/* Update ADC state machine to error */
3645-
SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
3651+
/* New check to avoid false timeout detection in case of preemption */
3652+
if((hadc->Instance->CR & tmp_ADC_CR_ADSTART_JADSTART) != 0UL)
3653+
{
3654+
/* Update ADC state machine to error */
3655+
SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
36463656

3647-
/* Set ADC error code to ADC peripheral internal error */
3648-
SET_BIT(hadc->ErrorCode, HAL_ADC_ERROR_INTERNAL);
3657+
/* Set ADC error code to ADC peripheral internal error */
3658+
SET_BIT(hadc->ErrorCode, HAL_ADC_ERROR_INTERNAL);
36493659

3650-
return HAL_ERROR;
3660+
return HAL_ERROR;
3661+
}
36513662
}
36523663
}
36533664

@@ -3718,13 +3729,17 @@ HAL_StatusTypeDef ADC_Enable(ADC_HandleTypeDef *hadc)
37183729

37193730
if ((HAL_GetTick() - tickstart) > ADC_ENABLE_TIMEOUT)
37203731
{
3721-
/* Update ADC state machine to error */
3722-
SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
3732+
/* New check to avoid false timeout detection in case of preemption */
3733+
if (__HAL_ADC_GET_FLAG(hadc, ADC_FLAG_RDY) == 0UL)
3734+
{
3735+
/* Update ADC state machine to error */
3736+
SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
37233737

3724-
/* Set ADC error code to ADC peripheral internal error */
3725-
SET_BIT(hadc->ErrorCode, HAL_ADC_ERROR_INTERNAL);
3738+
/* Set ADC error code to ADC peripheral internal error */
3739+
SET_BIT(hadc->ErrorCode, HAL_ADC_ERROR_INTERNAL);
37263740

3727-
return HAL_ERROR;
3741+
return HAL_ERROR;
3742+
}
37283743
}
37293744
}
37303745
}
@@ -3779,13 +3794,17 @@ HAL_StatusTypeDef ADC_Disable(ADC_HandleTypeDef *hadc)
37793794
{
37803795
if ((HAL_GetTick() - tickstart) > ADC_DISABLE_TIMEOUT)
37813796
{
3782-
/* Update ADC state machine to error */
3783-
SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
3797+
/* New check to avoid false timeout detection in case of preemption */
3798+
if ((hadc->Instance->CR & ADC_CR_ADEN) != 0UL)
3799+
{
3800+
/* Update ADC state machine to error */
3801+
SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);
37843802

3785-
/* Set ADC error code to ADC peripheral internal error */
3786-
SET_BIT(hadc->ErrorCode, HAL_ADC_ERROR_INTERNAL);
3803+
/* Set ADC error code to ADC peripheral internal error */
3804+
SET_BIT(hadc->ErrorCode, HAL_ADC_ERROR_INTERNAL);
37873805

3788-
return HAL_ERROR;
3806+
return HAL_ERROR;
3807+
}
37893808
}
37903809
}
37913810
}

0 commit comments

Comments
 (0)