my fork

Dependents:   Nucleo_blueNRG

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Wed Jun 11 15:14:05 2014 +0100
Revision:
85:024bf7f99721
Child:
92:4fc01daae5a5
Release 85 of the mbed library

Main changes:

- K64F Ethernet fixes
- Updated tests
- Fixes for various mbed targets
- Code cleanup: fixed warnings, more consistent code style
- GCC support for K64F

There is a known issue with the I2C interface on some ST targets. If you
find the I2C interface problematic on your ST board, please log a bug
against this on mbed.org.

Who changed what in which revision?

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