stm32l4xx_ll_comp.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_ll_comp.h
  4. * @author MCD Application Team
  5. * @brief Header file of COMP LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 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 __STM32L4xx_LL_COMP_H
  37. #define __STM32L4xx_LL_COMP_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32l4xx.h"
  43. /** @addtogroup STM32L4xx_LL_Driver
  44. * @{
  45. */
  46. #if defined (COMP1) || defined (COMP2)
  47. /** @defgroup COMP_LL COMP
  48. * @{
  49. */
  50. /* Private types -------------------------------------------------------------*/
  51. /* Private variables ---------------------------------------------------------*/
  52. /* Private constants ---------------------------------------------------------*/
  53. /** @defgroup COMP_LL_Private_Constants COMP Private Constants
  54. * @{
  55. */
  56. /* COMP registers bits positions */
  57. #define LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS (30U) /* Value equivalent to POSITION_VAL(COMP_CSR_VALUE) */
  58. /**
  59. * @}
  60. */
  61. /* Private macros ------------------------------------------------------------*/
  62. /* Exported types ------------------------------------------------------------*/
  63. #if defined(USE_FULL_LL_DRIVER)
  64. /** @defgroup COMP_LL_ES_INIT COMP Exported Init structure
  65. * @{
  66. */
  67. /**
  68. * @brief Structure definition of some features of COMP instance.
  69. */
  70. typedef struct
  71. {
  72. uint32_t PowerMode; /*!< Set comparator operating mode to adjust power and speed.
  73. This parameter can be a value of @ref COMP_LL_EC_POWERMODE
  74. This feature can be modified afterwards using unitary function @ref LL_COMP_SetPowerMode(). */
  75. uint32_t InputPlus; /*!< Set comparator input plus (non-inverting input).
  76. This parameter can be a value of @ref COMP_LL_EC_INPUT_PLUS
  77. This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputPlus(). */
  78. uint32_t InputMinus; /*!< Set comparator input minus (inverting input).
  79. This parameter can be a value of @ref COMP_LL_EC_INPUT_MINUS
  80. This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputMinus(). */
  81. uint32_t InputHysteresis; /*!< Set comparator hysteresis mode of the input minus.
  82. This parameter can be a value of @ref COMP_LL_EC_INPUT_HYSTERESIS
  83. This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputHysteresis(). */
  84. uint32_t OutputPolarity; /*!< Set comparator output polarity.
  85. This parameter can be a value of @ref COMP_LL_EC_OUTPUT_POLARITY
  86. This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputPolarity(). */
  87. uint32_t OutputBlankingSource; /*!< Set comparator blanking source.
  88. This parameter can be a value of @ref COMP_LL_EC_OUTPUT_BLANKING_SOURCE
  89. This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputBlankingSource(). */
  90. } LL_COMP_InitTypeDef;
  91. /**
  92. * @}
  93. */
  94. #endif /* USE_FULL_LL_DRIVER */
  95. /* Exported constants --------------------------------------------------------*/
  96. /** @defgroup COMP_LL_Exported_Constants COMP Exported Constants
  97. * @{
  98. */
  99. /** @defgroup COMP_LL_EC_COMMON_WINDOWMODE Comparator common modes - Window mode
  100. * @{
  101. */
  102. #define LL_COMP_WINDOWMODE_DISABLE (0x00000000U) /*!< Window mode disable: Comparators 1 and 2 are independent */
  103. #define LL_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). */
  104. /**
  105. * @}
  106. */
  107. /** @defgroup COMP_LL_EC_POWERMODE Comparator modes - Power mode
  108. * @{
  109. */
  110. #define LL_COMP_POWERMODE_HIGHSPEED (0x00000000U) /*!< COMP power mode to high speed */
  111. #define LL_COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_PWRMODE_0) /*!< COMP power mode to medium speed */
  112. #define LL_COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_PWRMODE_1 | COMP_CSR_PWRMODE_0) /*!< COMP power mode to ultra-low power */
  113. /**
  114. * @}
  115. */
  116. /** @defgroup COMP_LL_EC_INPUT_PLUS Comparator inputs - Input plus (input non-inverting) selection
  117. * @{
  118. */
  119. #define LL_COMP_INPUT_PLUS_IO1 (0x00000000U) /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1, pin PB4 for COMP2) */
  120. #define LL_COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2) */
  121. #if defined(COMP_CSR_INPSEL_1)
  122. #define LL_COMP_INPUT_PLUS_IO3 (COMP_CSR_INPSEL_1) /*!< Comparator input plus connected to IO3 (pin PA1 for COMP1, pin PA3 for COMP2) */
  123. #endif
  124. /**
  125. * @}
  126. */
  127. /** @defgroup COMP_LL_EC_INPUT_MINUS Comparator inputs - Input minus (input inverting) selection
  128. * @{
  129. */
  130. #define LL_COMP_INPUT_MINUS_1_4VREFINT ( COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/4 VrefInt */
  131. #define LL_COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/2 VrefInt */
  132. #define LL_COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */
  133. #define LL_COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) /*!< Comparator input minus connected to VrefInt */
  134. #define LL_COMP_INPUT_MINUS_DAC1_CH1 (COMP_CSR_INMSEL_2 ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */
  135. #define LL_COMP_INPUT_MINUS_DAC1_CH2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */
  136. #define LL_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) */
  137. #define LL_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) */
  138. #if defined(COMP_CSR_INMESEL_1)
  139. #define LL_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) */
  140. #define LL_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) */
  141. #define LL_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) */
  142. #endif
  143. /**
  144. * @}
  145. */
  146. /** @defgroup COMP_LL_EC_INPUT_LEGACY Comparator inputs legacy literals name
  147. * @{
  148. */
  149. #define LL_COMP_WINDOWMODE_ENABLE LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
  150. #define LL_COMP_INVERTINGINPUT_1_4VREFINT LL_COMP_INPUT_MINUS_1_4VREFINT
  151. #define LL_COMP_INVERTINGINPUT_1_2VREFINT LL_COMP_INPUT_MINUS_1_2VREFINT
  152. #define LL_COMP_INVERTINGINPUT_3_4VREFINT LL_COMP_INPUT_MINUS_3_4VREFINT
  153. #define LL_COMP_INVERTINGINPUT_VREFINT LL_COMP_INPUT_MINUS_VREFINT
  154. #define LL_COMP_INVERTINGINPUT_DAC1 LL_COMP_INPUT_MINUS_DAC1_CH1
  155. #define LL_COMP_INVERTINGINPUT_DAC2 LL_COMP_INPUT_MINUS_DAC1_CH2
  156. #define LL_COMP_INVERTINGINPUT_IO1 LL_COMP_INPUT_MINUS_IO1
  157. #define LL_COMP_INVERTINGINPUT_IO2 LL_COMP_INPUT_MINUS_IO2
  158. #if defined(COMP_CSR_INMESEL_1)
  159. #define LL_COMP_INVERTINGINPUT_IO3 LL_COMP_INPUT_MINUS_IO3
  160. #define LL_COMP_INVERTINGINPUT_IO4 LL_COMP_INPUT_MINUS_IO4
  161. #define LL_COMP_INVERTINGINPUT_IO5 LL_COMP_INPUT_MINUS_IO5
  162. #endif
  163. #define LL_COMP_NONINVERTINGINPUT_IO1 LL_COMP_INPUT_PLUS_IO1
  164. #define LL_COMP_NONINVERTINGINPUT_IO2 LL_COMP_INPUT_PLUS_IO2
  165. #if defined(COMP_CSR_INPSEL_1)
  166. #define LL_COMP_NONINVERTINGINPUT_IO3 LL_COMP_INPUT_PLUS_IO3
  167. #endif
  168. /**
  169. * @}
  170. */
  171. /** @defgroup COMP_LL_EC_INPUT_HYSTERESIS Comparator input - Hysteresis
  172. * @{
  173. */
  174. #define LL_COMP_HYSTERESIS_NONE (0x00000000U) /*!< No hysteresis */
  175. #define LL_COMP_HYSTERESIS_LOW ( COMP_CSR_HYST_0) /*!< Hysteresis level low */
  176. #define LL_COMP_HYSTERESIS_MEDIUM (COMP_CSR_HYST_1 ) /*!< Hysteresis level medium */
  177. #define LL_COMP_HYSTERESIS_HIGH (COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level high */
  178. /**
  179. * @}
  180. */
  181. /** @defgroup COMP_LL_EC_OUTPUT_POLARITY Comparator output - Output polarity
  182. * @{
  183. */
  184. #define LL_COMP_OUTPUTPOL_NONINVERTED (0x00000000U) /*!< COMP output polarity is not inverted: comparator output is high when the plus (non-inverting) input is at a higher voltage than the minus (inverting) input */
  185. #define LL_COMP_OUTPUTPOL_INVERTED (COMP_CSR_POLARITY) /*!< COMP output polarity is inverted: comparator output is low when the plus (non-inverting) input is at a lower voltage than the minus (inverting) input */
  186. /**
  187. * @}
  188. */
  189. /** @defgroup COMP_LL_EC_OUTPUT_BLANKING_SOURCE Comparator output - Blanking source
  190. * @{
  191. */
  192. #define LL_COMP_BLANKINGSRC_NONE (0x00000000U) /*!<Comparator output without blanking */
  193. #define LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1 (COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP1) */
  194. #define LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1 (COMP_CSR_BLANKING_1) /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP1) */
  195. #define LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1 (COMP_CSR_BLANKING_2) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP1) */
  196. #define LL_COMP_BLANKINGSRC_TIM3_OC4_COMP2 (COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM3 OC4 (specific to COMP instance: COMP2) */
  197. #define LL_COMP_BLANKINGSRC_TIM8_OC5_COMP2 (COMP_CSR_BLANKING_1) /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP2) */
  198. #define LL_COMP_BLANKINGSRC_TIM15_OC1_COMP2 (COMP_CSR_BLANKING_2) /*!< Comparator output blanking source TIM15 OC1 (specific to COMP instance: COMP2) */
  199. /**
  200. * @}
  201. */
  202. /** @defgroup COMP_LL_EC_OUTPUT_BLANKING_SOURCE_LEGACY Comparator output blanking source legacy literals name
  203. * @{
  204. */
  205. #define LL_COMP_BLANKINGSRC_TIM1_OC5 (LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1)
  206. #define LL_COMP_BLANKINGSRC_TIM2_OC3 (LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1)
  207. #define LL_COMP_BLANKINGSRC_TIM3_OC3 (LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1)
  208. #define LL_COMP_BLANKINGSRC_TIM3_OC4 (LL_COMP_BLANKINGSRC_TIM3_OC4_COMP2)
  209. #define LL_COMP_BLANKINGSRC_TIM8_OC5 (LL_COMP_BLANKINGSRC_TIM8_OC5_COMP2)
  210. #define LL_COMP_BLANKINGSRC_TIM15_OC1 (LL_COMP_BLANKINGSRC_TIM15_OC1_COMP2)
  211. /**
  212. * @}
  213. */
  214. /** @defgroup COMP_LL_EC_OUTPUT_LEVEL Comparator output - Output level
  215. * @{
  216. */
  217. #define LL_COMP_OUTPUT_LEVEL_LOW (0x00000000U) /*!< Comparator output level low (if the polarity is not inverted, otherwise to be complemented) */
  218. #define LL_COMP_OUTPUT_LEVEL_HIGH (0x00000001U) /*!< Comparator output level high (if the polarity is not inverted, otherwise to be complemented) */
  219. /**
  220. * @}
  221. */
  222. /** @defgroup COMP_LL_EC_HW_DELAYS Definitions of COMP hardware constraints delays
  223. * @note Only COMP IP HW delays are defined in COMP LL driver driver,
  224. * not timeout values.
  225. * For details on delays values, refer to descriptions in source code
  226. * above each literal definition.
  227. * @{
  228. */
  229. /* Delay for comparator startup time. */
  230. /* Note: Delay required to reach propagation delay specification. */
  231. /* Literal set to maximum value (refer to device datasheet, */
  232. /* parameter "tSTART"). */
  233. /* Unit: us */
  234. #define LL_COMP_DELAY_STARTUP_US ( 80U) /*!< Delay for COMP startup time */
  235. /* Delay for comparator voltage scaler stabilization time. */
  236. /* Note: Voltage scaler is used when selecting comparator input */
  237. /* based on VrefInt: VrefInt or subdivision of VrefInt. */
  238. /* Literal set to maximum value (refer to device datasheet, */
  239. /* parameter "tSTART_SCALER"). */
  240. /* Unit: us */
  241. #define LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US ( 200U) /*!< Delay for COMP voltage scaler stabilization time */
  242. /**
  243. * @}
  244. */
  245. /**
  246. * @}
  247. */
  248. /* Exported macro ------------------------------------------------------------*/
  249. /** @defgroup COMP_LL_Exported_Macros COMP Exported Macros
  250. * @{
  251. */
  252. /** @defgroup COMP_LL_EM_WRITE_READ Common write and read registers macro
  253. * @{
  254. */
  255. /**
  256. * @brief Write a value in COMP register
  257. * @param __INSTANCE__ comparator instance
  258. * @param __REG__ Register to be written
  259. * @param __VALUE__ Value to be written in the register
  260. * @retval None
  261. */
  262. #define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  263. /**
  264. * @brief Read a value in COMP register
  265. * @param __INSTANCE__ comparator instance
  266. * @param __REG__ Register to be read
  267. * @retval Register value
  268. */
  269. #define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  270. /**
  271. * @}
  272. */
  273. /** @defgroup COMP_LL_EM_HELPER_MACRO COMP helper macro
  274. * @{
  275. */
  276. /**
  277. * @brief Helper macro to select the COMP common instance
  278. * to which is belonging the selected COMP instance.
  279. * @note COMP common register instance can be used to
  280. * set parameters common to several COMP instances.
  281. * Refer to functions having argument "COMPxy_COMMON" as parameter.
  282. * @param __COMPx__ COMP instance
  283. * @retval COMP common instance or value "0" if there is no COMP common instance.
  284. */
  285. #define __LL_COMP_COMMON_INSTANCE(__COMPx__) \
  286. (COMP12_COMMON)
  287. /**
  288. * @}
  289. */
  290. /**
  291. * @}
  292. */
  293. /* Exported functions --------------------------------------------------------*/
  294. /** @defgroup COMP_LL_Exported_Functions COMP Exported Functions
  295. * @{
  296. */
  297. /** @defgroup COMP_LL_EF_Configuration_comparator_common Configuration of COMP hierarchical scope: common to several COMP instances
  298. * @{
  299. */
  300. /**
  301. * @brief Set window mode of a pair of comparators instances
  302. * (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
  303. * @rmtoll CSR WINMODE LL_COMP_SetCommonWindowMode
  304. * @param COMPxy_COMMON Comparator common instance
  305. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
  306. * @param WindowMode This parameter can be one of the following values:
  307. * @arg @ref LL_COMP_WINDOWMODE_DISABLE
  308. * @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
  309. * @retval None
  310. */
  311. __STATIC_INLINE void LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowMode)
  312. {
  313. /* Note: On this STM32 serie, window mode can be set only */
  314. /* from COMP instance: COMP2. */
  315. MODIFY_REG(COMPxy_COMMON->CSR, COMP_CSR_WINMODE, WindowMode);
  316. }
  317. /**
  318. * @brief Get window mode of a pair of comparators instances
  319. * (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
  320. * @rmtoll CSR WINMODE LL_COMP_GetCommonWindowMode
  321. * @param COMPxy_COMMON Comparator common instance
  322. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
  323. * @retval Returned value can be one of the following values:
  324. * @arg @ref LL_COMP_WINDOWMODE_DISABLE
  325. * @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
  326. */
  327. __STATIC_INLINE uint32_t LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON)
  328. {
  329. return (uint32_t)(READ_BIT(COMPxy_COMMON->CSR, COMP_CSR_WINMODE));
  330. }
  331. /**
  332. * @}
  333. */
  334. /** @defgroup COMP_LL_EF_Configuration_comparator_modes Configuration of comparator modes
  335. * @{
  336. */
  337. /**
  338. * @brief Set comparator instance operating mode to adjust power and speed.
  339. * @rmtoll CSR PWRMODE LL_COMP_SetPowerMode
  340. * @param COMPx Comparator instance
  341. * @param PowerMode This parameter can be one of the following values:
  342. * @arg @ref LL_COMP_POWERMODE_HIGHSPEED
  343. * @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED
  344. * @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER
  345. * @retval None
  346. */
  347. __STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode)
  348. {
  349. MODIFY_REG(COMPx->CSR, COMP_CSR_PWRMODE, PowerMode);
  350. }
  351. /**
  352. * @brief Get comparator instance operating mode to adjust power and speed.
  353. * @rmtoll CSR PWRMODE LL_COMP_GetPowerMode
  354. * @param COMPx Comparator instance
  355. * @retval Returned value can be one of the following values:
  356. * @arg @ref LL_COMP_POWERMODE_HIGHSPEED
  357. * @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED
  358. * @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER
  359. */
  360. __STATIC_INLINE uint32_t LL_COMP_GetPowerMode(COMP_TypeDef *COMPx)
  361. {
  362. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_PWRMODE));
  363. }
  364. /**
  365. * @}
  366. */
  367. /** @defgroup COMP_LL_EF_Configuration_comparator_inputs Configuration of comparator inputs
  368. * @{
  369. */
  370. /**
  371. * @brief Set comparator inputs minus (inverting) and plus (non-inverting).
  372. * @note In case of comparator input selected to be connected to IO:
  373. * GPIO pins are specific to each comparator instance.
  374. * Refer to description of parameters or to reference manual.
  375. * @note On this STM32 serie, scaler bridge is configurable:
  376. * to optimize power consumption, this function enables the
  377. * voltage scaler bridge only when required
  378. * (when selecting comparator input based on VrefInt: VrefInt or
  379. * subdivision of VrefInt).
  380. * - For scaler bridge power consumption values,
  381. * refer to device datasheet, parameter "IDDA(SCALER)".
  382. * - Voltage scaler requires a delay for voltage stabilization.
  383. * Refer to device datasheet, parameter "tSTART_SCALER".
  384. * - Scaler bridge is common for all comparator instances,
  385. * therefore if at least one of the comparator instance
  386. * is requiring the scaler bridge, it remains enabled.
  387. * @rmtoll CSR INMSEL LL_COMP_ConfigInputs\n
  388. * CSR INPSEL LL_COMP_ConfigInputs\n
  389. * CSR BRGEN LL_COMP_ConfigInputs\n
  390. * CSR SCALEN LL_COMP_ConfigInputs
  391. * @param COMPx Comparator instance
  392. * @param InputMinus This parameter can be one of the following values:
  393. * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
  394. * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
  395. * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
  396. * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
  397. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
  398. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2 (*)
  399. * @arg @ref LL_COMP_INPUT_MINUS_IO1
  400. * @arg @ref LL_COMP_INPUT_MINUS_IO2
  401. * @arg @ref LL_COMP_INPUT_MINUS_IO3 (*)
  402. * @arg @ref LL_COMP_INPUT_MINUS_IO4 (*)
  403. * @arg @ref LL_COMP_INPUT_MINUS_IO5 (*)
  404. *
  405. * (*) Parameter not available on all devices.
  406. * @param InputPlus This parameter can be one of the following values:
  407. * @arg @ref LL_COMP_INPUT_PLUS_IO1
  408. * @arg @ref LL_COMP_INPUT_PLUS_IO2
  409. * @arg @ref LL_COMP_INPUT_PLUS_IO3 (*)
  410. *
  411. * (*) Parameter not available on all devices.
  412. * @retval None
  413. */
  414. __STATIC_INLINE void LL_COMP_ConfigInputs(COMP_TypeDef *COMPx, uint32_t InputMinus, uint32_t InputPlus)
  415. {
  416. #if defined(COMP_CSR_INMESEL_1)
  417. MODIFY_REG(COMPx->CSR,
  418. COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_INPSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN,
  419. InputMinus | InputPlus);
  420. #else
  421. MODIFY_REG(COMPx->CSR,
  422. COMP_CSR_INMSEL | COMP_CSR_INPSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN,
  423. InputMinus | InputPlus);
  424. #endif
  425. }
  426. /**
  427. * @brief Set comparator input plus (non-inverting).
  428. * @note In case of comparator input selected to be connected to IO:
  429. * GPIO pins are specific to each comparator instance.
  430. * Refer to description of parameters or to reference manual.
  431. * @rmtoll CSR INPSEL LL_COMP_SetInputPlus
  432. * @param COMPx Comparator instance
  433. * @param InputPlus This parameter can be one of the following values:
  434. * @arg @ref LL_COMP_INPUT_PLUS_IO1
  435. * @arg @ref LL_COMP_INPUT_PLUS_IO2
  436. * @arg @ref LL_COMP_INPUT_PLUS_IO3 (*)
  437. *
  438. * (*) Parameter not available on all devices.
  439. * @retval None
  440. */
  441. __STATIC_INLINE void LL_COMP_SetInputPlus(COMP_TypeDef *COMPx, uint32_t InputPlus)
  442. {
  443. MODIFY_REG(COMPx->CSR, COMP_CSR_INPSEL, InputPlus);
  444. }
  445. /**
  446. * @brief Get comparator input plus (non-inverting).
  447. * @note In case of comparator input selected to be connected to IO:
  448. * GPIO pins are specific to each comparator instance.
  449. * Refer to description of parameters or to reference manual.
  450. * @rmtoll CSR INPSEL LL_COMP_GetInputPlus
  451. * @param COMPx Comparator instance
  452. * @retval Returned value can be one of the following values:
  453. * @arg @ref LL_COMP_INPUT_PLUS_IO1
  454. * @arg @ref LL_COMP_INPUT_PLUS_IO2
  455. * @arg @ref LL_COMP_INPUT_PLUS_IO3 (*)
  456. *
  457. * (*) Parameter not available on all devices.
  458. */
  459. __STATIC_INLINE uint32_t LL_COMP_GetInputPlus(COMP_TypeDef *COMPx)
  460. {
  461. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INPSEL));
  462. }
  463. /**
  464. * @brief Set comparator input minus (inverting).
  465. * @note In case of comparator input selected to be connected to IO:
  466. * GPIO pins are specific to each comparator instance.
  467. * Refer to description of parameters or to reference manual.
  468. * @note On this STM32 serie, scaler bridge is configurable:
  469. * to optimize power consumption, this function enables the
  470. * voltage scaler bridge only when required
  471. * (when selecting comparator input based on VrefInt: VrefInt or
  472. * subdivision of VrefInt).
  473. * - For scaler bridge power consumption values,
  474. * refer to device datasheet, parameter "IDDA(SCALER)".
  475. * - Voltage scaler requires a delay for voltage stabilization.
  476. * Refer to device datasheet, parameter "tSTART_SCALER".
  477. * - Scaler bridge is common for all comparator instances,
  478. * therefore if at least one of the comparator instance
  479. * is requiring the scaler bridge, it remains enabled.
  480. * @rmtoll CSR INMSEL LL_COMP_SetInputMinus\n
  481. * CSR BRGEN LL_COMP_SetInputMinus\n
  482. * CSR SCALEN LL_COMP_SetInputMinus
  483. * @param COMPx Comparator instance
  484. * @param InputMinus This parameter can be one of the following values:
  485. * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
  486. * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
  487. * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
  488. * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
  489. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
  490. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2 (*)
  491. * @arg @ref LL_COMP_INPUT_MINUS_IO1
  492. * @arg @ref LL_COMP_INPUT_MINUS_IO2
  493. * @arg @ref LL_COMP_INPUT_MINUS_IO3 (*)
  494. * @arg @ref LL_COMP_INPUT_MINUS_IO4 (*)
  495. * @arg @ref LL_COMP_INPUT_MINUS_IO5 (*)
  496. *
  497. * (*) Parameter not available on all devices.
  498. * @retval None
  499. */
  500. __STATIC_INLINE void LL_COMP_SetInputMinus(COMP_TypeDef *COMPx, uint32_t InputMinus)
  501. {
  502. #if defined(COMP_CSR_INMESEL_1)
  503. MODIFY_REG(COMPx->CSR, COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN, InputMinus);
  504. #else
  505. MODIFY_REG(COMPx->CSR, COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN, InputMinus);
  506. #endif
  507. }
  508. /**
  509. * @brief Get comparator input minus (inverting).
  510. * @note In case of comparator input selected to be connected to IO:
  511. * GPIO pins are specific to each comparator instance.
  512. * Refer to description of parameters or to reference manual.
  513. * @rmtoll CSR INMSEL LL_COMP_GetInputMinus\n
  514. * CSR BRGEN LL_COMP_GetInputMinus\n
  515. * CSR SCALEN LL_COMP_GetInputMinus
  516. * @param COMPx Comparator instance
  517. * @retval Returned value can be one of the following values:
  518. * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
  519. * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
  520. * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
  521. * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
  522. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
  523. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2 (*)
  524. * @arg @ref LL_COMP_INPUT_MINUS_IO1
  525. * @arg @ref LL_COMP_INPUT_MINUS_IO2
  526. * @arg @ref LL_COMP_INPUT_MINUS_IO3 (*)
  527. * @arg @ref LL_COMP_INPUT_MINUS_IO4 (*)
  528. * @arg @ref LL_COMP_INPUT_MINUS_IO5 (*)
  529. *
  530. * (*) Parameter not available on all devices.
  531. */
  532. __STATIC_INLINE uint32_t LL_COMP_GetInputMinus(COMP_TypeDef *COMPx)
  533. {
  534. #if defined(COMP_CSR_INMESEL_1)
  535. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN));
  536. #else
  537. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN));
  538. #endif
  539. }
  540. /**
  541. * @brief Set comparator instance hysteresis mode of the input minus (inverting input).
  542. * @rmtoll CSR HYST LL_COMP_SetInputHysteresis
  543. * @param COMPx Comparator instance
  544. * @param InputHysteresis This parameter can be one of the following values:
  545. * @arg @ref LL_COMP_HYSTERESIS_NONE
  546. * @arg @ref LL_COMP_HYSTERESIS_LOW
  547. * @arg @ref LL_COMP_HYSTERESIS_MEDIUM
  548. * @arg @ref LL_COMP_HYSTERESIS_HIGH
  549. * @retval None
  550. */
  551. __STATIC_INLINE void LL_COMP_SetInputHysteresis(COMP_TypeDef *COMPx, uint32_t InputHysteresis)
  552. {
  553. MODIFY_REG(COMPx->CSR, COMP_CSR_HYST, InputHysteresis);
  554. }
  555. /**
  556. * @brief Get comparator instance hysteresis mode of the minus (inverting) input.
  557. * @rmtoll CSR HYST LL_COMP_GetInputHysteresis
  558. * @param COMPx Comparator instance
  559. * @retval Returned value can be one of the following values:
  560. * @arg @ref LL_COMP_HYSTERESIS_NONE
  561. * @arg @ref LL_COMP_HYSTERESIS_LOW
  562. * @arg @ref LL_COMP_HYSTERESIS_MEDIUM
  563. * @arg @ref LL_COMP_HYSTERESIS_HIGH
  564. */
  565. __STATIC_INLINE uint32_t LL_COMP_GetInputHysteresis(COMP_TypeDef *COMPx)
  566. {
  567. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_HYST));
  568. }
  569. /**
  570. * @}
  571. */
  572. /** @defgroup COMP_LL_EF_Configuration_comparator_output Configuration of comparator output
  573. * @{
  574. */
  575. /**
  576. * @brief Set comparator instance output polarity.
  577. * @rmtoll CSR POLARITY LL_COMP_SetOutputPolarity
  578. * @param COMPx Comparator instance
  579. * @param OutputPolarity This parameter can be one of the following values:
  580. * @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
  581. * @arg @ref LL_COMP_OUTPUTPOL_INVERTED
  582. * @retval None
  583. */
  584. __STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPolarity)
  585. {
  586. MODIFY_REG(COMPx->CSR, COMP_CSR_POLARITY, OutputPolarity);
  587. }
  588. /**
  589. * @brief Get comparator instance output polarity.
  590. * @rmtoll CSR POLARITY LL_COMP_GetOutputPolarity
  591. * @param COMPx Comparator instance
  592. * @retval Returned value can be one of the following values:
  593. * @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
  594. * @arg @ref LL_COMP_OUTPUTPOL_INVERTED
  595. */
  596. __STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx)
  597. {
  598. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_POLARITY));
  599. }
  600. /**
  601. * @brief Set comparator instance blanking source.
  602. * @note Blanking source may be specific to each comparator instance.
  603. * Refer to description of parameters or to reference manual.
  604. * @note Availability of parameters of blanking source from timer
  605. * depends on timers availability on the selected device.
  606. * @rmtoll CSR BLANKING LL_COMP_SetOutputBlankingSource
  607. * @param COMPx Comparator instance
  608. * @param BlankingSource This parameter can be one of the following values:
  609. * @arg @ref LL_COMP_BLANKINGSRC_NONE
  610. * @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1 (1)(2)
  611. * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1 (1)(2)
  612. * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1 (1)(2)
  613. * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4_COMP2 (1)(3)
  614. * @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5_COMP2 (1)(3)
  615. * @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1_COMP2 (1)(3)
  616. *
  617. * (1) Parameter availability depending on timer availability
  618. * on the selected device.
  619. * (2) On STM32L4, parameter available only on comparator instance: COMP1.
  620. * (3) On STM32L4, parameter available only on comparator instance: COMP2.
  621. * @retval None
  622. */
  623. __STATIC_INLINE void LL_COMP_SetOutputBlankingSource(COMP_TypeDef *COMPx, uint32_t BlankingSource)
  624. {
  625. MODIFY_REG(COMPx->CSR, COMP_CSR_BLANKING, BlankingSource);
  626. }
  627. /**
  628. * @brief Get comparator instance blanking source.
  629. * @note Availability of parameters of blanking source from timer
  630. * depends on timers availability on the selected device.
  631. * @note Blanking source may be specific to each comparator instance.
  632. * Refer to description of parameters or to reference manual.
  633. * @rmtoll CSR BLANKING LL_COMP_GetOutputBlankingSource
  634. * @param COMPx Comparator instance
  635. * @retval Returned value can be one of the following values:
  636. * @arg @ref LL_COMP_BLANKINGSRC_NONE
  637. * @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1 (1)(2)
  638. * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1 (1)(2)
  639. * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1 (1)(2)
  640. * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4_COMP2 (1)(3)
  641. * @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5_COMP2 (1)(3)
  642. * @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1_COMP2 (1)(3)
  643. *
  644. * (1) Parameter availability depending on timer availability
  645. * on the selected device.
  646. * (2) On STM32L4, parameter available only on comparator instance: COMP1.
  647. * (3) On STM32L4, parameter available only on comparator instance: COMP2.
  648. */
  649. __STATIC_INLINE uint32_t LL_COMP_GetOutputBlankingSource(COMP_TypeDef *COMPx)
  650. {
  651. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_BLANKING));
  652. }
  653. /**
  654. * @}
  655. */
  656. /** @defgroup COMP_LL_EF_Configuration_Legacy_Functions Configuration of COMP, legacy functions name
  657. * @{
  658. */
  659. /* Old functions name kept for legacy purpose, to be replaced by the */
  660. /* current functions name. */
  661. __STATIC_INLINE void LL_COMP_SetInputNonInverting(COMP_TypeDef *COMPx, uint32_t InputNonInverting)
  662. {
  663. LL_COMP_SetInputPlus(COMPx, InputNonInverting);
  664. }
  665. __STATIC_INLINE uint32_t LL_COMP_GetInputNonInverting(COMP_TypeDef *COMPx)
  666. {
  667. return LL_COMP_GetInputPlus(COMPx);
  668. }
  669. __STATIC_INLINE void LL_COMP_SetInputInverting(COMP_TypeDef *COMPx, uint32_t InputInverting)
  670. {
  671. LL_COMP_SetInputMinus(COMPx, InputInverting);
  672. }
  673. __STATIC_INLINE uint32_t LL_COMP_GetInputInverting(COMP_TypeDef *COMPx)
  674. {
  675. return LL_COMP_GetInputMinus(COMPx);
  676. }
  677. /**
  678. * @}
  679. */
  680. /** @defgroup COMP_LL_EF_Operation Operation on comparator instance
  681. * @{
  682. */
  683. /**
  684. * @brief Enable comparator instance.
  685. * @note After enable from off state, comparator requires a delay
  686. * to reach reach propagation delay specification.
  687. * Refer to device datasheet, parameter "tSTART".
  688. * @rmtoll CSR EN LL_COMP_Enable
  689. * @param COMPx Comparator instance
  690. * @retval None
  691. */
  692. __STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx)
  693. {
  694. SET_BIT(COMPx->CSR, COMP_CSR_EN);
  695. }
  696. /**
  697. * @brief Disable comparator instance.
  698. * @rmtoll CSR EN LL_COMP_Disable
  699. * @param COMPx Comparator instance
  700. * @retval None
  701. */
  702. __STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx)
  703. {
  704. CLEAR_BIT(COMPx->CSR, COMP_CSR_EN);
  705. }
  706. /**
  707. * @brief Get comparator enable state
  708. * (0: COMP is disabled, 1: COMP is enabled)
  709. * @rmtoll CSR EN LL_COMP_IsEnabled
  710. * @param COMPx Comparator instance
  711. * @retval State of bit (1 or 0).
  712. */
  713. __STATIC_INLINE uint32_t LL_COMP_IsEnabled(COMP_TypeDef *COMPx)
  714. {
  715. return (READ_BIT(COMPx->CSR, COMP_CSR_EN) == (COMP_CSR_EN));
  716. }
  717. /**
  718. * @brief Lock comparator instance.
  719. * @note Once locked, comparator configuration can be accessed in read-only.
  720. * @note The only way to unlock the comparator is a device hardware reset.
  721. * @rmtoll CSR LOCK LL_COMP_Lock
  722. * @param COMPx Comparator instance
  723. * @retval None
  724. */
  725. __STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx)
  726. {
  727. SET_BIT(COMPx->CSR, COMP_CSR_LOCK);
  728. }
  729. /**
  730. * @brief Get comparator lock state
  731. * (0: COMP is unlocked, 1: COMP is locked).
  732. * @note Once locked, comparator configuration can be accessed in read-only.
  733. * @note The only way to unlock the comparator is a device hardware reset.
  734. * @rmtoll CSR LOCK LL_COMP_IsLocked
  735. * @param COMPx Comparator instance
  736. * @retval State of bit (1 or 0).
  737. */
  738. __STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx)
  739. {
  740. return (READ_BIT(COMPx->CSR, COMP_CSR_LOCK) == (COMP_CSR_LOCK));
  741. }
  742. /**
  743. * @brief Read comparator instance output level.
  744. * @note The comparator output level depends on the selected polarity
  745. * (Refer to function @ref LL_COMP_SetOutputPolarity()).
  746. * If the comparator polarity is not inverted:
  747. * - Comparator output is low when the input plus
  748. * is at a lower voltage than the input minus
  749. * - Comparator output is high when the input plus
  750. * is at a higher voltage than the input minus
  751. * If the comparator polarity is inverted:
  752. * - Comparator output is high when the input plus
  753. * is at a lower voltage than the input minus
  754. * - Comparator output is low when the input plus
  755. * is at a higher voltage than the input minus
  756. * @rmtoll CSR VALUE LL_COMP_ReadOutputLevel
  757. * @param COMPx Comparator instance
  758. * @retval Returned value can be one of the following values:
  759. * @arg @ref LL_COMP_OUTPUT_LEVEL_LOW
  760. * @arg @ref LL_COMP_OUTPUT_LEVEL_HIGH
  761. */
  762. __STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx)
  763. {
  764. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_VALUE)
  765. >> LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS);
  766. }
  767. /**
  768. * @}
  769. */
  770. #if defined(USE_FULL_LL_DRIVER)
  771. /** @defgroup COMP_LL_EF_Init Initialization and de-initialization functions
  772. * @{
  773. */
  774. ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx);
  775. ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct);
  776. void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct);
  777. /**
  778. * @}
  779. */
  780. #endif /* USE_FULL_LL_DRIVER */
  781. /**
  782. * @}
  783. */
  784. /**
  785. * @}
  786. */
  787. #endif /* COMP1 || COMP2 */
  788. /**
  789. * @}
  790. */
  791. #ifdef __cplusplus
  792. }
  793. #endif
  794. #endif /* __STM32L4xx_LL_COMP_H */
  795. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/