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