tae32f53xx_ll_dac.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. /**
  2. ******************************************************************************
  3. * @file tae32f53xx_ll_dac.h
  4. * @author MCD Application Team
  5. * @brief Header file for DAC 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_DAC_H_
  22. #define _TAE32F53XX_LL_DAC_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 DAC_LL
  32. * @{
  33. */
  34. /* Exported constants --------------------------------------------------------*/
  35. /** @defgroup DAC_LL_Exported_Constants DAC LL Exported Constants
  36. * @brief DAC LL Exported Constants
  37. * @{
  38. */
  39. /** @defgroup DAC_Channel_selection DAC Channel selection
  40. * @brief DAC Channel selection
  41. * @{
  42. */
  43. #define DAC_CHANNEL_0 (0x00000001U) /*!< DAC Channel 0 */
  44. #define DAC_CHANNEL_1 (0x00000002U) /*!< DAC Channel 1 */
  45. #define DAC_CHANNEL_2 (0x00000004U) /*!< DAC Channel 2 */
  46. #define DAC_CHANNEL_3 (0x00000008U) /*!< DAC Channel 3 */
  47. #define DAC_CHANNEL_ALL (DAC_CHANNEL_0 | DAC_CHANNEL_1 | DAC_CHANNEL_2 | DAC_CHANNEL_3 )
  48. /**
  49. * @}
  50. */
  51. /** @defgroup DAC_Interrupt_definition DAC Interrupt definition
  52. * @brief DAC Interrupt definition
  53. * @{
  54. */
  55. #define DAC_IT_DIE DAC_CR_DIE /*!< DAC_CHx DONE interrupt */
  56. #define DAC_IT_DBIE DAC_CR_DBIE /*!< DAC_CHx DONEB interrupt */
  57. /**
  58. * @}
  59. */
  60. /** @defgroup DAC_Flag_definition DAC Flag Definition
  61. * @{
  62. */
  63. #define DAC_FLAG_D0IF DAC_ISR_D0IF /*!< DAC Channel0 DONE pending flag */
  64. #define DAC_FLAG_D1IF DAC_ISR_D1IF /*!< DAC Channel1 DONE pending flag */
  65. #define DAC_FLAG_D2IF DAC_ISR_D2IF /*!< DAC Channel2 DONE pending flag */
  66. #define DAC_FLAG_D3IF DAC_ISR_D3IF /*!< DAC Channel0 DONE pending flag */
  67. #define DAC_FLAG_DB0IF DAC_ISR_DB0IF /*!< DAC Channel0 DONEB pending flag */
  68. #define DAC_FLAG_DB1IF DAC_ISR_DB1IF /*!< DAC Channel1 DONEB pending flag */
  69. #define DAC_FLAG_DB2IF DAC_ISR_DB2IF /*!< DAC Channel2 DONEB pending flag */
  70. #define DAC_FLAG_DB3IF DAC_ISR_DB3IF /*!< DAC Channel3 DONEB pending flag */
  71. #define DAC_FLAG_ALLIF (DAC_FLAG_D0IF | DAC_FLAG_D1IF | \
  72. DAC_FLAG_D2IF | DAC_FLAG_D3IF | \
  73. DAC_FLAG_DB0IF | DAC_FLAG_DB1IF | \
  74. DAC_FLAG_DB2IF | DAC_FLAG_DB3IF )
  75. /**
  76. * @}
  77. */
  78. /**
  79. * @}
  80. */
  81. /* Exported macro ------------------------------------------------------------*/
  82. /** @defgroup DAC_LL_Exported_Macros DAC LL Exported Macros
  83. * @brief DAC LL Exported Macros
  84. * @{
  85. */
  86. /**
  87. * @brief Enable DAC Channel
  88. * @param __INSTANCE__ DAC peripheral
  89. * @param __CHN_NB__ Specifies DAC Channel
  90. * This parameter can be a value of 0 to (DAC_CHN_NB - 1)
  91. * @return None
  92. */
  93. #define __LL_DAC_ENABLE(__INSTANCE__, __CHN_NB__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], DAC_CR_PEN)
  94. /**
  95. * @brief Disable DAC Channel
  96. * @param __INSTANCE__ DAC peripheral
  97. * @param __CHN_NB__ Specifies DAC Channel
  98. * This parameter can be a value of 0 to (DAC_CHN_NB - 1)
  99. * @return None
  100. */
  101. #define __LL_DAC_DISABLE(__INSTANCE__, __CHN_NB__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], DAC_CR_PEN)
  102. /**
  103. * @brief Enable DAC Channel Output to IO feature
  104. * @param __INSTANCE__ DAC peripheral
  105. * @param __CHN_NB__ Specifies DAC Channel
  106. * This parameter can be a value of 0 to (DAC_CHN_NB - 1)
  107. * @return None
  108. */
  109. #define __LL_DAC_OUTPUT_ENABLE(__INSTANCE__, __CHN_NB__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], DAC_CR_OEN)
  110. /**
  111. * @brief Disable DAC Channel Output to IO feature
  112. * @param __INSTANCE__ DAC peripheral
  113. * @param __CHN_NB__ Specifies DAC Channel
  114. * This parameter can be a value of 0 to (DAC_CHN_NB - 1)
  115. * @return None
  116. */
  117. #define __LL_DAC_OUTPUT_DISABLE(__INSTANCE__, __CHN_NB__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], DAC_CR_OEN)
  118. /**
  119. * @brief Enable the specified DAC Channel Interrupts
  120. * @param __INSTANCE__ DAC peripheral
  121. * @param __CHN_NB__ Specifies DAC Channel
  122. * This parameter can be a value of 0 to (DAC_CHN_NB - 1)
  123. * @param __INTERRUPT__ specifies the DAC Channel interrupt source to enable.
  124. * This parameter can be any combination of @ref DAC_Interrupt_definition:
  125. * @arg DAC_IT_DIE : DAC_CHx DONE interrupt
  126. * @arg DAC_IT_DBIE : DAC_CHx DONEB interrupt
  127. * @return None
  128. */
  129. #define __LL_DAC_IT_ENABLE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], __INTERRUPT__)
  130. /**
  131. * @brief Disable the specified DAC Channel Interrupts
  132. * @param __INSTANCE__ DAC peripheral
  133. * @param __CHN_NB__ Specifies DAC Channel
  134. * This parameter can be a value of 0 to (DAC_CHN_NB - 1)
  135. * @param __INTERRUPT__ specifies the DAC Channel interrupt source to disable.
  136. * This parameter can be any combination of @ref DAC_Interrupt_definition:
  137. * @arg DAC_IT_DIE : DAC_CHx DONE interrupt
  138. * @arg DAC_IT_DBIE : DAC_CHx DONEB interrupt
  139. * @return None
  140. */
  141. #define __LL_DAC_IT_DISABLE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], __INTERRUPT__)
  142. /**
  143. * @brief Check whether the specified DAC Channel interrupt source is set or not.
  144. * @param __INSTANCE__ DAC peripheral
  145. * @param __CHN_NB__ Specifies DAC Channel
  146. * This parameter can be a value of 0 to (DAC_CHN_NB - 1)
  147. * @param __INTERRUPT__ specifies the DAC Channel interrupt source to check.
  148. * This parameter can be ONE of @ref DAC_Interrupt_definition:
  149. * @arg DAC_IT_DIE : DAC_CHx DONE interrupt
  150. * @arg DAC_IT_DBIE : DAC_CHx DONEB interrupt
  151. * @return None
  152. */
  153. #define __LL_DAC_IT_CHECK_SOURCE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) \
  154. ((READ_BIT((__INSTANCE__)->CR[__CHN_NB__], (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  155. /**
  156. * @brief Check whether the specified pending flag is SET or not.
  157. * @param __INSTANCE__ DAC peripheral.
  158. * @param __FLAG__ specifies the DAC pending flag to check.
  159. * This parameter can be ONE of the following values where x can be a value of
  160. * 0, 1 ... (DAC_CHN_NB - 1):
  161. * @arg DAC_FLAG_DxIF : DAC_CHx DONE interrupt pending flag
  162. * @arg DAC_FLAG_DBxIF : DAC_CHx DONEB interrupt pending flag
  163. * @return The new state of __FLAG__ (SET or RESET).
  164. */
  165. #define __LL_DAC_PENDING_FLAG_GET(__INSTANCE__, __FLAG__) \
  166. ((READ_BIT((__INSTANCE__)->ISR, (__FLAG__)) == (__FLAG__)) ? SET : RESET)
  167. /**
  168. * @brief Clear the specified pending flags
  169. * @param __INSTANCE__ DAC peripheral.
  170. * @param __FLAG__ specifies the DAC pending flag to clear.
  171. * This parameter can be any combination of the following values where x can be a value of
  172. * 0, 1 ... (DAC_CHN_NB - 1):
  173. * @arg DAC_FLAG_DxIF : DAC_CHx DONE interrupt pending flag
  174. * @arg DAC_FLAG_DBxIF : DAC_CHx DONEB interrupt pending flag
  175. * @arg DAC_FLAG_ALLIF : DAC All interrupt pending flags
  176. * @return None
  177. */
  178. #define __LL_DAC_PENDING_FLAG_CLEAR(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->ISR, (__FLAG__))
  179. /**
  180. * @brief Set the data for DAC channel conversion on runtime
  181. * @param __INSTANCE__ DAC peripheral.
  182. * @param __CHN_NB__ Specifies DAC Channel
  183. * This parameter can be a value of 0 to (DAC_CHN_NB - 1)
  184. * @param __DATA__ Data to be loaded
  185. * @return None
  186. */
  187. #define __LL_DAC_SET_VALUE(__INSTANCE__, __CHN_NB__, __DATA__) WRITE_REG((__INSTANCE__)->WDR[__CHN_NB__], __DATA__)
  188. /**
  189. * @brief Get the DAC channel conversion value on runtime
  190. * @param __INSTANCE__ DAC peripheral.
  191. * @param __CHN_NB__ Specifies DAC Channel
  192. * This parameter can be a value of 0 to (DAC_CHN_NB - 1)
  193. * @return Conversion value
  194. */
  195. #define __LL_DAC_GET_VALUE(__INSTANCE__, __CHN_NB__) READ_REG((__INSTANCE__)->RDR[__CHN_NB__])
  196. /**
  197. * @}
  198. */
  199. /* Exported types ------------------------------------------------------------*/
  200. /** @defgroup DAC_LL_Exported_Types DAC LL Exported Types
  201. * @brief DAC LL Exported Types
  202. * @{
  203. */
  204. /**
  205. * @brief DAC Channel Output
  206. */
  207. typedef enum {
  208. DAC_CHANNEL_OUTPUT_DISABLE = 0x00000000U, /*!< DAC Channel Disable */
  209. DAC_CHANNEL_OUTPUT_ENABLE = DAC_CR_OEN, /*!< DAC Channel Enable */
  210. } DAC_OutputEnETypedef;
  211. /**
  212. * @brief DAC Channel Interrupt Done
  213. */
  214. typedef enum {
  215. DAC_CHANNEL_DONE_IT_DISABLE = 0x00000000U, /*!< DAC Channel Done Interrupt Disable */
  216. DAC_CHANNEL_DONE_IT_ENABLE = DAC_CR_DIE, /*!< DAC Channel Done Interrupt Enable */
  217. } DAC_DoneITEnETypedef;
  218. /**
  219. * @brief DAC Channel Interrupt DoneB
  220. */
  221. typedef enum {
  222. DAC_CHANNEL_DONEB_IT_DISABLE = 0x00000000U, /*!< DAC Channel DoneB Interrupt Disable */
  223. DAC_CHANNEL_DONEB_IT_ENABLE = DAC_CR_DBIE, /*!< DAC Channel DoneB Interrupt Enable */
  224. } DAC_DoneBITEnETypedef;
  225. /**
  226. * @brief DAC Sawtooth Polarity
  227. */
  228. typedef enum {
  229. DAC_SAWTOOTH_POLARITY_DEC = 0x00000000U, /*!< Sawtooth wave generation, polarity is decrement */
  230. DAC_SAWTOOTH_POLARITY_INC = DAC_CR_STDIR, /*!< Sawtooth wave generation, polarity is increment */
  231. } DAC_SawthoothPolETypedef;
  232. /**
  233. * @brief DAC Triangle Initial Direction
  234. */
  235. typedef enum {
  236. DAC_TRIANGLE_INITIALDIRECTION_DEC = 0x00000000U, /*!< Triangle wave generation, initial direction is decrement */
  237. DAC_TRIANGLE_INITIALDIRECTION_INC = DAC_CR_TGDIR, /*!< Triangle wave generation, initial direction is increment */
  238. } DAC_TriangleInitDirETypedef;
  239. /**
  240. * @brief DAC Triangle Amplitude
  241. */
  242. typedef enum {
  243. DAC_TRIANGLE_AMPLITUDE_1 = 0x00000000U, /*!< Amplitude of 1 */
  244. DAC_TRIANGLE_AMPLITUDE_3 = DAC_CR_TGAMP_0, /*!< Amplitude of 3 */
  245. DAC_TRIANGLE_AMPLITUDE_7 = DAC_CR_TGAMP_1, /*!< Amplitude of 7 */
  246. DAC_TRIANGLE_AMPLITUDE_15 = DAC_CR_TGAMP_1 | DAC_CR_TGAMP_0, /*!< Amplitude of 15 */
  247. DAC_TRIANGLE_AMPLITUDE_31 = DAC_CR_TGAMP_2, /*!< Amplitude of 31 */
  248. DAC_TRIANGLE_AMPLITUDE_63 = DAC_CR_TGAMP_2 | DAC_CR_TGAMP_0, /*!< Amplitude of 63 */
  249. DAC_TRIANGLE_AMPLITUDE_127 = DAC_CR_TGAMP_2 | DAC_CR_TGAMP_1, /*!< Amplitude of 127 */
  250. DAC_TRIANGLE_AMPLITUDE_255 = DAC_CR_TGAMP_2 | DAC_CR_TGAMP_1 | DAC_CR_TGAMP_0, /*!< Amplitude of 255 */
  251. DAC_TRIANGLE_AMPLITUDE_511 = DAC_CR_TGAMP_3, /*!< Amplitude of 511 */
  252. DAC_TRIANGLE_AMPLITUDE_1023 = DAC_CR_TGAMP_3 | DAC_CR_TGAMP_0, /*!< Amplitude of 1023 */
  253. DAC_TRIANGLE_AMPLITUDE_2047 = DAC_CR_TGAMP_3 | DAC_CR_TGAMP_1, /*!< Amplitude of 2047 */
  254. DAC_TRIANGLE_AMPLITUDE_4095 = DAC_CR_TGAMP_3 | DAC_CR_TGAMP_1 | DAC_CR_TGAMP_0, /*!< Amplitude of 4095 */
  255. } DAC_TrangleAmplETypedef;
  256. /**
  257. * @brief DAC Trigger Selection
  258. */
  259. typedef enum {
  260. DAC_TRIGGER_SOFTWARE = 0x0U, /*!< Software trigger by setting bit[s] in DAC_SWTR register */
  261. DAC_TRIGGER_TMR0_TRGO = 0x1U, /*!< TRGO signal exported from TMR0 (source from Update Event) */
  262. DAC_TRIGGER_TMR1_TRGO = 0x2U, /*!< TRGO signal exported from TMR1 (source from Update Event) */
  263. DAC_TRIGGER_TMR2_TRGO = 0x3U, /*!< TRGO signal exported from TMR2 (source from Update Event) */
  264. DAC_TRIGGER_TMR3_TRGO = 0x3U, /*!< TRGO signal exported from TMR3 (source from Update Event) */
  265. DAC_TRIGGER_TMR4_TRGO = 0x4U, /*!< TRGO signal exported from TMR4 (source from Update Event) */
  266. DAC_TRIGGER_TMR5_TRGO = 0x5U, /*!< TRGO signal exported from TMR5 (source from Update Event) */
  267. DAC_TRIGGER_TMR6_TRGO = 0x6U, /*!< TRGO signal exported from TMR6 (source from Update Event) */
  268. DAC_TRIGGER_TMR7_TRGO = 0x7U, /*!< TRGO signal exported from TMR7 (source from Update Event) */
  269. DAC_TRIGGER_HRPWM_DAC_RESET_TRG0 = 0x8U, /*!< DAC Reset Trigger event from HRPWM Slave timer0 */
  270. DAC_TRIGGER_HRPWM_DAC_RESET_TRG1 = 0x9U, /*!< DAC Reset Trigger event from HRPWM Slave timer1 */
  271. DAC_TRIGGER_HRPWM_DAC_RESET_TRG2 = 0xAU, /*!< DAC Reset Trigger event from HRPWM Slave timer2 */
  272. DAC_TRIGGER_HRPWM_DAC_RESET_TRG3 = 0xBU, /*!< DAC Reset Trigger event from HRPWM Slave timer3 */
  273. DAC_TRIGGER_HRPWM_DAC_RESET_TRG4 = 0xCU, /*!< DAC Reset Trigger event from HRPWM Slave timer4 */
  274. DAC_TRIGGER_HRPWM_DAC_RESET_TRG5 = 0xDU, /*!< DAC Reset Trigger event from HRPWM Slave timer5 */
  275. DAC_TRIGGER_HRPWM_DAC_STEP_TRG0 = 0x8U, /*!< DAC Step Trigger event from HRPWM Slave timer0 */
  276. DAC_TRIGGER_HRPWM_DAC_STEP_TRG1 = 0x9U, /*!< DAC Step Trigger event from HRPWM Slave timer1 */
  277. DAC_TRIGGER_HRPWM_DAC_STEP_TRG2 = 0xAU, /*!< DAC Step Trigger event from HRPWM Slave timer2 */
  278. DAC_TRIGGER_HRPWM_DAC_STEP_TRG3 = 0xBU, /*!< DAC Step Trigger event from HRPWM Slave timer3 */
  279. DAC_TRIGGER_HRPWM_DAC_STEP_TRG4 = 0xCU, /*!< DAC Step Trigger event from HRPWM Slave timer4 */
  280. DAC_TRIGGER_HRPWM_DAC_STEP_TRG5 = 0xDU, /*!< DAC Step Trigger event from HRPWM Slave timer5 */
  281. DAC_TRIGGER_HRPWM_ADC_TRG0 = 0xEU, /*!< DAC0 Step Trigger event from HRPWM Common ADDA Trigger 0 */
  282. DAC_TRIGGER_HRPWM_ADC_TRG1 = 0xEU, /*!< DAC1 Step Trigger event from HRPWM Common ADDA Trigger 1 */
  283. DAC_TRIGGER_HRPWM_ADC_TRG2 = 0xEU, /*!< DAC2 Step Trigger event from HRPWM Common ADDA Trigger 2 */
  284. DAC_TRIGGER_HRPWM_ADC_TRG3 = 0xEU, /*!< DAC3 Step Trigger event from HRPWM Common ADDA Trigger 3 */
  285. DAC_TRIGGER_HRPWM_ADC_TRG4 = 0xEU, /*!< DAC0 Reset Trigger event from HRPWM Common ADDA Trigger 4 */
  286. DAC_TRIGGER_HRPWM_ADC_TRG5 = 0xEU, /*!< DAC1 Reset Trigger event from HRPWM Common ADDA Trigger 5 */
  287. DAC_TRIGGER_HRPWM_ADC_TRG6 = 0xEU, /*!< DAC2 Reset Trigger event from HRPWM Common ADDA Trigger 6 */
  288. DAC_TRIGGER_HRPWM_ADC_TRG7 = 0xEU, /*!< DAC3 Reset Trigger event from HRPWM Common ADDA Trigger 7 */
  289. DAC_TRIGGER_EXTERNAL_INPUT_IO1 = 0xFU, /*!< DAC External Trigger from IO1, please see SPEC from more details */
  290. DAC_TRIGGER_EXTERNAL_INPUT_IO2 = 0xFU, /*!< DAC External Trigger from IO2, please see SPEC from more details */
  291. } DAC_TriggerSrcETypedef;
  292. /**
  293. * @brief DAC Channel Configuration structure definition
  294. */
  295. typedef struct __DAC_ChannelConfTypeDef {
  296. DAC_OutputEnETypedef Output; /*!< Specifies the DAC conversion output to IO or not. */
  297. uint32_t DoneIntPending; /*!< Specifies the interrupt for DONE pending flag enable or disable
  298. This parameter can be a value of @ref DAC_Channel_Interrupt_Done
  299. Note: Sawtooth Reset or Tranigle Step convert done will trigger the DONE flag */
  300. uint32_t DoneBIntPending; /*!< Specifies the interrupt for DONEB pending flag enable or disable
  301. This parameter can be a value of @ref DAC_Channel_Interrupt_DoneB
  302. Note: Sawtooth Step convert done will trigger the DONEB flag */
  303. } DAC_ChannelConfTypeDef;
  304. /**
  305. * @brief DAC Sawtooth Wave Configuration structure definition
  306. */
  307. typedef struct __DAC_SawtoothConfTypeDef {
  308. uint16_t ResetData; /*!< Specifies the Sawtooth wave Reset value.
  309. This parameter can be a number in range from 0 to DAC full range 4095(0xFFF) */
  310. uint16_t StepData; /*!< Specifies the Sawtooth wave step value.
  311. 12.4 bit format, unsigned: 12 bits exponent / 4 bits mantissa
  312. Step value step is 1/16 = 0.0625
  313. Step value range is 0.0000 to 4095.9375 (0xFFF.F) */
  314. DAC_TriggerSrcETypedef ResetTrigger; /*!< Specifies the external trigger source for the Sawtooth wave reset trigger
  315. Please see the SPEC Document for more details about the trigger selections */
  316. DAC_TriggerSrcETypedef StepTrigger; /*!< Specifies the external trigger source for the Sawtooth wave step trigger
  317. Please see the SPEC Document for more details about the trigger selections */
  318. DAC_SawthoothPolETypedef Polarity; /*!< Specifies the Sawtooth wave step polarity.*/
  319. } DAC_SawtoothConfTypeDef;
  320. /**
  321. * @brief DAC Triangle Wave Configuration structure definition
  322. */
  323. typedef struct __DAC_TriangleConfTypeDef {
  324. DAC_TriangleInitDirETypedef InitialDirection; /*!< Specifies the Triangle wave initial step direction. */
  325. DAC_TrangleAmplETypedef Amplitude; /*!< Specifies max triangle amplitude. */
  326. DAC_TriggerSrcETypedef StepTrigger; /*!< Specifies the external trigger source for the Triangle wave step trigger
  327. Please see the SPEC Document for more details about the trigger selections */
  328. } DAC_TriangleConfTypeDef;
  329. /**
  330. * @}
  331. */
  332. /* Exported functions --------------------------------------------------------*/
  333. /** @addtogroup DAC_LL_Exported_Functions
  334. * @{
  335. */
  336. /** @addtogroup DAC_LL_Exported_Functions_Group1
  337. * @{
  338. */
  339. LL_StatusETypeDef LL_DAC_Init(DAC_TypeDef *Instance);
  340. LL_StatusETypeDef LL_DAC_DeInit(DAC_TypeDef *Instance);
  341. void LL_DAC_MspInit(DAC_TypeDef *Instance);
  342. void LL_DAC_MspDeInit(DAC_TypeDef *Instance);
  343. /**
  344. * @}
  345. */
  346. /** @addtogroup DAC_LL_Exported_Functions_Group2
  347. * @{
  348. */
  349. LL_StatusETypeDef LL_DAC_ChannelConfig(DAC_TypeDef *Instance, uint32_t Channel, DAC_ChannelConfTypeDef *sConfig);
  350. LL_StatusETypeDef LL_DAC_SawtoothWaveGenerate(DAC_TypeDef *Instance, uint32_t Channel, DAC_SawtoothConfTypeDef *sConfig);
  351. LL_StatusETypeDef LL_DAC_TriangleWaveGenerate(DAC_TypeDef *Instance, uint32_t Channel, DAC_TriangleConfTypeDef *sConfig);
  352. /**
  353. * @}
  354. */
  355. /** @addtogroup DAC_LL_Exported_Functions_Group3
  356. * @{
  357. */
  358. LL_StatusETypeDef LL_DAC_Start(DAC_TypeDef *Instance, uint32_t Channel);
  359. LL_StatusETypeDef LL_DAC_Stop(DAC_TypeDef *Instance, uint32_t Channel);
  360. LL_StatusETypeDef LL_DAC_SetValue(DAC_TypeDef *Instance, uint32_t Channel, uint16_t Data);
  361. uint16_t LL_DAC_GetValue(DAC_TypeDef *Instance, uint32_t Channel);
  362. LL_StatusETypeDef LL_DAC_SawtoothWaveDataStep(DAC_TypeDef *Instance, uint32_t Channel);
  363. LL_StatusETypeDef LL_DAC_SawtoothWaveDataReset(DAC_TypeDef *Instance, uint32_t Channel);
  364. LL_StatusETypeDef LL_DAC_TriangleWaveStep(DAC_TypeDef *Instance, uint32_t Channel);
  365. /**
  366. * @}
  367. */
  368. /** @addtogroup DAC_LL_Exported_Functions_Interrupt
  369. * @{
  370. */
  371. void LL_DAC_IRQHandler(DAC_TypeDef *Instance);
  372. void LL_DAC_ConvDoneCallback(DAC_TypeDef *Instance, uint32_t Channel);
  373. void LL_DAC_ConvDoneBCallback(DAC_TypeDef *Instance, uint32_t Channel);
  374. /**
  375. * @}
  376. */
  377. /**
  378. * @}
  379. */
  380. /* Private constants ---------------------------------------------------------*/
  381. /* Private macros ------------------------------------------------------------*/
  382. /** @defgroup DAC_LL_Private_Macros DAC LL Private Macros
  383. * @brief DAC LL Private Macros
  384. * @{
  385. */
  386. /**
  387. * @brief Judge is DAC channel number or not
  388. * @param CHN_NB channel number to judge
  389. * @retval 0 isn't DAC channel number
  390. * @retval 1 is DAC channel number
  391. */
  392. #define IS_DAC_NUMBER(CHN_NB) ((CHN_NB) < DAC_CHN_NB)
  393. /**
  394. * @brief Judge is DAC channel or not
  395. * @param CHN channel to judge
  396. * @retval 0 isn't DAC channel
  397. * @retval 1 is DAC channel
  398. */
  399. #define IS_DAC_CHANNEL(CHN) (((CHN) == DAC_CHANNEL_0) || \
  400. ((CHN) == DAC_CHANNEL_1) || \
  401. ((CHN) == DAC_CHANNEL_2) || \
  402. ((CHN) == DAC_CHANNEL_3))
  403. /**
  404. * @brief Judge is DAC channels mask or not
  405. * @param CHN channels mask to judge
  406. * @retval 0 isn't DAC channels mask
  407. * @retval 1 is DAC channels mask
  408. */
  409. #define IS_DAC_CHANNELS_MASK(CHN) ((((CHN) & DAC_CHANNEL_ALL) != 0x00UL) && \
  410. (((CHN) & ~(DAC_CHANNEL_ALL)) == 0x00UL))
  411. /**
  412. * @brief Judge is DAC channel output select or not
  413. * @param OUTPUT output select
  414. * @retval 0 isn't DAC channel output select
  415. * @retval 1 is DAC channel output select
  416. */
  417. #define IS_DAC_CHANNEL_OUTPUT_SEL(OUTPUT) (((OUTPUT) == DAC_CHANNEL_OUTPUT_DISABLE) || \
  418. ((OUTPUT) == DAC_CHANNEL_OUTPUT_ENABLE))
  419. /**
  420. * @brief Judge is DAC channel done interrupt pending config or not
  421. * @param PENDING pending config to judge
  422. * @retval 0 isn't DAC channel done interrupt pending config
  423. * @retval 1 is DAC channel done interrupt pending config
  424. */
  425. #define IS_DAC_CHANNEL_DONE_IT_PENDING_CFG(PENDING) (((PENDING) == DAC_CHANNEL_DONE_IT_DISABLE) || \
  426. ((PENDING) == DAC_CHANNEL_DONE_IT_ENABLE))
  427. /**
  428. * @brief Judge is DAC channel doneB interrupt pending config or not
  429. * @param PENDING pending config to judge
  430. * @retval 0 isn't DAC channel doneB interrupt pending config
  431. * @retval 1 is DAC channel doneB interrupt pending config
  432. */
  433. #define IS_DAC_CHANNEL_DONEB_IT_PENDING_CFG(PENDING) (((PENDING) == DAC_CHANNEL_DONEB_IT_DISABLE) || \
  434. ((PENDING) == DAC_CHANNEL_DONEB_IT_ENABLE))
  435. /**
  436. * @brief Judge is DAC sawtooth reset data or not
  437. * @param DATA data to judge
  438. * @retval 0 isn't DAC sawtooth reset data
  439. * @retval 1 is DAC sawtooth reset data
  440. */
  441. #define IS_DAC_SAWTOOTH_RESET_DATA(DATA) ((DATA) <= 0xFFFUL)
  442. /**
  443. * @brief Judge is DAC sawtooth step data or not
  444. * @param DATA data to judge
  445. * @retval 0 isn't DAC sawtooth step data
  446. * @retval 1 is DAC sawtooth step data
  447. */
  448. #define IS_DAC_SAWTOOTH_STEP_DATA(DATA) ((DATA) <= 0xFFFFUL)
  449. /**
  450. * @brief Judge is DAC sawtooth reset trigger or not
  451. * @param TRIGGER trigger to judge
  452. * @retval 0 isn't DAC sawtooth reset trigger
  453. * @retval 1 is DAC sawtooth reset trigger
  454. */
  455. #define IS_DAC_SAWTOOTH_RESET_TRIGGER(TRIGGER) ((TRIGGER) < 16U)
  456. /**
  457. * @brief Judge is DAC sawtooth step trigger or not
  458. * @param TRIGGER trigger to judge
  459. * @retval 0 isn't DAC sawtooth step trigger
  460. * @retval 1 is DAC sawtooth step trigger
  461. */
  462. #define IS_DAC_SAWTOOTH_STEP_TRIGGER(TRIGGER) ((TRIGGER) < 16U)
  463. /**
  464. * @brief Judge is DAC sawtooth polarity or not
  465. * @param POLARITY polarity to judge
  466. * @retval 0 isn't DAC sawtooth polarity
  467. * @retval 1 is DAC sawtooth polarity
  468. */
  469. #define IS_DAC_SAWTOOTH_POLARITY(POLARITY) (((POLARITY) == DAC_SAWTOOTH_POLARITY_DEC) || \
  470. ((POLARITY) == DAC_SAWTOOTH_POLARITY_INC))
  471. /**
  472. * @brief Judge is DAC triangle initial direction or not
  473. * @param DIR direction to judge
  474. * @retval 0 isn't DAC triangle initial direction
  475. * @retval 1 is DAC triangle initial direction
  476. */
  477. #define IS_DAC_TRIANGLE_INITIALDIRECTION(DIR) (((DIR) == DAC_TRIANGLE_INITIALDIRECTION_DEC) || \
  478. ((DIR) == DAC_TRIANGLE_INITIALDIRECTION_INC))
  479. /**
  480. * @brief Judge is DAC triangle amplitude or not
  481. * @param AMP amplitude to judge
  482. * @retval 0 isn't DAC triangle amplitude
  483. * @retval 1 is DAC triangle amplitude
  484. */
  485. #define IS_DAC_TRIANGLE_AMPLITUDE(AMP) (((AMP) == DAC_TRIANGLE_AMPLITUDE_1) || \
  486. ((AMP) == DAC_TRIANGLE_AMPLITUDE_3) || \
  487. ((AMP) == DAC_TRIANGLE_AMPLITUDE_7) || \
  488. ((AMP) == DAC_TRIANGLE_AMPLITUDE_15) || \
  489. ((AMP) == DAC_TRIANGLE_AMPLITUDE_31) || \
  490. ((AMP) == DAC_TRIANGLE_AMPLITUDE_63) || \
  491. ((AMP) == DAC_TRIANGLE_AMPLITUDE_127) || \
  492. ((AMP) == DAC_TRIANGLE_AMPLITUDE_255) || \
  493. ((AMP) == DAC_TRIANGLE_AMPLITUDE_511) || \
  494. ((AMP) == DAC_TRIANGLE_AMPLITUDE_1023) || \
  495. ((AMP) == DAC_TRIANGLE_AMPLITUDE_2047) || \
  496. ((AMP) == DAC_TRIANGLE_AMPLITUDE_4095))
  497. /**
  498. * @brief Judge is DAC triangle step trigger or not
  499. * @param TRIGGER trigger to judge
  500. * @retval 0 isn't DAC triangle step trigger
  501. * @retval 1 is DAC triangle step trigger
  502. */
  503. #define IS_DAC_TRIANGLE_STEP_TRIGGER(TRIGGER) ((TRIGGER) < 16U)
  504. /**
  505. * @}
  506. */
  507. /* Private types -------------------------------------------------------------*/
  508. /* Private variables ---------------------------------------------------------*/
  509. /* Private functions ---------------------------------------------------------*/
  510. /**
  511. * @}
  512. */
  513. /**
  514. * @}
  515. */
  516. #ifdef __cplusplus
  517. }
  518. #endif /* __cplusplus */
  519. #endif /* _TAE32F53XX_LL_DAC_H_ */
  520. /************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/