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


3.1.1. GPIO_SET_CFG

Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
GPIO_SET _CFG (0x01) ECHO PORT MASK PIN 7,6 PIN 5,4 PIN 3,2 PIN 1,0

The GPIO_SET_CFG command configures GPIO port specified in Byte 2 with values from Bytes 4-7. Only pins with corresponding mask bit set to 1 will be affected.

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

Byte 0: GPIO_SET_CFG (0x01)
This byte contains command identifier (command type). It should be set to 0x01.
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 to configure:
  • 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..7: PINS
Each nibble of bytes 4-7 contains configuration settings for specific pin ( Figure 3.1, “Configuration settings for specific pin” ).

The following values are supported:

  • GPIO_CFG_IN (0x0) - GPIO pin is configured for input. GPIO-24 adapter can send events when input level is changed. Use GPIO_SET_IN_CFG command to configure event generation.
  • GPIO_CFG_OUT (0x1) - GPIO pin is configured for output. Use GPIO_SET_OUT_VAL command to set output value.
  • GPIO_CFG_PWM (0x2) - GPIO pin is configured for PWM (pulsed) output. Use GPIO_SET_PWM_CFG command to configure PWM setting.

Figure 3.1. Configuration settings for specific pin

Configuration settings for specific pin

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

typedef struct _GPIO_SET_CFG_CMD
{
   unsigned char id; //  = GPIO_SET_CFG;
   unsigned char echo;
   unsigned char port;
   unsigned char mask;
   unsigned char pins[4];
} __PACKED_ATTR GPIO_SET_CFG_CMD, *PGPIO_SET_CFG_CMD;

GPIO-24 adapter sends GPIO_SET_CFG response after command execution.