wm_gpio_afsel.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. /**
  2. * @file wm_gpio_afsel.h
  3. *
  4. * @brief GPIO Driver Module
  5. *
  6. * @author dave
  7. *
  8. * Copyright (c) 2014 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef WM_GPIO_AFSEL_H
  11. #define WM_GPIO_AFSEL_H
  12. #include "wm_gpio.h"
  13. #include "wm_regs.h"
  14. #include "wm_irq.h"
  15. #include "wm_osal.h"
  16. #include "tls_common.h"
  17. /**
  18. * @addtogroup Driver_APIs
  19. * @{
  20. */
  21. /**
  22. * @defgroup IOMUX_Driver_APIs IOMUX Driver APIs
  23. * @brief IO Multiplex driver APIs
  24. */
  25. /**
  26. * @addtogroup IOMUX_Driver_APIs
  27. * @{
  28. */
  29. /**
  30. * @brief config the pins used for highspeed spi
  31. * @param numsel: config highspeed spi pins multiplex relation,valid para 0,1
  32. * 0: hspi0 1: hspi1 only for 56pin
  33. * hspi_ck PB06 hspi_ck PB12
  34. * hspi_int PB07 hspi_int PB13
  35. * hspi_cs PB09 hspi_cs PB14
  36. * hspi_di PB10 hspi_di PB15
  37. * hspi_do PB11 hspi_do PB16
  38. * @return None
  39. */
  40. void wm_hspi_gpio_config(uint8_t numsel);
  41. /**
  42. * @brief config the pins used for spi ck
  43. * @param io_name: config spi ck pins name
  44. * WM_IO_PB_01
  45. * WM_IO_PB_02
  46. * WM_IO_PB_15 only for 56pin
  47. * WM_IO_PB_24 only for 56pin
  48. *
  49. * @return None
  50. */
  51. void wm_spi_ck_config(enum tls_io_name io_name);
  52. /**
  53. * @brief config the pins used for spi cs
  54. * @param io_name: config spi cs pins name
  55. * WM_IO_PA_00
  56. * WM_IO_PB_04
  57. * WM_IO_PB_14 only for 56pin
  58. * WM_IO_PB_23 only for 56pin
  59. *
  60. * @return None
  61. */
  62. void wm_spi_cs_config(enum tls_io_name io_name);
  63. /**
  64. * @brief config the pins used for spi di
  65. * @param io_name: config spi di pins name
  66. * WM_IO_PB_00
  67. * WM_IO_PB_03
  68. * WM_IO_PB_16 only for 56pin
  69. * WM_IO_PB_25 only for 56pin
  70. *
  71. * @return None
  72. */
  73. void wm_spi_di_config(enum tls_io_name io_name);
  74. /**
  75. * @brief config the pins used for spi do
  76. * @param io_name: config spi do pins name
  77. * WM_IO_PA_07
  78. * WM_IO_PB_05
  79. * WM_IO_PB_17 only for 56pin
  80. * WM_IO_PB_26 only for 56pin
  81. *
  82. * @return None
  83. */
  84. void wm_spi_do_config(enum tls_io_name io_name);
  85. /**
  86. * @brief config the pins used for sdio host ck dat0 dat1 dat2 dat3
  87. * @param numsel: config sdio ck cmd dat0 dat1 dat2 dat3 pins multiplex relation,valid para 0,1
  88. * 0: 1: only for 56pin
  89. * sdio_ck PB06 sdio_ck PA09
  90. * sdio_cmd PB07 sdio_cmd PA10
  91. * sdio_dat0 PB08 sdio_dat0 PA11
  92. * sdio_dat1 PB09 sdio_dat1 PA12
  93. * sdio_dat2 PB10 sdio_dat2 PA13
  94. * sdio_dat3 PB11 sdio_dat3 PA14
  95. *
  96. * @return None
  97. */
  98. void wm_sdio_host_config(uint8_t numsel);
  99. /**
  100. * @brief config the pins used for sdio slave ck dat0 dat1 dat2 dat3
  101. * @param numsel: config sdio ck cmd dat0 dat1 dat2 dat3 pins multiplex relation,valid para 0
  102. * 0:
  103. * sdio_ck PB06
  104. * sdio_cmd PB07
  105. * sdio_dat0 PB08
  106. * sdio_dat1 PB09
  107. * sdio_dat2 PB10
  108. * sdio_dat3 PB11
  109. *
  110. * @return None
  111. */
  112. void wm_sdio_slave_config(uint8_t numsel);
  113. /**
  114. * @brief config the pins used for psram ck cs dat0 dat1 dat2 dat3
  115. * @param numsel: config psram ck cs dat0 dat1 dat2 dat3 pins multiplex relation,valid para 0,1
  116. * 0: 1: only for 56pin
  117. * psram_ck PB00 psram_ck PA15
  118. * psram_cs PB01 psram_cs PB27
  119. * psram_dat0 PB02 psram_dat0 PB02
  120. * psram_dat1 PB03 psram_dat1 PB03
  121. * psram_dat2 PB04 psram_dat2 PB04
  122. * psram_dat3 PB05 psram_dat3 PB05
  123. * @return None
  124. */
  125. void wm_psram_config(uint8_t numsel);
  126. /**
  127. * @brief config the pins used for uart0 tx
  128. * @param io_name: config uart0 tx pins name
  129. * WM_IO_PB_19
  130. * WM_IO_PB_27 only for 56pin
  131. *
  132. * @return None
  133. */
  134. void wm_uart0_tx_config(enum tls_io_name io_name);
  135. /**
  136. * @brief config the pins used for uart0 rx
  137. * @param io_name: config uart0 rx pins name
  138. * WM_IO_PB_20
  139. *
  140. * @return None
  141. */
  142. void wm_uart0_rx_config(enum tls_io_name io_name);
  143. /**
  144. * @brief config the pins used for uart1 tx
  145. * @param io_name: config uart1 tx pins name
  146. * WM_IO_PB_06
  147. *
  148. * @return None
  149. */
  150. void wm_uart1_tx_config(enum tls_io_name io_name);
  151. /**
  152. * @brief config the pins used for uart1 rx
  153. * @param io_name: config uart1 rx pins name
  154. * WM_IO_PB_07
  155. * WM_IO_PB_16 only for 56pin
  156. *
  157. * @return None
  158. */
  159. void wm_uart1_rx_config(enum tls_io_name io_name);
  160. /**
  161. * @brief config the pins used for uart1 rts
  162. * @param io_name: config uart1 rts pins name
  163. * WM_IO_PB_19
  164. * WM_IO_PA_02 only for 56pin
  165. *
  166. * @return None
  167. */
  168. void wm_uart1_rts_config(enum tls_io_name io_name);
  169. /**
  170. * @brief config the pins used for uart1 cts
  171. * @param io_name: config uart1 cts pins name
  172. * WM_IO_PB_20
  173. * WM_IO_PA_03 only for 56pin
  174. *
  175. * @return None
  176. */
  177. void wm_uart1_cts_config(enum tls_io_name io_name);
  178. /**
  179. * @brief config the pins used for uart2 tx or 7816-io
  180. * @param io_name: config uart2 tx or 7816-io pins name
  181. * WM_IO_PB_02
  182. * WM_IO_PA_02 only for 56pin
  183. *
  184. * @return None
  185. */
  186. void wm_uart2_tx_scio_config(enum tls_io_name io_name);
  187. /**
  188. * @brief config the pins used for uart2 rx
  189. * @param io_name: config uart2 rx pins name
  190. * WM_IO_PB_03
  191. * WM_IO_PA_03 only for 56pin
  192. *
  193. * @return None
  194. */
  195. void wm_uart2_rx_config(enum tls_io_name io_name);
  196. /**
  197. * @brief config the pins used for uart2 rts or 7816-clk
  198. * @param io_name: config uart2 rts or 7816-clk pins name
  199. * WM_IO_PB_04
  200. * WM_IO_PA_05 only for 56pin
  201. *
  202. * @return None
  203. */
  204. void wm_uart2_rts_scclk_config(enum tls_io_name io_name);
  205. /**
  206. * @brief config the pins used for uart2 cts
  207. * @param io_name: config uart2 cts pins name
  208. * WM_IO_PB_05
  209. * WM_IO_PA_06 only for 56pin
  210. *
  211. * @return None
  212. */
  213. void wm_uart2_cts_config(enum tls_io_name io_name);
  214. /**
  215. * @brief config the pins used for uart3 tx
  216. * @param io_name: config uart1 tx pins name
  217. * WM_IO_PB_00
  218. * WM_IO_PA_05 only for 56pin
  219. *
  220. * @return None
  221. */
  222. void wm_uart3_tx_config(enum tls_io_name io_name);
  223. /**
  224. * @brief config the pins used for uart3 rx
  225. * @param io_name: config uart1 rx pins name
  226. * WM_IO_PB_01
  227. * WM_IO_PA_06 only for 56pin
  228. *
  229. * @return None
  230. */
  231. void wm_uart3_rx_config(enum tls_io_name io_name);
  232. /**
  233. * @brief config the pins used for uart3 rts
  234. * @param io_name: config uart3 rts pins name
  235. * WM_IO_PA_02
  236. *
  237. * @return None
  238. */
  239. void wm_uart3_rts_config(enum tls_io_name io_name);
  240. /**
  241. * @brief config the pins used for uart3 cts
  242. * @param io_name: config uart3 cts pins name
  243. * WM_IO_PA_03
  244. *
  245. * @return None
  246. */
  247. void wm_uart3_cts_config(enum tls_io_name io_name);
  248. /**
  249. * @brief config the pins used for uart4 tx
  250. * @param io_name: config uart1 tx pins name
  251. * WM_IO_PB_04
  252. * WM_IO_PA_08 only for 56pin
  253. *
  254. * @return None
  255. */
  256. void wm_uart4_tx_config(enum tls_io_name io_name);
  257. /**
  258. * @brief config the pins used for uart4 rx
  259. * @param io_name: config uart1 rx pins name
  260. * WM_IO_PB_05
  261. * WM_IO_PA_09 only for 56pin
  262. *
  263. * @return None
  264. */
  265. void wm_uart4_rx_config(enum tls_io_name io_name);
  266. /**
  267. * @brief config the pins used for uart4 rts
  268. * @param io_name: config uart4 rts pins name
  269. * WM_IO_PA_05 only for 56pin
  270. * WM_IO_PA_10 only for 56pin
  271. *
  272. * @return None
  273. */
  274. void wm_uart4_rts_config(enum tls_io_name io_name);
  275. /**
  276. * @brief config the pins used for uart4 cts
  277. * @param io_name: config uart4 cts pins name
  278. * WM_IO_PA_06 only for 56pin
  279. * WM_IO_PA_11 only for 56pin
  280. *
  281. * @return None
  282. */
  283. void wm_uart4_cts_config(enum tls_io_name io_name);
  284. /**
  285. * @brief config the pins used for uart4 tx
  286. * @param io_name: config uart1 tx pins name
  287. * WM_IO_PA_08 only for 56pin
  288. * WM_IO_PA_12 only for 56pin
  289. * WM_IO_PB_18 only for 56pin
  290. *
  291. * @return None
  292. */
  293. void wm_uart5_tx_config(enum tls_io_name io_name);
  294. /**
  295. * @brief config the pins used for uart4 rx
  296. * @param io_name: config uart1 rx pins name
  297. * WM_IO_PA_09 only for 56pin
  298. * WM_IO_PA_13 only for 56pin
  299. * WM_IO_PB_17 only for 56pin
  300. *
  301. * @return None
  302. */
  303. void wm_uart5_rx_config(enum tls_io_name io_name);
  304. /**
  305. * @brief config the pins used for uart4 rts
  306. * @param io_name: config uart4 rts pins name
  307. * WM_IO_PA_14 only for 56pin
  308. * WM_IO_PB_12 only for 56pin
  309. *
  310. * @return None
  311. */
  312. void wm_uart5_rts_config(enum tls_io_name io_name);
  313. /**
  314. * @brief config the pins used for uart4 cts
  315. * @param io_name: config uart4 cts pins name
  316. * WM_IO_PA_15 only for 56pin
  317. * WM_IO_PB_13 only for 56pin
  318. *
  319. * @return None
  320. */
  321. void wm_uart5_cts_config(enum tls_io_name io_name);
  322. /**
  323. * @brief config the pins used for i2s ck
  324. * @param io_name: config i2s master ck pins name
  325. * WM_IO_PA_04
  326. * WM_IO_PB_08
  327. * WM_IO_PA_08 only for 56pin
  328. * WM_IO_PB_12 only for 56pin
  329. *
  330. * @return None
  331. */
  332. void wm_i2s_ck_config(enum tls_io_name io_name);
  333. /**
  334. * @brief config the pins used for i2s ws
  335. * @param io_name: config i2s master ws pins name
  336. * WM_IO_PA_01
  337. * WM_IO_PB_09
  338. * WM_IO_PA_09 only for 56pin
  339. * WM_IO_PB_13 only for 56pin
  340. *
  341. * @return None
  342. */
  343. void wm_i2s_ws_config(enum tls_io_name io_name);
  344. /**
  345. * @brief config the pins used for i2s do
  346. * @param io_name: config i2s master do pins name
  347. * WM_IO_PA_00
  348. * WM_IO_PB_11
  349. * WM_IO_PA_10 only for 56pin
  350. * WM_IO_PB_14 only for 56pin
  351. *
  352. * @return None
  353. */
  354. void wm_i2s_do_config(enum tls_io_name io_name);
  355. /**
  356. * @brief config the pins used for i2s di
  357. * @param io_name: config i2s slave di pins name
  358. * WM_IO_PA_07
  359. * WM_IO_PB_10
  360. * WM_IO_PA_11 only for 56pin
  361. * WM_IO_PB_15 only for 56pin
  362. *
  363. * @return None
  364. */
  365. void wm_i2s_di_config(enum tls_io_name io_name);
  366. /**
  367. * @brief config the pins used for i2s mclk
  368. * @param io_name: config i2s mclk pins name
  369. * WM_IO_PA_00
  370. *
  371. * @return None
  372. */
  373. void wm_i2s_mclk_config(enum tls_io_name io_name);
  374. /**
  375. * @brief config the pins used for i2s extclk
  376. * @param io_name: config i2s extclk pins name
  377. * WM_IO_PA_07
  378. *
  379. * @return None
  380. */
  381. void wm_i2s_extclk_config(enum tls_io_name io_name);
  382. /**
  383. * @brief config the pins used for i2c scl
  384. * @param io_name: config i2c scl pins name
  385. * WM_IO_PA_01
  386. * WM_IO_PB_20
  387. *
  388. * @return None
  389. */
  390. void wm_i2c_scl_config(enum tls_io_name io_name);
  391. /**
  392. * @brief config the pins used for i2c sda
  393. * @param io_name: config i2c sda pins name
  394. * WM_IO_PA_04
  395. * WM_IO_PB_19
  396. *
  397. * @return None
  398. */
  399. void wm_i2c_sda_config(enum tls_io_name io_name);
  400. /**
  401. * @brief config the pins used for pwm0
  402. * @param io_name: config pwm1 pins name
  403. * WM_IO_PB_00
  404. * WM_IO_PB_19
  405. * WM_IO_PA_02 only for 56pin
  406. * WM_IO_PA_10 only for 56pin
  407. * WM_IO_PB_12 only for 56pin
  408. *
  409. * @return None
  410. */
  411. void wm_pwm0_config(enum tls_io_name io_name);
  412. /**
  413. * @brief config the pins used for pwm1
  414. * @param io_name: config pwm1 pins name
  415. * WM_IO_PB_01
  416. * WM_IO_PB_20
  417. * WM_IO_PA_03 only for 56pin
  418. * WM_IO_PA_11 only for 56pin
  419. * WM_IO_PB_13 only for 56pin
  420. *
  421. * @return None
  422. */
  423. void wm_pwm1_config(enum tls_io_name io_name);
  424. /**
  425. * @brief config the pins used for pwm2
  426. * @param io_name: config pwm3 pins name
  427. * WM_IO_PA_00
  428. * WM_IO_PB_02
  429. * WM_IO_PA_12 only for 56pin
  430. * WM_IO_PB_14 only for 56pin
  431. * WM_IO_PB_24 only for 56pin
  432. *
  433. * @return None
  434. */
  435. void wm_pwm2_config(enum tls_io_name io_name);
  436. /**
  437. * @brief config the pins used for pwm3
  438. * @param io_name: config pwm4 pins name
  439. * WM_IO_PA_01
  440. * WM_IO_PB_03
  441. * WM_IO_PA_13 only for 56pin
  442. * WM_IO_PB_15 only for 56pin
  443. * WM_IO_PB_25 only for 56pin
  444. *
  445. * @return None
  446. */
  447. void wm_pwm3_config(enum tls_io_name io_name);
  448. /**
  449. * @brief config the pins used for pwm4
  450. * @param io_name: config pwm5 pins name
  451. * WM_IO_PA_04
  452. * WM_IO_PA_07
  453. * WM_IO_PA_14 only for 56pin
  454. * WM_IO_PB_16 only for 56pin
  455. * WM_IO_PB_26 only for 56pin
  456. *
  457. * @return None
  458. */
  459. void wm_pwm4_config(enum tls_io_name io_name);
  460. /**
  461. * @brief config the pins used for pwm break
  462. * @param io_name: config pwm break pins name
  463. * WM_IO_PB_08
  464. * WM_IO_PA_05 only for 56pin
  465. * WM_IO_PA_08 only for 56pin
  466. * WM_IO_PA_15 only for 56pin
  467. * WM_IO_PB_17 only for 56pin
  468. *
  469. * @return None
  470. */
  471. void wm_pwmbrk_config(enum tls_io_name io_name);
  472. /**
  473. * @brief config the pins used for swd
  474. * @param enable: enable or disable chip swd function
  475. * 1: enable
  476. * 0: disable
  477. *
  478. * @return None
  479. */
  480. void wm_swd_config(bool enable);
  481. /**
  482. * @brief config the pins used for adc
  483. * @param Channel: the channel that shall be used
  484. * 0~1: single-ended input
  485. * 2~3: single-ended input only for 56pin
  486. * 0 and 1 can be used differential input
  487. * 2 and 3 can be used differential input only for 56pin
  488. *
  489. * @return None
  490. */
  491. void wm_adc_config(u8 Channel);
  492. /**
  493. * @brief config the pins used for touch sensor
  494. * @param io_name: config touch sensor pins name
  495. * WM_IO_PA_07
  496. * WM_IO_PB_00
  497. * WM_IO_PB_01
  498. * WM_IO_PB_02
  499. * WM_IO_PB_03
  500. * WM_IO_PB_04
  501. * WM_IO_PB_05
  502. * WM_IO_PB_06
  503. * WM_IO_PB_07
  504. * WM_IO_PB_08
  505. * WM_IO_PB_09
  506. * WM_IO_PA_09 only for 56pin
  507. * WM_IO_PA_10 only for 56pin
  508. * WM_IO_PA_12 only for 56pin
  509. * WM_IO_PA_14 only for 56pin
  510. *
  511. * @return None
  512. * @note If user use touch sensor function, firstly consider using WM_IO_PA_07 as TOUCH SENSOR pin.
  513. */
  514. void wm_touch_sensor_config(enum tls_io_name io_name);
  515. /**
  516. * @brief disable all the gpio af
  517. *
  518. * @return None
  519. *
  520. * @note This function must call before any others for configure
  521. * gpio Alternate functions
  522. */
  523. void wm_gpio_af_disable(void);
  524. /**
  525. * @}
  526. */
  527. /**
  528. * @}
  529. */
  530. #endif /* end of WM_GPIO_AFSEL_H */