USB-IO Interface Adapter GPIO-24. Programmers Reference Manual.


3.1.5. GPIO_SET_IN_CFG

Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
GPIO_SET _IN_CFG (0x05) ECHO PORT MASK PHASE DEBOUNCE REPEAT 0

The GPIO_SET_IN_CFG command configures input mode settings for specified IO pins.

IO pins have to be switched to input mode using the GPIO_SET_CFG command. GPIO_SET_IN_CFG command can be used prior to GPIO_SET_CFG. If IO pin is already in input mode, the settings are applied immediately.

Command is an 8-byte array of the following format:

Byte 0: GPIO_SET_IN_CFG (0x05)
This byte contains command identifier (command type). It should be set to 0x05.
Byte 1: ECHO
This byte can be used to associate a response received from GPIO-24 adapter with specific command. Response will contain exactly the same value in its echo byte.
Byte 2: PORT
GPIO PORT:
  • 0 - GPIO PORT A
  • 1 - GPIO PORT B
  • 2 - GPIO PORT C
Byte 3: MASK
Data mask to use when modifying IO pin configuration. The mask value allows modification of the specific pins, leaving rest of the pins unchanged. Only the pins with mask bit set to 1 will be affected.
Byte 4: PHASE
Phase configuration, which determines the conditions when GPIO-24 adapter sends GPIO_EV_IN event:
  • GPIO_IN_EV_NONE (0x00) - No events are sent for current pin. IO pin can still be switched to input mode using GPIO_SET_CFG command and the input values can be obtained using GPIO_GET_VAL command. DEBOUNCE and REPEAT values are ignored and will be reset to 0.
  • GPIO_IN_EV_LEV_0 (0x01) - Events are sent when pin has logical "0" on its input. If non-zero REPEAT value is specified, GPIO-24 adapter sends events every REPEAT * 100 ms. If REPEAT value is zero, GPIO_IN_EV_LEV_O is similar to GPIO_EV_FALLING (GPIO-24 adapter sends single event when input value changes from logical "1" to "0").
  • GPIO_IN_EV_LEV_1 (0x02) - Events are sent when pin has logical "1" on its input. If non-zero REPEAT value is specified, GPIO-24 adapter sends events every REPEAT * 100 ms. If REPEAT value is zero, GPIO_IN_EV_LEV_1 is similar to GPIO_EV_RISING (GPIO-24 adapter sends single event when input value changes from logical "0" to "1").
  • GPIO_IN_EV_RISING (0x03) - Events are sent when input value changes from logical "0" to "1". REPEAT value is ignored and will be reset to 0.
  • GPIO_IN_EV_FALLING (0x04) - Events are sent when input value changes from logical "1" to "0". REPEAT value is ignored and will be reset to 0.
  • GPIO_IN_EV_CHANGE (0x05) - Events are sent when input value of the pin changes. REPEAT value is ignored and will be reset to 0.
Byte 5: DEBOUNCE
To avoid sending of numerous events caused by contact bounce, GPIO-24 adapter only accepts signal change after the new value is stable. DEBOUNCE parameter specifies the debounce time in ms. If DEBOUNCE is equal to 0 GPIO-24 adapter sends event immediately.
Byte 6: REPEAT
Repeat interval in units of 100 ms. REPEAT value is used for pins with phase configuration set to GPIO_IN_EV_LEV_0 or GPIO_IN_EV_LEV_1 . It is ignored for pins with other phase configurations. If non-zero REPEAT value is specified, GPIO-24 adapter sends events each REPEAT*100 ms (while event condition exists). If REPEAT value is zero, GPIO-24 adapter sends single event when input value changes.
Byte 7: Reserved
This byte is reserved for future use and has to be set to 0.

For convenience GPIO_SET_IN_CFG_CMD structure is declared in reports.h file:

typedef struct _GPIO_SET_IN_CFG_CMD
{
   unsigned char id; //  = GPIO_SET_IN_CFG;
   unsigned char echo;
   unsigned char port;
   unsigned char mask;
   unsigned char phase;
   unsigned char debounce;
   unsigned char repeat;
   unsigned char reserved[1]; // must be 0
} __PACKED_ATTR GPIO_SET_IN_CFG_CMD, *PGPIO_SET_IN_CFG_CMD;

GPIO-24 adapter sends GPIO_SET_IN_CFG response after command execution.