humpback: added SPI

This commit is contained in:
occheung 2020-08-08 01:14:36 +08:00
parent 04faa5da95
commit 37d960669a
1 changed files with 45 additions and 42 deletions

View File

@ -45,15 +45,6 @@ class HumpbackPlatform(LatticeICE40Platform):
# attrs=Attrs(IO_STANDARD="SB_LVCMOS", PULLUP=1)
# ),
# Define SPI interfaces
# TODO; Make it optional, define it in a block
# Note: Use "role=device" to make humpback a SPI slave
# The ~CS pin is a global pin, but not being configured global.
SPIResource(0,
cs="R2", clk="C8", mosi="N5", miso="T2",
attrs=Attrs(IO_STANDARD="SB_LVCMOS")
),
# Define I2C interface
# TODO: Make it optional, declare it in a block itself
# Use "role=device" to make humpback a I2C slave
@ -64,7 +55,6 @@ class HumpbackPlatform(LatticeICE40Platform):
]
# Using the dict approach in (o)migen
# Note: Numbering is required in nMigen, so some probably not very meaningful strings/integers are inserted
connectors = [
# EEM0 Connector
@ -129,7 +119,7 @@ class HumpbackPlatform(LatticeICE40Platform):
# STM32 Nucleo/ Arduino Connector
# TODO: Suspect SPI mismatch forever
Connector("stm32", "pins", {
Connector("stm32", 0, {
"PA0": "A2",
# "PA1": "P14", # PA1 -> PB2, but PB2 has a mapping on FPGA already
# "PA2": "B8", # PA2 -> PF6
@ -228,7 +218,7 @@ class HumpbackPlatform(LatticeICE40Platform):
}),
# Beaglebone Black Connector
Connector("bb", "pins", {
Connector("bb", 0, {
"CLKOUT": "R9",
"GPIO0_7": "R14",
@ -281,7 +271,7 @@ class HumpbackPlatform(LatticeICE40Platform):
}),
# ESP32 Connector
Connector("esp32", "pins", {
Connector("esp32", 0, {
"IO2": "D9",
"IO4": "D7",
"IO22": "C7",
@ -290,11 +280,12 @@ class HumpbackPlatform(LatticeICE40Platform):
}),
# OrangePI Zero Connector
Connector("orange_pi", "pins", {
Connector("orange_pi", 0, {
"PG06": "A15",
}),
]
# Half completed, second EEM resource to be added
eem_to_urukul = [
Resource("eem", 1,
Subsignal("sclk", DiffPairs("L6", "L3", dir="o", conn=("eem", 1))),
@ -308,6 +299,17 @@ class HumpbackPlatform(LatticeICE40Platform):
)
]
# SPI Connection
spi = [
Resource("spi", 0,
Subsignal("cs", PinsN("R2", dir="i", conn=("stm32", 0))),
Subsignal("mosi", Pins("N5", dir="i", conn=("stm32", 0))),
Subsignal("miso", Pins("T2", dir="oe", conn=("stm32", 0))),
Subsignal("sck", Pins("C8", dir="i", conn=("stn32", 0))),
Attrs(IO_STANDARD="SB_LVCMOS")
)
]
# tool chain setup, using default ICE40 HX8K evaluation code
def toolchain_program(self, products, name):
iceprog = os.environ.get("ICEPROG", "iceprog")
@ -318,5 +320,6 @@ if __name__ == "__main__":
from nmigen_boards.test.blinky import *
platform = HumpbackPlatform()
platform.add_resources(platform.eem_to_urukul)
platform.add_resources(platform.spi)
platform.build(Blinky(), do_program=False)