105 Parse the devices.csv file at the given path, generate the definitions and
106 write them to the given path.
108 :param csv_path: Path to the devices.csv to parse
110 :param def_path: Path to the output file to write the definitions to
117 with open(csv_path)
as csv_file:
118 csv_reader = csv.reader(csv_file)
120 row = next(csv_reader)
121 if len(row) < MULTIPLIER_COLUMN:
124 if row[DEVICE_COLUMN] ==
"# Device Name":
125 assert row[CPU_COLUMN] ==
"CPU_TYPE",
"File format changed"
126 assert row[MULTIPLIER_COLUMN] ==
"MPY_TYPE",
"File format changed"
129 if row[0] ==
"Version:":
132 for row
in csv_reader:
133 if row[DEVICE_COLUMN].endswith(
"generic"):
135 assert row[CPU_COLUMN]
in CPUS,
"Unknown CPU type"
136 assert row[MULTIPLIER_COLUMN]
in MULTIPLIERS,
"Unknown multiplier type"
140 CPUS[row[CPU_COLUMN]],
141 MULTIPLIERS[row[MULTIPLIER_COLUMN]],
145 with open(def_path,
"w")
as def_file:
146 def_file.write(PREFIX.format(version))
148 for name, cpu, hwmult
in mcus:
149 def_file.write(f
'MSP430_MCU("{name}", "{cpu}", "{hwmult}")\n')
151 def_file.write(SUFFIX)