2 ******************************************************************************
3 * @file stm32f3xx_hal_comp.h
4 * @author MCD Application Team
7 * @brief Header file of COMP HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F3xx_HAL_COMP_H
40 #define __STM32F3xx_HAL_COMP_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f3xx_hal_def.h"
49 /** @addtogroup STM32F3xx_HAL_Driver
57 /* Exported types ------------------------------------------------------------*/
58 /** @defgroup COMP_Exported_Types COMP Exported Types
62 * @brief COMP Init structure definition
68 uint32_t InvertingInput; /*!< Selects the inverting input of the comparator.
69 This parameter can be a value of @ref COMPEx_InvertingInput */
71 uint32_t NonInvertingInput; /*!< Selects the non inverting input of the comparator.
72 This parameter can be a value of @ref COMPEx_NonInvertingInput
73 Note: Only available on STM32F302xB/xC, STM32F303xB/xC and STM32F358xx devices */
75 uint32_t Output; /*!< Selects the output redirection of the comparator.
76 This parameter can be a value of @ref COMPEx_Output */
78 uint32_t OutputPol; /*!< Selects the output polarity of the comparator.
79 This parameter can be a value of @ref COMP_OutputPolarity */
81 uint32_t Hysteresis; /*!< Selects the hysteresis voltage of the comparator.
82 This parameter can be a value of @ref COMPEx_Hysteresis
83 Note: Only available on STM32F302xB/xC, STM32F303xB/xC, STM32F373xB/xC, STM32F358xx and STM32F378xx devices */
85 uint32_t BlankingSrce; /*!< Selects the output blanking source of the comparator.
86 This parameter can be a value of @ref COMPEx_BlankingSrce
87 Note: Not available on STM32F373xB/C and STM32F378xx devices */
89 uint32_t Mode; /*!< Selects the operating comsumption mode of the comparator
90 to adjust the speed/consumption.
91 This parameter can be a value of @ref COMPEx_Mode
92 Note: Not available on STM32F301x6/x8, STM32F302x6/x8, STM32F334x6/x8, STM32F318xx and STM32F328xx devices */
94 uint32_t WindowMode; /*!< Selects the window mode of the comparator X (X=2, 4 or 6 if available).
95 This parameter can be a value of @ref COMPEx_WindowMode */
97 uint32_t TriggerMode; /*!< Selects the trigger mode of the comparator (interrupt mode).
98 This parameter can be a value of @ref COMP_TriggerMode */
103 * @brief HAL State structures definition
107 HAL_COMP_STATE_RESET = 0x00, /*!< COMP not yet initialized or disabled */
108 HAL_COMP_STATE_READY = 0x01, /*!< COMP initialized and ready for use */
109 HAL_COMP_STATE_READY_LOCKED = 0x11, /*!< COMP initialized but the configuration is locked */
110 HAL_COMP_STATE_BUSY = 0x02, /*!< COMP is running */
111 HAL_COMP_STATE_BUSY_LOCKED = 0x12 /*!< COMP is running and the configuration is locked */
112 }HAL_COMP_StateTypeDef;
116 * @brief PPP Handle Structure definition
120 COMP_TypeDef *Instance; /*!< Register base address */
121 COMP_InitTypeDef Init; /*!< COMP required parameters */
122 HAL_LockTypeDef Lock; /*!< Locking object */
123 __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
131 /* Exported constants --------------------------------------------------------*/
132 /** @defgroup COMP_Exported_Constants COMP Exported Constants
136 /** @defgroup COMP_OutputPolarity COMP Output Polarity
139 #define COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output on GPIO isn't inverted */
140 #define COMP_OUTPUTPOL_INVERTED COMP_CSR_COMPxPOL /*!< COMP output on GPIO is inverted */
141 #define IS_COMP_OUTPUTPOL(POL) (((POL) == COMP_OUTPUTPOL_NONINVERTED) || \
142 ((POL) == COMP_OUTPUTPOL_INVERTED))
147 /** @defgroup COMP_OutputLevel COMP Output Level
150 /* When output polarity is not inverted, comparator output is low when
151 the non-inverting input is at a lower voltage than the inverting input*/
152 #define COMP_OUTPUTLEVEL_LOW ((uint32_t)0x00000000)
153 /* When output polarity is not inverted, comparator output is high when
154 the non-inverting input is at a higher voltage than the inverting input */
155 #define COMP_OUTPUTLEVEL_HIGH COMP_CSR_COMPxOUT
160 /** @defgroup COMP_TriggerMode COMP Trigger Mode
163 #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< No External Interrupt trigger detection */
164 #define COMP_TRIGGERMODE_IT_RISING ((uint32_t)0x00000001) /*!< External Interrupt Mode with Rising edge trigger detection */
165 #define COMP_TRIGGERMODE_IT_FALLING ((uint32_t)0x00000002) /*!< External Interrupt Mode with Falling edge trigger detection */
166 #define COMP_TRIGGERMODE_IT_RISING_FALLING ((uint32_t)0x00000003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
167 #define IS_COMP_TRIGGERMODE(MODE) (((MODE) == COMP_TRIGGERMODE_NONE) || \
168 ((MODE) == COMP_TRIGGERMODE_IT_RISING) || \
169 ((MODE) == COMP_TRIGGERMODE_IT_FALLING) || \
170 ((MODE) == COMP_TRIGGERMODE_IT_RISING_FALLING))
175 #define COMP_LOCK_DISABLE ((uint32_t)0x00000000)
176 #define COMP_LOCK_ENABLE COMP_CSR_COMPxLOCK
178 #define COMP_STATE_BIT_LOCK ((uint32_t)0x10)
184 /* Exported macros -----------------------------------------------------------*/
185 /** @defgroup COMP_Exported_Macros COMP Exported Macros
189 /** @brief Reset COMP handle state
190 * @param __HANDLE__: COMP handle.
193 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
198 /* Include COMP HAL Extended module */
199 #include "stm32f3xx_hal_comp_ex.h"
201 /* Exported functions --------------------------------------------------------*/
202 /** @addtogroup COMP_Exported_Functions COMP Exported Functions
206 /** @addtogroup COMP_Exported_Functions_Group1 Initialization and de-initialization functions
207 * @brief Initialization and Configuration functions
210 /* Initialization and de-initialization functions ****************************/
211 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
212 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
213 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
214 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
219 /** @addtogroup COMP_Exported_Functions_Group2 Input and Output operation functions
220 * @brief Data transfers functions
223 /* IO operation functions *****************************************************/
224 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
225 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
226 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
227 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
228 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
233 /** @addtogroup COMP_Exported_Functions_Group3 Peripheral Control functions
234 * @brief management functions
237 /* Peripheral Control functions ***********************************************/
238 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
239 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
241 /* Callback in Interrupt mode */
242 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
247 /** @addtogroup COMP_Exported_Functions_Group4 Peripheral State functions
248 * @brief Peripheral State functions
251 /* Peripheral State and Error functions ***************************************/
252 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
273 #endif /* __STM32F3xx_HAL_COMP_H */
275 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/