Skip to content

Make IO standard a part of GlasgowPin structure #934

@whitequark

Description

@whitequark

This would entail additional infrastructure for:

  1. Automating adding a voltage argument that would populate the IO voltage part of the GlasgowPin structure;
  2. Making sure it is not onerous to specify voltage when using applets via the CLI;
  3. Making sure it is not onerous to specify voltage when using applets via the API.

For (1), I propose slightly amending our current DSL to:

    @classmethod
    def add_build_arguments(cls, parser, access):
        with access.add_voltage_argument(parser):
            access.add_pins_argument(parser, "ce",   default=True, required=True)
            access.add_pins_argument(parser, "cs",   default=True, required=True)
            access.add_pins_argument(parser, "sck",  default=True, required=True)
            access.add_pins_argument(parser, "copi", default=True, required=True)
            access.add_pins_argument(parser, "cipo", default=True, required=True)
            access.add_pins_argument(parser, "irq",  default=True)

This would create a voltage argument (probably with a name: Optional[str] argument, for dual I/O voltage applets) and attach it to the pins arguments inside the context manager, so that specyfing the voltage automatically inserts that value into the GlasgowPin objects in the namespace attributes defined by the add_pin_argument calls.

The explicit assembly.use_voltage call will then disappear. The Glasgow assembly would be able to diagnose voltage conflicts in configure_ports, as a separate step before making any actual adjustments to voltages.

For (2), I propose making the voltage argument required by default (to avoid a common current mistake: forgetting it entirely and getting nothing from the applet), but making it possible to specify --voltage - (similar to --pin-cs - which you can do already).

For (3), I propose making it legal to use GlasgowPin structures without a voltage attached to them, with the expectation that the use_voltage call will be done by whoever instantiates the *Interface object. (This guardrail can also be used for (2).) This way, one would be able to do e.g. ce="A1" without worrying about the voltage.

For (2) & (3), I propose also making it possible to say both --pin-ce A1~3.3 and ce="A1~3.3". It's not clear whether this is even a good idea, but it is worth looking at as a natural extension of our pin specification language.

This issue addresses a part of #234 and #460.

Metadata

Metadata

Assignees

No one assigned

    Labels

    softwareComponent: software

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions