gh_gpio.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /*!
  2. *******************************************************************************
  3. **
  4. ** \file gh_gpio.h
  5. **
  6. ** \brief These GPIO pins can be configured as I/O pins for other hardware modules..
  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_GPIO_H
  18. #define _GH_GPIO_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_GPIO_ENABLE_DEBUG_PRINT 0
  30. #ifdef __LINUX__
  31. #define GH_GPIO_DEBUG_PRINT_FUNCTION printk
  32. #else
  33. #define GH_GPIO_DEBUG_PRINT_FUNCTION printf
  34. #endif
  35. #ifndef __LINUX__
  36. #if GH_GPIO_ENABLE_DEBUG_PRINT
  37. #include <stdio.h>
  38. #endif
  39. #endif
  40. /*----------------------------------------------------------------------------*/
  41. /* registers */
  42. /*----------------------------------------------------------------------------*/
  43. #define REG_GPIO_IS_LOW FIO_ADDRESS(GPIO,0xa0009000) /* read/write */
  44. #define REG_GPIO_IS_HIGH FIO_ADDRESS(GPIO,0xa0009004) /* read/write */
  45. #define REG_GPIO_IBE_LOW FIO_ADDRESS(GPIO,0xa0009008) /* read/write */
  46. #define REG_GPIO_IBE_HIGH FIO_ADDRESS(GPIO,0xa000900C) /* read/write */
  47. #define REG_GPIO_IEV_LOW FIO_ADDRESS(GPIO,0xa0009010) /* read/write */
  48. #define REG_GPIO_IEV_HIGH FIO_ADDRESS(GPIO,0xa0009014) /* read/write */
  49. #define REG_GPIO_IE_LOW FIO_ADDRESS(GPIO,0xa0009018) /* read/write */
  50. #define REG_GPIO_IE_HIGH FIO_ADDRESS(GPIO,0xa000901C) /* read/write */
  51. #define REG_GPIO_IC_LOW FIO_ADDRESS(GPIO,0xa0009020) /* write */
  52. #define REG_GPIO_IC_HIGH FIO_ADDRESS(GPIO,0xa0009024) /* write */
  53. #define REG_GPIO_RIS_LOW FIO_ADDRESS(GPIO,0xa0009028) /* read */
  54. #define REG_GPIO_RIS_HIGH FIO_ADDRESS(GPIO,0xa000902C) /* read */
  55. #define REG_GPIO_MIS_LOW FIO_ADDRESS(GPIO,0xa0009030) /* read */
  56. #define REG_GPIO_MIS_HIGH FIO_ADDRESS(GPIO,0xa0009034) /* read */
  57. #define REG_GPIO_INT_EN FIO_ADDRESS(GPIO,0xa0009038) /* write */
  58. #define REG_GPIO_PER_SEL FIO_ADDRESS(GPIO,0xa000903C) /* read/write */
  59. #define REG_GPIO_DIN_LOW FIO_ADDRESS(GPIO,0xa0009040) /* read */
  60. #define REG_GPIO_DIN_HIGH FIO_ADDRESS(GPIO,0xa0009044) /* read */
  61. #define REG_GPIO_OUTPUT_CFG FIO_ADDRESS(GPIO,0xa0009100) /* write */
  62. #define REG_GPIO_INPUT_CFG FIO_ADDRESS(GPIO,0xa0009200) /* write */
  63. /*----------------------------------------------------------------------------*/
  64. /* bit group structures */
  65. /*----------------------------------------------------------------------------*/
  66. typedef union { /* GPIO_INT_EN */
  67. U32 all;
  68. struct {
  69. U32 int_en : 1;
  70. U32 : 31;
  71. } bitc;
  72. } GH_GPIO_INT_EN_S;
  73. typedef union { /* GPIO_PER_SEL */
  74. U32 all;
  75. struct {
  76. U32 enet_sel : 1;
  77. U32 i2s_sel : 1;
  78. U32 : 30;
  79. } bitc;
  80. } GH_GPIO_PER_SEL_S;
  81. typedef union { /* GPIO_OUTPUT_CFG */
  82. U32 all;
  83. struct {
  84. U32 out_sel : 6;
  85. U32 : 2;
  86. U32 oen_sel : 6;
  87. U32 out_invert : 1;
  88. U32 oen_invert : 1;
  89. U32 : 16;
  90. } bitc;
  91. } GH_GPIO_OUTPUT_CFG_S;
  92. typedef union { /* GPIO_INPUT_CFG */
  93. U32 all;
  94. struct {
  95. U32 in_sel : 6;
  96. U32 : 26;
  97. } bitc;
  98. } GH_GPIO_INPUT_CFG_S;
  99. /*----------------------------------------------------------------------------*/
  100. /* mirror variables */
  101. /*----------------------------------------------------------------------------*/
  102. extern U32 m_gpio_ic_low;
  103. extern U32 m_gpio_ic_high;
  104. extern GH_GPIO_INT_EN_S m_gpio_int_en;
  105. extern GH_GPIO_OUTPUT_CFG_S m_gpio_output_cfg[64];
  106. extern GH_GPIO_INPUT_CFG_S m_gpio_input_cfg[64];
  107. #ifdef __cplusplus
  108. extern "C" {
  109. #endif
  110. /*----------------------------------------------------------------------------*/
  111. /* register GPIO_IS_LOW (read/write) */
  112. /*----------------------------------------------------------------------------*/
  113. /*! \brief Writes the register 'GPIO_IS_LOW'. */
  114. void GH_GPIO_set_IS_LOW(U32 data);
  115. /*! \brief Reads the register 'GPIO_IS_LOW'. */
  116. U32 GH_GPIO_get_IS_LOW(void);
  117. /*----------------------------------------------------------------------------*/
  118. /* register GPIO_IS_HIGH (read/write) */
  119. /*----------------------------------------------------------------------------*/
  120. /*! \brief Writes the register 'GPIO_IS_HIGH'. */
  121. void GH_GPIO_set_IS_HIGH(U32 data);
  122. /*! \brief Reads the register 'GPIO_IS_HIGH'. */
  123. U32 GH_GPIO_get_IS_HIGH(void);
  124. /*----------------------------------------------------------------------------*/
  125. /* register GPIO_IBE_LOW (read/write) */
  126. /*----------------------------------------------------------------------------*/
  127. /*! \brief Writes the register 'GPIO_IBE_LOW'. */
  128. void GH_GPIO_set_IBE_LOW(U32 data);
  129. /*! \brief Reads the register 'GPIO_IBE_LOW'. */
  130. U32 GH_GPIO_get_IBE_LOW(void);
  131. /*----------------------------------------------------------------------------*/
  132. /* register GPIO_IBE_HIGH (read/write) */
  133. /*----------------------------------------------------------------------------*/
  134. /*! \brief Writes the register 'GPIO_IBE_HIGH'. */
  135. void GH_GPIO_set_IBE_HIGH(U32 data);
  136. /*! \brief Reads the register 'GPIO_IBE_HIGH'. */
  137. U32 GH_GPIO_get_IBE_HIGH(void);
  138. /*----------------------------------------------------------------------------*/
  139. /* register GPIO_IEV_LOW (read/write) */
  140. /*----------------------------------------------------------------------------*/
  141. /*! \brief Writes the register 'GPIO_IEV_LOW'. */
  142. void GH_GPIO_set_IEV_LOW(U32 data);
  143. /*! \brief Reads the register 'GPIO_IEV_LOW'. */
  144. U32 GH_GPIO_get_IEV_LOW(void);
  145. /*----------------------------------------------------------------------------*/
  146. /* register GPIO_IEV_HIGH (read/write) */
  147. /*----------------------------------------------------------------------------*/
  148. /*! \brief Writes the register 'GPIO_IEV_HIGH'. */
  149. void GH_GPIO_set_IEV_HIGH(U32 data);
  150. /*! \brief Reads the register 'GPIO_IEV_HIGH'. */
  151. U32 GH_GPIO_get_IEV_HIGH(void);
  152. /*----------------------------------------------------------------------------*/
  153. /* register GPIO_IE_LOW (read/write) */
  154. /*----------------------------------------------------------------------------*/
  155. /*! \brief Writes the register 'GPIO_IE_LOW'. */
  156. void GH_GPIO_set_IE_LOW(U32 data);
  157. /*! \brief Reads the register 'GPIO_IE_LOW'. */
  158. U32 GH_GPIO_get_IE_LOW(void);
  159. /*----------------------------------------------------------------------------*/
  160. /* register GPIO_IE_HIGH (read/write) */
  161. /*----------------------------------------------------------------------------*/
  162. /*! \brief Writes the register 'GPIO_IE_HIGH'. */
  163. void GH_GPIO_set_IE_HIGH(U32 data);
  164. /*! \brief Reads the register 'GPIO_IE_HIGH'. */
  165. U32 GH_GPIO_get_IE_HIGH(void);
  166. /*----------------------------------------------------------------------------*/
  167. /* register GPIO_IC_LOW (write) */
  168. /*----------------------------------------------------------------------------*/
  169. /*! \brief Writes the register 'GPIO_IC_LOW'. */
  170. void GH_GPIO_set_IC_LOW(U32 data);
  171. /*! \brief Reads the mirror variable of the register 'GPIO_IC_LOW'. */
  172. U32 GH_GPIO_getm_IC_LOW(void);
  173. /*----------------------------------------------------------------------------*/
  174. /* register GPIO_IC_HIGH (write) */
  175. /*----------------------------------------------------------------------------*/
  176. /*! \brief Writes the register 'GPIO_IC_HIGH'. */
  177. void GH_GPIO_set_IC_HIGH(U32 data);
  178. /*! \brief Reads the mirror variable of the register 'GPIO_IC_HIGH'. */
  179. U32 GH_GPIO_getm_IC_HIGH(void);
  180. /*----------------------------------------------------------------------------*/
  181. /* register GPIO_RIS_LOW (read) */
  182. /*----------------------------------------------------------------------------*/
  183. /*! \brief Reads the register 'GPIO_RIS_LOW'. */
  184. U32 GH_GPIO_get_RIS_LOW(void);
  185. /*----------------------------------------------------------------------------*/
  186. /* register GPIO_RIS_HIGH (read) */
  187. /*----------------------------------------------------------------------------*/
  188. /*! \brief Reads the register 'GPIO_RIS_HIGH'. */
  189. U32 GH_GPIO_get_RIS_HIGH(void);
  190. /*----------------------------------------------------------------------------*/
  191. /* register GPIO_MIS_LOW (read) */
  192. /*----------------------------------------------------------------------------*/
  193. /*! \brief Reads the register 'GPIO_MIS_LOW'. */
  194. U32 GH_GPIO_get_MIS_LOW(void);
  195. /*----------------------------------------------------------------------------*/
  196. /* register GPIO_MIS_HIGH (read) */
  197. /*----------------------------------------------------------------------------*/
  198. /*! \brief Reads the register 'GPIO_MIS_HIGH'. */
  199. U32 GH_GPIO_get_MIS_HIGH(void);
  200. /*----------------------------------------------------------------------------*/
  201. /* register GPIO_INT_EN (write) */
  202. /*----------------------------------------------------------------------------*/
  203. /*! \brief Writes the register 'GPIO_INT_EN'. */
  204. void GH_GPIO_set_INT_EN(U32 data);
  205. /*! \brief Reads the mirror variable of the register 'GPIO_INT_EN'. */
  206. U32 GH_GPIO_getm_INT_EN(void);
  207. /*! \brief Writes the bit group 'int_en' of register 'GPIO_INT_EN'. */
  208. void GH_GPIO_set_INT_EN_int_en(U8 data);
  209. /*! \brief Reads the bit group 'int_en' from the mirror variable of register 'GPIO_INT_EN'. */
  210. U8 GH_GPIO_getm_INT_EN_int_en(void);
  211. /*----------------------------------------------------------------------------*/
  212. /* register GPIO_PER_SEL (read/write) */
  213. /*----------------------------------------------------------------------------*/
  214. /*! \brief Writes the register 'GPIO_PER_SEL'. */
  215. void GH_GPIO_set_PER_SEL(U32 data);
  216. /*! \brief Reads the register 'GPIO_PER_SEL'. */
  217. U32 GH_GPIO_get_PER_SEL(void);
  218. /*! \brief Writes the bit group 'enet_sel' of register 'GPIO_PER_SEL'. */
  219. void GH_GPIO_set_PER_SEL_enet_sel(U8 data);
  220. /*! \brief Reads the bit group 'enet_sel' of register 'GPIO_PER_SEL'. */
  221. U8 GH_GPIO_get_PER_SEL_enet_sel(void);
  222. /*! \brief Writes the bit group 'i2s_sel' of register 'GPIO_PER_SEL'. */
  223. void GH_GPIO_set_PER_SEL_i2s_sel(U8 data);
  224. /*! \brief Reads the bit group 'i2s_sel' of register 'GPIO_PER_SEL'. */
  225. U8 GH_GPIO_get_PER_SEL_i2s_sel(void);
  226. /*----------------------------------------------------------------------------*/
  227. /* register GPIO_DIN_LOW (read) */
  228. /*----------------------------------------------------------------------------*/
  229. /*! \brief Reads the register 'GPIO_DIN_LOW'. */
  230. U32 GH_GPIO_get_DIN_LOW(void);
  231. /*----------------------------------------------------------------------------*/
  232. /* register GPIO_DIN_HIGH (read) */
  233. /*----------------------------------------------------------------------------*/
  234. /*! \brief Reads the register 'GPIO_DIN_HIGH'. */
  235. U32 GH_GPIO_get_DIN_HIGH(void);
  236. /*----------------------------------------------------------------------------*/
  237. /* register GPIO_OUTPUT_CFG (write) */
  238. /*----------------------------------------------------------------------------*/
  239. /*! \brief Writes the register 'GPIO_OUTPUT_CFG'. */
  240. void GH_GPIO_set_OUTPUT_CFG(U8 index, U32 data);
  241. /*! \brief Reads the mirror variable of the register 'GPIO_OUTPUT_CFG'. */
  242. U32 GH_GPIO_getm_OUTPUT_CFG(U8 index);
  243. /*! \brief Writes the bit group 'out_sel' of register 'GPIO_OUTPUT_CFG'. */
  244. void GH_GPIO_set_OUTPUT_CFG_out_sel(U8 index, U8 data);
  245. /*! \brief Reads the bit group 'out_sel' from the mirror variable of register 'GPIO_OUTPUT_CFG'. */
  246. U8 GH_GPIO_getm_OUTPUT_CFG_out_sel(U8 index);
  247. /*! \brief Writes the bit group 'oen_sel' of register 'GPIO_OUTPUT_CFG'. */
  248. void GH_GPIO_set_OUTPUT_CFG_oen_sel(U8 index, U8 data);
  249. /*! \brief Reads the bit group 'oen_sel' from the mirror variable of register 'GPIO_OUTPUT_CFG'. */
  250. U8 GH_GPIO_getm_OUTPUT_CFG_oen_sel(U8 index);
  251. /*! \brief Writes the bit group 'out_invert' of register 'GPIO_OUTPUT_CFG'. */
  252. void GH_GPIO_set_OUTPUT_CFG_out_invert(U8 index, U8 data);
  253. /*! \brief Reads the bit group 'out_invert' from the mirror variable of register 'GPIO_OUTPUT_CFG'. */
  254. U8 GH_GPIO_getm_OUTPUT_CFG_out_invert(U8 index);
  255. /*! \brief Writes the bit group 'oen_invert' of register 'GPIO_OUTPUT_CFG'. */
  256. void GH_GPIO_set_OUTPUT_CFG_oen_invert(U8 index, U8 data);
  257. /*! \brief Reads the bit group 'oen_invert' from the mirror variable of register 'GPIO_OUTPUT_CFG'. */
  258. U8 GH_GPIO_getm_OUTPUT_CFG_oen_invert(U8 index);
  259. /*----------------------------------------------------------------------------*/
  260. /* register GPIO_INPUT_CFG (write) */
  261. /*----------------------------------------------------------------------------*/
  262. /*! \brief Writes the register 'GPIO_INPUT_CFG'. */
  263. void GH_GPIO_set_INPUT_CFG(U8 index, U32 data);
  264. /*! \brief Reads the mirror variable of the register 'GPIO_INPUT_CFG'. */
  265. U32 GH_GPIO_getm_INPUT_CFG(U8 index);
  266. /*! \brief Writes the bit group 'in_sel' of register 'GPIO_INPUT_CFG'. */
  267. void GH_GPIO_set_INPUT_CFG_in_sel(U8 index, U8 data);
  268. /*! \brief Reads the bit group 'in_sel' from the mirror variable of register 'GPIO_INPUT_CFG'. */
  269. U8 GH_GPIO_getm_INPUT_CFG_in_sel(U8 index);
  270. /*----------------------------------------------------------------------------*/
  271. /* init function */
  272. /*----------------------------------------------------------------------------*/
  273. /*! \brief Initialises the registers and mirror variables. */
  274. void GH_GPIO_init(void);
  275. #ifdef SRC_INLINE
  276. #define SRC_INC 1
  277. #include "gh_gpio.c"
  278. #undef SRC_INC
  279. #endif
  280. #ifdef __cplusplus
  281. }
  282. #endif
  283. #endif /* _GH_GPIO_H */
  284. /*----------------------------------------------------------------------------*/
  285. /* end of file */
  286. /*----------------------------------------------------------------------------*/