/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/adc/fsl_adc_hal.h substitute line 894 extern } by }

Fork of mbed by mbed official

Committer:
fblanc
Date:
Fri Dec 05 15:42:32 2014 +0000
Revision:
93:9dd889aeda0e
Parent:
90:cb3d968589d8
substitute line 894 extern } by }; /TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/adc/fsl_adc_hal.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 90:cb3d968589d8 1 /**
Kojto 90:cb3d968589d8 2 ******************************************************************************
Kojto 90:cb3d968589d8 3 * @file stm32l1xx_hal_comp.h
Kojto 90:cb3d968589d8 4 * @author MCD Application Team
Kojto 90:cb3d968589d8 5 * @version V1.0.0
Kojto 90:cb3d968589d8 6 * @date 5-September-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 __STM32L1xx_HAL_COMP_H
Kojto 90:cb3d968589d8 40 #define __STM32L1xx_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 /* Includes ------------------------------------------------------------------*/
Kojto 90:cb3d968589d8 47 #include "stm32l1xx_hal_def.h"
Kojto 90:cb3d968589d8 48
Kojto 90:cb3d968589d8 49 /** @addtogroup STM32L1xx_HAL_Driver
Kojto 90:cb3d968589d8 50 * @{
Kojto 90:cb3d968589d8 51 */
Kojto 90:cb3d968589d8 52
Kojto 90:cb3d968589d8 53 /** @addtogroup COMP
Kojto 90:cb3d968589d8 54 * @{
Kojto 90:cb3d968589d8 55 */
Kojto 90:cb3d968589d8 56
Kojto 90:cb3d968589d8 57 /* Exported types ------------------------------------------------------------*/
Kojto 90:cb3d968589d8 58 /** @defgroup COMP_Exported_Types COMP Exported Types
Kojto 90:cb3d968589d8 59 * @{
Kojto 90:cb3d968589d8 60 */
Kojto 90:cb3d968589d8 61
Kojto 90:cb3d968589d8 62 /**
Kojto 90:cb3d968589d8 63 * @brief COMP Init structure definition
Kojto 90:cb3d968589d8 64 */
Kojto 90:cb3d968589d8 65 typedef struct
Kojto 90:cb3d968589d8 66 {
Kojto 90:cb3d968589d8 67
Kojto 90:cb3d968589d8 68 uint32_t InvertingInput; /*!< Selects the inverting input of the comparator.
Kojto 90:cb3d968589d8 69 This parameter can be a value of @ref COMP_InvertingInput
Kojto 90:cb3d968589d8 70 Note: Inverting input can be changed on the fly, while comparator is running.
Kojto 90:cb3d968589d8 71 Note: This feature is available on COMP2 only. If COMP1 is selected, this parameter is discarded (On COMP1, inverting input is fixed to Vrefint). */
Kojto 90:cb3d968589d8 72
Kojto 90:cb3d968589d8 73 uint32_t NonInvertingInput; /*!< Selects the non inverting input of the comparator.
Kojto 90:cb3d968589d8 74 This parameter can be a value of @ref COMPEx_NonInvertingInput */
Kojto 90:cb3d968589d8 75
Kojto 90:cb3d968589d8 76 uint32_t Output; /*!< Selects the output redirection of the comparator.
Kojto 90:cb3d968589d8 77 This parameter can be a value of @ref COMP_Output
Kojto 90:cb3d968589d8 78 Note: This feature is available on COMP2 only. If COMP1 is selected, this parameter is discarded. */
Kojto 90:cb3d968589d8 79
Kojto 90:cb3d968589d8 80 uint32_t Mode; /*!< Selects the operating consumption mode of the comparator
Kojto 90:cb3d968589d8 81 to adjust the speed/consumption.
Kojto 90:cb3d968589d8 82 This parameter can be a value of @ref COMP_Mode
Kojto 90:cb3d968589d8 83 Note: This feature is available on COMP2 only. If COMP1 is selected, this parameter is discarded. */
Kojto 90:cb3d968589d8 84
Kojto 90:cb3d968589d8 85 uint32_t WindowMode; /*!< Selects the window mode of the 2 comparators.
Kojto 90:cb3d968589d8 86 If enabled, non-inverting inputs of the 2 comparators are connected together and are using inputs of COMP2 only (COMP1 non-inverting input is no more accessible, even from ADC channel VCOMP).
Kojto 90:cb3d968589d8 87 This parameter can be a value of @ref COMP_WindowMode
Kojto 90:cb3d968589d8 88 Note: This feature must be enabled from COMP2 instance. If COMP1 is selected, this parameter is discarded. */
Kojto 90:cb3d968589d8 89
Kojto 90:cb3d968589d8 90 uint32_t TriggerMode; /*!< Selects the trigger mode of the comparator when using interruption on EXTI line (interrupt mode).
Kojto 90:cb3d968589d8 91 This parameter can be a value of @ref COMP_TriggerMode
Kojto 90:cb3d968589d8 92 Note: This feature is used with function "HAL_COMP_Start_IT()". In all other functions, this parameter is discarded. */
Kojto 90:cb3d968589d8 93
Kojto 90:cb3d968589d8 94 uint32_t NonInvertingInputPull; /*!< Selects the internal pulling resistor connected on non inverting input.
Kojto 90:cb3d968589d8 95 This parameter can be a value of @ref COMP_NonInvertingInputPull
Kojto 90:cb3d968589d8 96 Note: To avoid extra power consumption, only one resistor should be enabled at a time.
Kojto 90:cb3d968589d8 97 Note: This feature is available on COMP1 only. If COMP2 is selected, this parameter is discarded. */
Kojto 90:cb3d968589d8 98
Kojto 90:cb3d968589d8 99 }COMP_InitTypeDef;
Kojto 90:cb3d968589d8 100
Kojto 90:cb3d968589d8 101 /**
Kojto 90:cb3d968589d8 102 * @brief HAL State structures definition
Kojto 90:cb3d968589d8 103 */
Kojto 90:cb3d968589d8 104 typedef enum
Kojto 90:cb3d968589d8 105 {
Kojto 90:cb3d968589d8 106 HAL_COMP_STATE_RESET = 0x00, /*!< COMP not yet initialized or disabled */
Kojto 90:cb3d968589d8 107 HAL_COMP_STATE_READY = 0x01, /*!< COMP initialized and ready for use */
Kojto 90:cb3d968589d8 108 HAL_COMP_STATE_READY_LOCKED = 0x11, /*!< COMP initialized but the configuration is locked */
Kojto 90:cb3d968589d8 109 HAL_COMP_STATE_BUSY = 0x02, /*!< COMP is running */
Kojto 90:cb3d968589d8 110 HAL_COMP_STATE_BUSY_LOCKED = 0x12 /*!< COMP is running and the configuration is locked */
Kojto 90:cb3d968589d8 111 }HAL_COMP_StateTypeDef;
Kojto 90:cb3d968589d8 112
Kojto 90:cb3d968589d8 113 /**
Kojto 90:cb3d968589d8 114 * @brief COMP Handle Structure definition
Kojto 90:cb3d968589d8 115 */
Kojto 90:cb3d968589d8 116 typedef struct
Kojto 90:cb3d968589d8 117 {
Kojto 90:cb3d968589d8 118 COMP_TypeDef *Instance; /*!< Register base address */
Kojto 90:cb3d968589d8 119 COMP_InitTypeDef Init; /*!< COMP required parameters */
Kojto 90:cb3d968589d8 120 HAL_LockTypeDef Lock; /*!< Locking object */
Kojto 90:cb3d968589d8 121 __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
Kojto 90:cb3d968589d8 122 } COMP_HandleTypeDef;
Kojto 90:cb3d968589d8 123
Kojto 90:cb3d968589d8 124 /**
Kojto 90:cb3d968589d8 125 * @}
Kojto 90:cb3d968589d8 126 */
Kojto 90:cb3d968589d8 127
Kojto 90:cb3d968589d8 128 /* Exported constants --------------------------------------------------------*/
Kojto 90:cb3d968589d8 129 /** @defgroup COMP_Exported_Constants COMP Exported Constants
Kojto 90:cb3d968589d8 130 * @{
Kojto 90:cb3d968589d8 131 */
Kojto 90:cb3d968589d8 132
Kojto 90:cb3d968589d8 133 /** @defgroup COMP_Output COMP Output
Kojto 90:cb3d968589d8 134 * @{
Kojto 90:cb3d968589d8 135 */
Kojto 90:cb3d968589d8 136 #define COMP_OUTPUT_TIM2IC4 ((uint32_t)0x00000000) /*!< COMP2 output connected to TIM2 Input Capture 4 */
Kojto 90:cb3d968589d8 137 #define COMP_OUTPUT_TIM2OCREFCLR ( COMP_CSR_OUTSEL_0) /*!< COMP2 output connected to TIM2 OCREF Clear */
Kojto 90:cb3d968589d8 138 #define COMP_OUTPUT_TIM3IC4 ( COMP_CSR_OUTSEL_1 ) /*!< COMP2 output connected to TIM3 Input Capture 4 */
Kojto 90:cb3d968589d8 139 #define COMP_OUTPUT_TIM3OCREFCLR ( COMP_CSR_OUTSEL_1 | COMP_CSR_OUTSEL_0) /*!< COMP2 output connected to TIM3 OCREF Clear */
Kojto 90:cb3d968589d8 140 #define COMP_OUTPUT_TIM4IC4 (COMP_CSR_OUTSEL_2 ) /*!< COMP2 output connected to TIM4 Input Capture 4 */
Kojto 90:cb3d968589d8 141 #define COMP_OUTPUT_TIM4OCREFCLR (COMP_CSR_OUTSEL_2 | COMP_CSR_OUTSEL_0) /*!< COMP2 output connected to TIM4 OCREF Clear */
Kojto 90:cb3d968589d8 142 #define COMP_OUTPUT_TIM10IC1 (COMP_CSR_OUTSEL_2 | COMP_CSR_OUTSEL_1 ) /*!< COMP2 output connected to TIM10 Input Capture 1 */
Kojto 90:cb3d968589d8 143 #define COMP_OUTPUT_NONE (COMP_CSR_OUTSEL_2 | COMP_CSR_OUTSEL_1 | COMP_CSR_OUTSEL_0) /*!< COMP2 output is not connected to other peripherals */
Kojto 90:cb3d968589d8 144
Kojto 90:cb3d968589d8 145 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
Kojto 90:cb3d968589d8 146 ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
Kojto 90:cb3d968589d8 147 ((OUTPUT) == COMP_OUTPUT_TIM3IC4) || \
Kojto 90:cb3d968589d8 148 ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
Kojto 90:cb3d968589d8 149 ((OUTPUT) == COMP_OUTPUT_TIM4IC4) || \
Kojto 90:cb3d968589d8 150 ((OUTPUT) == COMP_OUTPUT_TIM4OCREFCLR) || \
Kojto 90:cb3d968589d8 151 ((OUTPUT) == COMP_OUTPUT_TIM10IC1) || \
Kojto 90:cb3d968589d8 152 ((OUTPUT) == COMP_OUTPUT_NONE) )
Kojto 90:cb3d968589d8 153 /**
Kojto 90:cb3d968589d8 154 * @}
Kojto 90:cb3d968589d8 155 */
Kojto 90:cb3d968589d8 156
Kojto 90:cb3d968589d8 157 /** @defgroup COMP_InvertingInput COMP InvertingInput
Kojto 90:cb3d968589d8 158 * @{
Kojto 90:cb3d968589d8 159 */
Kojto 90:cb3d968589d8 160 /* Inverting Input specific to COMP2 */
Kojto 90:cb3d968589d8 161 #define COMP_INVERTINGINPUT_IO ( COMP_CSR_INSEL_0) /*!< External I/O (COMP2_INM connected to pin PB3) connected to comparator 2 inverting input */
Kojto 90:cb3d968589d8 162 #define COMP_INVERTINGINPUT_VREFINT ( COMP_CSR_INSEL_1 ) /*!< VREFINT connected to comparator 2 inverting input */
Kojto 90:cb3d968589d8 163 #define COMP_INVERTINGINPUT_3_4VREFINT ( COMP_CSR_INSEL_1 | COMP_CSR_INSEL_0) /*!< 3/4 VREFINT connected to comparator 2 inverting input */
Kojto 90:cb3d968589d8 164 #define COMP_INVERTINGINPUT_1_2VREFINT (COMP_CSR_INSEL_2 ) /*!< 1/2 VREFINT connected to comparator 2 inverting input */
Kojto 90:cb3d968589d8 165 #define COMP_INVERTINGINPUT_1_4VREFINT (COMP_CSR_INSEL_2 | COMP_CSR_INSEL_0) /*!< 1/4 VREFINT connected to comparator 2 inverting input */
Kojto 90:cb3d968589d8 166 #define COMP_INVERTINGINPUT_DAC1 (COMP_CSR_INSEL_2 | COMP_CSR_INSEL_1 ) /*!< DAC_OUT1 (PA4) connected to comparator 2 inverting input */
Kojto 90:cb3d968589d8 167 #define COMP_INVERTINGINPUT_DAC2 (COMP_CSR_INSEL_2 | COMP_CSR_INSEL_1 | COMP_CSR_INSEL_0) /*!< DAC2_OUT (PA5) connected to comparator 2 inverting input */
Kojto 90:cb3d968589d8 168
Kojto 90:cb3d968589d8 169 #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_IO) || \
Kojto 90:cb3d968589d8 170 ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \
Kojto 90:cb3d968589d8 171 ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \
Kojto 90:cb3d968589d8 172 ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \
Kojto 90:cb3d968589d8 173 ((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \
Kojto 90:cb3d968589d8 174 ((INPUT) == COMP_INVERTINGINPUT_DAC1) || \
Kojto 90:cb3d968589d8 175 ((INPUT) == COMP_INVERTINGINPUT_DAC2) )
Kojto 90:cb3d968589d8 176 /**
Kojto 90:cb3d968589d8 177 * @}
Kojto 90:cb3d968589d8 178 */
Kojto 90:cb3d968589d8 179
Kojto 90:cb3d968589d8 180 /** @defgroup COMP_Mode COMP Mode
Kojto 90:cb3d968589d8 181 * @{
Kojto 90:cb3d968589d8 182 */
Kojto 90:cb3d968589d8 183 /* Please refer to the electrical characteristics in the device datasheet for
Kojto 90:cb3d968589d8 184 the power consumption values */
Kojto 90:cb3d968589d8 185 #define COMP_MODE_LOWSPEED ((uint32_t)0x00000000) /*!< Low Speed */
Kojto 90:cb3d968589d8 186 #define COMP_MODE_HIGHSPEED COMP_CSR_SPEED /*!< High Speed */
Kojto 90:cb3d968589d8 187
Kojto 90:cb3d968589d8 188 #define IS_COMP_MODE(SPEED) (((SPEED) == COMP_MODE_LOWSPEED) || \
Kojto 90:cb3d968589d8 189 ((SPEED) == COMP_MODE_HIGHSPEED))
Kojto 90:cb3d968589d8 190 /**
Kojto 90:cb3d968589d8 191 * @}
Kojto 90:cb3d968589d8 192 */
Kojto 90:cb3d968589d8 193
Kojto 90:cb3d968589d8 194 /** @defgroup COMP_WindowMode COMP WindowMode
Kojto 90:cb3d968589d8 195 * @{
Kojto 90:cb3d968589d8 196 */
Kojto 90:cb3d968589d8 197 #define COMP_WINDOWMODE_DISABLED ((uint32_t)0x00000000) /*!< Window mode disabled: COMP1 non-inverting input is independant */
Kojto 90:cb3d968589d8 198 #define COMP_WINDOWMODE_ENABLED COMP_CSR_WNDWE /*!< Window mode enabled: COMP1 non-inverting input is no more accessible, even from ADC channel VCOMP) (connected to COMP2 non-inverting input) */
Kojto 90:cb3d968589d8 199
Kojto 90:cb3d968589d8 200 #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLED) || \
Kojto 90:cb3d968589d8 201 ((WINDOWMODE) == COMP_WINDOWMODE_ENABLED))
Kojto 90:cb3d968589d8 202 /**
Kojto 90:cb3d968589d8 203 * @}
Kojto 90:cb3d968589d8 204 */
Kojto 90:cb3d968589d8 205
Kojto 90:cb3d968589d8 206 /** @defgroup COMP_OutputLevel COMP OutputLevel
Kojto 90:cb3d968589d8 207 * @{
Kojto 90:cb3d968589d8 208 */
Kojto 90:cb3d968589d8 209 /* Comparator output is low when the non-inverting input is at a lower */
Kojto 90:cb3d968589d8 210 /* voltage than the inverting input. */
Kojto 90:cb3d968589d8 211 #define COMP_OUTPUTLEVEL_LOW ((uint32_t)0x00000000)
Kojto 90:cb3d968589d8 212
Kojto 90:cb3d968589d8 213 /* Comparator output is high when the non-inverting input is at a higher */
Kojto 90:cb3d968589d8 214 /* voltage than the inverting input. */
Kojto 90:cb3d968589d8 215 #define COMP_OUTPUTLEVEL_HIGH ((uint32_t)0x00000001)
Kojto 90:cb3d968589d8 216 /**
Kojto 90:cb3d968589d8 217 * @}
Kojto 90:cb3d968589d8 218 */
Kojto 90:cb3d968589d8 219
Kojto 90:cb3d968589d8 220 /** @defgroup COMP_TriggerMode COMP TriggerMode
Kojto 90:cb3d968589d8 221 * @{
Kojto 90:cb3d968589d8 222 */
Kojto 90:cb3d968589d8 223 #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< No External Interrupt trigger detection */
Kojto 90:cb3d968589d8 224 #define COMP_TRIGGERMODE_IT_RISING ((uint32_t)0x00000001) /*!< External Interrupt Mode with Rising edge trigger detection */
Kojto 90:cb3d968589d8 225 #define COMP_TRIGGERMODE_IT_FALLING ((uint32_t)0x00000002) /*!< External Interrupt Mode with Falling edge trigger detection */
Kojto 90:cb3d968589d8 226 #define COMP_TRIGGERMODE_IT_RISING_FALLING ((uint32_t)0x00000003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
Kojto 90:cb3d968589d8 227
Kojto 90:cb3d968589d8 228 #define IS_COMP_TRIGGERMODE(MODE) (((MODE) == COMP_TRIGGERMODE_NONE) || \
Kojto 90:cb3d968589d8 229 ((MODE) == COMP_TRIGGERMODE_IT_RISING) || \
Kojto 90:cb3d968589d8 230 ((MODE) == COMP_TRIGGERMODE_IT_FALLING) || \
Kojto 90:cb3d968589d8 231 ((MODE) == COMP_TRIGGERMODE_IT_RISING_FALLING) )
Kojto 90:cb3d968589d8 232 /**
Kojto 90:cb3d968589d8 233 * @}
Kojto 90:cb3d968589d8 234 */
Kojto 90:cb3d968589d8 235
Kojto 90:cb3d968589d8 236 /** @defgroup COMP_ExtiLineEvent COMP ExtiLineEvent
Kojto 90:cb3d968589d8 237 * @{
Kojto 90:cb3d968589d8 238 */
Kojto 90:cb3d968589d8 239 #define COMP_EXTI_LINE_COMP1_EVENT EXTI_RTSR_TR21 /*!< External interrupt line 21 Connected to COMP1 */
Kojto 90:cb3d968589d8 240 #define COMP_EXTI_LINE_COMP2_EVENT EXTI_RTSR_TR22 /*!< External interrupt line 22 Connected to COMP2 */
Kojto 90:cb3d968589d8 241
Kojto 90:cb3d968589d8 242 /**
Kojto 90:cb3d968589d8 243 * @}
Kojto 90:cb3d968589d8 244 */
Kojto 90:cb3d968589d8 245
Kojto 90:cb3d968589d8 246 /** @defgroup COMP_NonInvertingInputPull COMP NonInvertingInputPull
Kojto 90:cb3d968589d8 247 * @{
Kojto 90:cb3d968589d8 248 */
Kojto 90:cb3d968589d8 249 #define COMP_NONINVERTINGINPUT_NOPULL ((uint32_t)0x00000000) /*!< No internal pull-up or pull-down resistor connected to comparator non inverting input */
Kojto 90:cb3d968589d8 250 #define COMP_NONINVERTINGINPUT_10KPU COMP_CSR_10KPU /*!< Internal 10kOhm pull-up resistor connected to comparator non inverting input */
Kojto 90:cb3d968589d8 251 #define COMP_NONINVERTINGINPUT_10KPD COMP_CSR_10KPD /*!< Internal 10kOhm pull-down resistor connected to comparator non inverting input */
Kojto 90:cb3d968589d8 252 #define COMP_NONINVERTINGINPUT_400KPU COMP_CSR_400KPU /*!< Internal 400kOhm pull-up resistor connected to comparator non inverting input */
Kojto 90:cb3d968589d8 253 #define COMP_NONINVERTINGINPUT_400KPD COMP_CSR_400KPD /*!< Internal 400kOhm pull-down resistor connected to comparator non inverting input */
Kojto 90:cb3d968589d8 254
Kojto 90:cb3d968589d8 255 #define IS_COMP_NONINVERTINGINPUTPULL(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_NOPULL) || \
Kojto 90:cb3d968589d8 256 ((INPUT) == COMP_NONINVERTINGINPUT_10KPU) || \
Kojto 90:cb3d968589d8 257 ((INPUT) == COMP_NONINVERTINGINPUT_10KPD) || \
Kojto 90:cb3d968589d8 258 ((INPUT) == COMP_NONINVERTINGINPUT_400KPU) || \
Kojto 90:cb3d968589d8 259 ((INPUT) == COMP_NONINVERTINGINPUT_400KPD) )
Kojto 90:cb3d968589d8 260 /**
Kojto 90:cb3d968589d8 261 * @}
Kojto 90:cb3d968589d8 262 */
Kojto 90:cb3d968589d8 263
Kojto 90:cb3d968589d8 264 /**
Kojto 90:cb3d968589d8 265 * @}
Kojto 90:cb3d968589d8 266 */
Kojto 90:cb3d968589d8 267
Kojto 90:cb3d968589d8 268
Kojto 90:cb3d968589d8 269 /* Exported macro ------------------------------------------------------------*/
Kojto 90:cb3d968589d8 270
Kojto 90:cb3d968589d8 271 /** @defgroup COMP_Exported_Macro COMP Exported Macro
Kojto 90:cb3d968589d8 272 * @{
Kojto 90:cb3d968589d8 273 */
Kojto 90:cb3d968589d8 274
Kojto 90:cb3d968589d8 275 /** @brief Reset COMP handle state
Kojto 90:cb3d968589d8 276 * @param __HANDLE__: COMP handle.
Kojto 90:cb3d968589d8 277 * @retval None
Kojto 90:cb3d968589d8 278 */
Kojto 90:cb3d968589d8 279 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
Kojto 90:cb3d968589d8 280
Kojto 90:cb3d968589d8 281 /**
Kojto 90:cb3d968589d8 282 * @brief Enables the specified comparator
Kojto 90:cb3d968589d8 283 * @param __HANDLE__: COMP handle.
Kojto 90:cb3d968589d8 284 * @retval None.
Kojto 90:cb3d968589d8 285 */
Kojto 90:cb3d968589d8 286 #define __HAL_COMP_ENABLE(__HANDLE__) \
Kojto 90:cb3d968589d8 287 ( ( ((__HANDLE__)->Instance == COMP1) \
Kojto 90:cb3d968589d8 288 )? \
Kojto 90:cb3d968589d8 289 SET_BIT(COMP->CSR, COMP_CSR_CMP1EN) \
Kojto 90:cb3d968589d8 290 : \
Kojto 90:cb3d968589d8 291 MODIFY_REG(COMP->CSR, COMP_CSR_INSEL, (__HANDLE__)->Init.InvertingInput ) \
Kojto 90:cb3d968589d8 292 )
Kojto 90:cb3d968589d8 293
Kojto 90:cb3d968589d8 294 /**
Kojto 90:cb3d968589d8 295 * @brief Disables the specified comparator
Kojto 90:cb3d968589d8 296 * @param __HANDLE__: COMP handle.
Kojto 90:cb3d968589d8 297 * @retval None.
Kojto 90:cb3d968589d8 298 */
Kojto 90:cb3d968589d8 299 #define __HAL_COMP_DISABLE(__HANDLE__) \
Kojto 90:cb3d968589d8 300 ( ( ((__HANDLE__)->Instance == COMP1) \
Kojto 90:cb3d968589d8 301 )? \
Kojto 90:cb3d968589d8 302 CLEAR_BIT(COMP->CSR, COMP_CSR_CMP1EN) \
Kojto 90:cb3d968589d8 303 : \
Kojto 90:cb3d968589d8 304 CLEAR_BIT(COMP->CSR, COMP_CSR_INSEL) \
Kojto 90:cb3d968589d8 305 )
Kojto 90:cb3d968589d8 306
Kojto 90:cb3d968589d8 307
Kojto 90:cb3d968589d8 308 /** @brief Checks whether the specified COMP flag is set or not.
Kojto 90:cb3d968589d8 309 * @param __HANDLE__: specifies the COMP Handle.
Kojto 90:cb3d968589d8 310 * @param __FLAG__: specifies the flag to check.
Kojto 90:cb3d968589d8 311 * This parameter can be one of the following values:
Kojto 90:cb3d968589d8 312 * @arg COMP_FLAG_LOCK: lock flag
Kojto 90:cb3d968589d8 313 * @retval The new state of __FLAG__ (TRUE or FALSE).
Kojto 90:cb3d968589d8 314 */
Kojto 90:cb3d968589d8 315 #define __HAL_COMP_GET_FLAG(__HANDLE__, __FLAG__) (READ_BIT((__HANDLE__)->Instance->CSR, (__FLAG__)) == (__FLAG__))
Kojto 90:cb3d968589d8 316
Kojto 90:cb3d968589d8 317
Kojto 90:cb3d968589d8 318 /**
Kojto 90:cb3d968589d8 319 * @brief Enable the Exti Line rising edge trigger.
Kojto 90:cb3d968589d8 320 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
Kojto 90:cb3d968589d8 321 * This parameter can be a value of @ref COMP_ExtiLineEvent
Kojto 90:cb3d968589d8 322 * @retval None.
Kojto 90:cb3d968589d8 323 */
Kojto 90:cb3d968589d8 324 #define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (SET_BIT(EXTI->RTSR, (__EXTILINE__)))
Kojto 90:cb3d968589d8 325
Kojto 90:cb3d968589d8 326 /**
Kojto 90:cb3d968589d8 327 * @brief Disable the Exti Line rising edge trigger.
Kojto 90:cb3d968589d8 328 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
Kojto 90:cb3d968589d8 329 * This parameter can be a value of @ref COMP_ExtiLineEvent
Kojto 90:cb3d968589d8 330 * @retval None.
Kojto 90:cb3d968589d8 331 */
Kojto 90:cb3d968589d8 332 #define __HAL_COMP_EXTI_RISING_IT_DISABLE(__EXTILINE__) (CLEAR_BIT(EXTI->RTSR, (__EXTILINE__)))
Kojto 90:cb3d968589d8 333
Kojto 90:cb3d968589d8 334 /**
Kojto 90:cb3d968589d8 335 * @brief Enable the Exti Line falling edge trigger.
Kojto 90:cb3d968589d8 336 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
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_FALLING_IT_ENABLE(__EXTILINE__) (SET_BIT(EXTI->FTSR, (__EXTILINE__)))
Kojto 90:cb3d968589d8 341
Kojto 90:cb3d968589d8 342 /**
Kojto 90:cb3d968589d8 343 * @brief Disable the Exti Line falling edge trigger.
Kojto 90:cb3d968589d8 344 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
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_FALLING_IT_DISABLE(__EXTILINE__) (CLEAR_BIT(EXTI->FTSR, (__EXTILINE__)))
Kojto 90:cb3d968589d8 349
Kojto 90:cb3d968589d8 350 /**
Kojto 90:cb3d968589d8 351 * @brief Get the specified EXTI line for a comparator instance
Kojto 90:cb3d968589d8 352 * @param __INSTANCE__: specifies the COMP instance.
Kojto 90:cb3d968589d8 353 * @retval value of @ref COMP_ExtiLineEvent
Kojto 90:cb3d968589d8 354 */
Kojto 90:cb3d968589d8 355 #define __HAL_COMP_GET_EXTI_LINE(__INSTANCE__) \
Kojto 90:cb3d968589d8 356 ( ( ((__INSTANCE__) == COMP1) \
Kojto 90:cb3d968589d8 357 )? \
Kojto 90:cb3d968589d8 358 (COMP_EXTI_LINE_COMP1_EVENT) \
Kojto 90:cb3d968589d8 359 : \
Kojto 90:cb3d968589d8 360 (COMP_EXTI_LINE_COMP2_EVENT) \
Kojto 90:cb3d968589d8 361 )
Kojto 90:cb3d968589d8 362
Kojto 90:cb3d968589d8 363 /**
Kojto 90:cb3d968589d8 364 * @brief Enable the COMP Exti Line.
Kojto 90:cb3d968589d8 365 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
Kojto 90:cb3d968589d8 366 * This parameter can be a value of @ref COMP_ExtiLineEvent
Kojto 90:cb3d968589d8 367 * @retval None.
Kojto 90:cb3d968589d8 368 */
Kojto 90:cb3d968589d8 369 #define __HAL_COMP_EXTI_ENABLE_IT(__EXTILINE__) (SET_BIT(EXTI->IMR, (__EXTILINE__)))
Kojto 90:cb3d968589d8 370
Kojto 90:cb3d968589d8 371 /**
Kojto 90:cb3d968589d8 372 * @brief Disable the COMP Exti Line.
Kojto 90:cb3d968589d8 373 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
Kojto 90:cb3d968589d8 374 * This parameter can be a value of @ref COMP_ExtiLineEvent
Kojto 90:cb3d968589d8 375 * @retval None.
Kojto 90:cb3d968589d8 376 */
Kojto 90:cb3d968589d8 377 #define __HAL_COMP_EXTI_DISABLE_IT(__EXTILINE__) (CLEAR_BIT(EXTI->IMR, (__EXTILINE__)))
Kojto 90:cb3d968589d8 378
Kojto 90:cb3d968589d8 379 /**
Kojto 90:cb3d968589d8 380 * @brief Checks whether the specified EXTI line flag is set or not.
Kojto 90:cb3d968589d8 381 * @param __FLAG__: specifies the COMP Exti sources to be checked.
Kojto 90:cb3d968589d8 382 * This parameter can be a value of @ref COMP_ExtiLineEvent
Kojto 90:cb3d968589d8 383 * @retval The state of __FLAG__ (SET or RESET).
Kojto 90:cb3d968589d8 384 */
Kojto 90:cb3d968589d8 385 #define __HAL_COMP_EXTI_GET_FLAG(__FLAG__) (READ_BIT(EXTI->PR, (__FLAG__)))
Kojto 90:cb3d968589d8 386
Kojto 90:cb3d968589d8 387 /**
Kojto 90:cb3d968589d8 388 * @brief Clear the COMP Exti flags.
Kojto 90:cb3d968589d8 389 * @param __FLAG__: specifies the COMP Exti sources to be cleared.
Kojto 90:cb3d968589d8 390 * This parameter can be a value of @ref COMP_ExtiLineEvent
Kojto 90:cb3d968589d8 391 * @retval None.
Kojto 90:cb3d968589d8 392 */
Kojto 90:cb3d968589d8 393 #define __HAL_COMP_EXTI_CLEAR_FLAG(__FLAG__) (EXTI->PR = (__FLAG__))
Kojto 90:cb3d968589d8 394
Kojto 90:cb3d968589d8 395 /**
Kojto 90:cb3d968589d8 396 * @brief Generates a Software interrupt on selected EXTI line.
Kojto 90:cb3d968589d8 397 * @param __EXTILINE__: specifies the COMP Exti sources to trig.
Kojto 90:cb3d968589d8 398 * This parameter can be a value of @ref COMP_ExtiLineEvent
Kojto 90:cb3d968589d8 399 * @retval None
Kojto 90:cb3d968589d8 400 */
Kojto 90:cb3d968589d8 401 #define __HAL_COMP_EXTI_GENERATE_SWIT(__EXTILINE__) (SET_BIT(EXTI->SWIER, (__EXTILINE__)))
Kojto 90:cb3d968589d8 402
Kojto 90:cb3d968589d8 403 /**
Kojto 90:cb3d968589d8 404 * @}
Kojto 90:cb3d968589d8 405 */
Kojto 90:cb3d968589d8 406
Kojto 90:cb3d968589d8 407 /* Private macro -------------------------------------------------------------*/
Kojto 90:cb3d968589d8 408
Kojto 90:cb3d968589d8 409 /** @defgroup COMP_Private_Macro COMP Private Macro
Kojto 90:cb3d968589d8 410 * @{
Kojto 90:cb3d968589d8 411 */
Kojto 90:cb3d968589d8 412
Kojto 90:cb3d968589d8 413 /**
Kojto 90:cb3d968589d8 414 * @brief Select the COMP register CSR bit CMPxOUT corresponding to the
Kojto 90:cb3d968589d8 415 * selected COMP instance.
Kojto 90:cb3d968589d8 416 * @param __HANDLE__: COMP handle
Kojto 90:cb3d968589d8 417 * @retval Comparator register CSR bit COMP_CSR_CMP1OUT or COMP_CSR_CMP2OUT
Kojto 90:cb3d968589d8 418 */
Kojto 90:cb3d968589d8 419 #define __COMP_CSR_CMPXOUT(__HANDLE__) \
Kojto 90:cb3d968589d8 420 ( ( ((__HANDLE__)->Instance == COMP1) \
Kojto 90:cb3d968589d8 421 )? \
Kojto 90:cb3d968589d8 422 (COMP_CSR_CMP1OUT) \
Kojto 90:cb3d968589d8 423 : \
Kojto 90:cb3d968589d8 424 (COMP_CSR_CMP2OUT) \
Kojto 90:cb3d968589d8 425 )
Kojto 90:cb3d968589d8 426
Kojto 90:cb3d968589d8 427 /**
Kojto 90:cb3d968589d8 428 * @brief Verification of COMP state: enabled or disabled
Kojto 90:cb3d968589d8 429 * @param __HANDLE__: COMP handle
Kojto 90:cb3d968589d8 430 * @retval SET (COMP enabled) or RESET (COMP disabled)
Kojto 90:cb3d968589d8 431 */
Kojto 90:cb3d968589d8 432 #define __COMP_IS_ENABLED(__HANDLE__) \
Kojto 90:cb3d968589d8 433 ( ( ((__HANDLE__)->Instance == COMP1) \
Kojto 90:cb3d968589d8 434 )? \
Kojto 90:cb3d968589d8 435 (((READ_BIT(COMP->CSR , COMP_CSR_CMP1EN) == COMP_CSR_CMP1EN) \
Kojto 90:cb3d968589d8 436 ) ? SET : RESET) \
Kojto 90:cb3d968589d8 437 : \
Kojto 90:cb3d968589d8 438 (((READ_BIT(COMP->CSR , COMP_CSR_INSEL) != RESET) \
Kojto 90:cb3d968589d8 439 ) ? SET : RESET) \
Kojto 90:cb3d968589d8 440 )
Kojto 90:cb3d968589d8 441
Kojto 90:cb3d968589d8 442 /**
Kojto 90:cb3d968589d8 443 * @}
Kojto 90:cb3d968589d8 444 */
Kojto 90:cb3d968589d8 445
Kojto 90:cb3d968589d8 446
Kojto 90:cb3d968589d8 447 /* Include COMP HAL Extension module */
Kojto 90:cb3d968589d8 448 #include "stm32l1xx_hal_comp_ex.h"
Kojto 90:cb3d968589d8 449
Kojto 90:cb3d968589d8 450 /* Exported functions --------------------------------------------------------*/
Kojto 90:cb3d968589d8 451 /** @addtogroup COMP_Exported_Functions
Kojto 90:cb3d968589d8 452 * @{
Kojto 90:cb3d968589d8 453 */
Kojto 90:cb3d968589d8 454
Kojto 90:cb3d968589d8 455 /* Initialization and de-initialization functions ******************************/
Kojto 90:cb3d968589d8 456 /** @addtogroup COMP_Exported_Functions_Group1
Kojto 90:cb3d968589d8 457 * @{
Kojto 90:cb3d968589d8 458 */
Kojto 90:cb3d968589d8 459 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 460 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 461 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 462 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 463 /**
Kojto 90:cb3d968589d8 464 * @}
Kojto 90:cb3d968589d8 465 */
Kojto 90:cb3d968589d8 466
Kojto 90:cb3d968589d8 467 /* I/O operation functions *****************************************************/
Kojto 90:cb3d968589d8 468 /** @addtogroup COMP_Exported_Functions_Group2
Kojto 90:cb3d968589d8 469 * @{
Kojto 90:cb3d968589d8 470 */
Kojto 90:cb3d968589d8 471 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 472 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 473 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 474 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 475 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 476 /**
Kojto 90:cb3d968589d8 477 * @}
Kojto 90:cb3d968589d8 478 */
Kojto 90:cb3d968589d8 479
Kojto 90:cb3d968589d8 480 /* Peripheral Control functions ************************************************/
Kojto 90:cb3d968589d8 481 /** @addtogroup COMP_Exported_Functions_Group3
Kojto 90:cb3d968589d8 482 * @{
Kojto 90:cb3d968589d8 483 */
Kojto 90:cb3d968589d8 484 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 485 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 486
Kojto 90:cb3d968589d8 487 /* Callback in Interrupt mode */
Kojto 90:cb3d968589d8 488 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 489 /**
Kojto 90:cb3d968589d8 490 * @}
Kojto 90:cb3d968589d8 491 */
Kojto 90:cb3d968589d8 492
Kojto 90:cb3d968589d8 493 /* Peripheral State functions **************************************************/
Kojto 90:cb3d968589d8 494 /** @addtogroup COMP_Exported_Functions_Group4
Kojto 90:cb3d968589d8 495 * @{
Kojto 90:cb3d968589d8 496 */
Kojto 90:cb3d968589d8 497 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
Kojto 90:cb3d968589d8 498 /**
Kojto 90:cb3d968589d8 499 * @}
Kojto 90:cb3d968589d8 500 */
Kojto 90:cb3d968589d8 501
Kojto 90:cb3d968589d8 502 /**
Kojto 90:cb3d968589d8 503 * @}
Kojto 90:cb3d968589d8 504 */
Kojto 90:cb3d968589d8 505
Kojto 90:cb3d968589d8 506 /**
Kojto 90:cb3d968589d8 507 * @}
Kojto 90:cb3d968589d8 508 */
Kojto 90:cb3d968589d8 509
Kojto 90:cb3d968589d8 510 /**
Kojto 90:cb3d968589d8 511 * @}
Kojto 90:cb3d968589d8 512 */
Kojto 90:cb3d968589d8 513
Kojto 90:cb3d968589d8 514 #ifdef __cplusplus
Kojto 90:cb3d968589d8 515 }
Kojto 90:cb3d968589d8 516 #endif
Kojto 90:cb3d968589d8 517
Kojto 90:cb3d968589d8 518 #endif /* __STM32L1xx_HAL_COMP_H */
Kojto 90:cb3d968589d8 519
Kojto 90:cb3d968589d8 520 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/