TUKS MCU Introductory course / TUKS-COURSE-TIMER
Committer:
elmot
Date:
Fri Feb 24 21:13:56 2017 +0000
Revision:
1:d0dfbce63a89
Ready-to-copy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elmot 1:d0dfbce63a89 1 /**
elmot 1:d0dfbce63a89 2 ******************************************************************************
elmot 1:d0dfbce63a89 3 * @file stm32l4xx_hal_comp.h
elmot 1:d0dfbce63a89 4 * @author MCD Application Team
elmot 1:d0dfbce63a89 5 * @version V1.5.1
elmot 1:d0dfbce63a89 6 * @date 31-May-2016
elmot 1:d0dfbce63a89 7 * @brief Header file of COMP HAL module.
elmot 1:d0dfbce63a89 8 ******************************************************************************
elmot 1:d0dfbce63a89 9 * @attention
elmot 1:d0dfbce63a89 10 *
elmot 1:d0dfbce63a89 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
elmot 1:d0dfbce63a89 12 *
elmot 1:d0dfbce63a89 13 * Redistribution and use in source and binary forms, with or without modification,
elmot 1:d0dfbce63a89 14 * are permitted provided that the following conditions are met:
elmot 1:d0dfbce63a89 15 * 1. Redistributions of source code must retain the above copyright notice,
elmot 1:d0dfbce63a89 16 * this list of conditions and the following disclaimer.
elmot 1:d0dfbce63a89 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
elmot 1:d0dfbce63a89 18 * this list of conditions and the following disclaimer in the documentation
elmot 1:d0dfbce63a89 19 * and/or other materials provided with the distribution.
elmot 1:d0dfbce63a89 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
elmot 1:d0dfbce63a89 21 * may be used to endorse or promote products derived from this software
elmot 1:d0dfbce63a89 22 * without specific prior written permission.
elmot 1:d0dfbce63a89 23 *
elmot 1:d0dfbce63a89 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
elmot 1:d0dfbce63a89 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
elmot 1:d0dfbce63a89 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
elmot 1:d0dfbce63a89 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
elmot 1:d0dfbce63a89 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
elmot 1:d0dfbce63a89 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
elmot 1:d0dfbce63a89 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
elmot 1:d0dfbce63a89 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
elmot 1:d0dfbce63a89 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
elmot 1:d0dfbce63a89 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
elmot 1:d0dfbce63a89 34 *
elmot 1:d0dfbce63a89 35 ******************************************************************************
elmot 1:d0dfbce63a89 36 */
elmot 1:d0dfbce63a89 37
elmot 1:d0dfbce63a89 38 /* Define to prevent recursive inclusion -------------------------------------*/
elmot 1:d0dfbce63a89 39 #ifndef __STM32L4xx_HAL_COMP_H
elmot 1:d0dfbce63a89 40 #define __STM32L4xx_HAL_COMP_H
elmot 1:d0dfbce63a89 41
elmot 1:d0dfbce63a89 42 #ifdef __cplusplus
elmot 1:d0dfbce63a89 43 extern "C" {
elmot 1:d0dfbce63a89 44 #endif
elmot 1:d0dfbce63a89 45
elmot 1:d0dfbce63a89 46 /* Includes ------------------------------------------------------------------*/
elmot 1:d0dfbce63a89 47 #include "stm32l4xx_hal_def.h"
elmot 1:d0dfbce63a89 48
elmot 1:d0dfbce63a89 49 /** @addtogroup STM32L4xx_HAL_Driver
elmot 1:d0dfbce63a89 50 * @{
elmot 1:d0dfbce63a89 51 */
elmot 1:d0dfbce63a89 52
elmot 1:d0dfbce63a89 53 /** @addtogroup COMP
elmot 1:d0dfbce63a89 54 * @{
elmot 1:d0dfbce63a89 55 */
elmot 1:d0dfbce63a89 56
elmot 1:d0dfbce63a89 57 /* Exported types ------------------------------------------------------------*/
elmot 1:d0dfbce63a89 58 /** @defgroup COMP_Exported_Types COMP Exported Types
elmot 1:d0dfbce63a89 59 * @{
elmot 1:d0dfbce63a89 60 */
elmot 1:d0dfbce63a89 61
elmot 1:d0dfbce63a89 62 /**
elmot 1:d0dfbce63a89 63 * @brief COMP Init structure definition
elmot 1:d0dfbce63a89 64 */
elmot 1:d0dfbce63a89 65 typedef struct
elmot 1:d0dfbce63a89 66 {
elmot 1:d0dfbce63a89 67
elmot 1:d0dfbce63a89 68 uint32_t WindowMode; /*!< Set window mode of a pair of comparators instances
elmot 1:d0dfbce63a89 69 (2 consecutive instances odd and even COMP<x> and COMP<x+1>).
elmot 1:d0dfbce63a89 70 Note: HAL COMP driver allows to set window mode from any COMP instance of the pair of COMP instances composing window mode.
elmot 1:d0dfbce63a89 71 This parameter can be a value of @ref COMP_WindowMode */
elmot 1:d0dfbce63a89 72
elmot 1:d0dfbce63a89 73 uint32_t Mode; /*!< Set comparator operating mode to adjust power and speed.
elmot 1:d0dfbce63a89 74 Note: For the characteritics of comparator power modes
elmot 1:d0dfbce63a89 75 (propagation delay and power consumption), refer to device datasheet.
elmot 1:d0dfbce63a89 76 This parameter can be a value of @ref COMP_PowerMode */
elmot 1:d0dfbce63a89 77
elmot 1:d0dfbce63a89 78 uint32_t NonInvertingInput; /*!< Set comparator input plus (non-inverting input).
elmot 1:d0dfbce63a89 79 This parameter can be a value of @ref COMP_InputPlus */
elmot 1:d0dfbce63a89 80
elmot 1:d0dfbce63a89 81 uint32_t InvertingInput; /*!< Set comparator input minus (inverting input).
elmot 1:d0dfbce63a89 82 This parameter can be a value of @ref COMP_InputMinus */
elmot 1:d0dfbce63a89 83
elmot 1:d0dfbce63a89 84 uint32_t Hysteresis; /*!< Set comparator hysteresis mode of the input minus.
elmot 1:d0dfbce63a89 85 This parameter can be a value of @ref COMP_Hysteresis */
elmot 1:d0dfbce63a89 86
elmot 1:d0dfbce63a89 87 uint32_t OutputPol; /*!< Set comparator output polarity.
elmot 1:d0dfbce63a89 88 This parameter can be a value of @ref COMP_OutputPolarity */
elmot 1:d0dfbce63a89 89
elmot 1:d0dfbce63a89 90 uint32_t BlankingSrce; /*!< Set comparator blanking source.
elmot 1:d0dfbce63a89 91 This parameter can be a value of @ref COMP_BlankingSrce */
elmot 1:d0dfbce63a89 92
elmot 1:d0dfbce63a89 93 uint32_t TriggerMode; /*!< Set the comparator output triggering External Interrupt Line (EXTI).
elmot 1:d0dfbce63a89 94 This parameter can be a value of @ref COMP_EXTI_TriggerMode */
elmot 1:d0dfbce63a89 95
elmot 1:d0dfbce63a89 96 }COMP_InitTypeDef;
elmot 1:d0dfbce63a89 97
elmot 1:d0dfbce63a89 98 /**
elmot 1:d0dfbce63a89 99 * @brief HAL COMP state machine: HAL COMP states definition
elmot 1:d0dfbce63a89 100 */
elmot 1:d0dfbce63a89 101 #define COMP_STATE_BITFIELD_LOCK ((uint32_t)0x10)
elmot 1:d0dfbce63a89 102 typedef enum
elmot 1:d0dfbce63a89 103 {
elmot 1:d0dfbce63a89 104 HAL_COMP_STATE_RESET = 0x00, /*!< COMP not yet initialized */
elmot 1:d0dfbce63a89 105 HAL_COMP_STATE_RESET_LOCKED = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */
elmot 1:d0dfbce63a89 106 HAL_COMP_STATE_READY = 0x01, /*!< COMP initialized and ready for use */
elmot 1:d0dfbce63a89 107 HAL_COMP_STATE_READY_LOCKED = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked */
elmot 1:d0dfbce63a89 108 HAL_COMP_STATE_BUSY = 0x02, /*!< COMP is running */
elmot 1:d0dfbce63a89 109 HAL_COMP_STATE_BUSY_LOCKED = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK) /*!< COMP is running and configuration is locked */
elmot 1:d0dfbce63a89 110 }HAL_COMP_StateTypeDef;
elmot 1:d0dfbce63a89 111
elmot 1:d0dfbce63a89 112 /**
elmot 1:d0dfbce63a89 113 * @brief COMP Handle Structure definition
elmot 1:d0dfbce63a89 114 */
elmot 1:d0dfbce63a89 115 typedef struct
elmot 1:d0dfbce63a89 116 {
elmot 1:d0dfbce63a89 117 COMP_TypeDef *Instance; /*!< Register base address */
elmot 1:d0dfbce63a89 118 COMP_InitTypeDef Init; /*!< COMP required parameters */
elmot 1:d0dfbce63a89 119 HAL_LockTypeDef Lock; /*!< Locking object */
elmot 1:d0dfbce63a89 120 __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
elmot 1:d0dfbce63a89 121 } COMP_HandleTypeDef;
elmot 1:d0dfbce63a89 122
elmot 1:d0dfbce63a89 123 /**
elmot 1:d0dfbce63a89 124 * @}
elmot 1:d0dfbce63a89 125 */
elmot 1:d0dfbce63a89 126
elmot 1:d0dfbce63a89 127 /* Exported constants --------------------------------------------------------*/
elmot 1:d0dfbce63a89 128 /** @defgroup COMP_Exported_Constants COMP Exported Constants
elmot 1:d0dfbce63a89 129 * @{
elmot 1:d0dfbce63a89 130 */
elmot 1:d0dfbce63a89 131
elmot 1:d0dfbce63a89 132 /** @defgroup COMP_WindowMode COMP Window Mode
elmot 1:d0dfbce63a89 133 * @{
elmot 1:d0dfbce63a89 134 */
elmot 1:d0dfbce63a89 135 #define COMP_WINDOWMODE_DISABLE ((uint32_t)0x00000000) /*!< Window mode disable: Comparators instances pair COMP1 and COMP2 are independent */
elmot 1:d0dfbce63a89 136 #define COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_WINMODE) /*!< Window mode enable: Comparators instances pair COMP1 and COMP2 have their input plus connected together. The common input is COMP1 input plus (COMP2 input plus is no more accessible). */
elmot 1:d0dfbce63a89 137
elmot 1:d0dfbce63a89 138 /**
elmot 1:d0dfbce63a89 139 * @}
elmot 1:d0dfbce63a89 140 */
elmot 1:d0dfbce63a89 141
elmot 1:d0dfbce63a89 142 /** @defgroup COMP_PowerMode COMP power mode
elmot 1:d0dfbce63a89 143 * @{
elmot 1:d0dfbce63a89 144 */
elmot 1:d0dfbce63a89 145 /* Note: For the characteritics of comparator power modes */
elmot 1:d0dfbce63a89 146 /* (propagation delay and power consumption), */
elmot 1:d0dfbce63a89 147 /* refer to device datasheet. */
elmot 1:d0dfbce63a89 148 #define COMP_POWERMODE_HIGHSPEED ((uint32_t)0x00000000) /*!< High Speed */
elmot 1:d0dfbce63a89 149 #define COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_PWRMODE_0) /*!< Medium Speed */
elmot 1:d0dfbce63a89 150 #define COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_PWRMODE) /*!< Ultra-low power mode */
elmot 1:d0dfbce63a89 151 /**
elmot 1:d0dfbce63a89 152 * @}
elmot 1:d0dfbce63a89 153 */
elmot 1:d0dfbce63a89 154
elmot 1:d0dfbce63a89 155 /** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
elmot 1:d0dfbce63a89 156 * @{
elmot 1:d0dfbce63a89 157 */
elmot 1:d0dfbce63a89 158 #define COMP_INPUT_PLUS_IO1 ((uint32_t)0x00000000) /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1, pin PB4 for COMP2) */
elmot 1:d0dfbce63a89 159 #define COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2) */
elmot 1:d0dfbce63a89 160 #if defined(COMP_CSR_INPSEL_1)
elmot 1:d0dfbce63a89 161 #define COMP_INPUT_PLUS_IO3 (COMP_CSR_INPSEL_1) /*!< Comparator input plus connected to IO3 (pin PA1 for COMP1, pin PA3 for COMP2) */
elmot 1:d0dfbce63a89 162 #endif
elmot 1:d0dfbce63a89 163 /**
elmot 1:d0dfbce63a89 164 * @}
elmot 1:d0dfbce63a89 165 */
elmot 1:d0dfbce63a89 166
elmot 1:d0dfbce63a89 167 /** @defgroup COMP_InputMinus COMP input minus (inverting input)
elmot 1:d0dfbce63a89 168 * @{
elmot 1:d0dfbce63a89 169 */
elmot 1:d0dfbce63a89 170 #define COMP_INPUT_MINUS_1_4VREFINT ( COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/4 VrefInt */
elmot 1:d0dfbce63a89 171 #define COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/2 VrefInt */
elmot 1:d0dfbce63a89 172 #define COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */
elmot 1:d0dfbce63a89 173 #define COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) /*!< Comparator input minus connected to VrefInt */
elmot 1:d0dfbce63a89 174 #define COMP_INPUT_MINUS_DAC1_CH1 (COMP_CSR_INMSEL_2 ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */
elmot 1:d0dfbce63a89 175 #define COMP_INPUT_MINUS_DAC1_CH2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */
elmot 1:d0dfbce63a89 176 #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) */
elmot 1:d0dfbce63a89 177 #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) */
elmot 1:d0dfbce63a89 178 #if defined(COMP_CSR_INMESEL_1)
elmot 1:d0dfbce63a89 179 #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) */
elmot 1:d0dfbce63a89 180 #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) */
elmot 1:d0dfbce63a89 181 #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) */
elmot 1:d0dfbce63a89 182 #endif
elmot 1:d0dfbce63a89 183 /**
elmot 1:d0dfbce63a89 184 * @}
elmot 1:d0dfbce63a89 185 */
elmot 1:d0dfbce63a89 186
elmot 1:d0dfbce63a89 187 /** @defgroup COMP_Hysteresis COMP hysteresis
elmot 1:d0dfbce63a89 188 * @{
elmot 1:d0dfbce63a89 189 */
elmot 1:d0dfbce63a89 190 #define COMP_HYSTERESIS_NONE ((uint32_t)0x00000000) /*!< No hysteresis */
elmot 1:d0dfbce63a89 191 #define COMP_HYSTERESIS_LOW (COMP_CSR_HYST_0) /*!< Hysteresis level low */
elmot 1:d0dfbce63a89 192 #define COMP_HYSTERESIS_MEDIUM (COMP_CSR_HYST_1) /*!< Hysteresis level medium */
elmot 1:d0dfbce63a89 193 #define COMP_HYSTERESIS_HIGH (COMP_CSR_HYST) /*!< Hysteresis level high */
elmot 1:d0dfbce63a89 194 /**
elmot 1:d0dfbce63a89 195 * @}
elmot 1:d0dfbce63a89 196 */
elmot 1:d0dfbce63a89 197
elmot 1:d0dfbce63a89 198 /** @defgroup COMP_OutputPolarity COMP output Polarity
elmot 1:d0dfbce63a89 199 * @{
elmot 1:d0dfbce63a89 200 */
elmot 1:d0dfbce63a89 201 #define COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output level is not inverted (comparator output is high when the input plus is at a higher voltage than the input minus) */
elmot 1:d0dfbce63a89 202 #define COMP_OUTPUTPOL_INVERTED (COMP_CSR_POLARITY) /*!< COMP output level is inverted (comparator output is low when the input plus is at a higher voltage than the input minus) */
elmot 1:d0dfbce63a89 203 /**
elmot 1:d0dfbce63a89 204 * @}
elmot 1:d0dfbce63a89 205 */
elmot 1:d0dfbce63a89 206
elmot 1:d0dfbce63a89 207 /** @defgroup COMP_BlankingSrce COMP blanking source
elmot 1:d0dfbce63a89 208 * @{
elmot 1:d0dfbce63a89 209 */
elmot 1:d0dfbce63a89 210 #define COMP_BLANKINGSRC_NONE ((uint32_t)0x00000000) /*!< No blanking source */
elmot 1:d0dfbce63a89 211 /* Blanking sources for COMP instance: COMP1 */
elmot 1:d0dfbce63a89 212 #define COMP_BLANKINGSRC_TIM1_OC5_COMP1 (COMP_CSR_BLANKING_0) /*!< Blanking source for COMP1: TIM1 OC5 selected as blanking source for comparator */
elmot 1:d0dfbce63a89 213 #define COMP_BLANKINGSRC_TIM2_OC3_COMP1 (COMP_CSR_BLANKING_1) /*!< Blanking source for COMP1: TIM2 OC3 selected as blanking source for comparator */
elmot 1:d0dfbce63a89 214 #define COMP_BLANKINGSRC_TIM3_OC3_COMP1 (COMP_CSR_BLANKING_2) /*!< Blanking source for COMP1: TIM3 OC3 selected as blanking source for comparator */
elmot 1:d0dfbce63a89 215 /* Blanking sources for COMP instance: COMP2 */
elmot 1:d0dfbce63a89 216 #define COMP_BLANKINGSRC_TIM3_OC4_COMP2 (COMP_CSR_BLANKING_0) /*!< Blanking source for COMP2: TIM3 OC4 selected as blanking source for comparator */
elmot 1:d0dfbce63a89 217 #define COMP_BLANKINGSRC_TIM8_OC5_COMP2 (COMP_CSR_BLANKING_1) /*!< Blanking source for COMP2: TIM8 OC5 selected as blanking source for comparator */
elmot 1:d0dfbce63a89 218 #define COMP_BLANKINGSRC_TIM15_OC1_COMP2 (COMP_CSR_BLANKING_2) /*!< Blanking source for COMP2: TIM15 OC1 selected as blanking source for comparator */
elmot 1:d0dfbce63a89 219 /**
elmot 1:d0dfbce63a89 220 * @}
elmot 1:d0dfbce63a89 221 */
elmot 1:d0dfbce63a89 222
elmot 1:d0dfbce63a89 223 /** @defgroup COMP_OutputLevel COMP Output Level
elmot 1:d0dfbce63a89 224 * @{
elmot 1:d0dfbce63a89 225 */
elmot 1:d0dfbce63a89 226 /* Note: Comparator output level values are fixed to "0" and "1", */
elmot 1:d0dfbce63a89 227 /* corresponding COMP register bit is managed by HAL function to match */
elmot 1:d0dfbce63a89 228 /* with these values (independently of bit position in register). */
elmot 1:d0dfbce63a89 229
elmot 1:d0dfbce63a89 230 /* When output polarity is not inverted, comparator output is low when
elmot 1:d0dfbce63a89 231 the input plus is at a lower voltage than the input minus */
elmot 1:d0dfbce63a89 232 #define COMP_OUTPUT_LEVEL_LOW ((uint32_t)0x00000000)
elmot 1:d0dfbce63a89 233 /* When output polarity is not inverted, comparator output is high when
elmot 1:d0dfbce63a89 234 the input plus is at a higher voltage than the input minus */
elmot 1:d0dfbce63a89 235 #define COMP_OUTPUT_LEVEL_HIGH ((uint32_t)0x00000001)
elmot 1:d0dfbce63a89 236 /**
elmot 1:d0dfbce63a89 237 * @}
elmot 1:d0dfbce63a89 238 */
elmot 1:d0dfbce63a89 239
elmot 1:d0dfbce63a89 240 /** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI
elmot 1:d0dfbce63a89 241 * @{
elmot 1:d0dfbce63a89 242 */
elmot 1:d0dfbce63a89 243 #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< Comparator output triggering no External Interrupt Line */
elmot 1:d0dfbce63a89 244 #define COMP_TRIGGERMODE_IT_RISING (COMP_EXTI_IT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */
elmot 1:d0dfbce63a89 245 #define COMP_TRIGGERMODE_IT_FALLING (COMP_EXTI_IT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */
elmot 1:d0dfbce63a89 246 #define COMP_TRIGGERMODE_IT_RISING_FALLING (COMP_EXTI_IT | COMP_EXTI_RISING | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on both rising and falling edges */
elmot 1:d0dfbce63a89 247 #define COMP_TRIGGERMODE_EVENT_RISING (COMP_EXTI_EVENT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */
elmot 1:d0dfbce63a89 248 #define COMP_TRIGGERMODE_EVENT_FALLING (COMP_EXTI_EVENT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */
elmot 1:d0dfbce63a89 249 #define COMP_TRIGGERMODE_EVENT_RISING_FALLING (COMP_EXTI_EVENT | COMP_EXTI_RISING | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on both rising and falling edges */
elmot 1:d0dfbce63a89 250 /**
elmot 1:d0dfbce63a89 251 * @}
elmot 1:d0dfbce63a89 252 */
elmot 1:d0dfbce63a89 253
elmot 1:d0dfbce63a89 254 /**
elmot 1:d0dfbce63a89 255 * @}
elmot 1:d0dfbce63a89 256 */
elmot 1:d0dfbce63a89 257
elmot 1:d0dfbce63a89 258 /* Exported macro ------------------------------------------------------------*/
elmot 1:d0dfbce63a89 259 /** @defgroup COMP_Exported_Macros COMP Exported Macros
elmot 1:d0dfbce63a89 260 * @{
elmot 1:d0dfbce63a89 261 */
elmot 1:d0dfbce63a89 262
elmot 1:d0dfbce63a89 263 /** @defgroup COMP_Handle_Management COMP Handle Management
elmot 1:d0dfbce63a89 264 * @{
elmot 1:d0dfbce63a89 265 */
elmot 1:d0dfbce63a89 266
elmot 1:d0dfbce63a89 267 /** @brief Reset COMP handle state.
elmot 1:d0dfbce63a89 268 * @param __HANDLE__ COMP handle
elmot 1:d0dfbce63a89 269 * @retval None
elmot 1:d0dfbce63a89 270 */
elmot 1:d0dfbce63a89 271 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
elmot 1:d0dfbce63a89 272
elmot 1:d0dfbce63a89 273 /**
elmot 1:d0dfbce63a89 274 * @brief Enable the specified comparator.
elmot 1:d0dfbce63a89 275 * @param __HANDLE__ COMP handle
elmot 1:d0dfbce63a89 276 * @retval None
elmot 1:d0dfbce63a89 277 */
elmot 1:d0dfbce63a89 278 #define __HAL_COMP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
elmot 1:d0dfbce63a89 279
elmot 1:d0dfbce63a89 280 /**
elmot 1:d0dfbce63a89 281 * @brief Disable the specified comparator.
elmot 1:d0dfbce63a89 282 * @param __HANDLE__ COMP handle
elmot 1:d0dfbce63a89 283 * @retval None
elmot 1:d0dfbce63a89 284 */
elmot 1:d0dfbce63a89 285 #define __HAL_COMP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
elmot 1:d0dfbce63a89 286
elmot 1:d0dfbce63a89 287 /**
elmot 1:d0dfbce63a89 288 * @brief Lock the specified comparator configuration.
elmot 1:d0dfbce63a89 289 * @note Using this macro induce HAL COMP handle state machine being no
elmot 1:d0dfbce63a89 290 * more in line with COMP instance state.
elmot 1:d0dfbce63a89 291 * To keep HAL COMP handle state machine updated, it is recommended
elmot 1:d0dfbce63a89 292 * to use function "HAL_COMP_Lock')".
elmot 1:d0dfbce63a89 293 * @param __HANDLE__ COMP handle
elmot 1:d0dfbce63a89 294 * @retval None
elmot 1:d0dfbce63a89 295 */
elmot 1:d0dfbce63a89 296 #define __HAL_COMP_LOCK(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK)
elmot 1:d0dfbce63a89 297
elmot 1:d0dfbce63a89 298 /**
elmot 1:d0dfbce63a89 299 * @brief Check whether the specified comparator is locked.
elmot 1:d0dfbce63a89 300 * @param __HANDLE__ COMP handle
elmot 1:d0dfbce63a89 301 * @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked
elmot 1:d0dfbce63a89 302 */
elmot 1:d0dfbce63a89 303 #define __HAL_COMP_IS_LOCKED(__HANDLE__) (READ_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK) == COMP_CSR_LOCK)
elmot 1:d0dfbce63a89 304
elmot 1:d0dfbce63a89 305 /**
elmot 1:d0dfbce63a89 306 * @}
elmot 1:d0dfbce63a89 307 */
elmot 1:d0dfbce63a89 308
elmot 1:d0dfbce63a89 309 /** @defgroup COMP_Exti_Management COMP external interrupt line management
elmot 1:d0dfbce63a89 310 * @{
elmot 1:d0dfbce63a89 311 */
elmot 1:d0dfbce63a89 312
elmot 1:d0dfbce63a89 313 /**
elmot 1:d0dfbce63a89 314 * @brief Enable the COMP1 EXTI line rising edge trigger.
elmot 1:d0dfbce63a89 315 * @retval None
elmot 1:d0dfbce63a89 316 */
elmot 1:d0dfbce63a89 317 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1)
elmot 1:d0dfbce63a89 318
elmot 1:d0dfbce63a89 319 /**
elmot 1:d0dfbce63a89 320 * @brief Disable the COMP1 EXTI line rising edge trigger.
elmot 1:d0dfbce63a89 321 * @retval None
elmot 1:d0dfbce63a89 322 */
elmot 1:d0dfbce63a89 323 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1)
elmot 1:d0dfbce63a89 324
elmot 1:d0dfbce63a89 325 /**
elmot 1:d0dfbce63a89 326 * @brief Enable the COMP1 EXTI line falling edge trigger.
elmot 1:d0dfbce63a89 327 * @retval None
elmot 1:d0dfbce63a89 328 */
elmot 1:d0dfbce63a89 329 #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1)
elmot 1:d0dfbce63a89 330
elmot 1:d0dfbce63a89 331 /**
elmot 1:d0dfbce63a89 332 * @brief Disable the COMP1 EXTI line falling edge trigger.
elmot 1:d0dfbce63a89 333 * @retval None
elmot 1:d0dfbce63a89 334 */
elmot 1:d0dfbce63a89 335 #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1)
elmot 1:d0dfbce63a89 336
elmot 1:d0dfbce63a89 337 /**
elmot 1:d0dfbce63a89 338 * @brief Enable the COMP1 EXTI line rising & falling edge trigger.
elmot 1:d0dfbce63a89 339 * @retval None
elmot 1:d0dfbce63a89 340 */
elmot 1:d0dfbce63a89 341 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
elmot 1:d0dfbce63a89 342 __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE(); \
elmot 1:d0dfbce63a89 343 __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE(); \
elmot 1:d0dfbce63a89 344 } while(0)
elmot 1:d0dfbce63a89 345
elmot 1:d0dfbce63a89 346 /**
elmot 1:d0dfbce63a89 347 * @brief Disable the COMP1 EXTI line rising & falling edge trigger.
elmot 1:d0dfbce63a89 348 * @retval None
elmot 1:d0dfbce63a89 349 */
elmot 1:d0dfbce63a89 350 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
elmot 1:d0dfbce63a89 351 __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE(); \
elmot 1:d0dfbce63a89 352 __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE(); \
elmot 1:d0dfbce63a89 353 } while(0)
elmot 1:d0dfbce63a89 354
elmot 1:d0dfbce63a89 355 /**
elmot 1:d0dfbce63a89 356 * @brief Enable the COMP1 EXTI line in interrupt mode.
elmot 1:d0dfbce63a89 357 * @retval None
elmot 1:d0dfbce63a89 358 */
elmot 1:d0dfbce63a89 359 #define __HAL_COMP_COMP1_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR1, COMP_EXTI_LINE_COMP1)
elmot 1:d0dfbce63a89 360
elmot 1:d0dfbce63a89 361 /**
elmot 1:d0dfbce63a89 362 * @brief Disable the COMP1 EXTI line in interrupt mode.
elmot 1:d0dfbce63a89 363 * @retval None
elmot 1:d0dfbce63a89 364 */
elmot 1:d0dfbce63a89 365 #define __HAL_COMP_COMP1_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR1, COMP_EXTI_LINE_COMP1)
elmot 1:d0dfbce63a89 366
elmot 1:d0dfbce63a89 367 /**
elmot 1:d0dfbce63a89 368 * @brief Generate a software interrupt on the COMP1 EXTI line.
elmot 1:d0dfbce63a89 369 * @retval None
elmot 1:d0dfbce63a89 370 */
elmot 1:d0dfbce63a89 371 #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP1)
elmot 1:d0dfbce63a89 372
elmot 1:d0dfbce63a89 373 /**
elmot 1:d0dfbce63a89 374 * @brief Enable the COMP1 EXTI line in event mode.
elmot 1:d0dfbce63a89 375 * @retval None
elmot 1:d0dfbce63a89 376 */
elmot 1:d0dfbce63a89 377 #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR1, COMP_EXTI_LINE_COMP1)
elmot 1:d0dfbce63a89 378
elmot 1:d0dfbce63a89 379 /**
elmot 1:d0dfbce63a89 380 * @brief Disable the COMP1 EXTI line in event mode.
elmot 1:d0dfbce63a89 381 * @retval None
elmot 1:d0dfbce63a89 382 */
elmot 1:d0dfbce63a89 383 #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR1, COMP_EXTI_LINE_COMP1)
elmot 1:d0dfbce63a89 384
elmot 1:d0dfbce63a89 385 /**
elmot 1:d0dfbce63a89 386 * @brief Check whether the COMP1 EXTI line flag is set.
elmot 1:d0dfbce63a89 387 * @retval RESET or SET
elmot 1:d0dfbce63a89 388 */
elmot 1:d0dfbce63a89 389 #define __HAL_COMP_COMP1_EXTI_GET_FLAG() READ_BIT(EXTI->PR1, COMP_EXTI_LINE_COMP1)
elmot 1:d0dfbce63a89 390
elmot 1:d0dfbce63a89 391 /**
elmot 1:d0dfbce63a89 392 * @brief Clear the COMP1 EXTI flag.
elmot 1:d0dfbce63a89 393 * @retval None
elmot 1:d0dfbce63a89 394 */
elmot 1:d0dfbce63a89 395 #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR1, COMP_EXTI_LINE_COMP1)
elmot 1:d0dfbce63a89 396
elmot 1:d0dfbce63a89 397 /**
elmot 1:d0dfbce63a89 398 * @brief Enable the COMP2 EXTI line rising edge trigger.
elmot 1:d0dfbce63a89 399 * @retval None
elmot 1:d0dfbce63a89 400 */
elmot 1:d0dfbce63a89 401 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2)
elmot 1:d0dfbce63a89 402
elmot 1:d0dfbce63a89 403 /**
elmot 1:d0dfbce63a89 404 * @brief Disable the COMP2 EXTI line rising edge trigger.
elmot 1:d0dfbce63a89 405 * @retval None
elmot 1:d0dfbce63a89 406 */
elmot 1:d0dfbce63a89 407 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2)
elmot 1:d0dfbce63a89 408
elmot 1:d0dfbce63a89 409 /**
elmot 1:d0dfbce63a89 410 * @brief Enable the COMP2 EXTI line falling edge trigger.
elmot 1:d0dfbce63a89 411 * @retval None
elmot 1:d0dfbce63a89 412 */
elmot 1:d0dfbce63a89 413 #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2)
elmot 1:d0dfbce63a89 414
elmot 1:d0dfbce63a89 415 /**
elmot 1:d0dfbce63a89 416 * @brief Disable the COMP2 EXTI line falling edge trigger.
elmot 1:d0dfbce63a89 417 * @retval None
elmot 1:d0dfbce63a89 418 */
elmot 1:d0dfbce63a89 419 #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2)
elmot 1:d0dfbce63a89 420
elmot 1:d0dfbce63a89 421 /**
elmot 1:d0dfbce63a89 422 * @brief Enable the COMP2 EXTI line rising & falling edge trigger.
elmot 1:d0dfbce63a89 423 * @retval None
elmot 1:d0dfbce63a89 424 */
elmot 1:d0dfbce63a89 425 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
elmot 1:d0dfbce63a89 426 __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE(); \
elmot 1:d0dfbce63a89 427 __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE(); \
elmot 1:d0dfbce63a89 428 } while(0)
elmot 1:d0dfbce63a89 429
elmot 1:d0dfbce63a89 430 /**
elmot 1:d0dfbce63a89 431 * @brief Disable the COMP2 EXTI line rising & falling edge trigger.
elmot 1:d0dfbce63a89 432 * @retval None
elmot 1:d0dfbce63a89 433 */
elmot 1:d0dfbce63a89 434 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
elmot 1:d0dfbce63a89 435 __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE(); \
elmot 1:d0dfbce63a89 436 __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE(); \
elmot 1:d0dfbce63a89 437 } while(0)
elmot 1:d0dfbce63a89 438
elmot 1:d0dfbce63a89 439 /**
elmot 1:d0dfbce63a89 440 * @brief Enable the COMP2 EXTI line in interrupt mode.
elmot 1:d0dfbce63a89 441 * @retval None
elmot 1:d0dfbce63a89 442 */
elmot 1:d0dfbce63a89 443 #define __HAL_COMP_COMP2_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR1, COMP_EXTI_LINE_COMP2)
elmot 1:d0dfbce63a89 444
elmot 1:d0dfbce63a89 445 /**
elmot 1:d0dfbce63a89 446 * @brief Disable the COMP2 EXTI line in interrupt mode.
elmot 1:d0dfbce63a89 447 * @retval None
elmot 1:d0dfbce63a89 448 */
elmot 1:d0dfbce63a89 449 #define __HAL_COMP_COMP2_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR1, COMP_EXTI_LINE_COMP2)
elmot 1:d0dfbce63a89 450
elmot 1:d0dfbce63a89 451 /**
elmot 1:d0dfbce63a89 452 * @brief Generate a software interrupt on the COMP2 EXTI line.
elmot 1:d0dfbce63a89 453 * @retval None
elmot 1:d0dfbce63a89 454 */
elmot 1:d0dfbce63a89 455 #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP2)
elmot 1:d0dfbce63a89 456
elmot 1:d0dfbce63a89 457 /**
elmot 1:d0dfbce63a89 458 * @brief Enable the COMP2 EXTI line in event mode.
elmot 1:d0dfbce63a89 459 * @retval None
elmot 1:d0dfbce63a89 460 */
elmot 1:d0dfbce63a89 461 #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR1, COMP_EXTI_LINE_COMP2)
elmot 1:d0dfbce63a89 462
elmot 1:d0dfbce63a89 463 /**
elmot 1:d0dfbce63a89 464 * @brief Disable the COMP2 EXTI line in event mode.
elmot 1:d0dfbce63a89 465 * @retval None
elmot 1:d0dfbce63a89 466 */
elmot 1:d0dfbce63a89 467 #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR1, COMP_EXTI_LINE_COMP2)
elmot 1:d0dfbce63a89 468
elmot 1:d0dfbce63a89 469 /**
elmot 1:d0dfbce63a89 470 * @brief Check whether the COMP2 EXTI line flag is set.
elmot 1:d0dfbce63a89 471 * @retval RESET or SET
elmot 1:d0dfbce63a89 472 */
elmot 1:d0dfbce63a89 473 #define __HAL_COMP_COMP2_EXTI_GET_FLAG() READ_BIT(EXTI->PR1, COMP_EXTI_LINE_COMP2)
elmot 1:d0dfbce63a89 474
elmot 1:d0dfbce63a89 475 /**
elmot 1:d0dfbce63a89 476 * @brief Clear the COMP2 EXTI flag.
elmot 1:d0dfbce63a89 477 * @retval None
elmot 1:d0dfbce63a89 478 */
elmot 1:d0dfbce63a89 479 #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR1, COMP_EXTI_LINE_COMP2)
elmot 1:d0dfbce63a89 480
elmot 1:d0dfbce63a89 481 /**
elmot 1:d0dfbce63a89 482 * @}
elmot 1:d0dfbce63a89 483 */
elmot 1:d0dfbce63a89 484
elmot 1:d0dfbce63a89 485 /**
elmot 1:d0dfbce63a89 486 * @}
elmot 1:d0dfbce63a89 487 */
elmot 1:d0dfbce63a89 488
elmot 1:d0dfbce63a89 489
elmot 1:d0dfbce63a89 490 /* Private types -------------------------------------------------------------*/
elmot 1:d0dfbce63a89 491 /* Private constants ---------------------------------------------------------*/
elmot 1:d0dfbce63a89 492 /** @defgroup COMP_Private_Constants COMP Private Constants
elmot 1:d0dfbce63a89 493 * @{
elmot 1:d0dfbce63a89 494 */
elmot 1:d0dfbce63a89 495 /** @defgroup COMP_ExtiLine COMP EXTI Lines
elmot 1:d0dfbce63a89 496 * @{
elmot 1:d0dfbce63a89 497 */
elmot 1:d0dfbce63a89 498 #define COMP_EXTI_LINE_COMP1 (EXTI_IMR1_IM21) /*!< EXTI line 21 connected to COMP1 output */
elmot 1:d0dfbce63a89 499 #define COMP_EXTI_LINE_COMP2 (EXTI_IMR1_IM22) /*!< EXTI line 22 connected to COMP2 output */
elmot 1:d0dfbce63a89 500 /**
elmot 1:d0dfbce63a89 501 * @}
elmot 1:d0dfbce63a89 502 */
elmot 1:d0dfbce63a89 503
elmot 1:d0dfbce63a89 504 /** @defgroup COMP_ExtiLine COMP EXTI Lines
elmot 1:d0dfbce63a89 505 * @{
elmot 1:d0dfbce63a89 506 */
elmot 1:d0dfbce63a89 507 #define COMP_EXTI_IT ((uint32_t) 0x01) /*!< EXTI line event with interruption */
elmot 1:d0dfbce63a89 508 #define COMP_EXTI_EVENT ((uint32_t) 0x02) /*!< EXTI line event only (without interruption) */
elmot 1:d0dfbce63a89 509 #define COMP_EXTI_RISING ((uint32_t) 0x10) /*!< EXTI line event on rising edge */
elmot 1:d0dfbce63a89 510 #define COMP_EXTI_FALLING ((uint32_t) 0x20) /*!< EXTI line event on falling edge */
elmot 1:d0dfbce63a89 511 /**
elmot 1:d0dfbce63a89 512 * @}
elmot 1:d0dfbce63a89 513 */
elmot 1:d0dfbce63a89 514
elmot 1:d0dfbce63a89 515 /**
elmot 1:d0dfbce63a89 516 * @}
elmot 1:d0dfbce63a89 517 */
elmot 1:d0dfbce63a89 518
elmot 1:d0dfbce63a89 519 /* Private macros ------------------------------------------------------------*/
elmot 1:d0dfbce63a89 520 /** @defgroup COMP_Private_Macros COMP Private Macros
elmot 1:d0dfbce63a89 521 * @{
elmot 1:d0dfbce63a89 522 */
elmot 1:d0dfbce63a89 523
elmot 1:d0dfbce63a89 524 /** @defgroup COMP_GET_EXTI_LINE COMP private macros to get EXTI line associated with comparators
elmot 1:d0dfbce63a89 525 * @{
elmot 1:d0dfbce63a89 526 */
elmot 1:d0dfbce63a89 527 /**
elmot 1:d0dfbce63a89 528 * @brief Get the specified EXTI line for a comparator instance.
elmot 1:d0dfbce63a89 529 * @param __INSTANCE__ specifies the COMP instance.
elmot 1:d0dfbce63a89 530 * @retval value of @ref COMP_ExtiLine
elmot 1:d0dfbce63a89 531 */
elmot 1:d0dfbce63a89 532 #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? \
elmot 1:d0dfbce63a89 533 COMP_EXTI_LINE_COMP1 : COMP_EXTI_LINE_COMP2)
elmot 1:d0dfbce63a89 534 /**
elmot 1:d0dfbce63a89 535 * @}
elmot 1:d0dfbce63a89 536 */
elmot 1:d0dfbce63a89 537
elmot 1:d0dfbce63a89 538 /** @defgroup COMP_IS_COMP_Definitions COMP private macros to check input parameters
elmot 1:d0dfbce63a89 539 * @{
elmot 1:d0dfbce63a89 540 */
elmot 1:d0dfbce63a89 541 #define IS_COMP_WINDOWMODE(__WINDOWMODE__) (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE) || \
elmot 1:d0dfbce63a89 542 ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON) )
elmot 1:d0dfbce63a89 543
elmot 1:d0dfbce63a89 544 #define IS_COMP_POWERMODE(__POWERMODE__) (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED) || \
elmot 1:d0dfbce63a89 545 ((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED) || \
elmot 1:d0dfbce63a89 546 ((__POWERMODE__) == COMP_POWERMODE_ULTRALOWPOWER) )
elmot 1:d0dfbce63a89 547
elmot 1:d0dfbce63a89 548 #if defined(COMP_CSR_INPSEL_1)
elmot 1:d0dfbce63a89 549 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
elmot 1:d0dfbce63a89 550 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \
elmot 1:d0dfbce63a89 551 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO3))
elmot 1:d0dfbce63a89 552 #else
elmot 1:d0dfbce63a89 553 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
elmot 1:d0dfbce63a89 554 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2))
elmot 1:d0dfbce63a89 555 #endif
elmot 1:d0dfbce63a89 556
elmot 1:d0dfbce63a89 557 /* Note: On this STM32 family, comparator input minus parameters are */
elmot 1:d0dfbce63a89 558 /* the same on all COMP instances. */
elmot 1:d0dfbce63a89 559 /* However, comparator instance kept as macro parameter for */
elmot 1:d0dfbce63a89 560 /* compatibility with other STM32 families. */
elmot 1:d0dfbce63a89 561 #if defined(COMP_CSR_INMESEL_1)
elmot 1:d0dfbce63a89 562 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
elmot 1:d0dfbce63a89 563 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
elmot 1:d0dfbce63a89 564 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
elmot 1:d0dfbce63a89 565 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
elmot 1:d0dfbce63a89 566 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
elmot 1:d0dfbce63a89 567 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
elmot 1:d0dfbce63a89 568 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
elmot 1:d0dfbce63a89 569 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) || \
elmot 1:d0dfbce63a89 570 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO3) || \
elmot 1:d0dfbce63a89 571 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO4) || \
elmot 1:d0dfbce63a89 572 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO5))
elmot 1:d0dfbce63a89 573 #else
elmot 1:d0dfbce63a89 574 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
elmot 1:d0dfbce63a89 575 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
elmot 1:d0dfbce63a89 576 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
elmot 1:d0dfbce63a89 577 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
elmot 1:d0dfbce63a89 578 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
elmot 1:d0dfbce63a89 579 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
elmot 1:d0dfbce63a89 580 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
elmot 1:d0dfbce63a89 581 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2))
elmot 1:d0dfbce63a89 582 #endif
elmot 1:d0dfbce63a89 583
elmot 1:d0dfbce63a89 584 #define IS_COMP_HYSTERESIS(__HYSTERESIS__) (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE) || \
elmot 1:d0dfbce63a89 585 ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW) || \
elmot 1:d0dfbce63a89 586 ((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \
elmot 1:d0dfbce63a89 587 ((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH))
elmot 1:d0dfbce63a89 588
elmot 1:d0dfbce63a89 589 #define IS_COMP_OUTPUTPOL(__POL__) (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
elmot 1:d0dfbce63a89 590 ((__POL__) == COMP_OUTPUTPOL_INVERTED))
elmot 1:d0dfbce63a89 591
elmot 1:d0dfbce63a89 592 #define IS_COMP_BLANKINGSRCE(__SOURCE__) (((__SOURCE__) == COMP_BLANKINGSRC_NONE) || \
elmot 1:d0dfbce63a89 593 ((__SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) || \
elmot 1:d0dfbce63a89 594 ((__SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) || \
elmot 1:d0dfbce63a89 595 ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1) || \
elmot 1:d0dfbce63a89 596 ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP2) || \
elmot 1:d0dfbce63a89 597 ((__SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2) || \
elmot 1:d0dfbce63a89 598 ((__SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP2))
elmot 1:d0dfbce63a89 599
elmot 1:d0dfbce63a89 600 #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __BLANKINGSRCE__) \
elmot 1:d0dfbce63a89 601 ((((__INSTANCE__) == COMP1) && \
elmot 1:d0dfbce63a89 602 (((__BLANKINGSRCE__) == COMP_BLANKINGSRC_NONE) || \
elmot 1:d0dfbce63a89 603 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) || \
elmot 1:d0dfbce63a89 604 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) || \
elmot 1:d0dfbce63a89 605 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1))) \
elmot 1:d0dfbce63a89 606 || \
elmot 1:d0dfbce63a89 607 (((__INSTANCE__) == COMP2) && \
elmot 1:d0dfbce63a89 608 (((__BLANKINGSRCE__) == COMP_BLANKINGSRC_NONE) || \
elmot 1:d0dfbce63a89 609 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP2) || \
elmot 1:d0dfbce63a89 610 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2) || \
elmot 1:d0dfbce63a89 611 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP2))))
elmot 1:d0dfbce63a89 612
elmot 1:d0dfbce63a89 613 #define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \
elmot 1:d0dfbce63a89 614 ((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \
elmot 1:d0dfbce63a89 615 ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \
elmot 1:d0dfbce63a89 616 ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \
elmot 1:d0dfbce63a89 617 ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \
elmot 1:d0dfbce63a89 618 ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \
elmot 1:d0dfbce63a89 619 ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
elmot 1:d0dfbce63a89 620
elmot 1:d0dfbce63a89 621 #define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW) || \
elmot 1:d0dfbce63a89 622 ((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH))
elmot 1:d0dfbce63a89 623
elmot 1:d0dfbce63a89 624 /**
elmot 1:d0dfbce63a89 625 * @}
elmot 1:d0dfbce63a89 626 */
elmot 1:d0dfbce63a89 627
elmot 1:d0dfbce63a89 628 /**
elmot 1:d0dfbce63a89 629 * @}
elmot 1:d0dfbce63a89 630 */
elmot 1:d0dfbce63a89 631
elmot 1:d0dfbce63a89 632
elmot 1:d0dfbce63a89 633 /* Exported functions --------------------------------------------------------*/
elmot 1:d0dfbce63a89 634 /** @addtogroup COMP_Exported_Functions
elmot 1:d0dfbce63a89 635 * @{
elmot 1:d0dfbce63a89 636 */
elmot 1:d0dfbce63a89 637
elmot 1:d0dfbce63a89 638 /** @addtogroup COMP_Exported_Functions_Group1
elmot 1:d0dfbce63a89 639 * @{
elmot 1:d0dfbce63a89 640 */
elmot 1:d0dfbce63a89 641
elmot 1:d0dfbce63a89 642 /* Initialization and de-initialization functions **********************************/
elmot 1:d0dfbce63a89 643 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
elmot 1:d0dfbce63a89 644 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
elmot 1:d0dfbce63a89 645 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
elmot 1:d0dfbce63a89 646 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
elmot 1:d0dfbce63a89 647 /**
elmot 1:d0dfbce63a89 648 * @}
elmot 1:d0dfbce63a89 649 */
elmot 1:d0dfbce63a89 650
elmot 1:d0dfbce63a89 651 /* IO operation functions *****************************************************/
elmot 1:d0dfbce63a89 652 /** @addtogroup COMP_Exported_Functions_Group2
elmot 1:d0dfbce63a89 653 * @{
elmot 1:d0dfbce63a89 654 */
elmot 1:d0dfbce63a89 655 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
elmot 1:d0dfbce63a89 656 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
elmot 1:d0dfbce63a89 657 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
elmot 1:d0dfbce63a89 658 /**
elmot 1:d0dfbce63a89 659 * @}
elmot 1:d0dfbce63a89 660 */
elmot 1:d0dfbce63a89 661
elmot 1:d0dfbce63a89 662 /* Peripheral Control functions ************************************************/
elmot 1:d0dfbce63a89 663 /** @addtogroup COMP_Exported_Functions_Group3
elmot 1:d0dfbce63a89 664 * @{
elmot 1:d0dfbce63a89 665 */
elmot 1:d0dfbce63a89 666 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
elmot 1:d0dfbce63a89 667 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
elmot 1:d0dfbce63a89 668 /* Callback in interrupt mode */
elmot 1:d0dfbce63a89 669 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
elmot 1:d0dfbce63a89 670 /**
elmot 1:d0dfbce63a89 671 * @}
elmot 1:d0dfbce63a89 672 */
elmot 1:d0dfbce63a89 673
elmot 1:d0dfbce63a89 674 /* Peripheral State functions **************************************************/
elmot 1:d0dfbce63a89 675 /** @addtogroup COMP_Exported_Functions_Group4
elmot 1:d0dfbce63a89 676 * @{
elmot 1:d0dfbce63a89 677 */
elmot 1:d0dfbce63a89 678 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
elmot 1:d0dfbce63a89 679 /**
elmot 1:d0dfbce63a89 680 * @}
elmot 1:d0dfbce63a89 681 */
elmot 1:d0dfbce63a89 682
elmot 1:d0dfbce63a89 683 /**
elmot 1:d0dfbce63a89 684 * @}
elmot 1:d0dfbce63a89 685 */
elmot 1:d0dfbce63a89 686
elmot 1:d0dfbce63a89 687 /**
elmot 1:d0dfbce63a89 688 * @}
elmot 1:d0dfbce63a89 689 */
elmot 1:d0dfbce63a89 690
elmot 1:d0dfbce63a89 691 /**
elmot 1:d0dfbce63a89 692 * @}
elmot 1:d0dfbce63a89 693 */
elmot 1:d0dfbce63a89 694
elmot 1:d0dfbce63a89 695 #ifdef __cplusplus
elmot 1:d0dfbce63a89 696 }
elmot 1:d0dfbce63a89 697 #endif
elmot 1:d0dfbce63a89 698
elmot 1:d0dfbce63a89 699 #endif /* __STM32L4xx_HAL_COMP_H */
elmot 1:d0dfbce63a89 700
elmot 1:d0dfbce63a89 701 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/