42 lines
969 B
Python
Raw Normal View History

2020-06-26 10:58:54 -05:00
#!/usr/bin/python3
2021-03-15 19:27:36 +05:30
2020-06-26 10:58:54 -05:00
def defines(name, function):
2021-03-15 19:27:36 +05:30
print(f"mcu_pin_function_t {name} [] = {{")
2020-06-26 10:58:54 -05:00
for instance in (0, 1):
2021-03-15 19:27:36 +05:30
for port in "ABCD":
2020-06-26 10:58:54 -05:00
for idx in range(32):
2021-03-15 19:27:36 +05:30
pin = f"P{port}{idx:02d}"
pinmux = f"PINMUX_{pin}I_SDHC{instance}_{function}"
print(
f"""\
2020-06-26 10:58:54 -05:00
#if defined({pinmux}) && ! defined(IGNORE_PIN_{pin})
{{&pin_{pin}, {instance}, PIN_{pin}, {pinmux} & 0xffff}},
2021-03-15 19:27:36 +05:30
#endif"""
)
print(f"{{NULL, 0, 0}}")
print(f"}};")
2020-06-26 10:58:54 -05:00
print()
2021-03-15 19:27:36 +05:30
print(
"""\
2020-06-26 10:58:54 -05:00
#include <stdint.h>
#include "py/obj.h"
#include "sam.h"
#include "samd/pins.h"
#include "mpconfigport.h"
#include "atmel_start_pins.h"
#include "hal/include/hal_gpio.h"
#include "common-hal/microcontroller/Pin.h"
2020-06-26 10:58:54 -05:00
2021-03-15 19:27:36 +05:30
"""
)
2020-06-26 10:58:54 -05:00
2021-03-15 19:27:36 +05:30
defines("sdio_ck", "SDCK")
defines("sdio_cmd", "SDCMD")
defines("sdio_dat0", "SDDAT0")
defines("sdio_dat1", "SDDAT1")
defines("sdio_dat2", "SDDAT2")
defines("sdio_dat3", "SDDAT3")