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


3.1.3. GPIO_SET_OUT_VAL

Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7
GPIO_ SET_OUT _VAL (0x03) ECHO PORT MASK VAL 0 0 0

The GPIO_SET_OUT_VAL command sets output values for all pins of particular I/O port. Port number is specified in Byte 2. Only pins with corresponding mask bit set to 1 will be affected.

IO pins have to be switched to output mode using the GPIO_SET_CFG command. GPIO_SET_OUT_VAL command can be used prior to GPIO_SET_CFG to preset output values before switching the pin to output mode. If IO pin is already in output mode, the output value is applied immediately.

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

Byte 0: GPIO_SET_OUT_VAL (0x03)
This byte contains command identifier (command type). It should be set to 0x03.
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 I/O pin output values. 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: VAL
Bits of this byte are output values to be set on the corresponding pins.
Byte 5..7: Reserved
These bytes are reserved for future use and have to be set to 0.

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

typedef struct _GPIO_SET_OUT_VAL_CMD
{
   unsigned char id; //  = GPIO_SET_OUT_VAL_CMD;
   unsigned char echo;
   unsigned char port;
   unsigned char mask;
   unsigned char val;
   unsigned char reserved[3]; // must be 0
} __PACKED_ATTR GPIO_SET_OUT_VAL_CMD, *PGPIO_SET_OUT_VAL_CMD;

GPIO-24 adapter sends GPIO_SET_OUT_VAL response after command execution.