hc32_ll_dac.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /**
  2. *******************************************************************************
  3. * @file hc32_ll_dac.h
  4. * @brief This file contains all the functions prototypes of the DAC driver
  5. * library.
  6. @verbatim
  7. Change Logs:
  8. Date Author Notes
  9. 2022-12-31 CDT First version
  10. @endverbatim
  11. *******************************************************************************
  12. * Copyright (C) 2022, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  13. *
  14. * This software component is licensed by XHSC under BSD 3-Clause license
  15. * (the "License"); You may not use this file except in compliance with the
  16. * License. You may obtain a copy of the License at:
  17. * opensource.org/licenses/BSD-3-Clause
  18. *
  19. *******************************************************************************
  20. */
  21. #ifndef __HC32_LL_DAC_H__
  22. #define __HC32_LL_DAC_H__
  23. /* C binding of definitions if building with C++ compiler */
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. /*******************************************************************************
  29. * Include files
  30. ******************************************************************************/
  31. #include "hc32_ll_def.h"
  32. #include "hc32f4xx.h"
  33. #include "hc32f4xx_conf.h"
  34. /**
  35. * @addtogroup LL_Driver
  36. * @{
  37. */
  38. /**
  39. * @addtogroup LL_DAC
  40. * @{
  41. */
  42. #if (LL_DAC_ENABLE == DDL_ON)
  43. /*******************************************************************************
  44. * Global type definitions ('typedef')
  45. ******************************************************************************/
  46. /**
  47. * @defgroup DAC_Global_Types DAC Global Types
  48. * @{
  49. */
  50. /**
  51. * @brief Structure definition of DAC initialization.
  52. */
  53. typedef struct {
  54. uint16_t u16Src; /*!< Data source to be converted
  55. This parameter can be a value of @ref DAC_DATA_SRC */
  56. en_functional_state_t enOutput; /*!< Enable or disable analog output
  57. This parameter can be a value of @ref en_functional_state_t */
  58. } stc_dac_init_t;
  59. /**
  60. * @}
  61. */
  62. /*******************************************************************************
  63. * Global pre-processor symbols/macros ('#define')
  64. ******************************************************************************/
  65. /**
  66. * @defgroup DAC_Global_Macros DAC Global Macros
  67. * @{
  68. */
  69. /**
  70. * @defgroup DAC_CH DAC channel
  71. * @{
  72. */
  73. #define DAC_CH1 (0U)
  74. #define DAC_CH2 (1U)
  75. /**
  76. * @}
  77. */
  78. /**
  79. * @defgroup DAC_DATA_SRC DAC data source
  80. * @{
  81. */
  82. #define DAC_DATA_SRC_DATAREG (0U)
  83. #define DAC_DATA_SRC_DCU (DAC_DACR_EXTDSL1)
  84. /**
  85. * @}
  86. */
  87. /**
  88. * @defgroup DAC_DATAREG_ALIGN_PATTERN DAC data register alignment pattern
  89. * @{
  90. */
  91. #define DAC_DATA_ALIGN_LEFT (DAC_DACR_DPSEL)
  92. #define DAC_DATA_ALIGN_RIGHT (0U)
  93. /**
  94. * @}
  95. */
  96. /**
  97. * @defgroup DAC_DATAREG_VALUE_MAX DAC data register value maximum
  98. * @{
  99. */
  100. #define DAC_DATAREG_VALUE_MAX (4096UL)
  101. /**
  102. * @}
  103. */
  104. /**
  105. * @defgroup DAC_ADP_SELECT DAC ADCx priority select
  106. * @{
  107. */
  108. #define DAC_ADP_SEL_ADC1 (DAC_DAADPCR_ADCSL1)
  109. #define DAC_ADP_SEL_ADC2 (DAC_DAADPCR_ADCSL2)
  110. #define DAC_ADP_SEL_ADC3 (DAC_DAADPCR_ADCSL3)
  111. #define DAC_ADP_SEL_ALL (DAC_DAADPCR_ADCSL1 | DAC_DAADPCR_ADCSL2 | DAC_DAADPCR_ADCSL3)
  112. /**
  113. * @}
  114. */
  115. /**
  116. * @}
  117. */
  118. /*******************************************************************************
  119. * Global variable definitions ('extern')
  120. ******************************************************************************/
  121. /*******************************************************************************
  122. Global function prototypes (definition in C source)
  123. ******************************************************************************/
  124. /**
  125. * @addtogroup DAC_Global_Functions
  126. * @{
  127. */
  128. int32_t DAC_StructInit(stc_dac_init_t *pstcDacInit);
  129. int32_t DAC_Init(CM_DAC_TypeDef *DACx, uint16_t u16Ch, const stc_dac_init_t *pstcDacInit);
  130. void DAC_DeInit(CM_DAC_TypeDef *DACx);
  131. void DAC_SetDataSrc(CM_DAC_TypeDef *DACx, uint16_t u16Ch, uint16_t u16Src);
  132. void DAC_DataRegAlignConfig(CM_DAC_TypeDef *DACx, uint16_t u16Align);
  133. void DAC_OutputCmd(CM_DAC_TypeDef *DACx, uint16_t u16Ch, en_functional_state_t enNewState);
  134. void DAC_AMPCmd(CM_DAC_TypeDef *DACx, uint16_t u16Ch, en_functional_state_t enNewState);
  135. void DAC_ADCPrioCmd(CM_DAC_TypeDef *DACx, en_functional_state_t enNewState);
  136. void DAC_ADCPrioConfig(CM_DAC_TypeDef *DACx, uint16_t u16ADCxPrio, en_functional_state_t enNewState);
  137. int32_t DAC_Start(CM_DAC_TypeDef *DACx, uint16_t u16Ch);
  138. int32_t DAC_Stop(CM_DAC_TypeDef *DACx, uint16_t u16Ch);
  139. void DAC_StartDualCh(CM_DAC_TypeDef *DACx);
  140. void DAC_StopDualCh(CM_DAC_TypeDef *DACx);
  141. void DAC_SetChData(CM_DAC_TypeDef *DACx, uint16_t u16Ch, uint16_t u16Data);
  142. void DAC_SetDualChData(CM_DAC_TypeDef *DACx, uint16_t u16Data1, uint16_t u16Data2);
  143. int32_t DAC_GetChConvertState(const CM_DAC_TypeDef *DACx, uint16_t u16Ch);
  144. /**
  145. * @}
  146. */
  147. #endif /* LL_DAC_ENABLE */
  148. /**
  149. * @}
  150. */
  151. /**
  152. * @}
  153. */
  154. #ifdef __cplusplus
  155. }
  156. #endif
  157. #endif /* __HC32_LL_DAC_H__ */
  158. /*******************************************************************************
  159. * EOF (not truncated)
  160. ******************************************************************************/