2 from nmigen
.build
.dsl
import Resource
, Subsignal
, Pins
3 from nmigen
.build
.plat
import Platform
# Not sure where platform comes from?
5 # Was thinking of using these functions, but skipped for simplicity for now
6 #from pinfunctions import i2s, lpc, emmc, sdmmc, mspi, mquadspi, spi, quadspi, i2c, mi2c, jtag, uart, uartfull, rgbttl, ulpi, rgmii, flexbus1, flexbus2, sdram1, sdram2, sdram3, vss, vdd, sys, eint, pwm, gpio
8 # File for stage 1 pinmux tested proposed by Luke, https://bugs.libre-soc.org/show_bug.cgi?id=50#c10
11 # sigh this needs to come from pinmux.
14 gpios
.append("%d*" % i
)
15 return {'uart': ['tx+', 'rx-'],
17 'i2c': ['sda*', 'scl+']}
20 a function is needed which turns the results of dummy_pinset()
23 [UARTResource("uart", 0, tx=..., rx=..),
24 I2CResource("i2c", 0, scl=..., sda=...),
25 Resource("gpio", 0, Subsignal("i"...), Subsignal("o"...)
26 Resource("gpio", 1, Subsignal("i"...), Subsignal("o"...)
30 def create_resources(pinset
):
32 for periph
, pins
in pinset
.items():
35 #print("I2C required!")
36 resources
.append(I2CResource('i2c', 0, sda
='sda0', scl
='scl0'))
37 elif periph
== 'uart':
38 #print("UART required!")
39 resources
.append(UARTResource('uart', 0, tx
='tx0', rx
='rx0'))
40 elif periph
== 'gpio':
41 #print("GPIO required!")
42 resources
.append(Resource('gpio', 0, Subsignal("i", Pins('i0', dir="i", conn
=None, assert_width
=1)), Subsignal("o", Pins('o0', dir="o", conn
=None, assert_width
=1))))
45 def UARTResource(*args
, rx
, tx
, rts
=None, cts
=None, dtr
=None, dsr
=None, dcd
=None, ri
=None,
46 conn
=None, attrs
=None, role
=None):
48 io
.append(Subsignal("rx", Pins(rx
, dir="i", conn
=conn
, assert_width
=1)))
49 io
.append(Subsignal("tx", Pins(tx
, dir="o", conn
=conn
, assert_width
=1)))
52 return Resource
.family(*args
, default_name
="uart", ios
=io
)
54 def I2CResource(*args
, scl
, sda
, conn
=None, attrs
=None):
56 io
.append(Subsignal("scl", Pins(scl
, dir="io", conn
=conn
, assert_width
=1)))
57 io
.append(Subsignal("sda", Pins(sda
, dir="io", conn
=conn
, assert_width
=1)))
60 return Resource
.family(*args
, default_name
="i2c", ios
=io
)
64 and to create a Platform instance with that list, and build
68 p.resources=listofstuff
71 pinset
= dummy_pinset()
72 resources
= create_resources(pinset
)
76 p
.resources
= create_resources(pinset
)