gpio_struct.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. /**
  2. * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /** Group: configuration register */
  12. /** Type of bt_select register
  13. * GPIO bit select register
  14. */
  15. typedef union {
  16. struct {
  17. /** bt_sel : R/W; bitpos: [31:0]; default: 0;
  18. * GPIO bit select register
  19. */
  20. uint32_t bt_sel:32;
  21. };
  22. uint32_t val;
  23. } gpio_bt_select_reg_t;
  24. /** Type of out register
  25. * GPIO output register for GPIO0-31
  26. */
  27. typedef union {
  28. struct {
  29. /** out_data_orig : R/W/SC/WTC; bitpos: [31:0]; default: 0;
  30. * GPIO output register for GPIO0-31
  31. */
  32. uint32_t out_data_orig:32;
  33. };
  34. uint32_t val;
  35. } gpio_out_reg_t;
  36. /** Type of out_w1ts register
  37. * GPIO output set register for GPIO0-31
  38. */
  39. typedef union {
  40. struct {
  41. /** out_w1ts : WT; bitpos: [31:0]; default: 0;
  42. * GPIO output set register for GPIO0-31
  43. */
  44. uint32_t out_w1ts:32;
  45. };
  46. uint32_t val;
  47. } gpio_out_w1ts_reg_t;
  48. /** Type of out_w1tc register
  49. * GPIO output clear register for GPIO0-31
  50. */
  51. typedef union {
  52. struct {
  53. /** out_w1tc : WT; bitpos: [31:0]; default: 0;
  54. * GPIO output clear register for GPIO0-31
  55. */
  56. uint32_t out_w1tc:32;
  57. };
  58. uint32_t val;
  59. } gpio_out_w1tc_reg_t;
  60. /** Type of out1 register
  61. * GPIO output register for GPIO32-34
  62. */
  63. typedef union {
  64. struct {
  65. /** out1_data_orig : R/W/SC/WTC; bitpos: [2:0]; default: 0;
  66. * GPIO output register for GPIO32-34
  67. */
  68. uint32_t out1_data_orig:3;
  69. uint32_t reserved_3:29;
  70. };
  71. uint32_t val;
  72. } gpio_out1_reg_t;
  73. /** Type of out1_w1ts register
  74. * GPIO output set register for GPIO32-34
  75. */
  76. typedef union {
  77. struct {
  78. /** out1_w1ts : WT; bitpos: [2:0]; default: 0;
  79. * GPIO output set register for GPIO32-34
  80. */
  81. uint32_t out1_w1ts:3;
  82. uint32_t reserved_3:29;
  83. };
  84. uint32_t val;
  85. } gpio_out1_w1ts_reg_t;
  86. /** Type of out1_w1tc register
  87. * GPIO output clear register for GPIO32-34
  88. */
  89. typedef union {
  90. struct {
  91. /** out1_w1tc : WT; bitpos: [2:0]; default: 0;
  92. * GPIO output clear register for GPIO32-34
  93. */
  94. uint32_t out1_w1tc:3;
  95. uint32_t reserved_3:29;
  96. };
  97. uint32_t val;
  98. } gpio_out1_w1tc_reg_t;
  99. /** Type of sdio_select register
  100. * GPIO sdio select register
  101. */
  102. typedef union {
  103. struct {
  104. /** sdio_sel : R/W; bitpos: [7:0]; default: 0;
  105. * GPIO sdio select register
  106. */
  107. uint32_t sdio_sel:8;
  108. uint32_t reserved_8:24;
  109. };
  110. uint32_t val;
  111. } gpio_sdio_select_reg_t;
  112. /** Type of enable register
  113. * GPIO output enable register for GPIO0-31
  114. */
  115. typedef union {
  116. struct {
  117. /** enable_data : R/W/WTC; bitpos: [31:0]; default: 0;
  118. * GPIO output enable register for GPIO0-31
  119. */
  120. uint32_t enable_data:32;
  121. };
  122. uint32_t val;
  123. } gpio_enable_reg_t;
  124. /** Type of enable_w1ts register
  125. * GPIO output enable set register for GPIO0-31
  126. */
  127. typedef union {
  128. struct {
  129. /** enable_w1ts : WT; bitpos: [31:0]; default: 0;
  130. * GPIO output enable set register for GPIO0-31
  131. */
  132. uint32_t enable_w1ts:32;
  133. };
  134. uint32_t val;
  135. } gpio_enable_w1ts_reg_t;
  136. /** Type of enable_w1tc register
  137. * GPIO output enable clear register for GPIO0-31
  138. */
  139. typedef union {
  140. struct {
  141. /** enable_w1tc : WT; bitpos: [31:0]; default: 0;
  142. * GPIO output enable clear register for GPIO0-31
  143. */
  144. uint32_t enable_w1tc:32;
  145. };
  146. uint32_t val;
  147. } gpio_enable_w1tc_reg_t;
  148. /** Type of enable1 register
  149. * GPIO output enable register for GPIO32-34
  150. */
  151. typedef union {
  152. struct {
  153. /** enable1_data : R/W/WTC; bitpos: [2:0]; default: 0;
  154. * GPIO output enable register for GPIO32-34
  155. */
  156. uint32_t enable1_data:3;
  157. uint32_t reserved_3:29;
  158. };
  159. uint32_t val;
  160. } gpio_enable1_reg_t;
  161. /** Type of enable1_w1ts register
  162. * GPIO output enable set register for GPIO32-34
  163. */
  164. typedef union {
  165. struct {
  166. /** enable1_w1ts : WT; bitpos: [2:0]; default: 0;
  167. * GPIO output enable set register for GPIO32-34
  168. */
  169. uint32_t enable1_w1ts:3;
  170. uint32_t reserved_3:29;
  171. };
  172. uint32_t val;
  173. } gpio_enable1_w1ts_reg_t;
  174. /** Type of enable1_w1tc register
  175. * GPIO output enable clear register for GPIO32-34
  176. */
  177. typedef union {
  178. struct {
  179. /** enable1_w1tc : WT; bitpos: [2:0]; default: 0;
  180. * GPIO output enable clear register for GPIO32-34
  181. */
  182. uint32_t enable1_w1tc:3;
  183. uint32_t reserved_3:29;
  184. };
  185. uint32_t val;
  186. } gpio_enable1_w1tc_reg_t;
  187. /** Type of strap register
  188. * pad strapping register
  189. */
  190. typedef union {
  191. struct {
  192. /** strapping : RO; bitpos: [15:0]; default: 0;
  193. * pad strapping register
  194. */
  195. uint32_t strapping:16;
  196. uint32_t reserved_16:16;
  197. };
  198. uint32_t val;
  199. } gpio_strap_reg_t;
  200. /** Type of in register
  201. * GPIO input register for GPIO0-31
  202. */
  203. typedef union {
  204. struct {
  205. /** in_data_next : RO; bitpos: [31:0]; default: 0;
  206. * GPIO input register for GPIO0-31
  207. */
  208. uint32_t in_data_next:32;
  209. };
  210. uint32_t val;
  211. } gpio_in_reg_t;
  212. /** Type of in1 register
  213. * GPIO input register for GPIO32-34
  214. */
  215. typedef union {
  216. struct {
  217. /** in1_data_next : RO; bitpos: [2:0]; default: 0;
  218. * GPIO input register for GPIO32-34
  219. */
  220. uint32_t in1_data_next:3;
  221. uint32_t reserved_3:29;
  222. };
  223. uint32_t val;
  224. } gpio_in1_reg_t;
  225. /** Type of status register
  226. * GPIO interrupt status register for GPIO0-31
  227. */
  228. typedef union {
  229. struct {
  230. /** status_interrupt : R/W/WTC; bitpos: [31:0]; default: 0;
  231. * GPIO interrupt status register for GPIO0-31
  232. */
  233. uint32_t status_interrupt:32;
  234. };
  235. uint32_t val;
  236. } gpio_status_reg_t;
  237. /** Type of status_w1ts register
  238. * GPIO interrupt status set register for GPIO0-31
  239. */
  240. typedef union {
  241. struct {
  242. /** status_w1ts : WT; bitpos: [31:0]; default: 0;
  243. * GPIO interrupt status set register for GPIO0-31
  244. */
  245. uint32_t status_w1ts:32;
  246. };
  247. uint32_t val;
  248. } gpio_status_w1ts_reg_t;
  249. /** Type of status_w1tc register
  250. * GPIO interrupt status clear register for GPIO0-31
  251. */
  252. typedef union {
  253. struct {
  254. /** status_w1tc : WT; bitpos: [31:0]; default: 0;
  255. * GPIO interrupt status clear register for GPIO0-31
  256. */
  257. uint32_t status_w1tc:32;
  258. };
  259. uint32_t val;
  260. } gpio_status_w1tc_reg_t;
  261. /** Type of status1 register
  262. * GPIO interrupt status register for GPIO32-34
  263. */
  264. typedef union {
  265. struct {
  266. /** status1_interrupt : R/W/WTC; bitpos: [2:0]; default: 0;
  267. * GPIO interrupt status register for GPIO32-34
  268. */
  269. uint32_t status1_interrupt:3;
  270. uint32_t reserved_3:29;
  271. };
  272. uint32_t val;
  273. } gpio_status1_reg_t;
  274. /** Type of status1_w1ts register
  275. * GPIO interrupt status set register for GPIO32-34
  276. */
  277. typedef union {
  278. struct {
  279. /** status1_w1ts : WT; bitpos: [2:0]; default: 0;
  280. * GPIO interrupt status set register for GPIO32-34
  281. */
  282. uint32_t status1_w1ts:3;
  283. uint32_t reserved_3:29;
  284. };
  285. uint32_t val;
  286. } gpio_status1_w1ts_reg_t;
  287. /** Type of status1_w1tc register
  288. * GPIO interrupt status clear register for GPIO32-34
  289. */
  290. typedef union {
  291. struct {
  292. /** status1_w1tc : WT; bitpos: [2:0]; default: 0;
  293. * GPIO interrupt status clear register for GPIO32-34
  294. */
  295. uint32_t status1_w1tc:3;
  296. uint32_t reserved_3:29;
  297. };
  298. uint32_t val;
  299. } gpio_status1_w1tc_reg_t;
  300. /** Type of pcpu_int register
  301. * GPIO PRO_CPU interrupt status register for GPIO0-31
  302. */
  303. typedef union {
  304. struct {
  305. /** procpu_int : RO; bitpos: [31:0]; default: 0;
  306. * GPIO PRO_CPU interrupt status register for GPIO0-31
  307. */
  308. uint32_t procpu_int:32;
  309. };
  310. uint32_t val;
  311. } gpio_pcpu_int_reg_t;
  312. /** Type of pcpu_nmi_int register
  313. * GPIO PRO_CPU(not shielded) interrupt status register for GPIO0-31
  314. */
  315. typedef union {
  316. struct {
  317. /** procpu_nmi_int : RO; bitpos: [31:0]; default: 0;
  318. * GPIO PRO_CPU(not shielded) interrupt status register for GPIO0-31
  319. */
  320. uint32_t procpu_nmi_int:32;
  321. };
  322. uint32_t val;
  323. } gpio_pcpu_nmi_int_reg_t;
  324. /** Type of cpusdio_int register
  325. * GPIO CPUSDIO interrupt status register for GPIO0-31
  326. */
  327. typedef union {
  328. struct {
  329. /** sdio_int : RO; bitpos: [31:0]; default: 0;
  330. * GPIO CPUSDIO interrupt status register for GPIO0-31
  331. */
  332. uint32_t sdio_int:32;
  333. };
  334. uint32_t val;
  335. } gpio_cpusdio_int_reg_t;
  336. /** Type of pcpu_int1 register
  337. * GPIO PRO_CPU interrupt status register for GPIO32-34
  338. */
  339. typedef union {
  340. struct {
  341. /** procpu_int1 : RO; bitpos: [2:0]; default: 0;
  342. * GPIO PRO_CPU interrupt status register for GPIO32-34
  343. */
  344. uint32_t procpu_int1:3;
  345. uint32_t reserved_3:29;
  346. };
  347. uint32_t val;
  348. } gpio_pcpu_int1_reg_t;
  349. /** Type of pcpu_nmi_int1 register
  350. * GPIO PRO_CPU(not shielded) interrupt status register for GPIO32-34
  351. */
  352. typedef union {
  353. struct {
  354. /** procpu_nmi_int1 : RO; bitpos: [2:0]; default: 0;
  355. * GPIO PRO_CPU(not shielded) interrupt status register for GPIO32-34
  356. */
  357. uint32_t procpu_nmi_int1:3;
  358. uint32_t reserved_3:29;
  359. };
  360. uint32_t val;
  361. } gpio_pcpu_nmi_int1_reg_t;
  362. /** Type of cpusdio_int1 register
  363. * GPIO CPUSDIO interrupt status register for GPIO32-34
  364. */
  365. typedef union {
  366. struct {
  367. /** sdio_int1 : RO; bitpos: [2:0]; default: 0;
  368. * GPIO CPUSDIO interrupt status register for GPIO32-34
  369. */
  370. uint32_t sdio_int1:3;
  371. uint32_t reserved_3:29;
  372. };
  373. uint32_t val;
  374. } gpio_cpusdio_int1_reg_t;
  375. /** Type of pin register
  376. * GPIO pin configuration register
  377. */
  378. typedef union {
  379. struct {
  380. /** sync2_bypass : R/W; bitpos: [1:0]; default: 0;
  381. * set GPIO input_sync2 signal mode. 0:disable. 1:trigger at negedge. 2or3:trigger at
  382. * posedge.
  383. */
  384. uint32_t sync2_bypass:2;
  385. /** pad_driver : R/W; bitpos: [2]; default: 0;
  386. * set this bit to select pad driver. 1:open-drain. 0:normal.
  387. */
  388. uint32_t pad_driver:1;
  389. /** sync1_bypass : R/W; bitpos: [4:3]; default: 0;
  390. * set GPIO input_sync1 signal mode. 0:disable. 1:trigger at negedge. 2or3:trigger at
  391. * posedge.
  392. */
  393. uint32_t sync1_bypass:2;
  394. uint32_t reserved_5:2;
  395. /** int_type : R/W; bitpos: [9:7]; default: 0;
  396. * set this value to choose interrupt mode. 0:disable GPIO interrupt. 1:trigger at
  397. * posedge. 2:trigger at negedge. 3:trigger at any edge. 4:valid at low level. 5:valid
  398. * at high level
  399. */
  400. uint32_t int_type:3;
  401. /** wakeup_enable : R/W; bitpos: [10]; default: 0;
  402. * set this bit to enable GPIO wakeup.(can only wakeup CPU from Light-sleep Mode)
  403. */
  404. uint32_t wakeup_enable:1;
  405. /** config : R/W; bitpos: [12:11]; default: 0;
  406. * reserved
  407. */
  408. uint32_t config:2;
  409. /** int_ena : R/W; bitpos: [17:13]; default: 0;
  410. * set bit 13 to enable CPU interrupt. set bit 14 to enable CPU(not shielded)
  411. * interrupt.
  412. */
  413. uint32_t int_ena:5;
  414. uint32_t reserved_18:14;
  415. };
  416. uint32_t val;
  417. } gpio_pin_reg_t;
  418. /** Type of status_next register
  419. * GPIO interrupt source register for GPIO0-31
  420. */
  421. typedef union {
  422. struct {
  423. /** status_interrupt_next : RO; bitpos: [31:0]; default: 0;
  424. * GPIO interrupt source register for GPIO0-31
  425. */
  426. uint32_t status_interrupt_next:32;
  427. };
  428. uint32_t val;
  429. } gpio_status_next_reg_t;
  430. /** Type of status_next1 register
  431. * GPIO interrupt source register for GPIO32-34
  432. */
  433. typedef union {
  434. struct {
  435. /** status_interrupt_next1 : RO; bitpos: [2:0]; default: 0;
  436. * GPIO interrupt source register for GPIO32-34
  437. */
  438. uint32_t status_interrupt_next1:3;
  439. uint32_t reserved_3:29;
  440. };
  441. uint32_t val;
  442. } gpio_status_next1_reg_t;
  443. /** Type of func_in_sel_cfg register
  444. * GPIO input function configuration register
  445. */
  446. typedef union {
  447. struct {
  448. /** in_sel : R/W; bitpos: [5:0]; default: 60;
  449. * set this value: s=0-34: connect GPIO[s] to this port. s=0x38: set this port always
  450. * high level. s=0x3C: set this port always low level.
  451. */
  452. uint32_t in_sel:6;
  453. /** in_inv_sel : R/W; bitpos: [6]; default: 0;
  454. * set this bit to invert input signal. 1:invert. 0:not invert.
  455. */
  456. uint32_t in_inv_sel:1;
  457. /** sig_in_sel : R/W; bitpos: [7]; default: 0;
  458. * set this bit to bypass GPIO. 1:do not bypass GPIO. 0:bypass GPIO.
  459. */
  460. uint32_t sig_in_sel:1;
  461. uint32_t reserved_8:24;
  462. };
  463. uint32_t val;
  464. } gpio_func_in_sel_cfg_reg_t;
  465. /** Type of func_out_sel_cfg register
  466. * GPIO output function select register
  467. */
  468. typedef union {
  469. struct {
  470. /** out_sel : R/W/SC; bitpos: [7:0]; default: 128;
  471. * The value of the bits: 0<=s<=256. Set the value to select output signal. s=0-127:
  472. * output of GPIO[n] equals input of peripheral[s]. s=128: output of GPIO[n] equals
  473. * GPIO_OUT_REG[n].
  474. */
  475. uint32_t out_sel:8;
  476. /** out_inv_sel : R/W/SC; bitpos: [8]; default: 0;
  477. * set this bit to invert output signal.1:invert.0:not invert.
  478. */
  479. uint32_t out_inv_sel:1;
  480. /** oen_sel : R/W; bitpos: [9]; default: 0;
  481. * set this bit to select output enable signal.1:use GPIO_ENABLE_REG[n] as output
  482. * enable signal.0:use peripheral output enable signal.
  483. */
  484. uint32_t oen_sel:1;
  485. /** oen_inv_sel : R/W; bitpos: [10]; default: 0;
  486. * set this bit to invert output enable signal.1:invert.0:not invert.
  487. */
  488. uint32_t oen_inv_sel:1;
  489. uint32_t reserved_11:21;
  490. };
  491. uint32_t val;
  492. } gpio_func_out_sel_cfg_reg_t;
  493. /** Type of clock_gate register
  494. * GPIO clock gate register
  495. */
  496. typedef union {
  497. struct {
  498. /** clk_en : R/W; bitpos: [0]; default: 1;
  499. * set this bit to enable GPIO clock gate
  500. */
  501. uint32_t clk_en:1;
  502. uint32_t reserved_1:31;
  503. };
  504. uint32_t val;
  505. } gpio_clock_gate_reg_t;
  506. /** Type of date register
  507. * GPIO version register
  508. */
  509. typedef union {
  510. struct {
  511. /** date : R/W; bitpos: [27:0]; default: 35655968;
  512. * version register
  513. */
  514. uint32_t date:28;
  515. uint32_t reserved_28:4;
  516. };
  517. uint32_t val;
  518. } gpio_date_reg_t;
  519. typedef struct gpio_dev_t {
  520. volatile gpio_bt_select_reg_t bt_select;
  521. volatile gpio_out_reg_t out;
  522. volatile gpio_out_w1ts_reg_t out_w1ts;
  523. volatile gpio_out_w1tc_reg_t out_w1tc;
  524. volatile gpio_out1_reg_t out1;
  525. volatile gpio_out1_w1ts_reg_t out1_w1ts;
  526. volatile gpio_out1_w1tc_reg_t out1_w1tc;
  527. volatile gpio_sdio_select_reg_t sdio_select;
  528. volatile gpio_enable_reg_t enable;
  529. volatile gpio_enable_w1ts_reg_t enable_w1ts;
  530. volatile gpio_enable_w1tc_reg_t enable_w1tc;
  531. volatile gpio_enable1_reg_t enable1;
  532. volatile gpio_enable1_w1ts_reg_t enable1_w1ts;
  533. volatile gpio_enable1_w1tc_reg_t enable1_w1tc;
  534. volatile gpio_strap_reg_t strap;
  535. volatile gpio_in_reg_t in;
  536. volatile gpio_in1_reg_t in1;
  537. volatile gpio_status_reg_t status;
  538. volatile gpio_status_w1ts_reg_t status_w1ts;
  539. volatile gpio_status_w1tc_reg_t status_w1tc;
  540. volatile gpio_status1_reg_t status1;
  541. volatile gpio_status1_w1ts_reg_t status1_w1ts;
  542. volatile gpio_status1_w1tc_reg_t status1_w1tc;
  543. volatile gpio_pcpu_int_reg_t pcpu_int;
  544. volatile gpio_pcpu_nmi_int_reg_t pcpu_nmi_int;
  545. volatile gpio_cpusdio_int_reg_t cpusdio_int;
  546. volatile gpio_pcpu_int1_reg_t pcpu_int1;
  547. volatile gpio_pcpu_nmi_int1_reg_t pcpu_nmi_int1;
  548. volatile gpio_cpusdio_int1_reg_t cpusdio_int1;
  549. volatile gpio_pin_reg_t pin[35];
  550. uint32_t reserved_100[19];
  551. volatile gpio_status_next_reg_t status_next;
  552. volatile gpio_status_next1_reg_t status_next1;
  553. volatile gpio_func_in_sel_cfg_reg_t func_in_sel_cfg[128];
  554. uint32_t reserved_34b[128];
  555. volatile gpio_func_out_sel_cfg_reg_t func_out_sel_cfg[35];
  556. uint32_t reserved_5e0[19];
  557. volatile gpio_clock_gate_reg_t clock_gate;
  558. uint32_t reserved_630[51];
  559. volatile gpio_date_reg_t date;
  560. } gpio_dev_t;
  561. extern gpio_dev_t GPIO;
  562. #ifndef __cplusplus
  563. _Static_assert(sizeof(gpio_dev_t) == 0x700, "Invalid size of gpio_dev_t structure");
  564. #endif
  565. #ifdef __cplusplus
  566. }
  567. #endif