periph icon indicating copy to clipboard operation
periph copied to clipboard

gpio: add Group interface, to act on multiple GPIO as a single transaction

Open maruel opened this issue 6 years ago • 1 comments

https://periph.io/x/periph/conn/gpio doesn't enable acting on multiple GPIOs simultaneously. This is useful to simulate a protocol, for example with bitbang.

Up to now the only API that exposes something close to that is https://periph.io/x/periph/host/bcm283x#PinsSet0To31 and https://periph.io/x/periph/host/bcm283x#PinsClear0To31. The https://periph.io/x/extra/hostextra/d2xx driver would also enable this but lack of clear API meant this functionality is not exposed. But these two are still fairly limited in scope.

#371 would make make this much more available, as synchronized GPIO I/O could be done on any system running the linux kernel 4.8 or later. To expose this functionality, an API has to be designed first.

Designing an API is challenging, as for proper synchonization, the operation must be hardware assisted. This means that GPIOs cannot be mix-and-matched, they must all belong to the same "GPIO source". There is no such concept at the moment, so this much be created first.

maruel avatar Jan 07 '19 20:01 maruel

Let's aim to have at least an idea how a gpio.Group would look like. A Group would be a logical group, not a physical one. To clarify, we're not talking about GPIOs grouped together on a header, I'm talking about GPIOs that are on the same controller thus can be acted on upon as a transaction. See the previous comment for precedents.

My thinking at the moment is to:

  • Add gpio.Group interface, listing its owned pins.
  • Add to interface gpio.Pin a new method .Group().

The interface Group would contain the transactional operations.

maruel avatar Jan 17 '19 13:01 maruel

Ported to https://github.com/periph/conn/issues/30

maruel avatar Sep 20 '23 16:09 maruel