1 from spec
.interfaces
import Pinouts
3 from spec
.ifaceprint
import display
, display_fns
, check_functions
4 from spec
.ifaceprint
import display_fixed
, python_dict_fns
5 from collections
import OrderedDict
8 class PinSpec(Pinouts
):
9 def __init__(self
, pinbanks
, fixedpins
, function_names
, fast
=None):
10 self
.fastbus
= fast
or {}
11 self
.pinbanks
= OrderedDict()
13 for bank
, (sz
, muxwidth
) in pinbanks
.items():
14 self
.pinbanks
[bank
] = sz
15 self
.muxwidths
[bank
] = muxwidth
16 self
.fixedpins
= fixedpins
17 self
.function_names
= function_names
18 bankspec
= OrderedDict()
20 pkeys
= self
.pinbanks
.keys()
23 bankspec
[kn
] = self
.offs
24 self
.offs
+= self
.pinbanks
[kn
]
28 Pinouts
.__init
__(self
, bankspec
)
30 def add_scenario(self
, name
, needed
, eint
, pwm
, descriptions
):
31 # Scenarios below can be spec'd out as either "find first interface"
32 # by name/number e.g. SPI0, or as "find in bank/mux" which must be
33 # spec'd as "BM:Name" where B is bank (A-F), M is Mux (0-3)
34 # EINT and PWM are grouped together, specially, but may still be spec'd
35 # using "BM:Name". Pins are removed in-order as listed from
36 # lists (interfaces, EINTs, PWMs) from available pins.
38 self
.scenarios
.append((name
, needed
, eint
, pwm
, descriptions
))
40 def pywrite(self
, pyf
, pinmap
):
41 return python_dict_fns(pyf
, pinmap
, self
, self
.function_names
)
45 of
.write("""# Pinouts (PinMux)
46 auto-generated by [[pinouts.py]]
51 bk
= self
.pinbanks
.keys()
54 "\n## Bank %s (%d pins, width %d)\n\n" %
55 (bank
, self
.pinbanks
[bank
], self
.muxwidths
[bank
]))
56 display(of
, self
, bank
, muxwidth
=self
.muxwidths
[bank
])
58 of
.write("\n# Pinouts (Fixed function)\n\n")
59 fixedpins
= display_fixed(of
, self
.fixedpins
, len(self
))
61 of
.write("""# Functions (PinMux)
63 auto-generated by [[pinouts.py]]
66 fns
= display_fns(of
, self
.bankspec
, self
, self
.function_names
)
69 for scenario
in self
.scenarios
:
70 name
, needed
, eint
, pwm
, descriptions
= scenario
71 unused_pins
= check_functions(of
, name
, self
.bankspec
, fns
,
76 of
.write("""# Reference Datasheets
78 datasheets and pinout links
79 * <https://ftp.libre-soc.org/STULPI01BTBR.en.CD00201527.pdf>
80 * <https://ftp.libre-soc.org/3300db.pdf>
81 * <https://ftp.libre-soc.org/1912111437_Realtek-Semicon-RTL8211F-CG_C187932.pdf>
83 * <http://datasheets.chipdb.org/AMD/8018x/80186/amd-80186.pdf>
84 * <http://hands.com/~lkcl/eoma/shenzen/frida/FRD144A2701.pdf>
85 * <http://pinouts.ru/Memory/sdcard_pinout.shtml>
86 * p8 <http://www.onfi.org/~/media/onfi/specs/onfi_2_0_gold.pdf?la=en>
87 * <https://www.heyrick.co.uk/blog/files/datasheets/dm9000aep.pdf>
88 * <http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4393.pdf>
89 * <https://www.nxp.com/docs/en/data-sheet/MCF54418.pdf>
90 * ULPI OTG PHY, ST <http://www.st.com/en/interfaces-and-transceivers/stulpi01a.html>
91 * ULPI OTG PHY, TI TUSB1210 <http://ti.com/product/TUSB1210/>
95 return self
, self
.bankspec
, self
.pinbanks
, fixedpins