The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
bogdanm
Date:
Fri Sep 12 16:41:52 2014 +0100
Revision:
89:552587b429a1
Parent:
84:0b3ab51c8877
Child:
92:4fc01daae5a5
Release 89 of the mbed library

Main changes:

- low power optimizations for Nordic targets
- code structure changes for Freescale K64F targets
- bug fixes in various backends

Who changed what in which revision?

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