The GPIO_SET_CFG command configures settings for pins of a GPIO port with values from Bytes 4-7. The GPIO port is specified in Byte 2 .
| Byte 0 | GPIO_SET_CFG | Command ID (0x01). |
| Byte 1 | ECHO | Echo to associate a command with the response. |
| Byte 2 | PORT | GPIO port. |
| Byte 3 | MASK | Data mask to use when modifying I/O pin
configuration. |
| Byte 4 | PIN 7,6 | Configuration settings for 7, 6 pins. |
| Byte 5 | PIN 5,4 | Configuration settings for 5, 4 pins. |
| Byte 6 | PIN 3,2 | Configuration settings for 3, 2 pins. |
| Byte 7 | PIN 1,0 | Configuration settings for 1, 0 pins. |
Command is an 8-byte array of the following format:
This byte contains command ID (command type). It should be set to 0x01.
This byte can be used to associate a response received from GPIO-24 adapter with a specific command. Response will contain exactly the same value in its echo byte.
GPIO port to configure:
0 – GPIO PORT A
1 – GPIO PORT B
2 – GPIO PORT C
Data mask which is used to modify GPIO port configuration. It is well known that a byte consists of 8 bits (which can be 0 or 1). This characteristic is used to create a mask. The mask value allows to modify certain pins, leaving rest of the pins unchanged. Note, that only the pins with mask bit set to 1 will be affected. The pins with mask bit set to 0 will leave unchanged.
Each nibble (four-bit aggregation or half an 8-bit byte) of bytes 4-7 contains configuration settings for a specific pin. The following values are supported:
GPIO_CFG_IN (0x0) – GPIO port 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 port is configured for output. Use GPIO_SET_OUT_VAL command to set output value;
GPIO_CFG_PWM (0x2) – GPIO port is configured for PWM (Pulse Width Modulation) output. Use GPIO_SET_PWM_CFG command to configure PWM setting;
GPIO_CFG_NOT_CONFIGURED (0xf) –
I/O port is not configured.
For convenience GPIO_SET_CFG_CMD structure is declared in reports.h file.
GPIO-24 adapter sends GPIO_SET_CFG response after command execution.
| Byte 0 | GPIO_SET_CFG | Response ID (0x01). |
| Byte 1 | ECHO | Echo to associate a command with the response. |
| Byte 2 | ST | Command execution status. |
| Bytes 3..7 | Reserved | Reserved. |
Response is an 8-byte array of the following format:
Response ID (response type). This byte will contain 0x01.
Echo byte copied from the corresponding command. It is used to associate the response with the specific command.
Status of the command execution:
GPIO_ST_SUCCESS (0x00) – The GPIO port was successfully configured;
GPIO_ST_INVALID_PORT (0x03) – Invalid port number has been specified;
GPIO_ST_INVALID_CFG (0x04) – Invalid configuration value has been specified in one or more PINS nibbles. These pins were left with their previous configurations. The correct configuration values were applied for other pins.
These bytes are reserved for future usage.
For convenience GPIO_SET_CFG_RSP structure is declared in reports.h file.