my fork

Dependents:   Nucleo_blueNRG

Fork of mbed by mbed official

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