stm32f3xx_hal_dac.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_hal_dac.c
  4. * @author MCD Application Team
  5. * @brief DAC HAL module driver.
  6. * This file provides firmware functions to manage the following
  7. * functionalities of the Digital to Analog Converter (DAC) peripheral:
  8. * + Initialization and de-initialization functions
  9. * + IO operation functions
  10. * + Peripheral Control functions
  11. * + Peripheral State and Errors functions
  12. *
  13. *
  14. @verbatim
  15. ==============================================================================
  16. ##### DAC Peripheral features #####
  17. ==============================================================================
  18. [..]
  19. *** DAC Channels ***
  20. ====================
  21. [..]
  22. The device integrates up to 3 12-bit Digital Analog Converters that can
  23. be used independently or simultaneously (dual mode):
  24. (#) DAC1 channel1 with DAC1_OUT1 (PA4) as output
  25. (#) DAC1 channel2 with DAC1_OUT2 (PA5) as output
  26. (for STM32F3 devices having 2 channels on DAC1)
  27. (#) DAC2 channel1 with DAC2_OUT1 (PA6) as output
  28. (for STM32F3 devices having 2 DAC)
  29. *** DAC Triggers ***
  30. ====================
  31. [..]
  32. Digital to Analog conversion can be non-triggered using DAC_TRIGGER_NONE
  33. and DAC1_OUT1/DAC1_OUT2/DAC2_OUT1 is available once writing to DHRx register.
  34. [..]
  35. Digital to Analog conversion can be triggered by:
  36. (#) External event: EXTI Line 9 (any GPIOx_PIN_9) using DAC_TRIGGER_EXT_IT9.
  37. The used pin (GPIOx_PIN_9) must be configured in input mode.
  38. (#) Timers TRGO: TIM2, TIM4, TIM5, TIM6, TIM7 and TIM8
  39. (DAC_TRIGGER_T2_TRGO, DAC_TRIGGER_T4_TRGO...)
  40. (#) Software using DAC_TRIGGER_SOFTWARE
  41. *** DAC Buffer mode feature ***
  42. ===============================
  43. [..]
  44. Each DAC channel integrates an output buffer that can be used to
  45. reduce the output impedance, and to drive external loads directly
  46. without having to add an external operational amplifier.
  47. To enable, the output buffer use
  48. sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
  49. Or
  50. An output switch
  51. (in STM32F303x4, STM32F303x6, STM32F303x8
  52. c, STM32F334x6, STM32F334x8
  53. & STM32F334xx).
  54. To enable, the output switch
  55. sConfig.DAC_OutputSwitch = DAC_OUTPUTSWITCH_ENABLE;
  56. [..]
  57. (@) Refer to the device datasheet for more details about output
  58. impedance value with and without output buffer.
  59. *** GPIO configurations guidelines ***
  60. =====================
  61. [..]
  62. When a DAC channel is used (ex channel1 on PA4) and the other is not
  63. (ex channel2 on PA5 is configured in Analog and disabled).
  64. Channel1 may disturb channel2 as coupling effect.
  65. Note that there is no coupling on channel2 as soon as channel2 is turned on.
  66. Coupling on adjacent channel could be avoided as follows:
  67. when unused PA5 is configured as INPUT PULL-UP or DOWN.
  68. PA5 is configured in ANALOG just before it is turned on.
  69. *** DAC wave generation feature ***
  70. ===================================
  71. [..]
  72. Both DAC channels of DAC1 can be used to generate
  73. note that wave generation is not available in DAC2.
  74. (#) Noise wave
  75. (#) Triangle wave
  76. Wave generation is NOT available in DAC2.
  77. *** DAC data format ***
  78. =======================
  79. [..]
  80. The DAC data format can be:
  81. (#) 8-bit right alignment using DAC_ALIGN_8B_R
  82. (#) 12-bit left alignment using DAC_ALIGN_12B_L
  83. (#) 12-bit right alignment using DAC_ALIGN_12B_R
  84. *** DAC data value to voltage correspondance ***
  85. ================================================
  86. [..]
  87. The analog output voltage on each DAC channel pin is determined
  88. by the following equation:
  89. [..]
  90. DAC_OUTx = VREF+ * DOR / 4095
  91. (+) with DOR is the Data Output Register
  92. [..]
  93. VEF+ is the input voltage reference (refer to the device datasheet)
  94. [..]
  95. e.g. To set DAC_OUT1 to 0.7V, use
  96. (+) Assuming that VREF+ = 3.3V, DAC_OUT1 = (3.3U * 868U) / 4095U = 0.7V
  97. *** DMA requests ***
  98. =====================
  99. [..]
  100. A DMA1 or DMA2 request can be generated when an external trigger
  101. (but not a software trigger) occurs if DMA1 or DMA2 requests are
  102. enabled using HAL_DAC_Start_DMA().
  103. [..]
  104. DMA1 requests are mapped as following:
  105. (#) DAC1 channel1: mapped either on
  106. (++) DMA1 channel3
  107. (++) or DMA2 channel3 (for STM32F3 devices having 2 DMA)
  108. which must be already configured
  109. (#) DAC1 channel2:
  110. (for STM32F3 devices having 2 channels on DAC1)
  111. mapped either on
  112. (++) DMA1 channel4
  113. (++) or DMA2 channel4 (for STM32F3 devices having 2 DMA)
  114. which must be already configured
  115. (#) DAC2 channel1: mapped either on
  116. (for STM32F3 devices having 2 DAC)
  117. (++) DMA1 channel4
  118. (++) or DMA2 channel4 (for STM32F3 devices having 2 DMA)
  119. which must be already configured
  120. (@) For Dual mode and specific signal (Triangle and noise) generation please
  121. refer to Extended Features Driver description
  122. ##### How to use this driver #####
  123. ==============================================================================
  124. [..]
  125. (+) DAC APB clock must be enabled to get write access to DAC
  126. registers using HAL_DAC_Init()
  127. (+) Configure DAC_OUTx (DAC_OUT1: PA4, DAC_OUT2: PA5) in analog mode.
  128. (+) Configure the DAC channel using HAL_DAC_ConfigChannel() function.
  129. (+) Enable the DAC channel using HAL_DAC_Start() or HAL_DAC_Start_DMA() functions
  130. *** Polling mode IO operation ***
  131. =================================
  132. [..]
  133. (+) Start the DAC peripheral using HAL_DAC_Start()
  134. (+) To read the DAC last data output value, use the HAL_DAC_GetValue() function.
  135. (+) Stop the DAC peripheral using HAL_DAC_Stop()
  136. *** DMA mode IO operation ***
  137. ==============================
  138. [..]
  139. (+) Start the DAC peripheral using HAL_DAC_Start_DMA(), at this stage the user specify the length
  140. of data to be transferred at each end of conversion
  141. (+) At the middle of data transfer HAL_DAC_ConvHalfCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2()
  142. function is executed and user can add his own code by customization of function pointer
  143. HAL_DAC_ConvHalfCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2()
  144. (+) At The end of data transfer HAL_DAC_ConvCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2()
  145. function is executed and user can add his own code by customization of function pointer
  146. HAL_DAC_ConvCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2()
  147. (+) In case of transfer Error, HAL_DAC_ErrorCallbackCh1() function is executed and user can
  148. add his own code by customization of function pointer HAL_DAC_ErrorCallbackCh1
  149. (+) In case of DMA underrun, DAC interruption triggers and execute internal function HAL_DAC_IRQHandler.
  150. HAL_DAC_DMAUnderrunCallbackCh1() or HAL_DACEx_DMAUnderrunCallbackCh2()
  151. function is executed and user can add his own code by customization of function pointer
  152. HAL_DAC_DMAUnderrunCallbackCh1() or HAL_DACEx_DMAUnderrunCallbackCh2() and
  153. add his own code by customization of function pointer HAL_DAC_ErrorCallbackCh1()
  154. (+) Stop the DAC peripheral using HAL_DAC_Stop_DMA()
  155. *** DAC HAL driver macros list ***
  156. =============================================
  157. [..]
  158. Below the list of most used macros in DAC HAL driver.
  159. (+) __HAL_DAC_ENABLE : Enable the DAC peripheral
  160. (+) __HAL_DAC_DISABLE : Disable the DAC peripheral
  161. (+) __HAL_DAC_CLEAR_FLAG: Clear the DAC's pending flags
  162. (+) __HAL_DAC_GET_FLAG: Get the selected DAC's flag status
  163. [..]
  164. (@) You can refer to the DAC HAL driver header file for more useful macros
  165. @endverbatim
  166. ******************************************************************************
  167. * @attention
  168. *
  169. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  170. *
  171. * Redistribution and use in source and binary forms, with or without modification,
  172. * are permitted provided that the following conditions are met:
  173. * 1. Redistributions of source code must retain the above copyright notice,
  174. * this list of conditions and the following disclaimer.
  175. * 2. Redistributions in binary form must reproduce the above copyright notice,
  176. * this list of conditions and the following disclaimer in the documentation
  177. * and/or other materials provided with the distribution.
  178. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  179. * may be used to endorse or promote products derived from this software
  180. * without specific prior written permission.
  181. *
  182. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  183. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  184. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  185. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  186. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  187. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  188. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  189. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  190. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  191. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  192. *
  193. ******************************************************************************
  194. */
  195. /* Includes ------------------------------------------------------------------*/
  196. #include "stm32f3xx_hal.h"
  197. /** @addtogroup STM32F3xx_HAL_Driver
  198. * @{
  199. */
  200. /** @defgroup DAC DAC
  201. * @brief DAC HAL module driver
  202. * @{
  203. */
  204. #ifdef HAL_DAC_MODULE_ENABLED
  205. /* Private typedef -----------------------------------------------------------*/
  206. /* Private define ------------------------------------------------------------*/
  207. /* Private macro -------------------------------------------------------------*/
  208. /** @defgroup DAC_Private_Macros DAC Private Macros
  209. * @{
  210. */
  211. /**
  212. * @}
  213. */
  214. /* Private variables ---------------------------------------------------------*/
  215. /* Private function prototypes -----------------------------------------------*/
  216. /** @defgroup DAC_Private_Functions DAC Private Functions
  217. * @{
  218. */
  219. /**
  220. * @}
  221. */
  222. /* Exported functions -------------------------------------------------------*/
  223. /** @defgroup DAC_Exported_Functions DAC Exported Functions
  224. * @{
  225. */
  226. /** @defgroup DAC_Exported_Functions_Group1 Initialization and de-initialization functions
  227. * @brief Initialization and Configuration functions
  228. *
  229. @verbatim
  230. ==============================================================================
  231. ##### Initialization and de-initialization functions #####
  232. ==============================================================================
  233. [..] This section provides functions allowing to:
  234. (+) Initialize and configure the DAC.
  235. (+) De-initialize the DAC.
  236. @endverbatim
  237. * @{
  238. */
  239. /**
  240. * @brief Initialize the DAC peripheral according to the specified parameters
  241. * in the DAC_InitStruct and initialize the associated handle.
  242. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  243. * the configuration information for the specified DAC.
  244. * @retval HAL status
  245. */
  246. HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef* hdac)
  247. {
  248. /* Check DAC handle */
  249. if(hdac == NULL)
  250. {
  251. return HAL_ERROR;
  252. }
  253. /* Check the parameters */
  254. assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance));
  255. if(hdac->State == HAL_DAC_STATE_RESET)
  256. {
  257. /* Allocate lock resource and initialize it */
  258. hdac->Lock = HAL_UNLOCKED;
  259. /* Init the low level hardware */
  260. HAL_DAC_MspInit(hdac);
  261. }
  262. /* Initialize the DAC state*/
  263. hdac->State = HAL_DAC_STATE_BUSY;
  264. /* Set DAC error code to none */
  265. hdac->ErrorCode = HAL_DAC_ERROR_NONE;
  266. /* Initialize the DAC state*/
  267. hdac->State = HAL_DAC_STATE_READY;
  268. /* Return function status */
  269. return HAL_OK;
  270. }
  271. /**
  272. * @brief Deinitialize the DAC peripheral registers to their default reset values.
  273. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  274. * the configuration information for the specified DAC.
  275. * @retval HAL status
  276. */
  277. HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef* hdac)
  278. {
  279. /* Check DAC handle */
  280. if(hdac == NULL)
  281. {
  282. return HAL_ERROR;
  283. }
  284. /* Check the parameters */
  285. assert_param(IS_DAC_ALL_INSTANCE(hdac->Instance));
  286. /* Change DAC state */
  287. hdac->State = HAL_DAC_STATE_BUSY;
  288. /* DeInit the low level hardware */
  289. HAL_DAC_MspDeInit(hdac);
  290. /* Set DAC error code to none */
  291. hdac->ErrorCode = HAL_DAC_ERROR_NONE;
  292. /* Change DAC state */
  293. hdac->State = HAL_DAC_STATE_RESET;
  294. /* Release Lock */
  295. __HAL_UNLOCK(hdac);
  296. /* Return function status */
  297. return HAL_OK;
  298. }
  299. /**
  300. * @brief Initialize the DAC MSP.
  301. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  302. * the configuration information for the specified DAC.
  303. * @retval None
  304. */
  305. __weak void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac)
  306. {
  307. /* Prevent unused argument(s) compilation warning */
  308. UNUSED(hdac);
  309. /* NOTE : This function should not be modified, when the callback is needed,
  310. the HAL_DAC_MspInit could be implemented in the user file
  311. */
  312. }
  313. /**
  314. * @brief DeInitialize the DAC MSP.
  315. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  316. * the configuration information for the specified DAC.
  317. * @retval None
  318. */
  319. __weak void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac)
  320. {
  321. /* Prevent unused argument(s) compilation warning */
  322. UNUSED(hdac);
  323. /* NOTE : This function should not be modified, when the callback is needed,
  324. the HAL_DAC_MspDeInit could be implemented in the user file
  325. */
  326. }
  327. /**
  328. * @}
  329. */
  330. /** @defgroup DAC_Exported_Functions_Group2 Input and Output operation functions
  331. * @brief IO operation functions
  332. *
  333. @verbatim
  334. ==============================================================================
  335. ##### IO operation functions #####
  336. ==============================================================================
  337. [..] This section provides functions allowing to:
  338. (+) Start conversion.
  339. (+) Stop conversion.
  340. (+) Start conversion and enable DMA transfer.
  341. (+) Stop conversion and disable DMA transfer.
  342. (+) Get result of conversion.
  343. (+) Get result of dual mode conversion.
  344. @endverbatim
  345. * @{
  346. */
  347. /**
  348. * @brief Enables DAC and starts conversion of channel.
  349. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  350. * the configuration information for the specified DAC.
  351. * @param Channel The selected DAC channel.
  352. * This parameter can be one of the following values:
  353. * @arg DAC_CHANNEL_1: DAC1 Channel1 selected
  354. * @arg DAC_CHANNEL_2: DAC1 Channel2 selected
  355. * @arg DAC_CHANNEL_1: DAC2 Channel1 selected
  356. * @retval HAL status
  357. */
  358. __weak HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel)
  359. {
  360. /* Prevent unused argument(s) compilation warning */
  361. UNUSED(hdac);
  362. UNUSED(Channel);
  363. /* Note : This function is defined into this file for library reference */
  364. /* Function content is located into file stm32f3xx_hal_dac_ex.c */
  365. /* Return function status */
  366. return HAL_ERROR;
  367. }
  368. /**
  369. * @brief Disables DAC and stop conversion of channel.
  370. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  371. * the configuration information for the specified DAC.
  372. * @param Channel The selected DAC channel.
  373. * This parameter can be one of the following values:
  374. * @arg DAC_CHANNEL_1: DAC1 Channel1 selected
  375. * @arg DAC_CHANNEL_2: DAC1 Channel2 selected
  376. * @arg DAC_CHANNEL_1: DAC2 Channel1 selected
  377. * @retval HAL status
  378. */
  379. HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef* hdac, uint32_t Channel)
  380. {
  381. /* Check the parameters */
  382. assert_param(IS_DAC_CHANNEL_INSTANCE(hdac->Instance, Channel));
  383. /* Disable the Peripheral */
  384. __HAL_DAC_DISABLE(hdac, Channel);
  385. /* Change DAC state */
  386. hdac->State = HAL_DAC_STATE_READY;
  387. /* Return function status */
  388. return HAL_OK;
  389. }
  390. /**
  391. * @brief Disables DAC and stop conversion of channel.
  392. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  393. * the configuration information for the specified DAC.
  394. * @param Channel The selected DAC channel.
  395. * This parameter can be one of the following values:
  396. * @arg DAC_CHANNEL_1: DAC1 Channel1 selected
  397. * @arg DAC_CHANNEL_2: DAC1 Channel2 selected
  398. * @arg DAC_CHANNEL_1: DAC2 Channel1 selected
  399. * @retval HAL status
  400. */
  401. HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel)
  402. {
  403. HAL_StatusTypeDef status = HAL_OK;
  404. /* Check the parameters */
  405. assert_param(IS_DAC_CHANNEL_INSTANCE(hdac->Instance, Channel));
  406. /* Disable the selected DAC channel DMA request */
  407. hdac->Instance->CR &= ~(DAC_CR_DMAEN1 << Channel);
  408. /* Disable the Peripheral */
  409. __HAL_DAC_DISABLE(hdac, Channel);
  410. /* Disable the DMA channel */
  411. /* Channel1 is used */
  412. if (Channel == DAC_CHANNEL_1)
  413. {
  414. /* Disable the DMA channel */
  415. status = HAL_DMA_Abort(hdac->DMA_Handle1);
  416. /* Disable the DAC DMA underrun interrupt */
  417. __HAL_DAC_DISABLE_IT(hdac, DAC_IT_DMAUDR1);
  418. }
  419. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  420. defined(STM32F303xC) || defined(STM32F358xx) || \
  421. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  422. defined(STM32F373xC) || defined(STM32F378xx)
  423. /* For all products including channel 2U */
  424. /* DAC channel 2 is available on top of DAC channel 1U */
  425. else /* Channel2 is used for */
  426. {
  427. /* Disable the DMA channel */
  428. status = HAL_DMA_Abort(hdac->DMA_Handle2);
  429. /* Disable the DAC DMA underrun interrupt */
  430. __HAL_DAC_DISABLE_IT(hdac, DAC_IT_DMAUDR2);
  431. }
  432. #endif
  433. /* Check if DMA Channel effectively disabled */
  434. if (status != HAL_OK)
  435. {
  436. /* Update DAC state machine to error */
  437. hdac->State = HAL_DAC_STATE_ERROR;
  438. }
  439. else
  440. {
  441. /* Change DAC state */
  442. hdac->State = HAL_DAC_STATE_READY;
  443. }
  444. /* Return function status */
  445. return status;
  446. }
  447. /**
  448. * @brief Returns the last data output value of the selected DAC channel.
  449. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  450. * the configuration information for the specified DAC.
  451. * @param Channel The selected DAC channel.
  452. * This parameter can be one of the following values:
  453. * @arg DAC_CHANNEL_1: DAC1 Channel1 selected
  454. * @arg DAC_CHANNEL_2: DAC1 Channel2 selected
  455. * @arg DAC_CHANNEL_1: DAC2 Channel1 selected
  456. * @retval The selected DAC channel data output value.
  457. */
  458. __weak uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel)
  459. {
  460. /* Prevent unused argument(s) compilation warning */
  461. UNUSED(hdac);
  462. UNUSED(Channel);
  463. /* Note : This function is defined into this file for library reference */
  464. /* Function content is located into file stm32f3xx_hal_dac_ex.c */
  465. /* Return function status */
  466. return HAL_OK;
  467. }
  468. /**
  469. * @brief Returns the last data output value of the selected DAC channel.
  470. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  471. * the configuration information for the specified DAC.
  472. * @retval The selected DAC channel data output value.
  473. */
  474. __weak uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac)
  475. {
  476. /* Prevent unused argument(s) compilation warning */
  477. UNUSED(hdac);
  478. /* Note : This function is defined into this file for library reference */
  479. /* Function content is located into file stm32f3xx_hal_dac_ex.c */
  480. /* Return function status */
  481. return HAL_OK;
  482. }
  483. /**
  484. * @}
  485. */
  486. /** @defgroup DAC_Exported_Functions_Group3 Peripheral Control functions
  487. * @brief Peripheral Control functions
  488. *
  489. @verbatim
  490. ==============================================================================
  491. ##### Peripheral Control functions #####
  492. ==============================================================================
  493. [..] This section provides functions allowing to:
  494. (+) Configure channels.
  495. (+) Configure Triangle wave generation.
  496. (+) Configure Noise wave generation.
  497. (+) Set the specified data holding register value for DAC channel.
  498. (+) Set the specified data holding register value for Dual DAC channels.
  499. @endverbatim
  500. * @{
  501. */
  502. /**
  503. * @brief Configures the selected DAC channel.
  504. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  505. * the configuration information for the specified DAC.
  506. * @param sConfig DAC configuration structure.
  507. * @param Channel The selected DAC channel.
  508. * This parameter can be one of the following values:
  509. * @arg DAC_CHANNEL_1: DAC1 Channel1 selected
  510. * @arg DAC_CHANNEL_2: DAC1 Channel2 selected
  511. * @arg DAC_CHANNEL_1: DAC2 Channel1 selected
  512. * @retval HAL status
  513. */
  514. __weak HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel)
  515. {
  516. /* Prevent unused argument(s) compilation warning */
  517. UNUSED(hdac);
  518. UNUSED(sConfig);
  519. UNUSED(Channel);
  520. /* Return function status */
  521. return HAL_OK;
  522. }
  523. __weak HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data)
  524. {
  525. /* Prevent unused argument(s) compilation warning */
  526. UNUSED(hdac);
  527. UNUSED(Channel);
  528. UNUSED(Alignment);
  529. UNUSED(Data);
  530. /* Note : This function is defined into this file for library reference */
  531. /* Function content is located into file stm32f3xx_hal_dac_ex.c */
  532. /* Return function status */
  533. return HAL_ERROR;
  534. }
  535. __weak HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2)
  536. {
  537. /* Prevent unused argument(s) compilation warning */
  538. UNUSED(hdac);
  539. UNUSED(Alignment);
  540. UNUSED(Data1);
  541. UNUSED(Data2);
  542. /* Note : This function is defined into this file for library reference */
  543. /* Function content is located into file stm32f3xx_hal_dac_ex.c */
  544. /* Return function status */
  545. return HAL_ERROR;
  546. }
  547. /**
  548. * @}
  549. */
  550. /** @defgroup DAC_Exported_Functions_Group4 Peripheral State and Error functions
  551. * @brief DAC Peripheral State and Error functions
  552. *
  553. @verbatim
  554. ==============================================================================
  555. ##### DAC Peripheral State and Error functions #####
  556. ==============================================================================
  557. [..]
  558. This subsection provides functions allowing to
  559. (+) Check the DAC state.
  560. (+) Check the DAC Errors.
  561. @endverbatim
  562. * @{
  563. */
  564. /**
  565. * @brief return the DAC handle state
  566. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  567. * the configuration information for the specified DAC.
  568. * @retval HAL state
  569. */
  570. HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef* hdac)
  571. {
  572. /* Return DAC handle state */
  573. return hdac->State;
  574. }
  575. /**
  576. * @brief Return the DAC error code
  577. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  578. * the configuration information for the specified DAC.
  579. * @retval DAC Error Code
  580. */
  581. uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac)
  582. {
  583. return hdac->ErrorCode;
  584. }
  585. /**
  586. * @}
  587. */
  588. /** @addtogroup DAC_Exported_Functions_Group2 Input and Output operation functions
  589. * @{
  590. */
  591. /**
  592. * @brief Conversion complete callback in non blocking mode for Channel1
  593. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  594. * the configuration information for the specified DAC.
  595. * @retval None
  596. */
  597. __weak void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef* hdac)
  598. {
  599. /* Prevent unused argument(s) compilation warning */
  600. UNUSED(hdac);
  601. /* NOTE : This function Should not be modified, when the callback is needed,
  602. the HAL_DAC_ConvCpltCallback1 could be implemented in the user file
  603. */
  604. }
  605. /**
  606. * @brief Conversion half DMA transfer callback in non blocking mode for Channel1
  607. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  608. * the configuration information for the specified DAC.
  609. * @retval None
  610. */
  611. __weak void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef* hdac)
  612. {
  613. /* Prevent unused argument(s) compilation warning */
  614. UNUSED(hdac);
  615. /* NOTE : This function Should not be modified, when the callback is needed,
  616. the HAL_DAC_ConvHalfCpltCallbackCh1 could be implemented in the user file
  617. */
  618. }
  619. /**
  620. * @brief Error DAC callback for Channel1.
  621. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  622. * the configuration information for the specified DAC.
  623. * @retval None
  624. */
  625. __weak void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac)
  626. {
  627. /* Prevent unused argument(s) compilation warning */
  628. UNUSED(hdac);
  629. /* NOTE : This function Should not be modified, when the callback is needed,
  630. the HAL_DAC_ErrorCallback could be implemented in the user file
  631. */
  632. }
  633. /**
  634. * @brief DMA underrun DAC callback for Channel1.
  635. * @param hdac pointer to a DAC_HandleTypeDef structure that contains
  636. * the configuration information for the specified DAC.
  637. * @retval None
  638. */
  639. __weak void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac)
  640. {
  641. /* Prevent unused argument(s) compilation warning */
  642. UNUSED(hdac);
  643. /* NOTE : This function Should not be modified, when the callback is needed,
  644. the HAL_DAC_DMAUnderrunCallbackCh1 could be implemented in the user file
  645. */
  646. }
  647. /**
  648. * @}
  649. */
  650. /**
  651. * @}
  652. */
  653. #endif /* HAL_DAC_MODULE_ENABLED */
  654. /**
  655. * @}
  656. */
  657. /**
  658. * @}
  659. */
  660. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/