forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ports/psoc6: Automatic generation of pins.csv and fixing codeformatting.
Signed-off-by: NikhitaR-IFX <Nikhita.Rajasekhar@infineon.com>
- Loading branch information
1 parent
9c4aef0
commit 07ea3cb
Showing
9 changed files
with
195 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
NC,NC | ||
P0_0,P0_0 | ||
P0_1,P0_1 | ||
P0_2,P0_2 | ||
P0_3,P0_3 | ||
P0_4,P0_4 | ||
P0_5,P0_5 | ||
P1_0,P1_0 | ||
P1_1,P1_1 | ||
P1_2,P1_2 | ||
P1_3,P1_3 | ||
P1_4,P1_4 | ||
P1_5,P1_5 | ||
P2_0,P2_0 | ||
P2_1,P2_1 | ||
P2_2,P2_2 | ||
P2_3,P2_3 | ||
P2_4,P2_4 | ||
P2_5,P2_5 | ||
P2_6,P2_6 | ||
P2_7,P2_7 | ||
P3_0,P3_0 | ||
P3_1,P3_1 | ||
P3_2,P3_2 | ||
P3_3,P3_3 | ||
P3_4,P3_4 | ||
P3_5,P3_5 | ||
P4_0,P4_0 | ||
P4_1,P4_1 | ||
P5_0,P5_0 | ||
P5_1,P5_1 | ||
P5_2,P5_2 | ||
P5_3,P5_3 | ||
P5_4,P5_4 | ||
P5_5,P5_5 | ||
P5_6,P5_6 | ||
P5_7,P5_7 | ||
P6_0,P6_0 | ||
P6_1,P6_1 | ||
P6_2,P6_2 | ||
P6_3,P6_3 | ||
P6_4,P6_4 | ||
P6_5,P6_5 | ||
P6_6,P6_6 | ||
P6_7,P6_7 | ||
P7_0,P7_0 | ||
P7_1,P7_1 | ||
P7_2,P7_2 | ||
P7_3,P7_3 | ||
P7_4,P7_4 | ||
P7_5,P7_5 | ||
P7_6,P7_6 | ||
P7_7,P7_7 | ||
P8_0,P8_0 | ||
P8_1,P8_1 | ||
P8_2,P8_2 | ||
P8_3,P8_3 | ||
P8_4,P8_4 | ||
P8_5,P8_5 | ||
P8_6,P8_6 | ||
P8_7,P8_7 | ||
P9_0,P9_0 | ||
P9_1,P9_1 | ||
P9_2,P9_2 | ||
P9_3,P9_3 | ||
P9_4,P9_4 | ||
P9_5,P9_5 | ||
P9_6,P9_6 | ||
P9_7,P9_7 | ||
P10_0,P10_0 | ||
P10_1,P10_1 | ||
P10_2,P10_2 | ||
P10_3,P10_3 | ||
P10_4,P10_4 | ||
P10_5,P10_5 | ||
P10_6,P10_6 | ||
P10_7,P10_7 | ||
P11_0,P11_0 | ||
P11_1,P11_1 | ||
P11_2,P11_2 | ||
P11_3,P11_3 | ||
P11_4,P11_4 | ||
P11_5,P11_5 | ||
P11_6,P11_6 | ||
P11_7,P11_7 | ||
P12_0,P12_0 | ||
P12_1,P12_1 | ||
P12_2,P12_2 | ||
P12_3,P12_3 | ||
P12_4,P12_4 | ||
P12_5,P12_5 | ||
P12_6,P12_6 | ||
P12_7,P12_7 | ||
P13_0,P13_0 | ||
P13_1,P13_1 | ||
P13_2,P13_2 | ||
P13_3,P13_3 | ||
P13_4,P13_4 | ||
P13_5,P13_5 | ||
P13_6,P13_6 | ||
P13_7,P13_7 | ||
USBDP,USBDP | ||
P14_0,P14_0 | ||
USBDM,USBDM | ||
P14_1,P14_1 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from __future__ import print_function | ||
|
||
import argparse | ||
import sys | ||
import csv | ||
import re | ||
import os | ||
|
||
|
||
class Pins(object): | ||
def generate_pins_csv(self, pin_package_filename, pins_csv_filename): | ||
# Read the header file | ||
with open(os.environ.get("MTB_PIN_PACKAGES_PATH") + pin_package_filename, "r") as file: | ||
content = file.read() | ||
|
||
# Find the starting and ending points of the enum declaration | ||
enum_start = content.find("typedef enum {") | ||
enum_end = content.find("}") | ||
|
||
if enum_start != -1 and enum_end != -1: | ||
enum_content = content[enum_start:enum_end] | ||
|
||
# Extract enum values using regex | ||
enum_values = re.findall(r"\b(\w+)\s*=", enum_content) | ||
|
||
# Write enum values to a CSV file | ||
with open( | ||
os.environ.get("PINS_CSV_PATH") + pins_csv_filename, "w", newline="" | ||
) as csv_file: | ||
csv_writer = csv.writer(csv_file) | ||
csv_writer.writerows([[value, value] for value in enum_values]) | ||
|
||
print("pins.csv generated successfully") | ||
else: | ||
print("Error: pins.csv generation failed") | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
prog="make-pins.py", | ||
usage="%(prog)s [options] [command]", | ||
description="Generate board specific pin file", | ||
) | ||
|
||
parser.add_argument( | ||
"-g", | ||
"--gen-pin-for", | ||
dest="pin_package_filename", | ||
help="Specifies the pin package file from mtb assets to generate pins.csv", | ||
) | ||
|
||
parser.add_argument( | ||
"-p", | ||
"--save-pins-csv-at", | ||
dest="pins_csv", | ||
help="Specifies name of generated pins csv file", | ||
default="pins.csv", | ||
) | ||
|
||
args = parser.parse_args(sys.argv[1:]) | ||
|
||
pins = Pins() | ||
|
||
if args.pin_package_filename and args.pins_csv: | ||
print("// Generating pins csv file with following parsed arguments") | ||
print("// - --gen-pin-for {:s}".format(args.pin_package_filename)) | ||
print("// - --save-pins-csv-at {:s}".format(args.pins_csv)) | ||
pins.generate_pins_csv(args.pin_package_filename, args.pins_csv) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.