gpio_struct.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef _SOC_GPIO_STRUCT_H_
  14. #define _SOC_GPIO_STRUCT_H_
  15. typedef volatile struct {
  16. uint32_t bt_select; /*NA*/
  17. uint32_t out; /*GPIO0~31 output value*/
  18. uint32_t out_w1ts; /*GPIO0~31 output value write 1 to set*/
  19. uint32_t out_w1tc; /*GPIO0~31 output value write 1 to clear*/
  20. union {
  21. struct {
  22. uint32_t data: 8; /*GPIO32~39 output value*/
  23. uint32_t reserved8: 24;
  24. };
  25. uint32_t val;
  26. } out1;
  27. union {
  28. struct {
  29. uint32_t data: 8; /*GPIO32~39 output value write 1 to set*/
  30. uint32_t reserved8: 24;
  31. };
  32. uint32_t val;
  33. } out1_w1ts;
  34. union {
  35. struct {
  36. uint32_t data: 8; /*GPIO32~39 output value write 1 to clear*/
  37. uint32_t reserved8: 24;
  38. };
  39. uint32_t val;
  40. } out1_w1tc;
  41. union {
  42. struct {
  43. uint32_t sel: 8; /*SDIO PADS on/off control from outside*/
  44. uint32_t reserved8: 24;
  45. };
  46. uint32_t val;
  47. } sdio_select;
  48. uint32_t enable; /*GPIO0~31 output enable*/
  49. uint32_t enable_w1ts; /*GPIO0~31 output enable write 1 to set*/
  50. uint32_t enable_w1tc; /*GPIO0~31 output enable write 1 to clear*/
  51. union {
  52. struct {
  53. uint32_t data: 8; /*GPIO32~39 output enable*/
  54. uint32_t reserved8: 24;
  55. };
  56. uint32_t val;
  57. } enable1;
  58. union {
  59. struct {
  60. uint32_t data: 8; /*GPIO32~39 output enable write 1 to set*/
  61. uint32_t reserved8: 24;
  62. };
  63. uint32_t val;
  64. } enable1_w1ts;
  65. union {
  66. struct {
  67. uint32_t data: 8; /*GPIO32~39 output enable write 1 to clear*/
  68. uint32_t reserved8: 24;
  69. };
  70. uint32_t val;
  71. } enable1_w1tc;
  72. union {
  73. struct {
  74. uint32_t strapping: 16; /*GPIO strapping results: {2'd0 boot_sel_dig[7:1] vsdio_boot_sel boot_sel_chip[5:0]} . Boot_sel_dig[7:1]: {U0RXD SD_CLK SD_CMD SD_DATA0 SD_DATA1 SD_DATA2 SD_DATA3} . vsdio_boot_sel: MTDI. boot_sel_chip[5:0]: {GPIO0 U0TXD GPIO2 GPIO4 MTDO GPIO5} */
  75. uint32_t reserved16:16;
  76. };
  77. uint32_t val;
  78. } strap;
  79. uint32_t in; /*GPIO0~31 input value*/
  80. union {
  81. struct {
  82. uint32_t data: 8; /*GPIO32~39 input value*/
  83. uint32_t reserved8: 24;
  84. };
  85. uint32_t val;
  86. } in1;
  87. uint32_t status; /*GPIO0~31 interrupt status*/
  88. uint32_t status_w1ts; /*GPIO0~31 interrupt status write 1 to set*/
  89. uint32_t status_w1tc; /*GPIO0~31 interrupt status write 1 to clear*/
  90. union {
  91. struct {
  92. uint32_t intr_st: 8; /*GPIO32~39 interrupt status*/
  93. uint32_t reserved8: 24;
  94. };
  95. uint32_t val;
  96. } status1;
  97. union {
  98. struct {
  99. uint32_t intr_st: 8; /*GPIO32~39 interrupt status write 1 to set*/
  100. uint32_t reserved8: 24;
  101. };
  102. uint32_t val;
  103. } status1_w1ts;
  104. union {
  105. struct {
  106. uint32_t intr_st: 8; /*GPIO32~39 interrupt status write 1 to clear*/
  107. uint32_t reserved8: 24;
  108. };
  109. uint32_t val;
  110. } status1_w1tc;
  111. uint32_t reserved_5c;
  112. uint32_t acpu_int; /*GPIO0~31 APP CPU interrupt status*/
  113. uint32_t acpu_nmi_int; /*GPIO0~31 APP CPU non-maskable interrupt status*/
  114. uint32_t pcpu_int; /*GPIO0~31 PRO CPU interrupt status*/
  115. uint32_t pcpu_nmi_int; /*GPIO0~31 PRO CPU non-maskable interrupt status*/
  116. uint32_t cpusdio_int; /*SDIO's extent GPIO0~31 interrupt*/
  117. union {
  118. struct {
  119. uint32_t intr: 8; /*GPIO32~39 APP CPU interrupt status*/
  120. uint32_t reserved8: 24;
  121. };
  122. uint32_t val;
  123. } acpu_int1;
  124. union {
  125. struct {
  126. uint32_t intr: 8; /*GPIO32~39 APP CPU non-maskable interrupt status*/
  127. uint32_t reserved8: 24;
  128. };
  129. uint32_t val;
  130. } acpu_nmi_int1;
  131. union {
  132. struct {
  133. uint32_t intr: 8; /*GPIO32~39 PRO CPU interrupt status*/
  134. uint32_t reserved8: 24;
  135. };
  136. uint32_t val;
  137. } pcpu_int1;
  138. union {
  139. struct {
  140. uint32_t intr: 8; /*GPIO32~39 PRO CPU non-maskable interrupt status*/
  141. uint32_t reserved8: 24;
  142. };
  143. uint32_t val;
  144. } pcpu_nmi_int1;
  145. union {
  146. struct {
  147. uint32_t intr: 8; /*SDIO's extent GPIO32~39 interrupt*/
  148. uint32_t reserved8: 24;
  149. };
  150. uint32_t val;
  151. } cpusdio_int1;
  152. union {
  153. struct {
  154. uint32_t reserved0: 2;
  155. uint32_t pad_driver: 1; /*if set to 0: normal output if set to 1: open drain*/
  156. uint32_t reserved3: 4;
  157. uint32_t int_type: 3; /*if set to 0: GPIO interrupt disable if set to 1: rising edge trigger if set to 2: falling edge trigger if set to 3: any edge trigger if set to 4: low level trigger if set to 5: high level trigger*/
  158. uint32_t wakeup_enable: 1; /*GPIO wake up enable only available in light sleep*/
  159. uint32_t config: 2; /*NA*/
  160. uint32_t int_ena: 5; /*bit0: APP CPU interrupt enable bit1: APP CPU non-maskable interrupt enable bit3: PRO CPU interrupt enable bit4: PRO CPU non-maskable interrupt enable bit5: SDIO's extent interrupt enable*/
  161. uint32_t reserved18: 14;
  162. };
  163. uint32_t val;
  164. } pin[40];
  165. union {
  166. struct {
  167. uint32_t rtc_max: 10;
  168. uint32_t reserved10: 21;
  169. uint32_t start: 1;
  170. };
  171. uint32_t val;
  172. } cali_conf;
  173. union {
  174. struct {
  175. uint32_t value_sync2: 20;
  176. uint32_t reserved20: 10;
  177. uint32_t rdy_real: 1;
  178. uint32_t rdy_sync2: 1;
  179. };
  180. uint32_t val;
  181. } cali_data;
  182. union {
  183. struct {
  184. uint32_t func_sel: 6; /*select one of the 256 inputs*/
  185. uint32_t sig_in_inv: 1; /*revert the value of the input if you want to revert please set the value to 1*/
  186. uint32_t sig_in_sel: 1; /*if the slow signal bypass the io matrix or not if you want setting the value to 1*/
  187. uint32_t reserved8: 24; /*The 256 registers below are selection control for 256 input signals connected to GPIO matrix's 40 GPIO input if GPIO_FUNCx_IN_SEL is set to n(0<=n<40): it means GPIOn input is used for input signal x if GPIO_FUNCx_IN_SEL is set to 0x38: the input signal x is set to 1 if GPIO_FUNCx_IN_SEL is set to 0x30: the input signal x is set to 0*/
  188. };
  189. uint32_t val;
  190. } func_in_sel_cfg[256];
  191. union {
  192. struct {
  193. uint32_t func_sel: 9; /*select one of the 256 output to 40 GPIO*/
  194. uint32_t inv_sel: 1; /*invert the output value if you want to revert the output value setting the value to 1*/
  195. uint32_t oen_sel: 1; /*weather using the logical oen signal or not using the value setting by the register*/
  196. uint32_t oen_inv_sel: 1; /*invert the output enable value if you want to revert the output enable value setting the value to 1*/
  197. uint32_t reserved12: 20; /*The 40 registers below are selection control for 40 GPIO output if GPIO_FUNCx_OUT_SEL is set to n(0<=n<256): it means GPIOn input is used for output signal x if GPIO_FUNCx_OUT_INV_SEL is set to 1 the output signal x is set to ~value. if GPIO_FUNC0_OUT_SEL is 256 or GPIO_FUNC0_OEN_SEL is 1 using GPIO_ENABLE_DATA[x] for the enable value else using the signal enable*/
  198. };
  199. uint32_t val;
  200. } func_out_sel_cfg[40];
  201. } gpio_dev_t;
  202. extern gpio_dev_t GPIO;
  203. #endif /* _SOC_GPIO_STRUCT_H_ */