stm32l4xx_ll_dac.h 96 KB

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