Вы здесь

DlnGpioPinSetCfg() Function

The DlnGpioPinSetCfg() function changes the configuration of a single GPIO pin. It allows customizing the following:

  • Define the pin direction (input or output).

  • Enable or disable the open drain, pull up resistor and/or debounce filter.

  • Define the output value.

  • Define input event parameters.

With this function, you can either reconfigure the pin entirely or change only some of its parameters.

Syntax
C/C++
DLN_RESULT DlnGpioPinSetCfg(
   HDLN handle,
   uint16_t pin,
   uint16_t validFields,
   DLN_GPIO_PIN_CONFIG config
);
Parameters
handle

A handle to the DLN-series adapter.

pin

A pin that you want to configure.

validFields

A bit field that defines the configuration parameters that you want to update. Each of the 16 bits of validFields 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. You can also configure the pin parameters, using the constants declared in the dln_gpio.h file. If several constants are used, separate them with "| " (binary "or").Several bits are reserved for future use and must be set to 0.

BitsCorresponds toConstant

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 you set a bit to 0, the field will be ignored.For example, if you only need to change the isOutput and eventType settings, the validFields byte should look like this: 0000000100000010.You can configure the pin by using the constants declared in the dln_gpio.h file. In this case, the validFields byte should look like this:

C/C++
validFields
= DLN_GPIO_OUTPUT_BIT | DLN_GPIO_EVENT_TYPE_BIT;

config

A new configuration. See the DLN_GPIO_PIN_CONFIG structure for details.

Return Value
DLN_RES_SUCCESS (0x00)

The new configuration was successfully applied.

DLN_RES_INVALID_HANDLE (0x8F)

The specified handle is not valid.

DLN_RES_CONNECTION_LOST (0xA0)

The connection to the DLN server was interrupted.

DLN_RES_INVALID_PIN_NUMBER (0xAB)

The pin number is not valid. Use the DlnGpioGetPinCount() function to find the maximum possible pin number.

DLN_RES_NON_ZERO_RESERVED_BIT (0xAD)

One or more of the reserved bits validFields or config parameters are set to 1.

Remarks

The DlnGpioPinSetCfg() function is declared in the dln_gpio.h file.

Языки

Вход на сайт