DlnGpioPinSetCfg() Function

 DLN_RESULT DlnGpioPinSetcfg(
    HDLN handle,
    uint16_t pin,
    uint16_t validFields,
    DLN_GPIO_PIN_CONFIG config
 );

The DlnGpioPinSetCfg() function changes the configuration of a single GPIO pin.

With this function you can either reconfigure the pin entirely or change only some of its parameters. This is what the validFields parameter is for.

Parameters:

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.h file. 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 isOutput and eventType settings, our validFields byte should look like this: 0000000100000010.

A user can configure the pin using the constants, defined in the dln_gpio.h file. In this case, the validFields byte 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.html">DLN_GPIO_PIN_CONFIG structure for details.

Results:

Result Description
DLN_RES_SUCCESS The new configuration has been successfully applied.
DLN_RES_INVALID_HANDLE The specified handle is not valid.
DLN_RES_CONNECTION_LOST The connection to the DLN server was interrupted.
DLN_RES_INVALID_PIN_NUMBER The number of the pin is out of range. Use DlnGpioGetPinCount() function to get the available number of pins for your DLN-series adapter.
DLN_RES_NON_ZERO_RESERVED_BIT One or more of the reserved bits in validFields or config parameters are set to 1.

This function is defined in the dln_gpio.h file.