GPIO Configuration (0x0C,0x41)

Description

Configures the user GPIO pins on the connector for use with several built-in functions or for general input or output.

Notes

GPIO pins are device-dependent. Some features are only available on certain pins. Some behaviors require specific configurations. Consult the device user manual for restrictions and default settings.

To avoid glitches on GPIOs configured as an output in a mode other than GPIO, always configure the relevant function before setting up the pin with this command. Otherwise, the pin state will be undefined between this command and the one to set up the feature. For input pins, use this command first so the state is well-defined when the feature is initialized.

Some configurations can only be active on one pin at a time. If such configuration is applied to a second pin, the second one will take precedence and the original pin's configuration will be reset.

Parameter Name Data Type Description
Field Length u8 7
Descriptor u8 0x41
Function Selector u8 This command supports the following MIP function selectors:
Write Read Save Load Default [WRSLD]
Pin [WRSLD] u8 GPIO pin number counting from 1. For save, load, and default function selectors, this can be 0 to select all pins.
Feature [W] u8 enum Determines how the pin will be used.
NameValueDescription
UNUSED0The pin is not used. It may be technically possible to read the pin state in this mode, but this is not guaranteed to be true of all devices or pins.
GPIO1General purpose input or output. Use this for direct control of pin output state or to stream the state of the pin.
PPS2Pulse per second input or output.
ENCODER3Motor encoder/odometer input.
TIMESTAMP4Precision Timestamping. Use with Event Trigger Configuration (0x0C,0x2E).
UART5UART data or control lines.
Behavior [W] u8 enum Select an appropriate value from the enumeration based on the selected feature (e.g. for PPS, select one of the values prefixed with PPS_.)
NameValueDescription
UNUSED0Use 0 unless otherwise specified.
GPIO_INPUT1Pin will be an input. This can be used to stream or poll the value and is the default setting.
GPIO_OUTPUT_LOW2Pin is an output initially in the LOW state. This state will be restored during system startup if the configuration is saved.
GPIO_OUTPUT_HIGH3Pin is an output initially in the HIGH state. This state will be restored during system startup if the configuration is saved.
PPS_INPUT1Pin will receive the pulse-per-second signal. Only one pin can have this behavior. This will only work if the PPS Source command is configured to GPIO.
PPS_OUTPUT2Pin will transmit the pulse-per-second signal from the device.
ENCODER_A1Encoder "A" quadrature input. Only one pin can have this behavior. The last command to set this behavior will take precedence.
ENCODER_B2Encoder "B" quadrature input. Only one pin can have this behavior. The last command to set this behavior will take precedence.
TIMESTAMP_RISING1Rising edges will be timestamped.
TIMESTAMP_FALLING2Falling edges will be timestamped.
TIMESTAMP_EITHER3Both rising and falling edges will be timestamped.
UART_PORT2_TX33(0x21) UART port 2 transmit.
UART_PORT2_RX34(0x22) UART port 2 receive.
UART_PORT3_TX49(0x31) UART port 3 transmit.
UART_PORT3_RX50(0x32) UART port 3 receive.
Pin Mode [W] u8 bitfield GPIO configuration. May be restricted depending on device, pin, feature, and behavior. See device user manual.
NameBit(s)Description
open_drain0The pin will be an open-drain output. The state will be either LOW or FLOATING instead of LOW or HIGH, respectively. This is used to connect multiple open-drain outputs from several devices. An internal or external pull-up resistor is typically used in combination. The maximum voltage of an open drain output is subject to the device maximum input voltage range found in the specifications.
pulldown1The pin will have an internal pull-down resistor enabled. This is useful for connecting inputs to signals which can only be pulled high such as mechanical switches. Cannot be used in combination with pull-up. See the device specifications for the resistance value.
pullup2The pin will have an internal pull-up resistor enabled. Useful for connecting inputs to signals which can only be pulled low such as mechanical switches, or in combination with an open drain output. Cannot be used in combination with pull-down. See the device specifications for the resistance value. Use of this mode may restrict the maximum allowed input voltage. See the device datasheet for details.
Ack/Nack Reply See standard MIP ack/nack reply format.
Response Data Data Type Description
Response Length u8 6
Response Descriptor u8 0xC1
Pin u8 GPIO pin number counting from 1. For save, load, and default function selectors, this can be 0 to select all pins.
Feature u8 enum Determines how the pin will be used.
NameValueDescription
UNUSED0The pin is not used. It may be technically possible to read the pin state in this mode, but this is not guaranteed to be true of all devices or pins.
GPIO1General purpose input or output. Use this for direct control of pin output state or to stream the state of the pin.
PPS2Pulse per second input or output.
ENCODER3Motor encoder/odometer input.
TIMESTAMP4Precision Timestamping. Use with Event Trigger Configuration (0x0C,0x2E).
UART5UART data or control lines.
Behavior u8 enum Select an appropriate value from the enumeration based on the selected feature (e.g. for PPS, select one of the values prefixed with PPS_.)
NameValueDescription
UNUSED0Use 0 unless otherwise specified.
GPIO_INPUT1Pin will be an input. This can be used to stream or poll the value and is the default setting.
GPIO_OUTPUT_LOW2Pin is an output initially in the LOW state. This state will be restored during system startup if the configuration is saved.
GPIO_OUTPUT_HIGH3Pin is an output initially in the HIGH state. This state will be restored during system startup if the configuration is saved.
PPS_INPUT1Pin will receive the pulse-per-second signal. Only one pin can have this behavior. This will only work if the PPS Source command is configured to GPIO.
PPS_OUTPUT2Pin will transmit the pulse-per-second signal from the device.
ENCODER_A1Encoder "A" quadrature input. Only one pin can have this behavior. The last command to set this behavior will take precedence.
ENCODER_B2Encoder "B" quadrature input. Only one pin can have this behavior. The last command to set this behavior will take precedence.
TIMESTAMP_RISING1Rising edges will be timestamped.
TIMESTAMP_FALLING2Falling edges will be timestamped.
TIMESTAMP_EITHER3Both rising and falling edges will be timestamped.
UART_PORT2_TX33(0x21) UART port 2 transmit.
UART_PORT2_RX34(0x22) UART port 2 receive.
UART_PORT3_TX49(0x31) UART port 3 transmit.
UART_PORT3_RX50(0x32) UART port 3 receive.
Pin Mode u8 bitfield GPIO configuration. May be restricted depending on device, pin, feature, and behavior. See device user manual.
NameBit(s)Description
open_drain0The pin will be an open-drain output. The state will be either LOW or FLOATING instead of LOW or HIGH, respectively. This is used to connect multiple open-drain outputs from several devices. An internal or external pull-up resistor is typically used in combination. The maximum voltage of an open drain output is subject to the device maximum input voltage range found in the specifications.
pulldown1The pin will have an internal pull-down resistor enabled. This is useful for connecting inputs to signals which can only be pulled high such as mechanical switches. Cannot be used in combination with pull-up. See the device specifications for the resistance value.
pullup2The pin will have an internal pull-up resistor enabled. Useful for connecting inputs to signals which can only be pulled low such as mechanical switches, or in combination with an open drain output. Cannot be used in combination with pull-down. See the device specifications for the resistance value. Use of this mode may restrict the maximum allowed input voltage. See the device datasheet for details.