gh_adc.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /*!
  2. *******************************************************************************
  3. **
  4. ** \file gh_adc.h
  5. **
  6. ** \brief ADC.
  7. **
  8. ** Copyright: 2012 - 2016 (C) GoKe Microelectronics
  9. **
  10. ** \attention THIS SAMPLE CODE IS PROVIDED AS IS. GOKE MICROELECTRONICS
  11. ** ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR
  12. ** OMMISSIONS.
  13. **
  14. ** \note Do not modify this file as it is generated automatically.
  15. **
  16. ******************************************************************************/
  17. #ifndef _GH_ADC_H
  18. #define _GH_ADC_H
  19. #ifdef __LINUX__
  20. #include "reg4linux.h"
  21. #else
  22. #define FIO_ADDRESS(block,address) (address)
  23. #define FIO_MOFFSET(block,moffset) (moffset)
  24. #endif
  25. #ifndef __LINUX__
  26. #include "gtypes.h" /* global type definitions */
  27. #include "gh_lib_cfg.h" /* configuration */
  28. #endif
  29. #define GH_ADC_ENABLE_DEBUG_PRINT 0
  30. #ifdef __LINUX__
  31. #define GH_ADC_DEBUG_PRINT_FUNCTION printk
  32. #else
  33. #define GH_ADC_DEBUG_PRINT_FUNCTION printf
  34. #endif
  35. #ifndef __LINUX__
  36. #if GH_ADC_ENABLE_DEBUG_PRINT
  37. #include <stdio.h>
  38. #endif
  39. #endif
  40. /*----------------------------------------------------------------------------*/
  41. /* registers */
  42. /*----------------------------------------------------------------------------*/
  43. #define REG_ADC_AUX_ATOP FIO_ADDRESS(ADC,0x90020A00) /* read/write */
  44. #define REG_ADC_GPIO FIO_ADDRESS(ADC,0x90020A04) /* read/write */
  45. #define REG_ADC_CONTROL FIO_ADDRESS(ADC,0xa000D000) /* read/write */
  46. #define REG_ADC_READDATA FIO_ADDRESS(ADC,0xa000D004) /* read */
  47. #define REG_ADC_ENABLE FIO_ADDRESS(ADC,0xa000D018) /* read/write */
  48. #define REG_ADC_INTCONTROL FIO_ADDRESS(ADC,0xa000D044) /* read/write */
  49. /*----------------------------------------------------------------------------*/
  50. /* bit group structures */
  51. /*----------------------------------------------------------------------------*/
  52. typedef union { /* ADC_AUX_ATOP */
  53. U32 all;
  54. struct {
  55. U32 sar_pd : 1;
  56. U32 sar_maxnsel : 3;
  57. U32 sar_maxsel : 4;
  58. U32 sar_oneshot : 1;
  59. U32 sar_freerun : 1;
  60. U32 sar_refnsel : 2;
  61. U32 sar_refsel : 3;
  62. U32 : 17;
  63. } bitc;
  64. } GH_ADC_AUX_ATOP_S;
  65. typedef union { /* ADC_GPIO */
  66. U32 all;
  67. struct {
  68. U32 sar_test : 4;
  69. U32 sar_key_pge : 4;
  70. U32 : 24;
  71. } bitc;
  72. } GH_ADC_GPIO_S;
  73. typedef union { /* ADC_Control */
  74. U32 all;
  75. struct {
  76. U32 status : 1;
  77. U32 start : 1;
  78. U32 : 1;
  79. U32 channel : 3;
  80. U32 : 26;
  81. } bitc;
  82. } GH_ADC_CONTROL_S;
  83. typedef union { /* ADC_IntControl */
  84. U32 all;
  85. struct {
  86. U32 val_lo : 10;
  87. U32 : 5;
  88. U32 val_hi : 10;
  89. U32 : 5;
  90. U32 en_lo : 1;
  91. U32 en_hi : 1;
  92. } bitc;
  93. } GH_ADC_INTCONTROL_S;
  94. /*----------------------------------------------------------------------------*/
  95. /* mirror variables */
  96. /*----------------------------------------------------------------------------*/
  97. #ifdef __cplusplus
  98. extern "C" {
  99. #endif
  100. /*----------------------------------------------------------------------------*/
  101. /* register ADC_AUX_ATOP (read/write) */
  102. /*----------------------------------------------------------------------------*/
  103. /*! \brief Writes the register 'ADC_AUX_ATOP'. */
  104. void GH_ADC_set_AUX_ATOP(U32 data);
  105. /*! \brief Reads the register 'ADC_AUX_ATOP'. */
  106. U32 GH_ADC_get_AUX_ATOP(void);
  107. /*! \brief Writes the bit group 'sar_pd' of register 'ADC_AUX_ATOP'. */
  108. void GH_ADC_set_AUX_ATOP_sar_pd(U8 data);
  109. /*! \brief Reads the bit group 'sar_pd' of register 'ADC_AUX_ATOP'. */
  110. U8 GH_ADC_get_AUX_ATOP_sar_pd(void);
  111. /*! \brief Writes the bit group 'sar_maxnsel' of register 'ADC_AUX_ATOP'. */
  112. void GH_ADC_set_AUX_ATOP_sar_maxnsel(U8 data);
  113. /*! \brief Reads the bit group 'sar_maxnsel' of register 'ADC_AUX_ATOP'. */
  114. U8 GH_ADC_get_AUX_ATOP_sar_maxnsel(void);
  115. /*! \brief Writes the bit group 'sar_maxsel' of register 'ADC_AUX_ATOP'. */
  116. void GH_ADC_set_AUX_ATOP_sar_maxsel(U8 data);
  117. /*! \brief Reads the bit group 'sar_maxsel' of register 'ADC_AUX_ATOP'. */
  118. U8 GH_ADC_get_AUX_ATOP_sar_maxsel(void);
  119. /*! \brief Writes the bit group 'sar_oneshot' of register 'ADC_AUX_ATOP'. */
  120. void GH_ADC_set_AUX_ATOP_sar_oneshot(U8 data);
  121. /*! \brief Reads the bit group 'sar_oneshot' of register 'ADC_AUX_ATOP'. */
  122. U8 GH_ADC_get_AUX_ATOP_sar_oneshot(void);
  123. /*! \brief Writes the bit group 'sar_freerun' of register 'ADC_AUX_ATOP'. */
  124. void GH_ADC_set_AUX_ATOP_sar_freerun(U8 data);
  125. /*! \brief Reads the bit group 'sar_freerun' of register 'ADC_AUX_ATOP'. */
  126. U8 GH_ADC_get_AUX_ATOP_sar_freerun(void);
  127. /*! \brief Writes the bit group 'sar_refnsel' of register 'ADC_AUX_ATOP'. */
  128. void GH_ADC_set_AUX_ATOP_sar_refnsel(U8 data);
  129. /*! \brief Reads the bit group 'sar_refnsel' of register 'ADC_AUX_ATOP'. */
  130. U8 GH_ADC_get_AUX_ATOP_sar_refnsel(void);
  131. /*! \brief Writes the bit group 'sar_refsel' of register 'ADC_AUX_ATOP'. */
  132. void GH_ADC_set_AUX_ATOP_sar_refsel(U8 data);
  133. /*! \brief Reads the bit group 'sar_refsel' of register 'ADC_AUX_ATOP'. */
  134. U8 GH_ADC_get_AUX_ATOP_sar_refsel(void);
  135. /*----------------------------------------------------------------------------*/
  136. /* register ADC_GPIO (read/write) */
  137. /*----------------------------------------------------------------------------*/
  138. /*! \brief Writes the register 'ADC_GPIO'. */
  139. void GH_ADC_set_GPIO(U32 data);
  140. /*! \brief Reads the register 'ADC_GPIO'. */
  141. U32 GH_ADC_get_GPIO(void);
  142. /*! \brief Writes the bit group 'sar_test' of register 'ADC_GPIO'. */
  143. void GH_ADC_set_GPIO_sar_test(U8 data);
  144. /*! \brief Reads the bit group 'sar_test' of register 'ADC_GPIO'. */
  145. U8 GH_ADC_get_GPIO_sar_test(void);
  146. /*! \brief Writes the bit group 'sar_key_pge' of register 'ADC_GPIO'. */
  147. void GH_ADC_set_GPIO_sar_key_pge(U8 data);
  148. /*! \brief Reads the bit group 'sar_key_pge' of register 'ADC_GPIO'. */
  149. U8 GH_ADC_get_GPIO_sar_key_pge(void);
  150. /*----------------------------------------------------------------------------*/
  151. /* register ADC_Control (read/write) */
  152. /*----------------------------------------------------------------------------*/
  153. /*! \brief Writes the register 'ADC_Control'. */
  154. void GH_ADC_set_Control(U32 data);
  155. /*! \brief Reads the register 'ADC_Control'. */
  156. U32 GH_ADC_get_Control(void);
  157. /*! \brief Writes the bit group 'status' of register 'ADC_Control'. */
  158. void GH_ADC_set_Control_status(U8 data);
  159. /*! \brief Reads the bit group 'status' of register 'ADC_Control'. */
  160. U8 GH_ADC_get_Control_status(void);
  161. /*! \brief Writes the bit group 'start' of register 'ADC_Control'. */
  162. void GH_ADC_set_Control_start(U8 data);
  163. /*! \brief Reads the bit group 'start' of register 'ADC_Control'. */
  164. U8 GH_ADC_get_Control_start(void);
  165. /*! \brief Writes the bit group 'channel' of register 'ADC_Control'. */
  166. void GH_ADC_set_Control_channel(U8 data);
  167. /*! \brief Reads the bit group 'channel' of register 'ADC_Control'. */
  168. U8 GH_ADC_get_Control_channel(void);
  169. /*----------------------------------------------------------------------------*/
  170. /* register ADC_ReadData (read) */
  171. /*----------------------------------------------------------------------------*/
  172. /*! \brief Reads the register 'ADC_ReadData'. */
  173. U32 GH_ADC_get_ReadData(U8 index);
  174. /*----------------------------------------------------------------------------*/
  175. /* register ADC_Enable (read/write) */
  176. /*----------------------------------------------------------------------------*/
  177. /*! \brief Writes the register 'ADC_Enable'. */
  178. void GH_ADC_set_Enable(U32 data);
  179. /*! \brief Reads the register 'ADC_Enable'. */
  180. U32 GH_ADC_get_Enable(void);
  181. /*----------------------------------------------------------------------------*/
  182. /* register ADC_IntControl (read/write) */
  183. /*----------------------------------------------------------------------------*/
  184. /*! \brief Writes the register 'ADC_IntControl'. */
  185. void GH_ADC_set_IntControl(U8 index, U32 data);
  186. /*! \brief Reads the register 'ADC_IntControl'. */
  187. U32 GH_ADC_get_IntControl(U8 index);
  188. /*! \brief Writes the bit group 'val_lo' of register 'ADC_IntControl'. */
  189. void GH_ADC_set_IntControl_val_lo(U8 index, U16 data);
  190. /*! \brief Reads the bit group 'val_lo' of register 'ADC_IntControl'. */
  191. U16 GH_ADC_get_IntControl_val_lo(U8 index);
  192. /*! \brief Writes the bit group 'val_hi' of register 'ADC_IntControl'. */
  193. void GH_ADC_set_IntControl_val_hi(U8 index, U16 data);
  194. /*! \brief Reads the bit group 'val_hi' of register 'ADC_IntControl'. */
  195. U16 GH_ADC_get_IntControl_val_hi(U8 index);
  196. /*! \brief Writes the bit group 'en_lo' of register 'ADC_IntControl'. */
  197. void GH_ADC_set_IntControl_en_lo(U8 index, U8 data);
  198. /*! \brief Reads the bit group 'en_lo' of register 'ADC_IntControl'. */
  199. U8 GH_ADC_get_IntControl_en_lo(U8 index);
  200. /*! \brief Writes the bit group 'en_hi' of register 'ADC_IntControl'. */
  201. void GH_ADC_set_IntControl_en_hi(U8 index, U8 data);
  202. /*! \brief Reads the bit group 'en_hi' of register 'ADC_IntControl'. */
  203. U8 GH_ADC_get_IntControl_en_hi(U8 index);
  204. /*----------------------------------------------------------------------------*/
  205. /* init function */
  206. /*----------------------------------------------------------------------------*/
  207. /*! \brief Initialises the registers and mirror variables. */
  208. void GH_ADC_init(void);
  209. #ifdef SRC_INLINE
  210. #define SRC_INC 1
  211. #include "gh_adc.c"
  212. #undef SRC_INC
  213. #endif
  214. #ifdef __cplusplus
  215. }
  216. #endif
  217. #endif /* _GH_ADC_H */
  218. /*----------------------------------------------------------------------------*/
  219. /* end of file */
  220. /*----------------------------------------------------------------------------*/