DLN_GPIO_PIN_SET_CFG Command and Response
The DLN_GPIO_PIN_SET_CFG command is used to change the configuration of a single GPIO pin and set the conditions of DLN_GPIO_EVENT generation.
DLN_GPIO_PIN_SET_CFG Command
typedef struct
{
DLN_MSG_HEADER header;
uint16_t pin;
uint16_t validFields;
DLN_GPIO_PIN_CONFIG config;
} __PACKED_ATTR DLN_GPIO_PIN_SET_CFG_CMD;
Parameters:
- header
-
Defines the DLN message header DLN_MSG_HEADER. The header contains several predefined fields and is used to identify and route messages. You must fill the following fields before sending the command:
Field Description size The size of the message. Must be equal to the size of the DLN_GPIO_PIN_SET_CFG_CMD structure. msgId Identifies the message. For the DLN_GPIO_PIN_SET_CFG command it must be set to 0x0109. You can use the DLN_MSG_ID_GPIO_PIN_SET_CFG constant. echoCounter Can be used to link a command to a response. The response will have the same echoCounter value. This field can be any numerical value from 0 to 0xFFFF (65536). handle A handle to the DLN-series adapter. - pin
- A pin to be configured.
- validFields
A bit field that defines the configuration parameters to be updated by this function. Each of the 16 validFields bits corresponds to a specific parameter in the DLN_GPIO_PIN_CONFIG structure. If you set the bit to 1, the new configuration parameter will be applied. If you set the bit to 0, the configuration parameter will remain unchanged regardless of its value in the DLN_GPIO_PIN_CONFIG structure. A user can also configure the pin parameters, using the constants, defined in the
dln_gpio.hfile. If several constant are used, they should be separated with "| " (binary "or").Several bits are reserved for future use and must be set to 0.
Bit Corresponds to Constant 0 Bit 0 of DLN_GPIO_PIN_CONFIG::cfg DLN_GPIO_ENABLE_BIT 1 Bit 1 of DLN_GPIO_PIN_CONFIG::cfg DLN_GPIO_OUTPUT_BIT 2 Bit 2 of DLN_GPIO_PIN_CONFIG::cfg DLN_GPIO_OUTPUT_VAL_BIT 3 Bit 3 of DLN_GPIO_PIN_CONFIG::cfg DLN_GPIO_OPEN_DRAIN_BIT 4 Bit 4 of DLN_GPIO_PIN_CONFIG::cfg DLN_GPIO_PULL_UP_BIT 5 Bit 5 of DLN_GPIO_PIN_CONFIG::cfg DLN_GPIO_DEBOUNCE_BIT 6 Reserved 7 Reserved 8 DLN_GPIO_PIN_CONFIG::eventType DLN_GPIO_EVENT_TYPE_BIT 9 DLN_GPIO_PIN_CONFIG::eventPeriod DLN_GPIO_EVENT_PERIOD_BIT 10 Reserved 11 Reserved 12 Reserved 13 Reserved 14 Reserved 15 Reserved In order to include a configuration field in the operation, set the corresponding bit to 1. If we set a bit to 0, the field will be ignored.
For example, if we only need to change
isOutputand eventType settings, ourvalidFieldsbyte should look like this:0000000100000010.A user can configure the pin using the constants, defined in the
dln_gpio.hfile. In this case, thevalidFieldsbyte should look like this:validFields = DLN_GPIO_OUTPUT_BIT | DLN_GPIO_EVENT_TYPE_BIT;- config
- A configuration to be set. See "DLN_GPIO_PIN_CONFIG" structure for details.
DLN_GPIO_PIN_SET_CFG Response
The adapter sends the DLN_GPIO_PIN_SET_CFG response after the DLN_GPIO_PIN_SET_CFG command execution. The response will contain the retrieved device ID number.
typedef struct
{
DLN_MSG_HEADER header;
DLN_RESULT result;
uint_16t conflict
} __PACKED_ATTR DLN_GPIO_PIN_SET_CFG_RSP;
Parameters:
- header
-
Defines the DLN message header DLN_MSG_HEADER. The response header contains the following fields:
Field Description size The size of the message. It is equal to the size of the DLN_GPIO_PIN_SET_CFG_RSP structure. msgId Contains the message id. For the DLN_GPIO_PIN_SET_CFG response it is set to 0x0109. The DLN_MSG_ID_GPIO_PIN_SET_CFG constant can be used to check the message ID. echoCounter Links a command to a response. The echoCounter value is copied from the respective command header. handle A handle to the DLN-series adapter. You can use the handle field to determine the adapter that have sent the response. - result
-
Contains the result of the command execution. For DLN_GPIO_PIN_SET_CFG command DLN-series adapter can return the following result values:
Return Code Description DLN_RES_SUCCESS New configuration has been successfully applied. DLN_RES_INVALID_HANDLE Specified handle is not valid. DLN_RES_SUCCESS Connection to the DLN server was interrupted; DLN_RES_SUCCESS Number of the pin is out of range. Use DlnGpioGetPinCount() function to get the number of pins available for the current DLN adapter. DLN_RES_SUCCESS One or more of the reserved bits in validFields or in config parameters are set to 1. - conflict
- Contains the set of unsupported bits, which intersect with the validFields parameter.
2006-2012