@@ -49,10 +49,12 @@ extern "C" {
49
49
typedef struct
50
50
{
51
51
52
+ #if defined(COMP2 )
52
53
uint32_t WindowMode ; /*!< Set window mode of a pair of comparators instances
53
54
(2 consecutive instances odd and even COMP<x> and COMP<x+1>).
54
55
Note: HAL COMP driver allows to set window mode from any COMP instance of the pair of COMP instances composing window mode.
55
56
This parameter can be a value of @ref COMP_WindowMode */
57
+ #endif /* COMP2 */
56
58
57
59
uint32_t Mode ; /*!< Set comparator operating mode to adjust power and speed.
58
60
Note: For the characteristics of comparator power modes
@@ -152,6 +154,7 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
152
154
* @}
153
155
*/
154
156
157
+ #if defined(COMP2 )
155
158
/** @defgroup COMP_WindowMode COMP Window Mode
156
159
* @{
157
160
*/
@@ -160,6 +163,7 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
160
163
/**
161
164
* @}
162
165
*/
166
+ #endif
163
167
164
168
/** @defgroup COMP_PowerMode COMP power mode
165
169
* @{
@@ -177,11 +181,9 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
177
181
/** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
178
182
* @{
179
183
*/
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) */
181
185
#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 )
183
186
#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
185
187
/**
186
188
* @}
187
189
*/
@@ -194,7 +196,7 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
194
196
#define COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */
195
197
#define COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) /*!< Comparator input minus connected to VrefInt */
196
198
#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) */
198
200
#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) */
199
201
#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) */
200
202
#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
422
424
*/
423
425
#define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG () LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP1)
424
426
427
+ #if defined(COMP2 )
425
428
/**
426
429
* @brief Enable the COMP2 EXTI line rising edge trigger.
427
430
* @retval None
@@ -506,6 +509,7 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
506
509
*/
507
510
#define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG () LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP2)
508
511
512
+ #endif /* COMP2 */
509
513
/**
510
514
* @}
511
515
*/
@@ -525,7 +529,9 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
525
529
* @{
526
530
*/
527
531
#define COMP_EXTI_LINE_COMP1 (LL_EXTI_LINE_20) /*!< EXTI line 20 connected to COMP1 output */
532
+ #if defined(COMP2 )
528
533
#define COMP_EXTI_LINE_COMP2 (LL_EXTI_LINE_21) /*!< EXTI line 21 connected to COMP2 output */
534
+ #endif /* COMP2 */
529
535
/**
530
536
* @}
531
537
*/
@@ -558,30 +564,42 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
558
564
* @param __INSTANCE__ specifies the COMP instance.
559
565
* @retval value of @ref COMP_ExtiLine
560
566
*/
567
+ #if defined(COMP2 )
561
568
#define COMP_GET_EXTI_LINE (__INSTANCE__ ) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 \
562
569
: COMP_EXTI_LINE_COMP2)
570
+ #else
571
+ #define COMP_GET_EXTI_LINE (__INSTANCE__ ) COMP_EXTI_LINE_COMP1
572
+ #endif /* COMP2 */
563
573
/**
564
574
* @}
565
575
*/
566
576
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
568
578
* @{
569
579
*/
580
+ #if defined(COMP2 )
570
581
#define IS_COMP_WINDOWMODE (__WINDOWMODE__ ) (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE) || \
571
582
((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON) )
583
+ #endif
572
584
573
585
#define IS_COMP_POWERMODE (__POWERMODE__ ) (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED) || \
574
586
((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED) || \
575
587
((__POWERMODE__) == COMP_POWERMODE_ULTRALOWPOWER) )
576
588
589
+ #if defined(COMP_INPUT_PLUS_IO1 )
577
590
#define IS_COMP_INPUT_PLUS (__COMP_INSTANCE__ , __INPUT_PLUS__ ) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
578
591
((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \
579
592
((__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
580
597
581
598
/* Note: On this STM32 serie, comparator input minus parameters are */
582
599
/* the same on all COMP instances. */
583
600
/* However, comparator instance kept as macro parameter for */
584
601
/* compatibility with other STM32 families. */
602
+ #if defined(COMP_INPUT_MINUS_IO2 )
585
603
#define IS_COMP_INPUT_MINUS (__COMP_INSTANCE__ , __INPUT_MINUS__ ) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
586
604
((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
587
605
((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
@@ -591,6 +609,16 @@ typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer
591
609
((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO3) || \
592
610
((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO4) || \
593
611
((__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
594
622
595
623
#define IS_COMP_HYSTERESIS (__HYSTERESIS__ ) (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE) || \
596
624
((__HYSTERESIS__) == COMP_HYSTERESIS_LOW) || \
0 commit comments