Dataloger
TARGET_NUCLEO_F072RB/stm32f0xx_hal_comp.h@0:666850d06c9f, 2015-08-20 (annotated)
- Committer:
- jhon309
- Date:
- Thu Aug 20 00:37:14 2015 +0000
- Revision:
- 0:666850d06c9f
ok
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jhon309 | 0:666850d06c9f | 1 | /** |
jhon309 | 0:666850d06c9f | 2 | ****************************************************************************** |
jhon309 | 0:666850d06c9f | 3 | * @file stm32f0xx_hal_comp.h |
jhon309 | 0:666850d06c9f | 4 | * @author MCD Application Team |
jhon309 | 0:666850d06c9f | 5 | * @version V1.2.0 |
jhon309 | 0:666850d06c9f | 6 | * @date 11-December-2014 |
jhon309 | 0:666850d06c9f | 7 | * @brief Header file of COMP HAL module. |
jhon309 | 0:666850d06c9f | 8 | ****************************************************************************** |
jhon309 | 0:666850d06c9f | 9 | * @attention |
jhon309 | 0:666850d06c9f | 10 | * |
jhon309 | 0:666850d06c9f | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
jhon309 | 0:666850d06c9f | 12 | * |
jhon309 | 0:666850d06c9f | 13 | * Redistribution and use in source and binary forms, with or without modification, |
jhon309 | 0:666850d06c9f | 14 | * are permitted provided that the following conditions are met: |
jhon309 | 0:666850d06c9f | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
jhon309 | 0:666850d06c9f | 16 | * this list of conditions and the following disclaimer. |
jhon309 | 0:666850d06c9f | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
jhon309 | 0:666850d06c9f | 18 | * this list of conditions and the following disclaimer in the documentation |
jhon309 | 0:666850d06c9f | 19 | * and/or other materials provided with the distribution. |
jhon309 | 0:666850d06c9f | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
jhon309 | 0:666850d06c9f | 21 | * may be used to endorse or promote products derived from this software |
jhon309 | 0:666850d06c9f | 22 | * without specific prior written permission. |
jhon309 | 0:666850d06c9f | 23 | * |
jhon309 | 0:666850d06c9f | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
jhon309 | 0:666850d06c9f | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
jhon309 | 0:666850d06c9f | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
jhon309 | 0:666850d06c9f | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
jhon309 | 0:666850d06c9f | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
jhon309 | 0:666850d06c9f | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
jhon309 | 0:666850d06c9f | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
jhon309 | 0:666850d06c9f | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
jhon309 | 0:666850d06c9f | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
jhon309 | 0:666850d06c9f | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
jhon309 | 0:666850d06c9f | 34 | * |
jhon309 | 0:666850d06c9f | 35 | ****************************************************************************** |
jhon309 | 0:666850d06c9f | 36 | */ |
jhon309 | 0:666850d06c9f | 37 | |
jhon309 | 0:666850d06c9f | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
jhon309 | 0:666850d06c9f | 39 | #ifndef __STM32F0xx_HAL_COMP_H |
jhon309 | 0:666850d06c9f | 40 | #define __STM32F0xx_HAL_COMP_H |
jhon309 | 0:666850d06c9f | 41 | |
jhon309 | 0:666850d06c9f | 42 | #ifdef __cplusplus |
jhon309 | 0:666850d06c9f | 43 | extern "C" { |
jhon309 | 0:666850d06c9f | 44 | #endif |
jhon309 | 0:666850d06c9f | 45 | |
jhon309 | 0:666850d06c9f | 46 | #if defined(STM32F051x8) || defined(STM32F058xx) || \ |
jhon309 | 0:666850d06c9f | 47 | defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \ |
jhon309 | 0:666850d06c9f | 48 | defined(STM32F091xC) || defined(STM32F098xx) |
jhon309 | 0:666850d06c9f | 49 | |
jhon309 | 0:666850d06c9f | 50 | /* Includes ------------------------------------------------------------------*/ |
jhon309 | 0:666850d06c9f | 51 | #include "stm32f0xx_hal_def.h" |
jhon309 | 0:666850d06c9f | 52 | |
jhon309 | 0:666850d06c9f | 53 | /** @addtogroup STM32F0xx_HAL_Driver |
jhon309 | 0:666850d06c9f | 54 | * @{ |
jhon309 | 0:666850d06c9f | 55 | */ |
jhon309 | 0:666850d06c9f | 56 | |
jhon309 | 0:666850d06c9f | 57 | /** @addtogroup COMP COMP HAL Module Driver |
jhon309 | 0:666850d06c9f | 58 | * @{ |
jhon309 | 0:666850d06c9f | 59 | */ |
jhon309 | 0:666850d06c9f | 60 | |
jhon309 | 0:666850d06c9f | 61 | /* Exported types ------------------------------------------------------------*/ |
jhon309 | 0:666850d06c9f | 62 | /** @defgroup COMP_Exported_Types COMP Exported Types |
jhon309 | 0:666850d06c9f | 63 | * @{ |
jhon309 | 0:666850d06c9f | 64 | */ |
jhon309 | 0:666850d06c9f | 65 | |
jhon309 | 0:666850d06c9f | 66 | /** |
jhon309 | 0:666850d06c9f | 67 | * @brief COMP Init structure definition |
jhon309 | 0:666850d06c9f | 68 | */ |
jhon309 | 0:666850d06c9f | 69 | typedef struct |
jhon309 | 0:666850d06c9f | 70 | { |
jhon309 | 0:666850d06c9f | 71 | |
jhon309 | 0:666850d06c9f | 72 | uint32_t InvertingInput; /*!< Selects the inverting input of the comparator. |
jhon309 | 0:666850d06c9f | 73 | This parameter can be a value of @ref COMP_InvertingInput */ |
jhon309 | 0:666850d06c9f | 74 | |
jhon309 | 0:666850d06c9f | 75 | uint32_t NonInvertingInput; /*!< Selects the non inverting input of the comparator. |
jhon309 | 0:666850d06c9f | 76 | This parameter can be a value of @ref COMP_NonInvertingInput */ |
jhon309 | 0:666850d06c9f | 77 | |
jhon309 | 0:666850d06c9f | 78 | uint32_t Output; /*!< Selects the output redirection of the comparator. |
jhon309 | 0:666850d06c9f | 79 | This parameter can be a value of @ref COMP_Output */ |
jhon309 | 0:666850d06c9f | 80 | |
jhon309 | 0:666850d06c9f | 81 | uint32_t OutputPol; /*!< Selects the output polarity of the comparator. |
jhon309 | 0:666850d06c9f | 82 | This parameter can be a value of @ref COMP_OutputPolarity */ |
jhon309 | 0:666850d06c9f | 83 | |
jhon309 | 0:666850d06c9f | 84 | uint32_t Hysteresis; /*!< Selects the hysteresis voltage of the comparator. |
jhon309 | 0:666850d06c9f | 85 | This parameter can be a value of @ref COMP_Hysteresis */ |
jhon309 | 0:666850d06c9f | 86 | |
jhon309 | 0:666850d06c9f | 87 | uint32_t Mode; /*!< Selects the operating comsumption mode of the comparator |
jhon309 | 0:666850d06c9f | 88 | to adjust the speed/consumption. |
jhon309 | 0:666850d06c9f | 89 | This parameter can be a value of @ref COMP_Mode */ |
jhon309 | 0:666850d06c9f | 90 | |
jhon309 | 0:666850d06c9f | 91 | uint32_t WindowMode; /*!< Selects the window mode of the comparator 1 & 2. |
jhon309 | 0:666850d06c9f | 92 | This parameter can be a value of @ref COMP_WindowMode */ |
jhon309 | 0:666850d06c9f | 93 | |
jhon309 | 0:666850d06c9f | 94 | uint32_t TriggerMode; /*!< Selects the trigger mode of the comparator (interrupt mode). |
jhon309 | 0:666850d06c9f | 95 | This parameter can be a value of @ref COMP_TriggerMode */ |
jhon309 | 0:666850d06c9f | 96 | |
jhon309 | 0:666850d06c9f | 97 | }COMP_InitTypeDef; |
jhon309 | 0:666850d06c9f | 98 | |
jhon309 | 0:666850d06c9f | 99 | /** |
jhon309 | 0:666850d06c9f | 100 | * @brief COMP Handle Structure definition |
jhon309 | 0:666850d06c9f | 101 | */ |
jhon309 | 0:666850d06c9f | 102 | typedef struct |
jhon309 | 0:666850d06c9f | 103 | { |
jhon309 | 0:666850d06c9f | 104 | COMP_TypeDef *Instance; /*!< Register base address */ |
jhon309 | 0:666850d06c9f | 105 | COMP_InitTypeDef Init; /*!< COMP required parameters */ |
jhon309 | 0:666850d06c9f | 106 | HAL_LockTypeDef Lock; /*!< Locking object */ |
jhon309 | 0:666850d06c9f | 107 | __IO uint32_t State; /*!< COMP communication state |
jhon309 | 0:666850d06c9f | 108 | This parameter can be a value of @ref COMP_State */ |
jhon309 | 0:666850d06c9f | 109 | }COMP_HandleTypeDef; |
jhon309 | 0:666850d06c9f | 110 | |
jhon309 | 0:666850d06c9f | 111 | /** |
jhon309 | 0:666850d06c9f | 112 | * @} |
jhon309 | 0:666850d06c9f | 113 | */ |
jhon309 | 0:666850d06c9f | 114 | |
jhon309 | 0:666850d06c9f | 115 | /* Exported constants --------------------------------------------------------*/ |
jhon309 | 0:666850d06c9f | 116 | /** @defgroup COMP_Exported_Constants COMP Exported Constants |
jhon309 | 0:666850d06c9f | 117 | * @{ |
jhon309 | 0:666850d06c9f | 118 | */ |
jhon309 | 0:666850d06c9f | 119 | |
jhon309 | 0:666850d06c9f | 120 | /** @defgroup COMP_State COMP State |
jhon309 | 0:666850d06c9f | 121 | * @{ |
jhon309 | 0:666850d06c9f | 122 | */ |
jhon309 | 0:666850d06c9f | 123 | #define HAL_COMP_STATE_RESET ((uint32_t)0x00000000) /*!< COMP not yet initialized or disabled */ |
jhon309 | 0:666850d06c9f | 124 | #define HAL_COMP_STATE_READY ((uint32_t)0x00000001) /*!< COMP initialized and ready for use */ |
jhon309 | 0:666850d06c9f | 125 | #define HAL_COMP_STATE_READY_LOCKED ((uint32_t)0x00000011) /*!< COMP initialized but the configuration is locked */ |
jhon309 | 0:666850d06c9f | 126 | #define HAL_COMP_STATE_BUSY ((uint32_t)0x00000002) /*!< COMP is running */ |
jhon309 | 0:666850d06c9f | 127 | #define HAL_COMP_STATE_BUSY_LOCKED ((uint32_t)0x00000012) /*!< COMP is running and the configuration is locked */ |
jhon309 | 0:666850d06c9f | 128 | /** |
jhon309 | 0:666850d06c9f | 129 | * @} |
jhon309 | 0:666850d06c9f | 130 | */ |
jhon309 | 0:666850d06c9f | 131 | |
jhon309 | 0:666850d06c9f | 132 | /** @defgroup COMP_OutputPolarity COMP OutputPolarity |
jhon309 | 0:666850d06c9f | 133 | * @{ |
jhon309 | 0:666850d06c9f | 134 | */ |
jhon309 | 0:666850d06c9f | 135 | #define COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output on GPIO isn't inverted */ |
jhon309 | 0:666850d06c9f | 136 | #define COMP_OUTPUTPOL_INVERTED COMP_CSR_COMP1POL /*!< COMP output on GPIO is inverted */ |
jhon309 | 0:666850d06c9f | 137 | |
jhon309 | 0:666850d06c9f | 138 | #define IS_COMP_OUTPUTPOL(POL) (((POL) == COMP_OUTPUTPOL_NONINVERTED) || \ |
jhon309 | 0:666850d06c9f | 139 | ((POL) == COMP_OUTPUTPOL_INVERTED)) |
jhon309 | 0:666850d06c9f | 140 | /** |
jhon309 | 0:666850d06c9f | 141 | * @} |
jhon309 | 0:666850d06c9f | 142 | */ |
jhon309 | 0:666850d06c9f | 143 | |
jhon309 | 0:666850d06c9f | 144 | /** @defgroup COMP_Hysteresis COMP Hysteresis |
jhon309 | 0:666850d06c9f | 145 | * @{ |
jhon309 | 0:666850d06c9f | 146 | */ |
jhon309 | 0:666850d06c9f | 147 | #define COMP_HYSTERESIS_NONE ((uint32_t)0x00000000) /*!< No hysteresis */ |
jhon309 | 0:666850d06c9f | 148 | #define COMP_HYSTERESIS_LOW COMP_CSR_COMP1HYST_0 /*!< Hysteresis level low */ |
jhon309 | 0:666850d06c9f | 149 | #define COMP_HYSTERESIS_MEDIUM COMP_CSR_COMP1HYST_1 /*!< Hysteresis level medium */ |
jhon309 | 0:666850d06c9f | 150 | #define COMP_HYSTERESIS_HIGH COMP_CSR_COMP1HYST /*!< Hysteresis level high */ |
jhon309 | 0:666850d06c9f | 151 | |
jhon309 | 0:666850d06c9f | 152 | #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_HYSTERESIS_NONE) || \ |
jhon309 | 0:666850d06c9f | 153 | ((HYSTERESIS) == COMP_HYSTERESIS_LOW) || \ |
jhon309 | 0:666850d06c9f | 154 | ((HYSTERESIS) == COMP_HYSTERESIS_MEDIUM) || \ |
jhon309 | 0:666850d06c9f | 155 | ((HYSTERESIS) == COMP_HYSTERESIS_HIGH)) |
jhon309 | 0:666850d06c9f | 156 | /** |
jhon309 | 0:666850d06c9f | 157 | * @} |
jhon309 | 0:666850d06c9f | 158 | */ |
jhon309 | 0:666850d06c9f | 159 | |
jhon309 | 0:666850d06c9f | 160 | /** @defgroup COMP_Mode COMP Mode |
jhon309 | 0:666850d06c9f | 161 | * @{ |
jhon309 | 0:666850d06c9f | 162 | */ |
jhon309 | 0:666850d06c9f | 163 | /* Please refer to the electrical characteristics in the device datasheet for |
jhon309 | 0:666850d06c9f | 164 | the power consumption values */ |
jhon309 | 0:666850d06c9f | 165 | #define COMP_MODE_HIGHSPEED ((uint32_t)0x00000000) /*!< High Speed */ |
jhon309 | 0:666850d06c9f | 166 | #define COMP_MODE_MEDIUMSPEED COMP_CSR_COMP1MODE_0 /*!< Medium Speed */ |
jhon309 | 0:666850d06c9f | 167 | #define COMP_MODE_LOWPOWER COMP_CSR_COMP1MODE_1 /*!< Low power mode */ |
jhon309 | 0:666850d06c9f | 168 | #define COMP_MODE_ULTRALOWPOWER COMP_CSR_COMP1MODE /*!< Ultra-low power mode */ |
jhon309 | 0:666850d06c9f | 169 | |
jhon309 | 0:666850d06c9f | 170 | #define IS_COMP_MODE(MODE) (((MODE) == COMP_MODE_HIGHSPEED) || \ |
jhon309 | 0:666850d06c9f | 171 | ((MODE) == COMP_MODE_MEDIUMSPEED) || \ |
jhon309 | 0:666850d06c9f | 172 | ((MODE) == COMP_MODE_LOWPOWER) || \ |
jhon309 | 0:666850d06c9f | 173 | ((MODE) == COMP_MODE_ULTRALOWPOWER)) |
jhon309 | 0:666850d06c9f | 174 | |
jhon309 | 0:666850d06c9f | 175 | /** |
jhon309 | 0:666850d06c9f | 176 | * @} |
jhon309 | 0:666850d06c9f | 177 | */ |
jhon309 | 0:666850d06c9f | 178 | |
jhon309 | 0:666850d06c9f | 179 | /** @defgroup COMP_InvertingInput COMP InvertingInput |
jhon309 | 0:666850d06c9f | 180 | * @{ |
jhon309 | 0:666850d06c9f | 181 | */ |
jhon309 | 0:666850d06c9f | 182 | |
jhon309 | 0:666850d06c9f | 183 | #define COMP_INVERTINGINPUT_1_4VREFINT ((uint32_t)0x00000000) /*!< 1/4 VREFINT connected to comparator inverting input */ |
jhon309 | 0:666850d06c9f | 184 | #define COMP_INVERTINGINPUT_1_2VREFINT COMP_CSR_COMP1INSEL_0 /*!< 1/2 VREFINT connected to comparator inverting input */ |
jhon309 | 0:666850d06c9f | 185 | #define COMP_INVERTINGINPUT_3_4VREFINT COMP_CSR_COMP1INSEL_1 /*!< 3/4 VREFINT connected to comparator inverting input */ |
jhon309 | 0:666850d06c9f | 186 | #define COMP_INVERTINGINPUT_VREFINT (COMP_CSR_COMP1INSEL_1|COMP_CSR_COMP1INSEL_0) /*!< VREFINT connected to comparator inverting input */ |
jhon309 | 0:666850d06c9f | 187 | #define COMP_INVERTINGINPUT_DAC1 COMP_CSR_COMP1INSEL_2 /*!< DAC_OUT1 (PA4) connected to comparator inverting input */ |
jhon309 | 0:666850d06c9f | 188 | #define COMP_INVERTINGINPUT_DAC1SWITCHCLOSED (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1SW1) /*!< DAC_OUT1 (PA4) connected to comparator inverting input |
jhon309 | 0:666850d06c9f | 189 | and close switch (PA0 for COMP1 only) */ |
jhon309 | 0:666850d06c9f | 190 | #define COMP_INVERTINGINPUT_DAC2 (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1INSEL_0) /*!< DAC_OUT2 (PA5) connected to comparator inverting input */ |
jhon309 | 0:666850d06c9f | 191 | #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 */ |
jhon309 | 0:666850d06c9f | 192 | |
jhon309 | 0:666850d06c9f | 193 | #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \ |
jhon309 | 0:666850d06c9f | 194 | ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \ |
jhon309 | 0:666850d06c9f | 195 | ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \ |
jhon309 | 0:666850d06c9f | 196 | ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \ |
jhon309 | 0:666850d06c9f | 197 | ((INPUT) == COMP_INVERTINGINPUT_DAC1) || \ |
jhon309 | 0:666850d06c9f | 198 | ((INPUT) == COMP_INVERTINGINPUT_DAC1SWITCHCLOSED) || \ |
jhon309 | 0:666850d06c9f | 199 | ((INPUT) == COMP_INVERTINGINPUT_DAC2) || \ |
jhon309 | 0:666850d06c9f | 200 | ((INPUT) == COMP_INVERTINGINPUT_IO1)) |
jhon309 | 0:666850d06c9f | 201 | /** |
jhon309 | 0:666850d06c9f | 202 | * @} |
jhon309 | 0:666850d06c9f | 203 | */ |
jhon309 | 0:666850d06c9f | 204 | |
jhon309 | 0:666850d06c9f | 205 | /** @defgroup COMP_NonInvertingInput COMP NonInvertingInput |
jhon309 | 0:666850d06c9f | 206 | * @{ |
jhon309 | 0:666850d06c9f | 207 | */ |
jhon309 | 0:666850d06c9f | 208 | #define COMP_NONINVERTINGINPUT_IO1 ((uint32_t)0x00000000) /*!< I/O1 (PA1 for COMP1, PA3 for COMP2) |
jhon309 | 0:666850d06c9f | 209 | connected to comparator non inverting input */ |
jhon309 | 0:666850d06c9f | 210 | #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED COMP_CSR_COMP1SW1 /*!< DAC ouput connected to comparator COMP1 non inverting input */ |
jhon309 | 0:666850d06c9f | 211 | |
jhon309 | 0:666850d06c9f | 212 | #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \ |
jhon309 | 0:666850d06c9f | 213 | ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED)) |
jhon309 | 0:666850d06c9f | 214 | /** |
jhon309 | 0:666850d06c9f | 215 | * @} |
jhon309 | 0:666850d06c9f | 216 | */ |
jhon309 | 0:666850d06c9f | 217 | |
jhon309 | 0:666850d06c9f | 218 | /** @defgroup COMP_Output COMP Output |
jhon309 | 0:666850d06c9f | 219 | * @{ |
jhon309 | 0:666850d06c9f | 220 | */ |
jhon309 | 0:666850d06c9f | 221 | |
jhon309 | 0:666850d06c9f | 222 | /* Output Redirection common for COMP1 and COMP2 */ |
jhon309 | 0:666850d06c9f | 223 | #define COMP_OUTPUT_NONE ((uint32_t)0x00000000) /*!< COMP output isn't connected to other peripherals */ |
jhon309 | 0:666850d06c9f | 224 | #define COMP_OUTPUT_TIM1BKIN COMP_CSR_COMP1OUTSEL_0 /*!< COMP output connected to TIM1 Break Input (BKIN) */ |
jhon309 | 0:666850d06c9f | 225 | #define COMP_OUTPUT_TIM1IC1 COMP_CSR_COMP1OUTSEL_1 /*!< COMP output connected to TIM1 Input Capture 1 */ |
jhon309 | 0:666850d06c9f | 226 | #define COMP_OUTPUT_TIM1OCREFCLR (COMP_CSR_COMP1OUTSEL_1|COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM1 OCREF Clear */ |
jhon309 | 0:666850d06c9f | 227 | #define COMP_OUTPUT_TIM2IC4 COMP_CSR_COMP1OUTSEL_2 /*!< COMP output connected to TIM2 Input Capture 4 */ |
jhon309 | 0:666850d06c9f | 228 | #define COMP_OUTPUT_TIM2OCREFCLR (COMP_CSR_COMP1OUTSEL_2|COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM2 OCREF Clear */ |
jhon309 | 0:666850d06c9f | 229 | #define COMP_OUTPUT_TIM3IC1 (COMP_CSR_COMP1OUTSEL_2|COMP_CSR_COMP1OUTSEL_1) /*!< COMP output connected to TIM3 Input Capture 1 */ |
jhon309 | 0:666850d06c9f | 230 | #define COMP_OUTPUT_TIM3OCREFCLR COMP_CSR_COMP1OUTSEL /*!< COMP output connected to TIM3 OCREF Clear */ |
jhon309 | 0:666850d06c9f | 231 | |
jhon309 | 0:666850d06c9f | 232 | #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE) || \ |
jhon309 | 0:666850d06c9f | 233 | ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \ |
jhon309 | 0:666850d06c9f | 234 | ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \ |
jhon309 | 0:666850d06c9f | 235 | ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \ |
jhon309 | 0:666850d06c9f | 236 | ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \ |
jhon309 | 0:666850d06c9f | 237 | ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \ |
jhon309 | 0:666850d06c9f | 238 | ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \ |
jhon309 | 0:666850d06c9f | 239 | ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR)) |
jhon309 | 0:666850d06c9f | 240 | |
jhon309 | 0:666850d06c9f | 241 | /** |
jhon309 | 0:666850d06c9f | 242 | * @} |
jhon309 | 0:666850d06c9f | 243 | */ |
jhon309 | 0:666850d06c9f | 244 | |
jhon309 | 0:666850d06c9f | 245 | /** @defgroup COMP_OutputLevel COMP OutputLevel |
jhon309 | 0:666850d06c9f | 246 | * @{ |
jhon309 | 0:666850d06c9f | 247 | */ |
jhon309 | 0:666850d06c9f | 248 | /* When output polarity is not inverted, comparator output is low when |
jhon309 | 0:666850d06c9f | 249 | the non-inverting input is at a lower voltage than the inverting input*/ |
jhon309 | 0:666850d06c9f | 250 | #define COMP_OUTPUTLEVEL_LOW ((uint32_t)0x00000000) |
jhon309 | 0:666850d06c9f | 251 | /* When output polarity is not inverted, comparator output is high when |
jhon309 | 0:666850d06c9f | 252 | the non-inverting input is at a higher voltage than the inverting input */ |
jhon309 | 0:666850d06c9f | 253 | #define COMP_OUTPUTLEVEL_HIGH COMP_CSR_COMP1OUT |
jhon309 | 0:666850d06c9f | 254 | /** |
jhon309 | 0:666850d06c9f | 255 | * @} |
jhon309 | 0:666850d06c9f | 256 | */ |
jhon309 | 0:666850d06c9f | 257 | |
jhon309 | 0:666850d06c9f | 258 | /** @defgroup COMP_TriggerMode COMP TriggerMode |
jhon309 | 0:666850d06c9f | 259 | * @{ |
jhon309 | 0:666850d06c9f | 260 | */ |
jhon309 | 0:666850d06c9f | 261 | #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< No External Interrupt trigger detection */ |
jhon309 | 0:666850d06c9f | 262 | #define COMP_TRIGGERMODE_IT_RISING ((uint32_t)0x00000001) /*!< External Interrupt Mode with Rising edge trigger detection */ |
jhon309 | 0:666850d06c9f | 263 | #define COMP_TRIGGERMODE_IT_FALLING ((uint32_t)0x00000002) /*!< External Interrupt Mode with Falling edge trigger detection */ |
jhon309 | 0:666850d06c9f | 264 | #define COMP_TRIGGERMODE_IT_RISING_FALLING ((uint32_t)0x00000003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ |
jhon309 | 0:666850d06c9f | 265 | |
jhon309 | 0:666850d06c9f | 266 | #define IS_COMP_TRIGGERMODE(MODE) (((MODE) == COMP_TRIGGERMODE_NONE) || \ |
jhon309 | 0:666850d06c9f | 267 | ((MODE) == COMP_TRIGGERMODE_IT_RISING) || \ |
jhon309 | 0:666850d06c9f | 268 | ((MODE) == COMP_TRIGGERMODE_IT_FALLING) || \ |
jhon309 | 0:666850d06c9f | 269 | ((MODE) == COMP_TRIGGERMODE_IT_RISING_FALLING)) |
jhon309 | 0:666850d06c9f | 270 | /** |
jhon309 | 0:666850d06c9f | 271 | * @} |
jhon309 | 0:666850d06c9f | 272 | */ |
jhon309 | 0:666850d06c9f | 273 | |
jhon309 | 0:666850d06c9f | 274 | /** @defgroup COMP_WindowMode COMP WindowMode |
jhon309 | 0:666850d06c9f | 275 | * @{ |
jhon309 | 0:666850d06c9f | 276 | */ |
jhon309 | 0:666850d06c9f | 277 | #define COMP_WINDOWMODE_DISABLED ((uint32_t)0x00000000) /*!< Window mode disabled */ |
jhon309 | 0:666850d06c9f | 278 | #define COMP_WINDOWMODE_ENABLED COMP_CSR_WNDWEN /*!< Window mode enabled: non inverting input of comparator 2 |
jhon309 | 0:666850d06c9f | 279 | is connected to the non inverting input of comparator 1 (PA1) */ |
jhon309 | 0:666850d06c9f | 280 | |
jhon309 | 0:666850d06c9f | 281 | #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLED) || \ |
jhon309 | 0:666850d06c9f | 282 | ((WINDOWMODE) == COMP_WINDOWMODE_ENABLED)) |
jhon309 | 0:666850d06c9f | 283 | /** |
jhon309 | 0:666850d06c9f | 284 | * @} |
jhon309 | 0:666850d06c9f | 285 | */ |
jhon309 | 0:666850d06c9f | 286 | |
jhon309 | 0:666850d06c9f | 287 | /** @defgroup COMP_ExtiLineEvent COMP ExtiLineEvent |
jhon309 | 0:666850d06c9f | 288 | * Elements values convention: XXXX0000 |
jhon309 | 0:666850d06c9f | 289 | * - XXXX : Interrupt mask in the EMR/IMR/RTSR/FTSR register |
jhon309 | 0:666850d06c9f | 290 | * @{ |
jhon309 | 0:666850d06c9f | 291 | */ |
jhon309 | 0:666850d06c9f | 292 | #define COMP_EXTI_LINE_COMP1_EVENT ((uint32_t)0x00200000) /*!< External interrupt line 21 Connected to COMP1 */ |
jhon309 | 0:666850d06c9f | 293 | #define COMP_EXTI_LINE_COMP2_EVENT ((uint32_t)0x00400000) /*!< External interrupt line 22 Connected to COMP2 */ |
jhon309 | 0:666850d06c9f | 294 | |
jhon309 | 0:666850d06c9f | 295 | /** |
jhon309 | 0:666850d06c9f | 296 | * @} |
jhon309 | 0:666850d06c9f | 297 | */ |
jhon309 | 0:666850d06c9f | 298 | |
jhon309 | 0:666850d06c9f | 299 | /** @defgroup COMP_Lock COMP Lock |
jhon309 | 0:666850d06c9f | 300 | * @{ |
jhon309 | 0:666850d06c9f | 301 | */ |
jhon309 | 0:666850d06c9f | 302 | #define COMP_LOCK_DISABLE ((uint32_t)0x00000000) |
jhon309 | 0:666850d06c9f | 303 | #define COMP_LOCK_ENABLE COMP_CSR_COMP1LOCK |
jhon309 | 0:666850d06c9f | 304 | |
jhon309 | 0:666850d06c9f | 305 | #define COMP_STATE_BIT_LOCK ((uint32_t)0x10) |
jhon309 | 0:666850d06c9f | 306 | /** |
jhon309 | 0:666850d06c9f | 307 | * @} |
jhon309 | 0:666850d06c9f | 308 | */ |
jhon309 | 0:666850d06c9f | 309 | |
jhon309 | 0:666850d06c9f | 310 | |
jhon309 | 0:666850d06c9f | 311 | /** |
jhon309 | 0:666850d06c9f | 312 | * @} |
jhon309 | 0:666850d06c9f | 313 | */ |
jhon309 | 0:666850d06c9f | 314 | |
jhon309 | 0:666850d06c9f | 315 | /* Exported macros -----------------------------------------------------------*/ |
jhon309 | 0:666850d06c9f | 316 | /** @defgroup COMP_Exported_Macros COMP Exported Macros |
jhon309 | 0:666850d06c9f | 317 | * @{ |
jhon309 | 0:666850d06c9f | 318 | */ |
jhon309 | 0:666850d06c9f | 319 | |
jhon309 | 0:666850d06c9f | 320 | /** @brief Reset COMP handle state |
jhon309 | 0:666850d06c9f | 321 | * @param __HANDLE__: COMP handle. |
jhon309 | 0:666850d06c9f | 322 | * @retval None |
jhon309 | 0:666850d06c9f | 323 | */ |
jhon309 | 0:666850d06c9f | 324 | #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET) |
jhon309 | 0:666850d06c9f | 325 | |
jhon309 | 0:666850d06c9f | 326 | /** |
jhon309 | 0:666850d06c9f | 327 | * @brief Checks whether the specified EXTI line flag is set or not. |
jhon309 | 0:666850d06c9f | 328 | * @param __FLAG__: specifies the COMP Exti sources to be checked. |
jhon309 | 0:666850d06c9f | 329 | * This parameter can be a value of @ref COMP_ExtiLineEvent |
jhon309 | 0:666850d06c9f | 330 | * @retval The state of __FLAG__ (SET or RESET). |
jhon309 | 0:666850d06c9f | 331 | */ |
jhon309 | 0:666850d06c9f | 332 | #define __HAL_COMP_EXTI_GET_FLAG(__FLAG__) (EXTI->PR & (__FLAG__)) |
jhon309 | 0:666850d06c9f | 333 | |
jhon309 | 0:666850d06c9f | 334 | /** |
jhon309 | 0:666850d06c9f | 335 | * @brief Clear the COMP Exti flags. |
jhon309 | 0:666850d06c9f | 336 | * @param __FLAG__: specifies the COMP Exti sources to be cleared. |
jhon309 | 0:666850d06c9f | 337 | * This parameter can be a value of @ref COMP_ExtiLineEvent |
jhon309 | 0:666850d06c9f | 338 | * @retval None. |
jhon309 | 0:666850d06c9f | 339 | */ |
jhon309 | 0:666850d06c9f | 340 | #define __HAL_COMP_EXTI_CLEAR_FLAG(__FLAG__) (EXTI->PR = (__FLAG__)) |
jhon309 | 0:666850d06c9f | 341 | |
jhon309 | 0:666850d06c9f | 342 | /** |
jhon309 | 0:666850d06c9f | 343 | * @brief Enable the COMP Exti Line. |
jhon309 | 0:666850d06c9f | 344 | * @param __EXTILINE__: specifies the COMP Exti sources to be enabled. |
jhon309 | 0:666850d06c9f | 345 | * This parameter can be a value of @ref COMP_ExtiLineEvent |
jhon309 | 0:666850d06c9f | 346 | * @retval None. |
jhon309 | 0:666850d06c9f | 347 | */ |
jhon309 | 0:666850d06c9f | 348 | #define __HAL_COMP_EXTI_ENABLE_IT(__EXTILINE__) (EXTI->IMR |= (__EXTILINE__)) |
jhon309 | 0:666850d06c9f | 349 | |
jhon309 | 0:666850d06c9f | 350 | /** |
jhon309 | 0:666850d06c9f | 351 | * @brief Disable the COMP Exti Line. |
jhon309 | 0:666850d06c9f | 352 | * @param __EXTILINE__: specifies the COMP Exti sources to be disabled. |
jhon309 | 0:666850d06c9f | 353 | * This parameter can be a value of @ref COMP_ExtiLineEvent |
jhon309 | 0:666850d06c9f | 354 | * @retval None. |
jhon309 | 0:666850d06c9f | 355 | */ |
jhon309 | 0:666850d06c9f | 356 | #define __HAL_COMP_EXTI_DISABLE_IT(__EXTILINE__) (EXTI->IMR &= ~(__EXTILINE__)) |
jhon309 | 0:666850d06c9f | 357 | |
jhon309 | 0:666850d06c9f | 358 | /** |
jhon309 | 0:666850d06c9f | 359 | * @brief Enable the Exti Line rising edge trigger. |
jhon309 | 0:666850d06c9f | 360 | * @param __EXTILINE__: specifies the COMP Exti sources to be enabled. |
jhon309 | 0:666850d06c9f | 361 | * This parameter can be a value of @ref COMP_ExtiLineEvent |
jhon309 | 0:666850d06c9f | 362 | * @retval None. |
jhon309 | 0:666850d06c9f | 363 | */ |
jhon309 | 0:666850d06c9f | 364 | #define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (EXTI->RTSR |= (__EXTILINE__)) |
jhon309 | 0:666850d06c9f | 365 | |
jhon309 | 0:666850d06c9f | 366 | /** |
jhon309 | 0:666850d06c9f | 367 | * @brief Disable the Exti Line rising edge trigger. |
jhon309 | 0:666850d06c9f | 368 | * @param __EXTILINE__: specifies the COMP Exti sources to be disabled. |
jhon309 | 0:666850d06c9f | 369 | * This parameter can be a value of @ref COMP_ExtiLineEvent |
jhon309 | 0:666850d06c9f | 370 | * @retval None. |
jhon309 | 0:666850d06c9f | 371 | */ |
jhon309 | 0:666850d06c9f | 372 | #define __HAL_COMP_EXTI_RISING_IT_DISABLE(__EXTILINE__) (EXTI->RTSR &= ~(__EXTILINE__)) |
jhon309 | 0:666850d06c9f | 373 | |
jhon309 | 0:666850d06c9f | 374 | /** |
jhon309 | 0:666850d06c9f | 375 | * @brief Enable the Exti Line falling edge trigger. |
jhon309 | 0:666850d06c9f | 376 | * @param __EXTILINE__: specifies the COMP Exti sources to be enabled. |
jhon309 | 0:666850d06c9f | 377 | * This parameter can be a value of @ref COMP_ExtiLineEvent |
jhon309 | 0:666850d06c9f | 378 | * @retval None. |
jhon309 | 0:666850d06c9f | 379 | */ |
jhon309 | 0:666850d06c9f | 380 | #define __HAL_COMP_EXTI_FALLING_IT_ENABLE(__EXTILINE__) (EXTI->FTSR |= (__EXTILINE__)) |
jhon309 | 0:666850d06c9f | 381 | |
jhon309 | 0:666850d06c9f | 382 | /** |
jhon309 | 0:666850d06c9f | 383 | * @brief Disable the Exti Line falling edge trigger. |
jhon309 | 0:666850d06c9f | 384 | * @param __EXTILINE__: specifies the COMP Exti sources to be disabled. |
jhon309 | 0:666850d06c9f | 385 | * This parameter can be a value of @ref COMP_ExtiLineEvent |
jhon309 | 0:666850d06c9f | 386 | * @retval None. |
jhon309 | 0:666850d06c9f | 387 | */ |
jhon309 | 0:666850d06c9f | 388 | #define __HAL_COMP_EXTI_FALLING_IT_DISABLE(__EXTILINE__) (EXTI->FTSR &= ~(__EXTILINE__)) |
jhon309 | 0:666850d06c9f | 389 | |
jhon309 | 0:666850d06c9f | 390 | /** |
jhon309 | 0:666850d06c9f | 391 | * @brief Get the specified EXTI line for a comparator instance |
jhon309 | 0:666850d06c9f | 392 | * @param __INSTANCE__: specifies the COMP instance. |
jhon309 | 0:666850d06c9f | 393 | * @retval value of @ref COMP_ExtiLineEvent |
jhon309 | 0:666850d06c9f | 394 | */ |
jhon309 | 0:666850d06c9f | 395 | #define __HAL_COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1_EVENT : \ |
jhon309 | 0:666850d06c9f | 396 | COMP_EXTI_LINE_COMP2_EVENT) |
jhon309 | 0:666850d06c9f | 397 | /** |
jhon309 | 0:666850d06c9f | 398 | * @} |
jhon309 | 0:666850d06c9f | 399 | */ |
jhon309 | 0:666850d06c9f | 400 | |
jhon309 | 0:666850d06c9f | 401 | /* Exported functions --------------------------------------------------------*/ |
jhon309 | 0:666850d06c9f | 402 | /** @addtogroup COMP_Exported_Functions COMP Exported Functions |
jhon309 | 0:666850d06c9f | 403 | * @{ |
jhon309 | 0:666850d06c9f | 404 | */ |
jhon309 | 0:666850d06c9f | 405 | /** @addtogroup COMP_Exported_Functions_Group1 Initialization/de-initialization functions |
jhon309 | 0:666850d06c9f | 406 | * @brief Initialization and Configuration functions |
jhon309 | 0:666850d06c9f | 407 | * @{ |
jhon309 | 0:666850d06c9f | 408 | */ |
jhon309 | 0:666850d06c9f | 409 | /* Initialization and de-initialization functions ****************************/ |
jhon309 | 0:666850d06c9f | 410 | HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 411 | HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 412 | void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 413 | void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 414 | /** |
jhon309 | 0:666850d06c9f | 415 | * @} |
jhon309 | 0:666850d06c9f | 416 | */ |
jhon309 | 0:666850d06c9f | 417 | |
jhon309 | 0:666850d06c9f | 418 | /** @addtogroup COMP_Exported_Functions_Group2 I/O operation functions |
jhon309 | 0:666850d06c9f | 419 | * @brief Data transfers functions |
jhon309 | 0:666850d06c9f | 420 | * @{ |
jhon309 | 0:666850d06c9f | 421 | */ |
jhon309 | 0:666850d06c9f | 422 | /* IO operation functions *****************************************************/ |
jhon309 | 0:666850d06c9f | 423 | HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 424 | HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 425 | HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 426 | HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 427 | void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 428 | /** |
jhon309 | 0:666850d06c9f | 429 | * @} |
jhon309 | 0:666850d06c9f | 430 | */ |
jhon309 | 0:666850d06c9f | 431 | |
jhon309 | 0:666850d06c9f | 432 | /** @addtogroup COMP_Exported_Functions_Group3 Peripheral Control functions |
jhon309 | 0:666850d06c9f | 433 | * @brief management functions |
jhon309 | 0:666850d06c9f | 434 | * @{ |
jhon309 | 0:666850d06c9f | 435 | */ |
jhon309 | 0:666850d06c9f | 436 | /* Peripheral Control functions ***********************************************/ |
jhon309 | 0:666850d06c9f | 437 | HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 438 | uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 439 | |
jhon309 | 0:666850d06c9f | 440 | /* Callback in Interrupt mode */ |
jhon309 | 0:666850d06c9f | 441 | void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 442 | /** |
jhon309 | 0:666850d06c9f | 443 | * @} |
jhon309 | 0:666850d06c9f | 444 | */ |
jhon309 | 0:666850d06c9f | 445 | |
jhon309 | 0:666850d06c9f | 446 | /** @addtogroup COMP_Exported_Functions_Group4 Peripheral State functions |
jhon309 | 0:666850d06c9f | 447 | * @brief Peripheral State functions |
jhon309 | 0:666850d06c9f | 448 | * @{ |
jhon309 | 0:666850d06c9f | 449 | */ |
jhon309 | 0:666850d06c9f | 450 | /* Peripheral State and Error functions ***************************************/ |
jhon309 | 0:666850d06c9f | 451 | uint32_t HAL_COMP_GetState(COMP_HandleTypeDef *hcomp); |
jhon309 | 0:666850d06c9f | 452 | /** |
jhon309 | 0:666850d06c9f | 453 | * @} |
jhon309 | 0:666850d06c9f | 454 | */ |
jhon309 | 0:666850d06c9f | 455 | |
jhon309 | 0:666850d06c9f | 456 | /** |
jhon309 | 0:666850d06c9f | 457 | * @} |
jhon309 | 0:666850d06c9f | 458 | */ |
jhon309 | 0:666850d06c9f | 459 | |
jhon309 | 0:666850d06c9f | 460 | /** |
jhon309 | 0:666850d06c9f | 461 | * @} |
jhon309 | 0:666850d06c9f | 462 | */ |
jhon309 | 0:666850d06c9f | 463 | |
jhon309 | 0:666850d06c9f | 464 | /** |
jhon309 | 0:666850d06c9f | 465 | * @} |
jhon309 | 0:666850d06c9f | 466 | */ |
jhon309 | 0:666850d06c9f | 467 | |
jhon309 | 0:666850d06c9f | 468 | #endif /* STM32F051x8 || STM32F058xx || */ |
jhon309 | 0:666850d06c9f | 469 | /* STM32F071xB || STM32F072xB || STM32F078xx || */ |
jhon309 | 0:666850d06c9f | 470 | /* STM32F091xC || STM32F098xx */ |
jhon309 | 0:666850d06c9f | 471 | |
jhon309 | 0:666850d06c9f | 472 | #ifdef __cplusplus |
jhon309 | 0:666850d06c9f | 473 | } |
jhon309 | 0:666850d06c9f | 474 | #endif |
jhon309 | 0:666850d06c9f | 475 | |
jhon309 | 0:666850d06c9f | 476 | #endif /* __STM32F0xx_HAL_COMP_H */ |
jhon309 | 0:666850d06c9f | 477 | |
jhon309 | 0:666850d06c9f | 478 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
jhon309 | 0:666850d06c9f | 479 |