/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/adc/fsl_adc_hal.h substitute line 894 extern } by }

Fork of mbed by mbed official

Committer:
fblanc
Date:
Fri Dec 05 15:42:32 2014 +0000
Revision:
93:9dd889aeda0e
Parent:
90:cb3d968589d8
substitute line 894 extern } by }; /TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/adc/fsl_adc_hal.h

Who changed what in which revision?

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