The GPIO_SET_OUT_VAL command sets output values for all
pins of particular I/O port (Byte 2: PORT).
If you want to change values on certain pins use a mask (Byte 3: MASK). 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.
I/O pins can be switched to output mode with the help of 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 I/O pin is already in output
mode, the output value is applied immediately.
| Byte 0 | GPIO_SET_OUT_VAL | Command ID (0x03). |
| Byte 1 | ECHO | Echo to associate a command with the response. |
| Byte 2 | PORT | Command execution status. |
| Byte 3 | MASK | Data mask to use while modifying I/O pin
output values. |
| Byte 4 | VAL | Bits of this byte are output values to be set on the corresponding pins. |
| Bytes 5..7 | Reserved | Reserved (must be 0). |
Command is an 8-byte array of the following format:
This byte contains command ID (command type). It should be set to 0x03.
This byte is used to associate a response received from GPIO-24 adapter with specific command. Response will contain exactly the same value in its echo byte.
GPIO PORT:
0 – GPIO PORT A
1 – GPIO PORT B
2 – GPIO PORT C
Data mask to use when modifying I/O pin output
values. 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.
Bits of this byte are output values to be set on the corresponding pins.
These bytes are reserved for future usage and must be set to 0.
For convenience GPIO_SET_OUT_VAL_CMD structure is declared in reports.h file.
GPIO-24 adapter sends GPIO_SET_OUT_VAL response after command execution.
| Byte 0 | GPIO_SET_OUT_VAL | Response ID (0x20). |
| 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 0x03.
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 I/O pins output values were successfully
configured.
GPIO_ST_INVALID_PORT (0x03) – Invalid port number has been specified.
These bytes are reserved for future usage.
For convenience GPIO_SET_OUT_VAL_RSP structure is declared in reports.h file.