mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri Nov 07 08:15:08 2014 +0000
Revision:
392:2b59412bb664
Parent:
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F091RC/stm32f0xx_hal_comp.h@340:28d1f895c6fe
Child:
441:d2c15dda23c1
Synchronized with git revision eec0be05cd92349bee83c65f9e1302b25b5badf4

Full URL: https://github.com/mbedmicro/mbed/commit/eec0be05cd92349bee83c65f9e1302b25b5badf4/

Targets: STM32F0 - Factorisation of NUCLEO_F030R8/F072RB/F091RC cmsis folders

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 340:28d1f895c6fe 5 * @version V1.1.0
mbed_official 340:28d1f895c6fe 6 * @date 03-Oct-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 HAL State structures definition
mbed_official 340:28d1f895c6fe 101 */
mbed_official 340:28d1f895c6fe 102 typedef enum
mbed_official 340:28d1f895c6fe 103 {
mbed_official 340:28d1f895c6fe 104 HAL_COMP_STATE_RESET = 0x00, /*!< COMP not yet initialized or disabled */
mbed_official 340:28d1f895c6fe 105 HAL_COMP_STATE_READY = 0x01, /*!< COMP initialized and ready for use */
mbed_official 340:28d1f895c6fe 106 HAL_COMP_STATE_READY_LOCKED = 0x11, /*!< COMP initialized but the configuration is locked */
mbed_official 340:28d1f895c6fe 107 HAL_COMP_STATE_BUSY = 0x02, /*!< COMP is running */
mbed_official 340:28d1f895c6fe 108 HAL_COMP_STATE_BUSY_LOCKED = 0x12 /*!< COMP is running and the configuration is locked */
mbed_official 340:28d1f895c6fe 109 }HAL_COMP_StateTypeDef;
mbed_official 340:28d1f895c6fe 110
mbed_official 340:28d1f895c6fe 111 /**
mbed_official 340:28d1f895c6fe 112 * @brief COMP Handle Structure definition
mbed_official 340:28d1f895c6fe 113 */
mbed_official 340:28d1f895c6fe 114 typedef struct
mbed_official 340:28d1f895c6fe 115 {
mbed_official 340:28d1f895c6fe 116 COMP_TypeDef *Instance; /*!< Register base address */
mbed_official 340:28d1f895c6fe 117 COMP_InitTypeDef Init; /*!< COMP required parameters */
mbed_official 340:28d1f895c6fe 118 HAL_LockTypeDef Lock; /*!< Locking object */
mbed_official 340:28d1f895c6fe 119 __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
mbed_official 340:28d1f895c6fe 120 }COMP_HandleTypeDef;
mbed_official 340:28d1f895c6fe 121
mbed_official 340:28d1f895c6fe 122 /**
mbed_official 340:28d1f895c6fe 123 * @}
mbed_official 340:28d1f895c6fe 124 */
mbed_official 340:28d1f895c6fe 125
mbed_official 340:28d1f895c6fe 126 /* Exported constants --------------------------------------------------------*/
mbed_official 340:28d1f895c6fe 127 /** @defgroup COMP_Exported_Constants COMP Exported Constants
mbed_official 340:28d1f895c6fe 128 * @{
mbed_official 340:28d1f895c6fe 129 */
mbed_official 340:28d1f895c6fe 130
mbed_official 340:28d1f895c6fe 131 /** @defgroup COMP_OutputPolarity COMP OutputPolarity
mbed_official 340:28d1f895c6fe 132 * @{
mbed_official 340:28d1f895c6fe 133 */
mbed_official 340:28d1f895c6fe 134 #define COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output on GPIO isn't inverted */
mbed_official 340:28d1f895c6fe 135 #define COMP_OUTPUTPOL_INVERTED COMP_CSR_COMP1POL /*!< COMP output on GPIO is inverted */
mbed_official 340:28d1f895c6fe 136
mbed_official 340:28d1f895c6fe 137 #define IS_COMP_OUTPUTPOL(POL) (((POL) == COMP_OUTPUTPOL_NONINVERTED) || \
mbed_official 340:28d1f895c6fe 138 ((POL) == COMP_OUTPUTPOL_INVERTED))
mbed_official 340:28d1f895c6fe 139 /**
mbed_official 340:28d1f895c6fe 140 * @}
mbed_official 340:28d1f895c6fe 141 */
mbed_official 340:28d1f895c6fe 142
mbed_official 340:28d1f895c6fe 143 /** @defgroup COMP_Hysteresis COMP Hysteresis
mbed_official 340:28d1f895c6fe 144 * @{
mbed_official 340:28d1f895c6fe 145 */
mbed_official 340:28d1f895c6fe 146 #define COMP_HYSTERESIS_NONE ((uint32_t)0x00000000) /*!< No hysteresis */
mbed_official 340:28d1f895c6fe 147 #define COMP_HYSTERESIS_LOW COMP_CSR_COMP1HYST_0 /*!< Hysteresis level low */
mbed_official 340:28d1f895c6fe 148 #define COMP_HYSTERESIS_MEDIUM COMP_CSR_COMP1HYST_1 /*!< Hysteresis level medium */
mbed_official 340:28d1f895c6fe 149 #define COMP_HYSTERESIS_HIGH COMP_CSR_COMP1HYST /*!< Hysteresis level high */
mbed_official 340:28d1f895c6fe 150
mbed_official 340:28d1f895c6fe 151 #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_HYSTERESIS_NONE) || \
mbed_official 340:28d1f895c6fe 152 ((HYSTERESIS) == COMP_HYSTERESIS_LOW) || \
mbed_official 340:28d1f895c6fe 153 ((HYSTERESIS) == COMP_HYSTERESIS_MEDIUM) || \
mbed_official 340:28d1f895c6fe 154 ((HYSTERESIS) == COMP_HYSTERESIS_HIGH))
mbed_official 340:28d1f895c6fe 155 /**
mbed_official 340:28d1f895c6fe 156 * @}
mbed_official 340:28d1f895c6fe 157 */
mbed_official 340:28d1f895c6fe 158
mbed_official 340:28d1f895c6fe 159 /** @defgroup COMP_Mode COMP Mode
mbed_official 340:28d1f895c6fe 160 * @{
mbed_official 340:28d1f895c6fe 161 */
mbed_official 340:28d1f895c6fe 162 /* Please refer to the electrical characteristics in the device datasheet for
mbed_official 340:28d1f895c6fe 163 the power consumption values */
mbed_official 340:28d1f895c6fe 164 #define COMP_MODE_HIGHSPEED ((uint32_t)0x00000000) /*!< High Speed */
mbed_official 340:28d1f895c6fe 165 #define COMP_MODE_MEDIUMSPEED COMP_CSR_COMP1MODE_0 /*!< Medium Speed */
mbed_official 340:28d1f895c6fe 166 #define COMP_MODE_LOWPOWER COMP_CSR_COMP1MODE_1 /*!< Low power mode */
mbed_official 340:28d1f895c6fe 167 #define COMP_MODE_ULTRALOWPOWER COMP_CSR_COMP1MODE /*!< Ultra-low power mode */
mbed_official 340:28d1f895c6fe 168
mbed_official 340:28d1f895c6fe 169 #define IS_COMP_MODE(MODE) (((MODE) == COMP_MODE_HIGHSPEED) || \
mbed_official 340:28d1f895c6fe 170 ((MODE) == COMP_MODE_MEDIUMSPEED) || \
mbed_official 340:28d1f895c6fe 171 ((MODE) == COMP_MODE_LOWPOWER) || \
mbed_official 340:28d1f895c6fe 172 ((MODE) == COMP_MODE_ULTRALOWPOWER))
mbed_official 340:28d1f895c6fe 173
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 /** @defgroup COMP_InvertingInput COMP InvertingInput
mbed_official 340:28d1f895c6fe 179 * @{
mbed_official 340:28d1f895c6fe 180 */
mbed_official 340:28d1f895c6fe 181
mbed_official 340:28d1f895c6fe 182 #define COMP_INVERTINGINPUT_1_4VREFINT ((uint32_t)0x00000000) /*!< 1/4 VREFINT connected to comparator inverting input */
mbed_official 340:28d1f895c6fe 183 #define COMP_INVERTINGINPUT_1_2VREFINT COMP_CSR_COMP1INSEL_0 /*!< 1/2 VREFINT connected to comparator inverting input */
mbed_official 340:28d1f895c6fe 184 #define COMP_INVERTINGINPUT_3_4VREFINT COMP_CSR_COMP1INSEL_1 /*!< 3/4 VREFINT connected to comparator inverting input */
mbed_official 340:28d1f895c6fe 185 #define COMP_INVERTINGINPUT_VREFINT (COMP_CSR_COMP1INSEL_1|COMP_CSR_COMP1INSEL_0) /*!< VREFINT connected to comparator inverting input */
mbed_official 340:28d1f895c6fe 186 #define COMP_INVERTINGINPUT_DAC1 COMP_CSR_COMP1INSEL_2 /*!< DAC_OUT1 (PA4) connected to comparator inverting input */
mbed_official 340:28d1f895c6fe 187 #define COMP_INVERTINGINPUT_DAC1SWITCHCLOSED (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1SW1) /*!< DAC_OUT1 (PA4) connected to comparator inverting input
mbed_official 340:28d1f895c6fe 188 and close switch (PA0 for COMP1 only) */
mbed_official 340:28d1f895c6fe 189 #define COMP_INVERTINGINPUT_DAC2 (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1INSEL_0) /*!< DAC_OUT2 (PA5) connected to comparator inverting input */
mbed_official 340:28d1f895c6fe 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 */
mbed_official 340:28d1f895c6fe 191
mbed_official 340:28d1f895c6fe 192 #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \
mbed_official 340:28d1f895c6fe 193 ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \
mbed_official 340:28d1f895c6fe 194 ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \
mbed_official 340:28d1f895c6fe 195 ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \
mbed_official 340:28d1f895c6fe 196 ((INPUT) == COMP_INVERTINGINPUT_DAC1) || \
mbed_official 340:28d1f895c6fe 197 ((INPUT) == COMP_INVERTINGINPUT_DAC1SWITCHCLOSED) || \
mbed_official 340:28d1f895c6fe 198 ((INPUT) == COMP_INVERTINGINPUT_DAC2) || \
mbed_official 340:28d1f895c6fe 199 ((INPUT) == COMP_INVERTINGINPUT_IO1))
mbed_official 340:28d1f895c6fe 200 /**
mbed_official 340:28d1f895c6fe 201 * @}
mbed_official 340:28d1f895c6fe 202 */
mbed_official 340:28d1f895c6fe 203
mbed_official 340:28d1f895c6fe 204 /** @defgroup COMP_NonInvertingInput COMP NonInvertingInput
mbed_official 340:28d1f895c6fe 205 * @{
mbed_official 340:28d1f895c6fe 206 */
mbed_official 340:28d1f895c6fe 207 #define COMP_NONINVERTINGINPUT_IO1 ((uint32_t)0x00000000) /*!< I/O1 (PA1 for COMP1, PA3 for COMP2)
mbed_official 340:28d1f895c6fe 208 connected to comparator non inverting input */
mbed_official 340:28d1f895c6fe 209 #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED COMP_CSR_COMP1SW1 /*!< DAC ouput connected to comparator COMP1 non inverting input */
mbed_official 340:28d1f895c6fe 210
mbed_official 340:28d1f895c6fe 211 #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
mbed_official 340:28d1f895c6fe 212 ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))
mbed_official 340:28d1f895c6fe 213 /**
mbed_official 340:28d1f895c6fe 214 * @}
mbed_official 340:28d1f895c6fe 215 */
mbed_official 340:28d1f895c6fe 216
mbed_official 340:28d1f895c6fe 217 /** @defgroup COMP_Output COMP Output
mbed_official 340:28d1f895c6fe 218 * @{
mbed_official 340:28d1f895c6fe 219 */
mbed_official 340:28d1f895c6fe 220
mbed_official 340:28d1f895c6fe 221 /* Output Redirection common for COMP1 and COMP2 */
mbed_official 340:28d1f895c6fe 222 #define COMP_OUTPUT_NONE ((uint32_t)0x00000000) /*!< COMP output isn't connected to other peripherals */
mbed_official 340:28d1f895c6fe 223 #define COMP_OUTPUT_TIM1BKIN COMP_CSR_COMP1OUTSEL_0 /*!< COMP output connected to TIM1 Break Input (BKIN) */
mbed_official 340:28d1f895c6fe 224 #define COMP_OUTPUT_TIM1IC1 COMP_CSR_COMP1OUTSEL_1 /*!< COMP output connected to TIM1 Input Capture 1 */
mbed_official 340:28d1f895c6fe 225 #define COMP_OUTPUT_TIM1OCREFCLR (COMP_CSR_COMP1OUTSEL_1|COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM1 OCREF Clear */
mbed_official 340:28d1f895c6fe 226 #define COMP_OUTPUT_TIM2IC4 COMP_CSR_COMP1OUTSEL_2 /*!< COMP output connected to TIM2 Input Capture 4 */
mbed_official 340:28d1f895c6fe 227 #define COMP_OUTPUT_TIM2OCREFCLR (COMP_CSR_COMP1OUTSEL_2|COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM2 OCREF Clear */
mbed_official 340:28d1f895c6fe 228 #define COMP_OUTPUT_TIM3IC1 (COMP_CSR_COMP1OUTSEL_2|COMP_CSR_COMP1OUTSEL_1) /*!< COMP output connected to TIM3 Input Capture 1 */
mbed_official 340:28d1f895c6fe 229 #define COMP_OUTPUT_TIM3OCREFCLR COMP_CSR_COMP1OUTSEL /*!< COMP output connected to TIM3 OCREF Clear */
mbed_official 340:28d1f895c6fe 230
mbed_official 340:28d1f895c6fe 231 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE) || \
mbed_official 340:28d1f895c6fe 232 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
mbed_official 340:28d1f895c6fe 233 ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
mbed_official 340:28d1f895c6fe 234 ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
mbed_official 340:28d1f895c6fe 235 ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
mbed_official 340:28d1f895c6fe 236 ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
mbed_official 340:28d1f895c6fe 237 ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
mbed_official 340:28d1f895c6fe 238 ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR))
mbed_official 340:28d1f895c6fe 239
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 /** @defgroup COMP_OutputLevel COMP OutputLevel
mbed_official 340:28d1f895c6fe 245 * @{
mbed_official 340:28d1f895c6fe 246 */
mbed_official 340:28d1f895c6fe 247 /* When output polarity is not inverted, comparator output is low when
mbed_official 340:28d1f895c6fe 248 the non-inverting input is at a lower voltage than the inverting input*/
mbed_official 340:28d1f895c6fe 249 #define COMP_OUTPUTLEVEL_LOW ((uint32_t)0x00000000)
mbed_official 340:28d1f895c6fe 250 /* When output polarity is not inverted, comparator output is high when
mbed_official 340:28d1f895c6fe 251 the non-inverting input is at a higher voltage than the inverting input */
mbed_official 340:28d1f895c6fe 252 #define COMP_OUTPUTLEVEL_HIGH COMP_CSR_COMP1OUT
mbed_official 340:28d1f895c6fe 253 /**
mbed_official 340:28d1f895c6fe 254 * @}
mbed_official 340:28d1f895c6fe 255 */
mbed_official 340:28d1f895c6fe 256
mbed_official 340:28d1f895c6fe 257 /** @defgroup COMP_TriggerMode COMP TriggerMode
mbed_official 340:28d1f895c6fe 258 * @{
mbed_official 340:28d1f895c6fe 259 */
mbed_official 340:28d1f895c6fe 260 #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< No External Interrupt trigger detection */
mbed_official 340:28d1f895c6fe 261 #define COMP_TRIGGERMODE_IT_RISING ((uint32_t)0x00000001) /*!< External Interrupt Mode with Rising edge trigger detection */
mbed_official 340:28d1f895c6fe 262 #define COMP_TRIGGERMODE_IT_FALLING ((uint32_t)0x00000002) /*!< External Interrupt Mode with Falling edge trigger detection */
mbed_official 340:28d1f895c6fe 263 #define COMP_TRIGGERMODE_IT_RISING_FALLING ((uint32_t)0x00000003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
mbed_official 340:28d1f895c6fe 264
mbed_official 340:28d1f895c6fe 265 #define IS_COMP_TRIGGERMODE(MODE) (((MODE) == COMP_TRIGGERMODE_NONE) || \
mbed_official 340:28d1f895c6fe 266 ((MODE) == COMP_TRIGGERMODE_IT_RISING) || \
mbed_official 340:28d1f895c6fe 267 ((MODE) == COMP_TRIGGERMODE_IT_FALLING) || \
mbed_official 340:28d1f895c6fe 268 ((MODE) == COMP_TRIGGERMODE_IT_RISING_FALLING))
mbed_official 340:28d1f895c6fe 269 /**
mbed_official 340:28d1f895c6fe 270 * @}
mbed_official 340:28d1f895c6fe 271 */
mbed_official 340:28d1f895c6fe 272
mbed_official 340:28d1f895c6fe 273 /** @defgroup COMP_WindowMode COMP WindowMode
mbed_official 340:28d1f895c6fe 274 * @{
mbed_official 340:28d1f895c6fe 275 */
mbed_official 340:28d1f895c6fe 276 #define COMP_WINDOWMODE_DISABLED ((uint32_t)0x00000000) /*!< Window mode disabled */
mbed_official 340:28d1f895c6fe 277 #define COMP_WINDOWMODE_ENABLED COMP_CSR_WNDWEN /*!< Window mode enabled: non inverting input of comparator 2
mbed_official 340:28d1f895c6fe 278 is connected to the non inverting input of comparator 1 (PA1) */
mbed_official 340:28d1f895c6fe 279
mbed_official 340:28d1f895c6fe 280 #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLED) || \
mbed_official 340:28d1f895c6fe 281 ((WINDOWMODE) == COMP_WINDOWMODE_ENABLED))
mbed_official 340:28d1f895c6fe 282 /**
mbed_official 340:28d1f895c6fe 283 * @}
mbed_official 340:28d1f895c6fe 284 */
mbed_official 340:28d1f895c6fe 285
mbed_official 340:28d1f895c6fe 286 /** @defgroup COMP_ExtiLineEvent COMP ExtiLineEvent
mbed_official 340:28d1f895c6fe 287 * Elements values convention: XXXX0000
mbed_official 340:28d1f895c6fe 288 * - XXXX : Interrupt mask in the EMR/IMR/RTSR/FTSR register
mbed_official 340:28d1f895c6fe 289 * @{
mbed_official 340:28d1f895c6fe 290 */
mbed_official 340:28d1f895c6fe 291 #define COMP_EXTI_LINE_COMP1_EVENT ((uint32_t)0x00200000) /*!< External interrupt line 21 Connected to COMP1 */
mbed_official 340:28d1f895c6fe 292 #define COMP_EXTI_LINE_COMP2_EVENT ((uint32_t)0x00400000) /*!< External interrupt line 22 Connected to COMP2 */
mbed_official 340:28d1f895c6fe 293
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 /** @defgroup COMP_Lock COMP Lock
mbed_official 340:28d1f895c6fe 299 * @{
mbed_official 340:28d1f895c6fe 300 */
mbed_official 340:28d1f895c6fe 301 #define COMP_LOCK_DISABLE ((uint32_t)0x00000000)
mbed_official 340:28d1f895c6fe 302 #define COMP_LOCK_ENABLE COMP_CSR_COMP1LOCK
mbed_official 340:28d1f895c6fe 303
mbed_official 340:28d1f895c6fe 304 #define COMP_STATE_BIT_LOCK ((uint32_t)0x10)
mbed_official 340:28d1f895c6fe 305 /**
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 /* Exported macros -----------------------------------------------------------*/
mbed_official 340:28d1f895c6fe 315 /** @defgroup COMP_Exported_Macros COMP Exported Macros
mbed_official 340:28d1f895c6fe 316 * @{
mbed_official 340:28d1f895c6fe 317 */
mbed_official 340:28d1f895c6fe 318
mbed_official 340:28d1f895c6fe 319 /** @brief Reset COMP handle state
mbed_official 340:28d1f895c6fe 320 * @param __HANDLE__: COMP handle.
mbed_official 340:28d1f895c6fe 321 * @retval None
mbed_official 340:28d1f895c6fe 322 */
mbed_official 340:28d1f895c6fe 323 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
mbed_official 340:28d1f895c6fe 324
mbed_official 340:28d1f895c6fe 325 /**
mbed_official 340:28d1f895c6fe 326 * @brief Checks whether the specified EXTI line flag is set or not.
mbed_official 340:28d1f895c6fe 327 * @param __FLAG__: specifies the COMP Exti sources to be checked.
mbed_official 340:28d1f895c6fe 328 * This parameter can be a value of @ref COMP_ExtiLineEvent
mbed_official 340:28d1f895c6fe 329 * @retval The state of __FLAG__ (SET or RESET).
mbed_official 340:28d1f895c6fe 330 */
mbed_official 340:28d1f895c6fe 331 #define __HAL_COMP_EXTI_GET_FLAG(__FLAG__) (EXTI->PR & (__FLAG__))
mbed_official 340:28d1f895c6fe 332
mbed_official 340:28d1f895c6fe 333 /**
mbed_official 340:28d1f895c6fe 334 * @brief Clear the COMP Exti flags.
mbed_official 340:28d1f895c6fe 335 * @param __FLAG__: specifies the COMP Exti sources to be cleared.
mbed_official 340:28d1f895c6fe 336 * This parameter can be a value of @ref COMP_ExtiLineEvent
mbed_official 340:28d1f895c6fe 337 * @retval None.
mbed_official 340:28d1f895c6fe 338 */
mbed_official 340:28d1f895c6fe 339 #define __HAL_COMP_EXTI_CLEAR_FLAG(__FLAG__) (EXTI->PR = (__FLAG__))
mbed_official 340:28d1f895c6fe 340
mbed_official 340:28d1f895c6fe 341 /**
mbed_official 340:28d1f895c6fe 342 * @brief Enable the COMP Exti Line.
mbed_official 340:28d1f895c6fe 343 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
mbed_official 340:28d1f895c6fe 344 * This parameter can be a value of @ref COMP_ExtiLineEvent
mbed_official 340:28d1f895c6fe 345 * @retval None.
mbed_official 340:28d1f895c6fe 346 */
mbed_official 340:28d1f895c6fe 347 #define __HAL_COMP_EXTI_ENABLE_IT(__EXTILINE__) (EXTI->IMR |= (__EXTILINE__))
mbed_official 340:28d1f895c6fe 348
mbed_official 340:28d1f895c6fe 349 /**
mbed_official 340:28d1f895c6fe 350 * @brief Disable the COMP Exti Line.
mbed_official 340:28d1f895c6fe 351 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
mbed_official 340:28d1f895c6fe 352 * This parameter can be a value of @ref COMP_ExtiLineEvent
mbed_official 340:28d1f895c6fe 353 * @retval None.
mbed_official 340:28d1f895c6fe 354 */
mbed_official 340:28d1f895c6fe 355 #define __HAL_COMP_EXTI_DISABLE_IT(__EXTILINE__) (EXTI->IMR &= ~(__EXTILINE__))
mbed_official 340:28d1f895c6fe 356
mbed_official 340:28d1f895c6fe 357 /**
mbed_official 340:28d1f895c6fe 358 * @brief Enable the Exti Line rising edge trigger.
mbed_official 340:28d1f895c6fe 359 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
mbed_official 340:28d1f895c6fe 360 * This parameter can be a value of @ref COMP_ExtiLineEvent
mbed_official 340:28d1f895c6fe 361 * @retval None.
mbed_official 340:28d1f895c6fe 362 */
mbed_official 340:28d1f895c6fe 363 #define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (EXTI->RTSR |= (__EXTILINE__))
mbed_official 340:28d1f895c6fe 364
mbed_official 340:28d1f895c6fe 365 /**
mbed_official 340:28d1f895c6fe 366 * @brief Disable the Exti Line rising edge trigger.
mbed_official 340:28d1f895c6fe 367 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
mbed_official 340:28d1f895c6fe 368 * This parameter can be a value of @ref COMP_ExtiLineEvent
mbed_official 340:28d1f895c6fe 369 * @retval None.
mbed_official 340:28d1f895c6fe 370 */
mbed_official 340:28d1f895c6fe 371 #define __HAL_COMP_EXTI_RISING_IT_DISABLE(__EXTILINE__) (EXTI->RTSR &= ~(__EXTILINE__))
mbed_official 340:28d1f895c6fe 372
mbed_official 340:28d1f895c6fe 373 /**
mbed_official 340:28d1f895c6fe 374 * @brief Enable the Exti Line falling edge trigger.
mbed_official 340:28d1f895c6fe 375 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
mbed_official 340:28d1f895c6fe 376 * This parameter can be a value of @ref COMP_ExtiLineEvent
mbed_official 340:28d1f895c6fe 377 * @retval None.
mbed_official 340:28d1f895c6fe 378 */
mbed_official 340:28d1f895c6fe 379 #define __HAL_COMP_EXTI_FALLING_IT_ENABLE(__EXTILINE__) (EXTI->FTSR |= (__EXTILINE__))
mbed_official 340:28d1f895c6fe 380
mbed_official 340:28d1f895c6fe 381 /**
mbed_official 340:28d1f895c6fe 382 * @brief Disable the Exti Line falling edge trigger.
mbed_official 340:28d1f895c6fe 383 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
mbed_official 340:28d1f895c6fe 384 * This parameter can be a value of @ref COMP_ExtiLineEvent
mbed_official 340:28d1f895c6fe 385 * @retval None.
mbed_official 340:28d1f895c6fe 386 */
mbed_official 340:28d1f895c6fe 387 #define __HAL_COMP_EXTI_FALLING_IT_DISABLE(__EXTILINE__) (EXTI->FTSR &= ~(__EXTILINE__))
mbed_official 340:28d1f895c6fe 388
mbed_official 340:28d1f895c6fe 389 /**
mbed_official 340:28d1f895c6fe 390 * @brief Get the specified EXTI line for a comparator instance
mbed_official 340:28d1f895c6fe 391 * @param __INSTANCE__: specifies the COMP instance.
mbed_official 340:28d1f895c6fe 392 * @retval value of @ref COMP_ExtiLineEvent
mbed_official 340:28d1f895c6fe 393 */
mbed_official 340:28d1f895c6fe 394 #define __HAL_COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1_EVENT : \
mbed_official 340:28d1f895c6fe 395 COMP_EXTI_LINE_COMP2_EVENT)
mbed_official 340:28d1f895c6fe 396 /**
mbed_official 340:28d1f895c6fe 397 * @}
mbed_official 340:28d1f895c6fe 398 */
mbed_official 340:28d1f895c6fe 399
mbed_official 340:28d1f895c6fe 400 /* Exported functions --------------------------------------------------------*/
mbed_official 340:28d1f895c6fe 401 /** @addtogroup COMP_Exported_Functions COMP Exported Functions
mbed_official 340:28d1f895c6fe 402 * @{
mbed_official 340:28d1f895c6fe 403 */
mbed_official 340:28d1f895c6fe 404 /** @addtogroup COMP_Exported_Functions_Group1 Initialization/de-initialization functions
mbed_official 340:28d1f895c6fe 405 * @brief Initialization and Configuration functions
mbed_official 340:28d1f895c6fe 406 * @{
mbed_official 340:28d1f895c6fe 407 */
mbed_official 340:28d1f895c6fe 408 /* Initialization and de-initialization functions ****************************/
mbed_official 340:28d1f895c6fe 409 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 410 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 411 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 412 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 413 /**
mbed_official 340:28d1f895c6fe 414 * @}
mbed_official 340:28d1f895c6fe 415 */
mbed_official 340:28d1f895c6fe 416
mbed_official 340:28d1f895c6fe 417 /** @addtogroup COMP_Exported_Functions_Group2 I/O operation functions
mbed_official 340:28d1f895c6fe 418 * @brief Data transfers functions
mbed_official 340:28d1f895c6fe 419 * @{
mbed_official 340:28d1f895c6fe 420 */
mbed_official 340:28d1f895c6fe 421 /* IO operation functions *****************************************************/
mbed_official 340:28d1f895c6fe 422 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 423 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 424 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 425 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 426 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 427 /**
mbed_official 340:28d1f895c6fe 428 * @}
mbed_official 340:28d1f895c6fe 429 */
mbed_official 340:28d1f895c6fe 430
mbed_official 340:28d1f895c6fe 431 /** @addtogroup COMP_Exported_Functions_Group3 Peripheral Control functions
mbed_official 340:28d1f895c6fe 432 * @brief management functions
mbed_official 340:28d1f895c6fe 433 * @{
mbed_official 340:28d1f895c6fe 434 */
mbed_official 340:28d1f895c6fe 435 /* Peripheral Control functions ***********************************************/
mbed_official 340:28d1f895c6fe 436 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 437 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 438
mbed_official 340:28d1f895c6fe 439 /* Callback in Interrupt mode */
mbed_official 340:28d1f895c6fe 440 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 441 /**
mbed_official 340:28d1f895c6fe 442 * @}
mbed_official 340:28d1f895c6fe 443 */
mbed_official 340:28d1f895c6fe 444
mbed_official 340:28d1f895c6fe 445 /** @addtogroup COMP_Exported_Functions_Group4 Peripheral State functions
mbed_official 340:28d1f895c6fe 446 * @brief Peripheral State functions
mbed_official 340:28d1f895c6fe 447 * @{
mbed_official 340:28d1f895c6fe 448 */
mbed_official 340:28d1f895c6fe 449 /* Peripheral State and Error functions ***************************************/
mbed_official 340:28d1f895c6fe 450 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
mbed_official 340:28d1f895c6fe 451 /**
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 #endif /* STM32F051x8 || STM32F058xx || */
mbed_official 340:28d1f895c6fe 468 /* STM32F071xB || STM32F072xB || STM32F078xx || */
mbed_official 340:28d1f895c6fe 469 /* STM32F091xC || STM32F098xx */
mbed_official 340:28d1f895c6fe 470
mbed_official 340:28d1f895c6fe 471 #ifdef __cplusplus
mbed_official 340:28d1f895c6fe 472 }
mbed_official 340:28d1f895c6fe 473 #endif
mbed_official 340:28d1f895c6fe 474
mbed_official 340:28d1f895c6fe 475 #endif /* __STM32F0xx_HAL_COMP_H */
mbed_official 340:28d1f895c6fe 476
mbed_official 340:28d1f895c6fe 477 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
mbed_official 340:28d1f895c6fe 478