stm32f3xx_hal_comp.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_hal_comp.h
  4. * @author MCD Application Team
  5. * @brief Header file of COMP HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  10. *
  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.
  21. *
  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.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F3xx_HAL_COMP_H
  37. #define __STM32F3xx_HAL_COMP_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f3xx_hal_def.h"
  43. /** @addtogroup STM32F3xx_HAL_Driver
  44. * @{
  45. */
  46. /** @addtogroup COMP
  47. * @{
  48. */
  49. /* Exported types ------------------------------------------------------------*/
  50. /** @defgroup COMP_Exported_Types COMP Exported Types
  51. * @{
  52. */
  53. /**
  54. * @brief COMP Init structure definition
  55. */
  56. typedef struct
  57. {
  58. uint32_t InvertingInput; /*!< Selects the inverting input of the comparator.
  59. This parameter can be a value of @ref COMPEx_InvertingInput */
  60. uint32_t NonInvertingInput; /*!< Selects the non inverting input of the comparator.
  61. This parameter can be a value of @ref COMPEx_NonInvertingInput
  62. Note: Only available on STM32F302xB/xC, STM32F303xB/xC and STM32F358xx devices */
  63. uint32_t Output; /*!< Selects the output redirection of the comparator.
  64. This parameter can be a value of @ref COMPEx_Output */
  65. uint32_t OutputPol; /*!< Selects the output polarity of the comparator.
  66. This parameter can be a value of @ref COMP_OutputPolarity */
  67. uint32_t Hysteresis; /*!< Selects the hysteresis voltage of the comparator.
  68. This parameter can be a value of @ref COMPEx_Hysteresis
  69. Note: Only available on STM32F302xB/xC, STM32F303xB/xC, STM32F373xB/xC, STM32F358xx and STM32F378xx devices */
  70. uint32_t BlankingSrce; /*!< Selects the output blanking source of the comparator.
  71. This parameter can be a value of @ref COMPEx_BlankingSrce
  72. Note: Not available on STM32F373xB/C and STM32F378xx devices */
  73. uint32_t Mode; /*!< Selects the operating consumption mode of the comparator
  74. to adjust the speed/consumption.
  75. This parameter can be a value of @ref COMPEx_Mode
  76. Note: Not available on STM32F301x6/x8, STM32F302x6/x8, STM32F334x6/x8, STM32F318xx and STM32F328xx devices */
  77. uint32_t WindowMode; /*!< Selects the window mode of the comparator X (X=2U, 4 or 6 if available).
  78. This parameter can be a value of @ref COMPEx_WindowMode */
  79. uint32_t TriggerMode; /*!< Selects the trigger mode of the comparator (interrupt mode).
  80. This parameter can be a value of @ref COMP_TriggerMode */
  81. }COMP_InitTypeDef;
  82. /**
  83. * @brief HAL State structures definition
  84. */
  85. typedef enum
  86. {
  87. HAL_COMP_STATE_RESET = 0x00U, /*!< COMP not yet initialized or disabled */
  88. HAL_COMP_STATE_READY = 0x01U, /*!< COMP initialized and ready for use */
  89. HAL_COMP_STATE_READY_LOCKED = 0x11U, /*!< COMP initialized but the configuration is locked */
  90. HAL_COMP_STATE_BUSY = 0x02U, /*!< COMP is running */
  91. HAL_COMP_STATE_BUSY_LOCKED = 0x12 /*!< COMP is running and the configuration is locked */
  92. }HAL_COMP_StateTypeDef;
  93. /**
  94. * @brief COMP Handle Structure definition
  95. */
  96. typedef struct
  97. {
  98. COMP_TypeDef *Instance; /*!< Register base address */
  99. COMP_InitTypeDef Init; /*!< COMP required parameters */
  100. HAL_LockTypeDef Lock; /*!< Locking object */
  101. __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
  102. }COMP_HandleTypeDef;
  103. /**
  104. * @}
  105. */
  106. /* Exported constants --------------------------------------------------------*/
  107. /** @defgroup COMP_Exported_Constants COMP Exported Constants
  108. * @{
  109. */
  110. /** @defgroup COMP_OutputPolarity COMP Output Polarity
  111. * @{
  112. */
  113. #define COMP_OUTPUTPOL_NONINVERTED (0x00000000U) /*!< COMP output on GPIO isn't inverted */
  114. #define COMP_OUTPUTPOL_INVERTED COMP_CSR_COMPxPOL /*!< COMP output on GPIO is inverted */
  115. /**
  116. * @}
  117. */
  118. /** @defgroup COMP_OutputLevel COMP Output Level
  119. * @{
  120. */
  121. /* When output polarity is not inverted, comparator output is low when
  122. the non-inverting input is at a lower voltage than the inverting input*/
  123. #define COMP_OUTPUTLEVEL_LOW (0x00000000U)
  124. /* When output polarity is not inverted, comparator output is high when
  125. the non-inverting input is at a higher voltage than the inverting input */
  126. #define COMP_OUTPUTLEVEL_HIGH COMP_CSR_COMPxOUT
  127. /**
  128. * @}
  129. */
  130. /** @defgroup COMP_TriggerMode COMP Trigger Mode
  131. * @{
  132. */
  133. #define COMP_TRIGGERMODE_NONE (0x00000000U) /*!< No External Interrupt trigger detection */
  134. #define COMP_TRIGGERMODE_IT_RISING (0x00000001U) /*!< External Interrupt Mode with Rising edge trigger detection */
  135. #define COMP_TRIGGERMODE_IT_FALLING (0x00000002U) /*!< External Interrupt Mode with Falling edge trigger detection */
  136. #define COMP_TRIGGERMODE_IT_RISING_FALLING (0x00000003U) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
  137. #define COMP_TRIGGERMODE_EVENT_RISING (0x00000010U) /*!< Event Mode with Rising edge trigger detection */
  138. #define COMP_TRIGGERMODE_EVENT_FALLING (0x00000020U) /*!< Event Mode with Falling edge trigger detection */
  139. #define COMP_TRIGGERMODE_EVENT_RISING_FALLING (0x00000030U) /*!< Event Mode with Rising/Falling edge trigger detection */
  140. /**
  141. * @}
  142. */
  143. /** @defgroup COMP_State_Lock COMP State Lock
  144. * @{
  145. */
  146. #define COMP_STATE_BIT_LOCK (0x00000010U) /* Lock bit in COMP handle state */
  147. /**
  148. * @}
  149. */
  150. /**
  151. * @}
  152. */
  153. /* Exported macros -----------------------------------------------------------*/
  154. /** @defgroup COMP_Exported_Macros COMP Exported Macros
  155. * @{
  156. */
  157. /** @brief Reset COMP handle state.
  158. * @param __HANDLE__ COMP handle.
  159. * @retval None
  160. */
  161. #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
  162. /**
  163. * @}
  164. */
  165. /* Include COMP HAL Extended module */
  166. #include "stm32f3xx_hal_comp_ex.h"
  167. /* Exported functions --------------------------------------------------------*/
  168. /** @addtogroup COMP_Exported_Functions
  169. * @{
  170. */
  171. /** @addtogroup COMP_Exported_Functions_Group1
  172. * @{
  173. */
  174. /* Initialization and de-initialization functions ****************************/
  175. HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
  176. HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
  177. void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
  178. void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
  179. /**
  180. * @}
  181. */
  182. /* IO operation functions *****************************************************/
  183. /** @addtogroup COMP_Exported_Functions_Group2
  184. * @{
  185. */
  186. HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
  187. HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
  188. HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
  189. HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
  190. void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
  191. /* Callback in Interrupt mode */
  192. void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
  193. /**
  194. * @}
  195. */
  196. /* Peripheral Control functions ************************************************/
  197. /** @addtogroup COMP_Exported_Functions_Group3
  198. * @{
  199. */
  200. HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
  201. uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
  202. /**
  203. * @}
  204. */
  205. /* Peripheral State functions **************************************************/
  206. /** @addtogroup COMP_Exported_Functions_Group4
  207. * @{
  208. */
  209. HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
  210. /**
  211. * @}
  212. */
  213. /**
  214. * @}
  215. */
  216. /* Private macros ------------------------------------------------------------*/
  217. /** @defgroup COMP_Private_Macros COMP Private Macros
  218. * @{
  219. */
  220. /** @defgroup COMP_IS_COMP_Definitions COMP Private macros to check input parameters
  221. * @{
  222. */
  223. #define IS_COMP_OUTPUTPOL(__POL__) (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
  224. ((__POL__) == COMP_OUTPUTPOL_INVERTED))
  225. #define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \
  226. ((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \
  227. ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \
  228. ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \
  229. ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \
  230. ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \
  231. ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
  232. /**
  233. * @}
  234. */
  235. /**
  236. * @}
  237. */
  238. /**
  239. * @}
  240. */
  241. /**
  242. * @}
  243. */
  244. #ifdef __cplusplus
  245. }
  246. #endif
  247. #endif /* __STM32F3xx_HAL_COMP_H */
  248. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/