Skip to content
Lars Pötter edited this page Jun 23, 2013 · 1 revision

GPIO Extension

The GPIO extension is largely provided for experimentation. Most pins which are dedicated for a particular purpose (such as specific digital inputs or outputs) can be assigned by the client configuration to the standard fixed function device types.

However, there are times where it is useful to provide the host software with direct access to the dyamically configurable GPIO pin functionality. For instance, with the GPIO extension a single pin can be used as an analogue input, an analogue output, a PWM output, digital input, digital output or open drain input-output simply by changing its active configuration.

GPIO Pin Modes

The following is a list of currently defined GPIO pin modes:

Value Mode

0x01

High Impedance

0x02

Digital Input

0x03

Digital Output

0x04

Analog Input

0x05

Analog Output

0x06

PWM Output

0x07

Open Drain Input-Output (with pull-up).

Note: the Analog Output GPIO mode should not be advertise if the analogue output level is provided simply through a raw PWM signal (e.g., as on AVR-based Arduinos).

Any digital write, digital read or PWM write should use the standard Pacemaker functions for this purpose.

Extension Orders

Get GPIO Pin Supported Modes

This order returns the modes supported by the specified GPIO pin.

Table 1. Parameter
Byte Number Content

0

device number

Replies
  • OK: The reply parameter contains a list of supported GPIO Pin Modes (1 value per byte).

Set GPIO Pin Mode

This order sets a GPIO into the requested mode.

Table 2. Parameter
Byte Number Content

0

device number

1

mode

Replies
  • OK: The reply parameter contains no data.

  • Bad Parameter Value: the requested mode is not supported for the specified pin.

Analog Read

This order performs an analog read of a GPIO pin. The value read is mapped onto a 16-bit range.

Table 3. Parameter
Byte Number Content

0

device number

Replies
  • OK: The reply parameter contains the analog value read as a 2 byte integer.

  • Bad Parameter Value: the requested mode is not supported for the specified pin.

Analog Write

This order performs an analog write on a GPIO pin. The value to write is mapped into a 16-bit range regardless of the underlying device precision.

Table 4. Parameter
Byte Number Content

0

device number

1

analog value to write (MSB)

2

analog value to write (LSB)

This order can also be queued using the Queue Command Wrapper if the basic move extension is supported.

Replies
  • OK: The reply parameter contains no data.

  • Bad Parameter Value: the requested mode is not supported for the specified pin.