RTEMS 6.1-rc5
Loading...
Searching...
No Matches
stm32h7xx_hal_dac.h
Go to the documentation of this file.
1
19/* Define to prevent recursive inclusion -------------------------------------*/
20#ifndef STM32H7xx_HAL_DAC_H
21#define STM32H7xx_HAL_DAC_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
31/* Includes ------------------------------------------------------------------*/
32#include "stm32h7xx_hal_def.h"
33
34#if defined(DAC1) || defined(DAC2)
35
40/* Exported types ------------------------------------------------------------*/
41
50typedef enum
51{
52 HAL_DAC_STATE_RESET = 0x00U,
53 HAL_DAC_STATE_READY = 0x01U,
54 HAL_DAC_STATE_BUSY = 0x02U,
55 HAL_DAC_STATE_TIMEOUT = 0x03U,
56 HAL_DAC_STATE_ERROR = 0x04U
58} HAL_DAC_StateTypeDef;
59
63#if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
64typedef struct __DAC_HandleTypeDef
65#else
66typedef struct
67#endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
68{
69 DAC_TypeDef *Instance;
71 __IO HAL_DAC_StateTypeDef State;
73 HAL_LockTypeDef Lock;
75 DMA_HandleTypeDef *DMA_Handle1;
77 DMA_HandleTypeDef *DMA_Handle2;
79 __IO uint32_t ErrorCode;
81#if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
82 void (* ConvCpltCallbackCh1)(struct __DAC_HandleTypeDef *hdac);
83 void (* ConvHalfCpltCallbackCh1)(struct __DAC_HandleTypeDef *hdac);
84 void (* ErrorCallbackCh1)(struct __DAC_HandleTypeDef *hdac);
85 void (* DMAUnderrunCallbackCh1)(struct __DAC_HandleTypeDef *hdac);
86
87 void (* ConvCpltCallbackCh2)(struct __DAC_HandleTypeDef *hdac);
88 void (* ConvHalfCpltCallbackCh2)(struct __DAC_HandleTypeDef *hdac);
89 void (* ErrorCallbackCh2)(struct __DAC_HandleTypeDef *hdac);
90 void (* DMAUnderrunCallbackCh2)(struct __DAC_HandleTypeDef *hdac);
91
92
93 void (* MspInitCallback)(struct __DAC_HandleTypeDef *hdac);
94 void (* MspDeInitCallback)(struct __DAC_HandleTypeDef *hdac);
95#endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
96
97} DAC_HandleTypeDef;
98
102typedef struct
103{
104 uint32_t DAC_SampleTime ;
108 uint32_t DAC_HoldTime ;
112 uint32_t DAC_RefreshTime ;
115} DAC_SampleAndHoldConfTypeDef;
116
120typedef struct
121{
122 uint32_t DAC_SampleAndHold;
125 uint32_t DAC_Trigger;
128 uint32_t DAC_OutputBuffer;
131 uint32_t DAC_ConnectOnChipPeripheral ;
134 uint32_t DAC_UserTrimming;
138 uint32_t DAC_TrimmingValue;
141 DAC_SampleAndHoldConfTypeDef DAC_SampleAndHoldConfig;
142} DAC_ChannelConfTypeDef;
143
144#if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
148typedef enum
149{
150 HAL_DAC_CH1_COMPLETE_CB_ID = 0x00U,
151 HAL_DAC_CH1_HALF_COMPLETE_CB_ID = 0x01U,
152 HAL_DAC_CH1_ERROR_ID = 0x02U,
153 HAL_DAC_CH1_UNDERRUN_CB_ID = 0x03U,
155 HAL_DAC_CH2_COMPLETE_CB_ID = 0x04U,
156 HAL_DAC_CH2_HALF_COMPLETE_CB_ID = 0x05U,
157 HAL_DAC_CH2_ERROR_ID = 0x06U,
158 HAL_DAC_CH2_UNDERRUN_CB_ID = 0x07U,
160 HAL_DAC_MSPINIT_CB_ID = 0x08U,
161 HAL_DAC_MSPDEINIT_CB_ID = 0x09U,
162 HAL_DAC_ALL_CB_ID = 0x0AU
163} HAL_DAC_CallbackIDTypeDef;
164
168typedef void (*pDAC_CallbackTypeDef)(DAC_HandleTypeDef *hdac);
169#endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
170
175/* Exported constants --------------------------------------------------------*/
176
186#define HAL_DAC_ERROR_NONE 0x00U
187#define HAL_DAC_ERROR_DMAUNDERRUNCH1 0x01U
188#define HAL_DAC_ERROR_DMAUNDERRUNCH2 0x02U
189#define HAL_DAC_ERROR_DMA 0x04U
190#define HAL_DAC_ERROR_TIMEOUT 0x08U
191#if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
192#define HAL_DAC_ERROR_INVALID_CALLBACK 0x10U
193#endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
194
203#define DAC_TRIGGER_NONE 0x00000000U
204#define DAC_TRIGGER_SOFTWARE ( DAC_CR_TEN1)
205#define DAC_TRIGGER_T1_TRGO ( DAC_CR_TSEL1_0 | DAC_CR_TEN1)
206#define DAC_TRIGGER_T2_TRGO ( DAC_CR_TSEL1_1 | DAC_CR_TEN1)
207#define DAC_TRIGGER_T4_TRGO ( DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)
208#define DAC_TRIGGER_T5_TRGO ( DAC_CR_TSEL1_2 | DAC_CR_TEN1)
209#define DAC_TRIGGER_T6_TRGO ( DAC_CR_TSEL1_2 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)
210#define DAC_TRIGGER_T7_TRGO ( DAC_CR_TSEL1_2 | DAC_CR_TSEL1_1 | DAC_CR_TEN1)
211#define DAC_TRIGGER_T8_TRGO ( DAC_CR_TSEL1_2 | DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)
212#define DAC_TRIGGER_T15_TRGO (DAC_CR_TSEL1_3 | DAC_CR_TEN1)
213#if defined(HRTIM1)
214#define DAC_TRIGGER_HR1_TRGO1 (DAC_CR_TSEL1_3 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)
215#define DAC_TRIGGER_HR1_TRGO2 (DAC_CR_TSEL1_3 | DAC_CR_TSEL1_1 | DAC_CR_TEN1)
216#endif /* HRTIM12 */
217#define DAC_TRIGGER_LPTIM1_OUT (DAC_CR_TSEL1_3 | DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)
218#define DAC_TRIGGER_LPTIM2_OUT (DAC_CR_TSEL1_3 | DAC_CR_TSEL1_2 | DAC_CR_TEN1)
219#define DAC_TRIGGER_EXT_IT9 (DAC_CR_TSEL1_3 | DAC_CR_TSEL1_2 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)
220#if defined(TIM23)
221#define DAC_TRIGGER_T23_TRGO (DAC_CR_TSEL1_3 | DAC_CR_TSEL1_2 | DAC_CR_TSEL1_1 | DAC_CR_TEN1)
222#endif /* TIM23 */
223#if defined(TIM24)
224#define DAC_TRIGGER_T24_TRGO (DAC_CR_TSEL1_3 | DAC_CR_TSEL1_2 | DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)
225#endif /* TIM24 */
226#if defined(DAC2)
227#define DAC_TRIGGER_LPTIM3_OUT (DAC_CR_TSEL1_3 | DAC_CR_TSEL1_2 | DAC_CR_TSEL1_1 | DAC_CR_TEN1)
228#endif /* DAC2 */
229
238#define DAC_OUTPUTBUFFER_ENABLE 0x00000000U
239#define DAC_OUTPUTBUFFER_DISABLE (DAC_MCR_MODE1_1)
240
249#define DAC_CHANNEL_1 0x00000000U
250
251#define DAC_CHANNEL_2 0x00000010U
252
261#define DAC_ALIGN_12B_R 0x00000000U
262#define DAC_ALIGN_12B_L 0x00000004U
263#define DAC_ALIGN_8B_R 0x00000008U
264
273#define DAC_FLAG_DMAUDR1 (DAC_SR_DMAUDR1)
274
275#define DAC_FLAG_DMAUDR2 (DAC_SR_DMAUDR2)
276
277
286#define DAC_IT_DMAUDR1 (DAC_SR_DMAUDR1)
287
288#define DAC_IT_DMAUDR2 (DAC_SR_DMAUDR2)
289
290
299#define DAC_CHIPCONNECT_EXTERNAL (1UL << 0)
300#define DAC_CHIPCONNECT_INTERNAL (1UL << 1)
301#define DAC_CHIPCONNECT_BOTH (1UL << 2)
302
311#define DAC_TRIMMING_FACTORY (0x00000000UL)
312#define DAC_TRIMMING_USER (0x00000001UL)
321#define DAC_SAMPLEANDHOLD_DISABLE (0x00000000UL)
322#define DAC_SAMPLEANDHOLD_ENABLE (DAC_MCR_MODE1_2)
323
331/* Exported macro ------------------------------------------------------------*/
332
342#if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
343#define __HAL_DAC_RESET_HANDLE_STATE(__HANDLE__) do { \
344 (__HANDLE__)->State = HAL_DAC_STATE_RESET; \
345 (__HANDLE__)->MspInitCallback = NULL; \
346 (__HANDLE__)->MspDeInitCallback = NULL; \
347 } while(0)
348#else
349#define __HAL_DAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DAC_STATE_RESET)
350#endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
351
357#define __HAL_DAC_ENABLE(__HANDLE__, __DAC_Channel__) \
358 ((__HANDLE__)->Instance->CR |= (DAC_CR_EN1 << ((__DAC_Channel__) & 0x10UL)))
359
365#define __HAL_DAC_DISABLE(__HANDLE__, __DAC_Channel__) \
366 ((__HANDLE__)->Instance->CR &= ~(DAC_CR_EN1 << ((__DAC_Channel__) & 0x10UL)))
367
372#define DAC_DHR12R1_ALIGNMENT(__ALIGNMENT__) (0x00000008UL + (__ALIGNMENT__))
373
374
379#define DAC_DHR12R2_ALIGNMENT(__ALIGNMENT__) (0x00000014UL + (__ALIGNMENT__))
380
381
386#define DAC_DHR12RD_ALIGNMENT(__ALIGNMENT__) (0x00000020UL + (__ALIGNMENT__))
387
396#define __HAL_DAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) |= (__INTERRUPT__))
397
406#define __HAL_DAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) &= ~(__INTERRUPT__))
407
416#define __HAL_DAC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR\
417 & (__INTERRUPT__)) == (__INTERRUPT__))
418
427#define __HAL_DAC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
428
437#define __HAL_DAC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = (__FLAG__))
438
443/* Private macro -------------------------------------------------------------*/
444
449#define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OUTPUTBUFFER_ENABLE) || \
450 ((STATE) == DAC_OUTPUTBUFFER_DISABLE))
451
452#define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_CHANNEL_1) || \
453 ((CHANNEL) == DAC_CHANNEL_2))
454
455#define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_ALIGN_12B_R) || \
456 ((ALIGN) == DAC_ALIGN_12B_L) || \
457 ((ALIGN) == DAC_ALIGN_8B_R))
458
459#define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0UL)
460
461#define IS_DAC_REFRESHTIME(TIME) ((TIME) <= 0x000000FFUL)
462
467/* Include DAC HAL Extended module */
468#include "stm32h7xx_hal_dac_ex.h"
469
470/* Exported functions --------------------------------------------------------*/
471
479/* Initialization and de-initialization functions *****************************/
480HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef *hdac);
481HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef *hdac);
482void HAL_DAC_MspInit(DAC_HandleTypeDef *hdac);
483void HAL_DAC_MspDeInit(DAC_HandleTypeDef *hdac);
484
492/* IO operation functions *****************************************************/
493HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef *hdac, uint32_t Channel);
494HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef *hdac, uint32_t Channel);
495HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel, const uint32_t *pData, uint32_t Length,
496 uint32_t Alignment);
497HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef *hdac, uint32_t Channel);
498void HAL_DAC_IRQHandler(DAC_HandleTypeDef *hdac);
499HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data);
500
501void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef *hdac);
502void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef *hdac);
503void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac);
504void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac);
505
506#if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
507/* DAC callback registering/unregistering */
508HAL_StatusTypeDef HAL_DAC_RegisterCallback(DAC_HandleTypeDef *hdac, HAL_DAC_CallbackIDTypeDef CallbackID,
509 pDAC_CallbackTypeDef pCallback);
510HAL_StatusTypeDef HAL_DAC_UnRegisterCallback(DAC_HandleTypeDef *hdac, HAL_DAC_CallbackIDTypeDef CallbackID);
511#endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
512
520/* Peripheral Control functions ***********************************************/
521uint32_t HAL_DAC_GetValue(const DAC_HandleTypeDef *hdac, uint32_t Channel);
522HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef *hdac,
523 const DAC_ChannelConfTypeDef *sConfig, uint32_t Channel);
531/* Peripheral State and Error functions ***************************************/
532HAL_DAC_StateTypeDef HAL_DAC_GetState(const DAC_HandleTypeDef *hdac);
533uint32_t HAL_DAC_GetError(const DAC_HandleTypeDef *hdac);
534
547void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma);
548void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma);
549void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma);
558#endif /* DAC1 || DAC2 */
559
564#ifdef __cplusplus
565}
566#endif
567
568
569#endif /* STM32H7xx_HAL_DAC_H */
#define __IO
Definition: core_cm4.h:239
Header file of DAC HAL Extended module.
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
Digital to Analog Converter.
Definition: stm32h723xx.h:469
DMA handle Structure definition.
Definition: stm32h7xx_hal_dma.h:138