mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
181:a4cbdfbbd2f4
test with CLOCK_SETUP = 0

Who changed what in which revision?

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