Skip to content

CS Assertion polarity - any support for active high devices? #71

Closed
@michthom

Description

@michthom

There was discussion in the comments for #1 about adding the ability to support CS lines that require active high, understandably in the minority so deferred. I'm currently trying to build an SPIDevice to talk to an ST7920 graphic LCD panel, and have code that adapts the venerable https://github.com/JMW95/pyST7920, but fails for (I'm assuming) this reason.
Is there any appetite for a PR that implements an additional parameter, and inverts the logic in __enter__() and __leave__() when requested?
I'm thinking about something like:

def __init__(self,
    spi: Any,
    chip_select: Any = None,
    *,
    cs_active_low: bool = True,
    baudrate: int = 100000,
    polarity: int = 0,
    phase: int = 0,
    extra_clocks: int = 0) -> None

and then in __enter__()

        if self.chip_select:
            self.chip_select.value = False if cs_active_low else True

and __leave__()

        if self.chip_select:
            self.chip_select.value = True if cs_active_low else False

Of course the alternative of inverting the signal in hardware remains an option, however unappealing, if this is a permanently closed topic?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions