circuitpython/ports/atmel-samd/tools/mkcandata.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
898 B
Python
Raw Normal View History

#!/usr/bin/python3
2021-03-15 09:57:36 -04:00
def defines(name, suffix):
2021-03-15 09:57:36 -04:00
print(f"mcu_pin_function_t {name} [] = {{")
for instance in (0, 1):
2021-03-15 09:57:36 -04:00
for function in "HI":
for port in "ABCD":
for idx in range(32):
2021-03-15 09:57:36 -04:00
pin = f"P{port}{idx:02d}"
pinmux = f"PINMUX_{pin}{function}_CAN{instance}_{suffix}"
print(
f"""\
#if defined({pinmux}) && ! defined(IGNORE_PIN_{pin})
{{&pin_{pin}, {instance}, PIN_{pin}, {pinmux} & 0xffff}},
2021-03-15 09:57:36 -04:00
#endif"""
)
print(f"{{NULL, 0, 0}}")
print(f"}};")
print()
2021-03-15 09:57:36 -04:00
print(
"""\
#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"
2021-03-15 09:57:36 -04:00
"""
)
2021-03-15 09:57:36 -04:00
defines("can_rx", "RX")
defines("can_tx", "TX")