stm32l4xx_ll_dac.h 92 KB

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