Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Feb 03 15:31:20 2015 +0000
Revision:
93:e188a91d3eaa
Parent:
92:4fc01daae5a5
Child:
108:34e6b704fe68
Release 93 of the mbed library

Main changes:

- Renesas RZ_A1H bugfixes - i2c, ticker
- new targets - Nucleo F303RE, Nucleo F070RB, BLE SMURFS,
Dragonfly 411RE,
- BusXXX - is connected method, plus operators addition
- LPC8xx - I2c fixes
- timestamp_t reverted to uint32_t
- RTX - fixes regarding stack (alignment, magic word)

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