dac_reg.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /**************************************************************************//**
  2. * @file dac_reg.h
  3. * @version V1.00
  4. * @brief DAC register definition header file
  5. *
  6. * SPDX-License-Identifier: Apache-2.0
  7. * @copyright (C) 2017-2020 Nuvoton Technology Corp. All rights reserved.
  8. *****************************************************************************/
  9. #ifndef __DAC_REG_H__
  10. #define __DAC_REG_H__
  11. #if defined ( __CC_ARM )
  12. #pragma anon_unions
  13. #endif
  14. /**
  15. @addtogroup REGISTER Control Register
  16. @{
  17. */
  18. /**
  19. @addtogroup DAC Digital to Analog Converter(DAC)
  20. Memory Mapped Structure for DAC Controller
  21. @{ */
  22. typedef struct
  23. {
  24. /**
  25. * @var DAC_T::CTL
  26. * Offset: 0x00 DAC Control Register
  27. * ---------------------------------------------------------------------------------------------------
  28. * |Bits |Field |Descriptions
  29. * | :----: | :----: | :---- |
  30. * |[0] |DACEN |DAC Enable Bit
  31. * | | |0 = DAC is Disabled.
  32. * | | |1 = DAC is Enabled.
  33. * |[1] |DACIEN |DAC Interrupt Enable Bit
  34. * | | |0 = Interrupt is Disabled.
  35. * | | |1 = Interrupt is Enabled.
  36. * |[2] |DMAEN |DMA Mode Enable Bit
  37. * | | |0 = DMA mode Disabled.
  38. * | | |1 = DMA mode Enabled.
  39. * |[3] |DMAURIEN |DMA Under-run Interrupt Enable Bit
  40. * | | |0 = DMA under-run interrupt Disabled.
  41. * | | |1 = DMA under-run interrupt Enabled.
  42. * |[4] |TRGEN |Trigger Mode Enable Bit
  43. * | | |0 = DAC event trigger mode Disabled.
  44. * | | |1 = DAC event trigger mode Enabled.
  45. * |[7:5] |TRGSEL |Trigger Source Selection
  46. * | | |000 = Software trigger.
  47. * | | |001 = External pin DAC0_ST trigger.
  48. * | | |010 = Timer 0 trigger.
  49. * | | |011 = Timer 1 trigger.
  50. * | | |100 = Timer 2 trigger.
  51. * | | |101 = Timer 3 trigger.
  52. * | | |110 = EPWM0 trigger.
  53. * | | |111 = EPWM1 trigger.
  54. * |[8] |BYPASS |Bypass Buffer Mode
  55. * | | |0 = Output voltage buffer Enabled.
  56. * | | |1 = Output voltage buffer Disabled.
  57. * |[10] |LALIGN |DAC Data Left-aligned Enabled Control
  58. * | | |0 = Right alignment.
  59. * | | |1 = Left alignment.
  60. * |[13:12] |ETRGSEL |External Pin Trigger Selection
  61. * | | |00 = Low level trigger.
  62. * | | |01 = High level trigger.
  63. * | | |10 = Falling edge trigger.
  64. * | | |11 = Rising edge trigger.
  65. * |[15:14] |BWSEL |DAC Data Bit-width Selection
  66. * | | |00 = data is 12 bits.
  67. * | | |01 = data is 8 bits.
  68. * | | |Others = reserved.
  69. * |[16] |GRPEN |DAC Group Mode Enable Bit
  70. * | | |0 = DAC0 and DAC1 are not grouped.
  71. * | | |1 = DAC0 and DAC1 are grouped.
  72. * @var DAC_T::SWTRG
  73. * Offset: 0x04 DAC Software Trigger Control Register
  74. * ---------------------------------------------------------------------------------------------------
  75. * |Bits |Field |Descriptions
  76. * | :----: | :----: | :---- |
  77. * |[0] |SWTRG |Software Trigger
  78. * | | |0 = Software trigger Disabled.
  79. * | | |1 = Software trigger Enabled.
  80. * | | |User writes this bit to generate one shot pulse and it is cleared to 0 by hardware automatically; Reading this bit will always get 0.
  81. * @var DAC_T::DAT
  82. * Offset: 0x08 DAC Data Holding Register
  83. * ---------------------------------------------------------------------------------------------------
  84. * |Bits |Field |Descriptions
  85. * | :----: | :----: | :---- |
  86. * |[15:0] |DACDAT |DAC 12-bit Holding Data
  87. * | | |These bits are written by user software which specifies 12-bit conversion data for DAC output
  88. * | | |The unused bits (DAC_DAT[3:0] in left-alignment mode and DAC_DAT[15:12] in right alignment mode) are ignored by DAC controller hardware.
  89. * | | |12 bit left alignment: user has to load data into DAC_DAT[15:4] bits.
  90. * | | |12 bit right alignment: user has to load data into DAC_DAT[11:0] bits.
  91. * @var DAC_T::DATOUT
  92. * Offset: 0x0C DAC Data Output Register
  93. * ---------------------------------------------------------------------------------------------------
  94. * |Bits |Field |Descriptions
  95. * | :----: | :----: | :---- |
  96. * |[11:0] |DATOUT |DAC 12-bit Output Data
  97. * | | |These bits are current digital data for DAC output conversion.
  98. * | | |It is loaded from DAC_DAT register and user cannot write it directly.
  99. * @var DAC_T::STATUS
  100. * Offset: 0x10 DAC Status Register
  101. * ---------------------------------------------------------------------------------------------------
  102. * |Bits |Field |Descriptions
  103. * | :----: | :----: | :---- |
  104. * |[0] |FINISH |DAC Conversion Complete Finish Flag
  105. * | | |0 = DAC is in conversion state.
  106. * | | |1 = DAC conversion finish.
  107. * | | |This bit set to 1 when conversion time counter counts to SETTLET
  108. * | | |It is cleared to 0 when DAC starts a new conversion
  109. * | | |User writes 1 to clear this bit to 0.
  110. * |[1] |DMAUDR |DMA Under-run Interrupt Flag
  111. * | | |0 = No DMA under-run error condition occurred.
  112. * | | |1 = DMA under-run error condition occurred.
  113. * | | |User writes 1 to clear this bit.
  114. * |[8] |BUSY |DAC Busy Flag (Read Only)
  115. * | | |0 = DAC is ready for next conversion.
  116. * | | |1 = DAC is busy in conversion.
  117. * | | |This is read only bit.
  118. * @var DAC_T::TCTL
  119. * Offset: 0x14 DAC Timing Control Register
  120. * ---------------------------------------------------------------------------------------------------
  121. * |Bits |Field |Descriptions
  122. * | :----: | :----: | :---- |
  123. * |[9:0] |SETTLET |DAC Output Settling Time
  124. * | | |User software needs to write appropriate value to these bits to meet DAC conversion settling time base on PCLK (APB clock) speed.
  125. * | | |For example, DAC controller clock speed is 80MHz and DAC conversion settling time is 1 us, SETTLETvalue must be greater than 0x50.
  126. * | | |SELTTLET = DAC controller clock speed x settling time.
  127. */
  128. __IO uint32_t CTL; /*!< [0x0000] DAC Control Register */
  129. __IO uint32_t SWTRG; /*!< [0x0004] DAC Software Trigger Control Register */
  130. __IO uint32_t DAT; /*!< [0x0008] DAC Data Holding Register */
  131. __I uint32_t DATOUT; /*!< [0x000c] DAC Data Output Register */
  132. __IO uint32_t STATUS; /*!< [0x0010] DAC Status Register */
  133. __IO uint32_t TCTL; /*!< [0x0014] DAC Timing Control Register */
  134. } DAC_T;
  135. /**
  136. @addtogroup DAC_CONST DAC Bit Field Definition
  137. Constant Definitions for DAC Controller
  138. @{ */
  139. #define DAC_CTL_DACEN_Pos (0) /*!< DAC_T::CTL: DACEN Position */
  140. #define DAC_CTL_DACEN_Msk (0x1ul << DAC_CTL_DACEN_Pos) /*!< DAC_T::CTL: DACEN Mask */
  141. #define DAC_CTL_DACIEN_Pos (1) /*!< DAC_T::CTL: DACIEN Position */
  142. #define DAC_CTL_DACIEN_Msk (0x1ul << DAC_CTL_DACIEN_Pos) /*!< DAC_T::CTL: DACIEN Mask */
  143. #define DAC_CTL_DMAEN_Pos (2) /*!< DAC_T::CTL: DMAEN Position */
  144. #define DAC_CTL_DMAEN_Msk (0x1ul << DAC_CTL_DMAEN_Pos) /*!< DAC_T::CTL: DMAEN Mask */
  145. #define DAC_CTL_DMAURIEN_Pos (3) /*!< DAC_T::CTL: DMAURIEN Position */
  146. #define DAC_CTL_DMAURIEN_Msk (0x1ul << DAC_CTL_DMAURIEN_Pos) /*!< DAC_T::CTL: DMAURIEN Mask */
  147. #define DAC_CTL_TRGEN_Pos (4) /*!< DAC_T::CTL: TRGEN Position */
  148. #define DAC_CTL_TRGEN_Msk (0x1ul << DAC_CTL_TRGEN_Pos) /*!< DAC_T::CTL: TRGEN Mask */
  149. #define DAC_CTL_TRGSEL_Pos (5) /*!< DAC_T::CTL: TRGSEL Position */
  150. #define DAC_CTL_TRGSEL_Msk (0x7ul << DAC_CTL_TRGSEL_Pos) /*!< DAC_T::CTL: TRGSEL Mask */
  151. #define DAC_CTL_BYPASS_Pos (8) /*!< DAC_T::CTL: BYPASS Position */
  152. #define DAC_CTL_BYPASS_Msk (0x1ul << DAC_CTL_BYPASS_Pos) /*!< DAC_T::CTL: BYPASS Mask */
  153. #define DAC_CTL_LALIGN_Pos (10) /*!< DAC_T::CTL: LALIGN Position */
  154. #define DAC_CTL_LALIGN_Msk (0x1ul << DAC_CTL_LALIGN_Pos) /*!< DAC_T::CTL: LALIGN Mask */
  155. #define DAC_CTL_ETRGSEL_Pos (12) /*!< DAC_T::CTL: ETRGSEL Position */
  156. #define DAC_CTL_ETRGSEL_Msk (0x3ul << DAC_CTL_ETRGSEL_Pos) /*!< DAC_T::CTL: ETRGSEL Mask */
  157. #define DAC_CTL_BWSEL_Pos (14) /*!< DAC_T::CTL: BWSEL Position */
  158. #define DAC_CTL_BWSEL_Msk (0x3ul << DAC_CTL_BWSEL_Pos) /*!< DAC_T::CTL: BWSEL Mask */
  159. #define DAC_CTL_GRPEN_Pos (16) /*!< DAC_T::CTL: GRPEN Position */
  160. #define DAC_CTL_GRPEN_Msk (0x1ul << DAC_CTL_GRPEN_Pos) /*!< DAC_T::CTL: GRPEN Mask */
  161. #define DAC_SWTRG_SWTRG_Pos (0) /*!< DAC_T::SWTRG: SWTRG Position */
  162. #define DAC_SWTRG_SWTRG_Msk (0x1ul << DAC_SWTRG_SWTRG_Pos) /*!< DAC_T::SWTRG: SWTRG Mask */
  163. #define DAC_DAT_DACDAT_Pos (0) /*!< DAC_T::DAT: DACDAT Position */
  164. #define DAC_DAT_DACDAT_Msk (0xfffful << DAC_DAT_DACDAT_Pos) /*!< DAC_T::DAT: DACDAT Mask */
  165. #define DAC_DATOUT_DATOUT_Pos (0) /*!< DAC_T::DATOUT: DATOUT Position */
  166. #define DAC_DATOUT_DATOUT_Msk (0xffful << DAC_DATOUT_DATOUT_Pos) /*!< DAC_T::DATOUT: DATOUT Mask */
  167. #define DAC_STATUS_FINISH_Pos (0) /*!< DAC_T::STATUS: FINISH Position */
  168. #define DAC_STATUS_FINISH_Msk (0x1ul << DAC_STATUS_FINISH_Pos) /*!< DAC_T::STATUS: FINISH Mask */
  169. #define DAC_STATUS_DMAUDR_Pos (1) /*!< DAC_T::STATUS: DMAUDR Position */
  170. #define DAC_STATUS_DMAUDR_Msk (0x1ul << DAC_STATUS_DMAUDR_Pos) /*!< DAC_T::STATUS: DMAUDR Mask */
  171. #define DAC_STATUS_BUSY_Pos (8) /*!< DAC_T::STATUS: BUSY Position */
  172. #define DAC_STATUS_BUSY_Msk (0x1ul << DAC_STATUS_BUSY_Pos) /*!< DAC_T::STATUS: BUSY Mask */
  173. #define DAC_TCTL_SETTLET_Pos (0) /*!< DAC_T::TCTL: SETTLET Position */
  174. #define DAC_TCTL_SETTLET_Msk (0x3fful << DAC_TCTL_SETTLET_Pos) /*!< DAC_T::TCTL: SETTLET Mask */
  175. /**@}*/ /* DAC_CONST */
  176. /**@}*/ /* end of DAC register group */
  177. /**@}*/ /* end of REGISTER group */
  178. #if defined ( __CC_ARM )
  179. #pragma no_anon_unions
  180. #endif
  181. #endif /* __DAC_REG_H__ */