The GPIO_GET_CFG command retrieves the configuration settings for all pins of particular GPIO port. The port number is specified in Byte 2.
| Byte 0 | GPIO_GET_CFG | Command ID (0x02). |
| Byte 1 | ECHO | Echo to associate a command with the response. |
| Byte 2 | PORT | GPIO port. |
| Bytes 3..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 0x02.
This byte is used to associate a response received from GPIO-24 adapter with a specific command. The 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
These bytes are reserved for future usage and must be set to 0.
For convenience GPIO_GET_CFG_CMD structure is declared in reports.h file.
GPIO-24 adapter sends GPIO_GET_CFG response after command execution. The configuration settings are specified inside the response.
| Byte 0 | GPIO_GET_CFG | Response ID (0x02). |
| Byte 1 | ECHO | Echo to associate a command with a response. |
| Byte 2 | ST | Command execution status. |
| Byte 3 | PORT | GPIO port. |
| 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. |
Response is an 8-byte array of the following format:
Response ID (response type). This byte will contain 0x02.
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 configuration settings were successfully retrieved;
GPIO_ST_INVALID_PORT (0x03)- Invalid port number has been specified.
GPIO PORT:
0 – GPIO PORT A;
1 – GPIO PORT B;
2 – GPIO PORT C.
Each nibble of bytes 4-7 contains configuration settings of a specific pin. The following values are supported:
GPIO_CFG_IN (0x0) – I/O pin is configured as a digital input;
GPIO_CFG_OUT (0x1) – I/O pin is configured as a digital output;
GPIO_CFG_PWM (0x2) – I/O pin is configured for PWM (Pulse Width Modulation) output;
GPIO_CFG_PULSE (0x3) – I/O pin is configured to send single pulses. Use GPIO_GET_PIN_CFG
command to retrieve settings for current pin. Byte 5 of the
GPIO_GET_PIN_CFG response
contains extended configuration settings;
GPIO_CFG_ADC (0x4) – I/O pin is used by ADC module. Use GPIO_GET_PIN_CFG
command to retrieve settings for current pin. Byte 5 of the
GPIO_GET_PIN_CFG response
contains extended configuration settings;
GPIO_CFG_CMP (0x5) – I/O pin is used by comparator module.
Use GPIO_GET_PIN_CFG
command to retrieve settings for current pin. Byte 5 of the
GPIO_GET_PIN_CFG response
contains extended configuration settings;
GPIO_CFG_FR_CNT (0x6) – I/O pin is used by frequency
counter;
GPIO_CFG_PLS_CNT (0x7) – I/O pin is used by pulse counter;
GPIO_CFG_HPWM (0x8) – I/O pin is configured for HPWM (High Frequency Pulse Width
Modulation) output;
GPIO_CFG_NOT_CONFIGURED (0xf) –
I/O pin is not configured.
For convenience GPIO_GET_CFG_RSP structure is declared in reports.h file.