The official mbed C/C SDK provides the software platform and libraries to build your applications.

Fork of mbed by mbed official

Committer:
Mikchel
Date:
Sun May 03 16:04:42 2015 +0000
Revision:
99:7f6c6de930c0
Parent:
93:e188a91d3eaa
12

Who changed what in which revision?

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