DlnGpioPinSetDirection() Function

The DlnGpioPinSetDirection() function configures a pin as an input or as an output.

Syntax
C/C++
DLN_RESULT DlnGpioPinSetDirection(
    HDLN handle,
    uint8_t pin,
    uint8_t direction
 );
Parameters
handle

A handle to the DLN-series adapter.

pin

A number of the GPIO pin that you want to configure.

direction

Direction of a pin. Set to 0 for input or 1 for output.

Return Value
DLN_RES_SUCCESS (0x00)

The pin direction has been successfully retrieved.

DLN_RES_INVALID_PIN_NUMBER (0xAB)

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

Remarks

By default, The GPIO pin is defined as an input. You can check the current pin direction by using the DlnGpioPinGetDirection() function.

If the pin is not currently assigned to the GPIO module, the pin direction setting is not lost. It is saved in internal memory. Later, when you assign this pin to the GPIO module by using the DlnGpioPinEnable() function, the pin direction will be applied.

The DlnGpioPinSetDirection() function is declared in dln_gpio.h file.