Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Switch GPIO direction on Raspberry Pi using ioctl()

gremlin%portal-to-web.de@localhost (Martin Mersberger) writes:

>My todays workaround is to run a kernel with 'INSECURE' option enabled,
>but any alternative which would allow a direction change of certain pins
>would be great

There is already a bidirectional GPIO_PIN_INOUT mode (as opposed to the
unidirectional GPIO_PIN_INPUT and GPIO_PIN_OUTPUT modes). But I doubt
anyone has an idea how it should operate. It also lacks a method to
tristate an output.

These 4 drivers reference the INOUT mode.

- treats it like GPIO_PIN_OUTPUT, the output is open-drain with
  an internal or maybe an external pullup.

- I doubt this works for anything, the control method sets a
  bitmask for one pin and clears them for all other pins.

  used as disjunct modes to control a pin.

- nothing to control, all pins have a default mode of GPIO_PIN_INOUT.
  That's probably an open-drain output.

There should be a clear definition on what the flags actually mean.
For example:

Pin directions, you must configure one of these:

GPIO_PIN_INPUT   - pin can be only read
GPIO_PIN_OUTPUT  - pin can be only written
GPIO_PIN_INOUT   - pin can be read and written

Output modes, you can configure one of these for an output pin.
If none is set, a hardware dependent value is used. The modes
are ignored for an input pin.

GPIO_PIN_OPENDRAIN - configure output as open drain
GPIO_PIN_PUSHPULL  - configure output as push-pull
GPIO_PIN_TRISTATE  - disable output

Pin options:

GPIO_PIN_PULLUP    - enable pullup resistor
GPIO_PIN_PULLDOWN  - enable pull-down resistor
GPIO_PIN_INVIN     - invert input (ignored for GPIO_PIN_OUTPUT mode)
GPIO_PIN_INVOUT    - invert output (ignored for GPIO_PIN_INPUT mode)
GPIO_PIN_PULSATE   - pulsate output (ignored for GPIO_PIN_INPUT mode)

tells you that the pin cannot be programmed as output.

There should also be new pin options, like:

GPIO_PIN_HIGHZ     - output can be tristated
GPIO_PIN_FLOAT     - pullups/pulldowns can be disabled

and corresponding operations

GPIOHIGHZ(struct gpio_req)
GPIOFLOAT(struct gpio_req)

                                Michael van Elst
Internet: mlelstv%serpens.de@localhost
                                "A potential Snark may lurk in every tree."

Home | Main Index | Thread Index | Old Index