Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
TARGET_NUCLEO_L152RE/stm32l1xx_hal_comp.h@122:f9eeca106725, 2016-07-07 (annotated)
- Committer:
- Kojto
- Date:
- Thu Jul 07 14:34:11 2016 +0100
- Revision:
- 122:f9eeca106725
- Parent:
- 90:cb3d968589d8
Release 122 of the mbed library
Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Kojto | 90:cb3d968589d8 | 1 | /** |
| Kojto | 90:cb3d968589d8 | 2 | ****************************************************************************** |
| Kojto | 90:cb3d968589d8 | 3 | * @file stm32l1xx_hal_comp.h |
| Kojto | 90:cb3d968589d8 | 4 | * @author MCD Application Team |
| Kojto | 122:f9eeca106725 | 5 | * @version V1.1.3 |
| Kojto | 122:f9eeca106725 | 6 | * @date 04-March-2016 |
| Kojto | 90:cb3d968589d8 | 7 | * @brief Header file of COMP HAL module. |
| Kojto | 90:cb3d968589d8 | 8 | ****************************************************************************** |
| Kojto | 90:cb3d968589d8 | 9 | * @attention |
| Kojto | 90:cb3d968589d8 | 10 | * |
| Kojto | 122:f9eeca106725 | 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
| Kojto | 90:cb3d968589d8 | 12 | * |
| Kojto | 90:cb3d968589d8 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
| Kojto | 90:cb3d968589d8 | 14 | * are permitted provided that the following conditions are met: |
| Kojto | 90:cb3d968589d8 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
| Kojto | 90:cb3d968589d8 | 16 | * this list of conditions and the following disclaimer. |
| Kojto | 90:cb3d968589d8 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| Kojto | 90:cb3d968589d8 | 18 | * this list of conditions and the following disclaimer in the documentation |
| Kojto | 90:cb3d968589d8 | 19 | * and/or other materials provided with the distribution. |
| Kojto | 90:cb3d968589d8 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| Kojto | 90:cb3d968589d8 | 21 | * may be used to endorse or promote products derived from this software |
| Kojto | 90:cb3d968589d8 | 22 | * without specific prior written permission. |
| Kojto | 90:cb3d968589d8 | 23 | * |
| Kojto | 90:cb3d968589d8 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| Kojto | 90:cb3d968589d8 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| Kojto | 90:cb3d968589d8 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| Kojto | 90:cb3d968589d8 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| Kojto | 90:cb3d968589d8 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| Kojto | 90:cb3d968589d8 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| Kojto | 90:cb3d968589d8 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| Kojto | 90:cb3d968589d8 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| Kojto | 90:cb3d968589d8 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| Kojto | 90:cb3d968589d8 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| Kojto | 90:cb3d968589d8 | 34 | * |
| Kojto | 90:cb3d968589d8 | 35 | ****************************************************************************** |
| Kojto | 90:cb3d968589d8 | 36 | */ |
| Kojto | 90:cb3d968589d8 | 37 | |
| Kojto | 90:cb3d968589d8 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
| Kojto | 90:cb3d968589d8 | 39 | #ifndef __STM32L1xx_HAL_COMP_H |
| Kojto | 90:cb3d968589d8 | 40 | #define __STM32L1xx_HAL_COMP_H |
| Kojto | 90:cb3d968589d8 | 41 | |
| Kojto | 90:cb3d968589d8 | 42 | #ifdef __cplusplus |
| Kojto | 90:cb3d968589d8 | 43 | extern "C" { |
| Kojto | 90:cb3d968589d8 | 44 | #endif |
| Kojto | 90:cb3d968589d8 | 45 | |
| Kojto | 90:cb3d968589d8 | 46 | /* Includes ------------------------------------------------------------------*/ |
| Kojto | 90:cb3d968589d8 | 47 | #include "stm32l1xx_hal_def.h" |
| Kojto | 90:cb3d968589d8 | 48 | |
| Kojto | 90:cb3d968589d8 | 49 | /** @addtogroup STM32L1xx_HAL_Driver |
| Kojto | 90:cb3d968589d8 | 50 | * @{ |
| Kojto | 90:cb3d968589d8 | 51 | */ |
| Kojto | 90:cb3d968589d8 | 52 | |
| Kojto | 90:cb3d968589d8 | 53 | /** @addtogroup COMP |
| Kojto | 90:cb3d968589d8 | 54 | * @{ |
| Kojto | 90:cb3d968589d8 | 55 | */ |
| Kojto | 90:cb3d968589d8 | 56 | |
| Kojto | 90:cb3d968589d8 | 57 | /* Exported types ------------------------------------------------------------*/ |
| Kojto | 90:cb3d968589d8 | 58 | /** @defgroup COMP_Exported_Types COMP Exported Types |
| Kojto | 90:cb3d968589d8 | 59 | * @{ |
| Kojto | 90:cb3d968589d8 | 60 | */ |
| Kojto | 90:cb3d968589d8 | 61 | |
| Kojto | 90:cb3d968589d8 | 62 | /** |
| Kojto | 90:cb3d968589d8 | 63 | * @brief COMP Init structure definition |
| Kojto | 90:cb3d968589d8 | 64 | */ |
| Kojto | 90:cb3d968589d8 | 65 | typedef struct |
| Kojto | 90:cb3d968589d8 | 66 | { |
| Kojto | 90:cb3d968589d8 | 67 | |
| Kojto | 90:cb3d968589d8 | 68 | uint32_t InvertingInput; /*!< Selects the inverting input of the comparator. |
| Kojto | 90:cb3d968589d8 | 69 | This parameter can be a value of @ref COMP_InvertingInput |
| Kojto | 90:cb3d968589d8 | 70 | Note: Inverting input can be changed on the fly, while comparator is running. |
| Kojto | 90:cb3d968589d8 | 71 | Note: This feature is available on COMP2 only. If COMP1 is selected, this parameter is discarded (On COMP1, inverting input is fixed to Vrefint). */ |
| Kojto | 90:cb3d968589d8 | 72 | |
| Kojto | 90:cb3d968589d8 | 73 | uint32_t NonInvertingInput; /*!< Selects the non inverting input of the comparator. |
| Kojto | 90:cb3d968589d8 | 74 | This parameter can be a value of @ref COMPEx_NonInvertingInput */ |
| Kojto | 90:cb3d968589d8 | 75 | |
| Kojto | 90:cb3d968589d8 | 76 | uint32_t Output; /*!< Selects the output redirection of the comparator. |
| Kojto | 90:cb3d968589d8 | 77 | This parameter can be a value of @ref COMP_Output |
| Kojto | 90:cb3d968589d8 | 78 | Note: This feature is available on COMP2 only. If COMP1 is selected, this parameter is discarded. */ |
| Kojto | 90:cb3d968589d8 | 79 | |
| Kojto | 90:cb3d968589d8 | 80 | uint32_t Mode; /*!< Selects the operating consumption mode of the comparator |
| Kojto | 90:cb3d968589d8 | 81 | to adjust the speed/consumption. |
| Kojto | 90:cb3d968589d8 | 82 | This parameter can be a value of @ref COMP_Mode |
| Kojto | 90:cb3d968589d8 | 83 | Note: This feature is available on COMP2 only. If COMP1 is selected, this parameter is discarded. */ |
| Kojto | 90:cb3d968589d8 | 84 | |
| Kojto | 90:cb3d968589d8 | 85 | uint32_t WindowMode; /*!< Selects the window mode of the 2 comparators. |
| Kojto | 90:cb3d968589d8 | 86 | If enabled, non-inverting inputs of the 2 comparators are connected together and are using inputs of COMP2 only (COMP1 non-inverting input is no more accessible, even from ADC channel VCOMP). |
| Kojto | 90:cb3d968589d8 | 87 | This parameter can be a value of @ref COMP_WindowMode |
| Kojto | 90:cb3d968589d8 | 88 | Note: This feature must be enabled from COMP2 instance. If COMP1 is selected, this parameter is discarded. */ |
| Kojto | 90:cb3d968589d8 | 89 | |
| Kojto | 90:cb3d968589d8 | 90 | uint32_t TriggerMode; /*!< Selects the trigger mode of the comparator when using interruption on EXTI line (interrupt mode). |
| Kojto | 90:cb3d968589d8 | 91 | This parameter can be a value of @ref COMP_TriggerMode |
| Kojto | 90:cb3d968589d8 | 92 | Note: This feature is used with function "HAL_COMP_Start_IT()". In all other functions, this parameter is discarded. */ |
| Kojto | 90:cb3d968589d8 | 93 | |
| Kojto | 90:cb3d968589d8 | 94 | uint32_t NonInvertingInputPull; /*!< Selects the internal pulling resistor connected on non inverting input. |
| Kojto | 90:cb3d968589d8 | 95 | This parameter can be a value of @ref COMP_NonInvertingInputPull |
| Kojto | 90:cb3d968589d8 | 96 | Note: To avoid extra power consumption, only one resistor should be enabled at a time. |
| Kojto | 90:cb3d968589d8 | 97 | Note: This feature is available on COMP1 only. If COMP2 is selected, this parameter is discarded. */ |
| Kojto | 90:cb3d968589d8 | 98 | |
| Kojto | 90:cb3d968589d8 | 99 | }COMP_InitTypeDef; |
| Kojto | 90:cb3d968589d8 | 100 | |
| Kojto | 90:cb3d968589d8 | 101 | /** |
| Kojto | 90:cb3d968589d8 | 102 | * @brief HAL State structures definition |
| Kojto | 90:cb3d968589d8 | 103 | */ |
| Kojto | 90:cb3d968589d8 | 104 | typedef enum |
| Kojto | 90:cb3d968589d8 | 105 | { |
| Kojto | 90:cb3d968589d8 | 106 | HAL_COMP_STATE_RESET = 0x00, /*!< COMP not yet initialized or disabled */ |
| Kojto | 90:cb3d968589d8 | 107 | HAL_COMP_STATE_READY = 0x01, /*!< COMP initialized and ready for use */ |
| Kojto | 90:cb3d968589d8 | 108 | HAL_COMP_STATE_READY_LOCKED = 0x11, /*!< COMP initialized but the configuration is locked */ |
| Kojto | 90:cb3d968589d8 | 109 | HAL_COMP_STATE_BUSY = 0x02, /*!< COMP is running */ |
| Kojto | 90:cb3d968589d8 | 110 | HAL_COMP_STATE_BUSY_LOCKED = 0x12 /*!< COMP is running and the configuration is locked */ |
| Kojto | 90:cb3d968589d8 | 111 | }HAL_COMP_StateTypeDef; |
| Kojto | 90:cb3d968589d8 | 112 | |
| Kojto | 90:cb3d968589d8 | 113 | /** |
| Kojto | 90:cb3d968589d8 | 114 | * @brief COMP Handle Structure definition |
| Kojto | 90:cb3d968589d8 | 115 | */ |
| Kojto | 90:cb3d968589d8 | 116 | typedef struct |
| Kojto | 90:cb3d968589d8 | 117 | { |
| Kojto | 90:cb3d968589d8 | 118 | COMP_TypeDef *Instance; /*!< Register base address */ |
| Kojto | 90:cb3d968589d8 | 119 | COMP_InitTypeDef Init; /*!< COMP required parameters */ |
| Kojto | 90:cb3d968589d8 | 120 | HAL_LockTypeDef Lock; /*!< Locking object */ |
| Kojto | 90:cb3d968589d8 | 121 | __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */ |
| Kojto | 90:cb3d968589d8 | 122 | } COMP_HandleTypeDef; |
| Kojto | 90:cb3d968589d8 | 123 | |
| Kojto | 90:cb3d968589d8 | 124 | /** |
| Kojto | 90:cb3d968589d8 | 125 | * @} |
| Kojto | 90:cb3d968589d8 | 126 | */ |
| Kojto | 90:cb3d968589d8 | 127 | |
| Kojto | 90:cb3d968589d8 | 128 | /* Exported constants --------------------------------------------------------*/ |
| Kojto | 90:cb3d968589d8 | 129 | /** @defgroup COMP_Exported_Constants COMP Exported Constants |
| Kojto | 90:cb3d968589d8 | 130 | * @{ |
| Kojto | 90:cb3d968589d8 | 131 | */ |
| Kojto | 90:cb3d968589d8 | 132 | |
| Kojto | 90:cb3d968589d8 | 133 | /** @defgroup COMP_Output COMP Output |
| Kojto | 90:cb3d968589d8 | 134 | * @{ |
| Kojto | 90:cb3d968589d8 | 135 | */ |
| Kojto | 90:cb3d968589d8 | 136 | #define COMP_OUTPUT_TIM2IC4 ((uint32_t)0x00000000) /*!< COMP2 output connected to TIM2 Input Capture 4 */ |
| Kojto | 90:cb3d968589d8 | 137 | #define COMP_OUTPUT_TIM2OCREFCLR ( COMP_CSR_OUTSEL_0) /*!< COMP2 output connected to TIM2 OCREF Clear */ |
| Kojto | 90:cb3d968589d8 | 138 | #define COMP_OUTPUT_TIM3IC4 ( COMP_CSR_OUTSEL_1 ) /*!< COMP2 output connected to TIM3 Input Capture 4 */ |
| Kojto | 90:cb3d968589d8 | 139 | #define COMP_OUTPUT_TIM3OCREFCLR ( COMP_CSR_OUTSEL_1 | COMP_CSR_OUTSEL_0) /*!< COMP2 output connected to TIM3 OCREF Clear */ |
| Kojto | 90:cb3d968589d8 | 140 | #define COMP_OUTPUT_TIM4IC4 (COMP_CSR_OUTSEL_2 ) /*!< COMP2 output connected to TIM4 Input Capture 4 */ |
| Kojto | 90:cb3d968589d8 | 141 | #define COMP_OUTPUT_TIM4OCREFCLR (COMP_CSR_OUTSEL_2 | COMP_CSR_OUTSEL_0) /*!< COMP2 output connected to TIM4 OCREF Clear */ |
| Kojto | 90:cb3d968589d8 | 142 | #define COMP_OUTPUT_TIM10IC1 (COMP_CSR_OUTSEL_2 | COMP_CSR_OUTSEL_1 ) /*!< COMP2 output connected to TIM10 Input Capture 1 */ |
| Kojto | 90:cb3d968589d8 | 143 | #define COMP_OUTPUT_NONE (COMP_CSR_OUTSEL_2 | COMP_CSR_OUTSEL_1 | COMP_CSR_OUTSEL_0) /*!< COMP2 output is not connected to other peripherals */ |
| Kojto | 90:cb3d968589d8 | 144 | |
| Kojto | 90:cb3d968589d8 | 145 | #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \ |
| Kojto | 90:cb3d968589d8 | 146 | ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \ |
| Kojto | 90:cb3d968589d8 | 147 | ((OUTPUT) == COMP_OUTPUT_TIM3IC4) || \ |
| Kojto | 90:cb3d968589d8 | 148 | ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \ |
| Kojto | 90:cb3d968589d8 | 149 | ((OUTPUT) == COMP_OUTPUT_TIM4IC4) || \ |
| Kojto | 90:cb3d968589d8 | 150 | ((OUTPUT) == COMP_OUTPUT_TIM4OCREFCLR) || \ |
| Kojto | 90:cb3d968589d8 | 151 | ((OUTPUT) == COMP_OUTPUT_TIM10IC1) || \ |
| Kojto | 90:cb3d968589d8 | 152 | ((OUTPUT) == COMP_OUTPUT_NONE) ) |
| Kojto | 90:cb3d968589d8 | 153 | /** |
| Kojto | 90:cb3d968589d8 | 154 | * @} |
| Kojto | 90:cb3d968589d8 | 155 | */ |
| Kojto | 90:cb3d968589d8 | 156 | |
| Kojto | 90:cb3d968589d8 | 157 | /** @defgroup COMP_InvertingInput COMP InvertingInput |
| Kojto | 90:cb3d968589d8 | 158 | * @{ |
| Kojto | 90:cb3d968589d8 | 159 | */ |
| Kojto | 90:cb3d968589d8 | 160 | /* Inverting Input specific to COMP2 */ |
| Kojto | 90:cb3d968589d8 | 161 | #define COMP_INVERTINGINPUT_IO ( COMP_CSR_INSEL_0) /*!< External I/O (COMP2_INM connected to pin PB3) connected to comparator 2 inverting input */ |
| Kojto | 90:cb3d968589d8 | 162 | #define COMP_INVERTINGINPUT_VREFINT ( COMP_CSR_INSEL_1 ) /*!< VREFINT connected to comparator 2 inverting input */ |
| Kojto | 90:cb3d968589d8 | 163 | #define COMP_INVERTINGINPUT_3_4VREFINT ( COMP_CSR_INSEL_1 | COMP_CSR_INSEL_0) /*!< 3/4 VREFINT connected to comparator 2 inverting input */ |
| Kojto | 90:cb3d968589d8 | 164 | #define COMP_INVERTINGINPUT_1_2VREFINT (COMP_CSR_INSEL_2 ) /*!< 1/2 VREFINT connected to comparator 2 inverting input */ |
| Kojto | 90:cb3d968589d8 | 165 | #define COMP_INVERTINGINPUT_1_4VREFINT (COMP_CSR_INSEL_2 | COMP_CSR_INSEL_0) /*!< 1/4 VREFINT connected to comparator 2 inverting input */ |
| Kojto | 90:cb3d968589d8 | 166 | #define COMP_INVERTINGINPUT_DAC1 (COMP_CSR_INSEL_2 | COMP_CSR_INSEL_1 ) /*!< DAC_OUT1 (PA4) connected to comparator 2 inverting input */ |
| Kojto | 90:cb3d968589d8 | 167 | #define COMP_INVERTINGINPUT_DAC2 (COMP_CSR_INSEL_2 | COMP_CSR_INSEL_1 | COMP_CSR_INSEL_0) /*!< DAC2_OUT (PA5) connected to comparator 2 inverting input */ |
| Kojto | 90:cb3d968589d8 | 168 | |
| Kojto | 90:cb3d968589d8 | 169 | #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_IO) || \ |
| Kojto | 90:cb3d968589d8 | 170 | ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \ |
| Kojto | 90:cb3d968589d8 | 171 | ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \ |
| Kojto | 90:cb3d968589d8 | 172 | ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \ |
| Kojto | 90:cb3d968589d8 | 173 | ((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \ |
| Kojto | 90:cb3d968589d8 | 174 | ((INPUT) == COMP_INVERTINGINPUT_DAC1) || \ |
| Kojto | 90:cb3d968589d8 | 175 | ((INPUT) == COMP_INVERTINGINPUT_DAC2) ) |
| Kojto | 90:cb3d968589d8 | 176 | /** |
| Kojto | 90:cb3d968589d8 | 177 | * @} |
| Kojto | 90:cb3d968589d8 | 178 | */ |
| Kojto | 90:cb3d968589d8 | 179 | |
| Kojto | 90:cb3d968589d8 | 180 | /** @defgroup COMP_Mode COMP Mode |
| Kojto | 90:cb3d968589d8 | 181 | * @{ |
| Kojto | 90:cb3d968589d8 | 182 | */ |
| Kojto | 90:cb3d968589d8 | 183 | /* Please refer to the electrical characteristics in the device datasheet for |
| Kojto | 90:cb3d968589d8 | 184 | the power consumption values */ |
| Kojto | 90:cb3d968589d8 | 185 | #define COMP_MODE_LOWSPEED ((uint32_t)0x00000000) /*!< Low Speed */ |
| Kojto | 90:cb3d968589d8 | 186 | #define COMP_MODE_HIGHSPEED COMP_CSR_SPEED /*!< High Speed */ |
| Kojto | 90:cb3d968589d8 | 187 | |
| Kojto | 90:cb3d968589d8 | 188 | #define IS_COMP_MODE(SPEED) (((SPEED) == COMP_MODE_LOWSPEED) || \ |
| Kojto | 90:cb3d968589d8 | 189 | ((SPEED) == COMP_MODE_HIGHSPEED)) |
| Kojto | 90:cb3d968589d8 | 190 | /** |
| Kojto | 90:cb3d968589d8 | 191 | * @} |
| Kojto | 90:cb3d968589d8 | 192 | */ |
| Kojto | 90:cb3d968589d8 | 193 | |
| Kojto | 90:cb3d968589d8 | 194 | /** @defgroup COMP_WindowMode COMP WindowMode |
| Kojto | 90:cb3d968589d8 | 195 | * @{ |
| Kojto | 90:cb3d968589d8 | 196 | */ |
| Kojto | 122:f9eeca106725 | 197 | #define COMP_WINDOWMODE_DISABLE ((uint32_t)0x00000000) /*!< Window mode disabled: COMP1 non-inverting input is independant */ |
| Kojto | 122:f9eeca106725 | 198 | #define COMP_WINDOWMODE_ENABLE COMP_CSR_WNDWE /*!< Window mode enabled: COMP1 non-inverting input is no more accessible, even from ADC channel VCOMP) (connected to COMP2 non-inverting input) */ |
| Kojto | 90:cb3d968589d8 | 199 | |
| Kojto | 122:f9eeca106725 | 200 | #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLE) || \ |
| Kojto | 122:f9eeca106725 | 201 | ((WINDOWMODE) == COMP_WINDOWMODE_ENABLE)) |
| Kojto | 90:cb3d968589d8 | 202 | /** |
| Kojto | 90:cb3d968589d8 | 203 | * @} |
| Kojto | 90:cb3d968589d8 | 204 | */ |
| Kojto | 90:cb3d968589d8 | 205 | |
| Kojto | 90:cb3d968589d8 | 206 | /** @defgroup COMP_OutputLevel COMP OutputLevel |
| Kojto | 90:cb3d968589d8 | 207 | * @{ |
| Kojto | 90:cb3d968589d8 | 208 | */ |
| Kojto | 90:cb3d968589d8 | 209 | /* Comparator output is low when the non-inverting input is at a lower */ |
| Kojto | 90:cb3d968589d8 | 210 | /* voltage than the inverting input. */ |
| Kojto | 90:cb3d968589d8 | 211 | #define COMP_OUTPUTLEVEL_LOW ((uint32_t)0x00000000) |
| Kojto | 90:cb3d968589d8 | 212 | |
| Kojto | 90:cb3d968589d8 | 213 | /* Comparator output is high when the non-inverting input is at a higher */ |
| Kojto | 90:cb3d968589d8 | 214 | /* voltage than the inverting input. */ |
| Kojto | 90:cb3d968589d8 | 215 | #define COMP_OUTPUTLEVEL_HIGH ((uint32_t)0x00000001) |
| Kojto | 90:cb3d968589d8 | 216 | /** |
| Kojto | 90:cb3d968589d8 | 217 | * @} |
| Kojto | 90:cb3d968589d8 | 218 | */ |
| Kojto | 90:cb3d968589d8 | 219 | |
| Kojto | 90:cb3d968589d8 | 220 | /** @defgroup COMP_TriggerMode COMP TriggerMode |
| Kojto | 90:cb3d968589d8 | 221 | * @{ |
| Kojto | 90:cb3d968589d8 | 222 | */ |
| Kojto | 90:cb3d968589d8 | 223 | #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< No External Interrupt trigger detection */ |
| Kojto | 90:cb3d968589d8 | 224 | #define COMP_TRIGGERMODE_IT_RISING ((uint32_t)0x00000001) /*!< External Interrupt Mode with Rising edge trigger detection */ |
| Kojto | 90:cb3d968589d8 | 225 | #define COMP_TRIGGERMODE_IT_FALLING ((uint32_t)0x00000002) /*!< External Interrupt Mode with Falling edge trigger detection */ |
| Kojto | 90:cb3d968589d8 | 226 | #define COMP_TRIGGERMODE_IT_RISING_FALLING ((uint32_t)0x00000003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ |
| Kojto | 90:cb3d968589d8 | 227 | |
| Kojto | 90:cb3d968589d8 | 228 | #define IS_COMP_TRIGGERMODE(MODE) (((MODE) == COMP_TRIGGERMODE_NONE) || \ |
| Kojto | 90:cb3d968589d8 | 229 | ((MODE) == COMP_TRIGGERMODE_IT_RISING) || \ |
| Kojto | 90:cb3d968589d8 | 230 | ((MODE) == COMP_TRIGGERMODE_IT_FALLING) || \ |
| Kojto | 90:cb3d968589d8 | 231 | ((MODE) == COMP_TRIGGERMODE_IT_RISING_FALLING) ) |
| Kojto | 90:cb3d968589d8 | 232 | /** |
| Kojto | 90:cb3d968589d8 | 233 | * @} |
| Kojto | 90:cb3d968589d8 | 234 | */ |
| Kojto | 90:cb3d968589d8 | 235 | |
| Kojto | 90:cb3d968589d8 | 236 | /** @defgroup COMP_ExtiLineEvent COMP ExtiLineEvent |
| Kojto | 90:cb3d968589d8 | 237 | * @{ |
| Kojto | 90:cb3d968589d8 | 238 | */ |
| Kojto | 122:f9eeca106725 | 239 | #define COMP_EXTI_LINE_COMP1 EXTI_RTSR_TR21 /*!< External interrupt line 21 Connected to COMP1 */ |
| Kojto | 122:f9eeca106725 | 240 | #define COMP_EXTI_LINE_COMP2 EXTI_RTSR_TR22 /*!< External interrupt line 22 Connected to COMP2 */ |
| Kojto | 90:cb3d968589d8 | 241 | |
| Kojto | 90:cb3d968589d8 | 242 | /** |
| Kojto | 90:cb3d968589d8 | 243 | * @} |
| Kojto | 90:cb3d968589d8 | 244 | */ |
| Kojto | 90:cb3d968589d8 | 245 | |
| Kojto | 90:cb3d968589d8 | 246 | /** @defgroup COMP_NonInvertingInputPull COMP NonInvertingInputPull |
| Kojto | 90:cb3d968589d8 | 247 | * @{ |
| Kojto | 90:cb3d968589d8 | 248 | */ |
| Kojto | 90:cb3d968589d8 | 249 | #define COMP_NONINVERTINGINPUT_NOPULL ((uint32_t)0x00000000) /*!< No internal pull-up or pull-down resistor connected to comparator non inverting input */ |
| Kojto | 90:cb3d968589d8 | 250 | #define COMP_NONINVERTINGINPUT_10KPU COMP_CSR_10KPU /*!< Internal 10kOhm pull-up resistor connected to comparator non inverting input */ |
| Kojto | 90:cb3d968589d8 | 251 | #define COMP_NONINVERTINGINPUT_10KPD COMP_CSR_10KPD /*!< Internal 10kOhm pull-down resistor connected to comparator non inverting input */ |
| Kojto | 90:cb3d968589d8 | 252 | #define COMP_NONINVERTINGINPUT_400KPU COMP_CSR_400KPU /*!< Internal 400kOhm pull-up resistor connected to comparator non inverting input */ |
| Kojto | 90:cb3d968589d8 | 253 | #define COMP_NONINVERTINGINPUT_400KPD COMP_CSR_400KPD /*!< Internal 400kOhm pull-down resistor connected to comparator non inverting input */ |
| Kojto | 90:cb3d968589d8 | 254 | |
| Kojto | 90:cb3d968589d8 | 255 | #define IS_COMP_NONINVERTINGINPUTPULL(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_NOPULL) || \ |
| Kojto | 90:cb3d968589d8 | 256 | ((INPUT) == COMP_NONINVERTINGINPUT_10KPU) || \ |
| Kojto | 90:cb3d968589d8 | 257 | ((INPUT) == COMP_NONINVERTINGINPUT_10KPD) || \ |
| Kojto | 90:cb3d968589d8 | 258 | ((INPUT) == COMP_NONINVERTINGINPUT_400KPU) || \ |
| Kojto | 90:cb3d968589d8 | 259 | ((INPUT) == COMP_NONINVERTINGINPUT_400KPD) ) |
| Kojto | 90:cb3d968589d8 | 260 | /** |
| Kojto | 90:cb3d968589d8 | 261 | * @} |
| Kojto | 90:cb3d968589d8 | 262 | */ |
| Kojto | 90:cb3d968589d8 | 263 | |
| Kojto | 90:cb3d968589d8 | 264 | /** |
| Kojto | 90:cb3d968589d8 | 265 | * @} |
| Kojto | 90:cb3d968589d8 | 266 | */ |
| Kojto | 90:cb3d968589d8 | 267 | |
| Kojto | 90:cb3d968589d8 | 268 | |
| Kojto | 90:cb3d968589d8 | 269 | /* Exported macro ------------------------------------------------------------*/ |
| Kojto | 90:cb3d968589d8 | 270 | |
| Kojto | 90:cb3d968589d8 | 271 | /** @defgroup COMP_Exported_Macro COMP Exported Macro |
| Kojto | 90:cb3d968589d8 | 272 | * @{ |
| Kojto | 90:cb3d968589d8 | 273 | */ |
| Kojto | 90:cb3d968589d8 | 274 | |
| Kojto | 90:cb3d968589d8 | 275 | /** @brief Reset COMP handle state |
| Kojto | 90:cb3d968589d8 | 276 | * @param __HANDLE__: COMP handle. |
| Kojto | 90:cb3d968589d8 | 277 | * @retval None |
| Kojto | 90:cb3d968589d8 | 278 | */ |
| Kojto | 90:cb3d968589d8 | 279 | #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET) |
| Kojto | 90:cb3d968589d8 | 280 | |
| Kojto | 90:cb3d968589d8 | 281 | /** |
| Kojto | 90:cb3d968589d8 | 282 | * @brief Enables the specified comparator |
| Kojto | 90:cb3d968589d8 | 283 | * @param __HANDLE__: COMP handle. |
| Kojto | 90:cb3d968589d8 | 284 | * @retval None. |
| Kojto | 90:cb3d968589d8 | 285 | */ |
| Kojto | 90:cb3d968589d8 | 286 | #define __HAL_COMP_ENABLE(__HANDLE__) \ |
| Kojto | 90:cb3d968589d8 | 287 | ( ( ((__HANDLE__)->Instance == COMP1) \ |
| Kojto | 90:cb3d968589d8 | 288 | )? \ |
| Kojto | 90:cb3d968589d8 | 289 | SET_BIT(COMP->CSR, COMP_CSR_CMP1EN) \ |
| Kojto | 90:cb3d968589d8 | 290 | : \ |
| Kojto | 90:cb3d968589d8 | 291 | MODIFY_REG(COMP->CSR, COMP_CSR_INSEL, (__HANDLE__)->Init.InvertingInput ) \ |
| Kojto | 90:cb3d968589d8 | 292 | ) |
| Kojto | 90:cb3d968589d8 | 293 | |
| Kojto | 90:cb3d968589d8 | 294 | /** |
| Kojto | 90:cb3d968589d8 | 295 | * @brief Disables the specified comparator |
| Kojto | 90:cb3d968589d8 | 296 | * @param __HANDLE__: COMP handle. |
| Kojto | 90:cb3d968589d8 | 297 | * @retval None. |
| Kojto | 90:cb3d968589d8 | 298 | */ |
| Kojto | 90:cb3d968589d8 | 299 | #define __HAL_COMP_DISABLE(__HANDLE__) \ |
| Kojto | 90:cb3d968589d8 | 300 | ( ( ((__HANDLE__)->Instance == COMP1) \ |
| Kojto | 90:cb3d968589d8 | 301 | )? \ |
| Kojto | 90:cb3d968589d8 | 302 | CLEAR_BIT(COMP->CSR, COMP_CSR_CMP1EN) \ |
| Kojto | 90:cb3d968589d8 | 303 | : \ |
| Kojto | 90:cb3d968589d8 | 304 | CLEAR_BIT(COMP->CSR, COMP_CSR_INSEL) \ |
| Kojto | 90:cb3d968589d8 | 305 | ) |
| Kojto | 122:f9eeca106725 | 306 | |
| Kojto | 90:cb3d968589d8 | 307 | /** @brief Checks whether the specified COMP flag is set or not. |
| Kojto | 90:cb3d968589d8 | 308 | * @param __HANDLE__: specifies the COMP Handle. |
| Kojto | 90:cb3d968589d8 | 309 | * @param __FLAG__: specifies the flag to check. |
| Kojto | 90:cb3d968589d8 | 310 | * This parameter can be one of the following values: |
| Kojto | 90:cb3d968589d8 | 311 | * @arg COMP_FLAG_LOCK: lock flag |
| Kojto | 90:cb3d968589d8 | 312 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
| Kojto | 90:cb3d968589d8 | 313 | */ |
| Kojto | 90:cb3d968589d8 | 314 | #define __HAL_COMP_GET_FLAG(__HANDLE__, __FLAG__) (READ_BIT((__HANDLE__)->Instance->CSR, (__FLAG__)) == (__FLAG__)) |
| Kojto | 90:cb3d968589d8 | 315 | |
| Kojto | 122:f9eeca106725 | 316 | /** |
| Kojto | 122:f9eeca106725 | 317 | * @brief Enable the COMP1 EXTI line rising edge trigger. |
| Kojto | 122:f9eeca106725 | 318 | * @retval None |
| Kojto | 122:f9eeca106725 | 319 | */ |
| Kojto | 122:f9eeca106725 | 320 | #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP1) |
| Kojto | 122:f9eeca106725 | 321 | |
| Kojto | 122:f9eeca106725 | 322 | /** |
| Kojto | 122:f9eeca106725 | 323 | * @brief Disable the COMP1 EXTI line rising edge trigger. |
| Kojto | 122:f9eeca106725 | 324 | * @retval None |
| Kojto | 122:f9eeca106725 | 325 | */ |
| Kojto | 122:f9eeca106725 | 326 | #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP1) |
| Kojto | 90:cb3d968589d8 | 327 | |
| Kojto | 90:cb3d968589d8 | 328 | /** |
| Kojto | 122:f9eeca106725 | 329 | * @brief Enable the COMP1 EXTI line falling edge trigger. |
| Kojto | 122:f9eeca106725 | 330 | * @retval None |
| Kojto | 122:f9eeca106725 | 331 | */ |
| Kojto | 122:f9eeca106725 | 332 | #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP1) |
| Kojto | 122:f9eeca106725 | 333 | |
| Kojto | 122:f9eeca106725 | 334 | /** |
| Kojto | 122:f9eeca106725 | 335 | * @brief Disable the COMP1 EXTI line falling edge trigger. |
| Kojto | 122:f9eeca106725 | 336 | * @retval None |
| Kojto | 90:cb3d968589d8 | 337 | */ |
| Kojto | 122:f9eeca106725 | 338 | #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP1) |
| Kojto | 122:f9eeca106725 | 339 | |
| Kojto | 122:f9eeca106725 | 340 | /** |
| Kojto | 122:f9eeca106725 | 341 | * @brief Enable the COMP1 EXTI line rising & falling edge trigger. |
| Kojto | 122:f9eeca106725 | 342 | * @retval None |
| Kojto | 122:f9eeca106725 | 343 | */ |
| Kojto | 122:f9eeca106725 | 344 | #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ |
| Kojto | 122:f9eeca106725 | 345 | __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE(); \ |
| Kojto | 122:f9eeca106725 | 346 | __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE(); \ |
| Kojto | 122:f9eeca106725 | 347 | } while(0) |
| Kojto | 90:cb3d968589d8 | 348 | |
| Kojto | 90:cb3d968589d8 | 349 | /** |
| Kojto | 122:f9eeca106725 | 350 | * @brief Disable the COMP1 EXTI line rising & falling edge trigger. |
| Kojto | 122:f9eeca106725 | 351 | * @retval None |
| Kojto | 90:cb3d968589d8 | 352 | */ |
| Kojto | 122:f9eeca106725 | 353 | #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ |
| Kojto | 122:f9eeca106725 | 354 | __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE(); \ |
| Kojto | 122:f9eeca106725 | 355 | __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE(); \ |
| Kojto | 122:f9eeca106725 | 356 | } while(0) |
| Kojto | 122:f9eeca106725 | 357 | |
| Kojto | 122:f9eeca106725 | 358 | /** |
| Kojto | 122:f9eeca106725 | 359 | * @brief Enable the COMP1 EXTI line in interrupt mode. |
| Kojto | 122:f9eeca106725 | 360 | * @retval None |
| Kojto | 122:f9eeca106725 | 361 | */ |
| Kojto | 122:f9eeca106725 | 362 | #define __HAL_COMP_COMP1_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP1) |
| Kojto | 122:f9eeca106725 | 363 | |
| Kojto | 122:f9eeca106725 | 364 | /** |
| Kojto | 122:f9eeca106725 | 365 | * @brief Disable the COMP1 EXTI line in interrupt mode. |
| Kojto | 122:f9eeca106725 | 366 | * @retval None |
| Kojto | 122:f9eeca106725 | 367 | */ |
| Kojto | 122:f9eeca106725 | 368 | #define __HAL_COMP_COMP1_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP1) |
| Kojto | 90:cb3d968589d8 | 369 | |
| Kojto | 90:cb3d968589d8 | 370 | /** |
| Kojto | 122:f9eeca106725 | 371 | * @brief Enable the COMP1 EXTI Line in event mode. |
| Kojto | 122:f9eeca106725 | 372 | * @retval None |
| Kojto | 122:f9eeca106725 | 373 | */ |
| Kojto | 122:f9eeca106725 | 374 | #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP1) |
| Kojto | 90:cb3d968589d8 | 375 | |
| Kojto | 90:cb3d968589d8 | 376 | /** |
| Kojto | 122:f9eeca106725 | 377 | * @brief Disable the COMP1 EXTI Line in event mode. |
| Kojto | 122:f9eeca106725 | 378 | * @retval None |
| Kojto | 122:f9eeca106725 | 379 | */ |
| Kojto | 122:f9eeca106725 | 380 | #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP1) |
| Kojto | 122:f9eeca106725 | 381 | |
| Kojto | 122:f9eeca106725 | 382 | /** |
| Kojto | 122:f9eeca106725 | 383 | * @brief Check whether the COMP1 EXTI line flag is set or not. |
| Kojto | 122:f9eeca106725 | 384 | * @retval RESET or SET |
| Kojto | 122:f9eeca106725 | 385 | */ |
| Kojto | 122:f9eeca106725 | 386 | #define __HAL_COMP_COMP1_EXTI_GET_FLAG() READ_BIT(EXTI->PR, COMP_EXTI_LINE_COMP1) |
| Kojto | 122:f9eeca106725 | 387 | |
| Kojto | 122:f9eeca106725 | 388 | /** |
| Kojto | 122:f9eeca106725 | 389 | * @brief Clear the the COMP1 EXTI flag. |
| Kojto | 122:f9eeca106725 | 390 | * @retval None |
| Kojto | 122:f9eeca106725 | 391 | */ |
| Kojto | 122:f9eeca106725 | 392 | #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR, COMP_EXTI_LINE_COMP1) |
| Kojto | 90:cb3d968589d8 | 393 | |
| Kojto | 90:cb3d968589d8 | 394 | /** |
| Kojto | 122:f9eeca106725 | 395 | * @brief Generates a Software interrupt on COMP1 EXTI Line. |
| Kojto | 122:f9eeca106725 | 396 | * @retval None |
| Kojto | 90:cb3d968589d8 | 397 | */ |
| Kojto | 122:f9eeca106725 | 398 | #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, COMP_EXTI_LINE_COMP1) |
| Kojto | 122:f9eeca106725 | 399 | |
| Kojto | 122:f9eeca106725 | 400 | /** |
| Kojto | 122:f9eeca106725 | 401 | * @brief Enable the COMP2 EXTI line rising edge trigger. |
| Kojto | 122:f9eeca106725 | 402 | * @retval None |
| Kojto | 122:f9eeca106725 | 403 | */ |
| Kojto | 122:f9eeca106725 | 404 | #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP2) |
| Kojto | 122:f9eeca106725 | 405 | |
| Kojto | 122:f9eeca106725 | 406 | /** |
| Kojto | 122:f9eeca106725 | 407 | * @brief Disable the COMP2 EXTI line rising edge trigger. |
| Kojto | 122:f9eeca106725 | 408 | * @retval None |
| Kojto | 122:f9eeca106725 | 409 | */ |
| Kojto | 122:f9eeca106725 | 410 | #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP2) |
| Kojto | 122:f9eeca106725 | 411 | |
| Kojto | 90:cb3d968589d8 | 412 | /** |
| Kojto | 122:f9eeca106725 | 413 | * @brief Enable the COMP2 EXTI line falling edge trigger. |
| Kojto | 122:f9eeca106725 | 414 | * @retval None |
| Kojto | 122:f9eeca106725 | 415 | */ |
| Kojto | 122:f9eeca106725 | 416 | #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP2) |
| Kojto | 122:f9eeca106725 | 417 | |
| Kojto | 122:f9eeca106725 | 418 | /** |
| Kojto | 122:f9eeca106725 | 419 | * @brief Disable the COMP2 EXTI line falling edge trigger. |
| Kojto | 122:f9eeca106725 | 420 | * @retval None |
| Kojto | 90:cb3d968589d8 | 421 | */ |
| Kojto | 122:f9eeca106725 | 422 | #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP2) |
| Kojto | 122:f9eeca106725 | 423 | |
| Kojto | 122:f9eeca106725 | 424 | /** |
| Kojto | 122:f9eeca106725 | 425 | * @brief Enable the COMP2 EXTI line rising & falling edge trigger. |
| Kojto | 122:f9eeca106725 | 426 | * @retval None |
| Kojto | 122:f9eeca106725 | 427 | */ |
| Kojto | 122:f9eeca106725 | 428 | #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ |
| Kojto | 122:f9eeca106725 | 429 | __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE(); \ |
| Kojto | 122:f9eeca106725 | 430 | __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE(); \ |
| Kojto | 122:f9eeca106725 | 431 | } while(0) |
| Kojto | 90:cb3d968589d8 | 432 | |
| Kojto | 90:cb3d968589d8 | 433 | /** |
| Kojto | 122:f9eeca106725 | 434 | * @brief Disable the COMP2 EXTI line rising & falling edge trigger. |
| Kojto | 122:f9eeca106725 | 435 | * @retval None |
| Kojto | 122:f9eeca106725 | 436 | */ |
| Kojto | 122:f9eeca106725 | 437 | #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ |
| Kojto | 122:f9eeca106725 | 438 | __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE(); \ |
| Kojto | 122:f9eeca106725 | 439 | __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE(); \ |
| Kojto | 122:f9eeca106725 | 440 | } while(0) |
| Kojto | 122:f9eeca106725 | 441 | |
| Kojto | 122:f9eeca106725 | 442 | /** |
| Kojto | 122:f9eeca106725 | 443 | * @brief Enable the COMP2 EXTI line. |
| Kojto | 122:f9eeca106725 | 444 | * @retval None |
| Kojto | 122:f9eeca106725 | 445 | */ |
| Kojto | 122:f9eeca106725 | 446 | #define __HAL_COMP_COMP2_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP2) |
| Kojto | 122:f9eeca106725 | 447 | |
| Kojto | 122:f9eeca106725 | 448 | /** |
| Kojto | 122:f9eeca106725 | 449 | * @brief Disable the COMP2 EXTI line. |
| Kojto | 122:f9eeca106725 | 450 | * @retval None |
| Kojto | 90:cb3d968589d8 | 451 | */ |
| Kojto | 122:f9eeca106725 | 452 | #define __HAL_COMP_COMP2_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP2) |
| Kojto | 90:cb3d968589d8 | 453 | |
| Kojto | 90:cb3d968589d8 | 454 | /** |
| Kojto | 122:f9eeca106725 | 455 | * @brief Enable the COMP2 EXTI Line in event mode. |
| Kojto | 122:f9eeca106725 | 456 | * @retval None |
| Kojto | 90:cb3d968589d8 | 457 | */ |
| Kojto | 122:f9eeca106725 | 458 | #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP2) |
| Kojto | 122:f9eeca106725 | 459 | |
| Kojto | 122:f9eeca106725 | 460 | /** |
| Kojto | 122:f9eeca106725 | 461 | * @brief Disable the COMP2 EXTI Line in event mode. |
| Kojto | 122:f9eeca106725 | 462 | * @retval None |
| Kojto | 122:f9eeca106725 | 463 | */ |
| Kojto | 122:f9eeca106725 | 464 | #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP2) |
| Kojto | 122:f9eeca106725 | 465 | |
| Kojto | 122:f9eeca106725 | 466 | /** |
| Kojto | 122:f9eeca106725 | 467 | * @brief Check whether the COMP2 EXTI line flag is set or not. |
| Kojto | 122:f9eeca106725 | 468 | * @retval RESET or SET |
| Kojto | 122:f9eeca106725 | 469 | */ |
| Kojto | 122:f9eeca106725 | 470 | #define __HAL_COMP_COMP2_EXTI_GET_FLAG() READ_BIT(EXTI->PR, COMP_EXTI_LINE_COMP2) |
| Kojto | 90:cb3d968589d8 | 471 | |
| Kojto | 90:cb3d968589d8 | 472 | /** |
| Kojto | 122:f9eeca106725 | 473 | * @brief Clear the the COMP2 EXTI flag. |
| Kojto | 122:f9eeca106725 | 474 | * @retval None |
| Kojto | 90:cb3d968589d8 | 475 | */ |
| Kojto | 122:f9eeca106725 | 476 | #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR, COMP_EXTI_LINE_COMP2) |
| Kojto | 90:cb3d968589d8 | 477 | |
| Kojto | 90:cb3d968589d8 | 478 | /** |
| Kojto | 122:f9eeca106725 | 479 | * @brief Generates a Software interrupt on COMP1 EXTI Line. |
| Kojto | 90:cb3d968589d8 | 480 | * @retval None |
| Kojto | 90:cb3d968589d8 | 481 | */ |
| Kojto | 122:f9eeca106725 | 482 | #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, COMP_EXTI_LINE_COMP2) |
| Kojto | 90:cb3d968589d8 | 483 | |
| Kojto | 90:cb3d968589d8 | 484 | /** |
| Kojto | 90:cb3d968589d8 | 485 | * @} |
| Kojto | 90:cb3d968589d8 | 486 | */ |
| Kojto | 90:cb3d968589d8 | 487 | |
| Kojto | 90:cb3d968589d8 | 488 | /* Private macro -------------------------------------------------------------*/ |
| Kojto | 90:cb3d968589d8 | 489 | |
| Kojto | 90:cb3d968589d8 | 490 | /** @defgroup COMP_Private_Macro COMP Private Macro |
| Kojto | 90:cb3d968589d8 | 491 | * @{ |
| Kojto | 90:cb3d968589d8 | 492 | */ |
| Kojto | 90:cb3d968589d8 | 493 | |
| Kojto | 90:cb3d968589d8 | 494 | /** |
| Kojto | 122:f9eeca106725 | 495 | * @brief Get the specified EXTI line for a comparator instance |
| Kojto | 122:f9eeca106725 | 496 | * @param __INSTANCE__: specifies the COMP instance. |
| Kojto | 122:f9eeca106725 | 497 | * @retval value of @ref COMP_ExtiLineEvent |
| Kojto | 122:f9eeca106725 | 498 | */ |
| Kojto | 122:f9eeca106725 | 499 | #define COMP_GET_EXTI_LINE(__INSTANCE__) \ |
| Kojto | 122:f9eeca106725 | 500 | ( ( ((__INSTANCE__) == COMP1) \ |
| Kojto | 122:f9eeca106725 | 501 | )? \ |
| Kojto | 122:f9eeca106725 | 502 | (COMP_EXTI_LINE_COMP1) \ |
| Kojto | 122:f9eeca106725 | 503 | : \ |
| Kojto | 122:f9eeca106725 | 504 | (COMP_EXTI_LINE_COMP2) \ |
| Kojto | 122:f9eeca106725 | 505 | ) |
| Kojto | 122:f9eeca106725 | 506 | |
| Kojto | 122:f9eeca106725 | 507 | /** |
| Kojto | 90:cb3d968589d8 | 508 | * @brief Select the COMP register CSR bit CMPxOUT corresponding to the |
| Kojto | 90:cb3d968589d8 | 509 | * selected COMP instance. |
| Kojto | 90:cb3d968589d8 | 510 | * @param __HANDLE__: COMP handle |
| Kojto | 90:cb3d968589d8 | 511 | * @retval Comparator register CSR bit COMP_CSR_CMP1OUT or COMP_CSR_CMP2OUT |
| Kojto | 90:cb3d968589d8 | 512 | */ |
| Kojto | 90:cb3d968589d8 | 513 | #define __COMP_CSR_CMPXOUT(__HANDLE__) \ |
| Kojto | 90:cb3d968589d8 | 514 | ( ( ((__HANDLE__)->Instance == COMP1) \ |
| Kojto | 90:cb3d968589d8 | 515 | )? \ |
| Kojto | 90:cb3d968589d8 | 516 | (COMP_CSR_CMP1OUT) \ |
| Kojto | 90:cb3d968589d8 | 517 | : \ |
| Kojto | 90:cb3d968589d8 | 518 | (COMP_CSR_CMP2OUT) \ |
| Kojto | 90:cb3d968589d8 | 519 | ) |
| Kojto | 90:cb3d968589d8 | 520 | |
| Kojto | 90:cb3d968589d8 | 521 | /** |
| Kojto | 90:cb3d968589d8 | 522 | * @brief Verification of COMP state: enabled or disabled |
| Kojto | 90:cb3d968589d8 | 523 | * @param __HANDLE__: COMP handle |
| Kojto | 90:cb3d968589d8 | 524 | * @retval SET (COMP enabled) or RESET (COMP disabled) |
| Kojto | 90:cb3d968589d8 | 525 | */ |
| Kojto | 90:cb3d968589d8 | 526 | #define __COMP_IS_ENABLED(__HANDLE__) \ |
| Kojto | 90:cb3d968589d8 | 527 | ( ( ((__HANDLE__)->Instance == COMP1) \ |
| Kojto | 90:cb3d968589d8 | 528 | )? \ |
| Kojto | 90:cb3d968589d8 | 529 | (((READ_BIT(COMP->CSR , COMP_CSR_CMP1EN) == COMP_CSR_CMP1EN) \ |
| Kojto | 90:cb3d968589d8 | 530 | ) ? SET : RESET) \ |
| Kojto | 90:cb3d968589d8 | 531 | : \ |
| Kojto | 90:cb3d968589d8 | 532 | (((READ_BIT(COMP->CSR , COMP_CSR_INSEL) != RESET) \ |
| Kojto | 90:cb3d968589d8 | 533 | ) ? SET : RESET) \ |
| Kojto | 90:cb3d968589d8 | 534 | ) |
| Kojto | 90:cb3d968589d8 | 535 | |
| Kojto | 90:cb3d968589d8 | 536 | /** |
| Kojto | 90:cb3d968589d8 | 537 | * @} |
| Kojto | 90:cb3d968589d8 | 538 | */ |
| Kojto | 90:cb3d968589d8 | 539 | |
| Kojto | 90:cb3d968589d8 | 540 | |
| Kojto | 90:cb3d968589d8 | 541 | /* Include COMP HAL Extension module */ |
| Kojto | 90:cb3d968589d8 | 542 | #include "stm32l1xx_hal_comp_ex.h" |
| Kojto | 90:cb3d968589d8 | 543 | |
| Kojto | 90:cb3d968589d8 | 544 | /* Exported functions --------------------------------------------------------*/ |
| Kojto | 90:cb3d968589d8 | 545 | /** @addtogroup COMP_Exported_Functions |
| Kojto | 90:cb3d968589d8 | 546 | * @{ |
| Kojto | 90:cb3d968589d8 | 547 | */ |
| Kojto | 90:cb3d968589d8 | 548 | |
| Kojto | 90:cb3d968589d8 | 549 | /* Initialization and de-initialization functions ******************************/ |
| Kojto | 90:cb3d968589d8 | 550 | /** @addtogroup COMP_Exported_Functions_Group1 |
| Kojto | 90:cb3d968589d8 | 551 | * @{ |
| Kojto | 90:cb3d968589d8 | 552 | */ |
| Kojto | 90:cb3d968589d8 | 553 | HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 554 | HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 555 | void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 556 | void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 557 | /** |
| Kojto | 90:cb3d968589d8 | 558 | * @} |
| Kojto | 90:cb3d968589d8 | 559 | */ |
| Kojto | 90:cb3d968589d8 | 560 | |
| Kojto | 90:cb3d968589d8 | 561 | /* I/O operation functions *****************************************************/ |
| Kojto | 90:cb3d968589d8 | 562 | /** @addtogroup COMP_Exported_Functions_Group2 |
| Kojto | 90:cb3d968589d8 | 563 | * @{ |
| Kojto | 90:cb3d968589d8 | 564 | */ |
| Kojto | 90:cb3d968589d8 | 565 | HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 566 | HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 567 | HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 568 | HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 569 | void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 570 | /** |
| Kojto | 90:cb3d968589d8 | 571 | * @} |
| Kojto | 90:cb3d968589d8 | 572 | */ |
| Kojto | 90:cb3d968589d8 | 573 | |
| Kojto | 90:cb3d968589d8 | 574 | /* Peripheral Control functions ************************************************/ |
| Kojto | 90:cb3d968589d8 | 575 | /** @addtogroup COMP_Exported_Functions_Group3 |
| Kojto | 90:cb3d968589d8 | 576 | * @{ |
| Kojto | 90:cb3d968589d8 | 577 | */ |
| Kojto | 90:cb3d968589d8 | 578 | HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 579 | uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 580 | |
| Kojto | 90:cb3d968589d8 | 581 | /* Callback in Interrupt mode */ |
| Kojto | 90:cb3d968589d8 | 582 | void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 583 | /** |
| Kojto | 90:cb3d968589d8 | 584 | * @} |
| Kojto | 90:cb3d968589d8 | 585 | */ |
| Kojto | 90:cb3d968589d8 | 586 | |
| Kojto | 90:cb3d968589d8 | 587 | /* Peripheral State functions **************************************************/ |
| Kojto | 90:cb3d968589d8 | 588 | /** @addtogroup COMP_Exported_Functions_Group4 |
| Kojto | 90:cb3d968589d8 | 589 | * @{ |
| Kojto | 90:cb3d968589d8 | 590 | */ |
| Kojto | 90:cb3d968589d8 | 591 | HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp); |
| Kojto | 90:cb3d968589d8 | 592 | /** |
| Kojto | 90:cb3d968589d8 | 593 | * @} |
| Kojto | 90:cb3d968589d8 | 594 | */ |
| Kojto | 90:cb3d968589d8 | 595 | |
| Kojto | 90:cb3d968589d8 | 596 | /** |
| Kojto | 90:cb3d968589d8 | 597 | * @} |
| Kojto | 90:cb3d968589d8 | 598 | */ |
| Kojto | 90:cb3d968589d8 | 599 | |
| Kojto | 90:cb3d968589d8 | 600 | /** |
| Kojto | 90:cb3d968589d8 | 601 | * @} |
| Kojto | 90:cb3d968589d8 | 602 | */ |
| Kojto | 90:cb3d968589d8 | 603 | |
| Kojto | 90:cb3d968589d8 | 604 | /** |
| Kojto | 90:cb3d968589d8 | 605 | * @} |
| Kojto | 90:cb3d968589d8 | 606 | */ |
| Kojto | 90:cb3d968589d8 | 607 | |
| Kojto | 90:cb3d968589d8 | 608 | #ifdef __cplusplus |
| Kojto | 90:cb3d968589d8 | 609 | } |
| Kojto | 90:cb3d968589d8 | 610 | #endif |
| Kojto | 90:cb3d968589d8 | 611 | |
| Kojto | 90:cb3d968589d8 | 612 | #endif /* __STM32L1xx_HAL_COMP_H */ |
| Kojto | 90:cb3d968589d8 | 613 | |
| Kojto | 90:cb3d968589d8 | 614 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |


