projects
/
pinmux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
19a02e3
)
write out to mdwn file instead of stdout
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Sat, 31 Mar 2018 07:02:06 +0000
(08:02 +0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Sat, 31 Mar 2018 07:02:06 +0000
(08:02 +0100)
src/pinmux_generator.py
patch
|
blob
|
history
src/spec/gen.py
patch
|
blob
|
history
src/spec/ifaceprint.py
patch
|
blob
|
history
src/spec/m_class.py
patch
|
blob
|
history
src/spec/minitest.py
patch
|
blob
|
history
diff --git
a/src/pinmux_generator.py
b/src/pinmux_generator.py
index 05ebf2d39f6e4c9bb5bf3d6a7346778b48d73950..9512d4d3bf4ce909589e87cd95fb06545d5a4fcc 100644
(file)
--- a/
src/pinmux_generator.py
+++ b/
src/pinmux_generator.py
@@
-77,8
+77,10
@@
if __name__ == '__main__':
printhelp()
sys.exit(1)
module = modules[pinspec]
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:
else:
gentypes = {'bsv': bsvgen}
if output_type not in gentypes:
diff --git
a/src/spec/gen.py
b/src/spec/gen.py
index cb7957f525b454bdeb12247b41c0589fbed4e5b2..6c9f563c02cc53be082e1835d6dfc1b4fc909023 100644
(file)
--- a/
src/spec/gen.py
+++ b/
src/spec/gen.py
@@
-3,7
+3,7
@@
import os.path
from spec.interfaces import Pinouts
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
"""
""" generates a specification of pinouts (tsv files)
for reading in by pinmux
"""
@@
-60,8
+60,8
@@
def specgen(pth, pinouts, bankspec, pinbanks, fixedpins):
g.write('\t'.join(p) + '\n')
# lists bankspec, shows where the pin-numbers *start*
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():
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]))
g.write("%s\t%d\t%d\n" % (bank, pinstart, pinbanks[bank]))
diff --git
a/src/spec/ifaceprint.py
b/src/spec/ifaceprint.py
index 5236a03e4f06985080e1d3999ae20663f9c126ae..c1891f7a8f13a6be83f47d5606d62a8ce8521380 100644
(file)
--- a/
src/spec/ifaceprint.py
+++ b/
src/spec/ifaceprint.py
@@
-3,9
+3,11
@@
from copy import deepcopy
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)
pinidx = sorted(pins.keys())
for pin in pinidx:
pdata = pins.get(pin)
@@
-16,7
+18,7
@@
def display(pins):
continue
name, bank = pdata[mux]
res += " %s %-9s |" % (bank, name)
continue
name, bank = pdata[mux]
res += " %s %-9s |" % (bank, name)
- print res
+ of.write("%s\n" % res)
def fnsplit(f):
def fnsplit(f):
@@
-50,7
+52,7
@@
def find_fn(fname, names):
return n
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():
fn_names = function_names.keys()
fns = {}
for (pin, pdata) in pins.items():
@@
-71,36
+73,30
@@
def display_fns(bankspec, pins, function_names):
#print "name", fname, fnbase
if fnbase != current_fn:
if current_fn is not None:
#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
current_fn = fnbase
- print "* %-9s :" % fname,
+ of.write("* %-9s :" % fname)
for (pin, mux, bank) in fns[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
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 = {}
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:
for name in required:
- print "## %s" % name
- print
+ of.write("## %s\n\n" % name)
if descriptions and name in descriptions:
if descriptions and name in descriptions:
- print descriptions[name]
- print
+ of.write("%s\n\n" % descriptions[name])
name = name.split(':')
if len(name) == 2:
name = name.split(':')
if len(name) == 2:
@@
-144,9
+140,9
@@
def check_functions(title, bankspec, fns, pins, required, eint, pwm,
if len(found) > count:
continue
del pins[pin_]
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
gpios = []
@@
-159,8
+155,7
@@
def check_functions(title, bankspec, fns, pins, required, eint, pwm,
gpios.sort()
if gpios:
gpios.sort()
if gpios:
- print "## GPIO"
- print
+ of.write("## GPIO\n\n")
for fname in gpios:
if fname in found:
for fname in gpios:
if fname in found:
@@
-175,28
+170,25
@@
def check_functions(title, bankspec, fns, pins, required, eint, pwm,
continue
del pins[pin_]
found.add(fname)
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:
if eint:
- display_group(bankspec, "EINT", eint, fns, pins, descriptions)
+ display_group(
of,
bankspec, "EINT", eint, fns, pins, descriptions)
if pwm:
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:
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
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:
found = set()
for fname in todisplay:
@@
-225,38
+217,38
@@
def display_group(bankspec, title, todisplay, fns, pins, descriptions):
continue
del pins[pin_]
found.add(fname)
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):
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
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:
if prevname[:2] == name[:2] and linecount != 0:
- print name,
+ of.write(" %s" % name)
linecount += 1
else:
if linecount != 0:
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:
linecount = 1
res.append((pin_, name))
prevname = name
pin_ += 1
if linecount != 0:
- print
- print
+ of.write('\n')
+ of.write('\n')
return res
return res
diff --git
a/src/spec/m_class.py
b/src/spec/m_class.py
index 3f3974b8e65f7595faa1eb74aa1d11eeedf3a8ab..d0dd7bd42a49e408d1e2a3c0cf13751b25da7107 100644
(file)
--- a/
src/spec/m_class.py
+++ b/
src/spec/m_class.py
@@
-6,7
+6,7
@@
from spec.ifaceprint import display, display_fns, check_functions
from spec.ifaceprint import display_fixed
from spec.ifaceprint import display_fixed
-def pinspec():
+def pinspec(
of
):
pinbanks = {'A': 16,
'B': 28,
'C': 24,
pinbanks = {'A': 16,
'B': 28,
'C': 24,
@@
-142,14
+142,15
@@
def pinspec():
pinouts.sdmmc("1", ('G', 24), "G", 3, limit=2)
pinouts.sdmmc("1", ('G', 28), "G", 2, start=2)
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 ]]
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': [
fixedpins = {
'DDR3': [
@@
-333,11
+334,12
@@
auto-generated by [[pinouts.py]]
'GND_GPIOG',
]}
'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]]
auto-generated by [[pinouts.py]]
+
""")
function_names = {'EINT': 'External Interrupt',
""")
function_names = {'EINT': 'External Interrupt',
@@
-368,8
+370,8
@@
auto-generated by [[pinouts.py]]
'ULPI2': 'ULPI (USB Low Pin-count) 3',
}
'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
# 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
@@
-401,7
+403,7
@@
auto-generated by [[pinouts.py]]
'ULPI1': 'EOMA68-compliance: dual USB2 Host ULPI PHY'
}
'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)
eoma68, eoma68_eint, eoma68_pwm,
descriptions)
@@
-422,7
+424,7
@@
auto-generated by [[pinouts.py]]
industrial_eint = ['EINT_24', 'EINT_25', 'EINT_26', 'EINT_27',
'EINT_20', 'EINT_21', 'EINT_22', 'EINT_23']
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
industrial, industrial_eint, industrial_pwm)
# Industrial scenario, using an SPI-based LCD instead of RGB/TTL
@@
-445,7
+447,7
@@
auto-generated by [[pinouts.py]]
'B2:SPI0': 'Used for 320x240 or 640x480 etc. SPI-based LCD.\n'
'Frees up large numbers of GPIO from RGB/TTL bank'
}
'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)
bankspec, fns, pinouts,
industrial, industrial_eint, industrial_pwm,
ind_descriptions)
@@
-526,7
+528,7
@@
auto-generated by [[pinouts.py]]
'EINT_30': 'OTG_ID',
'EINT_31': 'Spare?',
}
'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)
bankspec, fns, pinouts,
tablet, tablet_eint, tablet_pwm,
descriptions)
@@
-582,7
+584,7
@@
auto-generated by [[pinouts.py]]
'EINT_9': 'MCU_INT',
'EINT_31': 'PMIC_INT',
}
'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)
bankspec, fns, pinouts,
laptop, laptop_eint, laptop_pwm,
descriptions)
@@
-675,12
+677,12
@@
auto-generated by [[pinouts.py]]
'EINT_30': 'CTP_INT',
'EINT_31': 'SD_DETN',
}
'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)
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>
datasheets and pinout links
* <http://datasheets.chipdb.org/AMD/8018x/80186/amd-80186.pdf>
@@
-692,6
+694,7
@@
datasheets and pinout links
* <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/>
* <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
""")
return pinouts, bankspec, pinbanks, fixedpins
diff --git
a/src/spec/minitest.py
b/src/spec/minitest.py
index dc91d14a4151c6fc6ead305cbadea337c9173ea5..5820d54cdd983c0e2d3d1f0dcd67055e0b1e2805 100644
(file)
--- a/
src/spec/minitest.py
+++ b/
src/spec/minitest.py
@@
-6,7
+6,7
@@
from spec.ifaceprint import display, display_fns, check_functions
from spec.ifaceprint import display_fixed
from spec.ifaceprint import display_fixed
-def pinspec():
+def pinspec(
of
):
pinbanks = {
'B': 28,
}
pinbanks = {
'B': 28,
}
@@
-41,14
+41,15
@@
def pinspec():
pinouts.uart("1", ('B', 2), "B", 2)
pinouts.uart("2", ('B', 14), "B", 2)
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 ]]
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': [
fixedpins = {
'CTRL_SYS': [
@@
-71,11
+72,12
@@
auto-generated by [[pinouts.py]]
'GND_GPIOB',
]}
'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]]
auto-generated by [[pinouts.py]]
+
""")
function_names = {'EINT': 'External Interrupt',
""")
function_names = {'EINT': 'External Interrupt',
@@
-106,8
+108,8
@@
auto-generated by [[pinouts.py]]
'ULPI2': 'ULPI (USB Low Pin-count) 2',
}
'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
# 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
@@
-133,11
+135,11
@@
auto-generated by [[pinouts.py]]
'ULPI1': 'dual USB2 Host ULPI PHY'
}
'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)
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>
datasheets and pinout links
* <http://datasheets.chipdb.org/AMD/8018x/80186/amd-80186.pdf>
@@
-149,6
+151,7
@@
datasheets and pinout links
* <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/>
* <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
""")
return pinouts, bankspec, pinbanks, fixedpins