From c51cc46bf82d1f90e20f96798f27e6f496ec3266 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 16 Sep 2021 12:52:23 +1000 Subject: [PATCH] stm32/boards/make-pins.py: Allow empty lines and comments in pins.csv. Signed-off-by: Damien George --- ports/stm32/boards/make-pins.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ports/stm32/boards/make-pins.py b/ports/stm32/boards/make-pins.py index d3e2d0256f..c7423cb966 100755 --- a/ports/stm32/boards/make-pins.py +++ b/ports/stm32/boards/make-pins.py @@ -4,7 +4,8 @@ Generates pin source files based on an MCU alternate-function definition (eg stm32f405_af.csv) and a board-specific pin definition file, pins.csv. -The pins.csv file must contain lines of the form: +The pins.csv file can contain empty lines, comments (a line beginning with "#") +or pin definition lines. Pin definition lines must be of the form: board,cpu @@ -362,6 +363,12 @@ class Pins(object): with open(filename, "r") as csvfile: rows = csv.reader(csvfile) for row in rows: + if len(row) == 0 or row[0].startswith("#"): + # Skip empty lines, and lines starting with "#" + continue + if len(row) != 2: + raise ValueError("Expecting two entries in a row") + cpu_pin_name = row[1] cpu_pin_hidden = False if cpu_pin_name.startswith("-"):