Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: aca359701e70
Choose a base ref
...
head repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1639a25f35d4
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Aug 6, 2019

  1. Copy the full SHA
    6bbc527 View commit details
  2. Copy the full SHA
    ad30823 View commit details
  3. Copy the full SHA
    1639a25 View commit details
Showing with 27 additions and 8 deletions.
  1. +14 −3 software/glasgow/access/direct/arguments.py
  2. +2 −2 software/glasgow/applet/interface/spi_master/__init__.py
  3. +11 −3 software/glasgow/applet/memory/_25x/__init__.py
17 changes: 14 additions & 3 deletions software/glasgow/access/direct/arguments.py
Original file line number Diff line number Diff line change
@@ -38,20 +38,31 @@ def _add_port_voltage_arguments(self, parser, default):
"--keep-voltage", action="store_true", default=False,
help="do not change I/O port voltage")

def _pin_number(self, arg):
def _mandatory_pin_number(self, arg):
if not re.match(r"^[0-9]+$", arg):
self._arg_error("{} is not a valid pin number", arg)
return int(arg)

def _optional_pin_number(self, arg):
if arg == "-":
return None
return self._mandatory_pin_number(arg)

def _add_pin_argument(self, parser, name, default, required):
help = "bind the applet I/O line {!r} to pin NUM".format(name)
if default is not None:
help += " (default: %(default)s)"

if required:
type = self._mandatory_pin_number
if default is not None:
required = False
else:
type = self._optional_pin_number

opt_name = "--pin-" + name.lower().replace("_", "-")
parser.add_argument(
opt_name, metavar="NUM", type=self._pin_number, default=default, required=required,
help=help)
opt_name, metavar="NUM", type=type, default=default, required=required, help=help)

def _pin_set(self, width, arg):
if re.match(r"^[0-9]+:[0-9]+$", arg):
4 changes: 2 additions & 2 deletions software/glasgow/applet/interface/spi_master/__init__.py
Original file line number Diff line number Diff line change
@@ -307,8 +307,8 @@ def add_build_arguments(cls, parser, access, omit_pins=False):
access.add_pin_argument(parser, "miso")

parser.add_argument(
"-b", "--bit-rate", metavar="FREQ", type=int, default=100,
help="set SPI bit rate to FREQ kHz (default: %(default)s)")
"-f", "--frequency", metavar="FREQ", type=int, default=100,
help="set SPI clock frequency to FREQ kHz (default: %(default)s)")
parser.add_argument(
"--sck-idle", metavar="LEVEL", type=int, choices=[0, 1], default=0,
help="set idle clock level to LEVEL (default: %(default)s)")
14 changes: 11 additions & 3 deletions software/glasgow/applet/memory/_25x/__init__.py
Original file line number Diff line number Diff line change
@@ -236,13 +236,21 @@ class Memory25xApplet(SPIMasterApplet, name="memory-25x"):
N/C * * N/C
SS# * * GND
MISO * * WP#
The default pin assignment follows the pinouts above in the clockwise direction, making it easy
to connect the memory with probes or, alternatively, crimp an IDC cable wired to a SOIC clip.
"""

@classmethod
def add_build_arguments(cls, parser, access):
super().add_build_arguments(parser, access)

access.add_pin_argument(parser, "hold")
super().add_build_arguments(parser, access, omit_pins=True)

access.add_pin_argument(parser, "ss", default=True, required=True)
access.add_pin_argument(parser, "miso", default=True, required=True)
access.add_pin_argument(parser, "wp", default=True)
access.add_pin_argument(parser, "mosi", default=True, required=True)
access.add_pin_argument(parser, "sck", default=True, required=True)
access.add_pin_argument(parser, "hold", default=True)

def build(self, target, args):
subtarget = super().build(target, args)