Skip to content

Commit 4d568a5

Browse files
jimmodpgeorge
authored andcommitted
samd/boards/make-pins.py: Update to use tools/boardgen.py.
This replaces the previous make-pin-table.py with an implementation based on boardgen.py. - MICROPY_PY_MACHINE_PIN_BOARD_CPU macro is removed. This isn't optional on other ports, so no need for it to be optional on SAMD. - pin_af_table is removed, and lookups just search the cpu dict instead (this saves N*wordsize bytes of firmware size to have this extra table). - pins.csv is now BOARD,CPU to match other ports. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <[email protected]>
1 parent ff6c2ad commit 4d568a5

File tree

26 files changed

+715
-901
lines changed

26 files changed

+715
-901
lines changed

ports/samd/Makefile

+15-8
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/include
5656
INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/include/pio
5757
INC += -I$(TOP)/lib/tinyusb/src
5858

59-
MAKE_PIN_AF = boards/make-pin-table.py
60-
PIN_AF_TABLE_CSV = mcu/$(MCU_SERIES_LOWER)/pin-af-table.csv
59+
MAKE_PINS = boards/make-pins.py
6160
BOARD_PINS = $(BOARD_DIR)/pins.csv
62-
GEN_PIN_AF = pin_af_table.c
61+
PREFIX_FILE = boards/pins_prefix.c
62+
AF_FILE = mcu/$(MCU_SERIES_LOWER)/pin-af-table.csv
63+
GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c
64+
GEN_PINS_HDR = $(HEADER_BUILD)/pins.h
6365

6466
CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU) -fsingle-precision-constant -Wdouble-promotion
6567
CFLAGS += -DMCU_$(MCU_SERIES) -D__$(CMSIS_MCU)__
@@ -179,7 +181,7 @@ DRIVERS_SRC_C += \
179181
drivers/bus/softspi.c \
180182

181183
# List of sources for qstr extraction
182-
SRC_QSTR += $(SRC_C) $(SHARED_SRC_C) $(SRC_CXX)
184+
SRC_QSTR += $(SRC_C) $(SHARED_SRC_C) $(SRC_CXX) $(GEN_PINS_SRC)
183185

184186
OBJ += $(PY_O)
185187
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
@@ -190,6 +192,7 @@ OBJ += $(addprefix $(BUILD)/, $(ASF4_SRC_C:.c=.o))
190192
OBJ += $(addprefix $(BUILD)/, $(LIBM_SRC_C:.c=.o))
191193
OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o))
192194
OBJ += $(addprefix $(BUILD)/, $(TINYUSB_SRC_C:.c=.o))
195+
OBJ += $(GEN_PINS_SRC:.c=.o)
193196

194197
all: $(BUILD)/firmware.uf2
195198

@@ -203,10 +206,14 @@ $(BUILD)/firmware.bin: $(BUILD)/firmware.elf
203206
$(BUILD)/firmware.uf2: $(BUILD)/firmware.bin
204207
$(Q)$(PYTHON) $(UF2CONV) -b $(TEXT0) -c -o $@ $<
205208

206-
pin_af.c: $(BUILD)/$(GEN_PIN_AF) | $(HEADER_BUILD)
209+
# pin_af.c: $(BUILD)/$(GEN_PIN_AF) | $(HEADER_BUILD)
207210

208-
$(BUILD)/$(GEN_PIN_AF): $(PIN_AF_TABLE_CSV) $(BOARD_PINS) | $(HEADER_BUILD)
209-
$(ECHO) "Create $@"
210-
$(Q)$(PYTHON) $(MAKE_PIN_AF) --csv $(PIN_AF_TABLE_CSV) --board $(BOARD_PINS) --table $(BUILD)/$(GEN_PIN_AF) --mcu $(MCU_SERIES)
211+
# Use a pattern rule here so that make will only call make-pins.py once to make
212+
# both pins_$(BOARD).c and pins.h
213+
$(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h: $(BOARD_DIR)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
214+
$(ECHO) "GEN $@"
215+
$(Q)$(PYTHON) $(MAKE_PINS) --board-csv $(BOARD_PINS) --af-csv $(AF_FILE) --prefix $(PREFIX_FILE) \
216+
--output-source $(GEN_PINS_SRC) --output-header $(GEN_PINS_HDR) \
217+
--mcu $(MCU_SERIES)
211218

212219
include $(TOP)/py/mkrules.mk
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,38 @@
1-
# Pin rows contain Pin number and pin name.
2-
# Pin rows start with PIN_
3-
# If the pin name is omitted, the pin number is added as name.
4-
# Empty lines and lines starting with # are ignored
1+
LED_TX,PA27
2+
LED_RX,PB03
53

6-
PIN_PA27,LED_TX
7-
PIN_PB03,LED_RX
4+
D0,PA11
5+
D1,PA10
6+
FLASH_MOSI,PA08
7+
FLASH_MISO,PA14
8+
FLASH_SCK,PA09
9+
D5,PA15
10+
D6,PA20
11+
D7,PA21
12+
D8,PA06
13+
D9,PA07
14+
D10,PA18
15+
D11,PA16
16+
D12,PA19
17+
D13,PA17
18+
A0,PA02
19+
A1,PB08
20+
A2,PB09
21+
A3,PA04
22+
A4,PA05
23+
A5,PB02
24+
TX,PB22
25+
RX,PB23
26+
SCL,PA23
27+
SDA,PA22
28+
MOSI,PB10
29+
MISO,PA12
30+
SCK,PB11
31+
NEOPIXEL,PA06
32+
FLASH_CS,PA13
833

9-
PIN_PA11,D0
10-
PIN_PA10,D1
11-
PIN_PA08,FLASH_MOSI
12-
PIN_PA14,FLASH_MISO
13-
PIN_PA09,FLASH_SCK
14-
PIN_PA15,D5
15-
PIN_PA20,D6
16-
PIN_PA21,D7
17-
PIN_PA06,D8
18-
PIN_PA07,D9
19-
PIN_PA18,D10
20-
PIN_PA16,D11
21-
PIN_PA19,D12
22-
PIN_PA17,D13
23-
PIN_PA02,A0
24-
PIN_PB08,A1
25-
PIN_PB09,A2
26-
PIN_PA04,A3
27-
PIN_PA05,A4
28-
PIN_PB02,A5
29-
PIN_PB22,TX
30-
PIN_PB23,RX
31-
PIN_PA23,SCL
32-
PIN_PA22,SDA
33-
PIN_PB10,MOSI
34-
PIN_PA12,MISO
35-
PIN_PB11,SCK
36-
PIN_PA06,NEOPIXEL
37-
PIN_PA13,FLASH_CS
34+
USB_DM,PA24
35+
USB_DP,PA25
3836

39-
PIN_PA24,USB_DM
40-
PIN_PA25,USB_DP
41-
42-
PIN_PA30,SWCLK
43-
PIN_PA31,SWDIO
37+
SWCLK,PA30
38+
SWDIO,PA31
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
1-
# Pin rows contain Pin number and pin name.
2-
# Pin rows start with PIN_
3-
# If the pin name is omitted, the pin number is added as name.
4-
# Empty lines and lines not starting with PIN_ are ignored
1+
D0,PB17
2+
D1,PB16
3+
D4,PA14
4+
D5,PA16
5+
D6,PA18
6+
D8,PB03
7+
D9,PA19
8+
D10,PA20
9+
D11,PA21
10+
D12,PA22
11+
D13,PA23
12+
A0,PA02
13+
A1,PA05
14+
A2,PB08
15+
A3,PB09
16+
A4,PA04
17+
A5,PB06
18+
SCL,PA13
19+
SDA,PA12
20+
MOSI,PB23
21+
MISO,PB22
22+
SCK,PA17
23+
VDIV,PB01
24+
AREF,PA03
25+
NEOPIXEL,PB03
526

6-
PIN_PB17,D0
7-
PIN_PB16,D1
8-
PIN_PA14,D4
9-
PIN_PA16,D5
10-
PIN_PA18,D6
11-
PIN_PB03,D8
12-
PIN_PA19,D9
13-
PIN_PA20,D10
14-
PIN_PA21,D11
15-
PIN_PA22,D12
16-
PIN_PA23,D13
17-
PIN_PA02,A0
18-
PIN_PA05,A1
19-
PIN_PB08,A2
20-
PIN_PB09,A3
21-
PIN_PA04,A4
22-
PIN_PB06,A5
23-
PIN_PA13,SCL
24-
PIN_PA12,SDA
25-
PIN_PB23,MOSI
26-
PIN_PB22,MISO
27-
PIN_PA17,SCK
28-
PIN_PB01,VDIV
29-
PIN_PA03,AREF
30-
PIN_PB03,NEOPIXEL
27+
QSPI_CS,PB11
28+
QSPI_SCK,PB10
29+
QSPI_D0,PA08
30+
QSPI_D1,PA09
31+
QSPI_D2,PA10
32+
QSPI_D3,PA11
3133

32-
PIN_PB11,QSPI_CS
33-
PIN_PB10,QSPI_SCK
34-
PIN_PA08,QSPI_D0
35-
PIN_PA09,QSPI_D1
36-
PIN_PA10,QSPI_D2
37-
PIN_PA11,QSPI_D3
34+
USB_DM,PA24
35+
USB_DP,PA25
36+
USB_SOF,PA23
3837

39-
PIN_PA24,USB_DM
40-
PIN_PA25,USB_DP
41-
PIN_PA26,USB_SOF
42-
43-
PIN_PA30,SWCLK
44-
PIN_PA31,SWDIO
38+
SWCLK,PA30
39+
SWDIO,PA31
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,35 @@
1-
# Pin rows contain Pin number and pin name.
2-
# Pin rows start with PIN_
3-
# If the pin name is omitted, the pin number is added as name.
4-
# Empty lines and lines not starting with PIN_ are ignored
1+
D0,PA11
2+
D1,PA10
3+
D2,PA14
4+
D3,PA09
5+
D4,PA08
6+
D5,PA15
7+
D7,PA21
8+
D9,PA07
9+
D10,PA18
10+
D11,PA16
11+
D12,PA19
12+
D13,PA17
13+
A0,PA02
14+
A1,PB08
15+
A2,PB09
16+
A3,PA04
17+
A4,PA05
18+
A5,PB02
19+
SDA,PA22
20+
SCL,PA23
21+
MOSI,PB10
22+
MISO,PA12
23+
SCK,PB11
24+
DOTSTAR_CLK,PA00
25+
DOTSTAR_DATA,PA01
26+
FLASH_MOSI,PB22
27+
FLASH_MISO,PB03
28+
FLASH_SCK,PB23
29+
FLASH_CS,PA27
530

6-
PIN_PA11,D0
7-
PIN_PA10,D1
8-
PIN_PA14,D2
9-
PIN_PA09,D3
10-
PIN_PA08,D4
11-
PIN_PA15,D5
12-
PIN_PA21,D7
13-
PIN_PA07,D9
14-
PIN_PA18,D10
15-
PIN_PA16,D11
16-
PIN_PA19,D12
17-
PIN_PA17,D13
18-
PIN_PA02,A0
19-
PIN_PB08,A1
20-
PIN_PB09,A2
21-
PIN_PA04,A3
22-
PIN_PA05,A4
23-
PIN_PB02,A5
24-
PIN_PA22,SDA
25-
PIN_PA23,SCL
26-
PIN_PB10,MOSI
27-
PIN_PA12,MISO
28-
PIN_PB11,SCK
29-
PIN_PA00,DOTSTAR_CLK
30-
PIN_PA01,DOTSTAR_DATA
31-
PIN_PB22,FLASH_MOSI
32-
PIN_PB03,FLASH_MISO
33-
PIN_PB23,FLASH_SCK
34-
PIN_PA27,FLASH_CS
31+
USB_DM,PA24
32+
USB_DP,PA25
3533

36-
PIN_PA24,USB_DM
37-
PIN_PA25,USB_DP
38-
39-
PIN_PA30,SWCLK
40-
PIN_PA31,SWDIO
34+
SWCLK,PA30
35+
SWDIO,PA31
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
1-
# Pin rows contain Pin number and pin name.
2-
# Pin rows start with PIN_
3-
# If the pin name is omitted, the pin number is added as name.
4-
# Empty lines and lines not starting with PIN_ are ignored
1+
D0,PA16
2+
D1,PA17
3+
D2,PA07
4+
D3,PB22
5+
D4,PA14
6+
D5,PA15
7+
D7,PA18
8+
D9,PA19
9+
D10,PA20
10+
D11,PA21
11+
D12,PA23
12+
D13,PA22
13+
A0,PA02
14+
A1,PA05
15+
A2,PB08
16+
A3,PB09
17+
A4,PA04
18+
A5,PA06
19+
SDA,PA12
20+
SCL,PA13
21+
MOSI,PA00
22+
MISO,PB23
23+
SCK,PA01
24+
DOTSTAR_CLK,PB02
25+
DOTSTAR_DATA,PB03
526

6-
PIN_PA16,D0
7-
PIN_PA17,D1
8-
PIN_PA07,D2
9-
PIN_PB22,D3
10-
PIN_PA14,D4
11-
PIN_PA15,D5
12-
PIN_PA18,D7
13-
PIN_PA19,D9
14-
PIN_PA20,D10
15-
PIN_PA21,D11
16-
PIN_PA23,D12
17-
PIN_PA22,D13
18-
PIN_PA02,A0
19-
PIN_PA05,A1
20-
PIN_PB08,A2
21-
PIN_PB09,A3
22-
PIN_PA04,A4
23-
PIN_PA06,A5
24-
PIN_PA12,SDA
25-
PIN_PA13,SCL
26-
PIN_PA00,MOSI
27-
PIN_PB23,MISO
28-
PIN_PA01,SCK
29-
PIN_PB02,DOTSTAR_CLK
30-
PIN_PB03,DOTSTAR_DATA
27+
QSPI_CS,PB11
28+
QSPI_SCK,PB10
29+
QSPI_D0,PA08
30+
QSPI_D1,PA09
31+
QSPI_D2,PA10
32+
QSPI_D3,PA11
3133

32-
PIN_PB11,QSPI_CS
33-
PIN_PB10,QSPI_SCK
34-
PIN_PA08,QSPI_D0
35-
PIN_PA09,QSPI_D1
36-
PIN_PA10,QSPI_D2
37-
PIN_PA11,QSPI_D3
34+
USB_DM,PA24
35+
USB_DP,PA25
36+
USB_SOF,PA23
3837

39-
PIN_PA24,USB_DM
40-
PIN_PA25,USB_DP
41-
PIN_PA26,USB_SOF
42-
43-
PIN_PA30,SWCLK
44-
PIN_PA31,SWDIO
38+
SWCLK,PA30
39+
SWDIO,PA31

0 commit comments

Comments
 (0)