@@ -49,10 +49,12 @@ extern "C" {
4949typedef struct
5050{
5151
52+ #if defined(COMP2 )
5253 uint32_t WindowMode ; /*!< Set window mode of a pair of comparators instances
5354 (2 consecutive instances odd and even COMP<x> and COMP<x+1>).
5455 Note: HAL COMP driver allows to set window mode from any COMP instance of the pair of COMP instances composing window mode.
5556 This parameter can be a value of @ref COMP_WindowMode */
57+ #endif /* COMP2 */
5658
5759 uint32_t Mode ; /*!< Set comparator operating mode to adjust power and speed.
5860 Note: For the characteristics of comparator power modes
@@ -152,6 +154,7 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
152154 * @}
153155 */
154156
157+ #if defined(COMP2 )
155158/** @defgroup COMP_WindowMode COMP Window Mode
156159 * @{
157160 */
@@ -160,6 +163,7 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
160163/**
161164 * @}
162165 */
166+ #endif
163167
164168/** @defgroup COMP_PowerMode COMP power mode
165169 * @{
@@ -177,11 +181,9 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
177181/** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
178182 * @{
179183 */
180- #define COMP_INPUT_PLUS_IO1 (0x00000000UL) /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1, pin PB4 for COMP2) */
184+ #define COMP_INPUT_PLUS_IO1 (0x00000000UL) /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1 (except device STM32WB35xx) , pin PB4 for COMP2) */
181185#define COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2) */
182- #if defined(COMP_CSR_INPSEL_1 )
183186#define COMP_INPUT_PLUS_IO3 (COMP_CSR_INPSEL_1) /*!< Comparator input plus connected to IO3 (pin PA1 for COMP1, pin PA3 for COMP2) */
184- #endif
185187/**
186188 * @}
187189 */
@@ -194,7 +196,7 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
194196#define COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */
195197#define COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) /*!< Comparator input minus connected to VrefInt */
196198#define COMP_INPUT_MINUS_IO1 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PB1 for COMP1, pin PB3 for COMP2) */
197- #define COMP_INPUT_MINUS_IO2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO2 (pin PC4 for COMP1, pin PB7 for COMP2) */
199+ #define COMP_INPUT_MINUS_IO2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO2 (pin PC4 for COMP1 (except device STM32WB35xx) , pin PB7 for COMP2) */
198200#define COMP_INPUT_MINUS_IO3 ( COMP_CSR_INMESEL_0 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO3 (pin PA0 for COMP1, pin PA2 for COMP2) */
199201#define COMP_INPUT_MINUS_IO4 (COMP_CSR_INMESEL_1 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO4 (pin PA4 for COMP1, pin PA4 for COMP2) */
200202#define COMP_INPUT_MINUS_IO5 (COMP_CSR_INMESEL_1 | COMP_CSR_INMESEL_0 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO5 (pin PA5 for COMP1, pin PA5 for COMP2) */
@@ -422,6 +424,7 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
422424 */
423425#define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG () LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP1)
424426
427+ #if defined(COMP2 )
425428/**
426429 * @brief Enable the COMP2 EXTI line rising edge trigger.
427430 * @retval None
@@ -506,6 +509,7 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
506509 */
507510#define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG () LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP2)
508511
512+ #endif /* COMP2 */
509513/**
510514 * @}
511515 */
@@ -525,7 +529,9 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
525529 * @{
526530 */
527531#define COMP_EXTI_LINE_COMP1 (LL_EXTI_LINE_20) /*!< EXTI line 20 connected to COMP1 output */
532+ #if defined(COMP2 )
528533#define COMP_EXTI_LINE_COMP2 (LL_EXTI_LINE_21) /*!< EXTI line 21 connected to COMP2 output */
534+ #endif /* COMP2 */
529535/**
530536 * @}
531537 */
@@ -558,30 +564,42 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
558564 * @param __INSTANCE__ specifies the COMP instance.
559565 * @retval value of @ref COMP_ExtiLine
560566 */
567+ #if defined(COMP2 )
561568#define COMP_GET_EXTI_LINE (__INSTANCE__ ) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 \
562569 : COMP_EXTI_LINE_COMP2)
570+ #else
571+ #define COMP_GET_EXTI_LINE (__INSTANCE__ ) COMP_EXTI_LINE_COMP1
572+ #endif /* COMP2 */
563573/**
564574 * @}
565575 */
566576
567- /** @defgroup COMP_IS_COMP_Definitions COMP private macros to check input parameters
577+ /** @defgroup COMP_IS_COMP_Private_Definitions COMP private macros to check input parameters
568578 * @{
569579 */
580+ #if defined(COMP2 )
570581#define IS_COMP_WINDOWMODE (__WINDOWMODE__ ) (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE) || \
571582 ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON) )
583+ #endif
572584
573585#define IS_COMP_POWERMODE (__POWERMODE__ ) (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED) || \
574586 ((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED) || \
575587 ((__POWERMODE__) == COMP_POWERMODE_ULTRALOWPOWER) )
576588
589+ #if defined(COMP_INPUT_PLUS_IO1 )
577590#define IS_COMP_INPUT_PLUS (__COMP_INSTANCE__ , __INPUT_PLUS__ ) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
578591 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \
579592 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO3))
593+ #else
594+ #define IS_COMP_INPUT_PLUS (__COMP_INSTANCE__ , __INPUT_PLUS__ ) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \
595+ ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO3))
596+ #endif
580597
581598/* Note: On this STM32 serie, comparator input minus parameters are */
582599/* the same on all COMP instances. */
583600/* However, comparator instance kept as macro parameter for */
584601/* compatibility with other STM32 families. */
602+ #if defined(COMP_INPUT_MINUS_IO2 )
585603#define IS_COMP_INPUT_MINUS (__COMP_INSTANCE__ , __INPUT_MINUS__ ) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
586604 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
587605 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
@@ -591,6 +609,16 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
591609 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO3) || \
592610 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO4) || \
593611 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO5))
612+ #else
613+ #define IS_COMP_INPUT_MINUS (__COMP_INSTANCE__ , __INPUT_MINUS__ ) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
614+ ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
615+ ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
616+ ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
617+ ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
618+ ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO3) || \
619+ ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO4) || \
620+ ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO5))
621+ #endif
594622
595623#define IS_COMP_HYSTERESIS (__HYSTERESIS__ ) (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE) || \
596624 ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW) || \
0 commit comments