printhelp()
sys.exit(1)
module = modules[pinspec]
- pinout, bankspec, pinspec, fixedpins = module.pinspec()
- specgen(output_dir, pinout, bankspec, pinspec, fixedpins)
+ fname = os.path.join(output_dir or '', "%s.mdwn" % pinspec)
+ with open(fname, "w") as of:
+ pinout, bankspec, pinspec, fixedpins = module.pinspec(of)
+ specgen(of, output_dir, pinout, bankspec, pinspec, fixedpins)
else:
gentypes = {'bsv': bsvgen}
if output_type not in gentypes:
from spec.interfaces import Pinouts
-def specgen(pth, pinouts, bankspec, pinbanks, fixedpins):
+def specgen(of, pth, pinouts, bankspec, pinbanks, fixedpins):
""" generates a specification of pinouts (tsv files)
for reading in by pinmux
"""
g.write('\t'.join(p) + '\n')
# lists bankspec, shows where the pin-numbers *start*
- print ("# Pin Bank starting points and lengths\n")
+ of.write("# Pin Bank starting points and lengths\n\n")
with open(os.path.join(pth, 'pinspec.txt'), 'w') as g:
for bank, pinstart in bankspec.items():
- print ("* %s %d %d" % (bank, pinstart, pinbanks[bank]))
+ of.write("* %s %d %d\n" % (bank, pinstart, pinbanks[bank]))
g.write("%s\t%d\t%d\n" % (bank, pinstart, pinbanks[bank]))
from copy import deepcopy
-def display(pins):
- print "| Pin | Mux0 | Mux1 | Mux2 | Mux3 |"
- print "| --- | ----------- | ----------- | ----------- | ----------- |"
+def display(of, pins):
+ of.write("""\
+| Pin | Mux0 | Mux1 | Mux2 | Mux3 |
+| --- | ----------- | ----------- | ----------- | ----------- |
+""")
pinidx = sorted(pins.keys())
for pin in pinidx:
pdata = pins.get(pin)
continue
name, bank = pdata[mux]
res += " %s %-9s |" % (bank, name)
- print res
+ of.write("%s\n" % res)
def fnsplit(f):
return n
-def display_fns(bankspec, pins, function_names):
+def display_fns(of, bankspec, pins, function_names):
fn_names = function_names.keys()
fns = {}
for (pin, pdata) in pins.items():
#print "name", fname, fnbase
if fnbase != current_fn:
if current_fn is not None:
- print
- print "## %s" % fnbase
- print
- print function_names[fnbase]
- print
+ of.write('\n')
+ of.write("## %s\n\n%s\n\n" % (fnbase, function_names[fnbase]))
current_fn = fnbase
- print "* %-9s :" % fname,
+ of.write("* %-9s :" % fname)
for (pin, mux, bank) in fns[fname]:
- print "%s%d/%d" % (bank, pin, mux),
- print
+ of.write(" %s%d/%d" % (bank, pin, mux))
+ of.write('\n')
return fns
-def check_functions(title, bankspec, fns, pins, required, eint, pwm,
+def check_functions(of, title, bankspec, fns, pins, required, eint, pwm,
descriptions=None):
fns = deepcopy(fns)
pins = deepcopy(pins)
if descriptions is None:
descriptions = {}
- print "# Pinmap for %s" % title
- print
+ of.write("# Pinmap for %s\n\n" % title)
for name in required:
- print "## %s" % name
- print
+ of.write("## %s\n\n" % name)
if descriptions and name in descriptions:
- print descriptions[name]
- print
+ of.write("%s\n\n" % descriptions[name])
name = name.split(':')
if len(name) == 2:
if len(found) > count:
continue
del pins[pin_]
- print "* %s %d %s%d/%d" % (fname, pin_, bank, pin, mux)
+ of.write("* %s %d %s%d/%d\n" % (fname, pin_, bank, pin, mux))
- print
+ of.write('\n')
# gpios
gpios = []
gpios.sort()
if gpios:
- print "## GPIO"
- print
+ of.write("## GPIO\n\n")
for fname in gpios:
if fname in found:
continue
del pins[pin_]
found.add(fname)
- print "* %-8s %d %s%-2d %s" % (fname, pin_, bank, pin, desc)
- print
+ of.write("* %-8s %d %s%-2d %s\n" % (fname, pin_, bank, pin, desc))
+ of.write('\n')
if eint:
- display_group(bankspec, "EINT", eint, fns, pins, descriptions)
+ display_group(of, bankspec, "EINT", eint, fns, pins, descriptions)
if pwm:
- display_group(bankspec, "PWM", pwm, fns, pins, descriptions)
+ display_group(of, bankspec, "PWM", pwm, fns, pins, descriptions)
- print "## Unused Pinouts (spare as GPIO) for '%s'" % title
- print
+ of.write("## Unused Pinouts (spare as GPIO) for '%s'\n\n" % title)
if descriptions and 'GPIO' in descriptions:
- print descriptions['GPIO']
- print
- display(pins)
- print
+ of.write("%s\n\n" % descriptions['GPIO'])
+ display(of, pins)
+ of.write('\n')
return pins # unused
-def display_group(bankspec, title, todisplay, fns, pins, descriptions):
- print "## %s" % title
- print
+def display_group(of, bankspec, title, todisplay, fns, pins, descriptions):
+ of.write("## %s\n\n" % title)
found = set()
for fname in todisplay:
continue
del pins[pin_]
found.add(fname)
- print "* %s %d %s%d/%d %s" % (fname, pin_, bank, pin, mux, desc)
- print
+ of.write("* %s %d %s%d/%d %s\n" %
+ (fname, pin_, bank, pin, mux, desc))
+ of.write('\n')
-def display_fixed(fixed, offs):
+def display_fixed(of, fixed, offs):
fkeys = sorted(fixed.keys())
pin_ = offs
res = []
for pin, k in enumerate(fkeys):
- print "## %s" % k
- print
+ of.write("## %s\n\n" % k)
prevname = ''
linecount = 0
for name in fixed[k]:
if linecount == 4:
linecount = 0
- print
+ of.write('\n')
if prevname[:2] == name[:2] and linecount != 0:
- print name,
+ of.write(" %s" % name)
linecount += 1
else:
if linecount != 0:
- print
- print "* %d: %d %s" % (pin_, pin, name),
+ of.write('\n')
+ of.write("* %d: %d %s" % (pin_, pin, name))
linecount = 1
res.append((pin_, name))
prevname = name
pin_ += 1
if linecount != 0:
- print
- print
+ of.write('\n')
+ of.write('\n')
return res
from spec.ifaceprint import display_fixed
-def pinspec():
+def pinspec(of):
pinbanks = {'A': 16,
'B': 28,
'C': 24,
pinouts.sdmmc("1", ('G', 24), "G", 3, limit=2)
pinouts.sdmmc("1", ('G', 28), "G", 2, start=2)
- print ("""# Pinouts (PinMux)
+ of.write ("""# Pinouts (PinMux)
auto-generated by [[pinouts.py]]
[[!toc ]]
+
""")
- display(pinouts)
+ display(of, pinouts)
- print ("\n# Pinouts (Fixed function)\n")
+ of.write ("\n# Pinouts (Fixed function)\n\n")
fixedpins = {
'DDR3': [
'GND_GPIOG',
]}
- fixedpins = display_fixed(fixedpins, len(pinouts))
+ fixedpins = display_fixed(of, fixedpins, len(pinouts))
- print ("""# Functions (PinMux)
+ of.write ("""# Functions (PinMux)
auto-generated by [[pinouts.py]]
+
""")
function_names = {'EINT': 'External Interrupt',
'ULPI2': 'ULPI (USB Low Pin-count) 3',
}
- fns = display_fns(bankspec, pinouts, function_names)
- print
+ fns = display_fns(of, bankspec, pinouts, function_names)
+ of.write('\n')
# Scenarios below can be spec'd out as either "find first interface"
# by name/number e.g. SPI0, or as "find in bank/mux" which must be
'ULPI1': 'EOMA68-compliance: dual USB2 Host ULPI PHY'
}
- unused_pins = check_functions("EOMA68", bankspec, fns, pinouts,
+ unused_pins = check_functions(of, "EOMA68", bankspec, fns, pinouts,
eoma68, eoma68_eint, eoma68_pwm,
descriptions)
industrial_eint = ['EINT_24', 'EINT_25', 'EINT_26', 'EINT_27',
'EINT_20', 'EINT_21', 'EINT_22', 'EINT_23']
- unused_pins = check_functions("Industrial", bankspec, fns, pinouts,
+ unused_pins = check_functions(of, "Industrial", bankspec, fns, pinouts,
industrial, industrial_eint, industrial_pwm)
# Industrial scenario, using an SPI-based LCD instead of RGB/TTL
'B2:SPI0': 'Used for 320x240 or 640x480 etc. SPI-based LCD.\n'
'Frees up large numbers of GPIO from RGB/TTL bank'
}
- unused_pins = check_functions("Industrial with SPI-LCD",
+ unused_pins = check_functions(of, "Industrial with SPI-LCD",
bankspec, fns, pinouts,
industrial, industrial_eint, industrial_pwm,
ind_descriptions)
'EINT_30': 'OTG_ID',
'EINT_31': 'Spare?',
}
- unused_pins = check_functions("Smartphone / Tablet",
+ unused_pins = check_functions(of, "Smartphone / Tablet",
bankspec, fns, pinouts,
tablet, tablet_eint, tablet_pwm,
descriptions)
'EINT_9': 'MCU_INT',
'EINT_31': 'PMIC_INT',
}
- unused_pins = check_functions("Laptop / Netbook",
+ unused_pins = check_functions(of, "Laptop / Netbook",
bankspec, fns, pinouts,
laptop, laptop_eint, laptop_pwm,
descriptions)
'EINT_30': 'CTP_INT',
'EINT_31': 'SD_DETN',
}
- unused_pins = check_functions("IoT",
+ unused_pins = check_functions(of, "IoT",
bankspec, fns, pinouts,
iot, iot_eint, iot_pwm,
descriptions)
- print ("""# Reference Datasheets
+ of.write ("""# Reference Datasheets
datasheets and pinout links
* <http://datasheets.chipdb.org/AMD/8018x/80186/amd-80186.pdf>
* <https://www.nxp.com/docs/en/data-sheet/MCF54418.pdf>
* ULPI OTG PHY, ST <http://www.st.com/en/interfaces-and-transceivers/stulpi01a.html>
* ULPI OTG PHY, TI TUSB1210 <http://ti.com/product/TUSB1210/>
+
""")
return pinouts, bankspec, pinbanks, fixedpins
from spec.ifaceprint import display_fixed
-def pinspec():
+def pinspec(of):
pinbanks = {
'B': 28,
}
pinouts.uart("1", ('B', 2), "B", 2)
pinouts.uart("2", ('B', 14), "B", 2)
- print ("""# Pinouts (PinMux)
+ of.write("""# Pinouts (PinMux)
auto-generated by [[pinouts.py]]
[[!toc ]]
+
""")
- display(pinouts)
+ display(of, pinouts)
- print ("\n# Pinouts (Fixed function)\n")
+ of.write("\n# Pinouts (Fixed function)\n\n")
fixedpins = {
'CTRL_SYS': [
'GND_GPIOB',
]}
- fixedpins = display_fixed(fixedpins, len(pinouts))
+ fixedpins = display_fixed(of, fixedpins, len(pinouts))
- print ("""# Functions (PinMux)
+ of.write("""# Functions (PinMux)
auto-generated by [[pinouts.py]]
+
""")
function_names = {'EINT': 'External Interrupt',
'ULPI2': 'ULPI (USB Low Pin-count) 2',
}
- fns = display_fns(bankspec, pinouts, function_names)
- print
+ fns = display_fns(of, bankspec, pinouts, function_names)
+ of.write("\n")
# Scenarios below can be spec'd out as either "find first interface"
# by name/number e.g. SPI1, or as "find in bank/mux" which must be
'ULPI1': 'dual USB2 Host ULPI PHY'
}
- unused_pins = check_functions("MiniTest", bankspec, fns, pinouts,
+ unused_pins = check_functions(of, "MiniTest", bankspec, fns, pinouts,
minitest, minitest_eint, minitest_pwm,
descriptions)
- print ("""# Reference Datasheets
+ of.write("""# Reference Datasheets
datasheets and pinout links
* <http://datasheets.chipdb.org/AMD/8018x/80186/amd-80186.pdf>
* <https://www.nxp.com/docs/en/data-sheet/MCF54418.pdf>
* ULPI OTG PHY, ST <http://www.st.com/en/interfaces-and-transceivers/stulpi01a.html>
* ULPI OTG PHY, TI TUSB1210 <http://ti.com/product/TUSB1210/>
+
""")
return pinouts, bankspec, pinbanks, fixedpins