Skip to content

Commit

Permalink
ports/psoc6: Completed integration of make_pins and pin refactor.
Browse files Browse the repository at this point in the history
Signed-off-by: NikhitaR-IFX <Nikhita.Rajasekhar@infineon.com>
  • Loading branch information
NikhitaR-IFX committed Oct 20, 2023
1 parent 554a66e commit 07ffa85
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
34 changes: 20 additions & 14 deletions ports/psoc6/boards/make-pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ def print(self):
self._pin_addr,
)
)"""
# print("")

def print_header(self, hdr_file):
n = self.cpu_pin_name()
hdr_file.write("extern const machine_pin_phy_obj_t pin_{:s}_obj;\n".format(n))
def print_header(self, num_pins, hdr_file):
hdr_file.write("#define MAX_IO_PINS {:d} \n".format(num_pins))

def qstr_list(self):
return [self._name]
Expand All @@ -74,24 +72,30 @@ def __init__(self):
self.board_pin_csv_path = ""
self.num_cpu_pins = 0

def update_num_cpu_pins(self):
for named_pin in self.cpu_pins:
pin = named_pin.pin()
if pin.is_board_pin():
pin.set_board_index(self.num_cpu_pins)
self.num_cpu_pins += 1

def get_num_cpu_pins(self):
return self.num_cpu_pins

def find_pin(self, cpu_pin_name):
for named_pin in self.cpu_pins:
pin = named_pin.pin()
if pin.cpu_pin_name() == cpu_pin_name:
return pin

def print_const_table(self):
# num_cpu_pins = 0
for named_pin in self.cpu_pins:
pin = named_pin.pin()
if pin.is_board_pin():
pin.set_board_index(self.num_cpu_pins)
self.num_cpu_pins += 1
print("")
print(prefix_content)
print("const uint8_t machine_pin_num_of_cpu_pins = {:d};".format(self.num_cpu_pins))
print("const uint8_t machine_pin_num_of_cpu_pins = {:d};".format(self.get_num_cpu_pins()))
print("")
print("machine_pin_phy_obj_t machine_pin_phy_obj[{:d}] = {{".format(self.num_cpu_pins))
print(
"machine_pin_phy_obj_t machine_pin_phy_obj[{:d}] = {{".format(self.get_num_cpu_pins())
)
for named_pin in self.cpu_pins:
pin = named_pin.pin()
if pin.is_board_pin():
Expand Down Expand Up @@ -154,10 +158,11 @@ def print(self):

def print_header(self, hdr_filename):
with open(hdr_filename, "wt") as hdr_file:
for named_pin in self.cpu_pins:
hdr_file.write("#define MAX_IO_PINS {:d} \n".format(self.get_num_cpu_pins()))
"""for named_pin in self.cpu_pins:
pin = named_pin.pin()
if pin.is_board_pin():
pin.print_header(hdr_file)
pin.print_header(self.num_cpu_pins ,hdr_file)"""

def print_qstr(self, qstr_filename):
with open(qstr_filename, "wt") as qstr_file:
Expand Down Expand Up @@ -223,6 +228,7 @@ def main():

if args.hdr_filename and args.qstr_filename:
pins.parse_board_file()
pins.update_num_cpu_pins()
pins.print_const_table()
pins.print()
pins.print_header(args.hdr_filename)
Expand Down
2 changes: 1 addition & 1 deletion ports/psoc6/modules/machine/machine_pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ typedef struct _machine_pin_io_obj_t {
} machine_pin_io_obj_t;


machine_pin_io_obj_t *pin_io[102] = {NULL};
machine_pin_io_obj_t *pin_io[MAX_IO_PINS] = {NULL};

static inline machine_pin_io_obj_t *pin_io_allocate(mp_obj_t pin_name) {
machine_pin_phy_obj_t *pin_phy = pin_phy_realloc(pin_name, PIN_PHY_FUNC_DIO);
Expand Down

0 comments on commit 07ffa85

Please sign in to comment.