1
0

stm32l4xx_ll_dac.h 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_ll_dac.h
  4. * @author MCD Application Team
  5. * @version V1.7.2
  6. * @date 16-June-2017
  7. * @brief Header file of DAC 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_DAC_H
  39. #define __STM32L4xx_LL_DAC_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 (DAC1)
  49. /** @defgroup DAC_LL DAC
  50. * @{
  51. */
  52. /* Private types -------------------------------------------------------------*/
  53. /* Private variables ---------------------------------------------------------*/
  54. /* Private constants ---------------------------------------------------------*/
  55. /** @defgroup DAC_LL_Private_Constants DAC Private Constants
  56. * @{
  57. */
  58. /* Internal masks for DAC channels definition */
  59. /* To select into literal LL_DAC_CHANNEL_x the relevant bits for: */
  60. /* - channel bits position into registers CR, MCR, CCR, SHHR, SHRR */
  61. /* - channel bits position into register SWTRIG */
  62. /* - channel register offset of data holding register DHRx */
  63. /* - channel register offset of data output register DORx */
  64. /* - channel register offset of sample-and-hold sample time register SHSRx */
  65. #define DAC_CR_CH1_BITOFFSET 0U /* Position of channel bits into registers CR, MCR, CCR, SHHR, SHRR of channel 1 */
  66. #define DAC_CR_CH2_BITOFFSET 16U /* Position of channel bits into registers CR, MCR, CCR, SHHR, SHRR of channel 2 */
  67. #define DAC_CR_CHX_BITOFFSET_MASK (DAC_CR_CH1_BITOFFSET | DAC_CR_CH2_BITOFFSET)
  68. #define DAC_SWTR_CH1 (DAC_SWTRIGR_SWTRIG1) /* Channel bit into register SWTRIGR of channel 1. This bit is into area of LL_DAC_CR_CHx_BITOFFSET but excluded by mask DAC_CR_CHX_BITOFFSET_MASK (done to be enable to trig SW start of both DAC channels simultaneously). */
  69. #if defined(DAC_CHANNEL2_SUPPORT)
  70. #define DAC_SWTR_CH2 (DAC_SWTRIGR_SWTRIG2) /* Channel bit into register SWTRIGR of channel 2. This bit is into area of LL_DAC_CR_CHx_BITOFFSET but excluded by mask DAC_CR_CHX_BITOFFSET_MASK (done to be enable to trig SW start of both DAC channels simultaneously). */
  71. #define DAC_SWTR_CHX_MASK (DAC_SWTR_CH1 | DAC_SWTR_CH2)
  72. #else
  73. #define DAC_SWTR_CHX_MASK (DAC_SWTR_CH1)
  74. #endif /* DAC_CHANNEL2_SUPPORT */
  75. #define DAC_REG_DHR12R1_REGOFFSET 0x00000000U /* Register DHR12Rx channel 1 taken as reference */
  76. #define DAC_REG_DHR12L1_REGOFFSET 0x00100000U /* Register offset of DHR12Lx channel 1 versus DHR12Rx channel 1 (shifted left of 20 bits) */
  77. #define DAC_REG_DHR8R1_REGOFFSET 0x02000000U /* Register offset of DHR8Rx channel 1 versus DHR12Rx channel 1 (shifted left of 24 bits) */
  78. #if defined(DAC_CHANNEL2_SUPPORT)
  79. #define DAC_REG_DHR12R2_REGOFFSET 0x00030000U /* Register offset of DHR12Rx channel 2 versus DHR12Rx channel 1 (shifted left of 16 bits) */
  80. #define DAC_REG_DHR12L2_REGOFFSET 0x00400000U /* Register offset of DHR12Lx channel 2 versus DHR12Rx channel 1 (shifted left of 20 bits) */
  81. #define DAC_REG_DHR8R2_REGOFFSET 0x05000000U /* Register offset of DHR8Rx channel 2 versus DHR12Rx channel 1 (shifted left of 24 bits) */
  82. #endif /* DAC_CHANNEL2_SUPPORT */
  83. #define DAC_REG_DHR12RX_REGOFFSET_MASK 0x000F0000U
  84. #define DAC_REG_DHR12LX_REGOFFSET_MASK 0x00F00000U
  85. #define DAC_REG_DHR8RX_REGOFFSET_MASK 0x0F000000U
  86. #define DAC_REG_DHRX_REGOFFSET_MASK (DAC_REG_DHR12RX_REGOFFSET_MASK | DAC_REG_DHR12LX_REGOFFSET_MASK | DAC_REG_DHR8RX_REGOFFSET_MASK)
  87. #define DAC_REG_DOR1_REGOFFSET 0x00000000U /* Register DORx channel 1 taken as reference */
  88. #if defined(DAC_CHANNEL2_SUPPORT)
  89. #define DAC_REG_DOR2_REGOFFSET 0x10000000U /* Register offset of DORx channel 1 versus DORx channel 2 (shifted left of 28 bits) */
  90. #define DAC_REG_DORX_REGOFFSET_MASK (DAC_REG_DOR1_REGOFFSET | DAC_REG_DOR2_REGOFFSET)
  91. #else
  92. #define DAC_REG_DORX_REGOFFSET_MASK (DAC_REG_DOR1_REGOFFSET)
  93. #endif /* DAC_CHANNEL2_SUPPORT */
  94. #define DAC_REG_SHSR1_REGOFFSET 0x00000000U /* Register SHSRx channel 1 taken as reference */
  95. #if defined(DAC_CHANNEL2_SUPPORT)
  96. #define DAC_REG_SHSR2_REGOFFSET 0x00001000U /* Register offset of SHSRx channel 1 versus SHSRx channel 2 (shifted left of 12 bits) */
  97. #define DAC_REG_SHSRX_REGOFFSET_MASK (DAC_REG_SHSR1_REGOFFSET | DAC_REG_SHSR2_REGOFFSET)
  98. #else
  99. #define DAC_REG_SHSRX_REGOFFSET_MASK (DAC_REG_SHSR1_REGOFFSET)
  100. #endif /* DAC_CHANNEL2_SUPPORT */
  101. /* DAC registers bits positions */
  102. #if defined(DAC_CHANNEL2_SUPPORT)
  103. #define DAC_DHR12RD_DACC2DHR_BITOFFSET_POS 16U /* Value equivalent to POSITION_VAL(DAC_DHR12RD_DACC2DHR) */
  104. #define DAC_DHR12LD_DACC2DHR_BITOFFSET_POS 20U /* Value equivalent to POSITION_VAL(DAC_DHR12LD_DACC2DHR) */
  105. #define DAC_DHR8RD_DACC2DHR_BITOFFSET_POS 8U /* Value equivalent to POSITION_VAL(DAC_DHR8RD_DACC2DHR) */
  106. #endif /* DAC_CHANNEL2_SUPPORT */
  107. /* Miscellaneous data */
  108. #define DAC_DIGITAL_SCALE_12BITS 4095U /* Full-scale digital value with a resolution of 12 bits (voltage range determined by analog voltage references Vref+ and Vref-, refer to reference manual) */
  109. /**
  110. * @}
  111. */
  112. /* Private macros ------------------------------------------------------------*/
  113. /** @defgroup DAC_LL_Private_Macros DAC Private Macros
  114. * @{
  115. */
  116. /**
  117. * @brief Driver macro reserved for internal use: isolate bits with the
  118. * selected mask and shift them to the register LSB
  119. * (shift mask on register position bit 0).
  120. * @param __BITS__ Bits in register 32 bits
  121. * @param __MASK__ Mask in register 32 bits
  122. * @retval Bits in register 32 bits
  123. */
  124. #define __DAC_MASK_SHIFT(__BITS__, __MASK__) \
  125. (((__BITS__) & (__MASK__)) >> POSITION_VAL((__MASK__)))
  126. /**
  127. * @brief Driver macro reserved for internal use: set a pointer to
  128. * a register from a register basis from which an offset
  129. * is applied.
  130. * @param __REG__ Register basis from which the offset is applied.
  131. * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
  132. * @retval Pointer to register address
  133. */
  134. #define __DAC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
  135. ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
  136. /**
  137. * @}
  138. */
  139. /* Exported types ------------------------------------------------------------*/
  140. #if defined(USE_FULL_LL_DRIVER)
  141. /** @defgroup DAC_LL_ES_INIT DAC Exported Init structure
  142. * @{
  143. */
  144. /**
  145. * @brief Structure definition of some features of DAC instance.
  146. */
  147. typedef struct
  148. {
  149. uint32_t TriggerSource; /*!< Set the conversion trigger source for the selected DAC channel: internal (SW start) or from external IP (timer event, external interrupt line).
  150. This parameter can be a value of @ref DAC_LL_EC_TRIGGER_SOURCE
  151. This feature can be modified afterwards using unitary function @ref LL_DAC_SetTriggerSource(). */
  152. uint32_t WaveAutoGeneration; /*!< Set the waveform automatic generation mode for the selected DAC channel.
  153. This parameter can be a value of @ref DAC_LL_EC_WAVE_AUTO_GENERATION_MODE
  154. This feature can be modified afterwards using unitary function @ref LL_DAC_SetWaveAutoGeneration(). */
  155. uint32_t WaveAutoGenerationConfig; /*!< Set the waveform automatic generation mode for the selected DAC channel.
  156. If waveform automatic generation mode is set to noise, this parameter can be a value of @ref DAC_LL_EC_WAVE_NOISE_LFSR_UNMASK_BITS
  157. If waveform automatic generation mode is set to triangle, this parameter can be a value of @ref DAC_LL_EC_WAVE_TRIANGLE_AMPLITUDE
  158. @note If waveform automatic generation mode is disabled, this parameter is discarded.
  159. This feature can be modified afterwards using unitary function @ref LL_DAC_SetWaveNoiseLFSR() or @ref LL_DAC_SetWaveTriangleAmplitude(), depending on the wave automatic generation selected. */
  160. uint32_t OutputBuffer; /*!< Set the output buffer for the selected DAC channel.
  161. This parameter can be a value of @ref DAC_LL_EC_OUTPUT_BUFFER
  162. This feature can be modified afterwards using unitary function @ref LL_DAC_SetOutputBuffer(). */
  163. uint32_t OutputConnection; /*!< Set the output connection for the selected DAC channel.
  164. This parameter can be a value of @ref DAC_LL_EC_OUTPUT_CONNECTION
  165. This feature can be modified afterwards using unitary function @ref LL_DAC_SetOutputConnection(). */
  166. uint32_t OutputMode; /*!< Set the output mode normal or sample-and-hold for the selected DAC channel.
  167. This parameter can be a value of @ref DAC_LL_EC_OUTPUT_MODE
  168. This feature can be modified afterwards using unitary function @ref LL_DAC_SetOutputMode(). */
  169. } LL_DAC_InitTypeDef;
  170. /**
  171. * @}
  172. */
  173. #endif /* USE_FULL_LL_DRIVER */
  174. /* Exported constants --------------------------------------------------------*/
  175. /** @defgroup DAC_LL_Exported_Constants DAC Exported Constants
  176. * @{
  177. */
  178. /** @defgroup DAC_LL_EC_GET_FLAG DAC flags
  179. * @brief Flags defines which can be used with LL_DAC_ReadReg function
  180. * @{
  181. */
  182. /* DAC channel 1 flags */
  183. #define LL_DAC_FLAG_DMAUDR1 (DAC_SR_DMAUDR1) /*!< DAC channel 1 flag DMA underrun */
  184. #define LL_DAC_FLAG_CAL1 (DAC_SR_CAL_FLAG1) /*!< DAC channel 1 flag offset calibration status */
  185. #define LL_DAC_FLAG_BWST1 (DAC_SR_BWST1) /*!< DAC channel 1 flag busy writing sample time */
  186. #if defined(DAC_CHANNEL2_SUPPORT)
  187. /* DAC channel 2 flags */
  188. #define LL_DAC_FLAG_DMAUDR2 (DAC_SR_DMAUDR2) /*!< DAC channel 2 flag DMA underrun */
  189. #define LL_DAC_FLAG_CAL2 (DAC_SR_CAL_FLAG2) /*!< DAC channel 2 flag offset calibration status */
  190. #define LL_DAC_FLAG_BWST2 (DAC_SR_BWST2) /*!< DAC channel 2 flag busy writing sample time */
  191. #endif /* DAC_CHANNEL2_SUPPORT */
  192. /**
  193. * @}
  194. */
  195. /** @defgroup DAC_LL_EC_IT DAC interruptions
  196. * @brief IT defines which can be used with LL_DAC_ReadReg and LL_DAC_WriteReg functions
  197. * @{
  198. */
  199. #define LL_DAC_IT_DMAUDRIE1 (DAC_CR_DMAUDRIE1) /*!< DAC channel 1 interruption DMA underrun */
  200. #if defined(DAC_CHANNEL2_SUPPORT)
  201. #define LL_DAC_IT_DMAUDRIE2 (DAC_CR_DMAUDRIE2) /*!< DAC channel 2 interruption DMA underrun */
  202. #endif /* DAC_CHANNEL2_SUPPORT */
  203. /**
  204. * @}
  205. */
  206. /** @defgroup DAC_LL_EC_CHANNEL DAC channels
  207. * @{
  208. */
  209. #define LL_DAC_CHANNEL_1 (DAC_REG_SHSR1_REGOFFSET | DAC_REG_DOR1_REGOFFSET | DAC_REG_DHR12R1_REGOFFSET | DAC_REG_DHR12L1_REGOFFSET | DAC_REG_DHR8R1_REGOFFSET | DAC_CR_CH1_BITOFFSET | DAC_SWTR_CH1) /*!< DAC channel 1 */
  210. #if defined(DAC_CHANNEL2_SUPPORT)
  211. #define LL_DAC_CHANNEL_2 (DAC_REG_SHSR2_REGOFFSET | DAC_REG_DOR2_REGOFFSET | DAC_REG_DHR12R2_REGOFFSET | DAC_REG_DHR12L2_REGOFFSET | DAC_REG_DHR8R2_REGOFFSET | DAC_CR_CH2_BITOFFSET | DAC_SWTR_CH2) /*!< DAC channel 2 */
  212. #endif /* DAC_CHANNEL2_SUPPORT */
  213. /**
  214. * @}
  215. */
  216. /** @defgroup DAC_LL_EC_OPERATING_MODE DAC operating mode
  217. * @{
  218. */
  219. #define LL_DAC_MODE_NORMAL_OPERATION 0x00000000U /*!< DAC channel in mode normal operation */
  220. #define LL_DAC_MODE_CALIBRATION (DAC_CR_CEN1) /*!< DAC channel in mode calibration */
  221. /**
  222. * @}
  223. */
  224. /** @defgroup DAC_LL_EC_TRIGGER_SOURCE DAC trigger source
  225. * @{
  226. */
  227. #define LL_DAC_TRIG_SOFTWARE (DAC_CR_TSEL1_2 | DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0) /*!< DAC channel conversion trigger internal (SW start) */
  228. #define LL_DAC_TRIG_EXT_TIM2_TRGO (DAC_CR_TSEL1_2 ) /*!< DAC channel conversion trigger from external IP: TIM2 TRGO. */
  229. #define LL_DAC_TRIG_EXT_TIM4_TRGO (DAC_CR_TSEL1_2 | DAC_CR_TSEL1_0) /*!< DAC channel conversion trigger from external IP: TIM4 TRGO. */
  230. #define LL_DAC_TRIG_EXT_TIM5_TRGO ( DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0) /*!< DAC channel conversion trigger from external IP: TIM5 TRGO. */
  231. #define LL_DAC_TRIG_EXT_TIM6_TRGO 0x00000000U /*!< DAC channel conversion trigger from external IP: TIM6 TRGO. */
  232. #define LL_DAC_TRIG_EXT_TIM7_TRGO ( DAC_CR_TSEL1_1 ) /*!< DAC channel conversion trigger from external IP: TIM7 TRGO. */
  233. #define LL_DAC_TRIG_EXT_TIM8_TRGO ( DAC_CR_TSEL1_0) /*!< DAC channel conversion trigger from external IP: TIM8 TRGO. */
  234. #define LL_DAC_TRIG_EXT_EXTI_LINE9 (DAC_CR_TSEL1_2 | DAC_CR_TSEL1_1 ) /*!< DAC channel conversion trigger from external IP: external interrupt line 9. */
  235. /**
  236. * @}
  237. */
  238. /** @defgroup DAC_LL_EC_WAVE_AUTO_GENERATION_MODE DAC waveform automatic generation mode
  239. * @{
  240. */
  241. #define LL_DAC_WAVE_AUTO_GENERATION_NONE 0x00000000U /*!< DAC channel wave auto generation mode disabled. */
  242. #define LL_DAC_WAVE_AUTO_GENERATION_NOISE (DAC_CR_WAVE1_0) /*!< DAC channel wave auto generation mode enabled, set generated noise waveform. */
  243. #define LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE (DAC_CR_WAVE1_1) /*!< DAC channel wave auto generation mode enabled, set generated triangle waveform. */
  244. /**
  245. * @}
  246. */
  247. /** @defgroup DAC_LL_EC_WAVE_NOISE_LFSR_UNMASK_BITS DAC wave generation - Noise LFSR unmask bits
  248. * @{
  249. */
  250. #define LL_DAC_NOISE_LFSR_UNMASK_BIT0 0x00000000U /*!< Noise wave generation, unmask LFSR bit0, for the selected DAC channel */
  251. #define LL_DAC_NOISE_LFSR_UNMASK_BITS1_0 ( DAC_CR_MAMP1_0) /*!< Noise wave generation, unmask LFSR bits[1:0], for the selected DAC channel */
  252. #define LL_DAC_NOISE_LFSR_UNMASK_BITS2_0 ( DAC_CR_MAMP1_1 ) /*!< Noise wave generation, unmask LFSR bits[2:0], for the selected DAC channel */
  253. #define LL_DAC_NOISE_LFSR_UNMASK_BITS3_0 ( DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Noise wave generation, unmask LFSR bits[3:0], for the selected DAC channel */
  254. #define LL_DAC_NOISE_LFSR_UNMASK_BITS4_0 ( DAC_CR_MAMP1_2 ) /*!< Noise wave generation, unmask LFSR bits[4:0], for the selected DAC channel */
  255. #define LL_DAC_NOISE_LFSR_UNMASK_BITS5_0 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_0) /*!< Noise wave generation, unmask LFSR bits[5:0], for the selected DAC channel */
  256. #define LL_DAC_NOISE_LFSR_UNMASK_BITS6_0 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 ) /*!< Noise wave generation, unmask LFSR bits[6:0], for the selected DAC channel */
  257. #define LL_DAC_NOISE_LFSR_UNMASK_BITS7_0 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Noise wave generation, unmask LFSR bits[7:0], for the selected DAC channel */
  258. #define LL_DAC_NOISE_LFSR_UNMASK_BITS8_0 (DAC_CR_MAMP1_3 ) /*!< Noise wave generation, unmask LFSR bits[8:0], for the selected DAC channel */
  259. #define LL_DAC_NOISE_LFSR_UNMASK_BITS9_0 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_0) /*!< Noise wave generation, unmask LFSR bits[9:0], for the selected DAC channel */
  260. #define LL_DAC_NOISE_LFSR_UNMASK_BITS10_0 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 ) /*!< Noise wave generation, unmask LFSR bits[10:0], for the selected DAC channel */
  261. #define LL_DAC_NOISE_LFSR_UNMASK_BITS11_0 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Noise wave generation, unmask LFSR bits[11:0], for the selected DAC channel */
  262. /**
  263. * @}
  264. */
  265. /** @defgroup DAC_LL_EC_WAVE_TRIANGLE_AMPLITUDE DAC wave generation - Triangle amplitude
  266. * @{
  267. */
  268. #define LL_DAC_TRIANGLE_AMPLITUDE_1 0x00000000U /*!< Triangle wave generation, amplitude of 1 LSB of DAC output range, for the selected DAC channel */
  269. #define LL_DAC_TRIANGLE_AMPLITUDE_3 ( DAC_CR_MAMP1_0) /*!< Triangle wave generation, amplitude of 3 LSB of DAC output range, for the selected DAC channel */
  270. #define LL_DAC_TRIANGLE_AMPLITUDE_7 ( DAC_CR_MAMP1_1 ) /*!< Triangle wave generation, amplitude of 7 LSB of DAC output range, for the selected DAC channel */
  271. #define LL_DAC_TRIANGLE_AMPLITUDE_15 ( DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Triangle wave generation, amplitude of 15 LSB of DAC output range, for the selected DAC channel */
  272. #define LL_DAC_TRIANGLE_AMPLITUDE_31 ( DAC_CR_MAMP1_2 ) /*!< Triangle wave generation, amplitude of 31 LSB of DAC output range, for the selected DAC channel */
  273. #define LL_DAC_TRIANGLE_AMPLITUDE_63 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_0) /*!< Triangle wave generation, amplitude of 63 LSB of DAC output range, for the selected DAC channel */
  274. #define LL_DAC_TRIANGLE_AMPLITUDE_127 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 ) /*!< Triangle wave generation, amplitude of 127 LSB of DAC output range, for the selected DAC channel */
  275. #define LL_DAC_TRIANGLE_AMPLITUDE_255 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Triangle wave generation, amplitude of 255 LSB of DAC output range, for the selected DAC channel */
  276. #define LL_DAC_TRIANGLE_AMPLITUDE_511 (DAC_CR_MAMP1_3 ) /*!< Triangle wave generation, amplitude of 512 LSB of DAC output range, for the selected DAC channel */
  277. #define LL_DAC_TRIANGLE_AMPLITUDE_1023 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_0) /*!< Triangle wave generation, amplitude of 1023 LSB of DAC output range, for the selected DAC channel */
  278. #define LL_DAC_TRIANGLE_AMPLITUDE_2047 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 ) /*!< Triangle wave generation, amplitude of 2047 LSB of DAC output range, for the selected DAC channel */
  279. #define LL_DAC_TRIANGLE_AMPLITUDE_4095 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Triangle wave generation, amplitude of 4095 LSB of DAC output range, for the selected DAC channel */
  280. /**
  281. * @}
  282. */
  283. /** @defgroup DAC_LL_EC_OUTPUT_MODE DAC channel output mode
  284. * @{
  285. */
  286. #define LL_DAC_OUTPUT_MODE_NORMAL 0x00000000U /*!< The selected DAC channel output is on mode normal. */
  287. #define LL_DAC_OUTPUT_MODE_SAMPLE_AND_HOLD (DAC_MCR_MODE1_2) /*!< The selected DAC channel output is on mode sample-and-hold. Mode sample-and-hold requires an external capacitor, refer to description of function @ref LL_DAC_ConfigOutput() or @ref LL_DAC_SetOutputMode(). */
  288. /**
  289. * @}
  290. */
  291. /** @defgroup DAC_LL_EC_OUTPUT_BUFFER DAC channel output buffer
  292. * @{
  293. */
  294. #define LL_DAC_OUTPUT_BUFFER_ENABLE 0x00000000U /*!< The selected DAC channel output is buffered: higher drive current capability, but also higher current consumption */
  295. #define LL_DAC_OUTPUT_BUFFER_DISABLE (DAC_MCR_MODE1_1) /*!< The selected DAC channel output is not buffered: lower drive current capability, but also lower current consumption */
  296. /**
  297. * @}
  298. */
  299. /** @defgroup DAC_LL_EC_OUTPUT_CONNECTION DAC channel output connection
  300. * @{
  301. */
  302. #define LL_DAC_OUTPUT_CONNECT_GPIO 0x00000000U /*!< The selected DAC channel output is connected to external pin */
  303. #define LL_DAC_OUTPUT_CONNECT_INTERNAL (DAC_MCR_MODE1_0) /*!< The selected DAC channel output is connected to on-chip peripherals via internal paths. On this STM32 serie, output connection depends on output mode (normal or sample and hold) and output buffer state. Refer to comments of function @ref LL_DAC_SetOutputConnection(). */
  304. /**
  305. * @}
  306. */
  307. /** @defgroup DAC_LL_EC_LEGACY DAC literals legacy naming
  308. * @{
  309. */
  310. #define LL_DAC_TRIGGER_SOFTWARE (LL_DAC_TRIG_SOFTWARE)
  311. #define LL_DAC_TRIGGER_TIM2_TRGO (LL_DAC_TRIG_EXT_TIM2_TRGO)
  312. #define LL_DAC_TRIGGER_TIM4_TRGO (LL_DAC_TRIG_EXT_TIM4_TRGO)
  313. #define LL_DAC_TRIGGER_TIM5_TRGO (LL_DAC_TRIG_EXT_TIM5_TRGO)
  314. #define LL_DAC_TRIGGER_TIM6_TRGO (LL_DAC_TRIG_EXT_TIM6_TRGO)
  315. #define LL_DAC_TRIGGER_TIM7_TRGO (LL_DAC_TRIG_EXT_TIM7_TRGO)
  316. #define LL_DAC_TRIGGER_TIM8_TRGO (LL_DAC_TRIG_EXT_TIM8_TRGO)
  317. #define LL_DAC_TRIGGER_EXT_IT9 (LL_DAC_TRIG_EXT_EXTI_LINE9)
  318. #define LL_DAC_WAVEGENERATION_NONE (LL_DAC_WAVE_AUTO_GENERATION_NONE)
  319. #define LL_DAC_WAVEGENERATION_NOISE (LL_DAC_WAVE_AUTO_GENERATION_NOISE)
  320. #define LL_DAC_WAVEGENERATION_TRIANGLE (LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE)
  321. #define LL_DAC_CONNECT_GPIO (LL_DAC_OUTPUT_CONNECT_GPIO)
  322. #define LL_DAC_CONNECT_INTERNAL (LL_DAC_OUTPUT_CONNECT_INTERNAL)
  323. /**
  324. * @}
  325. */
  326. /** @defgroup DAC_LL_EC_RESOLUTION DAC channel output resolution
  327. * @{
  328. */
  329. #define LL_DAC_RESOLUTION_12B 0x00000000U /*!< DAC channel resolution 12 bits */
  330. #define LL_DAC_RESOLUTION_8B 0x00000002U /*!< DAC channel resolution 8 bits */
  331. /**
  332. * @}
  333. */
  334. /** @defgroup DAC_LL_EC_REGISTERS DAC registers compliant with specific purpose
  335. * @{
  336. */
  337. /* List of DAC registers intended to be used (most commonly) with */
  338. /* DMA transfer. */
  339. /* Refer to function @ref LL_DAC_DMA_GetRegAddr(). */
  340. #define LL_DAC_DMA_REG_DATA_12BITS_RIGHT_ALIGNED DAC_REG_DHR12RX_REGOFFSET_MASK /*!< DAC channel data holding register 12 bits right aligned */
  341. #define LL_DAC_DMA_REG_DATA_12BITS_LEFT_ALIGNED DAC_REG_DHR12LX_REGOFFSET_MASK /*!< DAC channel data holding register 12 bits left aligned */
  342. #define LL_DAC_DMA_REG_DATA_8BITS_RIGHT_ALIGNED DAC_REG_DHR8RX_REGOFFSET_MASK /*!< DAC channel data holding register 8 bits right aligned */
  343. /**
  344. * @}
  345. */
  346. /** @defgroup DAC_LL_EC_HW_DELAYS Definitions of DAC hardware constraints delays
  347. * @note Only DAC IP HW delays are defined in DAC LL driver driver,
  348. * not timeout values.
  349. * For details on delays values, refer to descriptions in source code
  350. * above each literal definition.
  351. * @{
  352. */
  353. /* Delay for DAC channel voltage settling time from DAC channel startup */
  354. /* (transition from disable to enable). */
  355. /* Note: DAC channel startup time depends on board application environment: */
  356. /* impedance connected to DAC channel output. */
  357. /* The delay below is specified under conditions: */
  358. /* - voltage maximum transition (lowest to highest value) */
  359. /* - until voltage reaches final value +-1LSB */
  360. /* - DAC channel output buffer enabled */
  361. /* - load impedance of 5kOhm (min), 50pF (max) */
  362. /* Literal set to maximum value (refer to device datasheet, */
  363. /* parameter "tWAKEUP"). */
  364. /* Unit: us */
  365. #define LL_DAC_DELAY_STARTUP_VOLTAGE_SETTLING_US 8U /*!< Delay for DAC channel voltage settling time from DAC channel startup (transition from disable to enable) */
  366. /* Delay for DAC channel voltage settling time. */
  367. /* Note: DAC channel startup time depends on board application environment: */
  368. /* impedance connected to DAC channel output. */
  369. /* The delay below is specified under conditions: */
  370. /* - voltage maximum transition (lowest to highest value) */
  371. /* - until voltage reaches final value +-1LSB */
  372. /* - DAC channel output buffer enabled */
  373. /* - load impedance of 5kOhm min, 50pF max */
  374. /* Literal set to maximum value (refer to device datasheet, */
  375. /* parameter "tSETTLING"). */
  376. /* Unit: us */
  377. #define LL_DAC_DELAY_VOLTAGE_SETTLING_US 2U /*!< Delay for DAC channel voltage settling time */
  378. /**
  379. * @}
  380. */
  381. /**
  382. * @}
  383. */
  384. /* Exported macro ------------------------------------------------------------*/
  385. /** @defgroup DAC_LL_Exported_Macros DAC Exported Macros
  386. * @{
  387. */
  388. /** @defgroup DAC_LL_EM_WRITE_READ Common write and read registers macros
  389. * @{
  390. */
  391. /**
  392. * @brief Write a value in DAC register
  393. * @param __INSTANCE__ DAC Instance
  394. * @param __REG__ Register to be written
  395. * @param __VALUE__ Value to be written in the register
  396. * @retval None
  397. */
  398. #define LL_DAC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  399. /**
  400. * @brief Read a value in DAC register
  401. * @param __INSTANCE__ DAC Instance
  402. * @param __REG__ Register to be read
  403. * @retval Register value
  404. */
  405. #define LL_DAC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  406. /**
  407. * @}
  408. */
  409. /** @defgroup DAC_LL_EM_HELPER_MACRO DAC helper macro
  410. * @{
  411. */
  412. /**
  413. * @brief Helper macro to get DAC channel number in decimal format
  414. * from literals LL_DAC_CHANNEL_x.
  415. * Example:
  416. * __LL_DAC_CHANNEL_TO_DECIMAL_NB(LL_DAC_CHANNEL_1)
  417. * will return decimal number "1".
  418. * @note The input can be a value from functions where a channel
  419. * number is returned.
  420. * @param __CHANNEL__ This parameter can be one of the following values:
  421. * @arg @ref LL_DAC_CHANNEL_1
  422. * @arg @ref LL_DAC_CHANNEL_2 (1)
  423. *
  424. * (1) On this STM32 serie, parameter not available on all devices.
  425. * Refer to device datasheet for channels availability.
  426. * @retval 1...2 (value "2" depending on DAC channel 2 availability)
  427. */
  428. #define __LL_DAC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
  429. ((__CHANNEL__) & DAC_SWTR_CHX_MASK)
  430. /**
  431. * @brief Helper macro to get DAC channel in literal format LL_DAC_CHANNEL_x
  432. * from number in decimal format.
  433. * Example:
  434. * __LL_DAC_DECIMAL_NB_TO_CHANNEL(1)
  435. * will return a data equivalent to "LL_DAC_CHANNEL_1".
  436. * @note If the input parameter does not correspond to a DAC channel,
  437. * this macro returns value '0'.
  438. * @param __DECIMAL_NB__ 1...2 (value "2" depending on DAC channel 2 availability)
  439. * @retval Returned value can be one of the following values:
  440. * @arg @ref LL_DAC_CHANNEL_1
  441. * @arg @ref LL_DAC_CHANNEL_2 (1)
  442. *
  443. * (1) On this STM32 serie, parameter not available on all devices.
  444. * Refer to device datasheet for channels availability.
  445. */
  446. #if defined(DAC_CHANNEL2_SUPPORT)
  447. #define __LL_DAC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  448. (((__DECIMAL_NB__) == 1U) \
  449. ? ( \
  450. LL_DAC_CHANNEL_1 \
  451. ) \
  452. : \
  453. (((__DECIMAL_NB__) == 2U) \
  454. ? ( \
  455. LL_DAC_CHANNEL_2 \
  456. ) \
  457. : \
  458. ( \
  459. 0 \
  460. ) \
  461. ) \
  462. )
  463. #else
  464. #define __LL_DAC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
  465. (((__DECIMAL_NB__) == 1U) \
  466. ? ( \
  467. LL_DAC_CHANNEL_1 \
  468. ) \
  469. : \
  470. ( \
  471. 0 \
  472. ) \
  473. )
  474. #endif /* DAC_CHANNEL2_SUPPORT */
  475. /**
  476. * @brief Helper macro to define the DAC conversion data full-scale digital
  477. * value corresponding to the selected DAC resolution.
  478. * @note DAC conversion data full-scale corresponds to voltage range
  479. * determined by analog voltage references Vref+ and Vref-
  480. * (refer to reference manual).
  481. * @param __DAC_RESOLUTION__ This parameter can be one of the following values:
  482. * @arg @ref LL_DAC_RESOLUTION_12B
  483. * @arg @ref LL_DAC_RESOLUTION_8B
  484. * @retval ADC conversion data equivalent voltage value (unit: mVolt)
  485. */
  486. #define __LL_DAC_DIGITAL_SCALE(__DAC_RESOLUTION__) \
  487. ((0x00000FFFU) >> ((__DAC_RESOLUTION__) << 1U))
  488. /**
  489. * @brief Helper macro to calculate the DAC conversion data (unit: digital
  490. * value) corresponding to a voltage (unit: mVolt).
  491. * @note This helper macro is intended to provide input data in voltage
  492. * rather than digital value,
  493. * to be used with LL DAC functions such as
  494. * @ref LL_DAC_ConvertData12RightAligned().
  495. * @note Analog reference voltage (Vref+) must be either known from
  496. * user board environment or can be calculated using ADC measurement
  497. * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
  498. * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
  499. * @param __DAC_VOLTAGE__ Voltage to be generated by DAC channel
  500. * (unit: mVolt).
  501. * @param __DAC_RESOLUTION__ This parameter can be one of the following values:
  502. * @arg @ref LL_DAC_RESOLUTION_12B
  503. * @arg @ref LL_DAC_RESOLUTION_8B
  504. * @retval DAC conversion data (unit: digital value)
  505. */
  506. #define __LL_DAC_CALC_VOLTAGE_TO_DATA(__VREFANALOG_VOLTAGE__,\
  507. __DAC_VOLTAGE__,\
  508. __DAC_RESOLUTION__) \
  509. ((__DAC_VOLTAGE__) * __LL_DAC_DIGITAL_SCALE(__DAC_RESOLUTION__) \
  510. / (__VREFANALOG_VOLTAGE__) \
  511. )
  512. /**
  513. * @}
  514. */
  515. /**
  516. * @}
  517. */
  518. /* Exported functions --------------------------------------------------------*/
  519. /** @defgroup DAC_LL_Exported_Functions DAC Exported Functions
  520. * @{
  521. */
  522. /** @defgroup DAC_LL_EF_Configuration Configuration of DAC channels
  523. * @{
  524. */
  525. /**
  526. * @brief Set the operating mode for the selected DAC channel:
  527. * calibration or normal operating mode.
  528. * @rmtoll CR CEN1 LL_DAC_SetMode\n
  529. * CR CEN2 LL_DAC_SetMode
  530. * @param DACx DAC instance
  531. * @param DAC_Channel This parameter can be one of the following values:
  532. * @arg @ref LL_DAC_CHANNEL_1
  533. *
  534. * @arg @ref LL_DAC_CHANNEL_2 (1)
  535. * (1) On this STM32 serie, parameter not available on all devices.
  536. * Refer to device datasheet for channels availability.
  537. * @param ChannelMode This parameter can be one of the following values:
  538. * @arg @ref LL_DAC_MODE_NORMAL_OPERATION
  539. * @arg @ref LL_DAC_MODE_CALIBRATION
  540. * @retval None
  541. */
  542. __STATIC_INLINE void LL_DAC_SetMode(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t ChannelMode)
  543. {
  544. MODIFY_REG(DACx->CR,
  545. DAC_CR_CEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
  546. ChannelMode << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  547. }
  548. /**
  549. * @brief Get the operating mode for the selected DAC channel:
  550. * calibration or normal operating mode.
  551. * @rmtoll CR CEN1 LL_DAC_GetMode\n
  552. * CR CEN2 LL_DAC_GetMode
  553. * @param DACx DAC instance
  554. * @param DAC_Channel This parameter can be one of the following values:
  555. * @arg @ref LL_DAC_CHANNEL_1
  556. * @arg @ref LL_DAC_CHANNEL_2 (1)
  557. *
  558. * (1) On this STM32 serie, parameter not available on all devices.
  559. * Refer to device datasheet for channels availability.
  560. * @retval Returned value can be one of the following values:
  561. * @arg @ref LL_DAC_MODE_NORMAL_OPERATION
  562. * @arg @ref LL_DAC_MODE_CALIBRATION
  563. */
  564. __STATIC_INLINE uint32_t LL_DAC_GetMode(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  565. {
  566. return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_CEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  567. >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
  568. );
  569. }
  570. /**
  571. * @brief Set the offset trimming value for the selected DAC channel.
  572. * Trimming has an impact when output buffer is enabled
  573. * and is intended to replace factory calibration default values.
  574. * @rmtoll CCR OTRIM1 LL_DAC_SetTrimmingValue\n
  575. * CCR OTRIM2 LL_DAC_SetTrimmingValue
  576. * @param DACx DAC instance
  577. * @param DAC_Channel This parameter can be one of the following values:
  578. * @arg @ref LL_DAC_CHANNEL_1
  579. * @arg @ref LL_DAC_CHANNEL_2 (1)
  580. *
  581. * (1) On this STM32 serie, parameter not available on all devices.
  582. * Refer to device datasheet for channels availability.
  583. * @param TrimmingValue Value between Min_Data=0x00 and Max_Data=0x1F
  584. * @retval None
  585. */
  586. __STATIC_INLINE void LL_DAC_SetTrimmingValue(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t TrimmingValue)
  587. {
  588. MODIFY_REG(DACx->CCR,
  589. DAC_CCR_OTRIM1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
  590. TrimmingValue << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  591. }
  592. /**
  593. * @brief Get the offset trimming value for the selected DAC channel.
  594. * Trimming has an impact when output buffer is enabled
  595. * and is intended to replace factory calibration default values.
  596. * @rmtoll CCR OTRIM1 LL_DAC_GetTrimmingValue\n
  597. * CCR OTRIM2 LL_DAC_GetTrimmingValue
  598. * @param DACx DAC instance
  599. * @param DAC_Channel This parameter can be one of the following values:
  600. * @arg @ref LL_DAC_CHANNEL_1
  601. * @arg @ref LL_DAC_CHANNEL_2 (1)
  602. *
  603. * (1) On this STM32 serie, parameter not available on all devices.
  604. * Refer to device datasheet for channels availability.
  605. * @retval TrimmingValue Value between Min_Data=0x00 and Max_Data=0x1F
  606. */
  607. __STATIC_INLINE uint32_t LL_DAC_GetTrimmingValue(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  608. {
  609. return (uint32_t)(READ_BIT(DACx->CCR, DAC_CCR_OTRIM1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  610. >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
  611. );
  612. }
  613. /**
  614. * @brief Set the conversion trigger source for the selected DAC channel.
  615. * @note For conversion trigger source to be effective, DAC trigger
  616. * must be enabled using function @ref LL_DAC_EnableTrigger().
  617. * @note To set conversion trigger source, DAC channel must be disabled.
  618. * Otherwise, the setting is discarded.
  619. * @note Availability of parameters of trigger sources from timer
  620. * depends on timers availability on the selected device.
  621. * @rmtoll CR TSEL1 LL_DAC_SetTriggerSource\n
  622. * CR TSEL2 LL_DAC_SetTriggerSource
  623. * @param DACx DAC instance
  624. * @param DAC_Channel This parameter can be one of the following values:
  625. * @arg @ref LL_DAC_CHANNEL_1
  626. * @arg @ref LL_DAC_CHANNEL_2 (1)
  627. *
  628. * (1) On this STM32 serie, parameter not available on all devices.
  629. * Refer to device datasheet for channels availability.
  630. * @param TriggerSource This parameter can be one of the following values:
  631. * @arg @ref LL_DAC_TRIG_SOFTWARE
  632. * @arg @ref LL_DAC_TRIG_EXT_TIM2_TRGO
  633. * @arg @ref LL_DAC_TRIG_EXT_TIM4_TRGO
  634. * @arg @ref LL_DAC_TRIG_EXT_TIM5_TRGO
  635. * @arg @ref LL_DAC_TRIG_EXT_TIM6_TRGO
  636. * @arg @ref LL_DAC_TRIG_EXT_TIM7_TRGO
  637. * @arg @ref LL_DAC_TRIG_EXT_TIM8_TRGO
  638. * @arg @ref LL_DAC_TRIG_EXT_EXTI_LINE9
  639. * @retval None
  640. */
  641. __STATIC_INLINE void LL_DAC_SetTriggerSource(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t TriggerSource)
  642. {
  643. MODIFY_REG(DACx->CR,
  644. DAC_CR_TSEL1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
  645. TriggerSource << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  646. }
  647. /**
  648. * @brief Get the conversion trigger source for the selected DAC channel.
  649. * @note For conversion trigger source to be effective, DAC trigger
  650. * must be enabled using function @ref LL_DAC_EnableTrigger().
  651. * @note Availability of parameters of trigger sources from timer
  652. * depends on timers availability on the selected device.
  653. * @rmtoll CR TSEL1 LL_DAC_GetTriggerSource\n
  654. * CR TSEL2 LL_DAC_GetTriggerSource
  655. * @param DACx DAC instance
  656. * @param DAC_Channel This parameter can be one of the following values:
  657. * @arg @ref LL_DAC_CHANNEL_1
  658. * @arg @ref LL_DAC_CHANNEL_2 (1)
  659. *
  660. * (1) On this STM32 serie, parameter not available on all devices.
  661. * Refer to device datasheet for channels availability.
  662. * @retval Returned value can be one of the following values:
  663. * @arg @ref LL_DAC_TRIG_SOFTWARE
  664. * @arg @ref LL_DAC_TRIG_EXT_TIM2_TRGO
  665. * @arg @ref LL_DAC_TRIG_EXT_TIM4_TRGO
  666. * @arg @ref LL_DAC_TRIG_EXT_TIM5_TRGO
  667. * @arg @ref LL_DAC_TRIG_EXT_TIM6_TRGO
  668. * @arg @ref LL_DAC_TRIG_EXT_TIM7_TRGO
  669. * @arg @ref LL_DAC_TRIG_EXT_TIM8_TRGO
  670. * @arg @ref LL_DAC_TRIGGER_EXT_IT9
  671. */
  672. __STATIC_INLINE uint32_t LL_DAC_GetTriggerSource(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  673. {
  674. return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_TSEL1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  675. >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
  676. );
  677. }
  678. /**
  679. * @brief Set the waveform automatic generation mode
  680. * for the selected DAC channel.
  681. * @rmtoll CR WAVE1 LL_DAC_SetWaveAutoGeneration\n
  682. * CR WAVE2 LL_DAC_SetWaveAutoGeneration
  683. * @param DACx DAC instance
  684. * @param DAC_Channel This parameter can be one of the following values:
  685. * @arg @ref LL_DAC_CHANNEL_1
  686. * @arg @ref LL_DAC_CHANNEL_2 (1)
  687. *
  688. * (1) On this STM32 serie, parameter not available on all devices.
  689. * Refer to device datasheet for channels availability.
  690. * @param WaveAutoGeneration This parameter can be one of the following values:
  691. * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_NONE
  692. * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_NOISE
  693. * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE
  694. * @retval None
  695. */
  696. __STATIC_INLINE void LL_DAC_SetWaveAutoGeneration(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t WaveAutoGeneration)
  697. {
  698. MODIFY_REG(DACx->CR,
  699. DAC_CR_WAVE1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
  700. WaveAutoGeneration << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  701. }
  702. /**
  703. * @brief Get the waveform automatic generation mode
  704. * for the selected DAC channel.
  705. * @rmtoll CR WAVE1 LL_DAC_GetWaveAutoGeneration\n
  706. * CR WAVE2 LL_DAC_GetWaveAutoGeneration
  707. * @param DACx DAC instance
  708. * @param DAC_Channel This parameter can be one of the following values:
  709. * @arg @ref LL_DAC_CHANNEL_1
  710. * @arg @ref LL_DAC_CHANNEL_2 (1)
  711. *
  712. * (1) On this STM32 serie, parameter not available on all devices.
  713. * Refer to device datasheet for channels availability.
  714. * @retval Returned value can be one of the following values:
  715. * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_NONE
  716. * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_NOISE
  717. * @arg @ref LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE
  718. */
  719. __STATIC_INLINE uint32_t LL_DAC_GetWaveAutoGeneration(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  720. {
  721. return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_WAVE1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  722. >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
  723. );
  724. }
  725. /**
  726. * @brief Set the noise waveform generation for the selected DAC channel:
  727. * Noise mode and parameters LFSR (linear feedback shift register).
  728. * @note For wave generation to be effective, DAC channel
  729. * wave generation mode must be enabled using
  730. * function @ref LL_DAC_SetWaveAutoGeneration().
  731. * @note This setting can be set when the selected DAC channel is disabled
  732. * (otherwise, the setting operation is ignored).
  733. * @rmtoll CR MAMP1 LL_DAC_SetWaveNoiseLFSR\n
  734. * CR MAMP2 LL_DAC_SetWaveNoiseLFSR
  735. * @param DACx DAC instance
  736. * @param DAC_Channel This parameter can be one of the following values:
  737. * @arg @ref LL_DAC_CHANNEL_1
  738. * @arg @ref LL_DAC_CHANNEL_2 (1)
  739. *
  740. * (1) On this STM32 serie, parameter not available on all devices.
  741. * Refer to device datasheet for channels availability.
  742. * @param NoiseLFSRMask This parameter can be one of the following values:
  743. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BIT0
  744. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS1_0
  745. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS2_0
  746. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS3_0
  747. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS4_0
  748. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS5_0
  749. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS6_0
  750. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS7_0
  751. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS8_0
  752. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS9_0
  753. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS10_0
  754. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS11_0
  755. * @retval None
  756. */
  757. __STATIC_INLINE void LL_DAC_SetWaveNoiseLFSR(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t NoiseLFSRMask)
  758. {
  759. MODIFY_REG(DACx->CR,
  760. DAC_CR_MAMP1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
  761. NoiseLFSRMask << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  762. }
  763. /**
  764. * @brief Set the noise waveform generation for the selected DAC channel:
  765. * Noise mode and parameters LFSR (linear feedback shift register).
  766. * @rmtoll CR MAMP1 LL_DAC_GetWaveNoiseLFSR\n
  767. * CR MAMP2 LL_DAC_GetWaveNoiseLFSR
  768. * @param DACx DAC instance
  769. * @param DAC_Channel This parameter can be one of the following values:
  770. * @arg @ref LL_DAC_CHANNEL_1
  771. * @arg @ref LL_DAC_CHANNEL_2 (1)
  772. *
  773. * (1) On this STM32 serie, parameter not available on all devices.
  774. * Refer to device datasheet for channels availability.
  775. * @retval Returned value can be one of the following values:
  776. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BIT0
  777. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS1_0
  778. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS2_0
  779. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS3_0
  780. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS4_0
  781. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS5_0
  782. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS6_0
  783. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS7_0
  784. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS8_0
  785. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS9_0
  786. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS10_0
  787. * @arg @ref LL_DAC_NOISE_LFSR_UNMASK_BITS11_0
  788. */
  789. __STATIC_INLINE uint32_t LL_DAC_GetWaveNoiseLFSR(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  790. {
  791. return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_MAMP1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  792. >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
  793. );
  794. }
  795. /**
  796. * @brief Set the triangle waveform generation for the selected DAC channel:
  797. * triangle mode and amplitude.
  798. * @note For wave generation to be effective, DAC channel
  799. * wave generation mode must be enabled using
  800. * function @ref LL_DAC_SetWaveAutoGeneration().
  801. * @note This setting can be set when the selected DAC channel is disabled
  802. * (otherwise, the setting operation is ignored).
  803. * @rmtoll CR MAMP1 LL_DAC_SetWaveTriangleAmplitude\n
  804. * CR MAMP2 LL_DAC_SetWaveTriangleAmplitude
  805. * @param DACx DAC instance
  806. * @param DAC_Channel This parameter can be one of the following values:
  807. * @arg @ref LL_DAC_CHANNEL_1
  808. * @arg @ref LL_DAC_CHANNEL_2 (1)
  809. *
  810. * (1) On this STM32 serie, parameter not available on all devices.
  811. * Refer to device datasheet for channels availability.
  812. * @param TriangleAmplitude This parameter can be one of the following values:
  813. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_1
  814. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_3
  815. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_7
  816. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_15
  817. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_31
  818. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_63
  819. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_127
  820. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_255
  821. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_511
  822. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_1023
  823. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_2047
  824. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_4095
  825. * @retval None
  826. */
  827. __STATIC_INLINE void LL_DAC_SetWaveTriangleAmplitude(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t TriangleAmplitude)
  828. {
  829. MODIFY_REG(DACx->CR,
  830. DAC_CR_MAMP1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
  831. TriangleAmplitude << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  832. }
  833. /**
  834. * @brief Set the triangle waveform generation for the selected DAC channel:
  835. * triangle mode and amplitude.
  836. * @rmtoll CR MAMP1 LL_DAC_GetWaveTriangleAmplitude\n
  837. * CR MAMP2 LL_DAC_GetWaveTriangleAmplitude
  838. * @param DACx DAC instance
  839. * @param DAC_Channel This parameter can be one of the following values:
  840. * @arg @ref LL_DAC_CHANNEL_1
  841. * @arg @ref LL_DAC_CHANNEL_2 (1)
  842. *
  843. * (1) On this STM32 serie, parameter not available on all devices.
  844. * Refer to device datasheet for channels availability.
  845. * @retval Returned value can be one of the following values:
  846. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_1
  847. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_3
  848. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_7
  849. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_15
  850. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_31
  851. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_63
  852. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_127
  853. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_255
  854. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_511
  855. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_1023
  856. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_2047
  857. * @arg @ref LL_DAC_TRIANGLE_AMPLITUDE_4095
  858. */
  859. __STATIC_INLINE uint32_t LL_DAC_GetWaveTriangleAmplitude(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  860. {
  861. return (uint32_t)(READ_BIT(DACx->CR, DAC_CR_MAMP1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  862. >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
  863. );
  864. }
  865. /**
  866. * @brief Set the output for the selected DAC channel.
  867. * @note This function set several features:
  868. * - mode normal or sample-and-hold
  869. * - buffer
  870. * - connection to GPIO or internal path.
  871. * These features can also be set individually using
  872. * dedicated functions:
  873. * - @ref LL_DAC_SetOutputBuffer()
  874. * - @ref LL_DAC_SetOutputMode()
  875. * - @ref LL_DAC_SetOutputConnection()
  876. * @note On this STM32 serie, output connection depends on output mode
  877. * (normal or sample and hold) and output buffer state.
  878. * - if output connection is set to internal path and output buffer
  879. * is enabled (whatever output mode):
  880. * output connection is also connected to GPIO pin
  881. * (both connections to GPIO pin and internal path).
  882. * - if output connection is set to GPIO pin, output buffer
  883. * is disabled, output mode set to sample and hold:
  884. * output connection is also connected to internal path
  885. * (both connections to GPIO pin and internal path).
  886. * @note Mode sample-and-hold requires an external capacitor
  887. * to be connected between DAC channel output and ground.
  888. * Capacitor value depends on load on DAC channel output and
  889. * sample-and-hold timings configured.
  890. * As indication, capacitor typical value is 100nF
  891. * (refer to device datasheet, parameter "CSH").
  892. * @rmtoll CR MODE1 LL_DAC_ConfigOutput\n
  893. * CR MODE2 LL_DAC_ConfigOutput
  894. * @param DACx DAC instance
  895. * @param DAC_Channel This parameter can be one of the following values:
  896. * @arg @ref LL_DAC_CHANNEL_1
  897. * @arg @ref LL_DAC_CHANNEL_2 (1)
  898. *
  899. * (1) On this STM32 serie, parameter not available on all devices.
  900. * Refer to device datasheet for channels availability.
  901. * @param OutputMode This parameter can be one of the following values:
  902. * @arg @ref LL_DAC_OUTPUT_MODE_NORMAL
  903. * @arg @ref LL_DAC_OUTPUT_MODE_SAMPLE_AND_HOLD
  904. * @param OutputBuffer This parameter can be one of the following values:
  905. * @arg @ref LL_DAC_OUTPUT_BUFFER_ENABLE
  906. * @arg @ref LL_DAC_OUTPUT_BUFFER_DISABLE
  907. * @param OutputConnection This parameter can be one of the following values:
  908. * @arg @ref LL_DAC_OUTPUT_CONNECT_GPIO
  909. * @arg @ref LL_DAC_OUTPUT_CONNECT_INTERNAL
  910. * @retval None
  911. */
  912. __STATIC_INLINE void LL_DAC_ConfigOutput(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t OutputMode, uint32_t OutputBuffer, uint32_t OutputConnection)
  913. {
  914. MODIFY_REG(DACx->MCR,
  915. (DAC_MCR_MODE1_2 | DAC_MCR_MODE1_1 | DAC_MCR_MODE1_0) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
  916. (OutputMode | OutputBuffer | OutputConnection) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  917. }
  918. /**
  919. * @brief Set the output mode normal or sample-and-hold
  920. * for the selected DAC channel.
  921. * @note Mode sample-and-hold requires an external capacitor
  922. * to be connected between DAC channel output and ground.
  923. * Capacitor value depends on load on DAC channel output and
  924. * sample-and-hold timings configured.
  925. * As indication, capacitor typical value is 100nF
  926. * (refer to device datasheet, parameter "CSH").
  927. * @rmtoll CR MODE1 LL_DAC_SetOutputMode\n
  928. * CR MODE2 LL_DAC_SetOutputMode
  929. * @param DACx DAC instance
  930. * @param DAC_Channel This parameter can be one of the following values:
  931. * @arg @ref LL_DAC_CHANNEL_1
  932. * @arg @ref LL_DAC_CHANNEL_2 (1)
  933. *
  934. * (1) On this STM32 serie, parameter not available on all devices.
  935. * Refer to device datasheet for channels availability.
  936. * @param OutputMode This parameter can be one of the following values:
  937. * @arg @ref LL_DAC_OUTPUT_MODE_NORMAL
  938. * @arg @ref LL_DAC_OUTPUT_MODE_SAMPLE_AND_HOLD
  939. * @retval None
  940. */
  941. __STATIC_INLINE void LL_DAC_SetOutputMode(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t OutputMode)
  942. {
  943. MODIFY_REG(DACx->MCR,
  944. DAC_MCR_MODE1_2 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
  945. OutputMode << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  946. }
  947. /**
  948. * @brief Get the output mode normal or sample-and-hold for the selected DAC channel.
  949. * @rmtoll CR MODE1 LL_DAC_GetOutputMode\n
  950. * CR MODE2 LL_DAC_GetOutputMode
  951. * @param DACx DAC instance
  952. * @param DAC_Channel This parameter can be one of the following values:
  953. * @arg @ref LL_DAC_CHANNEL_1
  954. * @arg @ref LL_DAC_CHANNEL_2 (1)
  955. *
  956. * (1) On this STM32 serie, parameter not available on all devices.
  957. * Refer to device datasheet for channels availability.
  958. * @retval Returned value can be one of the following values:
  959. * @arg @ref LL_DAC_OUTPUT_MODE_NORMAL
  960. * @arg @ref LL_DAC_OUTPUT_MODE_SAMPLE_AND_HOLD
  961. */
  962. __STATIC_INLINE uint32_t LL_DAC_GetOutputMode(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  963. {
  964. return (uint32_t)(READ_BIT(DACx->MCR, DAC_MCR_MODE1_2 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  965. >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
  966. );
  967. }
  968. /**
  969. * @brief Set the output buffer for the selected DAC channel.
  970. * @note On this STM32 serie, when buffer is enabled, its offset can be
  971. * trimmed: factory calibration default values can be
  972. * replaced by user trimming values, using function
  973. * @ref LL_DAC_SetTrimmingValue().
  974. * @rmtoll CR MODE1 LL_DAC_SetOutputBuffer\n
  975. * CR MODE2 LL_DAC_SetOutputBuffer
  976. * @param DACx DAC instance
  977. * @param DAC_Channel This parameter can be one of the following values:
  978. * @arg @ref LL_DAC_CHANNEL_1
  979. * @arg @ref LL_DAC_CHANNEL_2 (1)
  980. *
  981. * (1) On this STM32 serie, parameter not available on all devices.
  982. * Refer to device datasheet for channels availability.
  983. * @param OutputBuffer This parameter can be one of the following values:
  984. * @arg @ref LL_DAC_OUTPUT_BUFFER_ENABLE
  985. * @arg @ref LL_DAC_OUTPUT_BUFFER_DISABLE
  986. * @retval None
  987. */
  988. __STATIC_INLINE void LL_DAC_SetOutputBuffer(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t OutputBuffer)
  989. {
  990. MODIFY_REG(DACx->MCR,
  991. DAC_MCR_MODE1_1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
  992. OutputBuffer << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  993. }
  994. /**
  995. * @brief Get the output buffer state for the selected DAC channel.
  996. * @rmtoll CR MODE1 LL_DAC_GetOutputBuffer\n
  997. * CR MODE2 LL_DAC_GetOutputBuffer
  998. * @param DACx DAC instance
  999. * @param DAC_Channel This parameter can be one of the following values:
  1000. * @arg @ref LL_DAC_CHANNEL_1
  1001. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1002. *
  1003. * (1) On this STM32 serie, parameter not available on all devices.
  1004. * Refer to device datasheet for channels availability.
  1005. * @retval Returned value can be one of the following values:
  1006. * @arg @ref LL_DAC_OUTPUT_BUFFER_ENABLE
  1007. * @arg @ref LL_DAC_OUTPUT_BUFFER_DISABLE
  1008. */
  1009. __STATIC_INLINE uint32_t LL_DAC_GetOutputBuffer(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1010. {
  1011. return (uint32_t)(READ_BIT(DACx->MCR, DAC_MCR_MODE1_1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  1012. >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
  1013. );
  1014. }
  1015. /**
  1016. * @brief Set the output connection for the selected DAC channel.
  1017. * @note On this STM32 serie, output connection depends on output mode (normal or
  1018. * sample and hold) and output buffer state.
  1019. * - if output connection is set to internal path and output buffer
  1020. * is enabled (whatever output mode):
  1021. * output connection is also connected to GPIO pin
  1022. * (both connections to GPIO pin and internal path).
  1023. * - if output connection is set to GPIO pin, output buffer
  1024. * is disabled, output mode set to sample and hold:
  1025. * output connection is also connected to internal path
  1026. * (both connections to GPIO pin and internal path).
  1027. * @rmtoll CR MODE1 LL_DAC_SetOutputConnection\n
  1028. * CR MODE2 LL_DAC_SetOutputConnection
  1029. * @param DACx DAC instance
  1030. * @param DAC_Channel This parameter can be one of the following values:
  1031. * @arg @ref LL_DAC_CHANNEL_1
  1032. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1033. *
  1034. * (1) On this STM32 serie, parameter not available on all devices.
  1035. * Refer to device datasheet for channels availability.
  1036. * @param OutputConnection This parameter can be one of the following values:
  1037. * @arg @ref LL_DAC_OUTPUT_CONNECT_GPIO
  1038. * @arg @ref LL_DAC_OUTPUT_CONNECT_INTERNAL
  1039. * @retval None
  1040. */
  1041. __STATIC_INLINE void LL_DAC_SetOutputConnection(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t OutputConnection)
  1042. {
  1043. MODIFY_REG(DACx->MCR,
  1044. DAC_MCR_MODE1_0 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
  1045. OutputConnection << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  1046. }
  1047. /**
  1048. * @brief Get the output connection for the selected DAC channel.
  1049. * @note On this STM32 serie, output connection depends on output mode (normal or
  1050. * sample and hold) and output buffer state.
  1051. * - if output connection is set to internal path and output buffer
  1052. * is enabled (whatever output mode):
  1053. * output connection is also connected to GPIO pin
  1054. * (both connections to GPIO pin and internal path).
  1055. * - if output connection is set to GPIO pin, output buffer
  1056. * is disabled, output mode set to sample and hold:
  1057. * output connection is also connected to internal path
  1058. * (both connections to GPIO pin and internal path).
  1059. * @rmtoll CR MODE1 LL_DAC_GetOutputConnection\n
  1060. * CR MODE2 LL_DAC_GetOutputConnection
  1061. * @param DACx DAC instance
  1062. * @param DAC_Channel This parameter can be one of the following values:
  1063. * @arg @ref LL_DAC_CHANNEL_1
  1064. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1065. *
  1066. * (1) On this STM32 serie, parameter not available on all devices.
  1067. * Refer to device datasheet for channels availability.
  1068. * @retval Returned value can be one of the following values:
  1069. * @arg @ref LL_DAC_OUTPUT_CONNECT_GPIO
  1070. * @arg @ref LL_DAC_OUTPUT_CONNECT_INTERNAL
  1071. */
  1072. __STATIC_INLINE uint32_t LL_DAC_GetOutputConnection(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1073. {
  1074. return (uint32_t)(READ_BIT(DACx->MCR, DAC_MCR_MODE1_0 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  1075. >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
  1076. );
  1077. }
  1078. /**
  1079. * @brief Set the sample-and-hold timing for the selected DAC channel:
  1080. * sample time
  1081. * @note Sample time must be set when DAC channel is disabled
  1082. * or during DAC operation when DAC channel flag BWSTx is reset,
  1083. * otherwise the setting is ignored.
  1084. * Check BWSTx flag state using function "LL_DAC_IsActiveFlag_BWSTx()".
  1085. * @rmtoll SHSR1 TSAMPLE1 LL_DAC_SetSampleAndHoldSampleTime\n
  1086. * SHSR2 TSAMPLE2 LL_DAC_SetSampleAndHoldSampleTime
  1087. * @param DACx DAC instance
  1088. * @param DAC_Channel This parameter can be one of the following values:
  1089. * @arg @ref LL_DAC_CHANNEL_1
  1090. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1091. *
  1092. * (1) On this STM32 serie, parameter not available on all devices.
  1093. * Refer to device datasheet for channels availability.
  1094. * @param SampleTime Value between Min_Data=0x000 and Max_Data=0x3FF
  1095. * @retval None
  1096. */
  1097. __STATIC_INLINE void LL_DAC_SetSampleAndHoldSampleTime(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t SampleTime)
  1098. {
  1099. register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->SHSR1, __DAC_MASK_SHIFT(DAC_Channel, DAC_REG_SHSRX_REGOFFSET_MASK));
  1100. MODIFY_REG(*preg,
  1101. DAC_SHSR1_TSAMPLE1,
  1102. SampleTime);
  1103. }
  1104. /**
  1105. * @brief Get the sample-and-hold timing for the selected DAC channel:
  1106. * sample time
  1107. * @rmtoll SHSR1 TSAMPLE1 LL_DAC_GetSampleAndHoldSampleTime\n
  1108. * SHSR2 TSAMPLE2 LL_DAC_GetSampleAndHoldSampleTime
  1109. * @param DACx DAC instance
  1110. * @param DAC_Channel This parameter can be one of the following values:
  1111. * @arg @ref LL_DAC_CHANNEL_1
  1112. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1113. *
  1114. * (1) On this STM32 serie, parameter not available on all devices.
  1115. * Refer to device datasheet for channels availability.
  1116. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  1117. */
  1118. __STATIC_INLINE uint32_t LL_DAC_GetSampleAndHoldSampleTime(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1119. {
  1120. register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->SHSR1, __DAC_MASK_SHIFT(DAC_Channel, DAC_REG_SHSRX_REGOFFSET_MASK));
  1121. return (uint32_t) READ_BIT(*preg, DAC_SHSR1_TSAMPLE1);
  1122. }
  1123. /**
  1124. * @brief Set the sample-and-hold timing for the selected DAC channel:
  1125. * hold time
  1126. * @rmtoll SHHR THOLD1 LL_DAC_SetSampleAndHoldHoldTime\n
  1127. * SHHR THOLD2 LL_DAC_SetSampleAndHoldHoldTime
  1128. * @param DACx DAC instance
  1129. * @param DAC_Channel This parameter can be one of the following values:
  1130. * @arg @ref LL_DAC_CHANNEL_1
  1131. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1132. *
  1133. * (1) On this STM32 serie, parameter not available on all devices.
  1134. * Refer to device datasheet for channels availability.
  1135. * @param HoldTime Value between Min_Data=0x000 and Max_Data=0x3FF
  1136. * @retval None
  1137. */
  1138. __STATIC_INLINE void LL_DAC_SetSampleAndHoldHoldTime(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t HoldTime)
  1139. {
  1140. MODIFY_REG(DACx->SHHR,
  1141. DAC_SHHR_THOLD1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
  1142. HoldTime << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  1143. }
  1144. /**
  1145. * @brief Get the sample-and-hold timing for the selected DAC channel:
  1146. * hold time
  1147. * @rmtoll SHHR THOLD1 LL_DAC_GetSampleAndHoldHoldTime\n
  1148. * SHHR THOLD2 LL_DAC_GetSampleAndHoldHoldTime
  1149. * @param DACx DAC instance
  1150. * @param DAC_Channel This parameter can be one of the following values:
  1151. * @arg @ref LL_DAC_CHANNEL_1
  1152. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1153. *
  1154. * (1) On this STM32 serie, parameter not available on all devices.
  1155. * Refer to device datasheet for channels availability.
  1156. * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
  1157. */
  1158. __STATIC_INLINE uint32_t LL_DAC_GetSampleAndHoldHoldTime(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1159. {
  1160. return (uint32_t)(READ_BIT(DACx->SHHR, DAC_SHHR_THOLD1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  1161. >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
  1162. );
  1163. }
  1164. /**
  1165. * @brief Set the sample-and-hold timing for the selected DAC channel:
  1166. * refresh time
  1167. * @rmtoll SHRR TREFRESH1 LL_DAC_SetSampleAndHoldRefreshTime\n
  1168. * SHRR TREFRESH2 LL_DAC_SetSampleAndHoldRefreshTime
  1169. * @param DACx DAC instance
  1170. * @param DAC_Channel This parameter can be one of the following values:
  1171. * @arg @ref LL_DAC_CHANNEL_1
  1172. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1173. *
  1174. * (1) On this STM32 serie, parameter not available on all devices.
  1175. * Refer to device datasheet for channels availability.
  1176. * @param RefreshTime Value between Min_Data=0x00 and Max_Data=0xFF
  1177. * @retval None
  1178. */
  1179. __STATIC_INLINE void LL_DAC_SetSampleAndHoldRefreshTime(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t RefreshTime)
  1180. {
  1181. MODIFY_REG(DACx->SHRR,
  1182. DAC_SHRR_TREFRESH1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK),
  1183. RefreshTime << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  1184. }
  1185. /**
  1186. * @brief Get the sample-and-hold timing for the selected DAC channel:
  1187. * refresh time
  1188. * @rmtoll SHRR TREFRESH1 LL_DAC_GetSampleAndHoldRefreshTime\n
  1189. * SHRR TREFRESH2 LL_DAC_GetSampleAndHoldRefreshTime
  1190. * @param DACx DAC instance
  1191. * @param DAC_Channel This parameter can be one of the following values:
  1192. * @arg @ref LL_DAC_CHANNEL_1
  1193. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1194. *
  1195. * (1) On this STM32 serie, parameter not available on all devices.
  1196. * Refer to device datasheet for channels availability.
  1197. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  1198. */
  1199. __STATIC_INLINE uint32_t LL_DAC_GetSampleAndHoldRefreshTime(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1200. {
  1201. return (uint32_t)(READ_BIT(DACx->SHRR, DAC_SHRR_TREFRESH1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  1202. >> (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
  1203. );
  1204. }
  1205. /**
  1206. * @}
  1207. */
  1208. /** @defgroup DAC_LL_EF_Configuration_Legacy_Functions DAC configuration, legacy functions name
  1209. * @{
  1210. */
  1211. /* Old functions name kept for legacy purpose, to be replaced by the */
  1212. /* current functions name. */
  1213. __STATIC_INLINE void LL_DAC_SetWaveMode(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t WaveMode)
  1214. {
  1215. LL_DAC_SetWaveAutoGeneration(DACx, DAC_Channel, WaveMode);
  1216. }
  1217. __STATIC_INLINE uint32_t LL_DAC_GetWaveMode(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1218. {
  1219. return LL_DAC_GetWaveAutoGeneration(DACx, DAC_Channel);
  1220. }
  1221. /**
  1222. * @}
  1223. */
  1224. /** @defgroup DAC_LL_EF_DMA_Management DMA Management
  1225. * @{
  1226. */
  1227. /**
  1228. * @brief Enable DAC DMA transfer request of the selected channel.
  1229. * @note To configure DMA source address (peripheral address),
  1230. * use function @ref LL_DAC_DMA_GetRegAddr().
  1231. * @rmtoll CR DMAEN1 LL_DAC_EnableDMAReq\n
  1232. * CR DMAEN2 LL_DAC_EnableDMAReq
  1233. * @param DACx DAC instance
  1234. * @param DAC_Channel This parameter can be one of the following values:
  1235. * @arg @ref LL_DAC_CHANNEL_1
  1236. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1237. *
  1238. * (1) On this STM32 serie, parameter not available on all devices.
  1239. * Refer to device datasheet for channels availability.
  1240. * @retval None
  1241. */
  1242. __STATIC_INLINE void LL_DAC_EnableDMAReq(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1243. {
  1244. SET_BIT(DACx->CR,
  1245. DAC_CR_DMAEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  1246. }
  1247. /**
  1248. * @brief Disable DAC DMA transfer request of the selected channel.
  1249. * @note To configure DMA source address (peripheral address),
  1250. * use function @ref LL_DAC_DMA_GetRegAddr().
  1251. * @rmtoll CR DMAEN1 LL_DAC_DisableDMAReq\n
  1252. * CR DMAEN2 LL_DAC_DisableDMAReq
  1253. * @param DACx DAC instance
  1254. * @param DAC_Channel This parameter can be one of the following values:
  1255. * @arg @ref LL_DAC_CHANNEL_1
  1256. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1257. *
  1258. * (1) On this STM32 serie, parameter not available on all devices.
  1259. * Refer to device datasheet for channels availability.
  1260. * @retval None
  1261. */
  1262. __STATIC_INLINE void LL_DAC_DisableDMAReq(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1263. {
  1264. CLEAR_BIT(DACx->CR,
  1265. DAC_CR_DMAEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  1266. }
  1267. /**
  1268. * @brief Get DAC DMA transfer request state of the selected channel.
  1269. * (0: DAC DMA transfer request is disabled, 1: DAC DMA transfer request is enabled)
  1270. * @rmtoll CR DMAEN1 LL_DAC_IsDMAReqEnabled\n
  1271. * CR DMAEN2 LL_DAC_IsDMAReqEnabled
  1272. * @param DACx DAC instance
  1273. * @param DAC_Channel This parameter can be one of the following values:
  1274. * @arg @ref LL_DAC_CHANNEL_1
  1275. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1276. *
  1277. * (1) On this STM32 serie, parameter not available on all devices.
  1278. * Refer to device datasheet for channels availability.
  1279. * @retval State of bit (1 or 0).
  1280. */
  1281. __STATIC_INLINE uint32_t LL_DAC_IsDMAReqEnabled(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1282. {
  1283. return (READ_BIT(DACx->CR,
  1284. DAC_CR_DMAEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  1285. == (DAC_CR_DMAEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)));
  1286. }
  1287. /**
  1288. * @brief Function to help to configure DMA transfer to DAC: retrieve the
  1289. * DAC register address from DAC instance and a list of DAC registers
  1290. * intended to be used (most commonly) with DMA transfer.
  1291. * @note These DAC registers are data holding registers:
  1292. * when DAC conversion is requested, DAC generates a DMA transfer
  1293. * request to have data available in DAC data holding registers.
  1294. * @note This macro is intended to be used with LL DMA driver, refer to
  1295. * function "LL_DMA_ConfigAddresses()".
  1296. * Example:
  1297. * LL_DMA_ConfigAddresses(DMA1,
  1298. * LL_DMA_CHANNEL_1,
  1299. * (uint32_t)&< array or variable >,
  1300. * LL_DAC_DMA_GetRegAddr(DAC1, LL_DAC_CHANNEL_1, LL_DAC_DMA_REG_DATA_12BITS_RIGHT_ALIGNED),
  1301. * LL_DMA_DIRECTION_MEMORY_TO_PERIPH);
  1302. * @rmtoll DHR12R1 DACC1DHR LL_DAC_DMA_GetRegAddr\n
  1303. * DHR12L1 DACC1DHR LL_DAC_DMA_GetRegAddr\n
  1304. * DHR8R1 DACC1DHR LL_DAC_DMA_GetRegAddr\n
  1305. * DHR12R2 DACC2DHR LL_DAC_DMA_GetRegAddr\n
  1306. * DHR12L2 DACC2DHR LL_DAC_DMA_GetRegAddr\n
  1307. * DHR8R2 DACC2DHR LL_DAC_DMA_GetRegAddr
  1308. * @param DACx DAC instance
  1309. * @param DAC_Channel This parameter can be one of the following values:
  1310. * @arg @ref LL_DAC_CHANNEL_1
  1311. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1312. *
  1313. * (1) On this STM32 serie, parameter not available on all devices.
  1314. * Refer to device datasheet for channels availability.
  1315. * @param Register This parameter can be one of the following values:
  1316. * @arg @ref LL_DAC_DMA_REG_DATA_12BITS_RIGHT_ALIGNED
  1317. * @arg @ref LL_DAC_DMA_REG_DATA_12BITS_LEFT_ALIGNED
  1318. * @arg @ref LL_DAC_DMA_REG_DATA_8BITS_RIGHT_ALIGNED
  1319. * @retval DAC register address
  1320. */
  1321. __STATIC_INLINE uint32_t LL_DAC_DMA_GetRegAddr(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t Register)
  1322. {
  1323. /* Retrieve address of register DHR12Rx, DHR12Lx or DHR8Rx depending on */
  1324. /* DAC channel selected. */
  1325. return ((uint32_t)(__DAC_PTR_REG_OFFSET((DACx)->DHR12R1, __DAC_MASK_SHIFT(DAC_Channel, Register))));
  1326. }
  1327. /**
  1328. * @}
  1329. */
  1330. /** @defgroup DAC_LL_EF_Operation Operation on DAC channels
  1331. * @{
  1332. */
  1333. /**
  1334. * @brief Enable DAC selected channel.
  1335. * @rmtoll CR EN1 LL_DAC_Enable\n
  1336. * CR EN2 LL_DAC_Enable
  1337. * @note After enable from off state, DAC channel requires a delay
  1338. * for output voltage to reach accuracy +/- 1 LSB.
  1339. * Refer to device datasheet, parameter "tWAKEUP".
  1340. * @param DACx DAC instance
  1341. * @param DAC_Channel This parameter can be one of the following values:
  1342. * @arg @ref LL_DAC_CHANNEL_1
  1343. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1344. *
  1345. * (1) On this STM32 serie, parameter not available on all devices.
  1346. * Refer to device datasheet for channels availability.
  1347. * @retval None
  1348. */
  1349. __STATIC_INLINE void LL_DAC_Enable(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1350. {
  1351. SET_BIT(DACx->CR,
  1352. DAC_CR_EN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  1353. }
  1354. /**
  1355. * @brief Disable DAC selected channel.
  1356. * @rmtoll CR EN1 LL_DAC_Disable\n
  1357. * CR EN2 LL_DAC_Disable
  1358. * @param DACx DAC instance
  1359. * @param DAC_Channel This parameter can be one of the following values:
  1360. * @arg @ref LL_DAC_CHANNEL_1
  1361. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1362. *
  1363. * (1) On this STM32 serie, parameter not available on all devices.
  1364. * Refer to device datasheet for channels availability.
  1365. * @retval None
  1366. */
  1367. __STATIC_INLINE void LL_DAC_Disable(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1368. {
  1369. CLEAR_BIT(DACx->CR,
  1370. DAC_CR_EN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  1371. }
  1372. /**
  1373. * @brief Get DAC enable state of the selected channel.
  1374. * (0: DAC channel is disabled, 1: DAC channel is enabled)
  1375. * @rmtoll CR EN1 LL_DAC_IsEnabled\n
  1376. * CR EN2 LL_DAC_IsEnabled
  1377. * @param DACx DAC instance
  1378. * @param DAC_Channel This parameter can be one of the following values:
  1379. * @arg @ref LL_DAC_CHANNEL_1
  1380. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1381. *
  1382. * (1) On this STM32 serie, parameter not available on all devices.
  1383. * Refer to device datasheet for channels availability.
  1384. * @retval State of bit (1 or 0).
  1385. */
  1386. __STATIC_INLINE uint32_t LL_DAC_IsEnabled(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1387. {
  1388. return (READ_BIT(DACx->CR,
  1389. DAC_CR_EN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  1390. == (DAC_CR_EN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)));
  1391. }
  1392. /**
  1393. * @brief Enable DAC trigger of the selected channel.
  1394. * @note - If DAC trigger is disabled, DAC conversion is performed
  1395. * automatically once the data holding register is updated,
  1396. * using functions "LL_DAC_ConvertData{8; 12}{Right; Left} Aligned()":
  1397. * @ref LL_DAC_ConvertData12RightAligned(), ...
  1398. * - If DAC trigger is enabled, DAC conversion is performed
  1399. * only when a hardware of software trigger event is occurring.
  1400. * Select trigger source using
  1401. * function @ref LL_DAC_SetTriggerSource().
  1402. * @rmtoll CR TEN1 LL_DAC_EnableTrigger\n
  1403. * CR TEN2 LL_DAC_EnableTrigger
  1404. * @param DACx DAC instance
  1405. * @param DAC_Channel This parameter can be one of the following values:
  1406. * @arg @ref LL_DAC_CHANNEL_1
  1407. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1408. *
  1409. * (1) On this STM32 serie, parameter not available on all devices.
  1410. * Refer to device datasheet for channels availability.
  1411. * @retval None
  1412. */
  1413. __STATIC_INLINE void LL_DAC_EnableTrigger(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1414. {
  1415. SET_BIT(DACx->CR,
  1416. DAC_CR_TEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  1417. }
  1418. /**
  1419. * @brief Disable DAC trigger of the selected channel.
  1420. * @rmtoll CR TEN1 LL_DAC_DisableTrigger\n
  1421. * CR TEN2 LL_DAC_DisableTrigger
  1422. * @param DACx DAC instance
  1423. * @param DAC_Channel This parameter can be one of the following values:
  1424. * @arg @ref LL_DAC_CHANNEL_1
  1425. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1426. *
  1427. * (1) On this STM32 serie, parameter not available on all devices.
  1428. * Refer to device datasheet for channels availability.
  1429. * @retval None
  1430. */
  1431. __STATIC_INLINE void LL_DAC_DisableTrigger(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1432. {
  1433. CLEAR_BIT(DACx->CR,
  1434. DAC_CR_TEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK));
  1435. }
  1436. /**
  1437. * @brief Get DAC trigger state of the selected channel.
  1438. * (0: DAC trigger is disabled, 1: DAC trigger is enabled)
  1439. * @rmtoll CR TEN1 LL_DAC_IsTriggerEnabled\n
  1440. * CR TEN2 LL_DAC_IsTriggerEnabled
  1441. * @param DACx DAC instance
  1442. * @param DAC_Channel This parameter can be one of the following values:
  1443. * @arg @ref LL_DAC_CHANNEL_1
  1444. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1445. *
  1446. * (1) On this STM32 serie, parameter not available on all devices.
  1447. * Refer to device datasheet for channels availability.
  1448. * @retval State of bit (1 or 0).
  1449. */
  1450. __STATIC_INLINE uint32_t LL_DAC_IsTriggerEnabled(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1451. {
  1452. return (READ_BIT(DACx->CR,
  1453. DAC_CR_TEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK))
  1454. == (DAC_CR_TEN1 << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)));
  1455. }
  1456. /**
  1457. * @brief Trig DAC conversion by software for the selected DAC channel.
  1458. * @note Preliminarily, DAC trigger must be set to software trigger
  1459. * using function @ref LL_DAC_SetTriggerSource()
  1460. * with parameter "LL_DAC_TRIGGER_SOFTWARE".
  1461. * and DAC trigger must be enabled using
  1462. * function @ref LL_DAC_EnableTrigger().
  1463. * @note For devices featuring DAC with 2 channels: this function
  1464. * can perform a SW start of both DAC channels simultaneously.
  1465. * Two channels can be selected as parameter.
  1466. * Example: (LL_DAC_CHANNEL_1 | LL_DAC_CHANNEL_2)
  1467. * @rmtoll SWTRIGR SWTRIG1 LL_DAC_TrigSWConversion\n
  1468. * SWTRIGR SWTRIG2 LL_DAC_TrigSWConversion
  1469. * @param DACx DAC instance
  1470. * @param DAC_Channel This parameter can a combination of the following values:
  1471. * @arg @ref LL_DAC_CHANNEL_1
  1472. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1473. *
  1474. * (1) On this STM32 serie, parameter not available on all devices.
  1475. * Refer to device datasheet for channels availability.
  1476. * @retval None
  1477. */
  1478. __STATIC_INLINE void LL_DAC_TrigSWConversion(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1479. {
  1480. SET_BIT(DACx->SWTRIGR,
  1481. (DAC_Channel & DAC_SWTR_CHX_MASK));
  1482. }
  1483. /**
  1484. * @brief Set the data to be loaded in the data holding register
  1485. * in format 12 bits left alignment (LSB aligned on bit 0),
  1486. * for the selected DAC channel.
  1487. * @rmtoll DHR12R1 DACC1DHR LL_DAC_ConvertData12RightAligned\n
  1488. * DHR12R2 DACC2DHR LL_DAC_ConvertData12RightAligned
  1489. * @param DACx DAC instance
  1490. * @param DAC_Channel This parameter can be one of the following values:
  1491. * @arg @ref LL_DAC_CHANNEL_1
  1492. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1493. *
  1494. * (1) On this STM32 serie, parameter not available on all devices.
  1495. * Refer to device datasheet for channels availability.
  1496. * @param Data Value between Min_Data=0x000 and Max_Data=0xFFF
  1497. * @retval None
  1498. */
  1499. __STATIC_INLINE void LL_DAC_ConvertData12RightAligned(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t Data)
  1500. {
  1501. register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->DHR12R1, __DAC_MASK_SHIFT(DAC_Channel, DAC_REG_DHR12RX_REGOFFSET_MASK));
  1502. MODIFY_REG(*preg,
  1503. DAC_DHR12R1_DACC1DHR,
  1504. Data);
  1505. }
  1506. /**
  1507. * @brief Set the data to be loaded in the data holding register
  1508. * in format 12 bits left alignment (MSB aligned on bit 15),
  1509. * for the selected DAC channel.
  1510. * @rmtoll DHR12L1 DACC1DHR LL_DAC_ConvertData12LeftAligned\n
  1511. * DHR12L2 DACC2DHR LL_DAC_ConvertData12LeftAligned
  1512. * @param DACx DAC instance
  1513. * @param DAC_Channel This parameter can be one of the following values:
  1514. * @arg @ref LL_DAC_CHANNEL_1
  1515. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1516. *
  1517. * (1) On this STM32 serie, parameter not available on all devices.
  1518. * Refer to device datasheet for channels availability.
  1519. * @param Data Value between Min_Data=0x000 and Max_Data=0xFFF
  1520. * @retval None
  1521. */
  1522. __STATIC_INLINE void LL_DAC_ConvertData12LeftAligned(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t Data)
  1523. {
  1524. register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->DHR12R1, __DAC_MASK_SHIFT(DAC_Channel, DAC_REG_DHR12LX_REGOFFSET_MASK));
  1525. MODIFY_REG(*preg,
  1526. DAC_DHR12L1_DACC1DHR,
  1527. Data);
  1528. }
  1529. /**
  1530. * @brief Set the data to be loaded in the data holding register
  1531. * in format 8 bits left alignment (LSB aligned on bit 0),
  1532. * for the selected DAC channel.
  1533. * @rmtoll DHR8R1 DACC1DHR LL_DAC_ConvertData8RightAligned\n
  1534. * DHR8R2 DACC2DHR LL_DAC_ConvertData8RightAligned
  1535. * @param DACx DAC instance
  1536. * @param DAC_Channel This parameter can be one of the following values:
  1537. * @arg @ref LL_DAC_CHANNEL_1
  1538. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1539. *
  1540. * (1) On this STM32 serie, parameter not available on all devices.
  1541. * Refer to device datasheet for channels availability.
  1542. * @param Data Value between Min_Data=0x00 and Max_Data=0xFF
  1543. * @retval None
  1544. */
  1545. __STATIC_INLINE void LL_DAC_ConvertData8RightAligned(DAC_TypeDef *DACx, uint32_t DAC_Channel, uint32_t Data)
  1546. {
  1547. register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->DHR12R1, __DAC_MASK_SHIFT(DAC_Channel, DAC_REG_DHR8RX_REGOFFSET_MASK));
  1548. MODIFY_REG(*preg,
  1549. DAC_DHR8R1_DACC1DHR,
  1550. Data);
  1551. }
  1552. #if defined(DAC_CHANNEL2_SUPPORT)
  1553. /**
  1554. * @brief Set the data to be loaded in the data holding register
  1555. * in format 12 bits left alignment (LSB aligned on bit 0),
  1556. * for both DAC channels.
  1557. * @rmtoll DHR12RD DACC1DHR LL_DAC_ConvertDualData12RightAligned\n
  1558. * DHR12RD DACC2DHR LL_DAC_ConvertDualData12RightAligned
  1559. * @param DACx DAC instance
  1560. * @param DataChannel1 Value between Min_Data=0x000 and Max_Data=0xFFF
  1561. * @param DataChannel2 Value between Min_Data=0x000 and Max_Data=0xFFF
  1562. * @retval None
  1563. */
  1564. __STATIC_INLINE void LL_DAC_ConvertDualData12RightAligned(DAC_TypeDef *DACx, uint32_t DataChannel1, uint32_t DataChannel2)
  1565. {
  1566. MODIFY_REG(DACx->DHR12RD,
  1567. (DAC_DHR12RD_DACC2DHR | DAC_DHR12RD_DACC1DHR),
  1568. ((DataChannel2 << DAC_DHR12RD_DACC2DHR_BITOFFSET_POS) | DataChannel1));
  1569. }
  1570. /**
  1571. * @brief Set the data to be loaded in the data holding register
  1572. * in format 12 bits left alignment (MSB aligned on bit 15),
  1573. * for both DAC channels.
  1574. * @rmtoll DHR12LD DACC1DHR LL_DAC_ConvertDualData12LeftAligned\n
  1575. * DHR12LD DACC2DHR LL_DAC_ConvertDualData12LeftAligned
  1576. * @param DACx DAC instance
  1577. * @param DataChannel1 Value between Min_Data=0x000 and Max_Data=0xFFF
  1578. * @param DataChannel2 Value between Min_Data=0x000 and Max_Data=0xFFF
  1579. * @retval None
  1580. */
  1581. __STATIC_INLINE void LL_DAC_ConvertDualData12LeftAligned(DAC_TypeDef *DACx, uint32_t DataChannel1, uint32_t DataChannel2)
  1582. {
  1583. /* Note: Data of DAC channel 2 shift value subtracted of 4 because */
  1584. /* data on 16 bits and DAC channel 2 bits field is on the 12 MSB, */
  1585. /* the 4 LSB must be taken into account for the shift value. */
  1586. MODIFY_REG(DACx->DHR12LD,
  1587. (DAC_DHR12LD_DACC2DHR | DAC_DHR12LD_DACC1DHR),
  1588. ((DataChannel2 << (DAC_DHR12LD_DACC2DHR_BITOFFSET_POS - 4U)) | DataChannel1));
  1589. }
  1590. /**
  1591. * @brief Set the data to be loaded in the data holding register
  1592. * in format 8 bits left alignment (LSB aligned on bit 0),
  1593. * for both DAC channels.
  1594. * @rmtoll DHR8RD DACC1DHR LL_DAC_ConvertDualData8RightAligned\n
  1595. * DHR8RD DACC2DHR LL_DAC_ConvertDualData8RightAligned
  1596. * @param DACx DAC instance
  1597. * @param DataChannel1 Value between Min_Data=0x00 and Max_Data=0xFF
  1598. * @param DataChannel2 Value between Min_Data=0x00 and Max_Data=0xFF
  1599. * @retval None
  1600. */
  1601. __STATIC_INLINE void LL_DAC_ConvertDualData8RightAligned(DAC_TypeDef *DACx, uint32_t DataChannel1, uint32_t DataChannel2)
  1602. {
  1603. MODIFY_REG(DACx->DHR8RD,
  1604. (DAC_DHR8RD_DACC2DHR | DAC_DHR8RD_DACC1DHR),
  1605. ((DataChannel2 << DAC_DHR8RD_DACC2DHR_BITOFFSET_POS) | DataChannel1));
  1606. }
  1607. #endif /* DAC_CHANNEL2_SUPPORT */
  1608. /**
  1609. * @brief Retrieve output data currently generated for the selected DAC channel.
  1610. * @note Whatever alignment and resolution settings
  1611. * (using functions "LL_DAC_ConvertData{8; 12}{Right; Left} Aligned()":
  1612. * @ref LL_DAC_ConvertData12RightAligned(), ...),
  1613. * output data format is 12 bits right aligned (LSB aligned on bit 0).
  1614. * @rmtoll DOR1 DACC1DOR LL_DAC_RetrieveOutputData\n
  1615. * DOR2 DACC2DOR LL_DAC_RetrieveOutputData
  1616. * @param DACx DAC instance
  1617. * @param DAC_Channel This parameter can be one of the following values:
  1618. * @arg @ref LL_DAC_CHANNEL_1
  1619. * @arg @ref LL_DAC_CHANNEL_2 (1)
  1620. *
  1621. * (1) On this STM32 serie, parameter not available on all devices.
  1622. * Refer to device datasheet for channels availability.
  1623. * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
  1624. */
  1625. __STATIC_INLINE uint32_t LL_DAC_RetrieveOutputData(DAC_TypeDef *DACx, uint32_t DAC_Channel)
  1626. {
  1627. register uint32_t *preg = __DAC_PTR_REG_OFFSET(DACx->DOR1, __DAC_MASK_SHIFT(DAC_Channel, DAC_REG_DORX_REGOFFSET_MASK));
  1628. return (uint16_t) READ_BIT(*preg, DAC_DOR1_DACC1DOR);
  1629. }
  1630. /**
  1631. * @}
  1632. */
  1633. /** @defgroup DAC_LL_EF_FLAG_Management FLAG Management
  1634. * @{
  1635. */
  1636. /**
  1637. * @brief Get DAC calibration offset flag for DAC channel 1
  1638. * @rmtoll SR CAL_FLAG1 LL_DAC_IsActiveFlag_CAL1
  1639. * @param DACx DAC instance
  1640. * @retval State of bit (1 or 0).
  1641. */
  1642. __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_CAL1(DAC_TypeDef *DACx)
  1643. {
  1644. return (READ_BIT(DACx->SR, LL_DAC_FLAG_CAL1) == (LL_DAC_FLAG_CAL1));
  1645. }
  1646. #if defined(DAC_CHANNEL2_SUPPORT)
  1647. /**
  1648. * @brief Get DAC calibration offset flag for DAC channel 2
  1649. * @rmtoll SR CAL_FLAG2 LL_DAC_IsActiveFlag_CAL2
  1650. * @param DACx DAC instance
  1651. * @retval State of bit (1 or 0).
  1652. */
  1653. __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_CAL2(DAC_TypeDef *DACx)
  1654. {
  1655. return (READ_BIT(DACx->SR, LL_DAC_FLAG_CAL2) == (LL_DAC_FLAG_CAL2));
  1656. }
  1657. #endif /* DAC_CHANNEL2_SUPPORT */
  1658. /**
  1659. * @brief Get DAC busy writing sample time flag for DAC channel 1
  1660. * @rmtoll SR BWST1 LL_DAC_IsActiveFlag_BWST1
  1661. * @param DACx DAC instance
  1662. * @retval State of bit (1 or 0).
  1663. */
  1664. __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_BWST1(DAC_TypeDef *DACx)
  1665. {
  1666. return (READ_BIT(DACx->SR, LL_DAC_FLAG_BWST1) == (LL_DAC_FLAG_BWST1));
  1667. }
  1668. #if defined(DAC_CHANNEL2_SUPPORT)
  1669. /**
  1670. * @brief Get DAC busy writing sample time flag for DAC channel 2
  1671. * @rmtoll SR BWST2 LL_DAC_IsActiveFlag_BWST2
  1672. * @param DACx DAC instance
  1673. * @retval State of bit (1 or 0).
  1674. */
  1675. __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_BWST2(DAC_TypeDef *DACx)
  1676. {
  1677. return (READ_BIT(DACx->SR, LL_DAC_FLAG_BWST2) == (LL_DAC_FLAG_BWST2));
  1678. }
  1679. #endif /* DAC_CHANNEL2_SUPPORT */
  1680. /**
  1681. * @brief Get DAC underrun flag for DAC channel 1
  1682. * @rmtoll SR DMAUDR1 LL_DAC_IsActiveFlag_DMAUDR1
  1683. * @param DACx DAC instance
  1684. * @retval State of bit (1 or 0).
  1685. */
  1686. __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_DMAUDR1(DAC_TypeDef *DACx)
  1687. {
  1688. return (READ_BIT(DACx->SR, LL_DAC_FLAG_DMAUDR1) == (LL_DAC_FLAG_DMAUDR1));
  1689. }
  1690. #if defined(DAC_CHANNEL2_SUPPORT)
  1691. /**
  1692. * @brief Get DAC underrun flag for DAC channel 2
  1693. * @rmtoll SR DMAUDR2 LL_DAC_IsActiveFlag_DMAUDR2
  1694. * @param DACx DAC instance
  1695. * @retval State of bit (1 or 0).
  1696. */
  1697. __STATIC_INLINE uint32_t LL_DAC_IsActiveFlag_DMAUDR2(DAC_TypeDef *DACx)
  1698. {
  1699. return (READ_BIT(DACx->SR, LL_DAC_FLAG_DMAUDR2) == (LL_DAC_FLAG_DMAUDR2));
  1700. }
  1701. #endif /* DAC_CHANNEL2_SUPPORT */
  1702. /**
  1703. * @brief Clear DAC underrun flag for DAC channel 1
  1704. * @rmtoll SR DMAUDR1 LL_DAC_ClearFlag_DMAUDR1
  1705. * @param DACx DAC instance
  1706. * @retval None
  1707. */
  1708. __STATIC_INLINE void LL_DAC_ClearFlag_DMAUDR1(DAC_TypeDef *DACx)
  1709. {
  1710. WRITE_REG(DACx->SR, LL_DAC_FLAG_DMAUDR1);
  1711. }
  1712. #if defined(DAC_CHANNEL2_SUPPORT)
  1713. /**
  1714. * @brief Clear DAC underrun flag for DAC channel 2
  1715. * @rmtoll SR DMAUDR2 LL_DAC_ClearFlag_DMAUDR2
  1716. * @param DACx DAC instance
  1717. * @retval None
  1718. */
  1719. __STATIC_INLINE void LL_DAC_ClearFlag_DMAUDR2(DAC_TypeDef *DACx)
  1720. {
  1721. WRITE_REG(DACx->SR, LL_DAC_FLAG_DMAUDR2);
  1722. }
  1723. #endif /* DAC_CHANNEL2_SUPPORT */
  1724. /**
  1725. * @}
  1726. */
  1727. /** @defgroup DAC_LL_EF_IT_Management IT management
  1728. * @{
  1729. */
  1730. /**
  1731. * @brief Enable DMA underrun interrupt for DAC channel 1
  1732. * @rmtoll CR DMAUDRIE1 LL_DAC_EnableIT_DMAUDR1
  1733. * @param DACx DAC instance
  1734. * @retval None
  1735. */
  1736. __STATIC_INLINE void LL_DAC_EnableIT_DMAUDR1(DAC_TypeDef *DACx)
  1737. {
  1738. SET_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE1);
  1739. }
  1740. #if defined(DAC_CHANNEL2_SUPPORT)
  1741. /**
  1742. * @brief Enable DMA underrun interrupt for DAC channel 2
  1743. * @rmtoll CR DMAUDRIE2 LL_DAC_EnableIT_DMAUDR2
  1744. * @param DACx DAC instance
  1745. * @retval None
  1746. */
  1747. __STATIC_INLINE void LL_DAC_EnableIT_DMAUDR2(DAC_TypeDef *DACx)
  1748. {
  1749. SET_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE2);
  1750. }
  1751. #endif /* DAC_CHANNEL2_SUPPORT */
  1752. /**
  1753. * @brief Disable DMA underrun interrupt for DAC channel 1
  1754. * @rmtoll CR DMAUDRIE1 LL_DAC_DisableIT_DMAUDR1
  1755. * @param DACx DAC instance
  1756. * @retval None
  1757. */
  1758. __STATIC_INLINE void LL_DAC_DisableIT_DMAUDR1(DAC_TypeDef *DACx)
  1759. {
  1760. CLEAR_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE1);
  1761. }
  1762. #if defined(DAC_CHANNEL2_SUPPORT)
  1763. /**
  1764. * @brief Disable DMA underrun interrupt for DAC channel 2
  1765. * @rmtoll CR DMAUDRIE2 LL_DAC_DisableIT_DMAUDR2
  1766. * @param DACx DAC instance
  1767. * @retval None
  1768. */
  1769. __STATIC_INLINE void LL_DAC_DisableIT_DMAUDR2(DAC_TypeDef *DACx)
  1770. {
  1771. CLEAR_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE2);
  1772. }
  1773. #endif /* DAC_CHANNEL2_SUPPORT */
  1774. /**
  1775. * @brief Get DMA underrun interrupt for DAC channel 1
  1776. * @rmtoll CR DMAUDRIE1 LL_DAC_IsEnabledIT_DMAUDR1
  1777. * @param DACx DAC instance
  1778. * @retval State of bit (1 or 0).
  1779. */
  1780. __STATIC_INLINE uint32_t LL_DAC_IsEnabledIT_DMAUDR1(DAC_TypeDef *DACx)
  1781. {
  1782. return (READ_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE1) == (LL_DAC_IT_DMAUDRIE1));
  1783. }
  1784. #if defined(DAC_CHANNEL2_SUPPORT)
  1785. /**
  1786. * @brief Get DMA underrun interrupt for DAC channel 2
  1787. * @rmtoll CR DMAUDRIE2 LL_DAC_IsEnabledIT_DMAUDR2
  1788. * @param DACx DAC instance
  1789. * @retval State of bit (1 or 0).
  1790. */
  1791. __STATIC_INLINE uint32_t LL_DAC_IsEnabledIT_DMAUDR2(DAC_TypeDef *DACx)
  1792. {
  1793. return (READ_BIT(DACx->CR, LL_DAC_IT_DMAUDRIE2) == (LL_DAC_IT_DMAUDRIE2));
  1794. }
  1795. #endif /* DAC_CHANNEL2_SUPPORT */
  1796. /**
  1797. * @}
  1798. */
  1799. #if defined(USE_FULL_LL_DRIVER)
  1800. /** @defgroup DAC_LL_EF_Init Initialization and de-initialization functions
  1801. * @{
  1802. */
  1803. ErrorStatus LL_DAC_DeInit(DAC_TypeDef* DACx);
  1804. ErrorStatus LL_DAC_Init(DAC_TypeDef* DACx, uint32_t DAC_Channel, LL_DAC_InitTypeDef* DAC_InitStruct);
  1805. void LL_DAC_StructInit(LL_DAC_InitTypeDef* DAC_InitStruct);
  1806. /**
  1807. * @}
  1808. */
  1809. #endif /* USE_FULL_LL_DRIVER */
  1810. /**
  1811. * @}
  1812. */
  1813. /**
  1814. * @}
  1815. */
  1816. #endif /* DAC1 */
  1817. /**
  1818. * @}
  1819. */
  1820. #ifdef __cplusplus
  1821. }
  1822. #endif
  1823. #endif /* __STM32L4xx_LL_DAC_H */
  1824. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/