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