mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
targets/cmsis/TARGET_STM/TARGET_STM32F0/stm32f0xx_hal_comp.h@0:9b334a45a8ff, 2015-10-01 (annotated)
- Committer:
- bogdanm
- Date:
- Thu Oct 01 15:25:22 2015 +0300
- Revision:
- 0:9b334a45a8ff
- Child:
- 144:ef7eb2e8f9f7
Initial commit on mbed-dev
Replaces mbed-src (now inactive)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 0:9b334a45a8ff | 1 | /** |
bogdanm | 0:9b334a45a8ff | 2 | ****************************************************************************** |
bogdanm | 0:9b334a45a8ff | 3 | * @file stm32f0xx_hal_comp.h |
bogdanm | 0:9b334a45a8ff | 4 | * @author MCD Application Team |
bogdanm | 0:9b334a45a8ff | 5 | * @version V1.3.0 |
bogdanm | 0:9b334a45a8ff | 6 | * @date 26-June-2015 |
bogdanm | 0:9b334a45a8ff | 7 | * @brief Header file of COMP HAL module. |
bogdanm | 0:9b334a45a8ff | 8 | ****************************************************************************** |
bogdanm | 0:9b334a45a8ff | 9 | * @attention |
bogdanm | 0:9b334a45a8ff | 10 | * |
bogdanm | 0:9b334a45a8ff | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
bogdanm | 0:9b334a45a8ff | 12 | * |
bogdanm | 0:9b334a45a8ff | 13 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 0:9b334a45a8ff | 14 | * are permitted provided that the following conditions are met: |
bogdanm | 0:9b334a45a8ff | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
bogdanm | 0:9b334a45a8ff | 16 | * this list of conditions and the following disclaimer. |
bogdanm | 0:9b334a45a8ff | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bogdanm | 0:9b334a45a8ff | 18 | * this list of conditions and the following disclaimer in the documentation |
bogdanm | 0:9b334a45a8ff | 19 | * and/or other materials provided with the distribution. |
bogdanm | 0:9b334a45a8ff | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bogdanm | 0:9b334a45a8ff | 21 | * may be used to endorse or promote products derived from this software |
bogdanm | 0:9b334a45a8ff | 22 | * without specific prior written permission. |
bogdanm | 0:9b334a45a8ff | 23 | * |
bogdanm | 0:9b334a45a8ff | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 0:9b334a45a8ff | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 0:9b334a45a8ff | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 0:9b334a45a8ff | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bogdanm | 0:9b334a45a8ff | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bogdanm | 0:9b334a45a8ff | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bogdanm | 0:9b334a45a8ff | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bogdanm | 0:9b334a45a8ff | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bogdanm | 0:9b334a45a8ff | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bogdanm | 0:9b334a45a8ff | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 0:9b334a45a8ff | 34 | * |
bogdanm | 0:9b334a45a8ff | 35 | ****************************************************************************** |
bogdanm | 0:9b334a45a8ff | 36 | */ |
bogdanm | 0:9b334a45a8ff | 37 | |
bogdanm | 0:9b334a45a8ff | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 39 | #ifndef __STM32F0xx_HAL_COMP_H |
bogdanm | 0:9b334a45a8ff | 40 | #define __STM32F0xx_HAL_COMP_H |
bogdanm | 0:9b334a45a8ff | 41 | |
bogdanm | 0:9b334a45a8ff | 42 | #ifdef __cplusplus |
bogdanm | 0:9b334a45a8ff | 43 | extern "C" { |
bogdanm | 0:9b334a45a8ff | 44 | #endif |
bogdanm | 0:9b334a45a8ff | 45 | |
bogdanm | 0:9b334a45a8ff | 46 | #if defined(STM32F051x8) || defined(STM32F058xx) || \ |
bogdanm | 0:9b334a45a8ff | 47 | defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \ |
bogdanm | 0:9b334a45a8ff | 48 | defined(STM32F091xC) || defined(STM32F098xx) |
bogdanm | 0:9b334a45a8ff | 49 | |
bogdanm | 0:9b334a45a8ff | 50 | /* Includes ------------------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 51 | #include "stm32f0xx_hal_def.h" |
bogdanm | 0:9b334a45a8ff | 52 | |
bogdanm | 0:9b334a45a8ff | 53 | /** @addtogroup STM32F0xx_HAL_Driver |
bogdanm | 0:9b334a45a8ff | 54 | * @{ |
bogdanm | 0:9b334a45a8ff | 55 | */ |
bogdanm | 0:9b334a45a8ff | 56 | |
bogdanm | 0:9b334a45a8ff | 57 | /** @addtogroup COMP COMP |
bogdanm | 0:9b334a45a8ff | 58 | * @{ |
bogdanm | 0:9b334a45a8ff | 59 | */ |
bogdanm | 0:9b334a45a8ff | 60 | |
bogdanm | 0:9b334a45a8ff | 61 | /* Exported types ------------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 62 | /** @defgroup COMP_Exported_Types COMP Exported Types |
bogdanm | 0:9b334a45a8ff | 63 | * @{ |
bogdanm | 0:9b334a45a8ff | 64 | */ |
bogdanm | 0:9b334a45a8ff | 65 | |
bogdanm | 0:9b334a45a8ff | 66 | /** |
bogdanm | 0:9b334a45a8ff | 67 | * @brief COMP Init structure definition |
bogdanm | 0:9b334a45a8ff | 68 | */ |
bogdanm | 0:9b334a45a8ff | 69 | typedef struct |
bogdanm | 0:9b334a45a8ff | 70 | { |
bogdanm | 0:9b334a45a8ff | 71 | |
bogdanm | 0:9b334a45a8ff | 72 | uint32_t InvertingInput; /*!< Selects the inverting input of the comparator. |
bogdanm | 0:9b334a45a8ff | 73 | This parameter can be a value of @ref COMP_InvertingInput */ |
bogdanm | 0:9b334a45a8ff | 74 | |
bogdanm | 0:9b334a45a8ff | 75 | uint32_t NonInvertingInput; /*!< Selects the non inverting input of the comparator. |
bogdanm | 0:9b334a45a8ff | 76 | This parameter can be a value of @ref COMP_NonInvertingInput */ |
bogdanm | 0:9b334a45a8ff | 77 | |
bogdanm | 0:9b334a45a8ff | 78 | uint32_t Output; /*!< Selects the output redirection of the comparator. |
bogdanm | 0:9b334a45a8ff | 79 | This parameter can be a value of @ref COMP_Output */ |
bogdanm | 0:9b334a45a8ff | 80 | |
bogdanm | 0:9b334a45a8ff | 81 | uint32_t OutputPol; /*!< Selects the output polarity of the comparator. |
bogdanm | 0:9b334a45a8ff | 82 | This parameter can be a value of @ref COMP_OutputPolarity */ |
bogdanm | 0:9b334a45a8ff | 83 | |
bogdanm | 0:9b334a45a8ff | 84 | uint32_t Hysteresis; /*!< Selects the hysteresis voltage of the comparator. |
bogdanm | 0:9b334a45a8ff | 85 | This parameter can be a value of @ref COMP_Hysteresis */ |
bogdanm | 0:9b334a45a8ff | 86 | |
bogdanm | 0:9b334a45a8ff | 87 | uint32_t Mode; /*!< Selects the operating comsumption mode of the comparator |
bogdanm | 0:9b334a45a8ff | 88 | to adjust the speed/consumption. |
bogdanm | 0:9b334a45a8ff | 89 | This parameter can be a value of @ref COMP_Mode */ |
bogdanm | 0:9b334a45a8ff | 90 | |
bogdanm | 0:9b334a45a8ff | 91 | uint32_t WindowMode; /*!< Selects the window mode of the comparator 1 & 2. |
bogdanm | 0:9b334a45a8ff | 92 | This parameter can be a value of @ref COMP_WindowMode */ |
bogdanm | 0:9b334a45a8ff | 93 | |
bogdanm | 0:9b334a45a8ff | 94 | uint32_t TriggerMode; /*!< Selects the trigger mode of the comparator (interrupt mode). |
bogdanm | 0:9b334a45a8ff | 95 | This parameter can be a value of @ref COMP_TriggerMode */ |
bogdanm | 0:9b334a45a8ff | 96 | |
bogdanm | 0:9b334a45a8ff | 97 | }COMP_InitTypeDef; |
bogdanm | 0:9b334a45a8ff | 98 | |
bogdanm | 0:9b334a45a8ff | 99 | /** |
bogdanm | 0:9b334a45a8ff | 100 | * @brief COMP Handle Structure definition |
bogdanm | 0:9b334a45a8ff | 101 | */ |
bogdanm | 0:9b334a45a8ff | 102 | typedef struct |
bogdanm | 0:9b334a45a8ff | 103 | { |
bogdanm | 0:9b334a45a8ff | 104 | COMP_TypeDef *Instance; /*!< Register base address */ |
bogdanm | 0:9b334a45a8ff | 105 | COMP_InitTypeDef Init; /*!< COMP required parameters */ |
bogdanm | 0:9b334a45a8ff | 106 | HAL_LockTypeDef Lock; /*!< Locking object */ |
bogdanm | 0:9b334a45a8ff | 107 | __IO uint32_t State; /*!< COMP communication state |
bogdanm | 0:9b334a45a8ff | 108 | This parameter can be a value of @ref COMP_State */ |
bogdanm | 0:9b334a45a8ff | 109 | }COMP_HandleTypeDef; |
bogdanm | 0:9b334a45a8ff | 110 | |
bogdanm | 0:9b334a45a8ff | 111 | /** |
bogdanm | 0:9b334a45a8ff | 112 | * @} |
bogdanm | 0:9b334a45a8ff | 113 | */ |
bogdanm | 0:9b334a45a8ff | 114 | |
bogdanm | 0:9b334a45a8ff | 115 | /* Exported constants --------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 116 | /** @defgroup COMP_Exported_Constants COMP Exported Constants |
bogdanm | 0:9b334a45a8ff | 117 | * @{ |
bogdanm | 0:9b334a45a8ff | 118 | */ |
bogdanm | 0:9b334a45a8ff | 119 | |
bogdanm | 0:9b334a45a8ff | 120 | /** @defgroup COMP_State COMP State |
bogdanm | 0:9b334a45a8ff | 121 | * @{ |
bogdanm | 0:9b334a45a8ff | 122 | */ |
bogdanm | 0:9b334a45a8ff | 123 | #define HAL_COMP_STATE_RESET ((uint32_t)0x00000000) /*!< COMP not yet initialized or disabled */ |
bogdanm | 0:9b334a45a8ff | 124 | #define HAL_COMP_STATE_READY ((uint32_t)0x00000001) /*!< COMP initialized and ready for use */ |
bogdanm | 0:9b334a45a8ff | 125 | #define HAL_COMP_STATE_READY_LOCKED ((uint32_t)0x00000011) /*!< COMP initialized but the configuration is locked */ |
bogdanm | 0:9b334a45a8ff | 126 | #define HAL_COMP_STATE_BUSY ((uint32_t)0x00000002) /*!< COMP is running */ |
bogdanm | 0:9b334a45a8ff | 127 | #define HAL_COMP_STATE_BUSY_LOCKED ((uint32_t)0x00000012) /*!< COMP is running and the configuration is locked */ |
bogdanm | 0:9b334a45a8ff | 128 | /** |
bogdanm | 0:9b334a45a8ff | 129 | * @} |
bogdanm | 0:9b334a45a8ff | 130 | */ |
bogdanm | 0:9b334a45a8ff | 131 | |
bogdanm | 0:9b334a45a8ff | 132 | /** @defgroup COMP_OutputPolarity COMP OutputPolarity |
bogdanm | 0:9b334a45a8ff | 133 | * @{ |
bogdanm | 0:9b334a45a8ff | 134 | */ |
bogdanm | 0:9b334a45a8ff | 135 | #define COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output on GPIO isn't inverted */ |
bogdanm | 0:9b334a45a8ff | 136 | #define COMP_OUTPUTPOL_INVERTED COMP_CSR_COMP1POL /*!< COMP output on GPIO is inverted */ |
bogdanm | 0:9b334a45a8ff | 137 | /** |
bogdanm | 0:9b334a45a8ff | 138 | * @} |
bogdanm | 0:9b334a45a8ff | 139 | */ |
bogdanm | 0:9b334a45a8ff | 140 | |
bogdanm | 0:9b334a45a8ff | 141 | /** @defgroup COMP_Hysteresis COMP Hysteresis |
bogdanm | 0:9b334a45a8ff | 142 | * @{ |
bogdanm | 0:9b334a45a8ff | 143 | */ |
bogdanm | 0:9b334a45a8ff | 144 | #define COMP_HYSTERESIS_NONE ((uint32_t)0x00000000) /*!< No hysteresis */ |
bogdanm | 0:9b334a45a8ff | 145 | #define COMP_HYSTERESIS_LOW COMP_CSR_COMP1HYST_0 /*!< Hysteresis level low */ |
bogdanm | 0:9b334a45a8ff | 146 | #define COMP_HYSTERESIS_MEDIUM COMP_CSR_COMP1HYST_1 /*!< Hysteresis level medium */ |
bogdanm | 0:9b334a45a8ff | 147 | #define COMP_HYSTERESIS_HIGH COMP_CSR_COMP1HYST /*!< Hysteresis level high */ |
bogdanm | 0:9b334a45a8ff | 148 | /** |
bogdanm | 0:9b334a45a8ff | 149 | * @} |
bogdanm | 0:9b334a45a8ff | 150 | */ |
bogdanm | 0:9b334a45a8ff | 151 | |
bogdanm | 0:9b334a45a8ff | 152 | /** @defgroup COMP_Mode COMP Mode |
bogdanm | 0:9b334a45a8ff | 153 | * @{ |
bogdanm | 0:9b334a45a8ff | 154 | */ |
bogdanm | 0:9b334a45a8ff | 155 | /* Please refer to the electrical characteristics in the device datasheet for |
bogdanm | 0:9b334a45a8ff | 156 | the power consumption values */ |
bogdanm | 0:9b334a45a8ff | 157 | #define COMP_MODE_HIGHSPEED ((uint32_t)0x00000000) /*!< High Speed */ |
bogdanm | 0:9b334a45a8ff | 158 | #define COMP_MODE_MEDIUMSPEED COMP_CSR_COMP1MODE_0 /*!< Medium Speed */ |
bogdanm | 0:9b334a45a8ff | 159 | #define COMP_MODE_LOWPOWER COMP_CSR_COMP1MODE_1 /*!< Low power mode */ |
bogdanm | 0:9b334a45a8ff | 160 | #define COMP_MODE_ULTRALOWPOWER COMP_CSR_COMP1MODE /*!< Ultra-low power mode */ |
bogdanm | 0:9b334a45a8ff | 161 | /** |
bogdanm | 0:9b334a45a8ff | 162 | * @} |
bogdanm | 0:9b334a45a8ff | 163 | */ |
bogdanm | 0:9b334a45a8ff | 164 | |
bogdanm | 0:9b334a45a8ff | 165 | /** @defgroup COMP_InvertingInput COMP InvertingInput |
bogdanm | 0:9b334a45a8ff | 166 | * @{ |
bogdanm | 0:9b334a45a8ff | 167 | */ |
bogdanm | 0:9b334a45a8ff | 168 | |
bogdanm | 0:9b334a45a8ff | 169 | #define COMP_INVERTINGINPUT_1_4VREFINT ((uint32_t)0x00000000) /*!< 1/4 VREFINT connected to comparator inverting input */ |
bogdanm | 0:9b334a45a8ff | 170 | #define COMP_INVERTINGINPUT_1_2VREFINT COMP_CSR_COMP1INSEL_0 /*!< 1/2 VREFINT connected to comparator inverting input */ |
bogdanm | 0:9b334a45a8ff | 171 | #define COMP_INVERTINGINPUT_3_4VREFINT COMP_CSR_COMP1INSEL_1 /*!< 3/4 VREFINT connected to comparator inverting input */ |
bogdanm | 0:9b334a45a8ff | 172 | #define COMP_INVERTINGINPUT_VREFINT (COMP_CSR_COMP1INSEL_1|COMP_CSR_COMP1INSEL_0) /*!< VREFINT connected to comparator inverting input */ |
bogdanm | 0:9b334a45a8ff | 173 | #define COMP_INVERTINGINPUT_DAC1 COMP_CSR_COMP1INSEL_2 /*!< DAC_OUT1 (PA4) connected to comparator inverting input */ |
bogdanm | 0:9b334a45a8ff | 174 | #define COMP_INVERTINGINPUT_DAC1SWITCHCLOSED (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1SW1) /*!< DAC_OUT1 (PA4) connected to comparator inverting input |
bogdanm | 0:9b334a45a8ff | 175 | and close switch (PA0 for COMP1 only) */ |
bogdanm | 0:9b334a45a8ff | 176 | #define COMP_INVERTINGINPUT_DAC2 (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1INSEL_0) /*!< DAC_OUT2 (PA5) connected to comparator inverting input */ |
bogdanm | 0:9b334a45a8ff | 177 | #define COMP_INVERTINGINPUT_IO1 (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1INSEL_1) /*!< IO (PA0 for COMP1 and PA2 for COMP2) connected to comparator inverting input */ |
bogdanm | 0:9b334a45a8ff | 178 | /** |
bogdanm | 0:9b334a45a8ff | 179 | * @} |
bogdanm | 0:9b334a45a8ff | 180 | */ |
bogdanm | 0:9b334a45a8ff | 181 | |
bogdanm | 0:9b334a45a8ff | 182 | /** @defgroup COMP_NonInvertingInput COMP NonInvertingInput |
bogdanm | 0:9b334a45a8ff | 183 | * @{ |
bogdanm | 0:9b334a45a8ff | 184 | */ |
bogdanm | 0:9b334a45a8ff | 185 | #define COMP_NONINVERTINGINPUT_IO1 ((uint32_t)0x00000000) /*!< I/O1 (PA1 for COMP1, PA3 for COMP2) |
bogdanm | 0:9b334a45a8ff | 186 | connected to comparator non inverting input */ |
bogdanm | 0:9b334a45a8ff | 187 | #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED COMP_CSR_COMP1SW1 /*!< DAC ouput connected to comparator COMP1 non inverting input */ |
bogdanm | 0:9b334a45a8ff | 188 | /** |
bogdanm | 0:9b334a45a8ff | 189 | * @} |
bogdanm | 0:9b334a45a8ff | 190 | */ |
bogdanm | 0:9b334a45a8ff | 191 | |
bogdanm | 0:9b334a45a8ff | 192 | /** @defgroup COMP_Output COMP Output |
bogdanm | 0:9b334a45a8ff | 193 | * @{ |
bogdanm | 0:9b334a45a8ff | 194 | */ |
bogdanm | 0:9b334a45a8ff | 195 | |
bogdanm | 0:9b334a45a8ff | 196 | /* Output Redirection common for COMP1 and COMP2 */ |
bogdanm | 0:9b334a45a8ff | 197 | #define COMP_OUTPUT_NONE ((uint32_t)0x00000000) /*!< COMP output isn't connected to other peripherals */ |
bogdanm | 0:9b334a45a8ff | 198 | #define COMP_OUTPUT_TIM1BKIN COMP_CSR_COMP1OUTSEL_0 /*!< COMP output connected to TIM1 Break Input (BKIN) */ |
bogdanm | 0:9b334a45a8ff | 199 | #define COMP_OUTPUT_TIM1IC1 COMP_CSR_COMP1OUTSEL_1 /*!< COMP output connected to TIM1 Input Capture 1 */ |
bogdanm | 0:9b334a45a8ff | 200 | #define COMP_OUTPUT_TIM1OCREFCLR (COMP_CSR_COMP1OUTSEL_1|COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM1 OCREF Clear */ |
bogdanm | 0:9b334a45a8ff | 201 | #define COMP_OUTPUT_TIM2IC4 COMP_CSR_COMP1OUTSEL_2 /*!< COMP output connected to TIM2 Input Capture 4 */ |
bogdanm | 0:9b334a45a8ff | 202 | #define COMP_OUTPUT_TIM2OCREFCLR (COMP_CSR_COMP1OUTSEL_2|COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM2 OCREF Clear */ |
bogdanm | 0:9b334a45a8ff | 203 | #define COMP_OUTPUT_TIM3IC1 (COMP_CSR_COMP1OUTSEL_2|COMP_CSR_COMP1OUTSEL_1) /*!< COMP output connected to TIM3 Input Capture 1 */ |
bogdanm | 0:9b334a45a8ff | 204 | #define COMP_OUTPUT_TIM3OCREFCLR COMP_CSR_COMP1OUTSEL /*!< COMP output connected to TIM3 OCREF Clear */ |
bogdanm | 0:9b334a45a8ff | 205 | /** |
bogdanm | 0:9b334a45a8ff | 206 | * @} |
bogdanm | 0:9b334a45a8ff | 207 | */ |
bogdanm | 0:9b334a45a8ff | 208 | |
bogdanm | 0:9b334a45a8ff | 209 | /** @defgroup COMP_OutputLevel COMP OutputLevel |
bogdanm | 0:9b334a45a8ff | 210 | * @{ |
bogdanm | 0:9b334a45a8ff | 211 | */ |
bogdanm | 0:9b334a45a8ff | 212 | /* When output polarity is not inverted, comparator output is low when |
bogdanm | 0:9b334a45a8ff | 213 | the non-inverting input is at a lower voltage than the inverting input*/ |
bogdanm | 0:9b334a45a8ff | 214 | #define COMP_OUTPUTLEVEL_LOW ((uint32_t)0x00000000) |
bogdanm | 0:9b334a45a8ff | 215 | /* When output polarity is not inverted, comparator output is high when |
bogdanm | 0:9b334a45a8ff | 216 | the non-inverting input is at a higher voltage than the inverting input */ |
bogdanm | 0:9b334a45a8ff | 217 | #define COMP_OUTPUTLEVEL_HIGH COMP_CSR_COMP1OUT |
bogdanm | 0:9b334a45a8ff | 218 | /** |
bogdanm | 0:9b334a45a8ff | 219 | * @} |
bogdanm | 0:9b334a45a8ff | 220 | */ |
bogdanm | 0:9b334a45a8ff | 221 | |
bogdanm | 0:9b334a45a8ff | 222 | /** @defgroup COMP_TriggerMode COMP TriggerMode |
bogdanm | 0:9b334a45a8ff | 223 | * @{ |
bogdanm | 0:9b334a45a8ff | 224 | */ |
bogdanm | 0:9b334a45a8ff | 225 | #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< No External Interrupt trigger detection */ |
bogdanm | 0:9b334a45a8ff | 226 | #define COMP_TRIGGERMODE_IT_RISING ((uint32_t)0x00000001) /*!< External Interrupt Mode with Rising edge trigger detection */ |
bogdanm | 0:9b334a45a8ff | 227 | #define COMP_TRIGGERMODE_IT_FALLING ((uint32_t)0x00000002) /*!< External Interrupt Mode with Falling edge trigger detection */ |
bogdanm | 0:9b334a45a8ff | 228 | #define COMP_TRIGGERMODE_IT_RISING_FALLING ((uint32_t)0x00000003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ |
bogdanm | 0:9b334a45a8ff | 229 | #define COMP_TRIGGERMODE_EVENT_RISING ((uint32_t)0x00000010) /*!< Event Mode with Rising edge trigger detection */ |
bogdanm | 0:9b334a45a8ff | 230 | #define COMP_TRIGGERMODE_EVENT_FALLING ((uint32_t)0x00000020) /*!< Event Mode with Falling edge trigger detection */ |
bogdanm | 0:9b334a45a8ff | 231 | #define COMP_TRIGGERMODE_EVENT_RISING_FALLING ((uint32_t)0x00000030) /*!< Event Mode with Rising/Falling edge trigger detection */ |
bogdanm | 0:9b334a45a8ff | 232 | /** |
bogdanm | 0:9b334a45a8ff | 233 | * @} |
bogdanm | 0:9b334a45a8ff | 234 | */ |
bogdanm | 0:9b334a45a8ff | 235 | |
bogdanm | 0:9b334a45a8ff | 236 | /** @defgroup COMP_WindowMode COMP WindowMode |
bogdanm | 0:9b334a45a8ff | 237 | * @{ |
bogdanm | 0:9b334a45a8ff | 238 | */ |
bogdanm | 0:9b334a45a8ff | 239 | #define COMP_WINDOWMODE_DISABLE ((uint32_t)0x00000000) /*!< Window mode disabled */ |
bogdanm | 0:9b334a45a8ff | 240 | #define COMP_WINDOWMODE_ENABLE COMP_CSR_WNDWEN /*!< Window mode enabled: non inverting input of comparator 2 |
bogdanm | 0:9b334a45a8ff | 241 | is connected to the non inverting input of comparator 1 (PA1) */ |
bogdanm | 0:9b334a45a8ff | 242 | /** |
bogdanm | 0:9b334a45a8ff | 243 | * @} |
bogdanm | 0:9b334a45a8ff | 244 | */ |
bogdanm | 0:9b334a45a8ff | 245 | |
bogdanm | 0:9b334a45a8ff | 246 | /** @defgroup COMP_Flag COMP Flag |
bogdanm | 0:9b334a45a8ff | 247 | * @{ |
bogdanm | 0:9b334a45a8ff | 248 | */ |
bogdanm | 0:9b334a45a8ff | 249 | #define COMP_FLAG_LOCK ((uint32_t)COMP_CSR_COMPxLOCK) /*!< Lock flag */ |
bogdanm | 0:9b334a45a8ff | 250 | |
bogdanm | 0:9b334a45a8ff | 251 | /** |
bogdanm | 0:9b334a45a8ff | 252 | * @} |
bogdanm | 0:9b334a45a8ff | 253 | */ |
bogdanm | 0:9b334a45a8ff | 254 | |
bogdanm | 0:9b334a45a8ff | 255 | /** |
bogdanm | 0:9b334a45a8ff | 256 | * @} |
bogdanm | 0:9b334a45a8ff | 257 | */ |
bogdanm | 0:9b334a45a8ff | 258 | |
bogdanm | 0:9b334a45a8ff | 259 | /* Exported macros -----------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 260 | /** @defgroup COMP_Exported_Macros COMP Exported Macros |
bogdanm | 0:9b334a45a8ff | 261 | * @{ |
bogdanm | 0:9b334a45a8ff | 262 | */ |
bogdanm | 0:9b334a45a8ff | 263 | |
bogdanm | 0:9b334a45a8ff | 264 | /** @brief Reset COMP handle state |
bogdanm | 0:9b334a45a8ff | 265 | * @param __HANDLE__: COMP handle. |
bogdanm | 0:9b334a45a8ff | 266 | * @retval None |
bogdanm | 0:9b334a45a8ff | 267 | */ |
bogdanm | 0:9b334a45a8ff | 268 | #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET) |
bogdanm | 0:9b334a45a8ff | 269 | |
bogdanm | 0:9b334a45a8ff | 270 | /** |
bogdanm | 0:9b334a45a8ff | 271 | * @brief Enable the specified comparator. |
bogdanm | 0:9b334a45a8ff | 272 | * @param __HANDLE__: COMP handle. |
bogdanm | 0:9b334a45a8ff | 273 | * @retval None |
bogdanm | 0:9b334a45a8ff | 274 | */ |
bogdanm | 0:9b334a45a8ff | 275 | #define __HAL_COMP_ENABLE(__HANDLE__) (((__HANDLE__)->Instance == COMP1) ? \ |
bogdanm | 0:9b334a45a8ff | 276 | SET_BIT(COMP->CSR, COMP_CSR_COMP1EN) : \ |
bogdanm | 0:9b334a45a8ff | 277 | SET_BIT(COMP->CSR, COMP_CSR_COMP2EN)) |
bogdanm | 0:9b334a45a8ff | 278 | |
bogdanm | 0:9b334a45a8ff | 279 | /** |
bogdanm | 0:9b334a45a8ff | 280 | * @brief Disable the specified comparator. |
bogdanm | 0:9b334a45a8ff | 281 | * @param __HANDLE__: COMP handle. |
bogdanm | 0:9b334a45a8ff | 282 | * @retval None |
bogdanm | 0:9b334a45a8ff | 283 | */ |
bogdanm | 0:9b334a45a8ff | 284 | #define __HAL_COMP_DISABLE(__HANDLE__) (((__HANDLE__)->Instance == COMP1) ? \ |
bogdanm | 0:9b334a45a8ff | 285 | CLEAR_BIT(COMP->CSR, COMP_CSR_COMP1EN) : \ |
bogdanm | 0:9b334a45a8ff | 286 | CLEAR_BIT(COMP->CSR, COMP_CSR_COMP2EN)) |
bogdanm | 0:9b334a45a8ff | 287 | |
bogdanm | 0:9b334a45a8ff | 288 | /** |
bogdanm | 0:9b334a45a8ff | 289 | * @brief Lock the specified comparator configuration. |
bogdanm | 0:9b334a45a8ff | 290 | * @param __HANDLE__: COMP handle. |
bogdanm | 0:9b334a45a8ff | 291 | * @retval None |
bogdanm | 0:9b334a45a8ff | 292 | */ |
bogdanm | 0:9b334a45a8ff | 293 | #define __HAL_COMP_LOCK(__HANDLE__) (((__HANDLE__)->Instance == COMP1) ? \ |
bogdanm | 0:9b334a45a8ff | 294 | SET_BIT(COMP->CSR, COMP_CSR_COMP1LOCK) : \ |
bogdanm | 0:9b334a45a8ff | 295 | SET_BIT(COMP->CSR, COMP_CSR_COMP2LOCK)) |
bogdanm | 0:9b334a45a8ff | 296 | |
bogdanm | 0:9b334a45a8ff | 297 | /** |
bogdanm | 0:9b334a45a8ff | 298 | * @brief Enable the COMP1 EXTI line rising edge trigger. |
bogdanm | 0:9b334a45a8ff | 299 | * @retval None |
bogdanm | 0:9b334a45a8ff | 300 | */ |
bogdanm | 0:9b334a45a8ff | 301 | #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP1) |
bogdanm | 0:9b334a45a8ff | 302 | |
bogdanm | 0:9b334a45a8ff | 303 | /** |
bogdanm | 0:9b334a45a8ff | 304 | * @brief Disable the COMP1 EXTI line rising edge trigger. |
bogdanm | 0:9b334a45a8ff | 305 | * @retval None |
bogdanm | 0:9b334a45a8ff | 306 | */ |
bogdanm | 0:9b334a45a8ff | 307 | #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP1) |
bogdanm | 0:9b334a45a8ff | 308 | |
bogdanm | 0:9b334a45a8ff | 309 | /** |
bogdanm | 0:9b334a45a8ff | 310 | * @brief Enable the COMP1 EXTI line falling edge trigger. |
bogdanm | 0:9b334a45a8ff | 311 | * @retval None |
bogdanm | 0:9b334a45a8ff | 312 | */ |
bogdanm | 0:9b334a45a8ff | 313 | #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP1) |
bogdanm | 0:9b334a45a8ff | 314 | |
bogdanm | 0:9b334a45a8ff | 315 | /** |
bogdanm | 0:9b334a45a8ff | 316 | * @brief Disable the COMP1 EXTI line falling edge trigger. |
bogdanm | 0:9b334a45a8ff | 317 | * @retval None |
bogdanm | 0:9b334a45a8ff | 318 | */ |
bogdanm | 0:9b334a45a8ff | 319 | #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP1) |
bogdanm | 0:9b334a45a8ff | 320 | |
bogdanm | 0:9b334a45a8ff | 321 | /** |
bogdanm | 0:9b334a45a8ff | 322 | * @brief Enable the COMP1 EXTI line rising & falling edge trigger. |
bogdanm | 0:9b334a45a8ff | 323 | * @retval None |
bogdanm | 0:9b334a45a8ff | 324 | */ |
bogdanm | 0:9b334a45a8ff | 325 | #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ |
bogdanm | 0:9b334a45a8ff | 326 | __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE(); \ |
bogdanm | 0:9b334a45a8ff | 327 | __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE(); \ |
bogdanm | 0:9b334a45a8ff | 328 | } while(0) |
bogdanm | 0:9b334a45a8ff | 329 | |
bogdanm | 0:9b334a45a8ff | 330 | /** |
bogdanm | 0:9b334a45a8ff | 331 | * @brief Disable the COMP1 EXTI line rising & falling edge trigger. |
bogdanm | 0:9b334a45a8ff | 332 | * @retval None |
bogdanm | 0:9b334a45a8ff | 333 | */ |
bogdanm | 0:9b334a45a8ff | 334 | #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ |
bogdanm | 0:9b334a45a8ff | 335 | __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE(); \ |
bogdanm | 0:9b334a45a8ff | 336 | __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE(); \ |
bogdanm | 0:9b334a45a8ff | 337 | } while(0) |
bogdanm | 0:9b334a45a8ff | 338 | |
bogdanm | 0:9b334a45a8ff | 339 | /** |
bogdanm | 0:9b334a45a8ff | 340 | * @brief Enable the COMP1 EXTI line in interrupt mode. |
bogdanm | 0:9b334a45a8ff | 341 | * @retval None |
bogdanm | 0:9b334a45a8ff | 342 | */ |
bogdanm | 0:9b334a45a8ff | 343 | #define __HAL_COMP_COMP1_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP1) |
bogdanm | 0:9b334a45a8ff | 344 | |
bogdanm | 0:9b334a45a8ff | 345 | /** |
bogdanm | 0:9b334a45a8ff | 346 | * @brief Disable the COMP1 EXTI line in interrupt mode. |
bogdanm | 0:9b334a45a8ff | 347 | * @retval None |
bogdanm | 0:9b334a45a8ff | 348 | */ |
bogdanm | 0:9b334a45a8ff | 349 | #define __HAL_COMP_COMP1_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP1) |
bogdanm | 0:9b334a45a8ff | 350 | |
bogdanm | 0:9b334a45a8ff | 351 | /** |
bogdanm | 0:9b334a45a8ff | 352 | * @brief Generate a software interrupt on the COMP1 EXTI line. |
bogdanm | 0:9b334a45a8ff | 353 | * @retval None |
bogdanm | 0:9b334a45a8ff | 354 | */ |
bogdanm | 0:9b334a45a8ff | 355 | #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, COMP_EXTI_LINE_COMP1) |
bogdanm | 0:9b334a45a8ff | 356 | |
bogdanm | 0:9b334a45a8ff | 357 | /** |
bogdanm | 0:9b334a45a8ff | 358 | * @brief Enable the COMP1 EXTI Line in event mode. |
bogdanm | 0:9b334a45a8ff | 359 | * @retval None |
bogdanm | 0:9b334a45a8ff | 360 | */ |
bogdanm | 0:9b334a45a8ff | 361 | #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP1) |
bogdanm | 0:9b334a45a8ff | 362 | |
bogdanm | 0:9b334a45a8ff | 363 | /** |
bogdanm | 0:9b334a45a8ff | 364 | * @brief Disable the COMP1 EXTI Line in event mode. |
bogdanm | 0:9b334a45a8ff | 365 | * @retval None |
bogdanm | 0:9b334a45a8ff | 366 | */ |
bogdanm | 0:9b334a45a8ff | 367 | #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP1) |
bogdanm | 0:9b334a45a8ff | 368 | |
bogdanm | 0:9b334a45a8ff | 369 | /** |
bogdanm | 0:9b334a45a8ff | 370 | * @brief Check whether the COMP1 EXTI line flag is set or not. |
bogdanm | 0:9b334a45a8ff | 371 | * @retval RESET or SET |
bogdanm | 0:9b334a45a8ff | 372 | */ |
bogdanm | 0:9b334a45a8ff | 373 | #define __HAL_COMP_COMP1_EXTI_GET_FLAG() READ_BIT(EXTI->PR, COMP_EXTI_LINE_COMP1) |
bogdanm | 0:9b334a45a8ff | 374 | |
bogdanm | 0:9b334a45a8ff | 375 | /** |
bogdanm | 0:9b334a45a8ff | 376 | * @brief Clear the COMP1 EXTI flag. |
bogdanm | 0:9b334a45a8ff | 377 | * @retval None |
bogdanm | 0:9b334a45a8ff | 378 | */ |
bogdanm | 0:9b334a45a8ff | 379 | #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR, COMP_EXTI_LINE_COMP1) |
bogdanm | 0:9b334a45a8ff | 380 | |
bogdanm | 0:9b334a45a8ff | 381 | /** |
bogdanm | 0:9b334a45a8ff | 382 | * @brief Enable the COMP2 EXTI line rising edge trigger. |
bogdanm | 0:9b334a45a8ff | 383 | * @retval None |
bogdanm | 0:9b334a45a8ff | 384 | */ |
bogdanm | 0:9b334a45a8ff | 385 | #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP2) |
bogdanm | 0:9b334a45a8ff | 386 | |
bogdanm | 0:9b334a45a8ff | 387 | /** |
bogdanm | 0:9b334a45a8ff | 388 | * @brief Disable the COMP2 EXTI line rising edge trigger. |
bogdanm | 0:9b334a45a8ff | 389 | * @retval None |
bogdanm | 0:9b334a45a8ff | 390 | */ |
bogdanm | 0:9b334a45a8ff | 391 | #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP2) |
bogdanm | 0:9b334a45a8ff | 392 | |
bogdanm | 0:9b334a45a8ff | 393 | /** |
bogdanm | 0:9b334a45a8ff | 394 | * @brief Enable the COMP2 EXTI line falling edge trigger. |
bogdanm | 0:9b334a45a8ff | 395 | * @retval None |
bogdanm | 0:9b334a45a8ff | 396 | */ |
bogdanm | 0:9b334a45a8ff | 397 | #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP2) |
bogdanm | 0:9b334a45a8ff | 398 | |
bogdanm | 0:9b334a45a8ff | 399 | /** |
bogdanm | 0:9b334a45a8ff | 400 | * @brief Disable the COMP2 EXTI line falling edge trigger. |
bogdanm | 0:9b334a45a8ff | 401 | * @retval None |
bogdanm | 0:9b334a45a8ff | 402 | */ |
bogdanm | 0:9b334a45a8ff | 403 | #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP2) |
bogdanm | 0:9b334a45a8ff | 404 | |
bogdanm | 0:9b334a45a8ff | 405 | /** |
bogdanm | 0:9b334a45a8ff | 406 | * @brief Enable the COMP2 EXTI line rising & falling edge trigger. |
bogdanm | 0:9b334a45a8ff | 407 | * @retval None |
bogdanm | 0:9b334a45a8ff | 408 | */ |
bogdanm | 0:9b334a45a8ff | 409 | #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ |
bogdanm | 0:9b334a45a8ff | 410 | __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE(); \ |
bogdanm | 0:9b334a45a8ff | 411 | __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE(); \ |
bogdanm | 0:9b334a45a8ff | 412 | } while(0) |
bogdanm | 0:9b334a45a8ff | 413 | |
bogdanm | 0:9b334a45a8ff | 414 | /** |
bogdanm | 0:9b334a45a8ff | 415 | * @brief Disable the COMP2 EXTI line rising & falling edge trigger. |
bogdanm | 0:9b334a45a8ff | 416 | * @retval None |
bogdanm | 0:9b334a45a8ff | 417 | */ |
bogdanm | 0:9b334a45a8ff | 418 | #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ |
bogdanm | 0:9b334a45a8ff | 419 | __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE(); \ |
bogdanm | 0:9b334a45a8ff | 420 | __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE(); \ |
bogdanm | 0:9b334a45a8ff | 421 | } while(0) |
bogdanm | 0:9b334a45a8ff | 422 | |
bogdanm | 0:9b334a45a8ff | 423 | /** |
bogdanm | 0:9b334a45a8ff | 424 | * @brief Enable the COMP2 EXTI line in interrupt mode. |
bogdanm | 0:9b334a45a8ff | 425 | * @retval None |
bogdanm | 0:9b334a45a8ff | 426 | */ |
bogdanm | 0:9b334a45a8ff | 427 | #define __HAL_COMP_COMP2_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP2) |
bogdanm | 0:9b334a45a8ff | 428 | |
bogdanm | 0:9b334a45a8ff | 429 | /** |
bogdanm | 0:9b334a45a8ff | 430 | * @brief Disable the COMP2 EXTI line in interrupt mode. |
bogdanm | 0:9b334a45a8ff | 431 | * @retval None |
bogdanm | 0:9b334a45a8ff | 432 | */ |
bogdanm | 0:9b334a45a8ff | 433 | #define __HAL_COMP_COMP2_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP2) |
bogdanm | 0:9b334a45a8ff | 434 | |
bogdanm | 0:9b334a45a8ff | 435 | /** |
bogdanm | 0:9b334a45a8ff | 436 | * @brief Generate a software interrupt on the COMP2 EXTI line. |
bogdanm | 0:9b334a45a8ff | 437 | * @retval None |
bogdanm | 0:9b334a45a8ff | 438 | */ |
bogdanm | 0:9b334a45a8ff | 439 | #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, COMP_EXTI_LINE_COMP2) |
bogdanm | 0:9b334a45a8ff | 440 | |
bogdanm | 0:9b334a45a8ff | 441 | /** |
bogdanm | 0:9b334a45a8ff | 442 | * @brief Enable the COMP2 EXTI Line in event mode. |
bogdanm | 0:9b334a45a8ff | 443 | * @retval None |
bogdanm | 0:9b334a45a8ff | 444 | */ |
bogdanm | 0:9b334a45a8ff | 445 | #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP2) |
bogdanm | 0:9b334a45a8ff | 446 | |
bogdanm | 0:9b334a45a8ff | 447 | /** |
bogdanm | 0:9b334a45a8ff | 448 | * @brief Disable the COMP2 EXTI Line in event mode. |
bogdanm | 0:9b334a45a8ff | 449 | * @retval None |
bogdanm | 0:9b334a45a8ff | 450 | */ |
bogdanm | 0:9b334a45a8ff | 451 | #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP2) |
bogdanm | 0:9b334a45a8ff | 452 | |
bogdanm | 0:9b334a45a8ff | 453 | /** |
bogdanm | 0:9b334a45a8ff | 454 | * @brief Check whether the COMP2 EXTI line flag is set or not. |
bogdanm | 0:9b334a45a8ff | 455 | * @retval RESET or SET |
bogdanm | 0:9b334a45a8ff | 456 | */ |
bogdanm | 0:9b334a45a8ff | 457 | #define __HAL_COMP_COMP2_EXTI_GET_FLAG() READ_BIT(EXTI->PR, COMP_EXTI_LINE_COMP2) |
bogdanm | 0:9b334a45a8ff | 458 | |
bogdanm | 0:9b334a45a8ff | 459 | /** |
bogdanm | 0:9b334a45a8ff | 460 | * @brief Clear the COMP2 EXTI flag. |
bogdanm | 0:9b334a45a8ff | 461 | * @retval None |
bogdanm | 0:9b334a45a8ff | 462 | */ |
bogdanm | 0:9b334a45a8ff | 463 | #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR, COMP_EXTI_LINE_COMP2) |
bogdanm | 0:9b334a45a8ff | 464 | |
bogdanm | 0:9b334a45a8ff | 465 | /** @brief Check whether the specified COMP flag is set or not. |
bogdanm | 0:9b334a45a8ff | 466 | * @param __HANDLE__: specifies the COMP Handle. |
bogdanm | 0:9b334a45a8ff | 467 | * @param __FLAG__: specifies the flag to check. |
bogdanm | 0:9b334a45a8ff | 468 | * This parameter can be one of the following values: |
bogdanm | 0:9b334a45a8ff | 469 | * @arg COMP_FLAG_LOCK: lock flag |
bogdanm | 0:9b334a45a8ff | 470 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
bogdanm | 0:9b334a45a8ff | 471 | */ |
bogdanm | 0:9b334a45a8ff | 472 | #define __HAL_COMP_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->CSR & (__FLAG__)) == (__FLAG__)) |
bogdanm | 0:9b334a45a8ff | 473 | |
bogdanm | 0:9b334a45a8ff | 474 | /** |
bogdanm | 0:9b334a45a8ff | 475 | * @} |
bogdanm | 0:9b334a45a8ff | 476 | */ |
bogdanm | 0:9b334a45a8ff | 477 | |
bogdanm | 0:9b334a45a8ff | 478 | /* Exported functions --------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 479 | /** @addtogroup COMP_Exported_Functions COMP Exported Functions |
bogdanm | 0:9b334a45a8ff | 480 | * @{ |
bogdanm | 0:9b334a45a8ff | 481 | */ |
bogdanm | 0:9b334a45a8ff | 482 | /** @addtogroup COMP_Exported_Functions_Group1 Initialization/de-initialization functions |
bogdanm | 0:9b334a45a8ff | 483 | * @brief Initialization and Configuration functions |
bogdanm | 0:9b334a45a8ff | 484 | * @{ |
bogdanm | 0:9b334a45a8ff | 485 | */ |
bogdanm | 0:9b334a45a8ff | 486 | /* Initialization and de-initialization functions ****************************/ |
bogdanm | 0:9b334a45a8ff | 487 | HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 488 | HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 489 | void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 490 | void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 491 | /** |
bogdanm | 0:9b334a45a8ff | 492 | * @} |
bogdanm | 0:9b334a45a8ff | 493 | */ |
bogdanm | 0:9b334a45a8ff | 494 | |
bogdanm | 0:9b334a45a8ff | 495 | /** @addtogroup COMP_Exported_Functions_Group2 I/O operation functions |
bogdanm | 0:9b334a45a8ff | 496 | * @brief Data transfers functions |
bogdanm | 0:9b334a45a8ff | 497 | * @{ |
bogdanm | 0:9b334a45a8ff | 498 | */ |
bogdanm | 0:9b334a45a8ff | 499 | /* IO operation functions *****************************************************/ |
bogdanm | 0:9b334a45a8ff | 500 | HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 501 | HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 502 | HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 503 | HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 504 | void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 505 | /** |
bogdanm | 0:9b334a45a8ff | 506 | * @} |
bogdanm | 0:9b334a45a8ff | 507 | */ |
bogdanm | 0:9b334a45a8ff | 508 | |
bogdanm | 0:9b334a45a8ff | 509 | /** @addtogroup COMP_Exported_Functions_Group3 Peripheral Control functions |
bogdanm | 0:9b334a45a8ff | 510 | * @brief management functions |
bogdanm | 0:9b334a45a8ff | 511 | * @{ |
bogdanm | 0:9b334a45a8ff | 512 | */ |
bogdanm | 0:9b334a45a8ff | 513 | /* Peripheral Control functions ***********************************************/ |
bogdanm | 0:9b334a45a8ff | 514 | HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 515 | uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 516 | |
bogdanm | 0:9b334a45a8ff | 517 | /* Callback in Interrupt mode */ |
bogdanm | 0:9b334a45a8ff | 518 | void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 519 | /** |
bogdanm | 0:9b334a45a8ff | 520 | * @} |
bogdanm | 0:9b334a45a8ff | 521 | */ |
bogdanm | 0:9b334a45a8ff | 522 | |
bogdanm | 0:9b334a45a8ff | 523 | /** @addtogroup COMP_Exported_Functions_Group4 Peripheral State functions |
bogdanm | 0:9b334a45a8ff | 524 | * @brief Peripheral State functions |
bogdanm | 0:9b334a45a8ff | 525 | * @{ |
bogdanm | 0:9b334a45a8ff | 526 | */ |
bogdanm | 0:9b334a45a8ff | 527 | /* Peripheral State and Error functions ***************************************/ |
bogdanm | 0:9b334a45a8ff | 528 | uint32_t HAL_COMP_GetState(COMP_HandleTypeDef *hcomp); |
bogdanm | 0:9b334a45a8ff | 529 | /** |
bogdanm | 0:9b334a45a8ff | 530 | * @} |
bogdanm | 0:9b334a45a8ff | 531 | */ |
bogdanm | 0:9b334a45a8ff | 532 | |
bogdanm | 0:9b334a45a8ff | 533 | /** |
bogdanm | 0:9b334a45a8ff | 534 | * @} |
bogdanm | 0:9b334a45a8ff | 535 | */ |
bogdanm | 0:9b334a45a8ff | 536 | |
bogdanm | 0:9b334a45a8ff | 537 | /* Private types -------------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 538 | /* Private constants ---------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 539 | /** @defgroup COMP_Private_Constants COMP Private Constants |
bogdanm | 0:9b334a45a8ff | 540 | * @{ |
bogdanm | 0:9b334a45a8ff | 541 | */ |
bogdanm | 0:9b334a45a8ff | 542 | /** @defgroup COMP_ExtiLine COMP EXTI Lines |
bogdanm | 0:9b334a45a8ff | 543 | * Elements values convention: XXXX0000 |
bogdanm | 0:9b334a45a8ff | 544 | * - XXXX : Interrupt mask in the EMR/IMR/RTSR/FTSR register |
bogdanm | 0:9b334a45a8ff | 545 | * @{ |
bogdanm | 0:9b334a45a8ff | 546 | */ |
bogdanm | 0:9b334a45a8ff | 547 | #define COMP_EXTI_LINE_COMP1 ((uint32_t)EXTI_IMR_MR21) /*!< EXTI line 21 connected to COMP1 output */ |
bogdanm | 0:9b334a45a8ff | 548 | #define COMP_EXTI_LINE_COMP2 ((uint32_t)EXTI_IMR_MR22) /*!< EXTI line 22 connected to COMP2 output */ |
bogdanm | 0:9b334a45a8ff | 549 | |
bogdanm | 0:9b334a45a8ff | 550 | /** |
bogdanm | 0:9b334a45a8ff | 551 | * @} |
bogdanm | 0:9b334a45a8ff | 552 | */ |
bogdanm | 0:9b334a45a8ff | 553 | |
bogdanm | 0:9b334a45a8ff | 554 | /** |
bogdanm | 0:9b334a45a8ff | 555 | * @} |
bogdanm | 0:9b334a45a8ff | 556 | */ |
bogdanm | 0:9b334a45a8ff | 557 | |
bogdanm | 0:9b334a45a8ff | 558 | /* Private macros ------------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 559 | /** @defgroup COMP_Private_Macros COMP Private Macros |
bogdanm | 0:9b334a45a8ff | 560 | * @{ |
bogdanm | 0:9b334a45a8ff | 561 | */ |
bogdanm | 0:9b334a45a8ff | 562 | /** @defgroup COMP_GET_EXTI_LINE COMP Private macros to get EXTI line associated with Comparators |
bogdanm | 0:9b334a45a8ff | 563 | * @{ |
bogdanm | 0:9b334a45a8ff | 564 | */ |
bogdanm | 0:9b334a45a8ff | 565 | /** |
bogdanm | 0:9b334a45a8ff | 566 | * @brief Get the specified EXTI line for a comparator instance. |
bogdanm | 0:9b334a45a8ff | 567 | * @param __INSTANCE__: specifies the COMP instance. |
bogdanm | 0:9b334a45a8ff | 568 | * @retval value of @ref COMP_ExtiLine |
bogdanm | 0:9b334a45a8ff | 569 | */ |
bogdanm | 0:9b334a45a8ff | 570 | #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 : \ |
bogdanm | 0:9b334a45a8ff | 571 | COMP_EXTI_LINE_COMP2) |
bogdanm | 0:9b334a45a8ff | 572 | /** |
bogdanm | 0:9b334a45a8ff | 573 | * @} |
bogdanm | 0:9b334a45a8ff | 574 | */ |
bogdanm | 0:9b334a45a8ff | 575 | |
bogdanm | 0:9b334a45a8ff | 576 | /** @defgroup COMP_IS_COMP_Definitions COMP Private macros to check input parameters |
bogdanm | 0:9b334a45a8ff | 577 | * @{ |
bogdanm | 0:9b334a45a8ff | 578 | */ |
bogdanm | 0:9b334a45a8ff | 579 | |
bogdanm | 0:9b334a45a8ff | 580 | #define IS_COMP_OUTPUTPOL(POL) (((POL) == COMP_OUTPUTPOL_NONINVERTED) || \ |
bogdanm | 0:9b334a45a8ff | 581 | ((POL) == COMP_OUTPUTPOL_INVERTED)) |
bogdanm | 0:9b334a45a8ff | 582 | |
bogdanm | 0:9b334a45a8ff | 583 | #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_HYSTERESIS_NONE) || \ |
bogdanm | 0:9b334a45a8ff | 584 | ((HYSTERESIS) == COMP_HYSTERESIS_LOW) || \ |
bogdanm | 0:9b334a45a8ff | 585 | ((HYSTERESIS) == COMP_HYSTERESIS_MEDIUM) || \ |
bogdanm | 0:9b334a45a8ff | 586 | ((HYSTERESIS) == COMP_HYSTERESIS_HIGH)) |
bogdanm | 0:9b334a45a8ff | 587 | |
bogdanm | 0:9b334a45a8ff | 588 | #define IS_COMP_MODE(MODE) (((MODE) == COMP_MODE_HIGHSPEED) || \ |
bogdanm | 0:9b334a45a8ff | 589 | ((MODE) == COMP_MODE_MEDIUMSPEED) || \ |
bogdanm | 0:9b334a45a8ff | 590 | ((MODE) == COMP_MODE_LOWPOWER) || \ |
bogdanm | 0:9b334a45a8ff | 591 | ((MODE) == COMP_MODE_ULTRALOWPOWER)) |
bogdanm | 0:9b334a45a8ff | 592 | |
bogdanm | 0:9b334a45a8ff | 593 | #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \ |
bogdanm | 0:9b334a45a8ff | 594 | ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \ |
bogdanm | 0:9b334a45a8ff | 595 | ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \ |
bogdanm | 0:9b334a45a8ff | 596 | ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \ |
bogdanm | 0:9b334a45a8ff | 597 | ((INPUT) == COMP_INVERTINGINPUT_DAC1) || \ |
bogdanm | 0:9b334a45a8ff | 598 | ((INPUT) == COMP_INVERTINGINPUT_DAC1SWITCHCLOSED) || \ |
bogdanm | 0:9b334a45a8ff | 599 | ((INPUT) == COMP_INVERTINGINPUT_DAC2) || \ |
bogdanm | 0:9b334a45a8ff | 600 | ((INPUT) == COMP_INVERTINGINPUT_IO1)) |
bogdanm | 0:9b334a45a8ff | 601 | |
bogdanm | 0:9b334a45a8ff | 602 | #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \ |
bogdanm | 0:9b334a45a8ff | 603 | ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED)) |
bogdanm | 0:9b334a45a8ff | 604 | |
bogdanm | 0:9b334a45a8ff | 605 | #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE) || \ |
bogdanm | 0:9b334a45a8ff | 606 | ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \ |
bogdanm | 0:9b334a45a8ff | 607 | ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \ |
bogdanm | 0:9b334a45a8ff | 608 | ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \ |
bogdanm | 0:9b334a45a8ff | 609 | ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \ |
bogdanm | 0:9b334a45a8ff | 610 | ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \ |
bogdanm | 0:9b334a45a8ff | 611 | ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \ |
bogdanm | 0:9b334a45a8ff | 612 | ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR)) |
bogdanm | 0:9b334a45a8ff | 613 | |
bogdanm | 0:9b334a45a8ff | 614 | #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLE) || \ |
bogdanm | 0:9b334a45a8ff | 615 | ((WINDOWMODE) == COMP_WINDOWMODE_ENABLE)) |
bogdanm | 0:9b334a45a8ff | 616 | |
bogdanm | 0:9b334a45a8ff | 617 | #define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \ |
bogdanm | 0:9b334a45a8ff | 618 | ((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \ |
bogdanm | 0:9b334a45a8ff | 619 | ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \ |
bogdanm | 0:9b334a45a8ff | 620 | ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \ |
bogdanm | 0:9b334a45a8ff | 621 | ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \ |
bogdanm | 0:9b334a45a8ff | 622 | ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \ |
bogdanm | 0:9b334a45a8ff | 623 | ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING)) |
bogdanm | 0:9b334a45a8ff | 624 | /** |
bogdanm | 0:9b334a45a8ff | 625 | * @} |
bogdanm | 0:9b334a45a8ff | 626 | */ |
bogdanm | 0:9b334a45a8ff | 627 | |
bogdanm | 0:9b334a45a8ff | 628 | /** @defgroup COMP_Lock COMP Lock |
bogdanm | 0:9b334a45a8ff | 629 | * @{ |
bogdanm | 0:9b334a45a8ff | 630 | */ |
bogdanm | 0:9b334a45a8ff | 631 | #define COMP_LOCK_DISABLE ((uint32_t)0x00000000) |
bogdanm | 0:9b334a45a8ff | 632 | #define COMP_LOCK_ENABLE COMP_CSR_COMP1LOCK |
bogdanm | 0:9b334a45a8ff | 633 | |
bogdanm | 0:9b334a45a8ff | 634 | #define COMP_STATE_BIT_LOCK ((uint32_t)0x10) |
bogdanm | 0:9b334a45a8ff | 635 | /** |
bogdanm | 0:9b334a45a8ff | 636 | * @} |
bogdanm | 0:9b334a45a8ff | 637 | */ |
bogdanm | 0:9b334a45a8ff | 638 | |
bogdanm | 0:9b334a45a8ff | 639 | /** |
bogdanm | 0:9b334a45a8ff | 640 | * @} |
bogdanm | 0:9b334a45a8ff | 641 | */ |
bogdanm | 0:9b334a45a8ff | 642 | |
bogdanm | 0:9b334a45a8ff | 643 | /* Private functions ---------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 644 | |
bogdanm | 0:9b334a45a8ff | 645 | /** |
bogdanm | 0:9b334a45a8ff | 646 | * @} |
bogdanm | 0:9b334a45a8ff | 647 | */ |
bogdanm | 0:9b334a45a8ff | 648 | |
bogdanm | 0:9b334a45a8ff | 649 | /** |
bogdanm | 0:9b334a45a8ff | 650 | * @} |
bogdanm | 0:9b334a45a8ff | 651 | */ |
bogdanm | 0:9b334a45a8ff | 652 | |
bogdanm | 0:9b334a45a8ff | 653 | #endif /* STM32F051x8 || STM32F058xx || */ |
bogdanm | 0:9b334a45a8ff | 654 | /* STM32F071xB || STM32F072xB || STM32F078xx || */ |
bogdanm | 0:9b334a45a8ff | 655 | /* STM32F091xC || STM32F098xx */ |
bogdanm | 0:9b334a45a8ff | 656 | |
bogdanm | 0:9b334a45a8ff | 657 | #ifdef __cplusplus |
bogdanm | 0:9b334a45a8ff | 658 | } |
bogdanm | 0:9b334a45a8ff | 659 | #endif |
bogdanm | 0:9b334a45a8ff | 660 | |
bogdanm | 0:9b334a45a8ff | 661 | #endif /* __STM32F0xx_HAL_COMP_H */ |
bogdanm | 0:9b334a45a8ff | 662 | |
bogdanm | 0:9b334a45a8ff | 663 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
bogdanm | 0:9b334a45a8ff | 664 |