|
| 1 | +import os |
| 2 | +import sys |
| 3 | +import subprocess |
| 4 | + |
| 5 | +from nmigen.build import * |
| 6 | +from nmigen.vendor.quicklogic import * |
| 7 | +from nmigen_boards.resources import * |
| 8 | + |
| 9 | + |
| 10 | +__all__ = ["QuickfeatherPlatform"] |
| 11 | + |
| 12 | + |
| 13 | +class QuickfeatherPlatform(QuicklogicPlatform): |
| 14 | + device = "ql-eos-s3_wlcsp" |
| 15 | + package = "PU64" |
| 16 | + default_clk = "sys_clk0" |
| 17 | + # It is possible to configure both oscillator frequency and |
| 18 | + # clock divider. Resulting frequency is: 60MHz / 12 = 5MHz |
| 19 | + osc_freq = int(60e6) |
| 20 | + osc_div = 12 |
| 21 | + connectors = [ |
| 22 | + Connector("J", 2, "- 28 22 21 37 36 42 40 7 2 4 5"), |
| 23 | + Connector("J", 3, "- 8 9 17 16 20 6 55 31 25 47 - - - - 41"), |
| 24 | + Connector("J", 8, "27 26 33 32 23 57 56 3 64 62 63 61 59 - - -"), |
| 25 | + ] |
| 26 | + resources = [ |
| 27 | + *ButtonResources(pins="62"), |
| 28 | + |
| 29 | + RGBLEDResource(0, r="34", g="39", b="38"), |
| 30 | + |
| 31 | + UARTResource(0, |
| 32 | + rx="9", tx="8", |
| 33 | + ), |
| 34 | + |
| 35 | + SPIResource(0, |
| 36 | + cs="11", clk="20", copi="16", cipo="17" |
| 37 | + ), |
| 38 | + SPIResource(1, |
| 39 | + cs="37", clk="40", copi="36", cipo="42", |
| 40 | + role="peripheral" |
| 41 | + ), |
| 42 | + |
| 43 | + I2CResource(0, |
| 44 | + scl="4", sda="5" |
| 45 | + ), |
| 46 | + I2CResource(1, |
| 47 | + scl="22", sda="21" |
| 48 | + ), |
| 49 | + |
| 50 | + DirectUSBResource(0, d_p="10", d_n="14"), |
| 51 | + |
| 52 | + Resource("swd", 0, |
| 53 | + Subsignal("clk", Pins("54", dir="io")), |
| 54 | + Subsignal("io", Pins("53", dir="io")), |
| 55 | + ), |
| 56 | + ] |
| 57 | + |
| 58 | + # This programmer requires OpenOCD with support for eos-s3: |
| 59 | + # https://github.com/antmicro/openocd/tree/eos-s3-support |
| 60 | + def toolchain_program(self, products, name): |
| 61 | + openocd = os.environ.get("OPENOCD", "openocd") |
| 62 | + with products.extract("{}.openocd".format(name), |
| 63 | + "{}_iomux.openocd".format(name)) as \ |
| 64 | + (bitstream_openocd_filename, iomux_openocd_filename): |
| 65 | + subprocess.check_call([ |
| 66 | + openocd, |
| 67 | + "-s", "tcl", |
| 68 | + "-f", "interface/ftdi/antmicro-ftdi-adapter.cfg", |
| 69 | + "-f", "interface/ftdi/swd-resistor-hack.cfg", |
| 70 | + "-f", "board/quicklogic_quickfeather.cfg", |
| 71 | + "-f", bitstream_openocd_filename, |
| 72 | + "-c", "init", |
| 73 | + "-c", "reset halt", |
| 74 | + "-c", "load_bitstream", |
| 75 | + "-f", iomux_openocd_filename, |
| 76 | + "-c", "exit" |
| 77 | + ]) |
| 78 | + |
| 79 | + |
| 80 | +if __name__ == "__main__": |
| 81 | + from .test.blinky import * |
| 82 | + QuickfeatherPlatform().build(Blinky()) |
0 commit comments