mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

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

Committer:
mbed_official
Date:
Mon Nov 03 10:45:07 2014 +0000
Revision:
382:ee426a420dbb
Parent:
targets/cmsis/TARGET_STM/TARGET_DISCO_L053C8/stm32l0xx_hal_comp.h@376:cb4d9db17537
Child:
489:119543c9f674
Synchronized with git revision d54467eb07f62efd9ccdf44f1ede7fe1c1b0cf83

Full URL: https://github.com/mbedmicro/mbed/commit/d54467eb07f62efd9ccdf44f1ede7fe1c1b0cf83/

Who changed what in which revision?

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