fm33lc0xx_fl_comp.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. /**
  2. *******************************************************************************************************
  3. * @file fm33lc0xx_fl_comp.h
  4. * @author FMSH Application Team
  5. * @brief Head file of COMP FL Module
  6. *******************************************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) [2021] [Fudan Microelectronics]
  10. * THIS SOFTWARE is licensed under Mulan PSL v2.
  11. * You can use this software according to the terms and conditions of the Mulan PSL v2.
  12. * You may obtain a copy of Mulan PSL v2 at:
  13. * http://license.coscl.org.cn/MulanPSL2
  14. * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  15. * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  16. * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  17. * See the Mulan PSL v2 for more details.
  18. *
  19. *******************************************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion---------------------------------------------------------------*/
  22. #ifndef __FM33LC0XX_FL_COMP_H
  23. #define __FM33LC0XX_FL_COMP_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes -------------------------------------------------------------------------------------------*/
  28. #include "fm33lc0xx_fl_def.h"
  29. /** @addtogroup FM33LC0XX_FL_Driver
  30. * @{
  31. */
  32. /** @defgroup COMP COMP
  33. * @brief COMP FL driver
  34. * @{
  35. */
  36. /* Exported types -------------------------------------------------------------------------------------*/
  37. /** @defgroup COMP_FL_ES_INIT COMP Exported Init structures
  38. * @{
  39. */
  40. /**
  41. * @brief FL COMP Init Sturcture definition
  42. */
  43. typedef struct
  44. {
  45. /** 比较器正向输入选择 */
  46. uint32_t positiveInput;
  47. /** 比较器反向输入选择 */
  48. uint32_t negativeInput;
  49. /** 结果输出极性 */
  50. uint32_t polarity;
  51. /** 中断触发边沿选择 */
  52. uint32_t edge;
  53. /** 数字滤波器使能 */
  54. uint32_t digitalFilter;
  55. /** 数字滤波器长度 */
  56. uint32_t digitalFilterLen; /* 此芯片不可设 */
  57. } FL_COMP_InitTypeDef;
  58. /**
  59. * @}
  60. */
  61. /* Exported constants ---------------------------------------------------------------------------------*/
  62. /** @defgroup COMP_FL_Exported_Constants COMP Exported Constants
  63. * @{
  64. */
  65. #define COMP_CR_CMPO_Pos (8U)
  66. #define COMP_CR_CMPO_Msk (0x1U << COMP_CR_CMPO_Pos)
  67. #define COMP_CR_CMPO COMP_CR_CMPO_Msk
  68. #define COMP_CR_POLAR_Pos (5U)
  69. #define COMP_CR_POLAR_Msk (0x1U << COMP_CR_POLAR_Pos)
  70. #define COMP_CR_POLAR COMP_CR_POLAR_Msk
  71. #define COMP_CR_VPSEL_Pos (3U)
  72. #define COMP_CR_VPSEL_Msk (0x3U << COMP_CR_VPSEL_Pos)
  73. #define COMP_CR_VPSEL COMP_CR_VPSEL_Msk
  74. #define COMP_CR_VNSEL_Pos (1U)
  75. #define COMP_CR_VNSEL_Msk (0x3U << COMP_CR_VNSEL_Pos)
  76. #define COMP_CR_VNSEL COMP_CR_VNSEL_Msk
  77. #define COMP_CR_CMPEN_Pos (0U)
  78. #define COMP_CR_CMPEN_Msk (0x1U << COMP_CR_CMPEN_Pos)
  79. #define COMP_CR_CMPEN COMP_CR_CMPEN_Msk
  80. #define COMP_ICR_COMP2DF_Pos (9U)
  81. #define COMP_ICR_COMP2DF_Msk (0x1U << COMP_ICR_COMP2DF_Pos)
  82. #define COMP_ICR_COMP2DF COMP_ICR_COMP2DF_Msk
  83. #define COMP_ICR_COMP1DF_Pos (8U)
  84. #define COMP_ICR_COMP1DF_Msk (0x1U << COMP_ICR_COMP1DF_Pos)
  85. #define COMP_ICR_COMP1DF COMP_ICR_COMP1DF_Msk
  86. #define COMP_ICR_CMP2SEL_Pos (4U)
  87. #define COMP_ICR_CMP2SEL_Msk (0x3U << COMP_ICR_CMP2SEL_Pos)
  88. #define COMP_ICR_CMP2SEL COMP_ICR_CMP2SEL_Msk
  89. #define COMP_ICR_CMP1SEL_Pos (2U)
  90. #define COMP_ICR_CMP1SEL_Msk (0x3U << COMP_ICR_CMP1SEL_Pos)
  91. #define COMP_ICR_CMP1SEL COMP_ICR_CMP1SEL_Msk
  92. #define COMP_ICR_CMP2IE_Pos (1U)
  93. #define COMP_ICR_CMP2IE_Msk (0x1U << COMP_ICR_CMP2IE_Pos)
  94. #define COMP_ICR_CMP2IE COMP_ICR_CMP2IE_Msk
  95. #define COMP_ICR_CMP1IE_Pos (0U)
  96. #define COMP_ICR_CMP1IE_Msk (0x1U << COMP_ICR_CMP1IE_Pos)
  97. #define COMP_ICR_CMP1IE COMP_ICR_CMP1IE_Msk
  98. #define COMP_ISR_CMP2IF_Pos (1U)
  99. #define COMP_ISR_CMP2IF_Msk (0x1U << COMP_ISR_CMP2IF_Pos)
  100. #define COMP_ISR_CMP2IF COMP_ISR_CMP2IF_Msk
  101. #define COMP_ISR_CMP1IF_Pos (0U)
  102. #define COMP_ISR_CMP1IF_Msk (0x1U << COMP_ISR_CMP1IF_Pos)
  103. #define COMP_ISR_CMP1IF COMP_ISR_CMP1IF_Msk
  104. #define FL_COMP_INTERRUPT_EDGE_BOTH 0x0U
  105. #define FL_COMP_INTERRUPT_EDGE_RISING 0x1U
  106. #define FL_COMP_INTERRUPT_EDGE_FALLING 0x2U
  107. #define FL_COMP_OUTPUT_LOW (0x0U << COMP_CR_CMPO_Pos)
  108. #define FL_COMP_OUTPUT_HIGH (0x1U << COMP_CR_CMPO_Pos)
  109. #define FL_COMP_OUTPUT_POLARITY_NORMAL (0x0U << COMP_CR_POLAR_Pos)
  110. #define FL_COMP_OUTPUT_POLARITY_INVERT (0x1U << COMP_CR_POLAR_Pos)
  111. #define FL_COMP_INP_SOURCE_INP1 (0x0U << COMP_CR_VPSEL_Pos)
  112. #define FL_COMP_INP_SOURCE_INP2 (0x1U << COMP_CR_VPSEL_Pos)
  113. #define FL_COMP_INP_SOURCE_INP3 (0x2U << COMP_CR_VPSEL_Pos)
  114. #define FL_COMP_INN_SOURCE_INN1 (0x0U << COMP_CR_VNSEL_Pos)
  115. #define FL_COMP_INN_SOURCE_INN2 (0x1U << COMP_CR_VNSEL_Pos)
  116. #define FL_COMP_INN_SOURCE_VREF (0x2U << COMP_CR_VNSEL_Pos)
  117. #define FL_COMP_INN_SOURCE_VREF_DIV_2 (0x3U << COMP_CR_VNSEL_Pos)
  118. #define FL_COMP_COMP2_INTERRUPT_EDGE_BOTH (0x0U << COMP_ICR_CMP2SEL_Pos)
  119. #define FL_COMP_COMP2_INTERRUPT_EDGE_RISING (0x1U << COMP_ICR_CMP2SEL_Pos)
  120. #define FL_COMP_COMP2_INTERRUPT_EDGE_FALLING (0x2U << COMP_ICR_CMP2SEL_Pos)
  121. #define FL_COMP_COMP1_INTERRUPT_EDGE_BOTH (0x0U << COMP_ICR_CMP1SEL_Pos)
  122. #define FL_COMP_COMP1_INTERRUPT_EDGE_RISING (0x1U << COMP_ICR_CMP1SEL_Pos)
  123. #define FL_COMP_COMP1_INTERRUPT_EDGE_FALLING (0x2U << COMP_ICR_CMP1SEL_Pos)
  124. /**
  125. * @}
  126. */
  127. /* Exported functions ---------------------------------------------------------------------------------*/
  128. /** @defgroup COMP_FL_Exported_Functions COMP Exported Functions
  129. * @{
  130. */
  131. /**
  132. * @brief Get comparator output channel
  133. * @rmtoll CR CMPO FL_COMP_GetOutput
  134. * @param COMPx COMP instance
  135. * @retval Returned value can be one of the following values:
  136. * @arg @ref FL_COMP_OUTPUT_LOW
  137. * @arg @ref FL_COMP_OUTPUT_HIGH
  138. */
  139. __STATIC_INLINE uint32_t FL_COMP_GetOutput(COMP_Type *COMPx)
  140. {
  141. return (uint32_t)(READ_BIT(COMPx->CR, COMP_CR_CMPO_Msk));
  142. }
  143. /**
  144. * @brief Set COMPx output polarity
  145. * @rmtoll CR POLAR FL_COMP_SetOutputPolarity
  146. * @param COMPx COMP instance
  147. * @param polarity This parameter can be one of the following values:
  148. * @arg @ref FL_COMP_OUTPUT_POLARITY_NORMAL
  149. * @arg @ref FL_COMP_OUTPUT_POLARITY_INVERT
  150. * @retval None
  151. */
  152. __STATIC_INLINE void FL_COMP_SetOutputPolarity(COMP_Type *COMPx, uint32_t polarity)
  153. {
  154. MODIFY_REG(COMPx->CR, COMP_CR_POLAR_Msk, polarity);
  155. }
  156. /**
  157. * @brief Get COMPx output polarity
  158. * @rmtoll CR POLAR FL_COMP_GetOutputPolarity
  159. * @param COMPx COMP instance
  160. * @retval Returned value can be one of the following values:
  161. * @arg @ref FL_COMP_OUTPUT_POLARITY_NORMAL
  162. * @arg @ref FL_COMP_OUTPUT_POLARITY_INVERT
  163. */
  164. __STATIC_INLINE uint32_t FL_COMP_GetOutputPolarity(COMP_Type *COMPx)
  165. {
  166. return (uint32_t)(READ_BIT(COMPx->CR, COMP_CR_POLAR_Msk));
  167. }
  168. /**
  169. * @brief Set COMPx positive input
  170. * @rmtoll CR VPSEL FL_COMP_SetINPSource
  171. * @param COMPx COMP instance
  172. * @param source This parameter can be one of the following values:
  173. * @arg @ref FL_COMP_INP_SOURCE_INP1
  174. * @arg @ref FL_COMP_INP_SOURCE_INP2
  175. * @arg @ref FL_COMP_INP_SOURCE_INP3
  176. * @retval None
  177. */
  178. __STATIC_INLINE void FL_COMP_SetINPSource(COMP_Type *COMPx, uint32_t source)
  179. {
  180. MODIFY_REG(COMPx->CR, COMP_CR_VPSEL_Msk, source);
  181. }
  182. /**
  183. * @brief Get COMPx positive input status
  184. * @rmtoll CR VPSEL FL_COMP_GetINPSource
  185. * @param COMPx COMP instance
  186. * @retval Returned value can be one of the following values:
  187. * @arg @ref FL_COMP_INP_SOURCE_INP1
  188. * @arg @ref FL_COMP_INP_SOURCE_INP2
  189. * @arg @ref FL_COMP_INP_SOURCE_INP3
  190. */
  191. __STATIC_INLINE uint32_t FL_COMP_GetINPSource(COMP_Type *COMPx)
  192. {
  193. return (uint32_t)(READ_BIT(COMPx->CR, COMP_CR_VPSEL_Msk));
  194. }
  195. /**
  196. * @brief Set COMPx negative input
  197. * @rmtoll CR VNSEL FL_COMP_SetINNSource
  198. * @param COMPx COMP instance
  199. * @param source This parameter can be one of the following values:
  200. * @arg @ref FL_COMP_INN_SOURCE_INN1
  201. * @arg @ref FL_COMP_INN_SOURCE_INN2
  202. * @arg @ref FL_COMP_INN_SOURCE_VREF
  203. * @arg @ref FL_COMP_INN_SOURCE_VREF_DIV_2
  204. * @retval None
  205. */
  206. __STATIC_INLINE void FL_COMP_SetINNSource(COMP_Type *COMPx, uint32_t source)
  207. {
  208. MODIFY_REG(COMPx->CR, COMP_CR_VNSEL_Msk, source);
  209. }
  210. /**
  211. * @brief Get COMPx negative input status
  212. * @rmtoll CR VNSEL FL_COMP_GetINNSource
  213. * @param COMPx COMP instance
  214. * @retval Returned value can be one of the following values:
  215. * @arg @ref FL_COMP_INN_SOURCE_INN1
  216. * @arg @ref FL_COMP_INN_SOURCE_INN2
  217. * @arg @ref FL_COMP_INN_SOURCE_VREF
  218. * @arg @ref FL_COMP_INN_SOURCE_VREF_DIV_2
  219. */
  220. __STATIC_INLINE uint32_t FL_COMP_GetINNSource(COMP_Type *COMPx)
  221. {
  222. return (uint32_t)(READ_BIT(COMPx->CR, COMP_CR_VNSEL_Msk));
  223. }
  224. /**
  225. * @brief COMPx enable
  226. * @rmtoll CR CMPEN FL_COMP_Enable
  227. * @param COMPx COMP instance
  228. * @retval None
  229. */
  230. __STATIC_INLINE void FL_COMP_Enable(COMP_Type *COMPx)
  231. {
  232. SET_BIT(COMPx->CR, COMP_CR_CMPEN_Msk);
  233. }
  234. /**
  235. * @brief Get COMPx enable status
  236. * @rmtoll CR CMPEN FL_COMP_IsEnabled
  237. * @param COMPx COMP instance
  238. * @retval State of bit (1 or 0).
  239. */
  240. __STATIC_INLINE uint32_t FL_COMP_IsEnabled(COMP_Type *COMPx)
  241. {
  242. return (uint32_t)(READ_BIT(COMPx->CR, COMP_CR_CMPEN_Msk) == COMP_CR_CMPEN_Msk);
  243. }
  244. /**
  245. * @brief COMPx disable
  246. * @rmtoll CR CMPEN FL_COMP_Disable
  247. * @param COMPx COMP instance
  248. * @retval None
  249. */
  250. __STATIC_INLINE void FL_COMP_Disable(COMP_Type *COMPx)
  251. {
  252. CLEAR_BIT(COMPx->CR, COMP_CR_CMPEN_Msk);
  253. }
  254. /**
  255. * @brief Comparator2 DigitalFilter enable
  256. * @rmtoll ICR COMP2DF FL_COMP_EnableComparator2OutputFilter
  257. * @param COMPx COMP instance
  258. * @retval None
  259. */
  260. __STATIC_INLINE void FL_COMP_EnableComparator2OutputFilter(COMP_COMMON_Type *COMPx)
  261. {
  262. SET_BIT(COMPx->ICR, COMP_ICR_COMP2DF_Msk);
  263. }
  264. /**
  265. * @brief Get comparator2 DigitalFilter enable status
  266. * @rmtoll ICR COMP2DF FL_COMP_IsEnabledComparator2OutputFilter
  267. * @param COMPx COMP instance
  268. * @retval State of bit (1 or 0).
  269. */
  270. __STATIC_INLINE uint32_t FL_COMP_IsEnabledComparator2OutputFilter(COMP_COMMON_Type *COMPx)
  271. {
  272. return (uint32_t)(READ_BIT(COMPx->ICR, COMP_ICR_COMP2DF_Msk) == COMP_ICR_COMP2DF_Msk);
  273. }
  274. /**
  275. * @brief Comparator2 DigitalFilter disable
  276. * @rmtoll ICR COMP2DF FL_COMP_DisableComparator2OutputFilter
  277. * @param COMPx COMP instance
  278. * @retval None
  279. */
  280. __STATIC_INLINE void FL_COMP_DisableComparator2OutputFilter(COMP_COMMON_Type *COMPx)
  281. {
  282. CLEAR_BIT(COMPx->ICR, COMP_ICR_COMP2DF_Msk);
  283. }
  284. /**
  285. * @brief Comparator1 DigitalFilter enable
  286. * @rmtoll ICR COMP1DF FL_COMP_EnableComparator1OutputFilter
  287. * @param COMPx COMP instance
  288. * @retval None
  289. */
  290. __STATIC_INLINE void FL_COMP_EnableComparator1OutputFilter(COMP_COMMON_Type *COMPx)
  291. {
  292. SET_BIT(COMPx->ICR, COMP_ICR_COMP1DF_Msk);
  293. }
  294. /**
  295. * @brief Get comparator1 DigitalFilter enable status
  296. * @rmtoll ICR COMP1DF FL_COMP_IsEnabledComparator1OutputFilter
  297. * @param COMPx COMP instance
  298. * @retval State of bit (1 or 0).
  299. */
  300. __STATIC_INLINE uint32_t FL_COMP_IsEnabledComparator1OutputFilter(COMP_COMMON_Type *COMPx)
  301. {
  302. return (uint32_t)(READ_BIT(COMPx->ICR, COMP_ICR_COMP1DF_Msk) == COMP_ICR_COMP1DF_Msk);
  303. }
  304. /**
  305. * @brief Comparator1 DigitalFilter disable
  306. * @rmtoll ICR COMP1DF FL_COMP_DisableComparator1OutputFilter
  307. * @param COMPx COMP instance
  308. * @retval None
  309. */
  310. __STATIC_INLINE void FL_COMP_DisableComparator1OutputFilter(COMP_COMMON_Type *COMPx)
  311. {
  312. CLEAR_BIT(COMPx->ICR, COMP_ICR_COMP1DF_Msk);
  313. }
  314. /**
  315. * @brief Set comparator2 interrupt edge
  316. * @rmtoll ICR CMP2SEL FL_COMP_SetComparator2InterruptEdge
  317. * @param COMPx COMP instance
  318. * @param edge This parameter can be one of the following values:
  319. * @arg @ref FL_COMP_COMP2_INTERRUPT_EDGE_BOTH
  320. * @arg @ref FL_COMP_COMP2_INTERRUPT_EDGE_RISING
  321. * @arg @ref FL_COMP_COMP2_INTERRUPT_EDGE_FALLING
  322. * @retval None
  323. */
  324. __STATIC_INLINE void FL_COMP_SetComparator2InterruptEdge(COMP_COMMON_Type *COMPx, uint32_t edge)
  325. {
  326. MODIFY_REG(COMPx->ICR, COMP_ICR_CMP2SEL_Msk, edge);
  327. }
  328. /**
  329. * @brief Get comparator2 interrupt edge
  330. * @rmtoll ICR CMP2SEL FL_COMP_GetComparator2InterruptEdge
  331. * @param COMPx COMP instance
  332. * @retval Returned value can be one of the following values:
  333. * @arg @ref FL_COMP_COMP2_INTERRUPT_EDGE_BOTH
  334. * @arg @ref FL_COMP_COMP2_INTERRUPT_EDGE_RISING
  335. * @arg @ref FL_COMP_COMP2_INTERRUPT_EDGE_FALLING
  336. */
  337. __STATIC_INLINE uint32_t FL_COMP_GetComparator2InterruptEdge(COMP_COMMON_Type *COMPx)
  338. {
  339. return (uint32_t)(READ_BIT(COMPx->ICR, COMP_ICR_CMP2SEL_Msk));
  340. }
  341. /**
  342. * @brief Set comparator1 interrupt edge
  343. * @rmtoll ICR CMP1SEL FL_COMP_SetComparator1InterruptEdge
  344. * @param COMPx COMP instance
  345. * @param edge This parameter can be one of the following values:
  346. * @arg @ref FL_COMP_COMP1_INTERRUPT_EDGE_BOTH
  347. * @arg @ref FL_COMP_COMP1_INTERRUPT_EDGE_RISING
  348. * @arg @ref FL_COMP_COMP1_INTERRUPT_EDGE_FALLING
  349. * @retval None
  350. */
  351. __STATIC_INLINE void FL_COMP_SetComparator1InterruptEdge(COMP_COMMON_Type *COMPx, uint32_t edge)
  352. {
  353. MODIFY_REG(COMPx->ICR, COMP_ICR_CMP1SEL_Msk, edge);
  354. }
  355. /**
  356. * @brief Get comparator1 interrupt edge
  357. * @rmtoll ICR CMP1SEL FL_COMP_GetComparator1InterruptEdge
  358. * @param COMPx COMP instance
  359. * @retval Returned value can be one of the following values:
  360. * @arg @ref FL_COMP_COMP1_INTERRUPT_EDGE_BOTH
  361. * @arg @ref FL_COMP_COMP1_INTERRUPT_EDGE_RISING
  362. * @arg @ref FL_COMP_COMP1_INTERRUPT_EDGE_FALLING
  363. */
  364. __STATIC_INLINE uint32_t FL_COMP_GetComparator1InterruptEdge(COMP_COMMON_Type *COMPx)
  365. {
  366. return (uint32_t)(READ_BIT(COMPx->ICR, COMP_ICR_CMP1SEL_Msk));
  367. }
  368. /**
  369. * @brief Comparator2 interrupt enable
  370. * @rmtoll ICR CMP2IE FL_COMP_EnableIT_Comparator2
  371. * @param COMPx COMP instance
  372. * @retval None
  373. */
  374. __STATIC_INLINE void FL_COMP_EnableIT_Comparator2(COMP_COMMON_Type *COMPx)
  375. {
  376. SET_BIT(COMPx->ICR, COMP_ICR_CMP2IE_Msk);
  377. }
  378. /**
  379. * @brief Get comparator2 interrupt enable status
  380. * @rmtoll ICR CMP2IE FL_COMP_IsEnabledIT_Comparator2
  381. * @param COMPx COMP instance
  382. * @retval State of bit (1 or 0).
  383. */
  384. __STATIC_INLINE uint32_t FL_COMP_IsEnabledIT_Comparator2(COMP_COMMON_Type *COMPx)
  385. {
  386. return (uint32_t)(READ_BIT(COMPx->ICR, COMP_ICR_CMP2IE_Msk) == COMP_ICR_CMP2IE_Msk);
  387. }
  388. /**
  389. * @brief Comparator2 interrupt disable
  390. * @rmtoll ICR CMP2IE FL_COMP_DisableIT_Comparator2
  391. * @param COMPx COMP instance
  392. * @retval None
  393. */
  394. __STATIC_INLINE void FL_COMP_DisableIT_Comparator2(COMP_COMMON_Type *COMPx)
  395. {
  396. CLEAR_BIT(COMPx->ICR, COMP_ICR_CMP2IE_Msk);
  397. }
  398. /**
  399. * @brief Comparator1 interrupt enable
  400. * @rmtoll ICR CMP1IE FL_COMP_EnableIT_Comparator1
  401. * @param COMPx COMP instance
  402. * @retval None
  403. */
  404. __STATIC_INLINE void FL_COMP_EnableIT_Comparator1(COMP_COMMON_Type *COMPx)
  405. {
  406. SET_BIT(COMPx->ICR, COMP_ICR_CMP1IE_Msk);
  407. }
  408. /**
  409. * @brief Get comparator1 interrupt enable status
  410. * @rmtoll ICR CMP1IE FL_COMP_IsEnabledIT_Comparator1
  411. * @param COMPx COMP instance
  412. * @retval State of bit (1 or 0).
  413. */
  414. __STATIC_INLINE uint32_t FL_COMP_IsEnabledIT_Comparator1(COMP_COMMON_Type *COMPx)
  415. {
  416. return (uint32_t)(READ_BIT(COMPx->ICR, COMP_ICR_CMP1IE_Msk) == COMP_ICR_CMP1IE_Msk);
  417. }
  418. /**
  419. * @brief Comparator1 interrupt disable
  420. * @rmtoll ICR CMP1IE FL_COMP_DisableIT_Comparator1
  421. * @param COMPx COMP instance
  422. * @retval None
  423. */
  424. __STATIC_INLINE void FL_COMP_DisableIT_Comparator1(COMP_COMMON_Type *COMPx)
  425. {
  426. CLEAR_BIT(COMPx->ICR, COMP_ICR_CMP1IE_Msk);
  427. }
  428. /**
  429. * @brief Get comparator2 interrupt flag
  430. * @rmtoll ISR CMP2IF FL_COMP_IsActiveFlag_Comparator2
  431. * @param COMPx COMP instance
  432. * @retval State of bit (1 or 0).
  433. */
  434. __STATIC_INLINE uint32_t FL_COMP_IsActiveFlag_Comparator2(COMP_COMMON_Type *COMPx)
  435. {
  436. return (uint32_t)(READ_BIT(COMPx->ISR, COMP_ISR_CMP2IF_Msk) == (COMP_ISR_CMP2IF_Msk));
  437. }
  438. /**
  439. * @brief Clear comparator2 interrupt flag
  440. * @rmtoll ISR CMP2IF FL_COMP_ClearFlag_Comparator2
  441. * @param COMPx COMP instance
  442. * @retval None
  443. */
  444. __STATIC_INLINE void FL_COMP_ClearFlag_Comparator2(COMP_COMMON_Type *COMPx)
  445. {
  446. WRITE_REG(COMPx->ISR, COMP_ISR_CMP2IF_Msk);
  447. }
  448. /**
  449. * @brief Get comparator1 interrupt flag
  450. * @rmtoll ISR CMP1IF FL_COMP_IsActiveFlag_Comparator1
  451. * @param COMPx COMP instance
  452. * @retval State of bit (1 or 0).
  453. */
  454. __STATIC_INLINE uint32_t FL_COMP_IsActiveFlag_Comparator1(COMP_COMMON_Type *COMPx)
  455. {
  456. return (uint32_t)(READ_BIT(COMPx->ISR, COMP_ISR_CMP1IF_Msk) == (COMP_ISR_CMP1IF_Msk));
  457. }
  458. /**
  459. * @brief Clear comparator1 interrupt flag
  460. * @rmtoll ISR CMP1IF FL_COMP_ClearFlag_Comparator1
  461. * @param COMPx COMP instance
  462. * @retval None
  463. */
  464. __STATIC_INLINE void FL_COMP_ClearFlag_Comparator1(COMP_COMMON_Type *COMPx)
  465. {
  466. WRITE_REG(COMPx->ISR, COMP_ISR_CMP1IF_Msk);
  467. }
  468. /**
  469. * @}
  470. */
  471. /** @defgroup COMP_FL_EF_Init Initialization and de-initialization functions
  472. * @{
  473. */
  474. FL_ErrorStatus FL_COMP_DeInit(COMP_Type *COMPx);
  475. void FL_COMP_StructInit(FL_COMP_InitTypeDef *initStruct);
  476. FL_ErrorStatus FL_COMP_Init(COMP_Type *COMPx, FL_COMP_InitTypeDef *initStruct);
  477. /**
  478. * @}
  479. */
  480. /**
  481. * @}
  482. */
  483. /**
  484. * @}
  485. */
  486. #ifdef __cplusplus
  487. }
  488. #endif
  489. #endif /* __FM33LC0XX_FL_COMP_H*/
  490. /*************************Py_Code_Generator Version: 0.1-0.11-0.1 @ 2020-09-22*************************/
  491. /********************** (C) COPYRIGHT Fudan Microelectronics **** END OF FILE ***********************/