STM32G474xx HAL用户手册
stm32g4xx_hal_dac.h
转到此文件的文档。
00001 /**
00002   ******************************************************************************
00003   * @file    stm32g4xx_hal_dac.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of DAC HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2019 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 
00019 /* Define to prevent recursive inclusion -------------------------------------*/
00020 #ifndef STM32G4xx_HAL_DAC_H
00021 #define STM32G4xx_HAL_DAC_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /** @addtogroup STM32G4xx_HAL_Driver
00028   * @{
00029   */
00030 
00031 /* Includes ------------------------------------------------------------------*/
00032 #include "stm32g4xx_hal_def.h"
00033 
00034 #if defined(DAC1) || defined(DAC2) || defined(DAC3) ||defined (DAC4)
00035 
00036 /** @addtogroup DAC
00037   * @{
00038   */
00039 
00040 /* Exported types ------------------------------------------------------------*/
00041 
00042 /** @defgroup DAC_Exported_Types DAC Exported Types
00043   * @{
00044   */
00045 
00046 /**
00047   * @brief  HAL State structures definition
00048   */
00049 typedef enum
00050 {
00051   HAL_DAC_STATE_RESET             = 0x00U,  /*!< DAC not yet initialized or disabled  */
00052   HAL_DAC_STATE_READY             = 0x01U,  /*!< DAC initialized and ready for use    */
00053   HAL_DAC_STATE_BUSY              = 0x02U,  /*!< DAC internal processing is ongoing   */
00054   HAL_DAC_STATE_TIMEOUT           = 0x03U,  /*!< DAC timeout state                    */
00055   HAL_DAC_STATE_ERROR             = 0x04U   /*!< DAC error state                      */
00056 
00057 } HAL_DAC_StateTypeDef;
00058 
00059 /**
00060   * @brief  DAC handle Structure definition
00061   */
00062 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
00063 typedef struct __DAC_HandleTypeDef
00064 #else
00065 typedef struct
00066 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
00067 {
00068   DAC_TypeDef                 *Instance;     /*!< Register base address             */
00069 
00070   __IO HAL_DAC_StateTypeDef   State;         /*!< DAC communication state           */
00071 
00072   HAL_LockTypeDef             Lock;          /*!< DAC locking object                */
00073 
00074   DMA_HandleTypeDef           *DMA_Handle1;  /*!< Pointer DMA handler for channel 1 */
00075 
00076   DMA_HandleTypeDef           *DMA_Handle2;  /*!< Pointer DMA handler for channel 2 */
00077 
00078   __IO uint32_t               ErrorCode;     /*!< DAC Error code                    */
00079 
00080 #if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
00081   void (* ConvCpltCallbackCh1)(struct __DAC_HandleTypeDef *hdac);
00082   void (* ConvHalfCpltCallbackCh1)(struct __DAC_HandleTypeDef *hdac);
00083   void (* ErrorCallbackCh1)(struct __DAC_HandleTypeDef *hdac);
00084   void (* DMAUnderrunCallbackCh1)(struct __DAC_HandleTypeDef *hdac);
00085 
00086   void (* ConvCpltCallbackCh2)(struct __DAC_HandleTypeDef *hdac);
00087   void (* ConvHalfCpltCallbackCh2)(struct __DAC_HandleTypeDef *hdac);
00088   void (* ErrorCallbackCh2)(struct __DAC_HandleTypeDef *hdac);
00089   void (* DMAUnderrunCallbackCh2)(struct __DAC_HandleTypeDef *hdac);
00090 
00091 
00092   void (* MspInitCallback)(struct __DAC_HandleTypeDef *hdac);
00093   void (* MspDeInitCallback)(struct __DAC_HandleTypeDef *hdac);
00094 #endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
00095 
00096 } DAC_HandleTypeDef;
00097 
00098 /**
00099   * @brief   DAC Configuration sample and hold Channel structure definition
00100   */
00101 typedef struct
00102 {
00103   uint32_t DAC_SampleTime ;          /*!< Specifies the Sample time for the selected channel.
00104                                           This parameter applies when DAC_SampleAndHold is DAC_SAMPLEANDHOLD_ENABLE.
00105                                           This parameter must be a number between Min_Data = 0 and Max_Data = 1023 */
00106 
00107   uint32_t DAC_HoldTime ;            /*!< Specifies the hold time for the selected channel
00108                                           This parameter applies when DAC_SampleAndHold is DAC_SAMPLEANDHOLD_ENABLE.
00109                                           This parameter must be a number between Min_Data = 0 and Max_Data = 1023 */
00110 
00111   uint32_t DAC_RefreshTime ;         /*!< Specifies the refresh time for the selected channel
00112                                           This parameter applies when DAC_SampleAndHold is DAC_SAMPLEANDHOLD_ENABLE.
00113                                           This parameter must be a number between Min_Data = 0 and Max_Data = 255 */
00114 } DAC_SampleAndHoldConfTypeDef;
00115 
00116 /**
00117   * @brief   DAC Configuration regular Channel structure definition
00118   */
00119 typedef struct
00120 {
00121   uint32_t DAC_HighFrequency;            /*!< Specifies the frequency interface mode
00122                                               This parameter can be a value of @ref DAC_HighFrequency */
00123 
00124   FunctionalState DAC_DMADoubleDataMode; /*!< Specifies if DMA double data mode should be enabled or not for the selected channel.
00125                                               This parameter can be ENABLE or DISABLE */
00126 
00127   FunctionalState DAC_SignedFormat;      /*!< Specifies if signed format should be used or not for the selected channel.
00128                                               This parameter can be ENABLE or DISABLE */
00129 
00130   uint32_t DAC_SampleAndHold;            /*!< Specifies whether the DAC mode.
00131                                               This parameter can be a value of @ref DAC_SampleAndHold */
00132 
00133   uint32_t DAC_Trigger;                  /*!< Specifies the external trigger for the selected DAC channel.
00134                                               This parameter can be a value of @ref DAC_trigger_selection.
00135                                               Note: In case of sawtooth wave generation, this
00136                                               trigger corresponds to the reset trigger. */
00137 
00138   uint32_t DAC_Trigger2;                 /*!< Specifies the external secondary trigger for the selected DAC channel.
00139                                               This parameter can be a value of @ref DAC_trigger_selection.
00140                                               Note: In case of sawtooth wave generation, this
00141                                               trigger corresponds to the step trigger.*/
00142 
00143   uint32_t DAC_OutputBuffer;             /*!< Specifies whether the DAC channel output buffer is enabled or disabled.
00144                                                This parameter can be a value of @ref DAC_output_buffer */
00145 
00146   uint32_t DAC_ConnectOnChipPeripheral ; /*!< Specifies whether the DAC output is connected or not to on