summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2023-08-03 15:02:41 +1000
committerDamien George <damien@micropython.org>2023-11-03 14:03:28 +1100
commit59f3c7facbb6100108750efa857f1550f23f2482 (patch)
treefac7e8d70fd08a258349761cb86381310c197201
parentcb37b7bba756115029d9b973c753eb4b81be5ab7 (diff)
examples/pins.py: Remove this pins printing example.
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 <jim.mussared@gmail.com>
-rw-r--r--examples/pins.py60
-rw-r--r--ports/mimxrt/Makefile1
-rw-r--r--ports/nrf/Makefile3
-rw-r--r--ports/nrf/boards/make-pins.py18
-rw-r--r--ports/renesas-ra/Makefile3
-rw-r--r--ports/renesas-ra/boards/make-pins.py6
-rw-r--r--ports/rp2/CMakeLists.txt3
-rwxr-xr-xports/rp2/boards/make-pins.py18
-rw-r--r--ports/stm32/Makefile3
-rwxr-xr-xports/stm32/boards/make-pins.py20
-rwxr-xr-xports/stm32/mboot/Makefile3
11 files changed, 5 insertions, 133 deletions
diff --git a/examples/pins.py b/examples/pins.py
deleted file mode 100644
index 3a8472e8a..000000000
--- a/examples/pins.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# Print a nice list of pins, their current settings, and available afs.
-# Requires pins_af.py from ports/stm32/build-PYBV10/ directory.
-
-import pyb
-import pins_af
-
-
-def af():
- max_name_width = 0
- max_af_width = 0
- for pin_entry in pins_af.PINS_AF:
- max_name_width = max(max_name_width, len(pin_entry[0]))
- for af_entry in pin_entry[1:]:
- max_af_width = max(max_af_width, len(af_entry[1]))
- for pin_entry in pins_af.PINS_AF:
- pin_name = pin_entry[0]
- print("%-*s " % (max_name_width, pin_name), end="")
- for af_entry in pin_entry[1:]:
- print("%2d: %-*s " % (af_entry[0], max_af_width, af_entry[1]), end="")
- print("")
-
-
-def pins():
- mode_str = {
- pyb.Pin.IN: "IN",
- pyb.Pin.OUT_PP: "OUT_PP",
- pyb.Pin.OUT_OD: "OUT_OD",
- pyb.Pin.AF_PP: "AF_PP",
- pyb.Pin.AF_OD: "AF_OD",
- pyb.Pin.ANALOG: "ANALOG",
- }
- pull_str = {pyb.Pin.PULL_NONE: "", pyb.Pin.PULL_UP: "PULL_UP", pyb.Pin.PULL_DOWN: "PULL_DOWN"}
- width = [0, 0, 0, 0]
- rows = []
- for pin_entry in pins_af.PINS_AF:
- row = []
- pin_name = pin_entry[0]
- pin = pyb.Pin(pin_name)
- pin_mode = pin.mode()
- row.append(pin_name)
- row.append(mode_str[pin_mode])
- row.append(pull_str[pin.pull()])
- if pin_mode == pyb.Pin.AF_PP or pin_mode == pyb.Pin.AF_OD:
- pin_af = pin.af()
- for af_entry in pin_entry[1:]:
- if pin_af == af_entry[0]:
- af_str = "%d: %s" % (pin_af, af_entry[1])
- break
- else:
- af_str = "%d" % pin_af
- else:
- af_str = ""
- row.append(af_str)
- for col in range(len(width)):
- width[col] = max(width[col], len(row[col]))
- rows.append(row)
- for row in rows:
- for col in range(len(width)):
- print("%-*s " % (width[col], row[col]), end="")
- print("")
diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile
index c22c5442a..51cf5178b 100644
--- a/ports/mimxrt/Makefile
+++ b/ports/mimxrt/Makefile
@@ -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
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index 7d7589cc2..cb81ad847 100644
--- a/ports/nrf/Makefile
+++ b/ports/nrf/Makefile
@@ -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
@@ -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
diff --git a/ports/nrf/boards/make-pins.py b/ports/nrf/boards/make-pins.py
index b535e2418..6bfb66251 100644
--- a/ports/nrf/boards/make-pins.py
+++ b/ports/nrf/boards/make-pins.py
@@ -320,17 +320,6 @@ class Pins(object):
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(
@@ -352,12 +341,6 @@ def main():
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",
dest="board_filename",
@@ -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__":
diff --git a/ports/renesas-ra/Makefile b/ports/renesas-ra/Makefile
index e77843b1e..8c09dc91b 100644
--- a/ports/renesas-ra/Makefile
+++ b/ports/renesas-ra/Makefile
@@ -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
@@ -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
diff --git a/ports/renesas-ra/boards/make-pins.py b/ports/renesas-ra/boards/make-pins.py
index 4127c9ff1..43267a1fa 100644
--- a/ports/renesas-ra/boards/make-pins.py
+++ b/ports/renesas-ra/boards/make-pins.py
@@ -241,12 +241,6 @@ def main():
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",
help="Specifies the filename for the alternate function defines.",
diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt
index 4a0d2fbad..f643b6679 100644
--- a/ports/rp2/CMakeLists.txt
+++ b/ports/rp2/CMakeLists.txt
@@ -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")
@@ -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}
diff --git a/ports/rp2/boards/make-pins.py b/ports/rp2/boards/make-pins.py
index 4029d7b1c..9c6624888 100755
--- a/ports/rp2/boards/make-pins.py
+++ b/ports/rp2/boards/make-pins.py
@@ -284,17 +284,6 @@ class Pins(object):
)
)
- 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(
@@ -310,12 +299,6 @@ def main():
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",
dest="board_filename",
@@ -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__":
diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile
index 3bb18ee3c..5b853592c 100644
--- a/ports/stm32/Makefile
+++ b/ports/stm32/Makefile
@@ -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
@@ -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)
diff --git a/ports/stm32/boards/make-pins.py b/ports/stm32/boards/make-pins.py
index f0fcb8243..99b507a3a 100755
--- a/ports/stm32/boards/make-pins.py
+++ b/ports/stm32/boards/make-pins.py
@@ -503,19 +503,6 @@ class Pins(object):
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(
@@ -537,12 +524,6 @@ def main():
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",
help="Specifies the filename for the alternate function defines.",
@@ -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)
diff --git a/ports/stm32/mboot/Makefile b/ports/stm32/mboot/Makefile
index a37b046ca..fab8ce215 100755
--- a/ports/stm32/mboot/Makefile
+++ b/ports/stm32/mboot/Makefile
@@ -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)
@@ -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)
#########################################