[HAL][ADC] Fix calibration factor asser_param
diff --git a/Inc/stm32h7xx_hal_adc_ex.h b/Inc/stm32h7xx_hal_adc_ex.h
index 524a6a3..aaf6d75 100644
--- a/Inc/stm32h7xx_hal_adc_ex.h
+++ b/Inc/stm32h7xx_hal_adc_ex.h
@@ -137,7 +137,7 @@
FunctionalState InjectedOffsetSignedSaturation; /*!< Specifies whether the Signed saturation feature is used or not.
This parameter is applied only for 16-bit or 8-bit resolution.
This parameter can be set to ENABLE or DISABLE. */
-
+
uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ranks that will be converted within the ADC group injected sequencer.
To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
This parameter must be a number between Min_Data = 1 and Max_Data = 4.
@@ -918,12 +918,20 @@
#define IS_ADC_INJECTED_NB_CONV(__LENGTH__) (((__LENGTH__) >= (1U)) && ((__LENGTH__) <= (4U)))
/**
- * @brief Calibration factor size verification (7 bits maximum).
+ * @brief Calibration factor size verification (11 bits maximum).
* @param __CALIBRATION_FACTOR__ Calibration factor value.
* @retval SET (__CALIBRATION_FACTOR__ is within the authorized size) or RESET (__CALIBRATION_FACTOR__ is too large)
*/
-#define IS_ADC_CALFACT(__CALIBRATION_FACTOR__) ((__CALIBRATION_FACTOR__) <= (0x7FU))
+#define IS_ADC_CALFACT(__CALIBRATION_FACTOR__) ((__CALIBRATION_FACTOR__) <= (0x7FFU))
+#if defined(ADC_VER_V5_V90)
+/**
+ * @brief Calibration factor size verification (7 bits maximum on ADC3).
+ * @param __CALIBRATION_FACTOR__ Calibration factor value.
+ * @retval SET (__CALIBRATION_FACTOR__ is within the authorized size) or RESET (__CALIBRATION_FACTOR__ is too large)
+ */
+#define IS_ADC_CALFACT_ADC3(__CALIBRATION_FACTOR__) ((__CALIBRATION_FACTOR__) <= (0x7FU))
+#endif
/**
* @brief Verify the ADC channel setting.
diff --git a/Src/stm32h7xx_hal_adc_ex.c b/Src/stm32h7xx_hal_adc_ex.c
index 6dd4901..4837c31 100644
--- a/Src/stm32h7xx_hal_adc_ex.c
+++ b/Src/stm32h7xx_hal_adc_ex.c
@@ -255,7 +255,9 @@
* @param SingleDiff This parameter can be only:
* @arg @ref ADC_SINGLE_ENDED Channel in mode input single ended
* @arg @ref ADC_DIFFERENTIAL_ENDED Channel in mode input differential ended
- * @param CalibrationFactor Calibration factor (coded on 7 bits maximum)
+ * @param CalibrationFactor Calibration factor On devices STM32H72xx and STM32H73xx this parameter is coded on 11 bits
+ * maximum for ADC1/2 and on 7 bits for ADC3.
+ * On devices STM32H74xx and STM32H75xx this parameter is coded on 11 bits.
* @retval HAL state
*/
HAL_StatusTypeDef HAL_ADCEx_Calibration_SetValue(ADC_HandleTypeDef *hadc, uint32_t SingleDiff, uint32_t CalibrationFactor)
@@ -267,7 +269,19 @@
/* Check the parameters */
assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
assert_param(IS_ADC_SINGLE_DIFFERENTIAL(SingleDiff));
+
+#if defined(ADC_VER_V5_V90)
+ if (hadc->Instance == ADC3)
+ {
+ assert_param(IS_ADC_CALFACT_ADC3(CalibrationFactor));
+ }
+ else
+ {
+ assert_param(IS_ADC_CALFACT(CalibrationFactor));
+ }
+#else
assert_param(IS_ADC_CALFACT(CalibrationFactor));
+#endif
/* Process locked */
__HAL_LOCK(hadc);