tae32f53xx_ll_cmp.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. /**
  2. ******************************************************************************
  3. * @file tae32f53xx_ll_cmp.h
  4. * @author MCD Application Team
  5. * @brief Header file for CMP Module
  6. *
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2020 Tai-Action.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software is licensed by Tai-Action under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef _TAE32F53XX_LL_CMP_H_
  22. #define _TAE32F53XX_LL_CMP_H_
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif /* __cplusplus */
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "tae32f53xx_ll_def.h"
  28. /** @addtogroup TAE32F53xx_LL_Driver
  29. * @{
  30. */
  31. /** @addtogroup CMP_LL
  32. * @{
  33. */
  34. /* Exported constants --------------------------------------------------------*/
  35. /** @defgroup CMP_LL_Exported_Constants CMP LL Exported Constants
  36. * @brief CMP LL Exported Constants
  37. * @{
  38. */
  39. /** @defgroup CMP_Channel_selection CMP Channel selection
  40. * @{
  41. */
  42. #define CMP_CHANNEL_0 (0x00000001U)
  43. #define CMP_CHANNEL_1 (0x00000002U)
  44. #define CMP_CHANNEL_2 (0x00000004U)
  45. #define CMP_CHANNEL_3 (0x00000008U)
  46. #define CMP_CHANNEL_ALL (CMP_CHANNEL_0 | CMP_CHANNEL_1 | CMP_CHANNEL_2 | CMP_CHANNEL_3 )
  47. /**
  48. * @}
  49. */
  50. /** @defgroup CMP_Interrupt_definition CMP Interrupt definition
  51. * @{
  52. */
  53. #define CMP_IT_FALIE CMP_CR_FALIE /*!< CMP_CHx failing edge interrupt */
  54. #define CMP_IT_RISIE CMP_CR_RISIE /*!< CMP_CHx rising edge interrupt */
  55. /**
  56. * @}
  57. */
  58. /** @defgroup CMP_Flag_definition CMP Flag Definition
  59. * @{
  60. */
  61. #define CMP_FLAG_FAL3IF CMP_SR_FALIF_3
  62. #define CMP_FLAG_FAL2IF CMP_SR_FALIF_2
  63. #define CMP_FLAG_FAL1IF CMP_SR_FALIF_1
  64. #define CMP_FLAG_FAL0IF CMP_SR_FALIF_0
  65. #define CMP_FLAG_RIS3IF CMP_SR_RISIF_3
  66. #define CMP_FLAG_RIS2IF CMP_SR_RISIF_2
  67. #define CMP_FLAG_RIS1IF CMP_SR_RISIF_1
  68. #define CMP_FLAG_RIS0IF CMP_SR_RISIF_0
  69. #define CMP_FLAG_ALLIF (CMP_SR_FALIF_3 | CMP_SR_FALIF_2 | \
  70. CMP_SR_FALIF_1 | CMP_SR_FALIF_0 | \
  71. CMP_SR_RISIF_3 | CMP_SR_RISIF_2 | \
  72. CMP_SR_RISIF_1 | CMP_SR_RISIF_0)
  73. /**
  74. * @}
  75. */
  76. /**
  77. * @}
  78. */
  79. /* Exported macro ------------------------------------------------------------*/
  80. /** @defgroup CMP_LL_Exported_Macros CMP LL Exported Macros
  81. * @brief CMP LL Exported Macros
  82. * @{
  83. */
  84. /**
  85. * @brief Enable CMP Channel
  86. * @param __INSTANCE__ CMP peripheral
  87. * @param __CHN_NB__ Specifies CMP Channel
  88. * This parameter can be a value of 0 to (CMP_CHN_NB - 1)
  89. * @return None
  90. */
  91. #define __LL_CMP_ENABLE(__INSTANCE__, __CHN_NB__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], CMP_CR_PEN)
  92. /**
  93. * @brief Disable CMP Channel
  94. * @param __INSTANCE__ CMP peripheral
  95. * @param __CHN_NB__ Specifies CMP Channel
  96. * This parameter can be a value of 0 to (CMP_CHN_NB - 1)
  97. * @return None
  98. */
  99. #define __LL_CMP_DISABLE(__INSTANCE__, __CHN_NB__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], CMP_CR_PEN)
  100. /**
  101. * @brief Enable the specified CMP Channel Interrupts
  102. * @param __INSTANCE__ CMP peripheral
  103. * @param __CHN_NB__ Specifies CMP Channel
  104. * This parameter can be a value of 0 to (CMP_CHN_NB - 1)
  105. * @param __INTERRUPT__ specifies the CMP Channel interrupt source to enable.
  106. * This parameter can be any combination of @ref CMP_Interrupt_definition:
  107. * @arg CMP_IT_FALIE : CMP_CHx failing edge interrupt
  108. * @arg CMP_IT_RISIE : CMP_CHx rising edge interrupt
  109. * @return None
  110. */
  111. #define __LL_CMP_IT_ENABLE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], (__INTERRUPT__))
  112. /**
  113. * @brief Disable the specified CMP Channel Interrupts
  114. * @param __INSTANCE__ CMP peripheral
  115. * @param __CHN_NB__ Specifies CMP Channel
  116. * This parameter can be a value of 0 to (CMP_CHN_NB - 1)
  117. * @param __INTERRUPT__ specifies the CMP Channel interrupt source to disable.
  118. * This parameter can be any combination of @ref CMP_Interrupt_definition:
  119. * @arg CMP_IT_FALIE : CMP_CHx failing edge interrupt
  120. * @arg CMP_IT_RISIE : CMP_CHx rising edge interrupt
  121. * @return None
  122. */
  123. #define __LL_CMP_IT_DISABLE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], (__INTERRUPT__))
  124. /**
  125. * @brief Check whether the specified CMP Channel interrupt source is set or not.
  126. * @param __INSTANCE__ CMP peripheral
  127. * @param __CHN_NB__ Specifies CMP Channel
  128. * This parameter can be a value of 0 to (CMP_CHN_NB - 1)
  129. * @param __INTERRUPT__ specifies the CMP Channel interrupt source to check.
  130. * This parameter can be ONE of @ref CMP_Interrupt_definition:
  131. * @arg CMP_IT_FALIE : CMP_CHx failing edge interrupt
  132. * @arg CMP_IT_RISIE : CMP_CHx rising edge interrupt
  133. * @return None
  134. */
  135. #define __LL_CMP_IT_CHECK_SOURCE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) \
  136. ((READ_BIT((__INSTANCE__)->CR[__CHN_NB__], (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  137. /**
  138. * @brief Check whether the specified pending flag is SET or not.
  139. * @param __INSTANCE__ CMP peripheral.
  140. * @param __FLAG__ specifies the CMP pending flag to check.
  141. * This parameter can be ONE of the following values where x can be a value of
  142. * 0, 1 ... (CMP_CHN_NB - 1):
  143. * @arg CMP_FLAG_FALxIF : CMP_CHx failing edge interrupt pending flag
  144. * @arg CMP_FLAG_RISxIF : CMP_CHx rising interrupt pending flag
  145. * @return The new state of __FLAG__ (SET or RESET).
  146. */
  147. #define __LL_CMP_PENDING_FLAG_GET(__INSTANCE__, __FLAG__) ((READ_BIT((__INSTANCE__)->SR, (__FLAG__)) == (__FLAG__)) ? SET : RESET)
  148. /**
  149. * @brief Clear the specified pending flags
  150. * @param __INSTANCE__ CMP peripheral.
  151. * @param __FLAG__ specifies the CMP pending flag to clear.
  152. * This parameter can be any combination of the following values where x can be a value of
  153. * 0, 1 ... (CMP_CHN_NB - 1):
  154. * @arg CMP_FLAG_FALxIF : CMP_CHx failing edge interrupt pending flag
  155. * @arg CMP_FLAG_RISxIF : CMP_CHx rising interrupt pending flag
  156. * @arg CMP_FLAG_ALLIF : CMP All interrupt pending flags
  157. * @return None
  158. */
  159. #define __LL_CMP_PENDING_FLAG_CLEAR(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->SR, (__FLAG__))
  160. /**
  161. * @brief Set the specified CMP Channel output debounce value
  162. * @param __INSTANCE__ CMP peripheral.
  163. * @param __CHN_NB__ Specifies CMP Channel
  164. * This parameter can be a value of 0 to (CMP_CHN_NB - 1)
  165. * @param __VAL__ Specifies debounce value
  166. * This value can be a range from 0 - 0xFFF (in System Clocks)
  167. * @return None
  168. */
  169. #define __LL_CMP_DEBOUNCE_VALUE_SET(__INSTANCE__, __CHN_NB__, __VAL__) WRITE_REG((__INSTANCE__)->DEBR[__CHN_NB__], (__VAL__))
  170. /**
  171. * @}
  172. */
  173. /* Exported types ------------------------------------------------------------*/
  174. /** @defgroup CMP_LL_Exported_Types CMP LL Exported Types
  175. * @brief CMP LL Exported Types
  176. * @{
  177. */
  178. /**
  179. * @brief CMP input minus (INM)
  180. */
  181. typedef enum {
  182. CMP_INPUT_MINUS_GND = 0x0U,
  183. /*!< Comparator input minus connected to GND */
  184. CMP_INPUT_MINUS_IO1 = CMP_CR_INM_0,
  185. /*!< Comparator input minus connected to IO1, Note: For CMPx instance availability, please refer to SPEC Document */
  186. CMP_INPUT_MINUS_IO2 = CMP_CR_INM_1,
  187. /*!< Comparator input minus connected to IO2, Note: For CMPx instance availability, please refer to SPEC Document */
  188. CMP_INPUT_MINUS_DAC = CMP_CR_INM_1 | CMP_CR_INM_0,
  189. /*!< Comparator input minus connected to DAC Channel x for CMP Channel x.
  190. Note: For CMPx & DACx instances availability, please refer to SPEC Document */
  191. } CMP_InputMinusETypeDef;
  192. /**
  193. * @brief CMP Hysteresis
  194. */
  195. typedef enum {
  196. CMP_HYSTERESIS_NONE = 0x0U, /*!< No hysteresis */
  197. CMP_HYSTERESIS_10MV = CMP_CR_HYST_0, /*!< Hysteresis level 10mV */
  198. CMP_HYSTERESIS_20MV = CMP_CR_HYST_1, /*!< Hysteresis level 20mV */
  199. CMP_HYSTERESIS_30MV = CMP_CR_HYST_1 | CMP_CR_HYST_0, /*!< Hysteresis level 30mV */
  200. } CMP_HysteresisETypeDef;
  201. /**
  202. * @brief CMP Blanking Source
  203. * @note For CMPx & TMRx instances availability, please refer to SPEC Document
  204. */
  205. typedef enum {
  206. CMP_BLANKINGSRC_NONE = 0x00000000U,
  207. CMP_BLANKINGSRC_TMR0_PWM_CMP0 = CMP_CR_BLANKING_0,
  208. /*!< CMP output blanking source TMR0_PWM (specific to CMP Channel0). */
  209. CMP_BLANKINGSRC_TMR1_PWM_CMP1 = CMP_CR_BLANKING_0,
  210. /*!< CMP output blanking source TMR1_PWM (specific to CMP Channel1). */
  211. CMP_BLANKINGSRC_TMR0_PWM_CMP2 = CMP_CR_BLANKING_0,
  212. /*!< CMP output blanking source TMR0_PWM (specific to CMP Channel2). */
  213. CMP_BLANKINGSRC_TMR1_PWM_CMP3 = CMP_CR_BLANKING_0,
  214. /*!< CMP output blanking source TMR1_PWM (specific to CMP Channel3). */
  215. CMP_BLANKINGSRC_TMR1_PWM_CMP0 = CMP_CR_BLANKING_1,
  216. /*!< CMP output blanking source TMR1_PWM (specific to CMP Channel0). */
  217. CMP_BLANKINGSRC_TMR2_PWM_CMP1 = CMP_CR_BLANKING_1,
  218. /*!< CMP output blanking source TMR2_PWM (specific to CMP Channel1). */
  219. CMP_BLANKINGSRC_TMR1_PWM_CMP2 = CMP_CR_BLANKING_1,
  220. /*!< CMP output blanking source TMR1_PWM (specific to CMP Channel2). */
  221. CMP_BLANKINGSRC_TMR2_PWM_CMP3 = CMP_CR_BLANKING_1,
  222. /*!< CMP output blanking source TMR2_PWM (specific to CMP Channel3). */
  223. CMP_BLANKINGSRC_TMR2_PWM_CMP0 = CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0,
  224. /*!< CMP output blanking source TMR2_PWM (specific to CMP Channel0). */
  225. CMP_BLANKINGSRC_TMR3_PWM_CMP1 = CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0,
  226. /*!< CMP output blanking source TMR3_PWM (specific to CMP Channel1). */
  227. CMP_BLANKINGSRC_TMR2_PWM_CMP2 = CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0,
  228. /*!< CMP output blanking source TMR2_PWM (specific to CMP Channel2). */
  229. CMP_BLANKINGSRC_TMR3_PWM_CMP3 = CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0,
  230. /*!< CMP output blanking source TMR3_PWM (specific to CMP Channel3). */
  231. CMP_BLANKINGSRC_TMR3_PWM_CMP0 = CMP_CR_BLANKING_2,
  232. /*!< CMP output blanking source TMR3_PWM (specific to CMP Channel0). */
  233. CMP_BLANKINGSRC_TMR4_PWM_CMP1 = CMP_CR_BLANKING_2,
  234. /*!< CMP output blanking source TMR4_PWM (specific to CMP Channel1). */
  235. CMP_BLANKINGSRC_TMR3_PWM_CMP2 = CMP_CR_BLANKING_2,
  236. /*!< CMP output blanking source TMR3_PWM (specific to CMP Channel2). */
  237. CMP_BLANKINGSRC_TMR4_PWM_CMP3 = CMP_CR_BLANKING_2,
  238. /*!< CMP output blanking source TMR4_PWM (specific to CMP Channel3). */
  239. CMP_BLANKINGSRC_TMR4_PWM_CMP0 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_0,
  240. /*!< CMP output blanking source TMR4_PWM (specific to CMP Channel0). */
  241. CMP_BLANKINGSRC_TMR5_PWM_CMP1 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_0,
  242. /*!< CMP output blanking source TMR5_PWM (specific to CMP Channel1). */
  243. CMP_BLANKINGSRC_TMR4_PWM_CMP2 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_0,
  244. /*!< CMP output blanking source TMR4_PWM (specific to CMP Channel2). */
  245. CMP_BLANKINGSRC_TMR5_PWM_CMP3 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_0,
  246. /*!< CMP output blanking source TMR5_PWM (specific to CMP Channel3). */
  247. CMP_BLANKINGSRC_TMR5_PWM_CMP0 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1,
  248. /*!< CMP output blanking source TMR5_PWM (specific to CMP Channel0). */
  249. CMP_BLANKINGSRC_TMR6_PWM_CMP1 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1,
  250. /*!< CMP output blanking source TMR6_PWM (specific to CMP Channel1). */
  251. CMP_BLANKINGSRC_TMR5_PWM_CMP2 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1,
  252. /*!< CMP output blanking source TMR5_PWM (specific to CMP Channel2). */
  253. CMP_BLANKINGSRC_TMR6_PWM_CMP3 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1,
  254. /*!< CMP output blanking source TMR6_PWM (specific to CMP Channel3). */
  255. CMP_BLANKINGSRC_TMR6_PWM_CMP0 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0,
  256. /*!< CMP output blanking source TMR6_PWM (specific to CMP Channel0). */
  257. CMP_BLANKINGSRC_TMR7_PWM_CMP1 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0,
  258. /*!< CMP output blanking source TMR7_PWM (specific to CMP Channel1). */
  259. CMP_BLANKINGSRC_TMR6_PWM_CMP2 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0,
  260. /*!< CMP output blanking source TMR6_PWM (specific to CMP Channel2). */
  261. CMP_BLANKINGSRC_TMR7_PWM_CMP3 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0,
  262. /*!< CMP output blanking source TMR7_PWM (specific to CMP Channel3). */
  263. } CMP_BlankingSrcETypeDef;
  264. /**
  265. * @brief CMP Output Debounce
  266. */
  267. typedef enum {
  268. CMP_OUTPUT_DEBOUNCE_DISABLE = 0x0U, /*!< Disable CMP output debounce */
  269. CMP_OUTPUT_DEBOUNCE_ENABLE = CMP_CR_ODEB, /*!< Enable CMP output debounce */
  270. } CMP_OutputDebounceETypeDef;
  271. /**
  272. * @brief CMP output polarity
  273. */
  274. typedef enum {
  275. CMP_OUPUT_POLARITY_NON_INVERTED = 0x0U,
  276. /*!< CMP output level is not inverted. CMP output HIGH when the input plus(INP) is at a higher voltage than the input minus(INM) */
  277. CMP_OUPUT_POLARITY_INVERTED = CMP_CR_OPOL,
  278. /*!< CMP output level is inverted. CMP output LOW when the input plus(INP) is at a higher voltage than the input minus(INM) */
  279. } CMP_OutputPolarityETypeDef;
  280. /**
  281. * @brief CMP trigger interrupt
  282. */
  283. typedef enum {
  284. CMP_TRIGGER_IT_DISABLE = 0x00000000U,
  285. /*!< CMP output triggering event without interrupt */
  286. CMP_TRIGGER_IT_FALLING = CMP_CR_FALIE,
  287. /*!< CMP output triggering event with interrupt on falling edge */
  288. CMP_TRIGGER_IT_RISING = CMP_CR_RISIE,
  289. /*!< CMP output triggering event with interrupt on rising edge */
  290. CMP_TRIGGER_IT_RISING_FALLING = CMP_CR_RISIE | CMP_CR_FALIE,
  291. /*!< CMP output triggering event with interrupt on both rising and falling edges */
  292. } CMP_TriggerITETypeDef;
  293. /**
  294. * @brief CMP Channel Configuration structure definition
  295. */
  296. typedef struct __CMP_ChannelConfTypeDef {
  297. CMP_InputMinusETypeDef InputMinus; /*!< Set comparator input minus (INM). */
  298. CMP_HysteresisETypeDef Hysteresis; /*!< Set comparator hysteresis mode of the input minus(INM). */
  299. CMP_BlankingSrcETypeDef BlankingSource; /*!< Set comparator blanking source. */
  300. CMP_OutputDebounceETypeDef OutputDebounce; /*!< Set comparator output debounce. */
  301. CMP_OutputPolarityETypeDef OutputPolarity; /*!< Set comparator output polarity. */
  302. CMP_TriggerITETypeDef TriggerInterrupt; /*!< Set the comparator output triggering with or without interrupt. */
  303. uint32_t OutputDebounceValue; /*!< Set comparator output debounce vaule. This Should be configured when
  304. Output Debounce is enabled.
  305. this value can be a range from 0 - 0xFFF (in System Clocks) */
  306. } CMP_ChannelConfTypeDef;
  307. /**
  308. * @}
  309. */
  310. /* Exported functions --------------------------------------------------------*/
  311. /** @addtogroup CMP_LL_Exported_Functions
  312. * @{
  313. */
  314. /** @addtogroup CMP_LL_Exported_Functions_Group1
  315. * @{
  316. */
  317. LL_StatusETypeDef LL_CMP_Init(CMP_TypeDef *Instance);
  318. LL_StatusETypeDef LL_CMP_DeInit(CMP_TypeDef *Instance);
  319. void LL_CMP_MspInit(CMP_TypeDef *Instance);
  320. void LL_CMP_MspDeInit(CMP_TypeDef *Instance);
  321. /**
  322. * @}
  323. */
  324. /** @addtogroup CMP_LL_Exported_Functions_Group2
  325. * @{
  326. */
  327. LL_StatusETypeDef LL_CMP_ChannelConfig(CMP_TypeDef *Instance, uint32_t Channel, CMP_ChannelConfTypeDef *sConfig);
  328. /**
  329. * @}
  330. */
  331. /** @addtogroup CMP_LL_Exported_Functions_Group3
  332. * @{
  333. */
  334. LL_StatusETypeDef LL_CMP_Start(CMP_TypeDef *Instance, uint32_t Channel);
  335. LL_StatusETypeDef LL_CMP_Stop(CMP_TypeDef *Instance, uint32_t Channel);
  336. /**
  337. * @}
  338. */
  339. /** @addtogroup CMP_LL_Exported_Functions_Interrupt
  340. * @{
  341. */
  342. void LL_CMP_IRQHandler(CMP_TypeDef *Instance);
  343. void LL_CMP_FailingEdgeTrigCallback(CMP_TypeDef *Instance, uint32_t Channel);
  344. void LL_CMP_RisingEdgeTrigCallback(CMP_TypeDef *Instance, uint32_t Channel);
  345. /**
  346. * @}
  347. */
  348. /**
  349. * @}
  350. */
  351. /* Private constants ---------------------------------------------------------*/
  352. /* Private macros ------------------------------------------------------------*/
  353. /** @defgroup CMP_LL_Private_Macros CMP LL Private Macros
  354. * @brief CMP LL Private Macros
  355. * @{
  356. */
  357. /**
  358. * @brief Judge is CMP channel number or not
  359. * @param CHN_NB channel number to judge
  360. * @retval 0 isn't CMP channel number
  361. * @retval 1 is CMP channel number
  362. */
  363. #define IS_CMP_NUMBER(CHN_NB) ((CHN_NB) < CMP_CHN_NB)
  364. /**
  365. * @brief Judge is CMP Channel or not
  366. * @param CHN Channel to judge
  367. * @retval 0 isn't CMP Channel
  368. * @retval 1 is CMP Channel
  369. */
  370. #define IS_CMP_CHANNEL(CHN) (((CHN) == CMP_CHANNEL_0) || \
  371. ((CHN) == CMP_CHANNEL_1) || \
  372. ((CHN) == CMP_CHANNEL_2) || \
  373. ((CHN) == CMP_CHANNEL_3))
  374. /**
  375. * @brief Judge is CMP input minus or not
  376. * @param INM input minus to judge
  377. * @retval 0 isn't CMP input minus
  378. * @retval 1 is CMP input minus
  379. */
  380. #define IS_CMP_INPUT_MINUS(INM) (((INM) == CMP_INPUT_MINUS_GND) || \
  381. ((INM) == CMP_INPUT_MINUS_IO1) || \
  382. ((INM) == CMP_INPUT_MINUS_IO2) || \
  383. ((INM) == CMP_INPUT_MINUS_DAC))
  384. /**
  385. * @brief Judge is CMP hysteresis or not
  386. * @param HYST hysteresis to judge
  387. * @retval 0 isn't CMP hysteresis
  388. * @retval 1 is CMP hysteresis
  389. */
  390. #define IS_CMP_HYSTERESIS(HYST) (((HYST) == CMP_HYSTERESIS_NONE) || \
  391. ((HYST) == CMP_HYSTERESIS_10MV) || \
  392. ((HYST) == CMP_HYSTERESIS_20MV) || \
  393. ((HYST) == CMP_HYSTERESIS_30MV))
  394. /**
  395. * @brief Judge is CMP blanking source or not
  396. * @param CHN CMP channel to judge
  397. * @param BLANKING blanking to judge
  398. * @retval 0 isn't CMP blanking source
  399. * @retval 1 is CMP blanking source
  400. */
  401. #define IS_CMP_BLANKING_SOURCE(CHN, BLANKING) ( \
  402. (((CHN) == CMP_CHANNEL_0) && \
  403. (((BLANKING) == CMP_BLANKINGSRC_NONE) || \
  404. ((BLANKING) == CMP_BLANKINGSRC_TMR0_PWM_CMP0) || \
  405. ((BLANKING) == CMP_BLANKINGSRC_TMR1_PWM_CMP0) || \
  406. ((BLANKING) == CMP_BLANKINGSRC_TMR2_PWM_CMP0) || \
  407. ((BLANKING) == CMP_BLANKINGSRC_TMR3_PWM_CMP0) || \
  408. ((BLANKING) == CMP_BLANKINGSRC_TMR4_PWM_CMP0) || \
  409. ((BLANKING) == CMP_BLANKINGSRC_TMR5_PWM_CMP0) || \
  410. ((BLANKING) == CMP_BLANKINGSRC_TMR6_PWM_CMP0))) \
  411. || \
  412. (((CHN) == CMP_CHANNEL_1) && \
  413. (((BLANKING) == CMP_BLANKINGSRC_NONE) || \
  414. ((BLANKING) == CMP_BLANKINGSRC_TMR1_PWM_CMP1) || \
  415. ((BLANKING) == CMP_BLANKINGSRC_TMR2_PWM_CMP1) || \
  416. ((BLANKING) == CMP_BLANKINGSRC_TMR3_PWM_CMP1) || \
  417. ((BLANKING) == CMP_BLANKINGSRC_TMR4_PWM_CMP1) || \
  418. ((BLANKING) == CMP_BLANKINGSRC_TMR5_PWM_CMP1) || \
  419. ((BLANKING) == CMP_BLANKINGSRC_TMR6_PWM_CMP1) || \
  420. ((BLANKING) == CMP_BLANKINGSRC_TMR7_PWM_CMP1))) \
  421. || \
  422. (((CHN) == CMP_CHANNEL_2) && \
  423. (((BLANKING) == CMP_BLANKINGSRC_NONE) || \
  424. ((BLANKING) == CMP_BLANKINGSRC_TMR0_PWM_CMP2) || \
  425. ((BLANKING) == CMP_BLANKINGSRC_TMR1_PWM_CMP2) || \
  426. ((BLANKING) == CMP_BLANKINGSRC_TMR2_PWM_CMP2) || \
  427. ((BLANKING) == CMP_BLANKINGSRC_TMR3_PWM_CMP2) || \
  428. ((BLANKING) == CMP_BLANKINGSRC_TMR4_PWM_CMP2) || \
  429. ((BLANKING) == CMP_BLANKINGSRC_TMR5_PWM_CMP2) || \
  430. ((BLANKING) == CMP_BLANKINGSRC_TMR6_PWM_CMP2))) \
  431. || \
  432. (((CHN) == CMP_CHANNEL_3) && \
  433. (((BLANKING) == CMP_BLANKINGSRC_NONE) || \
  434. ((BLANKING) == CMP_BLANKINGSRC_TMR1_PWM_CMP3) || \
  435. ((BLANKING) == CMP_BLANKINGSRC_TMR2_PWM_CMP3) || \
  436. ((BLANKING) == CMP_BLANKINGSRC_TMR3_PWM_CMP3) || \
  437. ((BLANKING) == CMP_BLANKINGSRC_TMR4_PWM_CMP3) || \
  438. ((BLANKING) == CMP_BLANKINGSRC_TMR5_PWM_CMP3) || \
  439. ((BLANKING) == CMP_BLANKINGSRC_TMR6_PWM_CMP3) || \
  440. ((BLANKING) == CMP_BLANKINGSRC_TMR7_PWM_CMP3))) \
  441. )
  442. /**
  443. * @brief Judge is CMP output debounce or not
  444. * @param DEB debounce to judge
  445. * @retval 0 isn't CMP output debounce
  446. * @retval 1 is CMP output debounce
  447. */
  448. #define IS_CMP_OUTPUT_DEBOUNCE(DEB) (((DEB) == CMP_OUTPUT_DEBOUNCE_DISABLE) || \
  449. ((DEB) == CMP_OUTPUT_DEBOUNCE_ENABLE))
  450. /**
  451. * @brief Jugdge is CMP output debounce value or not
  452. * @param VAL value to judge
  453. * @retval 0 isn't CMP output debounce value
  454. * @retval 1 is CMP output debounce value
  455. */
  456. #define IS_CMP_OUTPUT_DEBOUNCE_VAL(VAL) ((VAL) <= 0xFFFUL)
  457. /**
  458. * @brief Jugdge is CMP output debounce polarity or not
  459. * @param POL polarity to judge
  460. * @retval 0 isn't CMP output debounce polarity
  461. * @retval 1 is CMP output debounce polarity
  462. */
  463. #define IS_CMP_OUTPUT_POLARITY(POL) (((POL) == CMP_OUPUT_POLARITY_NON_INVERTED) || \
  464. ((POL) == CMP_OUPUT_POLARITY_INVERTED))
  465. /**
  466. * @brief Judge is CMP trigger interrupt or not
  467. * @param INTERRUPT trigger interrupt to judge
  468. * @retval 0 isn't CMP trigger interrupt
  469. * @retval 1 is CMP trigger interrupt
  470. */
  471. #define IS_CMP_TRIGGER_IT(INTERRUPT) (((INTERRUPT) == CMP_TRIGGER_IT_DISABLE) || \
  472. ((INTERRUPT) == CMP_TRIGGER_IT_FALLING) || \
  473. ((INTERRUPT) == CMP_TRIGGER_IT_RISING) || \
  474. ((INTERRUPT) == CMP_TRIGGER_IT_RISING_FALLING))
  475. /**
  476. * @}
  477. */
  478. /* Private types -------------------------------------------------------------*/
  479. /* Private variables ---------------------------------------------------------*/
  480. /* Private functions ---------------------------------------------------------*/
  481. /**
  482. * @}
  483. */
  484. /**
  485. * @}
  486. */
  487. #ifdef __cplusplus
  488. }
  489. #endif /* __cplusplus */
  490. #endif /* _TAE32F53XX_LL_CMP_H_ */
  491. /************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/