Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of TUKS-COURSE-TIMER by
stm32l4xx_hal_comp.h
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal_comp.h 00004 * @author MCD Application Team 00005 * @version V1.5.1 00006 * @date 31-May-2016 00007 * @brief Header file of COMP HAL module. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 /* Define to prevent recursive inclusion -------------------------------------*/ 00039 #ifndef __STM32L4xx_HAL_COMP_H 00040 #define __STM32L4xx_HAL_COMP_H 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 /* Includes ------------------------------------------------------------------*/ 00047 #include "stm32l4xx_hal_def.h" 00048 00049 /** @addtogroup STM32L4xx_HAL_Driver 00050 * @{ 00051 */ 00052 00053 /** @addtogroup COMP 00054 * @{ 00055 */ 00056 00057 /* Exported types ------------------------------------------------------------*/ 00058 /** @defgroup COMP_Exported_Types COMP Exported Types 00059 * @{ 00060 */ 00061 00062 /** 00063 * @brief COMP Init structure definition 00064 */ 00065 typedef struct 00066 { 00067 00068 uint32_t WindowMode; /*!< Set window mode of a pair of comparators instances 00069 (2 consecutive instances odd and even COMP<x> and COMP<x+1>). 00070 Note: HAL COMP driver allows to set window mode from any COMP instance of the pair of COMP instances composing window mode. 00071 This parameter can be a value of @ref COMP_WindowMode */ 00072 00073 uint32_t Mode; /*!< Set comparator operating mode to adjust power and speed. 00074 Note: For the characteritics of comparator power modes 00075 (propagation delay and power consumption), refer to device datasheet. 00076 This parameter can be a value of @ref COMP_PowerMode */ 00077 00078 uint32_t NonInvertingInput; /*!< Set comparator input plus (non-inverting input). 00079 This parameter can be a value of @ref COMP_InputPlus */ 00080 00081 uint32_t InvertingInput; /*!< Set comparator input minus (inverting input). 00082 This parameter can be a value of @ref COMP_InputMinus */ 00083 00084 uint32_t Hysteresis; /*!< Set comparator hysteresis mode of the input minus. 00085 This parameter can be a value of @ref COMP_Hysteresis */ 00086 00087 uint32_t OutputPol; /*!< Set comparator output polarity. 00088 This parameter can be a value of @ref COMP_OutputPolarity */ 00089 00090 uint32_t BlankingSrce; /*!< Set comparator blanking source. 00091 This parameter can be a value of @ref COMP_BlankingSrce */ 00092 00093 uint32_t TriggerMode; /*!< Set the comparator output triggering External Interrupt Line (EXTI). 00094 This parameter can be a value of @ref COMP_EXTI_TriggerMode */ 00095 00096 }COMP_InitTypeDef; 00097 00098 /** 00099 * @brief HAL COMP state machine: HAL COMP states definition 00100 */ 00101 #define COMP_STATE_BITFIELD_LOCK ((uint32_t)0x10) 00102 typedef enum 00103 { 00104 HAL_COMP_STATE_RESET = 0x00, /*!< COMP not yet initialized */ 00105 HAL_COMP_STATE_RESET_LOCKED = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */ 00106 HAL_COMP_STATE_READY = 0x01, /*!< COMP initialized and ready for use */ 00107 HAL_COMP_STATE_READY_LOCKED = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked */ 00108 HAL_COMP_STATE_BUSY = 0x02, /*!< COMP is running */ 00109 HAL_COMP_STATE_BUSY_LOCKED = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK) /*!< COMP is running and configuration is locked */ 00110 }HAL_COMP_StateTypeDef; 00111 00112 /** 00113 * @brief COMP Handle Structure definition 00114 */ 00115 typedef struct 00116 { 00117 COMP_TypeDef *Instance; /*!< Register base address */ 00118 COMP_InitTypeDef Init; /*!< COMP required parameters */ 00119 HAL_LockTypeDef Lock; /*!< Locking object */ 00120 __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */ 00121 } COMP_HandleTypeDef; 00122 00123 /** 00124 * @} 00125 */ 00126 00127 /* Exported constants --------------------------------------------------------*/ 00128 /** @defgroup COMP_Exported_Constants COMP Exported Constants 00129 * @{ 00130 */ 00131 00132 /** @defgroup COMP_WindowMode COMP Window Mode 00133 * @{ 00134 */ 00135 #define COMP_WINDOWMODE_DISABLE ((uint32_t)0x00000000) /*!< Window mode disable: Comparators instances pair COMP1 and COMP2 are independent */ 00136 #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). */ 00137 00138 /** 00139 * @} 00140 */ 00141 00142 /** @defgroup COMP_PowerMode COMP power mode 00143 * @{ 00144 */ 00145 /* Note: For the characteritics of comparator power modes */ 00146 /* (propagation delay and power consumption), */ 00147 /* refer to device datasheet. */ 00148 #define COMP_POWERMODE_HIGHSPEED ((uint32_t)0x00000000) /*!< High Speed */ 00149 #define COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_PWRMODE_0) /*!< Medium Speed */ 00150 #define COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_PWRMODE) /*!< Ultra-low power mode */ 00151 /** 00152 * @} 00153 */ 00154 00155 /** @defgroup COMP_InputPlus COMP input plus (non-inverting input) 00156 * @{ 00157 */ 00158 #define COMP_INPUT_PLUS_IO1 ((uint32_t)0x00000000) /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1, pin PB4 for COMP2) */ 00159 #define COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2) */ 00160 #if defined(COMP_CSR_INPSEL_1) 00161 #define COMP_INPUT_PLUS_IO3 (COMP_CSR_INPSEL_1) /*!< Comparator input plus connected to IO3 (pin PA1 for COMP1, pin PA3 for COMP2) */ 00162 #endif 00163 /** 00164 * @} 00165 */ 00166 00167 /** @defgroup COMP_InputMinus COMP input minus (inverting input) 00168 * @{ 00169 */ 00170 #define COMP_INPUT_MINUS_1_4VREFINT ( COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/4 VrefInt */ 00171 #define COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/2 VrefInt */ 00172 #define COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */ 00173 #define COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) /*!< Comparator input minus connected to VrefInt */ 00174 #define COMP_INPUT_MINUS_DAC1_CH1 (COMP_CSR_INMSEL_2 ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */ 00175 #define COMP_INPUT_MINUS_DAC1_CH2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */ 00176 #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) */ 00177 #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) */ 00178 #if defined(COMP_CSR_INMESEL_1) 00179 #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) */ 00180 #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) */ 00181 #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) */ 00182 #endif 00183 /** 00184 * @} 00185 */ 00186 00187 /** @defgroup COMP_Hysteresis COMP hysteresis 00188 * @{ 00189 */ 00190 #define COMP_HYSTERESIS_NONE ((uint32_t)0x00000000) /*!< No hysteresis */ 00191 #define COMP_HYSTERESIS_LOW (COMP_CSR_HYST_0) /*!< Hysteresis level low */ 00192 #define COMP_HYSTERESIS_MEDIUM (COMP_CSR_HYST_1) /*!< Hysteresis level medium */ 00193 #define COMP_HYSTERESIS_HIGH (COMP_CSR_HYST) /*!< Hysteresis level high */ 00194 /** 00195 * @} 00196 */ 00197 00198 /** @defgroup COMP_OutputPolarity COMP output Polarity 00199 * @{ 00200 */ 00201 #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) */ 00202 #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) */ 00203 /** 00204 * @} 00205 */ 00206 00207 /** @defgroup COMP_BlankingSrce COMP blanking source 00208 * @{ 00209 */ 00210 #define COMP_BLANKINGSRC_NONE ((uint32_t)0x00000000) /*!< No blanking source */ 00211 /* Blanking sources for COMP instance: COMP1 */ 00212 #define COMP_BLANKINGSRC_TIM1_OC5_COMP1 (COMP_CSR_BLANKING_0) /*!< Blanking source for COMP1: TIM1 OC5 selected as blanking source for comparator */ 00213 #define COMP_BLANKINGSRC_TIM2_OC3_COMP1 (COMP_CSR_BLANKING_1) /*!< Blanking source for COMP1: TIM2 OC3 selected as blanking source for comparator */ 00214 #define COMP_BLANKINGSRC_TIM3_OC3_COMP1 (COMP_CSR_BLANKING_2) /*!< Blanking source for COMP1: TIM3 OC3 selected as blanking source for comparator */ 00215 /* Blanking sources for COMP instance: COMP2 */ 00216 #define COMP_BLANKINGSRC_TIM3_OC4_COMP2 (COMP_CSR_BLANKING_0) /*!< Blanking source for COMP2: TIM3 OC4 selected as blanking source for comparator */ 00217 #define COMP_BLANKINGSRC_TIM8_OC5_COMP2 (COMP_CSR_BLANKING_1) /*!< Blanking source for COMP2: TIM8 OC5 selected as blanking source for comparator */ 00218 #define COMP_BLANKINGSRC_TIM15_OC1_COMP2 (COMP_CSR_BLANKING_2) /*!< Blanking source for COMP2: TIM15 OC1 selected as blanking source for comparator */ 00219 /** 00220 * @} 00221 */ 00222 00223 /** @defgroup COMP_OutputLevel COMP Output Level 00224 * @{ 00225 */ 00226 /* Note: Comparator output level values are fixed to "0" and "1", */ 00227 /* corresponding COMP register bit is managed by HAL function to match */ 00228 /* with these values (independently of bit position in register). */ 00229 00230 /* When output polarity is not inverted, comparator output is low when 00231 the input plus is at a lower voltage than the input minus */ 00232 #define COMP_OUTPUT_LEVEL_LOW ((uint32_t)0x00000000) 00233 /* When output polarity is not inverted, comparator output is high when 00234 the input plus is at a higher voltage than the input minus */ 00235 #define COMP_OUTPUT_LEVEL_HIGH ((uint32_t)0x00000001) 00236 /** 00237 * @} 00238 */ 00239 00240 /** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI 00241 * @{ 00242 */ 00243 #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< Comparator output triggering no External Interrupt Line */ 00244 #define COMP_TRIGGERMODE_IT_RISING (COMP_EXTI_IT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */ 00245 #define COMP_TRIGGERMODE_IT_FALLING (COMP_EXTI_IT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */ 00246 #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 */ 00247 #define COMP_TRIGGERMODE_EVENT_RISING (COMP_EXTI_EVENT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */ 00248 #define COMP_TRIGGERMODE_EVENT_FALLING (COMP_EXTI_EVENT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */ 00249 #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 */ 00250 /** 00251 * @} 00252 */ 00253 00254 /** 00255 * @} 00256 */ 00257 00258 /* Exported macro ------------------------------------------------------------*/ 00259 /** @defgroup COMP_Exported_Macros COMP Exported Macros 00260 * @{ 00261 */ 00262 00263 /** @defgroup COMP_Handle_Management COMP Handle Management 00264 * @{ 00265 */ 00266 00267 /** @brief Reset COMP handle state. 00268 * @param __HANDLE__ COMP handle 00269 * @retval None 00270 */ 00271 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET) 00272 00273 /** 00274 * @brief Enable the specified comparator. 00275 * @param __HANDLE__ COMP handle 00276 * @retval None 00277 */ 00278 #define __HAL_COMP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN) 00279 00280 /** 00281 * @brief Disable the specified comparator. 00282 * @param __HANDLE__ COMP handle 00283 * @retval None 00284 */ 00285 #define __HAL_COMP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN) 00286 00287 /** 00288 * @brief Lock the specified comparator configuration. 00289 * @note Using this macro induce HAL COMP handle state machine being no 00290 * more in line with COMP instance state. 00291 * To keep HAL COMP handle state machine updated, it is recommended 00292 * to use function "HAL_COMP_Lock')". 00293 * @param __HANDLE__ COMP handle 00294 * @retval None 00295 */ 00296 #define __HAL_COMP_LOCK(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK) 00297 00298 /** 00299 * @brief Check whether the specified comparator is locked. 00300 * @param __HANDLE__ COMP handle 00301 * @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked 00302 */ 00303 #define __HAL_COMP_IS_LOCKED(__HANDLE__) (READ_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK) == COMP_CSR_LOCK) 00304 00305 /** 00306 * @} 00307 */ 00308 00309 /** @defgroup COMP_Exti_Management COMP external interrupt line management 00310 * @{ 00311 */ 00312 00313 /** 00314 * @brief Enable the COMP1 EXTI line rising edge trigger. 00315 * @retval None 00316 */ 00317 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1) 00318 00319 /** 00320 * @brief Disable the COMP1 EXTI line rising edge trigger. 00321 * @retval None 00322 */ 00323 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1) 00324 00325 /** 00326 * @brief Enable the COMP1 EXTI line falling edge trigger. 00327 * @retval None 00328 */ 00329 #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1) 00330 00331 /** 00332 * @brief Disable the COMP1 EXTI line falling edge trigger. 00333 * @retval None 00334 */ 00335 #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1) 00336 00337 /** 00338 * @brief Enable the COMP1 EXTI line rising & falling edge trigger. 00339 * @retval None 00340 */ 00341 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ 00342 __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE(); \ 00343 __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE(); \ 00344 } while(0) 00345 00346 /** 00347 * @brief Disable the COMP1 EXTI line rising & falling edge trigger. 00348 * @retval None 00349 */ 00350 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ 00351 __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE(); \ 00352 __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE(); \ 00353 } while(0) 00354 00355 /** 00356 * @brief Enable the COMP1 EXTI line in interrupt mode. 00357 * @retval None 00358 */ 00359 #define __HAL_COMP_COMP1_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR1, COMP_EXTI_LINE_COMP1) 00360 00361 /** 00362 * @brief Disable the COMP1 EXTI line in interrupt mode. 00363 * @retval None 00364 */ 00365 #define __HAL_COMP_COMP1_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR1, COMP_EXTI_LINE_COMP1) 00366 00367 /** 00368 * @brief Generate a software interrupt on the COMP1 EXTI line. 00369 * @retval None 00370 */ 00371 #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP1) 00372 00373 /** 00374 * @brief Enable the COMP1 EXTI line in event mode. 00375 * @retval None 00376 */ 00377 #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR1, COMP_EXTI_LINE_COMP1) 00378 00379 /** 00380 * @brief Disable the COMP1 EXTI line in event mode. 00381 * @retval None 00382 */ 00383 #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR1, COMP_EXTI_LINE_COMP1) 00384 00385 /** 00386 * @brief Check whether the COMP1 EXTI line flag is set. 00387 * @retval RESET or SET 00388 */ 00389 #define __HAL_COMP_COMP1_EXTI_GET_FLAG() READ_BIT(EXTI->PR1, COMP_EXTI_LINE_COMP1) 00390 00391 /** 00392 * @brief Clear the COMP1 EXTI flag. 00393 * @retval None 00394 */ 00395 #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR1, COMP_EXTI_LINE_COMP1) 00396 00397 /** 00398 * @brief Enable the COMP2 EXTI line rising edge trigger. 00399 * @retval None 00400 */ 00401 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2) 00402 00403 /** 00404 * @brief Disable the COMP2 EXTI line rising edge trigger. 00405 * @retval None 00406 */ 00407 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2) 00408 00409 /** 00410 * @brief Enable the COMP2 EXTI line falling edge trigger. 00411 * @retval None 00412 */ 00413 #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2) 00414 00415 /** 00416 * @brief Disable the COMP2 EXTI line falling edge trigger. 00417 * @retval None 00418 */ 00419 #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2) 00420 00421 /** 00422 * @brief Enable the COMP2 EXTI line rising & falling edge trigger. 00423 * @retval None 00424 */ 00425 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ 00426 __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE(); \ 00427 __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE(); \ 00428 } while(0) 00429 00430 /** 00431 * @brief Disable the COMP2 EXTI line rising & falling edge trigger. 00432 * @retval None 00433 */ 00434 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ 00435 __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE(); \ 00436 __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE(); \ 00437 } while(0) 00438 00439 /** 00440 * @brief Enable the COMP2 EXTI line in interrupt mode. 00441 * @retval None 00442 */ 00443 #define __HAL_COMP_COMP2_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR1, COMP_EXTI_LINE_COMP2) 00444 00445 /** 00446 * @brief Disable the COMP2 EXTI line in interrupt mode. 00447 * @retval None 00448 */ 00449 #define __HAL_COMP_COMP2_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR1, COMP_EXTI_LINE_COMP2) 00450 00451 /** 00452 * @brief Generate a software interrupt on the COMP2 EXTI line. 00453 * @retval None 00454 */ 00455 #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP2) 00456 00457 /** 00458 * @brief Enable the COMP2 EXTI line in event mode. 00459 * @retval None 00460 */ 00461 #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR1, COMP_EXTI_LINE_COMP2) 00462 00463 /** 00464 * @brief Disable the COMP2 EXTI line in event mode. 00465 * @retval None 00466 */ 00467 #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR1, COMP_EXTI_LINE_COMP2) 00468 00469 /** 00470 * @brief Check whether the COMP2 EXTI line flag is set. 00471 * @retval RESET or SET 00472 */ 00473 #define __HAL_COMP_COMP2_EXTI_GET_FLAG() READ_BIT(EXTI->PR1, COMP_EXTI_LINE_COMP2) 00474 00475 /** 00476 * @brief Clear the COMP2 EXTI flag. 00477 * @retval None 00478 */ 00479 #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR1, COMP_EXTI_LINE_COMP2) 00480 00481 /** 00482 * @} 00483 */ 00484 00485 /** 00486 * @} 00487 */ 00488 00489 00490 /* Private types -------------------------------------------------------------*/ 00491 /* Private constants ---------------------------------------------------------*/ 00492 /** @defgroup COMP_Private_Constants COMP Private Constants 00493 * @{ 00494 */ 00495 /** @defgroup COMP_ExtiLine COMP EXTI Lines 00496 * @{ 00497 */ 00498 #define COMP_EXTI_LINE_COMP1 (EXTI_IMR1_IM21) /*!< EXTI line 21 connected to COMP1 output */ 00499 #define COMP_EXTI_LINE_COMP2 (EXTI_IMR1_IM22) /*!< EXTI line 22 connected to COMP2 output */ 00500 /** 00501 * @} 00502 */ 00503 00504 /** @defgroup COMP_ExtiLine COMP EXTI Lines 00505 * @{ 00506 */ 00507 #define COMP_EXTI_IT ((uint32_t) 0x01) /*!< EXTI line event with interruption */ 00508 #define COMP_EXTI_EVENT ((uint32_t) 0x02) /*!< EXTI line event only (without interruption) */ 00509 #define COMP_EXTI_RISING ((uint32_t) 0x10) /*!< EXTI line event on rising edge */ 00510 #define COMP_EXTI_FALLING ((uint32_t) 0x20) /*!< EXTI line event on falling edge */ 00511 /** 00512 * @} 00513 */ 00514 00515 /** 00516 * @} 00517 */ 00518 00519 /* Private macros ------------------------------------------------------------*/ 00520 /** @defgroup COMP_Private_Macros COMP Private Macros 00521 * @{ 00522 */ 00523 00524 /** @defgroup COMP_GET_EXTI_LINE COMP private macros to get EXTI line associated with comparators 00525 * @{ 00526 */ 00527 /** 00528 * @brief Get the specified EXTI line for a comparator instance. 00529 * @param __INSTANCE__ specifies the COMP instance. 00530 * @retval value of @ref COMP_ExtiLine 00531 */ 00532 #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? \ 00533 COMP_EXTI_LINE_COMP1 : COMP_EXTI_LINE_COMP2) 00534 /** 00535 * @} 00536 */ 00537 00538 /** @defgroup COMP_IS_COMP_Definitions COMP private macros to check input parameters 00539 * @{ 00540 */ 00541 #define IS_COMP_WINDOWMODE(__WINDOWMODE__) (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE) || \ 00542 ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON) ) 00543 00544 #define IS_COMP_POWERMODE(__POWERMODE__) (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED) || \ 00545 ((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED) || \ 00546 ((__POWERMODE__) == COMP_POWERMODE_ULTRALOWPOWER) ) 00547 00548 #if defined(COMP_CSR_INPSEL_1) 00549 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \ 00550 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \ 00551 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO3)) 00552 #else 00553 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \ 00554 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2)) 00555 #endif 00556 00557 /* Note: On this STM32 family, comparator input minus parameters are */ 00558 /* the same on all COMP instances. */ 00559 /* However, comparator instance kept as macro parameter for */ 00560 /* compatibility with other STM32 families. */ 00561 #if defined(COMP_CSR_INMESEL_1) 00562 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \ 00563 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \ 00564 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \ 00565 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \ 00566 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \ 00567 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \ 00568 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \ 00569 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) || \ 00570 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO3) || \ 00571 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO4) || \ 00572 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO5)) 00573 #else 00574 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \ 00575 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \ 00576 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \ 00577 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \ 00578 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \ 00579 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \ 00580 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \ 00581 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2)) 00582 #endif 00583 00584 #define IS_COMP_HYSTERESIS(__HYSTERESIS__) (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE) || \ 00585 ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW) || \ 00586 ((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \ 00587 ((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH)) 00588 00589 #define IS_COMP_OUTPUTPOL(__POL__) (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \ 00590 ((__POL__) == COMP_OUTPUTPOL_INVERTED)) 00591 00592 #define IS_COMP_BLANKINGSRCE(__SOURCE__) (((__SOURCE__) == COMP_BLANKINGSRC_NONE) || \ 00593 ((__SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) || \ 00594 ((__SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) || \ 00595 ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1) || \ 00596 ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP2) || \ 00597 ((__SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2) || \ 00598 ((__SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP2)) 00599 00600 #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __BLANKINGSRCE__) \ 00601 ((((__INSTANCE__) == COMP1) && \ 00602 (((__BLANKINGSRCE__) == COMP_BLANKINGSRC_NONE) || \ 00603 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) || \ 00604 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) || \ 00605 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1))) \ 00606 || \ 00607 (((__INSTANCE__) == COMP2) && \ 00608 (((__BLANKINGSRCE__) == COMP_BLANKINGSRC_NONE) || \ 00609 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP2) || \ 00610 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2) || \ 00611 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP2)))) 00612 00613 #define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \ 00614 ((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \ 00615 ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \ 00616 ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \ 00617 ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \ 00618 ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \ 00619 ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING)) 00620 00621 #define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW) || \ 00622 ((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH)) 00623 00624 /** 00625 * @} 00626 */ 00627 00628 /** 00629 * @} 00630 */ 00631 00632 00633 /* Exported functions --------------------------------------------------------*/ 00634 /** @addtogroup COMP_Exported_Functions 00635 * @{ 00636 */ 00637 00638 /** @addtogroup COMP_Exported_Functions_Group1 00639 * @{ 00640 */ 00641 00642 /* Initialization and de-initialization functions **********************************/ 00643 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp); 00644 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp); 00645 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp); 00646 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp); 00647 /** 00648 * @} 00649 */ 00650 00651 /* IO operation functions *****************************************************/ 00652 /** @addtogroup COMP_Exported_Functions_Group2 00653 * @{ 00654 */ 00655 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp); 00656 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp); 00657 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp); 00658 /** 00659 * @} 00660 */ 00661 00662 /* Peripheral Control functions ************************************************/ 00663 /** @addtogroup COMP_Exported_Functions_Group3 00664 * @{ 00665 */ 00666 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp); 00667 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp); 00668 /* Callback in interrupt mode */ 00669 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp); 00670 /** 00671 * @} 00672 */ 00673 00674 /* Peripheral State functions **************************************************/ 00675 /** @addtogroup COMP_Exported_Functions_Group4 00676 * @{ 00677 */ 00678 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp); 00679 /** 00680 * @} 00681 */ 00682 00683 /** 00684 * @} 00685 */ 00686 00687 /** 00688 * @} 00689 */ 00690 00691 /** 00692 * @} 00693 */ 00694 00695 #ifdef __cplusplus 00696 } 00697 #endif 00698 00699 #endif /* __STM32L4xx_HAL_COMP_H */ 00700 00701 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 17:38:49 by
