Updated and Validated
[betaflight.git] / lib / main / STM32F3 / Drivers / STM32F3xx_HAL_Driver / Inc / stm32f3xx_hal_comp.h
blob0510e0f047b1d7c0c7cb7959487d3e34c78f2e6d
1 /**
2 ******************************************************************************
3 * @file stm32f3xx_hal_comp.h
4 * @author MCD Application Team
5 * @brief Header file of COMP HAL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ******************************************************************************
36 /* Define to prevent recursive inclusion -------------------------------------*/
37 #ifndef __STM32F3xx_HAL_COMP_H
38 #define __STM32F3xx_HAL_COMP_H
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
44 /* Includes ------------------------------------------------------------------*/
45 #include "stm32f3xx_hal_def.h"
47 /** @addtogroup STM32F3xx_HAL_Driver
48 * @{
51 /** @addtogroup COMP
52 * @{
55 /* Exported types ------------------------------------------------------------*/
56 /** @defgroup COMP_Exported_Types COMP Exported Types
57 * @{
59 /**
60 * @brief COMP Init structure definition
62 typedef struct
65 uint32_t InvertingInput; /*!< Selects the inverting input of the comparator.
66 This parameter can be a value of @ref COMPEx_InvertingInput */
68 uint32_t NonInvertingInput; /*!< Selects the non inverting input of the comparator.
69 This parameter can be a value of @ref COMPEx_NonInvertingInput
70 Note: Only available on STM32F302xB/xC, STM32F303xB/xC and STM32F358xx devices */
72 uint32_t Output; /*!< Selects the output redirection of the comparator.
73 This parameter can be a value of @ref COMPEx_Output */
75 uint32_t OutputPol; /*!< Selects the output polarity of the comparator.
76 This parameter can be a value of @ref COMP_OutputPolarity */
78 uint32_t Hysteresis; /*!< Selects the hysteresis voltage of the comparator.
79 This parameter can be a value of @ref COMPEx_Hysteresis
80 Note: Only available on STM32F302xB/xC, STM32F303xB/xC, STM32F373xB/xC, STM32F358xx and STM32F378xx devices */
82 uint32_t BlankingSrce; /*!< Selects the output blanking source of the comparator.
83 This parameter can be a value of @ref COMPEx_BlankingSrce
84 Note: Not available on STM32F373xB/C and STM32F378xx devices */
86 uint32_t Mode; /*!< Selects the operating consumption mode of the comparator
87 to adjust the speed/consumption.
88 This parameter can be a value of @ref COMPEx_Mode
89 Note: Not available on STM32F301x6/x8, STM32F302x6/x8, STM32F334x6/x8, STM32F318xx and STM32F328xx devices */
91 uint32_t WindowMode; /*!< Selects the window mode of the comparator X (X=2U, 4 or 6 if available).
92 This parameter can be a value of @ref COMPEx_WindowMode */
94 uint32_t TriggerMode; /*!< Selects the trigger mode of the comparator (interrupt mode).
95 This parameter can be a value of @ref COMP_TriggerMode */
97 }COMP_InitTypeDef;
99 /**
100 * @brief HAL State structures definition
102 typedef enum
104 HAL_COMP_STATE_RESET = 0x00U, /*!< COMP not yet initialized or disabled */
105 HAL_COMP_STATE_READY = 0x01U, /*!< COMP initialized and ready for use */
106 HAL_COMP_STATE_READY_LOCKED = 0x11U, /*!< COMP initialized but the configuration is locked */
107 HAL_COMP_STATE_BUSY = 0x02U, /*!< COMP is running */
108 HAL_COMP_STATE_BUSY_LOCKED = 0x12 /*!< COMP is running and the configuration is locked */
109 }HAL_COMP_StateTypeDef;
111 /**
112 * @brief COMP Handle Structure definition
114 typedef struct
116 COMP_TypeDef *Instance; /*!< Register base address */
117 COMP_InitTypeDef Init; /*!< COMP required parameters */
118 HAL_LockTypeDef Lock; /*!< Locking object */
119 __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
120 }COMP_HandleTypeDef;
123 * @}
126 /* Exported constants --------------------------------------------------------*/
127 /** @defgroup COMP_Exported_Constants COMP Exported Constants
128 * @{
131 /** @defgroup COMP_OutputPolarity COMP Output Polarity
132 * @{
134 #define COMP_OUTPUTPOL_NONINVERTED (0x00000000U) /*!< COMP output on GPIO isn't inverted */
135 #define COMP_OUTPUTPOL_INVERTED COMP_CSR_COMPxPOL /*!< COMP output on GPIO is inverted */
137 * @}
140 /** @defgroup COMP_OutputLevel COMP Output Level
141 * @{
143 /* When output polarity is not inverted, comparator output is low when
144 the non-inverting input is at a lower voltage than the inverting input*/
145 #define COMP_OUTPUTLEVEL_LOW (0x00000000U)
146 /* When output polarity is not inverted, comparator output is high when
147 the non-inverting input is at a higher voltage than the inverting input */
148 #define COMP_OUTPUTLEVEL_HIGH COMP_CSR_COMPxOUT
150 * @}
153 /** @defgroup COMP_TriggerMode COMP Trigger Mode
154 * @{
156 #define COMP_TRIGGERMODE_NONE (0x00000000U) /*!< No External Interrupt trigger detection */
157 #define COMP_TRIGGERMODE_IT_RISING (0x00000001U) /*!< External Interrupt Mode with Rising edge trigger detection */
158 #define COMP_TRIGGERMODE_IT_FALLING (0x00000002U) /*!< External Interrupt Mode with Falling edge trigger detection */
159 #define COMP_TRIGGERMODE_IT_RISING_FALLING (0x00000003U) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
160 #define COMP_TRIGGERMODE_EVENT_RISING (0x00000010U) /*!< Event Mode with Rising edge trigger detection */
161 #define COMP_TRIGGERMODE_EVENT_FALLING (0x00000020U) /*!< Event Mode with Falling edge trigger detection */
162 #define COMP_TRIGGERMODE_EVENT_RISING_FALLING (0x00000030U) /*!< Event Mode with Rising/Falling edge trigger detection */
164 * @}
167 /** @defgroup COMP_State_Lock COMP State Lock
168 * @{
170 #define COMP_STATE_BIT_LOCK (0x00000010U) /* Lock bit in COMP handle state */
172 * @}
176 * @}
179 /* Exported macros -----------------------------------------------------------*/
180 /** @defgroup COMP_Exported_Macros COMP Exported Macros
181 * @{
184 /** @brief Reset COMP handle state.
185 * @param __HANDLE__ COMP handle.
186 * @retval None
188 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
190 * @}
193 /* Include COMP HAL Extended module */
194 #include "stm32f3xx_hal_comp_ex.h"
196 /* Exported functions --------------------------------------------------------*/
197 /** @addtogroup COMP_Exported_Functions
198 * @{
200 /** @addtogroup COMP_Exported_Functions_Group1
201 * @{
203 /* Initialization and de-initialization functions ****************************/
204 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
205 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
206 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
207 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
209 * @}
212 /* IO operation functions *****************************************************/
213 /** @addtogroup COMP_Exported_Functions_Group2
214 * @{
216 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
217 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
218 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
219 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
220 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
221 /* Callback in Interrupt mode */
222 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
224 * @}
227 /* Peripheral Control functions ************************************************/
228 /** @addtogroup COMP_Exported_Functions_Group3
229 * @{
231 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
232 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
234 * @}
237 /* Peripheral State functions **************************************************/
238 /** @addtogroup COMP_Exported_Functions_Group4
239 * @{
241 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
243 * @}
247 * @}
250 /* Private macros ------------------------------------------------------------*/
251 /** @defgroup COMP_Private_Macros COMP Private Macros
252 * @{
255 /** @defgroup COMP_IS_COMP_Definitions COMP Private macros to check input parameters
256 * @{
259 #define IS_COMP_OUTPUTPOL(__POL__) (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
260 ((__POL__) == COMP_OUTPUTPOL_INVERTED))
262 #define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \
263 ((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \
264 ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \
265 ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \
266 ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \
267 ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \
268 ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
271 * @}
275 * @}
279 * @}
283 * @}
286 #ifdef __cplusplus
288 #endif
290 #endif /* __STM32F3xx_HAL_COMP_H */
292 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/