stm32l4xx_ll_comp.h 38 KB

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