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 write(self
, pyf
, of
, pinmap
):
42 fns
= python_dict_fns(pyf
, pinmap
, self
, self
.function_names
)
44 of
.write("""# Pinouts (PinMux)
45 auto-generated by [[pinouts.py]]
50 bk
= self
.pinbanks
.keys()
53 "\n## Bank %s (%d pins, width %d)\n\n" %
54 (bank
, self
.pinbanks
[bank
], self
.muxwidths
[bank
]))
55 display(of
, self
, bank
, muxwidth
=self
.muxwidths
[bank
])
57 of
.write("\n# Pinouts (Fixed function)\n\n")
58 fixedpins
= display_fixed(of
, self
.fixedpins
, len(self
))
60 of
.write("""# Functions (PinMux)
62 auto-generated by [[pinouts.py]]
65 fns
= display_fns(of
, self
.bankspec
, self
, self
.function_names
)
68 for scenario
in self
.scenarios
:
69 name
, needed
, eint
, pwm
, descriptions
= scenario
70 unused_pins
= check_functions(of
, name
, self
.bankspec
, fns
,
75 of
.write("""# Reference Datasheets
77 datasheets and pinout links
79 * <http://datasheets.chipdb.org/AMD/8018x/80186/amd-80186.pdf>
80 * <http://hands.com/~lkcl/eoma/shenzen/frida/FRD144A2701.pdf>
81 * <http://pinouts.ru/Memory/sdcard_pinout.shtml>
82 * p8 <http://www.onfi.org/~/media/onfi/specs/onfi_2_0_gold.pdf?la=en>
83 * <https://www.heyrick.co.uk/blog/files/datasheets/dm9000aep.pdf>
84 * <http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4393.pdf>
85 * <https://www.nxp.com/docs/en/data-sheet/MCF54418.pdf>
86 * ULPI OTG PHY, ST <http://www.st.com/en/interfaces-and-transceivers/stulpi01a.html>
87 * ULPI OTG PHY, TI TUSB1210 <http://ti.com/product/TUSB1210/>
91 return self
, self
.bankspec
, self
.pinbanks
, fixedpins