mbed library sources

Fork of mbed-src by mbed official

Committer:
moirans2
Date:
Wed Jan 14 20:53:08 2015 +0000
Revision:
445:9a3ffe6cfa19
Parent:
441:d2c15dda23c1
internal clock stm32L051

Who changed what in which revision?

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