DLN_GPIO_PORT_SET_CFG Command and Response

The DLN_GPIO_PORT_SET_CFG command is used to change the configuration of the GPIO pins from the specified port and set the conditions of the DLN_GPIO_CONDITION_MET_EV event generation. Each pin is configured individually via the DLN_GPIO_PIN_CONFIG structure.

The mask parameter allows a user to reconfigure all of the pins from the specified port or only some of them. This parameter is a byte value. Each of the eight bits, contained in the byte, corresponds to a pin of the port. The new configuration will be applied only to the pins with their mask bits set to 1. The configuration of pins with mask bits set to 0 will remain unchanged.

For example, if we only need to reconfigure the first and the fourth pin, we should set the mask byte as follows: 00010010

The validFields parameter is 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. See DlnGpioPinSetCfg() for details.

DLN_GPIO_PORT_SET_CFG Command

Go to response

Syntax

C/C++
 typedef struct
 {
    DLN_MSG_HEADER header;	    	
    uint8_t port;			    	
    uint8_t mask;
    uint16_t validFields;
    DLN_GPIO_PORT_CONFIG config;	
 } __PACKED_ATTR	DLN_GPIO_PORT_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_PORT_SET_CFG_CMD structure.
msgId Identifies the message. For the DLN_GPIO_PORT_SET_CFG command it must be set to 0x0102. You can use the DLN_MSG_ID_GPIO_PORT_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.
port
A port whose pins will be configured.
mask
A bit field that defines, which I/O lines are to be configured. Each of the eight bits, contained in the byte, corresponds to a pin of the port. The new configuration will be applied only to the pins with their mask bits set to 1. The configuration of pins with mask bits set to 0 will remain unchanged.
validFields
A bit field that defines valid DLN_GPIO_PIN_CONFIG fields. See DlnGpioPinSetCfg() for details.
config
A configuration to be set. See DLN_GPIO_PORT_CONFIG structure for details.

DLN_GPIO_PORT_SET_CFG Response

Go to command

The adapter sends the DLN_GPIO_PORT_SET_CFG response after the DLN_GPIO_PORT_SET_CFG command execution. The result field informs a user if the settings were successfully applied.

Syntax

C/C++
 typedef struct
 {
    DLN_MSG_HEADER header;		
    uint8_t result;    
    uint16_t conflictedPin;				
 }	DLN_GPIO_PORT_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_PORT_SET_CFG_RSP structure.
msgId Contains the message id. For the DLN_GPIO_PORT_SET_CFG response it is set to 0x0102. The DLN_MSG_ID_GPIO_PORT_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_PORT_SET_CFG command DLN-series adapter can return the following result values:

Return Code Description
DLN_RES_SUCCESS Settings were successfully configured.
DLN_RES_INVALID_COMMAND_SIZE Size, specified in the size field does not correspond to the actual size of the command.
DLN_RES_SUCCESS The device ID was successfully retrieved.
DLN_RES_INVALID_PORT_NUMBER Invalid port number specified.
DLN_RES_INVALID_EVENT_TYPE nvalid event type specified.
DLN_RES_GPIO_PIN_IN_USE Pin is used by another module. The number of the pin is contained in the conflictedPin field.
DLN_RES_PIN_NOT_CONNECTED_TO_MODULE Pin is not connected to the GPIO module. The number of the pin is contained in the conflictedPin field.
conflictedPin

A number of the conflicted pin, if any. The pins are numbered throughout the whole device. Numbers 0 to 7 belong to port A, 8 to 15 belong to port B etc.

In case there are several conflicted pins, only the number of the first one will be returned. As soon as a user fixes the problem, they should send the DLN_GPIO_PORT_SET_CFG command once again, to see if there are any more conflicting pins.