Skip to content

Commit

Permalink
examples/pins.py: Remove this pins printing example.
Browse files Browse the repository at this point in the history
It's not supported on all ports, adds complexity to the build to generate
pins_af.py, and can mostly be replicated just by printing the pin objects.

Remove support for generating pins_af.py from all ports (nrf, stm32,
renesas-ra, mimxrt, rp2).

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <[email protected]>
  • Loading branch information
jimmo authored and dpgeorge committed Nov 3, 2023
1 parent cb37b7b commit 59f3c7f
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 133 deletions.
60 changes: 0 additions & 60 deletions examples/pins.py

This file was deleted.

1 change: 0 additions & 1 deletion ports/mimxrt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ BOARD_PINS = $(BOARD_DIR)/pins.csv
PREFIX_FILE = boards/mimxrt_prefix.c
GEN_FLEXRAM_CONFIG_SRC = $(BUILD)/flexram_config.s
GEN_PINS_AF_CONST = $(HEADER_BUILD)/pins_af_const.h
GEN_PINS_AF_PY = $(BUILD)/pins_af.py
GEN_PINS_HDR = $(HEADER_BUILD)/pins.h
GEN_PINS_SRC = $(BUILD)/pins_gen.c

Expand Down
3 changes: 1 addition & 2 deletions ports/nrf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ PREFIX_FILE = boards/$(MCU_VARIANT)_prefix.c
GEN_PINS_SRC = $(BUILD)/pins_gen.c
GEN_PINS_HDR = $(HEADER_BUILD)/pins.h
GEN_PINS_AF_CONST = $(HEADER_BUILD)/pins_af_const.h
GEN_PINS_AF_PY = $(BUILD)/pins_af.py

CFLAGS_CORTEX_M = -mthumb -mabi=aapcs -fsingle-precision-constant -Wdouble-promotion

Expand Down Expand Up @@ -544,7 +543,7 @@ $(OBJ): | $(HEADER_BUILD)/pins.h
# both pins_gen.c and pins.h
$(BUILD)/%_gen.c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_af_const.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
$(ECHO) "Create $@"
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --af-const $(GEN_PINS_AF_CONST) --af-py $(GEN_PINS_AF_PY) > $(GEN_PINS_SRC)
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --af-const $(GEN_PINS_AF_CONST) > $(GEN_PINS_SRC)

$(PY_BUILD)/nlr%.o: CFLAGS += -Os -fno-lto

Expand Down
18 changes: 0 additions & 18 deletions ports/nrf/boards/make-pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,17 +320,6 @@ def print_af_hdr(self, af_const_filename):
val = "MP_ROM_INT(GPIO_{})".format(mux_name)
print(" { %-*s %s }," % (mux_name_width + 26, key, val), file=af_const_file)

def print_af_py(self, af_py_filename):
with open(af_py_filename, "wt") as af_py_file:
print("PINS_AF = (", file=af_py_file)
for named_pin in self.board_pins:
print(" ('%s', " % named_pin.name(), end="", file=af_py_file)
for af in named_pin.pin().alt_fn:
if af.is_supported():
print("(%d, '%s'), " % (af.idx, af.af_str), end="", file=af_py_file)
print("),", file=af_py_file)
print(")", file=af_py_file)


def main():
parser = argparse.ArgumentParser(
Expand All @@ -351,12 +340,6 @@ def main():
help="Specifies header file for alternate function constants.",
default="build/pins_af_const.h",
)
parser.add_argument(
"--af-py",
dest="af_py_filename",
help="Specifies the filename for the python alternate function mappings.",
default="build/pins_af.py",
)
parser.add_argument(
"-b",
"--board",
Expand Down Expand Up @@ -401,7 +384,6 @@ def main():
pins.print()
pins.print_header(args.hdr_filename)
pins.print_af_hdr(args.af_const_filename)
pins.print_af_py(args.af_py_filename)


if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions ports/renesas-ra/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@ GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c
GEN_PINS_HDR = $(HEADER_BUILD)/pins.h
# Currently unused.
GEN_PINS_AD_CONST = $(HEADER_BUILD)/pins_ad_const.h
GEN_PINS_AF_PY = $(BUILD)/pins_af.py

FILE2H = $(TOP)/tools/file2h.py

Expand All @@ -581,7 +580,7 @@ $(HEADER_BUILD)/qstrdefs.generated.h: $(BOARD_DIR)/mpconfigboard.h
.PRECIOUS: $(GEN_PINS_SRC)
$(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_ad_const.h: $(BOARD_DIR)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) | $(HEADER_BUILD)
$(ECHO) "GEN $@"
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --ad-const $(GEN_PINS_AD_CONST) --af-py $(GEN_PINS_AF_PY) > $(GEN_PINS_SRC)
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --ad-const $(GEN_PINS_AD_CONST) > $(GEN_PINS_SRC)

CMSIS_MCU_HDR = $(CMSIS_DIR)/$(CMSIS_MCU_LOWER).h

Expand Down
6 changes: 0 additions & 6 deletions ports/renesas-ra/boards/make-pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,6 @@ def main():
help="Specifies header file for AD function constants.",
default="build/pins_ad_const.h",
)
parser.add_argument(
"--af-py",
dest="af_py_filename",
help="Specifies the filename for the python alternate function mappings.",
default="build/pins_af.py",
)
parser.add_argument(
"--af-defs",
dest="af_defs_filename",
Expand Down
3 changes: 1 addition & 2 deletions ports/rp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ set(GEN_PINS_MKPINS "${MICROPY_BOARDS_DIR}/make-pins.py")
set(GEN_PINS_SRC "${CMAKE_BINARY_DIR}/pins_${MICROPY_BOARD}.c")
set(GEN_PINS_HDR "${MICROPY_GENHDR_DIR}/pins.h")
set(GEN_PINS_AF_CONST "${MICROPY_GENHDR_DIR}/pins_af_const.h")
set(GEN_PINS_AF_PY "${CMAKE_BINARY_DIR}/pins_af.py")

if(EXISTS "${MICROPY_BOARDS_DIR}/${MICROPY_BOARD}/pins.csv")
set(GEN_PINS_BOARD_CSV "${MICROPY_BOARDS_DIR}/${MICROPY_BOARD}/pins.csv")
Expand All @@ -495,7 +494,7 @@ target_sources(${MICROPY_TARGET} PRIVATE
add_custom_command(
OUTPUT ${GEN_PINS_HDR} ${GEN_PINS_SRC}
COMMAND ${Python3_EXECUTABLE} ${GEN_PINS_MKPINS} ${GEN_PINS_CSV_ARG} --af ${GEN_PINS_AF_CSV} --prefix ${GEN_PINS_PREFIX}
--hdr ${GEN_PINS_HDR} --af-py ${GEN_PINS_AF_PY} > ${GEN_PINS_SRC}
--hdr ${GEN_PINS_HDR} > ${GEN_PINS_SRC}
DEPENDS
${GEN_PINS_AF_CSV}
${GEN_PINS_BOARD_CSV}
Expand Down
18 changes: 0 additions & 18 deletions ports/rp2/boards/make-pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,6 @@ def print_header(self, hdr_filename, obj_decls):
)
)

def print_af_py(self, af_py_filename):
with open(af_py_filename, "wt") as af_py_file:
print("PINS_AF = (", file=af_py_file)
for named_pin in self.board_pins:
print(" ('%s', " % named_pin.name(), end="", file=af_py_file)
for af in named_pin.pin().alt_fn:
if af.is_supported():
print("(%d, '%s'), " % (af.idx, af.af_str), end="", file=af_py_file)
print("),", file=af_py_file)
print(")", file=af_py_file)


def main():
parser = argparse.ArgumentParser(
Expand All @@ -309,12 +298,6 @@ def main():
help="Specifies the alternate function file for the chip",
default="rp2_af.csv",
)
parser.add_argument(
"--af-py",
dest="af_py_filename",
help="Specifies the filename for the python alternate function mappings.",
default="build/pins_af.py",
)
parser.add_argument(
"-b",
"--board",
Expand Down Expand Up @@ -356,7 +339,6 @@ def main():
print(prefix_file.read())
pins.print()
pins.print_header(args.hdr_filename, True)
pins.print_af_py(args.af_py_filename)


if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions ports/stm32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c
GEN_PINS_HDR = $(HEADER_BUILD)/pins.h
GEN_PINS_AF_CONST = $(HEADER_BUILD)/pins_af_const.h
GEN_PINS_AF_DEFS = $(HEADER_BUILD)/pins_af_defs.h
GEN_PINS_AF_PY = $(BUILD)/pins_af.py

INSERT_USB_IDS = $(TOP)/tools/insert-usb-ids.py
FILE2H = $(TOP)/tools/file2h.py
Expand Down Expand Up @@ -678,7 +677,7 @@ $(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h $(HEADER_BUILD)/%_af_const.h $(HEADER_
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) \
--prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) --hdr-obj-decls \
--af-const $(GEN_PINS_AF_CONST) --af-defs $(GEN_PINS_AF_DEFS) \
--af-defs-cmp-strings --af-py $(GEN_PINS_AF_PY) > $(GEN_PINS_SRC)
--af-defs-cmp-strings > $(GEN_PINS_SRC)

modmachine.c: $(GEN_PLLFREQTABLE_HDR)
$(GEN_PLLFREQTABLE_HDR): $(PLLVALUES) | $(HEADER_BUILD)
Expand Down
20 changes: 0 additions & 20 deletions ports/stm32/boards/make-pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,19 +503,6 @@ def print_af_defs(self, af_defs_filename, cmp_strings):
print("\n".join(sorted(pins)), file=af_defs_file)
print(" (0xffffffffffffffffULL))\n", file=af_defs_file)

def print_af_py(self, af_py_filename):
with open(af_py_filename, "wt") as af_py_file:
print("PINS_AF = (", file=af_py_file)
for named_pin in self.board_pins:
if named_pin.is_hidden():
continue
print(" ('%s', " % named_pin.name(), end="", file=af_py_file)
for af in named_pin.pin().alt_fn:
if af.is_supported():
print("(%d, '%s'), " % (af.idx, af.af_str), end="", file=af_py_file)
print("),", file=af_py_file)
print(")", file=af_py_file)


def main():
parser = argparse.ArgumentParser(
Expand All @@ -536,12 +523,6 @@ def main():
help="Specifies header file for alternate function constants.",
default="build/pins_af_const.h",
)
parser.add_argument(
"--af-py",
dest="af_py_filename",
help="Specifies the filename for the python alternate function mappings.",
default="build/pins_af.py",
)
parser.add_argument(
"--af-defs",
dest="af_defs_filename",
Expand Down Expand Up @@ -604,7 +585,6 @@ def main():
pins.print_adc(i)
pins.print_header(args.hdr_filename, args.hdr_obj_decls)
pins.print_af_hdr(args.af_const_filename)
pins.print_af_py(args.af_py_filename)
pins.print_af_defs(args.af_defs_filename, args.af_defs_cmp_strings)


Expand Down
3 changes: 1 addition & 2 deletions ports/stm32/mboot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c
GEN_PINS_HDR = $(HEADER_BUILD)/pins.h
GEN_PINS_AF_CONST = $(HEADER_BUILD)/pins_af_const.h
GEN_PINS_AF_DEFS = $(HEADER_BUILD)/pins_af_defs.h
GEN_PINS_AF_PY = $(BUILD)/pins_af.py

$(OBJ): $(GEN_QSTRDEFS_GENERATED) $(GEN_ROOT_POINTERS) $(GEN_PINS_AF_DEFS)

Expand All @@ -247,7 +246,7 @@ $(GEN_PINS_AF_DEFS): $(BOARD_PINS) $(MAKE_PINS) ../$(AF_FILE) $(PREFIX_FILE) | $
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af ../$(AF_FILE) \
--prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) \
--af-const $(GEN_PINS_AF_CONST) --af-defs $(GEN_PINS_AF_DEFS) \
--af-py $(GEN_PINS_AF_PY) > $(GEN_PINS_SRC)
> $(GEN_PINS_SRC)

#########################################

Expand Down

0 comments on commit 59f3c7f

Please sign in to comment.