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:
<>
Date:
Wed Apr 12 16:07:08 2017 +0100
Revision:
140:97feb9bacc10
Parent:
128:9bcdf88f62b0
Child:
145:64910690c574
Release 140 of the mbed library

Ports for Upcoming Targets

3841: Add nRf52840 target https://github.com/ARMmbed/mbed-os/pull/3841
3992: Introducing UBLOX_C030 platform. https://github.com/ARMmbed/mbed-os/pull/3992

Fixes and Changes

3951: [NUCLEO_F303ZE] Correct ARDUINO pin https://github.com/ARMmbed/mbed-os/pull/3951
4021: Fixing a macro to detect when RTOS was in use for the NRF52840_DK https://github.com/ARMmbed/mbed-os/pull/4021
3979: KW24D: Add missing SPI defines and Arduino connector definitions https://github.com/ARMmbed/mbed-os/pull/3979
3990: UBLOX_C027: construct a ticker-based wait, rather than calling wait_ms(), in the https://github.com/ARMmbed/mbed-os/pull/3990
4003: Fixed OBOE in async serial tx for NRF52 target, fixes #4002 https://github.com/ARMmbed/mbed-os/pull/4003
4012: STM32: Correct I2C master error handling https://github.com/ARMmbed/mbed-os/pull/4012
4020: NUCLEO_L011K4 remove unsupported tool chain files https://github.com/ARMmbed/mbed-os/pull/4020
4065: K66F: Move bss section to m_data_2 Section https://github.com/ARMmbed/mbed-os/pull/4065
4014: Issue 3763: Reduce heap allocation in the GCC linker file https://github.com/ARMmbed/mbed-os/pull/4014
4030: [STM32L0] reduce IAR heap and stack size for small targets https://github.com/ARMmbed/mbed-os/pull/4030
4109: NUCLEO_L476RG : minor serial pin update https://github.com/ARMmbed/mbed-os/pull/4109
3982: Ticker - kl25z bugfix for handling events in the past https://github.com/ARMmbed/mbed-os/pull/3982

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 122:f9eeca106725 1 /**
Kojto 122:f9eeca106725 2 ******************************************************************************
Kojto 122:f9eeca106725 3 * @file stm32l4xx_hal_comp.h
Kojto 122:f9eeca106725 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.5.1
Kojto 122:f9eeca106725 6 * @date 31-May-2016
Kojto 122:f9eeca106725 7 * @brief Header file of COMP HAL module.
Kojto 122:f9eeca106725 8 ******************************************************************************
Kojto 122:f9eeca106725 9 * @attention
Kojto 122:f9eeca106725 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 122:f9eeca106725 12 *
Kojto 122:f9eeca106725 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 122:f9eeca106725 14 * are permitted provided that the following conditions are met:
Kojto 122:f9eeca106725 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 122:f9eeca106725 16 * this list of conditions and the following disclaimer.
Kojto 122:f9eeca106725 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 122:f9eeca106725 18 * this list of conditions and the following disclaimer in the documentation
Kojto 122:f9eeca106725 19 * and/or other materials provided with the distribution.
Kojto 122:f9eeca106725 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 122:f9eeca106725 21 * may be used to endorse or promote products derived from this software
Kojto 122:f9eeca106725 22 * without specific prior written permission.
Kojto 122:f9eeca106725 23 *
Kojto 122:f9eeca106725 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 122:f9eeca106725 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 122:f9eeca106725 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 122:f9eeca106725 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 122:f9eeca106725 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 122:f9eeca106725 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 122:f9eeca106725 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 122:f9eeca106725 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 122:f9eeca106725 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 122:f9eeca106725 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 122:f9eeca106725 34 *
Kojto 122:f9eeca106725 35 ******************************************************************************
Kojto 122:f9eeca106725 36 */
Kojto 122:f9eeca106725 37
Kojto 122:f9eeca106725 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 122:f9eeca106725 39 #ifndef __STM32L4xx_HAL_COMP_H
Kojto 122:f9eeca106725 40 #define __STM32L4xx_HAL_COMP_H
Kojto 122:f9eeca106725 41
Kojto 122:f9eeca106725 42 #ifdef __cplusplus
Kojto 122:f9eeca106725 43 extern "C" {
Kojto 122:f9eeca106725 44 #endif
Kojto 122:f9eeca106725 45
Kojto 122:f9eeca106725 46 /* Includes ------------------------------------------------------------------*/
Kojto 122:f9eeca106725 47 #include "stm32l4xx_hal_def.h"
Kojto 122:f9eeca106725 48
Kojto 122:f9eeca106725 49 /** @addtogroup STM32L4xx_HAL_Driver
Kojto 122:f9eeca106725 50 * @{
Kojto 122:f9eeca106725 51 */
Kojto 122:f9eeca106725 52
Kojto 122:f9eeca106725 53 /** @addtogroup COMP
Kojto 122:f9eeca106725 54 * @{
Kojto 122:f9eeca106725 55 */
Kojto 122:f9eeca106725 56
Kojto 122:f9eeca106725 57 /* Exported types ------------------------------------------------------------*/
Kojto 122:f9eeca106725 58 /** @defgroup COMP_Exported_Types COMP Exported Types
Kojto 122:f9eeca106725 59 * @{
Kojto 122:f9eeca106725 60 */
Kojto 122:f9eeca106725 61
Kojto 122:f9eeca106725 62 /**
Kojto 122:f9eeca106725 63 * @brief COMP Init structure definition
Kojto 122:f9eeca106725 64 */
Kojto 122:f9eeca106725 65 typedef struct
Kojto 122:f9eeca106725 66 {
Kojto 122:f9eeca106725 67
Kojto 122:f9eeca106725 68 uint32_t WindowMode; /*!< Set window mode of a pair of comparators instances
Kojto 122:f9eeca106725 69 (2 consecutive instances odd and even COMP<x> and COMP<x+1>).
Kojto 122:f9eeca106725 70 Note: HAL COMP driver allows to set window mode from any COMP instance of the pair of COMP instances composing window mode.
Kojto 122:f9eeca106725 71 This parameter can be a value of @ref COMP_WindowMode */
Kojto 122:f9eeca106725 72
Kojto 122:f9eeca106725 73 uint32_t Mode; /*!< Set comparator operating mode to adjust power and speed.
Kojto 122:f9eeca106725 74 Note: For the characteritics of comparator power modes
Kojto 122:f9eeca106725 75 (propagation delay and power consumption), refer to device datasheet.
Kojto 122:f9eeca106725 76 This parameter can be a value of @ref COMP_PowerMode */
Kojto 122:f9eeca106725 77
Kojto 122:f9eeca106725 78 uint32_t NonInvertingInput; /*!< Set comparator input plus (non-inverting input).
Kojto 122:f9eeca106725 79 This parameter can be a value of @ref COMP_InputPlus */
Kojto 122:f9eeca106725 80
Kojto 122:f9eeca106725 81 uint32_t InvertingInput; /*!< Set comparator input minus (inverting input).
Kojto 122:f9eeca106725 82 This parameter can be a value of @ref COMP_InputMinus */
Kojto 122:f9eeca106725 83
Kojto 122:f9eeca106725 84 uint32_t Hysteresis; /*!< Set comparator hysteresis mode of the input minus.
Kojto 122:f9eeca106725 85 This parameter can be a value of @ref COMP_Hysteresis */
Kojto 122:f9eeca106725 86
Kojto 122:f9eeca106725 87 uint32_t OutputPol; /*!< Set comparator output polarity.
Kojto 122:f9eeca106725 88 This parameter can be a value of @ref COMP_OutputPolarity */
Kojto 122:f9eeca106725 89
Kojto 122:f9eeca106725 90 uint32_t BlankingSrce; /*!< Set comparator blanking source.
Kojto 122:f9eeca106725 91 This parameter can be a value of @ref COMP_BlankingSrce */
Kojto 122:f9eeca106725 92
Kojto 122:f9eeca106725 93 uint32_t TriggerMode; /*!< Set the comparator output triggering External Interrupt Line (EXTI).
Kojto 122:f9eeca106725 94 This parameter can be a value of @ref COMP_EXTI_TriggerMode */
Kojto 122:f9eeca106725 95
Kojto 122:f9eeca106725 96 }COMP_InitTypeDef;
Kojto 122:f9eeca106725 97
Kojto 122:f9eeca106725 98 /**
Kojto 122:f9eeca106725 99 * @brief HAL COMP state machine: HAL COMP states definition
Kojto 122:f9eeca106725 100 */
Kojto 122:f9eeca106725 101 #define COMP_STATE_BITFIELD_LOCK ((uint32_t)0x10)
Kojto 122:f9eeca106725 102 typedef enum
Kojto 122:f9eeca106725 103 {
Kojto 122:f9eeca106725 104 HAL_COMP_STATE_RESET = 0x00, /*!< COMP not yet initialized */
Kojto 122:f9eeca106725 105 HAL_COMP_STATE_RESET_LOCKED = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */
Kojto 122:f9eeca106725 106 HAL_COMP_STATE_READY = 0x01, /*!< COMP initialized and ready for use */
Kojto 122:f9eeca106725 107 HAL_COMP_STATE_READY_LOCKED = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked */
Kojto 122:f9eeca106725 108 HAL_COMP_STATE_BUSY = 0x02, /*!< COMP is running */
Kojto 122:f9eeca106725 109 HAL_COMP_STATE_BUSY_LOCKED = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK) /*!< COMP is running and configuration is locked */
Kojto 122:f9eeca106725 110 }HAL_COMP_StateTypeDef;
Kojto 122:f9eeca106725 111
Kojto 122:f9eeca106725 112 /**
Kojto 122:f9eeca106725 113 * @brief COMP Handle Structure definition
Kojto 122:f9eeca106725 114 */
Kojto 122:f9eeca106725 115 typedef struct
Kojto 122:f9eeca106725 116 {
Kojto 122:f9eeca106725 117 COMP_TypeDef *Instance; /*!< Register base address */
Kojto 122:f9eeca106725 118 COMP_InitTypeDef Init; /*!< COMP required parameters */
Kojto 122:f9eeca106725 119 HAL_LockTypeDef Lock; /*!< Locking object */
Kojto 122:f9eeca106725 120 __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
Kojto 122:f9eeca106725 121 } COMP_HandleTypeDef;
Kojto 122:f9eeca106725 122
Kojto 122:f9eeca106725 123 /**
Kojto 122:f9eeca106725 124 * @}
Kojto 122:f9eeca106725 125 */
Kojto 122:f9eeca106725 126
Kojto 122:f9eeca106725 127 /* Exported constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 128 /** @defgroup COMP_Exported_Constants COMP Exported Constants
Kojto 122:f9eeca106725 129 * @{
Kojto 122:f9eeca106725 130 */
Kojto 122:f9eeca106725 131
Kojto 122:f9eeca106725 132 /** @defgroup COMP_WindowMode COMP Window Mode
Kojto 122:f9eeca106725 133 * @{
Kojto 122:f9eeca106725 134 */
Kojto 122:f9eeca106725 135 #define COMP_WINDOWMODE_DISABLE ((uint32_t)0x00000000) /*!< Window mode disable: Comparators instances pair COMP1 and COMP2 are independent */
Kojto 122:f9eeca106725 136 #define COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_WINMODE) /*!< Window mode enable: Comparators instances pair COMP1 and COMP2 have their input plus connected together. The common input is COMP1 input plus (COMP2 input plus is no more accessible). */
Kojto 122:f9eeca106725 137
Kojto 122:f9eeca106725 138 /**
Kojto 122:f9eeca106725 139 * @}
Kojto 122:f9eeca106725 140 */
Kojto 122:f9eeca106725 141
Kojto 122:f9eeca106725 142 /** @defgroup COMP_PowerMode COMP power mode
Kojto 122:f9eeca106725 143 * @{
Kojto 122:f9eeca106725 144 */
Kojto 122:f9eeca106725 145 /* Note: For the characteritics of comparator power modes */
Kojto 122:f9eeca106725 146 /* (propagation delay and power consumption), */
Kojto 122:f9eeca106725 147 /* refer to device datasheet. */
Kojto 122:f9eeca106725 148 #define COMP_POWERMODE_HIGHSPEED ((uint32_t)0x00000000) /*!< High Speed */
Kojto 122:f9eeca106725 149 #define COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_PWRMODE_0) /*!< Medium Speed */
Kojto 122:f9eeca106725 150 #define COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_PWRMODE) /*!< Ultra-low power mode */
Kojto 122:f9eeca106725 151 /**
Kojto 122:f9eeca106725 152 * @}
Kojto 122:f9eeca106725 153 */
Kojto 122:f9eeca106725 154
Kojto 122:f9eeca106725 155 /** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
Kojto 122:f9eeca106725 156 * @{
Kojto 122:f9eeca106725 157 */
Kojto 122:f9eeca106725 158 #define COMP_INPUT_PLUS_IO1 ((uint32_t)0x00000000) /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1, pin PB4 for COMP2) */
Kojto 122:f9eeca106725 159 #define COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2) */
Kojto 122:f9eeca106725 160 #if defined(COMP_CSR_INPSEL_1)
Kojto 122:f9eeca106725 161 #define COMP_INPUT_PLUS_IO3 (COMP_CSR_INPSEL_1) /*!< Comparator input plus connected to IO3 (pin PA1 for COMP1, pin PA3 for COMP2) */
Kojto 122:f9eeca106725 162 #endif
Kojto 122:f9eeca106725 163 /**
Kojto 122:f9eeca106725 164 * @}
Kojto 122:f9eeca106725 165 */
Kojto 122:f9eeca106725 166
Kojto 122:f9eeca106725 167 /** @defgroup COMP_InputMinus COMP input minus (inverting input)
Kojto 122:f9eeca106725 168 * @{
Kojto 122:f9eeca106725 169 */
Kojto 122:f9eeca106725 170 #define COMP_INPUT_MINUS_1_4VREFINT ( COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/4 VrefInt */
Kojto 122:f9eeca106725 171 #define COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/2 VrefInt */
Kojto 122:f9eeca106725 172 #define COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */
Kojto 122:f9eeca106725 173 #define COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) /*!< Comparator input minus connected to VrefInt */
Kojto 122:f9eeca106725 174 #define COMP_INPUT_MINUS_DAC1_CH1 (COMP_CSR_INMSEL_2 ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */
Kojto 122:f9eeca106725 175 #define COMP_INPUT_MINUS_DAC1_CH2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */
Kojto 122:f9eeca106725 176 #define COMP_INPUT_MINUS_IO1 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PB1 for COMP1, pin PB3 for COMP2) */
Kojto 122:f9eeca106725 177 #define COMP_INPUT_MINUS_IO2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO2 (pin PC4 for COMP1, pin PB7 for COMP2) */
Kojto 122:f9eeca106725 178 #if defined(COMP_CSR_INMESEL_1)
Kojto 122:f9eeca106725 179 #define COMP_INPUT_MINUS_IO3 ( COMP_CSR_INMESEL_0 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO3 (pin PA0 for COMP1, pin PA2 for COMP2) */
Kojto 122:f9eeca106725 180 #define COMP_INPUT_MINUS_IO4 (COMP_CSR_INMESEL_1 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO4 (pin PA4 for COMP1, pin PA4 for COMP2) */
Kojto 122:f9eeca106725 181 #define COMP_INPUT_MINUS_IO5 (COMP_CSR_INMESEL_1 | COMP_CSR_INMESEL_0 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO5 (pin PA5 for COMP1, pin PA5 for COMP2) */
Kojto 122:f9eeca106725 182 #endif
Kojto 122:f9eeca106725 183 /**
Kojto 122:f9eeca106725 184 * @}
Kojto 122:f9eeca106725 185 */
Kojto 122:f9eeca106725 186
Kojto 122:f9eeca106725 187 /** @defgroup COMP_Hysteresis COMP hysteresis
Kojto 122:f9eeca106725 188 * @{
Kojto 122:f9eeca106725 189 */
Kojto 122:f9eeca106725 190 #define COMP_HYSTERESIS_NONE ((uint32_t)0x00000000) /*!< No hysteresis */
Kojto 122:f9eeca106725 191 #define COMP_HYSTERESIS_LOW (COMP_CSR_HYST_0) /*!< Hysteresis level low */
Kojto 122:f9eeca106725 192 #define COMP_HYSTERESIS_MEDIUM (COMP_CSR_HYST_1) /*!< Hysteresis level medium */
Kojto 122:f9eeca106725 193 #define COMP_HYSTERESIS_HIGH (COMP_CSR_HYST) /*!< Hysteresis level high */
Kojto 122:f9eeca106725 194 /**
Kojto 122:f9eeca106725 195 * @}
Kojto 122:f9eeca106725 196 */
Kojto 122:f9eeca106725 197
Kojto 122:f9eeca106725 198 /** @defgroup COMP_OutputPolarity COMP output Polarity
Kojto 122:f9eeca106725 199 * @{
Kojto 122:f9eeca106725 200 */
Kojto 122:f9eeca106725 201 #define COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output level is not inverted (comparator output is high when the input plus is at a higher voltage than the input minus) */
Kojto 122:f9eeca106725 202 #define COMP_OUTPUTPOL_INVERTED (COMP_CSR_POLARITY) /*!< COMP output level is inverted (comparator output is low when the input plus is at a higher voltage than the input minus) */
Kojto 122:f9eeca106725 203 /**
Kojto 122:f9eeca106725 204 * @}
Kojto 122:f9eeca106725 205 */
Kojto 122:f9eeca106725 206
Kojto 122:f9eeca106725 207 /** @defgroup COMP_BlankingSrce COMP blanking source
Kojto 122:f9eeca106725 208 * @{
Kojto 122:f9eeca106725 209 */
Kojto 122:f9eeca106725 210 #define COMP_BLANKINGSRC_NONE ((uint32_t)0x00000000) /*!< No blanking source */
Kojto 122:f9eeca106725 211 /* Blanking sources for COMP instance: COMP1 */
Kojto 122:f9eeca106725 212 #define COMP_BLANKINGSRC_TIM1_OC5_COMP1 (COMP_CSR_BLANKING_0) /*!< Blanking source for COMP1: TIM1 OC5 selected as blanking source for comparator */
Kojto 122:f9eeca106725 213 #define COMP_BLANKINGSRC_TIM2_OC3_COMP1 (COMP_CSR_BLANKING_1) /*!< Blanking source for COMP1: TIM2 OC3 selected as blanking source for comparator */
Kojto 122:f9eeca106725 214 #define COMP_BLANKINGSRC_TIM3_OC3_COMP1 (COMP_CSR_BLANKING_2) /*!< Blanking source for COMP1: TIM3 OC3 selected as blanking source for comparator */
Kojto 122:f9eeca106725 215 /* Blanking sources for COMP instance: COMP2 */
Kojto 122:f9eeca106725 216 #define COMP_BLANKINGSRC_TIM3_OC4_COMP2 (COMP_CSR_BLANKING_0) /*!< Blanking source for COMP2: TIM3 OC4 selected as blanking source for comparator */
Kojto 122:f9eeca106725 217 #define COMP_BLANKINGSRC_TIM8_OC5_COMP2 (COMP_CSR_BLANKING_1) /*!< Blanking source for COMP2: TIM8 OC5 selected as blanking source for comparator */
Kojto 122:f9eeca106725 218 #define COMP_BLANKINGSRC_TIM15_OC1_COMP2 (COMP_CSR_BLANKING_2) /*!< Blanking source for COMP2: TIM15 OC1 selected as blanking source for comparator */
Kojto 122:f9eeca106725 219 /**
Kojto 122:f9eeca106725 220 * @}
Kojto 122:f9eeca106725 221 */
Kojto 122:f9eeca106725 222
Kojto 122:f9eeca106725 223 /** @defgroup COMP_OutputLevel COMP Output Level
Kojto 122:f9eeca106725 224 * @{
Kojto 122:f9eeca106725 225 */
Kojto 122:f9eeca106725 226 /* Note: Comparator output level values are fixed to "0" and "1", */
Kojto 122:f9eeca106725 227 /* corresponding COMP register bit is managed by HAL function to match */
Kojto 122:f9eeca106725 228 /* with these values (independently of bit position in register). */
Kojto 122:f9eeca106725 229
Kojto 122:f9eeca106725 230 /* When output polarity is not inverted, comparator output is low when
Kojto 122:f9eeca106725 231 the input plus is at a lower voltage than the input minus */
Kojto 122:f9eeca106725 232 #define COMP_OUTPUT_LEVEL_LOW ((uint32_t)0x00000000)
Kojto 122:f9eeca106725 233 /* When output polarity is not inverted, comparator output is high when
Kojto 122:f9eeca106725 234 the input plus is at a higher voltage than the input minus */
Kojto 122:f9eeca106725 235 #define COMP_OUTPUT_LEVEL_HIGH ((uint32_t)0x00000001)
Kojto 122:f9eeca106725 236 /**
Kojto 122:f9eeca106725 237 * @}
Kojto 122:f9eeca106725 238 */
Kojto 122:f9eeca106725 239
Kojto 122:f9eeca106725 240 /** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI
Kojto 122:f9eeca106725 241 * @{
Kojto 122:f9eeca106725 242 */
Kojto 122:f9eeca106725 243 #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< Comparator output triggering no External Interrupt Line */
Kojto 122:f9eeca106725 244 #define COMP_TRIGGERMODE_IT_RISING (COMP_EXTI_IT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */
Kojto 122:f9eeca106725 245 #define COMP_TRIGGERMODE_IT_FALLING (COMP_EXTI_IT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */
Kojto 122:f9eeca106725 246 #define COMP_TRIGGERMODE_IT_RISING_FALLING (COMP_EXTI_IT | COMP_EXTI_RISING | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on both rising and falling edges */
Kojto 122:f9eeca106725 247 #define COMP_TRIGGERMODE_EVENT_RISING (COMP_EXTI_EVENT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */
Kojto 122:f9eeca106725 248 #define COMP_TRIGGERMODE_EVENT_FALLING (COMP_EXTI_EVENT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */
Kojto 122:f9eeca106725 249 #define COMP_TRIGGERMODE_EVENT_RISING_FALLING (COMP_EXTI_EVENT | COMP_EXTI_RISING | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on both rising and falling edges */
Kojto 122:f9eeca106725 250 /**
Kojto 122:f9eeca106725 251 * @}
Kojto 122:f9eeca106725 252 */
Kojto 122:f9eeca106725 253
Kojto 122:f9eeca106725 254 /**
Kojto 122:f9eeca106725 255 * @}
Kojto 122:f9eeca106725 256 */
Kojto 122:f9eeca106725 257
Kojto 122:f9eeca106725 258 /* Exported macro ------------------------------------------------------------*/
Kojto 122:f9eeca106725 259 /** @defgroup COMP_Exported_Macros COMP Exported Macros
Kojto 122:f9eeca106725 260 * @{
Kojto 122:f9eeca106725 261 */
Kojto 122:f9eeca106725 262
Kojto 122:f9eeca106725 263 /** @defgroup COMP_Handle_Management COMP Handle Management
Kojto 122:f9eeca106725 264 * @{
Kojto 122:f9eeca106725 265 */
Kojto 122:f9eeca106725 266
Kojto 122:f9eeca106725 267 /** @brief Reset COMP handle state.
Kojto 122:f9eeca106725 268 * @param __HANDLE__ COMP handle
Kojto 122:f9eeca106725 269 * @retval None
Kojto 122:f9eeca106725 270 */
Kojto 122:f9eeca106725 271 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
Kojto 122:f9eeca106725 272
Kojto 122:f9eeca106725 273 /**
Kojto 122:f9eeca106725 274 * @brief Enable the specified comparator.
Kojto 122:f9eeca106725 275 * @param __HANDLE__ COMP handle
Kojto 122:f9eeca106725 276 * @retval None
Kojto 122:f9eeca106725 277 */
Kojto 122:f9eeca106725 278 #define __HAL_COMP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
Kojto 122:f9eeca106725 279
Kojto 122:f9eeca106725 280 /**
Kojto 122:f9eeca106725 281 * @brief Disable the specified comparator.
Kojto 122:f9eeca106725 282 * @param __HANDLE__ COMP handle
Kojto 122:f9eeca106725 283 * @retval None
Kojto 122:f9eeca106725 284 */
Kojto 122:f9eeca106725 285 #define __HAL_COMP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
Kojto 122:f9eeca106725 286
Kojto 122:f9eeca106725 287 /**
Kojto 122:f9eeca106725 288 * @brief Lock the specified comparator configuration.
Kojto 122:f9eeca106725 289 * @note Using this macro induce HAL COMP handle state machine being no
Kojto 122:f9eeca106725 290 * more in line with COMP instance state.
Kojto 122:f9eeca106725 291 * To keep HAL COMP handle state machine updated, it is recommended
Kojto 122:f9eeca106725 292 * to use function "HAL_COMP_Lock')".
Kojto 122:f9eeca106725 293 * @param __HANDLE__ COMP handle
Kojto 122:f9eeca106725 294 * @retval None
Kojto 122:f9eeca106725 295 */
Kojto 122:f9eeca106725 296 #define __HAL_COMP_LOCK(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK)
Kojto 122:f9eeca106725 297
Kojto 122:f9eeca106725 298 /**
Kojto 122:f9eeca106725 299 * @brief Check whether the specified comparator is locked.
Kojto 122:f9eeca106725 300 * @param __HANDLE__ COMP handle
Kojto 122:f9eeca106725 301 * @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked
Kojto 122:f9eeca106725 302 */
Kojto 122:f9eeca106725 303 #define __HAL_COMP_IS_LOCKED(__HANDLE__) (READ_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK) == COMP_CSR_LOCK)
Kojto 122:f9eeca106725 304
Kojto 122:f9eeca106725 305 /**
Kojto 122:f9eeca106725 306 * @}
Kojto 122:f9eeca106725 307 */
Kojto 122:f9eeca106725 308
Kojto 122:f9eeca106725 309 /** @defgroup COMP_Exti_Management COMP external interrupt line management
Kojto 122:f9eeca106725 310 * @{
Kojto 122:f9eeca106725 311 */
Kojto 122:f9eeca106725 312
Kojto 122:f9eeca106725 313 /**
Kojto 122:f9eeca106725 314 * @brief Enable the COMP1 EXTI line rising edge trigger.
Kojto 122:f9eeca106725 315 * @retval None
Kojto 122:f9eeca106725 316 */
Kojto 122:f9eeca106725 317 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1)
Kojto 122:f9eeca106725 318
Kojto 122:f9eeca106725 319 /**
Kojto 122:f9eeca106725 320 * @brief Disable the COMP1 EXTI line rising edge trigger.
Kojto 122:f9eeca106725 321 * @retval None
Kojto 122:f9eeca106725 322 */
Kojto 122:f9eeca106725 323 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1)
Kojto 122:f9eeca106725 324
Kojto 122:f9eeca106725 325 /**
Kojto 122:f9eeca106725 326 * @brief Enable the COMP1 EXTI line falling edge trigger.
Kojto 122:f9eeca106725 327 * @retval None
Kojto 122:f9eeca106725 328 */
Kojto 122:f9eeca106725 329 #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1)
Kojto 122:f9eeca106725 330
Kojto 122:f9eeca106725 331 /**
Kojto 122:f9eeca106725 332 * @brief Disable the COMP1 EXTI line falling edge trigger.
Kojto 122:f9eeca106725 333 * @retval None
Kojto 122:f9eeca106725 334 */
Kojto 122:f9eeca106725 335 #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1)
Kojto 122:f9eeca106725 336
Kojto 122:f9eeca106725 337 /**
Kojto 122:f9eeca106725 338 * @brief Enable the COMP1 EXTI line rising & falling edge trigger.
Kojto 122:f9eeca106725 339 * @retval None
Kojto 122:f9eeca106725 340 */
Kojto 122:f9eeca106725 341 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
Kojto 122:f9eeca106725 342 __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE(); \
Kojto 122:f9eeca106725 343 __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE(); \
Kojto 122:f9eeca106725 344 } while(0)
Kojto 122:f9eeca106725 345
Kojto 122:f9eeca106725 346 /**
Kojto 122:f9eeca106725 347 * @brief Disable the COMP1 EXTI line rising & falling edge trigger.
Kojto 122:f9eeca106725 348 * @retval None
Kojto 122:f9eeca106725 349 */
Kojto 122:f9eeca106725 350 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
Kojto 122:f9eeca106725 351 __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE(); \
Kojto 122:f9eeca106725 352 __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE(); \
Kojto 122:f9eeca106725 353 } while(0)
Kojto 122:f9eeca106725 354
Kojto 122:f9eeca106725 355 /**
Kojto 122:f9eeca106725 356 * @brief Enable the COMP1 EXTI line in interrupt mode.
Kojto 122:f9eeca106725 357 * @retval None
Kojto 122:f9eeca106725 358 */
Kojto 122:f9eeca106725 359 #define __HAL_COMP_COMP1_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR1, COMP_EXTI_LINE_COMP1)
Kojto 122:f9eeca106725 360
Kojto 122:f9eeca106725 361 /**
Kojto 122:f9eeca106725 362 * @brief Disable the COMP1 EXTI line in interrupt mode.
Kojto 122:f9eeca106725 363 * @retval None
Kojto 122:f9eeca106725 364 */
Kojto 122:f9eeca106725 365 #define __HAL_COMP_COMP1_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR1, COMP_EXTI_LINE_COMP1)
Kojto 122:f9eeca106725 366
Kojto 122:f9eeca106725 367 /**
Kojto 122:f9eeca106725 368 * @brief Generate a software interrupt on the COMP1 EXTI line.
Kojto 122:f9eeca106725 369 * @retval None
Kojto 122:f9eeca106725 370 */
Kojto 122:f9eeca106725 371 #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP1)
Kojto 122:f9eeca106725 372
Kojto 122:f9eeca106725 373 /**
Kojto 122:f9eeca106725 374 * @brief Enable the COMP1 EXTI line in event mode.
Kojto 122:f9eeca106725 375 * @retval None
Kojto 122:f9eeca106725 376 */
Kojto 122:f9eeca106725 377 #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR1, COMP_EXTI_LINE_COMP1)
Kojto 122:f9eeca106725 378
Kojto 122:f9eeca106725 379 /**
Kojto 122:f9eeca106725 380 * @brief Disable the COMP1 EXTI line in event mode.
Kojto 122:f9eeca106725 381 * @retval None
Kojto 122:f9eeca106725 382 */
Kojto 122:f9eeca106725 383 #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR1, COMP_EXTI_LINE_COMP1)
Kojto 122:f9eeca106725 384
Kojto 122:f9eeca106725 385 /**
Kojto 122:f9eeca106725 386 * @brief Check whether the COMP1 EXTI line flag is set.
Kojto 122:f9eeca106725 387 * @retval RESET or SET
Kojto 122:f9eeca106725 388 */
Kojto 122:f9eeca106725 389 #define __HAL_COMP_COMP1_EXTI_GET_FLAG() READ_BIT(EXTI->PR1, COMP_EXTI_LINE_COMP1)
Kojto 122:f9eeca106725 390
Kojto 122:f9eeca106725 391 /**
Kojto 122:f9eeca106725 392 * @brief Clear the COMP1 EXTI flag.
Kojto 122:f9eeca106725 393 * @retval None
Kojto 122:f9eeca106725 394 */
Kojto 122:f9eeca106725 395 #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR1, COMP_EXTI_LINE_COMP1)
Kojto 122:f9eeca106725 396
Kojto 122:f9eeca106725 397 /**
Kojto 122:f9eeca106725 398 * @brief Enable the COMP2 EXTI line rising edge trigger.
Kojto 122:f9eeca106725 399 * @retval None
Kojto 122:f9eeca106725 400 */
Kojto 122:f9eeca106725 401 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2)
Kojto 122:f9eeca106725 402
Kojto 122:f9eeca106725 403 /**
Kojto 122:f9eeca106725 404 * @brief Disable the COMP2 EXTI line rising edge trigger.
Kojto 122:f9eeca106725 405 * @retval None
Kojto 122:f9eeca106725 406 */
Kojto 122:f9eeca106725 407 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2)
Kojto 122:f9eeca106725 408
Kojto 122:f9eeca106725 409 /**
Kojto 122:f9eeca106725 410 * @brief Enable the COMP2 EXTI line falling edge trigger.
Kojto 122:f9eeca106725 411 * @retval None
Kojto 122:f9eeca106725 412 */
Kojto 122:f9eeca106725 413 #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2)
Kojto 122:f9eeca106725 414
Kojto 122:f9eeca106725 415 /**
Kojto 122:f9eeca106725 416 * @brief Disable the COMP2 EXTI line falling edge trigger.
Kojto 122:f9eeca106725 417 * @retval None
Kojto 122:f9eeca106725 418 */
Kojto 122:f9eeca106725 419 #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2)
Kojto 122:f9eeca106725 420
Kojto 122:f9eeca106725 421 /**
Kojto 122:f9eeca106725 422 * @brief Enable the COMP2 EXTI line rising & falling edge trigger.
Kojto 122:f9eeca106725 423 * @retval None
Kojto 122:f9eeca106725 424 */
Kojto 122:f9eeca106725 425 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
Kojto 122:f9eeca106725 426 __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE(); \
Kojto 122:f9eeca106725 427 __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE(); \
Kojto 122:f9eeca106725 428 } while(0)
Kojto 122:f9eeca106725 429
Kojto 122:f9eeca106725 430 /**
Kojto 122:f9eeca106725 431 * @brief Disable the COMP2 EXTI line rising & falling edge trigger.
Kojto 122:f9eeca106725 432 * @retval None
Kojto 122:f9eeca106725 433 */
Kojto 122:f9eeca106725 434 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
Kojto 122:f9eeca106725 435 __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE(); \
Kojto 122:f9eeca106725 436 __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE(); \
Kojto 122:f9eeca106725 437 } while(0)
Kojto 122:f9eeca106725 438
Kojto 122:f9eeca106725 439 /**
Kojto 122:f9eeca106725 440 * @brief Enable the COMP2 EXTI line in interrupt mode.
Kojto 122:f9eeca106725 441 * @retval None
Kojto 122:f9eeca106725 442 */
Kojto 122:f9eeca106725 443 #define __HAL_COMP_COMP2_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR1, COMP_EXTI_LINE_COMP2)
Kojto 122:f9eeca106725 444
Kojto 122:f9eeca106725 445 /**
Kojto 122:f9eeca106725 446 * @brief Disable the COMP2 EXTI line in interrupt mode.
Kojto 122:f9eeca106725 447 * @retval None
Kojto 122:f9eeca106725 448 */
Kojto 122:f9eeca106725 449 #define __HAL_COMP_COMP2_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR1, COMP_EXTI_LINE_COMP2)
Kojto 122:f9eeca106725 450
Kojto 122:f9eeca106725 451 /**
Kojto 122:f9eeca106725 452 * @brief Generate a software interrupt on the COMP2 EXTI line.
Kojto 122:f9eeca106725 453 * @retval None
Kojto 122:f9eeca106725 454 */
Kojto 122:f9eeca106725 455 #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP2)
Kojto 122:f9eeca106725 456
Kojto 122:f9eeca106725 457 /**
Kojto 122:f9eeca106725 458 * @brief Enable the COMP2 EXTI line in event mode.
Kojto 122:f9eeca106725 459 * @retval None
Kojto 122:f9eeca106725 460 */
Kojto 122:f9eeca106725 461 #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR1, COMP_EXTI_LINE_COMP2)
Kojto 122:f9eeca106725 462
Kojto 122:f9eeca106725 463 /**
Kojto 122:f9eeca106725 464 * @brief Disable the COMP2 EXTI line in event mode.
Kojto 122:f9eeca106725 465 * @retval None
Kojto 122:f9eeca106725 466 */
Kojto 122:f9eeca106725 467 #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR1, COMP_EXTI_LINE_COMP2)
Kojto 122:f9eeca106725 468
Kojto 122:f9eeca106725 469 /**
Kojto 122:f9eeca106725 470 * @brief Check whether the COMP2 EXTI line flag is set.
Kojto 122:f9eeca106725 471 * @retval RESET or SET
Kojto 122:f9eeca106725 472 */
Kojto 122:f9eeca106725 473 #define __HAL_COMP_COMP2_EXTI_GET_FLAG() READ_BIT(EXTI->PR1, COMP_EXTI_LINE_COMP2)
Kojto 122:f9eeca106725 474
Kojto 122:f9eeca106725 475 /**
Kojto 122:f9eeca106725 476 * @brief Clear the COMP2 EXTI flag.
Kojto 122:f9eeca106725 477 * @retval None
Kojto 122:f9eeca106725 478 */
Kojto 122:f9eeca106725 479 #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR1, COMP_EXTI_LINE_COMP2)
Kojto 122:f9eeca106725 480
Kojto 122:f9eeca106725 481 /**
Kojto 122:f9eeca106725 482 * @}
Kojto 122:f9eeca106725 483 */
Kojto 122:f9eeca106725 484
Kojto 122:f9eeca106725 485 /**
Kojto 122:f9eeca106725 486 * @}
Kojto 122:f9eeca106725 487 */
Kojto 122:f9eeca106725 488
Kojto 122:f9eeca106725 489
Kojto 122:f9eeca106725 490 /* Private types -------------------------------------------------------------*/
Kojto 122:f9eeca106725 491 /* Private constants ---------------------------------------------------------*/
Kojto 122:f9eeca106725 492 /** @defgroup COMP_Private_Constants COMP Private Constants
Kojto 122:f9eeca106725 493 * @{
Kojto 122:f9eeca106725 494 */
Kojto 122:f9eeca106725 495 /** @defgroup COMP_ExtiLine COMP EXTI Lines
Kojto 122:f9eeca106725 496 * @{
Kojto 122:f9eeca106725 497 */
Kojto 122:f9eeca106725 498 #define COMP_EXTI_LINE_COMP1 (EXTI_IMR1_IM21) /*!< EXTI line 21 connected to COMP1 output */
Kojto 122:f9eeca106725 499 #define COMP_EXTI_LINE_COMP2 (EXTI_IMR1_IM22) /*!< EXTI line 22 connected to COMP2 output */
Kojto 122:f9eeca106725 500 /**
Kojto 122:f9eeca106725 501 * @}
Kojto 122:f9eeca106725 502 */
Kojto 122:f9eeca106725 503
Kojto 122:f9eeca106725 504 /** @defgroup COMP_ExtiLine COMP EXTI Lines
Kojto 122:f9eeca106725 505 * @{
Kojto 122:f9eeca106725 506 */
Kojto 122:f9eeca106725 507 #define COMP_EXTI_IT ((uint32_t) 0x01) /*!< EXTI line event with interruption */
Kojto 122:f9eeca106725 508 #define COMP_EXTI_EVENT ((uint32_t) 0x02) /*!< EXTI line event only (without interruption) */
Kojto 122:f9eeca106725 509 #define COMP_EXTI_RISING ((uint32_t) 0x10) /*!< EXTI line event on rising edge */
Kojto 122:f9eeca106725 510 #define COMP_EXTI_FALLING ((uint32_t) 0x20) /*!< EXTI line event on falling edge */
Kojto 122:f9eeca106725 511 /**
Kojto 122:f9eeca106725 512 * @}
Kojto 122:f9eeca106725 513 */
Kojto 122:f9eeca106725 514
Kojto 122:f9eeca106725 515 /**
Kojto 122:f9eeca106725 516 * @}
Kojto 122:f9eeca106725 517 */
Kojto 122:f9eeca106725 518
Kojto 122:f9eeca106725 519 /* Private macros ------------------------------------------------------------*/
Kojto 122:f9eeca106725 520 /** @defgroup COMP_Private_Macros COMP Private Macros
Kojto 122:f9eeca106725 521 * @{
Kojto 122:f9eeca106725 522 */
Kojto 122:f9eeca106725 523
Kojto 122:f9eeca106725 524 /** @defgroup COMP_GET_EXTI_LINE COMP private macros to get EXTI line associated with comparators
Kojto 122:f9eeca106725 525 * @{
Kojto 122:f9eeca106725 526 */
Kojto 122:f9eeca106725 527 /**
Kojto 122:f9eeca106725 528 * @brief Get the specified EXTI line for a comparator instance.
Kojto 122:f9eeca106725 529 * @param __INSTANCE__ specifies the COMP instance.
Kojto 122:f9eeca106725 530 * @retval value of @ref COMP_ExtiLine
Kojto 122:f9eeca106725 531 */
Kojto 122:f9eeca106725 532 #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? \
Kojto 122:f9eeca106725 533 COMP_EXTI_LINE_COMP1 : COMP_EXTI_LINE_COMP2)
Kojto 122:f9eeca106725 534 /**
Kojto 122:f9eeca106725 535 * @}
Kojto 122:f9eeca106725 536 */
Kojto 122:f9eeca106725 537
Kojto 122:f9eeca106725 538 /** @defgroup COMP_IS_COMP_Definitions COMP private macros to check input parameters
Kojto 122:f9eeca106725 539 * @{
Kojto 122:f9eeca106725 540 */
Kojto 122:f9eeca106725 541 #define IS_COMP_WINDOWMODE(__WINDOWMODE__) (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE) || \
Kojto 122:f9eeca106725 542 ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON) )
Kojto 122:f9eeca106725 543
Kojto 122:f9eeca106725 544 #define IS_COMP_POWERMODE(__POWERMODE__) (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED) || \
Kojto 122:f9eeca106725 545 ((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED) || \
Kojto 122:f9eeca106725 546 ((__POWERMODE__) == COMP_POWERMODE_ULTRALOWPOWER) )
Kojto 122:f9eeca106725 547
Kojto 122:f9eeca106725 548 #if defined(COMP_CSR_INPSEL_1)
Kojto 122:f9eeca106725 549 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
Kojto 122:f9eeca106725 550 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \
Kojto 122:f9eeca106725 551 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO3))
Kojto 122:f9eeca106725 552 #else
Kojto 122:f9eeca106725 553 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
Kojto 122:f9eeca106725 554 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2))
Kojto 122:f9eeca106725 555 #endif
Kojto 122:f9eeca106725 556
Kojto 122:f9eeca106725 557 /* Note: On this STM32 family, comparator input minus parameters are */
Kojto 122:f9eeca106725 558 /* the same on all COMP instances. */
Kojto 122:f9eeca106725 559 /* However, comparator instance kept as macro parameter for */
Kojto 122:f9eeca106725 560 /* compatibility with other STM32 families. */
Kojto 122:f9eeca106725 561 #if defined(COMP_CSR_INMESEL_1)
Kojto 122:f9eeca106725 562 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
Kojto 122:f9eeca106725 563 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
Kojto 122:f9eeca106725 564 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
Kojto 122:f9eeca106725 565 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
Kojto 122:f9eeca106725 566 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
Kojto 122:f9eeca106725 567 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
Kojto 122:f9eeca106725 568 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
Kojto 122:f9eeca106725 569 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) || \
Kojto 122:f9eeca106725 570 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO3) || \
Kojto 122:f9eeca106725 571 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO4) || \
Kojto 122:f9eeca106725 572 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO5))
Kojto 122:f9eeca106725 573 #else
Kojto 122:f9eeca106725 574 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
Kojto 122:f9eeca106725 575 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
Kojto 122:f9eeca106725 576 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
Kojto 122:f9eeca106725 577 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
Kojto 122:f9eeca106725 578 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
Kojto 122:f9eeca106725 579 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
Kojto 122:f9eeca106725 580 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
Kojto 122:f9eeca106725 581 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2))
Kojto 122:f9eeca106725 582 #endif
Kojto 122:f9eeca106725 583
Kojto 122:f9eeca106725 584 #define IS_COMP_HYSTERESIS(__HYSTERESIS__) (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE) || \
Kojto 122:f9eeca106725 585 ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW) || \
Kojto 122:f9eeca106725 586 ((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \
Kojto 122:f9eeca106725 587 ((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH))
Kojto 122:f9eeca106725 588
Kojto 122:f9eeca106725 589 #define IS_COMP_OUTPUTPOL(__POL__) (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
Kojto 122:f9eeca106725 590 ((__POL__) == COMP_OUTPUTPOL_INVERTED))
Kojto 122:f9eeca106725 591
Kojto 122:f9eeca106725 592 #define IS_COMP_BLANKINGSRCE(__SOURCE__) (((__SOURCE__) == COMP_BLANKINGSRC_NONE) || \
Kojto 122:f9eeca106725 593 ((__SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) || \
Kojto 122:f9eeca106725 594 ((__SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) || \
Kojto 122:f9eeca106725 595 ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1) || \
Kojto 122:f9eeca106725 596 ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP2) || \
Kojto 122:f9eeca106725 597 ((__SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2) || \
Kojto 122:f9eeca106725 598 ((__SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP2))
Kojto 122:f9eeca106725 599
Kojto 122:f9eeca106725 600 #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __BLANKINGSRCE__) \
Kojto 122:f9eeca106725 601 ((((__INSTANCE__) == COMP1) && \
Kojto 122:f9eeca106725 602 (((__BLANKINGSRCE__) == COMP_BLANKINGSRC_NONE) || \
Kojto 122:f9eeca106725 603 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) || \
Kojto 122:f9eeca106725 604 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) || \
Kojto 122:f9eeca106725 605 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1))) \
Kojto 122:f9eeca106725 606 || \
Kojto 122:f9eeca106725 607 (((__INSTANCE__) == COMP2) && \
Kojto 122:f9eeca106725 608 (((__BLANKINGSRCE__) == COMP_BLANKINGSRC_NONE) || \
Kojto 122:f9eeca106725 609 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP2) || \
Kojto 122:f9eeca106725 610 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2) || \
Kojto 122:f9eeca106725 611 ((__BLANKINGSRCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP2))))
Kojto 122:f9eeca106725 612
Kojto 122:f9eeca106725 613 #define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \
Kojto 122:f9eeca106725 614 ((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \
Kojto 122:f9eeca106725 615 ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \
Kojto 122:f9eeca106725 616 ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \
Kojto 122:f9eeca106725 617 ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \
Kojto 122:f9eeca106725 618 ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \
Kojto 122:f9eeca106725 619 ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
Kojto 122:f9eeca106725 620
Kojto 122:f9eeca106725 621 #define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW) || \
Kojto 122:f9eeca106725 622 ((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH))
Kojto 122:f9eeca106725 623
Kojto 122:f9eeca106725 624 /**
Kojto 122:f9eeca106725 625 * @}
Kojto 122:f9eeca106725 626 */
Kojto 122:f9eeca106725 627
Kojto 122:f9eeca106725 628 /**
Kojto 122:f9eeca106725 629 * @}
Kojto 122:f9eeca106725 630 */
Kojto 122:f9eeca106725 631
Kojto 122:f9eeca106725 632
Kojto 122:f9eeca106725 633 /* Exported functions --------------------------------------------------------*/
Kojto 122:f9eeca106725 634 /** @addtogroup COMP_Exported_Functions
Kojto 122:f9eeca106725 635 * @{
Kojto 122:f9eeca106725 636 */
Kojto 122:f9eeca106725 637
Kojto 122:f9eeca106725 638 /** @addtogroup COMP_Exported_Functions_Group1
Kojto 122:f9eeca106725 639 * @{
Kojto 122:f9eeca106725 640 */
Kojto 122:f9eeca106725 641
Kojto 122:f9eeca106725 642 /* Initialization and de-initialization functions **********************************/
Kojto 122:f9eeca106725 643 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
Kojto 122:f9eeca106725 644 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
Kojto 122:f9eeca106725 645 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
Kojto 122:f9eeca106725 646 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
Kojto 122:f9eeca106725 647 /**
Kojto 122:f9eeca106725 648 * @}
Kojto 122:f9eeca106725 649 */
Kojto 122:f9eeca106725 650
Kojto 122:f9eeca106725 651 /* IO operation functions *****************************************************/
Kojto 122:f9eeca106725 652 /** @addtogroup COMP_Exported_Functions_Group2
Kojto 122:f9eeca106725 653 * @{
Kojto 122:f9eeca106725 654 */
Kojto 122:f9eeca106725 655 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
Kojto 122:f9eeca106725 656 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
Kojto 122:f9eeca106725 657 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
Kojto 122:f9eeca106725 658 /**
Kojto 122:f9eeca106725 659 * @}
Kojto 122:f9eeca106725 660 */
Kojto 122:f9eeca106725 661
Kojto 122:f9eeca106725 662 /* Peripheral Control functions ************************************************/
Kojto 122:f9eeca106725 663 /** @addtogroup COMP_Exported_Functions_Group3
Kojto 122:f9eeca106725 664 * @{
Kojto 122:f9eeca106725 665 */
Kojto 122:f9eeca106725 666 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
Kojto 122:f9eeca106725 667 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
Kojto 122:f9eeca106725 668 /* Callback in interrupt mode */
Kojto 122:f9eeca106725 669 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
Kojto 122:f9eeca106725 670 /**
Kojto 122:f9eeca106725 671 * @}
Kojto 122:f9eeca106725 672 */
Kojto 122:f9eeca106725 673
Kojto 122:f9eeca106725 674 /* Peripheral State functions **************************************************/
Kojto 122:f9eeca106725 675 /** @addtogroup COMP_Exported_Functions_Group4
Kojto 122:f9eeca106725 676 * @{
Kojto 122:f9eeca106725 677 */
Kojto 122:f9eeca106725 678 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
Kojto 122:f9eeca106725 679 /**
Kojto 122:f9eeca106725 680 * @}
Kojto 122:f9eeca106725 681 */
Kojto 122:f9eeca106725 682
Kojto 122:f9eeca106725 683 /**
Kojto 122:f9eeca106725 684 * @}
Kojto 122:f9eeca106725 685 */
Kojto 122:f9eeca106725 686
Kojto 122:f9eeca106725 687 /**
Kojto 122:f9eeca106725 688 * @}
Kojto 122:f9eeca106725 689 */
Kojto 122:f9eeca106725 690
Kojto 122:f9eeca106725 691 /**
Kojto 122:f9eeca106725 692 * @}
Kojto 122:f9eeca106725 693 */
Kojto 122:f9eeca106725 694
Kojto 122:f9eeca106725 695 #ifdef __cplusplus
Kojto 122:f9eeca106725 696 }
Kojto 122:f9eeca106725 697 #endif
Kojto 122:f9eeca106725 698
Kojto 122:f9eeca106725 699 #endif /* __STM32L4xx_HAL_COMP_H */
Kojto 122:f9eeca106725 700
Kojto 122:f9eeca106725 701 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/