STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
stm32f7xx_hal_dac_ex.c
Go to the documentation of this file.
1 
56 /* Includes ------------------------------------------------------------------*/
57 #include "stm32f7xx_hal.h"
58 
68 #ifdef HAL_DAC_MODULE_ENABLED
69 
70 /* Private typedef -----------------------------------------------------------*/
71 /* Private define ------------------------------------------------------------*/
72 /* Private macro -------------------------------------------------------------*/
73 /* Private variables ---------------------------------------------------------*/
74 /* Private function prototypes -----------------------------------------------*/
75 /* Private functions ---------------------------------------------------------*/
76 /* Exported functions --------------------------------------------------------*/
107 {
108  uint32_t tmp = 0;
109 
110  tmp |= hdac->Instance->DOR1;
111 
112  tmp |= hdac->Instance->DOR2 << 16;
113 
114  /* Returns the DAC channel data output register value */
115  return tmp;
116 }
117 
142 HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude)
143 {
144  /* Check the parameters */
145  assert_param(IS_DAC_CHANNEL(Channel));
147 
148  /* Process locked */
149  __HAL_LOCK(hdac);
150 
151  /* Change DAC state */
152  hdac->State = HAL_DAC_STATE_BUSY;
153 
154  /* Enable the selected wave generation for the selected DAC channel */
155  MODIFY_REG(hdac->Instance->CR, (DAC_CR_WAVE1 | DAC_CR_MAMP1) << Channel, (DAC_CR_WAVE1_1 | Amplitude) << Channel);
156 
157  /* Change DAC state */
158  hdac->State = HAL_DAC_STATE_READY;
159 
160  /* Process unlocked */
161  __HAL_UNLOCK(hdac);
162 
163  /* Return function status */
164  return HAL_OK;
165 }
166 
191 HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude)
192 {
193  /* Check the parameters */
194  assert_param(IS_DAC_CHANNEL(Channel));
196 
197  /* Process locked */
198  __HAL_LOCK(hdac);
199 
200  /* Change DAC state */
201  hdac->State = HAL_DAC_STATE_BUSY;
202 
203  /* Enable the selected wave generation for the selected DAC channel */
204  MODIFY_REG(hdac->Instance->CR, (DAC_CR_WAVE1 | DAC_CR_MAMP1) << Channel, (DAC_CR_WAVE1_0 | Amplitude) << Channel);
205 
206  /* Change DAC state */
207  hdac->State = HAL_DAC_STATE_READY;
208 
209  /* Process unlocked */
210  __HAL_UNLOCK(hdac);
211 
212  /* Return function status */
213  return HAL_OK;
214 }
215 
231 HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2)
232 {
233  uint32_t data = 0, tmp = 0;
234 
235  /* Check the parameters */
236  assert_param(IS_DAC_ALIGN(Alignment));
237  assert_param(IS_DAC_DATA(Data1));
238  assert_param(IS_DAC_DATA(Data2));
239 
240  /* Calculate and set dual DAC data holding register value */
241  if (Alignment == DAC_ALIGN_8B_R)
242  {
243  data = ((uint32_t)Data2 << 8) | Data1;
244  }
245  else
246  {
247  data = ((uint32_t)Data2 << 16) | Data1;
248  }
249 
250  tmp = (uint32_t)hdac->Instance;
251  tmp += DAC_DHR12RD_ALIGNMENT(Alignment);
252 
253  /* Set the dual DAC selected data holding register */
254  *(__IO uint32_t *)tmp = data;
255 
256  /* Return function status */
257  return HAL_OK;
258 }
259 
271 {
272  /* Prevent unused argument(s) compilation warning */
273  UNUSED(hdac);
274 
275  /* NOTE : This function Should not be modified, when the callback is needed,
276  the HAL_DAC_ConvCpltCallbackCh2 could be implemented in the user file
277  */
278 }
279 
287 {
288  /* Prevent unused argument(s) compilation warning */
289  UNUSED(hdac);
290 
291  /* NOTE : This function Should not be modified, when the callback is needed,
292  the HAL_DACEx_ConvHalfCpltCallbackCh2 could be implemented in the user file
293  */
294 }
295 
303 {
304  /* Prevent unused argument(s) compilation warning */
305  UNUSED(hdac);
306 
307  /* NOTE : This function Should not be modified, when the callback is needed,
308  the HAL_DACEx_ErrorCallbackCh2 could be implemented in the user file
309  */
310 }
311 
319 {
320  /* Prevent unused argument(s) compilation warning */
321  UNUSED(hdac);
322 
323  /* NOTE : This function Should not be modified, when the callback is needed,
324  the HAL_DACEx_DMAUnderrunCallbackCh2 could be implemented in the user file
325  */
326 }
327 
335 {
336  DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
337 
339 
340  hdac->State= HAL_DAC_STATE_READY;
341 }
342 
350 {
351  DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
352  /* Conversion complete callback */
354 }
355 
363 {
364  DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
365 
366  /* Set DAC error code to DMA error */
367  hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
368 
370 
371  hdac->State= HAL_DAC_STATE_READY;
372 }
373 
378 #endif /* HAL_DAC_MODULE_ENABLED */
379 
388 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#define MODIFY_REG(REG, CLEARMASK, SETMASK)
Definition: stm32f7xx.h:190
void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef *hdac)
void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma)
#define DAC_DHR12RD_ALIGNMENT(__ALIGNMENT__)
Set DHR12RD alignment.
#define HAL_DAC_ERROR_DMA
#define assert_param(expr)
Include module&#39;s header file.
#define DAC_CR_MAMP1
Definition: stm32f745xx.h:3101
uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef *hdac)
__IO uint32_t CR
Definition: stm32f745xx.h:338
#define __HAL_UNLOCK(__HANDLE__)
#define DAC_CR_WAVE1_1
Definition: stm32f745xx.h:3100
#define IS_DAC_DATA(DATA)
DAC_TypeDef * Instance
#define __HAL_LOCK(__HANDLE__)
#define DAC_ALIGN_8B_R
#define DAC_CR_WAVE1_0
Definition: stm32f745xx.h:3099
#define __IO
Definition: core_cm0.h:213
__IO uint32_t DOR2
Definition: stm32f745xx.h:350
void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac)
This file contains all the functions prototypes for the HAL module driver.
void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma)
#define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE)
HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Amplitude)
__IO uint32_t ErrorCode
void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma)
#define DAC_CR_WAVE1
Definition: stm32f745xx.h:3098
HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef *hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2)
__IO HAL_DAC_StateTypeDef State
#define UNUSED(x)
HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Amplitude)
DMA handle Structure definition.
__IO uint32_t DOR1
Definition: stm32f745xx.h:349
#define IS_DAC_CHANNEL(CHANNEL)
HAL_StatusTypeDef
HAL Status structures definition.
DAC handle Structure definition.
#define IS_DAC_ALIGN(ALIGN)
void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef *hdac)
void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac)