1 /*********************************************************************************************************//** 2 * @file ht32f5xxxx_dac.h 3 * @version $Rev:: 7081 $ 4 * @date $Date:: 2023-08-01 #$ 5 * @brief The header file of the DAC library. 6 ************************************************************************************************************* 7 * @attention 8 * 9 * Firmware Disclaimer Information 10 * 11 * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the 12 * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the 13 * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and 14 * other intellectual property laws. 15 * 16 * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the 17 * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties 18 * other than HOLTEK and the customer. 19 * 20 * 3. The program technical documentation, including the code, is provided "as is" and for customer reference 21 * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including 22 * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including 23 * the warranties of merchantability, satisfactory quality and fitness for a particular purpose. 24 * 25 * <h2><center>Copyright (C) Holtek Semiconductor Inc. All rights reserved</center></h2> 26 ************************************************************************************************************/ 27 28 /* Define to prevent recursive inclusion -------------------------------------------------------------------*/ 29 #ifndef __HT32F5XXXX_DAC_H 30 #define __HT32F5XXXX_DAC_H 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* Includes ------------------------------------------------------------------------------------------------*/ 37 #include "ht32.h" 38 39 /** @addtogroup HT32F5xxxx_Peripheral_Driver HT32F5xxxx Peripheral Driver 40 * @{ 41 */ 42 43 /** @addtogroup DAC 44 * @{ 45 */ 46 47 48 /* Exported types ------------------------------------------------------------------------------------------*/ 49 /** @defgroup DAC_Exported_Types DAC exported types 50 * @{ 51 */ 52 53 /** 54 * @} 55 */ 56 57 /* Exported constants --------------------------------------------------------------------------------------*/ 58 /** @defgroup DAC_Exported_Constants DAC exported constants 59 * @{ 60 */ 61 #define ASYNC_MODE (0x00000000) 62 #define SYNC_MODE (0x00000001) 63 64 #if (LIBCFG_DAC1) 65 #define IS_DAC(DAC) (((DAC) == HT_DAC0) || ((DAC) == HT_DAC1)) 66 #else 67 #define IS_DAC(DAC) ((DAC) == HT_DAC0) 68 #endif 69 70 71 #define IS_DAC_CONVERSION_MODE(MODE) (((MODE) == ASYNC_MODE) || ((MODE) == SYNC_MODE)) 72 73 74 #define DAC_CH0 (0) 75 #define DAC_CH1 (1) 76 77 #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_CH0) || ((CHANNEL) == DAC_CH1)) 78 79 80 81 #define DAC_REFERENCE_VDDA (0) 82 #define DAC_REFERENCE_VREF (1UL << 14) 83 84 #define IS_DAC_REFERENCE(REF) (((REF) == DAC_REFERENCE_VDDA) || ((REF) == DAC_REFERENCE_VREF)) 85 86 87 #define DAC_RESOLUTION_12BIT (0) 88 #define DAC_RESOLUTION_8BIT (1UL << 2) 89 90 #define IS_DAC_RESOLUTION(RES) (((RES) == DAC_RESOLUTION_8BIT) || ((RES) == DAC_RESOLUTION_12BIT)) 91 92 /** 93 * @} 94 */ 95 96 /* Exported functions --------------------------------------------------------------------------------------*/ 97 /** @defgroup DAC_Exported_Functions DAC exported functions 98 * @{ 99 */ 100 void DAC_DeInit(HT_DAC_TypeDef* HT_DACn); 101 102 void DAC_ModeConfig(HT_DAC_TypeDef* HT_DACn, u8 ModeSel); 103 104 void DAC_ReferenceConfig(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, u32 RefSel); 105 void DAC_ResolutionConfig(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, u32 ResoSel); 106 107 void DAC_OutBufCmd(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, ControlStatus NewState); 108 void DAC_Cmd(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, ControlStatus NewState); 109 110 void DAC_SetData(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch, u32 Data); 111 u16 DAC_GetOutData(HT_DAC_TypeDef* HT_DACn, u8 DAC_Ch); 112 113 /** 114 * @} 115 */ 116 117 118 /** 119 * @} 120 */ 121 122 /** 123 * @} 124 */ 125 126 #ifdef __cplusplus 127 } 128 #endif 129 130 #endif 131