1# GD32VF103XX pin definitions
2#
3# Sources:
4# - GD32VF103XX Datasheet (Revision 1.2)
5# - GD32VF103 User Manual (Revision 1.2)
6#
7# Pin codes:
8#
9# - 100 pins: V
10# - 64 pins:  R
11# - 48 pins:  C
12# - 36 pins:  T
13#
14# Memory codes:
15#
16# - 128Kb Flash, 32Kb SRAM: B
17# - 64Kb  Flash, 20Kb SRAM: 8
18# - 32Kb  Flash, 10Kb SRAM: 6
19# - 16Kb  Flash, 6Kb  SRAM: 4
20#
21# Copyright (c) 2021 Teslabs Engineering S.L.
22# SPDX-License-Identifier: Apache 2.0
23
24model: afio
25
26series: gd32vf103
27
28variants:
29  - pincode: V
30    memories: [B, 8]
31  - pincode: R
32    memories: [B, 8]
33  - pincode: R
34    memories: [6, 4]
35  - pincode: C
36    memories: [B, 8]
37  - pincode: C
38    memories: [6, 4]
39  - pincode: T
40    memories: [B, 8]
41  - pincode: T
42    memories: [6, 4]
43
44signal-configs:
45  ADC01_IN0:
46    modes: [analog]
47  ADC01_IN1:
48    modes: [analog]
49  ADC01_IN2:
50    modes: [analog]
51  ADC01_IN3:
52    modes: [analog]
53  ADC01_IN4:
54    modes: [analog]
55  ADC01_IN5:
56    modes: [analog]
57  ADC01_IN6:
58    modes: [analog]
59  ADC01_IN7:
60    modes: [analog]
61  ADC01_IN8:
62    modes: [analog]
63  ADC01_IN9:
64    modes: [analog]
65  ADC01_IN10:
66    modes: [analog]
67  ADC01_IN11:
68    modes: [analog]
69  ADC01_IN12:
70    modes: [analog]
71  ADC01_IN13:
72    modes: [analog]
73  ADC01_IN14:
74    modes: [analog]
75  ADC01_IN15:
76    modes: [analog]
77  CAN0_RX:
78    modes: [inp]
79  CAN0_TX:
80    modes: [out]
81  CAN1_RX:
82    modes: [inp]
83  CAN1_TX:
84    modes: [out]
85  CK_OUT0:
86    modes: [out]
87  DAC_OUT0:
88    modes: [analog]
89  DAC_OUT1:
90    modes: [analog]
91  EXMC_A16:
92    modes: [out]
93    exclude-pincodes: [R, C, T]
94  EXMC_A17:
95    modes: [out]
96    exclude-pincodes: [R, C, T]
97  EXMC_A18:
98    modes: [out]
99    exclude-pincodes: [R, C, T]
100  EXMC_A19:
101    modes: [out]
102    exclude-pincodes: [R, C, T]
103  EXMC_A20:
104    modes: [out]
105    exclude-pincodes: [R, C, T]
106  EXMC_A21:
107    modes: [out]
108    exclude-pincodes: [R, C, T]
109  EXMC_A22:
110    modes: [out]
111    exclude-pincodes: [R, C, T]
112  EXMC_A23:
113    modes: [out]
114    exclude-pincodes: [R, C, T]
115  EXMC_A24:
116    modes: [out]
117    exclude-pincodes: [R, C, T]
118  EXMC_A25:
119    modes: [out]
120    exclude-pincodes: [R, C, T]
121  EXMC_D0:
122    modes: [out]
123    exclude-pincodes: [R, C, T]
124  EXMC_D1:
125    modes: [out]
126    exclude-pincodes: [R, C, T]
127  EXMC_D2:
128    modes: [out]
129    exclude-pincodes: [R, C, T]
130  EXMC_D3:
131    modes: [out]
132    exclude-pincodes: [R, C, T]
133  EXMC_D4:
134    modes: [out]
135    exclude-pincodes: [R, C, T]
136  EXMC_D5:
137    modes: [out]
138    exclude-pincodes: [R, C, T]
139  EXMC_D6:
140    modes: [out]
141    exclude-pincodes: [R, C, T]
142  EXMC_D7:
143    modes: [out]
144    exclude-pincodes: [R, C, T]
145  EXMC_D8:
146    modes: [out]
147    exclude-pincodes: [R, C, T]
148  EXMC_D9:
149    modes: [out]
150    exclude-pincodes: [R, C, T]
151  EXMC_D10:
152    modes: [out]
153    exclude-pincodes: [R, C, T]
154  EXMC_D11:
155    modes: [out]
156    exclude-pincodes: [R, C, T]
157  EXMC_D12:
158    modes: [out]
159    exclude-pincodes: [R, C, T]
160  EXMC_D13:
161    modes: [out]
162    exclude-pincodes: [R, C, T]
163  EXMC_D14:
164    modes: [out]
165    exclude-pincodes: [R, C, T]
166  EXMC_D15:
167    modes: [out]
168    exclude-pincodes: [R, C, T]
169  EXMC_NADV:
170    modes: [out]
171    exclude-pincodes: [R, C, T]
172  EXMC_NBL0:
173    modes: [out]
174    exclude-pincodes: [R, C, T]
175  EXMC_NBL1:
176    modes: [out]
177    exclude-pincodes: [R, C, T]
178  EXMC_NE0:
179    modes: [out]
180    exclude-pincodes: [R, C, T]
181  EXMC_NOE:
182    modes: [out]
183    exclude-pincodes: [R, C, T]
184  EXMC_NWAIT:
185    modes: [inp]
186  EXMC_NWE:
187    modes: [out]
188    exclude-pincodes: [R, C, T]
189  I2C0_SCL:
190    modes: [out]
191  I2C0_SDA:
192    modes: [out]
193  I2C0_SMBA:
194    modes: [out]
195  I2C1_SCL:
196    modes: [out]
197    exclude-memories: [6, 4]
198  I2C1_SDA:
199    modes: [out]
200    exclude-memories: [6, 4]
201  I2C1_SMBA:
202    modes: [out]
203    exclude-memories: [6, 4]
204  I2S1_CK:
205    modes: [inp, out]
206  I2S1_MCK:
207    modes: [out]
208  I2S1_SD:
209    modes: [inp, out]
210  I2S1_WS:
211    modes: [inp, out]
212  I2S2_CK:
213    modes: [inp, out]
214    exclude-memories: [6, 4]
215  I2S2_MCK:
216    modes: [out]
217    exclude-memories: [6, 4]
218  I2S2_SD:
219    modes: [inp, out]
220    exclude-memories: [6, 4]
221  I2S2_WS:
222    modes: [inp, out]
223    exclude-memories: [6, 4]
224  SPI0_MISO:
225    modes: [inp, out]
226  SPI0_MOSI:
227    modes: [inp, out]
228  SPI0_NSS:
229    modes: [inp, out]
230  SPI0_SCK:
231    modes: [inp, out]
232  SPI1_MISO:
233    modes: [inp, out]
234  SPI1_MOSI:
235    modes: [inp, out]
236  SPI1_NSS:
237    modes: [inp, out]
238  SPI1_SCK:
239    modes: [inp, out]
240  SPI2_MISO:
241    modes: [inp, out]
242    exclude-memories: [6, 4]
243  SPI2_MOSI:
244    modes: [inp, out]
245    exclude-memories: [6, 4]
246  SPI2_NSS:
247    modes: [inp, out]
248    exclude-memories: [6, 4]
249  SPI2_SCK:
250    modes: [inp, out]
251    exclude-memories: [6, 4]
252  TAMPER:
253    modes: [inp]
254  TIMER0_BRKIN:
255    modes: [inp]
256  TIMER0_CH0:
257    modes: [inp, out]
258  TIMER0_CH0_ON:
259    modes: [out]
260  TIMER0_CH1:
261    modes: [inp, out]
262  TIMER0_CH1_ON:
263    modes: [out]
264  TIMER0_CH2:
265    modes: [inp, out]
266  TIMER0_CH2_ON:
267    modes: [out]
268  TIMER0_CH3:
269    modes: [inp, out]
270  TIMER0_ETI:
271    modes: [inp]
272  TIMER1_CH0:
273    modes: [inp, out]
274  TIMER1_CH0_ON:
275    modes: [out]
276  TIMER1_CH1:
277    modes: [inp, out]
278  TIMER1_CH1_ON:
279    modes: [out]
280  TIMER1_CH2:
281    modes: [inp, out]
282  TIMER1_CH2_ON:
283    modes: [out]
284  TIMER1_CH3:
285    modes: [inp, out]
286  TIMER2_CH0:
287    modes: [inp, out]
288  TIMER2_CH1:
289    modes: [inp, out]
290  TIMER2_CH2:
291    modes: [inp, out]
292  TIMER2_CH3:
293    modes: [inp, out]
294  TIMER2_ETI:
295    modes: [inp]
296  TIMER3_CH0:
297    modes: [inp, out]
298    exclude-memories: [6, 4]
299  TIMER3_CH1:
300    modes: [inp, out]
301    exclude-memories: [6, 4]
302  TIMER3_CH2:
303    modes: [inp, out]
304    exclude-memories: [6, 4]
305  TIMER3_CH3:
306    modes: [inp, out]
307    exclude-memories: [6, 4]
308  TIMER3_ETI:
309    modes: [inp]
310    exclude-memories: [6, 4]
311  TIMER4_CH0:
312    modes: [inp, out]
313    exclude-memories: [6, 4]
314  TIMER4_CH1:
315    modes: [inp, out]
316    exclude-memories: [6, 4]
317  TIMER4_CH2:
318    modes: [inp, out]
319    exclude-memories: [6, 4]
320  TIMER4_CH3:
321    modes: [inp, out]
322    exclude-memories: [6, 4]
323  USART0_CK:
324    modes: [out]
325  USART0_CTS:
326    modes: [inp]
327  USART0_RTS:
328    modes: [out]
329  USART0_RX:
330    modes: [inp]
331  USART0_TX:
332    modes: [out]
333  USART1_CK:
334    modes: [out]
335  USART1_CTS:
336    modes: [inp]
337  USART1_RTS:
338    modes: [out]
339  USART1_RX:
340    modes: [inp]
341  USART1_TX:
342    modes: [out]
343  USART2_CK:
344    modes: [out]
345    exclude-memories: [6, 4]
346  USART2_CTS:
347    modes: [inp]
348    exclude-memories: [6, 4]
349  USART2_RTS:
350    modes: [out]
351    exclude-memories: [6, 4]
352  USART2_RX:
353    modes: [inp]
354    exclude-memories: [6, 4]
355  USART2_TX:
356    modes: [out]
357    exclude-memories: [6, 4]
358  UART3_RX:
359    modes: [inp]
360    exclude-memories: [6, 4]
361  UART3_TX:
362    modes: [out]
363    exclude-memories: [6, 4]
364  UART4_RX:
365    modes: [inp]
366    exclude-memories: [6, 4]
367  UART4_TX:
368    modes: [out]
369    exclude-memories: [6, 4]
370  USBFS_DM:
371    modes: [inp, out]
372  USBFS_DP:
373    modes: [inp, out]
374  USBFS_ID:
375    modes: [inp, out]
376  USBFS_SOF:
377    modes: [out]
378  USBFS_VBUS:
379    modes: [inp]
380  WKUP:
381    modes: [inp]
382
383pins:
384  PA0:
385    pincodes: [V, R, C, T]
386    afs: [WKUP, USART1_CTS, ADC01_IN0, TIMER1_CH0_ETI,TIMER4_CH0]
387  PA1:
388    pincodes: [V, R, C, T]
389    afs: [USART1_RTS, ADC01_IN1, TIMER1_CH1, TIMER4_CH1]
390  PA2:
391    pincodes: [V, R, C, T]
392    afs: [USART1_TX, ADC01_IN2, TIMER1_CH2, TIMER4_CH2]
393  PA3:
394    pincodes: [V, R, C, T]
395    afs: [USART1_RX, ADC01_IN3, TIMER1_CH3, TIMER4_CH3]
396  PA4:
397    pincodes: [V, R, C, T]
398    afs: [SPI0_NSS, USART1_CK, ADC01_IN4, DAC_OUT0]
399  PA5:
400    pincodes: [V, R, C, T]
401    afs: [SPI0_SCK, ADC01_IN5, DAC_OUT1]
402  PA6:
403    pincodes: [V, R, C, T]
404    afs: [SPI0_MISO, ADC01_IN6, TIMER2_CH0]
405  PA7:
406    pincodes: [V, R, C, T]
407    afs: [SPI0_MOSI, ADC01_IN7, TIMER2_CH1]
408  PA8:
409    pincodes: [V, R, C, T]
410    afs: [USART0_CK, TIMER0_CH0, CK_OUT0, USBFS_SOF]
411  PA9:
412    pincodes: [V, R, C, T]
413    afs: [USART0_TX, TIMER0_CH1, USBFS_VBUS]
414  PA10:
415    pincodes: [V, R, C, T]
416    afs: [USART0_RX, TIMER0_CH2, USBFS_ID]
417  PA11:
418    pincodes: [V, R, C, T]
419    afs: [USART0_CTS, CAN0_RX, TIMER0_CH3, USBFS_DM, TIMER0_CH3]
420  PA12:
421    pincodes: [V, R, C, T]
422    afs: [USART0_RTS, CAN0_TX, TIMER0_ETI, USBFS_DP]
423  PA13:
424    pincodes: [V, R, C, T]
425    afs: []
426  PA14:
427    pincodes: [V, R, C, T]
428    afs: []
429  PA15:
430    pincodes: [V, R, C, T]
431    afs: [SPI2_NSS, I2S2_WS]
432  PB0:
433    pincodes: [V, R, C, T]
434    afs: [ADC01_IN8, TIMER2_CH2]
435  PB1:
436    pincodes: [V, R, C, T]
437    afs: [ADC01_IN9, TIMER2_CH3]
438  PB2:
439    pincodes: [V, R, C, T]
440    afs: []
441  PB3:
442    pincodes: [V, R, C, T]
443    afs: [SPI2_SCK, I2S2_CK]
444  PB4:
445    pincodes: [V, R, C, T]
446    afs: [SPI2_MISO]
447  PB5:
448    pincodes: [V, R, C, T]
449    afs: [I2C0_SMBA, SPI2_MOSI, I2S2_SD]
450  PB6:
451    pincodes: [V, R, C, T]
452    afs: [I2C0_SCL, TIMER3_CH0]
453  PB7:
454    pincodes: [V, R, C, T]
455    afs: [I2C0_SDA , TIMER3_CH1, EXMC_NADV]
456  PB8:
457    pincodes: [V, R, C]
458    afs: [TIMER3_CH2]
459  PB9:
460    pincodes: [V, R, C]
461    afs: [TIMER3_CH3]
462  PB10:
463    pincodes: [V, R, C]
464    afs: [I2C1_SCL, USART2_TX]
465  PB11:
466    pincodes: [V, R, C]
467    afs: [I2C1_SDA, USART2_RX]
468  PB12:
469    pincodes: [V, R, C]
470    afs: [SPI1_NSS, I2C1_SMBA, USART2_CK, TIMER0_BRKIN, I2S1_WS, CAN1_RX]
471  PB13:
472    pincodes: [V, R, C]
473    afs: [SPI1_SCK, USART2_CTS, TIMER0_CH0_ON, I2S1_CK, CAN1_TX]
474  PB14:
475    pincodes: [V, R, C]
476    afs: [SPI1_MISO, USART2_RTS, TIMER0_CH1_ON]
477  PB15:
478    pincodes: [V, R, C]
479    afs: [SPI1_MOSI, TIMER0_CH2_ON, I2S1_SD]
480  PC0:
481    pincodes: [V, R]
482    afs: [ADC01_IN10]
483  PC1:
484    pincodes: [V, R]
485    afs: [ADC01_IN11]
486  PC2:
487    pincodes: [V, R]
488    afs: [ADC01_IN12]
489  PC3:
490    pincodes: [V, R]
491    afs: [ADC01_IN13]
492  PC4:
493    pincodes: [V, R]
494    afs: [ADC01_IN14]
495  PC5:
496    pincodes: [V, R]
497    afs: [ADC01_IN15]
498  PC6:
499    pincodes: [V, R]
500    afs: [I2S1_MCK]
501  PC7:
502    pincodes: [V, R]
503    afs: [I2S2_MCK]
504  PC8:
505    pincodes: [V, R]
506    afs: []
507  PC9:
508    pincodes: [V, R]
509    afs: []
510  PC10:
511    pincodes: [V, R]
512    afs: [UART3_TX]
513  PC11:
514    pincodes: [V, R]
515    afs: [UART3_RX]
516  PC12:
517    pincodes: [V, R]
518    afs: [UART4_TX]
519  PC13:
520    pincodes: [V, R, C]
521    afs: [TAMPER]
522  PC14:
523    pincodes: [V, R, C]
524    afs: []
525  PC15:
526    pincodes: [V, R, C]
527    afs: []
528  PD0:
529    pincodes: [V, R, C, T]
530    afs: [EXMC_D2]
531  PD1:
532    pincodes: [V, R, C, T]
533    afs: [EXMC_D3]
534  PD2:
535    pincodes: [V, R]
536    afs: [TIMER2_ETI, UART4_RX]
537  PD3:
538    pincodes: [V]
539    afs: []
540  PD4:
541    pincodes: [V]
542    afs: [EXMC_NOE]
543  PD5:
544    pincodes: [V]
545    afs: [EXMC_NWE]
546  PD6:
547    pincodes: [V]
548    afs: [EXMC_NWAIT]
549  PD7:
550    pincodes: [V]
551    afs: [EXMC_NE0]
552  PD8:
553    pincodes: [V]
554    afs: [EXMC_D13]
555  PD9:
556    pincodes: [V]
557    afs: [EXMC_D14]
558  PD10:
559    pincodes: [V]
560    afs: [EXMC_D15]
561  PD11:
562    pincodes: [V]
563    afs: [EXMC_A16]
564  PD12:
565    pincodes: [V]
566    afs: [EXMC_A17]
567  PD13:
568    pincodes: [V]
569    afs: [EXMC_A18]
570  PD14:
571    pincodes: [V]
572    afs: [EXMC_D0]
573  PD15:
574    pincodes: [V]
575    afs: [EXMC_D1]
576  PE0:
577    pincodes: [V]
578    afs: [TIMER3_ETI, EXMC_NBL0]
579  PE1:
580    pincodes: [V]
581    afs: [EXMC_NBL1]
582  PE2:
583    pincodes: [V]
584    afs: [EXMC_A23]
585  PE3:
586    pincodes: [V]
587    afs: [EXMC_A19]
588  PE4:
589    pincodes: [V]
590    afs: [EXMC_A20]
591  PE5:
592    pincodes: [V]
593    afs: [EXMC_A21]
594  PE6:
595    pincodes: [V]
596    afs: [EXMC_A22]
597  PE7:
598    pincodes: [V]
599    afs: [EXMC_D4]
600  PE8:
601    pincodes: [V]
602    afs: [EXMC_D5]
603  PE9:
604    pincodes: [V]
605    afs: [EXMC_D6]
606  PE10:
607    pincodes: [V]
608    afs: [EXMC_D7]
609  PE11:
610    pincodes: [V]
611    afs: [EXMC_D8]
612  PE12:
613    pincodes: [V]
614    afs: [EXMC_D9]
615  PE13:
616    pincodes: [V]
617    afs: [EXMC_D10]
618  PE14:
619    pincodes: [V]
620    afs: [EXMC_D11]
621  PE15:
622    pincodes: [V]
623    afs: [EXMC_D12]
624
625remaps:
626  CAN0_RX:
627    pins: [PA11, null, PB8, PD0]
628  CAN0_TX:
629    pins: [PA12, null, PB9, PD1]
630  CAN1_RX:
631    pins: [PB12, PB5]
632  CAN1_TX:
633    pins: [PB13, PB6]
634  I2C0_SCL:
635    pins: [PB6, PB8]
636  I2C0_SDA:
637    pins: [PB7, PB9]
638  I2S2_SD:
639    pins: [PB5, PC12]
640  I2S2_WS:
641    pins: [PA15, PA4]
642  I2S2_CK:
643    pins: [PB3, PC10]
644  SPI0_MISO:
645    pins: [PA6, PB4]
646  SPI0_MOSI:
647    pins: [PA7, PB5]
648  SPI0_NSS:
649    pins: [PA4, PA15]
650  SPI0_SCK:
651    pins: [PA5, PB3]
652  SPI2_MISO:
653    pins: [PB4, PC11]
654  SPI2_MOSI:
655    pins: [PB5, PC12]
656  SPI2_NSS:
657    pins: [PA15, PA4]
658  SPI2_SCK:
659    pins: [PB3, PC10]
660  TIMER0_BKIN:
661    pins: [PB12, PA6, null, PE15]
662  TIMER0_CH0:
663    pins: [PA8, PA8, null, PE9]
664  TIMER0_CH1:
665    pins: [PA9, PA9, null, PE11]
666  TIMER0_CH2:
667    pins: [PA10, PA10, null, PE13]
668  TIMER0_CH3:
669    pins: [PA11, PA11, null, PE14]
670  TIMER0_CH0_ON:
671    pins: [PB13, PA7, null, PE8]
672  TIMER0_CH1_ON:
673    pins: [PB14, PB0, null, PE10]
674  TIMER0_CH2_ON:
675    pins: [PB15, PB1, null, PE12]
676  TIMER0_ETI:
677    pins: [PA12, PA12, null, PE7]
678  TIMER1_CH0:
679    pins: [PA0, PA15, PA0, PA15]
680  TIMER1_CH1:
681    pins: [PA1, PB3, PA1, PB3]
682  TIMER1_CH2:
683    pins: [PA2, PA2, PB10, PB10]
684  TIMER1_CH3:
685    pins: [PA3, PA3, PB11, PB11]
686  TIMER1_ETI:
687    pins: [PA0, PA15, PA0, PA15]
688  TIMER2_CH0:
689    pins: [PA6, null, PB4, PC6]
690  TIMER2_CH1:
691    pins: [PA7, null, PB5, PC7]
692  TIMER2_CH2:
693    pins: [PB0, null, PB0, PC8]
694  TIMER2_CH3:
695    pins: [PB1, null, PB1, PC9]
696  TIMER3_CH0:
697    pins: [PB6, PD12]
698  TIMER3_CH1:
699    pins: [PB7, PD13]
700  TIMER3_CH2:
701    pins: [PB8, PD14]
702  TIMER3_CH3:
703    pins: [PB9, PD15]
704  USART0_RX:
705    pins: [PA10, PB7]
706  USART0_TX:
707    pins: [PA9, PB6]
708  USART1_CK:
709    pins: [PA4, PD7]
710  USART1_CTS:
711    pins: [PA0, PD3]
712  USART1_RTS:
713    pins: [PA1, PD4]
714  USART1_RX:
715    pins: [PA3, PD6]
716  USART1_TX:
717    pins: [PA2, PD5]
718  USART2_CK:
719    pins: [PB12, PC12, null, PD10]
720  USART2_CTS:
721    pins: [PB13, PB13, null, PD11]
722  USART2_RTS:
723    pins: [PB14, PB14, null, PD12]
724  USART2_RX:
725    pins: [PB11, PC11, null, PD9]
726  USART2_TX:
727    pins: [PB10, PC10, null, PD8]
728