meh

Fork of mbed by mbed official

Committer:
ricardobtez
Date:
Tue Apr 05 23:51:21 2016 +0000
Revision:
118:16969dd821af
Parent:
92:4fc01daae5a5
Child:
96:487b796308b0
dgdgr

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 92:4fc01daae5a5 5 * @version V1.1.0
bogdanm 92:4fc01daae5a5 6 * @date 18-June-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 92:4fc01daae5a5 72 uint32_t LPTIMConnection; /*!< Selects if the COMP connection to the LPTIM is established or not.
bogdanm 92:4fc01daae5a5 73 This parameter can be a value of @ref COMP_LPTIMConnection */
bogdanm 92:4fc01daae5a5 74
bogdanm 84:0b3ab51c8877 75 uint32_t OutputPol; /*!< Selects the output polarity of the comparator.
bogdanm 84:0b3ab51c8877 76 This parameter can be a value of @ref COMP_OutputPolarity */
bogdanm 84:0b3ab51c8877 77
bogdanm 84:0b3ab51c8877 78 uint32_t Mode; /*!< Selects the operating comsumption mode of the comparator
bogdanm 84:0b3ab51c8877 79 to adjust the speed/consumption.
bogdanm 84:0b3ab51c8877 80 This parameter can be a value of @ref COMP_Mode */
bogdanm 84:0b3ab51c8877 81
bogdanm 84:0b3ab51c8877 82 uint32_t WindowMode; /*!< Selects the window mode of the comparator 2.
bogdanm 84:0b3ab51c8877 83 This parameter can be a value of @ref COMP_WindowMode */
bogdanm 84:0b3ab51c8877 84
bogdanm 84:0b3ab51c8877 85 uint32_t TriggerMode; /*!< Selects the trigger mode of the comparator (interrupt mode).
bogdanm 84:0b3ab51c8877 86 This parameter can be a value of @ref COMP_TriggerMode */
bogdanm 84:0b3ab51c8877 87
bogdanm 84:0b3ab51c8877 88 }COMP_InitTypeDef;
bogdanm 84:0b3ab51c8877 89
bogdanm 84:0b3ab51c8877 90 /**
bogdanm 84:0b3ab51c8877 91 * @brief HAL State structures definition
bogdanm 84:0b3ab51c8877 92 */
bogdanm 84:0b3ab51c8877 93 typedef enum
bogdanm 84:0b3ab51c8877 94 {
bogdanm 84:0b3ab51c8877 95 HAL_COMP_STATE_RESET = 0x00, /*!< COMP not yet initialized or disabled */
bogdanm 84:0b3ab51c8877 96 HAL_COMP_STATE_READY = 0x01, /*!< COMP initialized and ready for use */
bogdanm 84:0b3ab51c8877 97 HAL_COMP_STATE_READY_LOCKED = 0x11, /*!< COMP initialized but the configuration is locked */
bogdanm 84:0b3ab51c8877 98 HAL_COMP_STATE_BUSY = 0x02, /*!< COMP is running */
bogdanm 84:0b3ab51c8877 99 HAL_COMP_STATE_BUSY_LOCKED = 0x12 /*!< COMP is running and the configuration is locked */
bogdanm 84:0b3ab51c8877 100 }HAL_COMP_StateTypeDef;
bogdanm 84:0b3ab51c8877 101
bogdanm 84:0b3ab51c8877 102 /**
bogdanm 92:4fc01daae5a5 103 * @brief COMP Handle Structure definition
bogdanm 84:0b3ab51c8877 104 */
bogdanm 84:0b3ab51c8877 105 typedef struct
bogdanm 84:0b3ab51c8877 106 {
bogdanm 84:0b3ab51c8877 107 COMP_TypeDef *Instance; /*!< Register base address */
bogdanm 84:0b3ab51c8877 108 COMP_InitTypeDef Init; /*!< COMP required parameters */
bogdanm 84:0b3ab51c8877 109 HAL_LockTypeDef Lock; /*!< Locking object */
bogdanm 84:0b3ab51c8877 110 __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
bogdanm 84:0b3ab51c8877 111 } COMP_HandleTypeDef;
bogdanm 84:0b3ab51c8877 112
bogdanm 84:0b3ab51c8877 113 /* Exported constants --------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 114 /** @defgroup COMP_Exported_Constants
bogdanm 84:0b3ab51c8877 115 * @{
bogdanm 84:0b3ab51c8877 116 */
bogdanm 84:0b3ab51c8877 117
bogdanm 84:0b3ab51c8877 118 /** @defgroup COMP_OutputPolarity
bogdanm 84:0b3ab51c8877 119 * @{
bogdanm 84:0b3ab51c8877 120 */
bogdanm 84:0b3ab51c8877 121 #define COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output on GPIO isn't inverted */
bogdanm 84:0b3ab51c8877 122 #define COMP_OUTPUTPOL_INVERTED COMP_CSR_COMPxPOLARITY /*!< COMP output on GPIO is inverted */
bogdanm 84:0b3ab51c8877 123 #define IS_COMP_OUTPUTPOL(POL) (((POL) == COMP_OUTPUTPOL_NONINVERTED) || \
bogdanm 84:0b3ab51c8877 124 ((POL) == COMP_OUTPUTPOL_INVERTED))
bogdanm 84:0b3ab51c8877 125 /**
bogdanm 84:0b3ab51c8877 126 * @}
bogdanm 84:0b3ab51c8877 127 */
bogdanm 84:0b3ab51c8877 128
bogdanm 84:0b3ab51c8877 129
bogdanm 84:0b3ab51c8877 130 /** @defgroup COMP_InvertingInput
bogdanm 84:0b3ab51c8877 131 * @{
bogdanm 84:0b3ab51c8877 132 */
bogdanm 84:0b3ab51c8877 133
bogdanm 84:0b3ab51c8877 134 /* Inverting Input specific to COMP1 */
bogdanm 84:0b3ab51c8877 135 #define COMP_INVERTINGINPUT_VREFINT ((uint32_t)0x00000000) /*!< VREFINT connected to comparator1 inverting input */
bogdanm 84:0b3ab51c8877 136 #define COMP_INVERTINGINPUT_IO1 ((uint32_t)0x00000010) /*!< I/O1 connected to comparator inverting input (PA0) for COMP1 and (PA2) for COMP2*/
bogdanm 84:0b3ab51c8877 137 #define COMP_INVERTINGINPUT_DAC1 ((uint32_t)0x00000020) /*!< DAC1_OUT (PA4) connected to comparator inverting input */
bogdanm 84:0b3ab51c8877 138 #define COMP_INVERTINGINPUT_IO2 ((uint32_t)0x00000030) /*!< I/O2 (PA5) connected to comparator inverting input */
bogdanm 84:0b3ab51c8877 139
bogdanm 84:0b3ab51c8877 140 /* Inverting Input specific to COMP2 */
bogdanm 84:0b3ab51c8877 141 #define COMP_INVERTINGINPUT_1_4VREFINT ((uint32_t)0x00000040) /*!< 1/4 VREFINT connected to comparator inverting input */
bogdanm 84:0b3ab51c8877 142 #define COMP_INVERTINGINPUT_1_2VREFINT ((uint32_t)0x00000050) /*!< 1/2 VREFINT connected to comparator inverting input */
bogdanm 84:0b3ab51c8877 143 #define COMP_INVERTINGINPUT_3_4VREFINT ((uint32_t)0x00000060) /*!< 3/4 VREFINT connected to comparator inverting input */
bogdanm 84:0b3ab51c8877 144 #define COMP_INVERTINGINPUT_IO3 ((uint32_t)0x00000070) /*!< I/O3 (PB3) for COMP2 connected to comparator inverting input */
bogdanm 84:0b3ab51c8877 145
bogdanm 84:0b3ab51c8877 146
bogdanm 84:0b3ab51c8877 147 #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \
bogdanm 84:0b3ab51c8877 148 ((INPUT) == COMP_INVERTINGINPUT_IO1) || \
bogdanm 84:0b3ab51c8877 149 ((INPUT) == COMP_INVERTINGINPUT_DAC1) || \
bogdanm 84:0b3ab51c8877 150 ((INPUT) == COMP_INVERTINGINPUT_IO2) || \
bogdanm 84:0b3ab51c8877 151 ((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \
bogdanm 84:0b3ab51c8877 152 ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \
bogdanm 84:0b3ab51c8877 153 ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \
bogdanm 84:0b3ab51c8877 154 ((INPUT) == COMP_INVERTINGINPUT_IO3))
bogdanm 84:0b3ab51c8877 155
bogdanm 84:0b3ab51c8877 156 /**
bogdanm 84:0b3ab51c8877 157 * @}
bogdanm 84:0b3ab51c8877 158 */
bogdanm 84:0b3ab51c8877 159
bogdanm 84:0b3ab51c8877 160
bogdanm 84:0b3ab51c8877 161 /** @defgroup COMP_NonInvertingInput
bogdanm 84:0b3ab51c8877 162 * @{
bogdanm 84:0b3ab51c8877 163 */
bogdanm 84:0b3ab51c8877 164
bogdanm 84:0b3ab51c8877 165 #define COMP_NONINVERTINGINPUT_IO1 ((uint32_t)0x00000000) /*!< I/O1 (PA3) connected to comparator non inverting input */
bogdanm 84:0b3ab51c8877 166 #define COMP_NONINVERTINGINPUT_IO2 ((uint32_t)0x00000100) /*!< I/O2 (PB4) connected to comparator non inverting input */
bogdanm 84:0b3ab51c8877 167 #define COMP_NONINVERTINGINPUT_IO3 ((uint32_t)0x00000200) /*!< I/O3 (PB5) connected to comparator non inverting input */
bogdanm 84:0b3ab51c8877 168 #define COMP_NONINVERTINGINPUT_IO4 ((uint32_t)0x00000300) /*!< I/O1 (PB6) connected to comparator non inverting input */
bogdanm 84:0b3ab51c8877 169 #define COMP_NONINVERTINGINPUT_IO5 ((uint32_t)0x00000400) /*!< I/O3 (PB7) connected to comparator non inverting input */
bogdanm 84:0b3ab51c8877 170 #define COMP_NONINVERTINGINPUT_IO6 ((uint32_t)0x00000500) /*!< I/O3 (PB7) connected to comparator non inverting input */
bogdanm 84:0b3ab51c8877 171 #define COMP_NONINVERTINGINPUT_IO7 ((uint32_t)0x00000600) /*!< I/O3 (PB7) connected to comparator non inverting input */
bogdanm 84:0b3ab51c8877 172 #define COMP_NONINVERTINGINPUT_IO8 ((uint32_t)0x00000700) /*!< I/O3 (PB7) connected to comparator non inverting input */
bogdanm 84:0b3ab51c8877 173
bogdanm 84:0b3ab51c8877 174 #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
bogdanm 84:0b3ab51c8877 175 ((INPUT) == COMP_NONINVERTINGINPUT_IO2) || \
bogdanm 84:0b3ab51c8877 176 ((INPUT) == COMP_NONINVERTINGINPUT_IO3) || \
bogdanm 84:0b3ab51c8877 177 ((INPUT) == COMP_NONINVERTINGINPUT_IO4) || \
bogdanm 84:0b3ab51c8877 178 ((INPUT) == COMP_NONINVERTINGINPUT_IO5) || \
bogdanm 84:0b3ab51c8877 179 ((INPUT) == COMP_NONINVERTINGINPUT_IO6) || \
bogdanm 84:0b3ab51c8877 180 ((INPUT) == COMP_NONINVERTINGINPUT_IO7) || \
bogdanm 84:0b3ab51c8877 181 ((INPUT) == COMP_NONINVERTINGINPUT_IO8))
bogdanm 84:0b3ab51c8877 182 /**
bogdanm 84:0b3ab51c8877 183 * @}
bogdanm 84:0b3ab51c8877 184 */
bogdanm 84:0b3ab51c8877 185
bogdanm 84:0b3ab51c8877 186
bogdanm 84:0b3ab51c8877 187 /** @defgroup COMP_Mode
bogdanm 84:0b3ab51c8877 188 * @{
bogdanm 84:0b3ab51c8877 189 */
bogdanm 84:0b3ab51c8877 190 /* Please refer to the electrical characteristics in the device datasheet for
bogdanm 84:0b3ab51c8877 191 the power consumption values */
bogdanm 84:0b3ab51c8877 192 #define COMP_MODE_HIGHSPEED COMP_CSR_COMP2SPEED /*!< High Speed */
bogdanm 84:0b3ab51c8877 193 #define COMP_MODE_LOWSPEED ((uint32_t)0x00000000) /*!< Low Speed */
bogdanm 84:0b3ab51c8877 194
bogdanm 84:0b3ab51c8877 195 #define IS_COMP_MODE(SPEED) (((SPEED) == COMP_MODE_HIGHSPEED) || \
bogdanm 84:0b3ab51c8877 196 ((SPEED) == COMP_MODE_LOWSPEED))
bogdanm 84:0b3ab51c8877 197 /**
bogdanm 84:0b3ab51c8877 198 * @}
bogdanm 84:0b3ab51c8877 199 */
bogdanm 84:0b3ab51c8877 200
bogdanm 84:0b3ab51c8877 201 /** @defgroup COMP_WindowMode
bogdanm 84:0b3ab51c8877 202 * @{
bogdanm 84:0b3ab51c8877 203 */
bogdanm 84:0b3ab51c8877 204 #define COMP_WINDOWMODE_DISABLED ((uint32_t)0x00000000) /*!< Window mode disabled (Plus input of comparator 1 connected to PA1)*/
bogdanm 84:0b3ab51c8877 205 #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 206 #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLED) || \
bogdanm 84:0b3ab51c8877 207 ((WINDOWMODE) == COMP_WINDOWMODE_ENABLED))
bogdanm 84:0b3ab51c8877 208
bogdanm 84:0b3ab51c8877 209 #define IS_COMP_WINDOWMODE_INSTANCE(INSTANCE) ((INSTANCE) == COMP1)
bogdanm 84:0b3ab51c8877 210 /**
bogdanm 84:0b3ab51c8877 211 * @}
bogdanm 84:0b3ab51c8877 212 */
bogdanm 84:0b3ab51c8877 213
bogdanm 92:4fc01daae5a5 214 /** @defgroup COMP_LPTIMConnection
bogdanm 92:4fc01daae5a5 215 * @{
bogdanm 92:4fc01daae5a5 216 */
bogdanm 92:4fc01daae5a5 217 #define COMP_LPTIMCONNECTION_DISABLED ((uint32_t)0x00000000) /*!< COMPx signal is gated */
bogdanm 92:4fc01daae5a5 218 #define COMP_LPTIMCONNECTION_ENABLED COMP_CSR_COMP1LPTIM1IN1 /*!< COMPx signal is connected to LPTIM */
bogdanm 92:4fc01daae5a5 219 #define IS_COMP_LPTIMCONNECTION(LPTIMCONNECTION) (((LPTIMCONNECTION) == COMP_LPTIMCONNECTION_DISABLED) || \
bogdanm 92:4fc01daae5a5 220 ((LPTIMCONNECTION) == COMP_LPTIMCONNECTION_ENABLED))
bogdanm 92:4fc01daae5a5 221
bogdanm 92:4fc01daae5a5 222 /**
bogdanm 92:4fc01daae5a5 223 * @}
bogdanm 92:4fc01daae5a5 224 */
bogdanm 84:0b3ab51c8877 225
bogdanm 84:0b3ab51c8877 226 /** @defgroup COMP_OutputLevel
bogdanm 84:0b3ab51c8877 227 * @{
bogdanm 84:0b3ab51c8877 228 */
bogdanm 84:0b3ab51c8877 229 /* When output polarity is not inverted, comparator output is low when
bogdanm 84:0b3ab51c8877 230 the non-inverting input is at a lower voltage than the inverting input*/
bogdanm 84:0b3ab51c8877 231 #define COMP_OUTPUTLEVEL_LOW ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 232 /* When output polarity is not inverted, comparator output is high when
bogdanm 84:0b3ab51c8877 233 the non-inverting input is at a higher voltage than the inverting input */
bogdanm 84:0b3ab51c8877 234 #define COMP_OUTPUTLEVEL_HIGH COMP_CSR_COMPxOUTVALUE
bogdanm 84:0b3ab51c8877 235 /**
bogdanm 84:0b3ab51c8877 236 * @}
bogdanm 84:0b3ab51c8877 237 */
bogdanm 84:0b3ab51c8877 238
bogdanm 84:0b3ab51c8877 239 /* CSR register Mask */
bogdanm 84:0b3ab51c8877 240 #define COMP_CSR_UPDATE_PARAMETERS_MASK ((uint32_t)0xC0008779)
bogdanm 84:0b3ab51c8877 241
bogdanm 84:0b3ab51c8877 242 #define COMP_LOCK_DISABLE ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 243 #define COMP_LOCK_ENABLE COMP_CSR_COMPxLOCK
bogdanm 84:0b3ab51c8877 244
bogdanm 84:0b3ab51c8877 245 #define COMP_STATE_BIT_LOCK ((uint32_t)0x10)
bogdanm 84:0b3ab51c8877 246
bogdanm 92:4fc01daae5a5 247 /** @defgroup COMP_TriggerMode
bogdanm 84:0b3ab51c8877 248 * @{
bogdanm 84:0b3ab51c8877 249 */
bogdanm 84:0b3ab51c8877 250 #define COMP_TRIGGERMODE_IT_RISING ((uint32_t)0x00000001) /*!< External Interrupt Mode with Rising edge trigger detection */
bogdanm 84:0b3ab51c8877 251 #define COMP_TRIGGERMODE_IT_FALLING ((uint32_t)0x00000002) /*!< External Interrupt Mode with Falling edge trigger detection */
bogdanm 84:0b3ab51c8877 252 #define COMP_TRIGGERMODE_IT_RISING_FALLING ((uint32_t)0x00000003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
bogdanm 84:0b3ab51c8877 253 #define IS_COMP_TRIGGERMODE(MODE) (((MODE) == COMP_TRIGGERMODE_IT_RISING) || \
bogdanm 84:0b3ab51c8877 254 ((MODE) == COMP_TRIGGERMODE_IT_FALLING) || \
bogdanm 84:0b3ab51c8877 255 ((MODE) == COMP_TRIGGERMODE_IT_RISING_FALLING))
bogdanm 84:0b3ab51c8877 256 /**
bogdanm 84:0b3ab51c8877 257 * @}
bogdanm 84:0b3ab51c8877 258 */
bogdanm 84:0b3ab51c8877 259
bogdanm 84:0b3ab51c8877 260 /** @defgroup COMP_ExtiLineEvent
bogdanm 84:0b3ab51c8877 261 * @{
bogdanm 84:0b3ab51c8877 262 */
bogdanm 84:0b3ab51c8877 263
bogdanm 84:0b3ab51c8877 264 #define COMP_EXTI_LINE_COMP2_EVENT ((uint32_t)0x00400000) /*!< External interrupt line 22 Connected to COMP2 */
bogdanm 84:0b3ab51c8877 265 #define COMP_EXTI_LINE_COMP1_EVENT ((uint32_t)0x00200000) /*!< External interrupt line 21 Connected to COMP1 */
bogdanm 84:0b3ab51c8877 266
bogdanm 84:0b3ab51c8877 267 /**
bogdanm 84:0b3ab51c8877 268 * @}
bogdanm 84:0b3ab51c8877 269 */
bogdanm 84:0b3ab51c8877 270
bogdanm 84:0b3ab51c8877 271 /**
bogdanm 84:0b3ab51c8877 272 * @}
bogdanm 84:0b3ab51c8877 273 */
bogdanm 84:0b3ab51c8877 274
bogdanm 84:0b3ab51c8877 275 /* Exported macro ------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 276 /** @brief Reset COMP handle state
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_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
bogdanm 84:0b3ab51c8877 281
bogdanm 84:0b3ab51c8877 282 /**
bogdanm 84:0b3ab51c8877 283 * @brief Enables the specified comparator
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_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CSR |= (COMP_CSR_COMPxEN))
bogdanm 84:0b3ab51c8877 288
bogdanm 84:0b3ab51c8877 289 /**
bogdanm 84:0b3ab51c8877 290 * @brief Disables the specified comparator
bogdanm 84:0b3ab51c8877 291 * @param __HANDLE__: COMP handle.
bogdanm 84:0b3ab51c8877 292 * @retval None.
bogdanm 84:0b3ab51c8877 293 */
bogdanm 84:0b3ab51c8877 294 #define __HAL_COMP_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CSR &= ~(COMP_CSR_COMPxEN))
bogdanm 84:0b3ab51c8877 295
bogdanm 84:0b3ab51c8877 296 /**
bogdanm 84:0b3ab51c8877 297 * @brief Lock the specified comparator configuration
bogdanm 84:0b3ab51c8877 298 * @param __HANDLE__: COMP handle.
bogdanm 84:0b3ab51c8877 299 * @retval None.
bogdanm 84:0b3ab51c8877 300 */
bogdanm 84:0b3ab51c8877 301 #define __HAL_COMP_LOCK(__HANDLE__) ((__HANDLE__)->Instance->CSR |= COMP_CSR_COMPxLOCK)
bogdanm 84:0b3ab51c8877 302
bogdanm 84:0b3ab51c8877 303 /** @brief Checks whether the specified COMP flag is set or not.
bogdanm 84:0b3ab51c8877 304 * @param __HANDLE__: specifies the COMP Handle.
bogdanm 84:0b3ab51c8877 305 * @param __FLAG__: specifies the flag to check.
bogdanm 84:0b3ab51c8877 306 * This parameter can be one of the following values:
bogdanm 84:0b3ab51c8877 307 * @arg COMP_FLAG_LOCK: lock flag
bogdanm 84:0b3ab51c8877 308 * @retval The new state of __FLAG__ (TRUE or FALSE).
bogdanm 84:0b3ab51c8877 309 */
bogdanm 84:0b3ab51c8877 310 #define __HAL_COMP_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->CSR & (__FLAG__)) == (__FLAG__))
bogdanm 84:0b3ab51c8877 311
bogdanm 84:0b3ab51c8877 312
bogdanm 84:0b3ab51c8877 313 /**
bogdanm 84:0b3ab51c8877 314 * @brief Enable the Exti Line rising edge trigger.
bogdanm 84:0b3ab51c8877 315 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
bogdanm 84:0b3ab51c8877 316 * This parameter can be a value of @ref COMP_ExtiLineEvent
bogdanm 84:0b3ab51c8877 317 * @retval None.
bogdanm 84:0b3ab51c8877 318 */
bogdanm 84:0b3ab51c8877 319 #define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (EXTI->RTSR |= (__EXTILINE__))
bogdanm 84:0b3ab51c8877 320
bogdanm 84:0b3ab51c8877 321 /**
bogdanm 84:0b3ab51c8877 322 * @brief Disable the Exti Line rising edge trigger.
bogdanm 84:0b3ab51c8877 323 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
bogdanm 84:0b3ab51c8877 324 * This parameter can be a value of @ref COMP_ExtiLineEvent
bogdanm 84:0b3ab51c8877 325 * @retval None.
bogdanm 84:0b3ab51c8877 326 */
bogdanm 84:0b3ab51c8877 327 #define __HAL_COMP_EXTI_RISING_IT_DISABLE(__EXTILINE__) (EXTI->RTSR &= ~(__EXTILINE__))
bogdanm 84:0b3ab51c8877 328
bogdanm 84:0b3ab51c8877 329 /**
bogdanm 84:0b3ab51c8877 330 * @brief Enable the Exti Line falling edge trigger.
bogdanm 84:0b3ab51c8877 331 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
bogdanm 84:0b3ab51c8877 332 * This parameter can be a value of @ref COMP_ExtiLineEvent
bogdanm 84:0b3ab51c8877 333 * @retval None.
bogdanm 84:0b3ab51c8877 334 */
bogdanm 84:0b3ab51c8877 335 #define __HAL_COMP_EXTI_FALLING_IT_ENABLE(__EXTILINE__) (EXTI->FTSR |= (__EXTILINE__))
bogdanm 84:0b3ab51c8877 336
bogdanm 84:0b3ab51c8877 337 /**
bogdanm 84:0b3ab51c8877 338 * @brief Disable the Exti Line falling edge trigger.
bogdanm 84:0b3ab51c8877 339 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
bogdanm 84:0b3ab51c8877 340 * This parameter can be a value of @ref COMP_ExtiLineEvent
bogdanm 84:0b3ab51c8877 341 * @retval None.
bogdanm 84:0b3ab51c8877 342 */
bogdanm 84:0b3ab51c8877 343 #define __HAL_COMP_EXTI_FALLING_IT_DISABLE(__EXTILINE__) (EXTI->FTSR &= ~(__EXTILINE__))
bogdanm 84:0b3ab51c8877 344
bogdanm 84:0b3ab51c8877 345 /**
bogdanm 84:0b3ab51c8877 346 * @brief Get the specified EXTI line for a comparator instance
bogdanm 84:0b3ab51c8877 347 * @param __INSTANCE__: specifies the COMP instance.
bogdanm 84:0b3ab51c8877 348 * @retval value of @ref COMP_ExtiLineEvent
bogdanm 84:0b3ab51c8877 349 */
bogdanm 84:0b3ab51c8877 350 #define __HAL_COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1_EVENT : \
bogdanm 84:0b3ab51c8877 351 COMP_EXTI_LINE_COMP2_EVENT)
bogdanm 84:0b3ab51c8877 352
bogdanm 84:0b3ab51c8877 353 /**
bogdanm 84:0b3ab51c8877 354 * @brief Enable the COMP Exti Line.
bogdanm 84:0b3ab51c8877 355 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
bogdanm 84:0b3ab51c8877 356 * This parameter can be a value of @ref COMP_ExtiLineEvent
bogdanm 84:0b3ab51c8877 357 * @retval None.
bogdanm 84:0b3ab51c8877 358 */
bogdanm 84:0b3ab51c8877 359 #define __HAL_COMP_EXTI_ENABLE_IT(__EXTILINE__) (EXTI->IMR |= (__EXTILINE__))
bogdanm 84:0b3ab51c8877 360
bogdanm 84:0b3ab51c8877 361 /**
bogdanm 84:0b3ab51c8877 362 * @brief Disable the COMP Exti Line.
bogdanm 84:0b3ab51c8877 363 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
bogdanm 84:0b3ab51c8877 364 * This parameter can be a value of @ref COMP_ExtiLineEvent
bogdanm 84:0b3ab51c8877 365 * @retval None.
bogdanm 84:0b3ab51c8877 366 */
bogdanm 84:0b3ab51c8877 367 #define __HAL_COMP_EXTI_DISABLE_IT(__EXTILINE__) (EXTI->IMR &= ~(__EXTILINE__))
bogdanm 84:0b3ab51c8877 368
bogdanm 84:0b3ab51c8877 369 /**
bogdanm 84:0b3ab51c8877 370 * @brief Checks whether the specified EXTI line flag is set or not.
bogdanm 84:0b3ab51c8877 371 * @param __FLAG__: specifies the COMP Exti sources to be checked.
bogdanm 84:0b3ab51c8877 372 * This parameter can be a value of @ref COMP_ExtiLineEvent
bogdanm 84:0b3ab51c8877 373 * @retval The state of __FLAG__ (SET or RESET).
bogdanm 84:0b3ab51c8877 374 */
bogdanm 84:0b3ab51c8877 375 #define __HAL_COMP_EXTI_GET_FLAG(__FLAG__) (EXTI->PR & (__FLAG__))
bogdanm 84:0b3ab51c8877 376
bogdanm 84:0b3ab51c8877 377 /**
bogdanm 84:0b3ab51c8877 378 * @brief Clear the COMP Exti flags.
bogdanm 84:0b3ab51c8877 379 * @param __FLAG__: specifies the COMP Exti sources to be cleared.
bogdanm 84:0b3ab51c8877 380 * This parameter can be a value of @ref COMP_ExtiLineEvent
bogdanm 84:0b3ab51c8877 381 * @retval None.
bogdanm 84:0b3ab51c8877 382 */
bogdanm 92:4fc01daae5a5 383 #define __HAL_COMP_EXTI_CLEAR_FLAG(__FLAG__) (EXTI->PR = (__FLAG__))
bogdanm 84:0b3ab51c8877 384
bogdanm 84:0b3ab51c8877 385
bogdanm 84:0b3ab51c8877 386 /* Exported functions --------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 387
bogdanm 84:0b3ab51c8877 388 /* Initialization/de-initialization functions **********************************/
bogdanm 84:0b3ab51c8877 389 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 390 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 391 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 392 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 393
bogdanm 84:0b3ab51c8877 394 /* I/O operation functions *****************************************************/
bogdanm 84:0b3ab51c8877 395 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 396 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 397 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 398 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 399 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 400
bogdanm 84:0b3ab51c8877 401 /* Peripheral Control functions ************************************************/
bogdanm 84:0b3ab51c8877 402 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 403 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 404
bogdanm 84:0b3ab51c8877 405 /* Callback in Interrupt mode */
bogdanm 84:0b3ab51c8877 406 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 407
bogdanm 84:0b3ab51c8877 408 /* Peripheral State functions **************************************************/
bogdanm 84:0b3ab51c8877 409 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
bogdanm 84:0b3ab51c8877 410
bogdanm 84:0b3ab51c8877 411 /**
bogdanm 84:0b3ab51c8877 412 * @}
bogdanm 84:0b3ab51c8877 413 */
bogdanm 84:0b3ab51c8877 414
bogdanm 84:0b3ab51c8877 415 /**
bogdanm 84:0b3ab51c8877 416 * @}
bogdanm 84:0b3ab51c8877 417 */
bogdanm 84:0b3ab51c8877 418
bogdanm 84:0b3ab51c8877 419 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 420 }
bogdanm 84:0b3ab51c8877 421 #endif
bogdanm 84:0b3ab51c8877 422
bogdanm 84:0b3ab51c8877 423 #endif /* __STM32L0xx_HAL_COMP_H */
bogdanm 84:0b3ab51c8877 424
bogdanm 84:0b3ab51c8877 425 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/