GPIO Interface Functions

Use the GPIO Interface functions to control and monitor the GPIO module of a DLN-series adapter.

General pin information:

DlnGpioGetPinCount()

Retrieves the number of pins that can be assigned to the GPIO module.

DlnGpioPinEnable()

Assigns a pin to the GPIO module.

DlnGpioPinDisable()

Unassigns a pin from the GPIO module.

DlnGpioPinIsEnabled()

Retrieves whether a pin is connected to the GPIO module.

DlnGpioPinSetDirection()

Configures a pin as a digital input or output.

DlnGpioPinGetDirection()

Retrieves whether a pin is configured as a digital input or output.

DlnGpioPinSetOutVal()

Defines a value on the output pin.

DlnGpioPinGetOutVal()

Retrieves the output value configured to the pin.

DlnGpioPinGetVal()

Retrieves the actual value on the I/O line.

Event functions:

DlnGpioPinSetEventCfg()

Configures event generation for a pin.

DlnGpioPinGetEventCfg()

Retrieves event generation configuration for a pin.

DlnGpioPinGetSupportedEventTypes()

Returns the list of the event types available for a pin.

Debounce filter functions:

DlnGpioPinDebounceEnable()

Enables the Debounce Filter on a pin.

DlnGpioPinDebounceDisable()

Disables the Debounce Filter on a pin

DlnGpioPinDebounceIsEnabled()

Determines whether the Debounce Filter is enabled on a pin.

DlnGpioSetDebounce()

Configures the debounce interval (the minimum duration of pulses to be registered).

DlnGpioGetDebounce()

Retrieves the debounce interval value.

Open Drain mode functions:

DlnGpioPinOpendrainEnable()

Enables the Open Drain mode on a pin.

DlnGpioPinOpendrainDisable()

Disables the Open Drain mode on a pin.

DlnGpioPinOpendrainIsEnabled()

Determines whether the Open Drain mode in enabled on a pin.

Pull-up/Pull-down resistors functions:

DlnGpioPinPullupEnable()

Enables the pull-up resistor on a pin.

DlnGpioPinPulldownEnable()

Enables the pull-down resistor on a pin.

DlnGpioPinPullupDisable()

Disables the pull-up resistor on a pin.

DlnGpioPinPulldownDisable()

Disables the pull-down resistor on a pin.

DlnGpioPinPullupIsEnabled()

Determines whether the pull-up resistor is enabled on a pin.

DlnGpioPinPulldownIsEnabled()

Determines whether the pull-down resistor is enabled on a pin.

The dln_gpio.h file declares the GPIO Interface functions.

Rating: 
Голосов пока нет

DlnGpioGetPinCount() Function

The DlnGpioGetPinCount() function retrieves the total number of GPIO pins available in the DLN-series adapter.

Syntax
C/C++
DLN_RESULT DlnGpioGetPinCount(
    HDLN handle,
    uint16_t* count
 );
Parameters
handle

A handle to a DLN-series adapter.

count

A pointer to an unsigned 16-bit integer that receives the number of available GPIO pins.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the GPIO pin count.

Remarks

The DlnGpioGetPinCount() function retrieves the number of pins that can be configured as GPIO. Even the pins that are assigned for other modules (but can be configured as GPIO) will be counted. To check whether a pin is connected to the GPIO module, use the DlnGpioPinIsEnabled() function.

The GPIO functions that accept a pin number as a parameter will return the DLN_RES_INVALID_PIN_NUMBER error code if the specified pin number exceeds the value returned by the DlnGpioGetPinCount() function.

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

DlnGpioPinEnable() Function

The DlnGpioPinEnable() function connects a pin to the GPIO module.

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

A handle to a DLN-series adapter.

pin

A number of the pin that you want to configure.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully connected the pin to the GPIO module.

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_PIN_IN_USE (0xA5)

Another module uses the pin and the GPIO module cannot use it. Use the DlnGetPinCfg()function to get the name of module using the pin.

Remarks

If you have not changed the configuration settings for the pin which you want to configure as a GPIO, it will have the default configuration. See Digital Input Events for details.

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

DlnGpioPinDisable() Function

The DlnGpioPinDisable() function disconnects a pin from the GPIO module. Then, another module can use the pin.

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

A handle to a DLN-series adapter.

pin

A number of the pin that you want to configure.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully disconnected the pin from the GPIO module.

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_PIN_NOT_CONNECTED_TO_MODULE (0xAA)

The GPIO module does not use the pin, so the pin cannot be disconnected from the module.

Remarks

When you use the DlnGpioPinDisable() function, the pin configuration settings are not lost. They are saved in the internal memory. Later, if you reassign this pin to the GPIO module by using the DlnGpioPinEnable() function, the pin configuration is restored.

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

DlnGpioPinIsEnabled() Function

The DlnGpioPinIsEnabled() function informs whether the GPIO module currently uses the pin.

Syntax
C/C++
DLN_RESULT DlnGpioPinIsEnabled(
   HDLN handle,
   uint8_t pin, 
   uint8_t* enabled
);
Parameters
handle

A handle to a DLN-series adapter.

pin

A number of the pin that you want to check.

enabled

A pointer to an unsigned 8-bit integer. After the function execution, this integer is set to one of the following values:

ValueDescription

1

The pin is configured as GPIO.

0

The pin is NOT configured as GPIO.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the pin information.

DLN_RES_INVALID_PIN_NUMBER ( 0xAB)

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

Remarks

To connect the pin with the GPIO module, use the DlnGpioPinEnable() function. To disconnect the pin assigned to the GPIO module, call the DlnGpioPinDisable() function.

To check which module uses the pin, use the DlnGetPinCfg()function.

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

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.

DlnGpioPinGetDirection() Function

The DlnGpioPinGetDirection() function retrieves current direction of a GPIO pin.

Syntax
C/C++
DLN_RESULT DlnGpioPinGetDirection(
   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 check.

direction

A pointer to an unsigned 8-bit integer. After the function execution, the integer will be filled with the pin current direction. Possible values:

ValueDescription

1

The pin is an output.

0

The pin is an input.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the pin direction.

DLN_RES_INVALID_PIN_NUMBER (0xAB)

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

Remarks

If the pin is not currently assigned to the GPIO module, the pin direction setting is got from internal memory where it is saved when you define it. To change the current pin direction, use the DlnGpioPinSetDirection() function.

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

DlnGpioPinGetVal() Function

The DlnGpioPinGetVal() function retrieves the current value on the specified GPIO pin.

Syntax
C/C++
DLN_RESULT DlnGpioPinGetVal(
   HDLN handle, 
   uint8_t pin,
   uint8_t* value
);
Parameters
handle

A handle to the DLN-series adapter.

pin

A number of the pin which value you want to know.

value

A pointer to an unsigned 8-bit integer. After the function execution, this integer will be set to the pin value.

Return Value
DLN_RES_SUCCESS (0x00)

The function retrieved the current pin value successfully.

DLN_RES_INVALID_PIN_NUMBER (0xAB)

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

Remarks

The DlnGpioPinGetVal() function retrieves the value on the pin regardless of its direction. To check the GPIO pin direction, use the DlnGpioPinGetDirection() function. You can change the pin output value by using the DlnGpioPinSetOutVal() function.

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

DlnGpioPinSetOutVal() Function

The DlnGpioPinSetOutVal() function sets the output value for the specified GPIO pin.

Syntax
C/C++
DLN_RESULT DlnGpioPinSetOutVal(
   HDLN handle,
   uint8_t pin, 
   uint8_t value
);
Parameters
handle

A handle to the DLN-series adapter.

pin

A number of the pin that you want to configure.

value

A pin output value to be set.

Return Value
DLN_RES_SUCCESS (0x00)

The pin output value was successfully applied.

DLN_RES_INVALID_PIN_NUMBER (0xAB)

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

Remarks

If the specified pin is an output, the value is applied immediately. If the pins is an input or is not assigned to the GPIO module, the value is stored in the internal memory. The stored value will be applied when the pin becomes output.The DlnGpioPinSetOutVal() function is declared in the dln_gpio.h file.

DlnGpioPinGetOutVal() Function

The DlnGpioPinGetOutVal() function retrieves the pin output value.

Syntax
C/C++
DLN_RESULT DlnGpioPinGetOutVal(
    HDLN handle,
    uint8_t pin, 
    uint8_t* value
 );
Parameters
handle

A handle to the DLN-series adapter.

pin

A number of the pin which output value you want to know.

value

A pointer to an unsigned 8-bit integer. After the function execution, this integer is filled with the pin output value.

Return Value
DLN_RES_SUCCESS (0x00)

The function retrieved the pin output value successfully.

DLN_RES_INVALID_PIN_NUMBER (0xAB)

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

Remarks

The default pin output value is 0. By using the DlnGpioPinSetOutVal() function you can change the output value. If the specified pin is not assigned to the GPIO module or is not an output, the DlnGpioPinGetOutVal() function takes the output value from the internal memory, where it is saved.

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

DlnGpioPinSetEventCfg() Function

The DlnGpioPinSetEventCfg() function configures when and which events should be generated for the specified pin. For more information, read Digital Input Events.

Syntax
C/C++
DLN_RESULT DlnGpioPinSetEventCfg(
   HDLN handle,
   uint8_t pin,
   uint8_t eventType,
   uint16_t eventPeriod
);
Parameters
handle

A handle to the DLN-series adapter.

pin

A number of the pin for which you want to configure the event generation.

eventType

Defines when the DLN adapter should generate pin events. The following values are available:

ValueDescription

0 or DLN_GPIO_EVENT_NONE

The DLN adapter does not generate any events.

1 or DLN_GPIO_EVENT_CHANGE

The DLN adapter generates events when the level on the digital input line changes. For details, read DLN_GPIO_EVENT_CHANGE Events

2 or DLN_GPIO_EVENT_LEVEL_HIGH

The DLN adapter generates events when the high level is present on the digital input line or after transition from low to high level. For details, read DLN_GPIO_EVENT_LEVEL_HIGH Events

3 or DLN_GPIO_EVENT_LEVEL_LOW

The DLN adapter generates events when the low level is present on the digital input line or after transition from high to low level. For details, read DLN_GPIO_EVENT_LEVEL_LOW Events

4 or DLN_GPIO_EVENT_ALWAYS

The DLN adapter generates events continuously, regardless of the level. For details, read DLN_GPIO_EVENT_ALWAYS Events

eventPeriod

Defines the interval in milliseconds (ms) at which the events occur.

Return Value
DLN_RES_SUCCESS (0x00)

The function configured event settings successfully.

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_INVALID_EVENT_TYPE (0xA9)

The specified event type is not valid. Use the DlnGpioPinGetSupportedEventTypes() function to check the event types supported for the pin.

DLN_RES_INVALID_EVENT_PERIOD (0xAC)

The specified event period is not valid.

Remarks
The DLN-1 adapters do not support GPIO events.

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

DlnGpioPinGetEventCfg() Function

The DlnGpioPinGetEventCfg() function retrieves the current event configuration for the specified pin. For more information, read Digital Input Events.

Syntax
C/C++
DLN_RESULT DlnGpioPinGetEventCfg(
   HDLN handle, 
   uint8_t pin, 
   uint8_t* eventType,
   uint16_t* eventPeriod
);
Parameters
handle

A handle to the DLN-series adapter.

pin

A number of the pin that you want to check.

eventType

A pointer to an unsigned 8-bit integer. After the function execution, this integer is set to the current event configuration of the pin.

eventPeriod

A pointer to an unsigned 16-bit integer. After the function execution, this integer is set to the interval at which the specified events occur.

Return Value
DLN_RES_SUCCESS (0x00)

The function retrieved the event configuration successfully.

DLN_RES_INVALID_PIN_NUMBER (0xAB)

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

Remarks
GPIO events are by the DLN-1 adapters.

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

DlnGpioPinGetSupportedEventTypes() Function

The DlnGpioPinGetSupportedEventTypes() function returns all event types supported for the specified pin.

Syntax
C/C++
DLN_RESULT DlnGpioPinGetSupportedEventTypes(
    HDLN handle, 
    uint16_t pin, 
    DLN_GPIO_PIN_EVENT_TYPES* supportedEventTypes
);
Parameters
handle

A handle to the DLN-series adapter.

pin

A number of the pin for which you want to get the information.

supportedEventTypes

The pointer to the DLN_GPIO_PIN_EVENT_TYPES structure that is filled by the supported event types. After the function execution, the structure fields include the following information:

FieldDescription

count

The number of available event types.

eventTypes[8]

An 8-element array. Each element corresponds to one of the supported event types.

Return Value
DLN_RES_SUCCESS (0x00)

The function was successful.

DLN_RES_INVALID_PIN_NUMBER (0xAB)

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

Remarks
The DLN-1 adapters do not support GPIO events.

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

DlnGpioPinDebounceEnable() Function

The DlnGpioPinDebounceEnable() function enables Debounce Filter for the specified pin.

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

A handle to the DLN-series adapter.

pin

A number of the pin that you want to configure.

Return Value
DLN_RES_SUCCESS ( 0x00)

The function activated the debounce filter successfully.

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_COMMAND_NOT_SUPPORTED (0x91)

The adapter does not support debounce filtering.

Remarks

You can use the DlnGpioPinDebounceEnable() function regardless of whether or not the specified pin is connected to the GPIO module. For a disconnected pin, the debounce filter configuration is saved in the internal memory. This value will be applied when the pin is connected to the GPIO module.

The debounce filter feature is not supported by DLN-1 and DLN-2 adapters.

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

DlnGpioPinDebounceDisable() Function

The DlnGpioPinDebounceDisable() disables Debounce Filter for the specified pin.

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

A handle to the DLN-series adapter.

pin

A number of the pin that you want to configure.

Return Value
DLN_RES_SUCCESS (0x00)

The function deactivated debounce filter successfully.

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_COMMAND_NOT_SUPPORTED (0x91)

The adapter does not support debounce filtering.

Remarks
The DLN-1 and DLN-2 adapters do not support the debounce filter feature.

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

DlnGpioPinDebounceIsEnabled() Function

The DlnGpioPinDebounceIsEnabled() function informs whether the Debounce Filter is currently enabled for the specified pin.

Syntax
C/C++
DLN_RESULT DlnGpioPinOpendrainIsEnabled(
   HDLN handle,
   uint8_t pin,
   uint8_t* enabled
);
Parameters
handle

A handle to the DLN-series adapter.

pin

A number of the pin that you want to check.

enabled

A pointer to an unsigned 8-bit integer. After the function execution, this parameter is set to one of the following values:

ValueDescription

1

Debounce filtering is active.

0

Debounce filtering is not active.

Return Value
DLN_RES_SUCCESS (0x00)

The function retrieves the debounce filter settings successfully.

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_COMMAND_NOT_SUPPORTED (0x91)

The adapter does not support debounce filtering.

Remarks

The DlnGpioPinDebounceIsEnabled() function returns whether or not the debounce filtering feature is enabled for the specified pin. To enable this feature, use the DlnGpioPinDebounceEnable() function. To disable this feature, use the DlnGpioPinDebounceDisable() function. To specify the debounce interval, use the DlnGpioSetDebounce() function (See Debounce Filter for details).

DLN-1, DLN-2 adapters do not support the debounce filter feature.

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

DlnGpioSetDebounce() Function

The DlnGpioSetDebounce() function specifies the debounce interval (the minimum duration of pulses to be registered). See Debounce Filter for details.

Syntax
C/C++
DLN_RESULT DlnGpioSetDebounce(
   HDLN handle, 
   uint32_t* duration
);
Parameters
handle

A handle to the DLN-series adapter.

duration

A pointer to an unsigned 32-bit integer. After the function execution, this integer is set to the debounce duration, rounded up to the nearest value supported by the adapter. See Debounce Filter for details.

Return Value
DLN_RES_SUCCESS (0x00)

The function specified the debounce interval successfully.

DLN_RES_COMMAND_NOT_SUPPORTED (0x91)

The adapter does not support debounce filtering.

Remarks

The specified debounce interval is actual for all pins where the debounce filter is enabled. This value should be specified in microseconds (µs): from 1µs up to 4,294,967,295µs (~1h 10m). If a DLN-series adapter does not support the specified value, it rounds it up to the nearest supported value.

The default value of the debounce interval depends on the DLN adapter. Once you call the DlnGpioSetDebounce() function and specify the debounce interval value, you change the default value. If the debounce filter is disabled for a pin or a pin is not assigned to the GPIO module, this value will be applied when the pin is assigned to the GPIO module with the debounce filter enabled.

DLN-1 and DLN-2 adapters do not support the debounce filter feature.

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

DlnGpioGetDebounce() Function

The DlnGpioGetDebounce() function retrieves the current value of the debounce interval (the minimum duration of the pulse to be registered). See Debounce Filter for details.

Syntax
C/C++
DLN_RESULT DlnGpioGetDebounce(
   HDLN handle, 
   uint32_t* duration
);
Parameters
handle

A handle to the DLN-series adapter.

duration

A pointer to an unsigned 32-bit integer. After the function executed, this integer is set to the debounce interval value.

Return Value
DLN_RES_SUCCESS (0x00)

The function retrieved the debounce interval successfully.

DLN_RES_COMMAND_NOT_SUPPORTED (0x91)

The adapter does not support debounce filtering.

Remarks

The debounce interval is actual for all GPIO pins with the enabled debounce filter. To change the debounce interval value, use the DlnGpioSetDebounce() function.

DLN-1 and DLN-2 adapters do not support the debounce filter feature.

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

DlnGpioPinOpendrainEnable() Function

The DlnGpioPinOpendrainEnable() function enables Open Drain Mode for the specified pin.

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

A handle to the DLN-series adapter.

pin

A number of the pin that you want to configure.

Return Value
DLN_RES_SUCCESS (0x00)

The function enabled the open drain mode successfully.

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 Open Drain Mode is disabled for all GPIO pins. The DlnGpioPinOpendrainEnable() function enables the Open Drain Mode for the specified pin. If the pin is not assigned to the GPIO module, this configuration will be saved in the internal memory. When you assign the pin to the GPIO module, the saved configuration will be applied.

DLN-1 and DLN-2 adapters do not support the Open Drain mode.

The DlnGpioPinOpendrainEnable() function is defined in the dln_gpio.h file.

DlnGpioPinOpendrainDisable() Function

The DlnGpioPinOpendrainDisable() disables Open Drain Mode for the specified pin.

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

A handle to the DLN-series adapter.

pin

A number of the pin that you want to configure.

Return Value
DLN_RES_SUCCESS (0x00)

The function disabled the open drain mode successfully.

DLN_RES_INVALID_PIN_NUMBER (0xAB)

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

Remarks

The DlnGpioPinOpendrainDisable() function disables the Open Drain Mode for the specified pin. If the pin is not assigned to the GPIO module, this configuration will be saved in the internal memory. When you assign the pin to the GPIO module, the saved configuration will be applied.

Most pins of DLN-1 and DLN-2 adapters do not support the Open Drain mode.

The DlnGpioPinOpendrainDisable() function is defined in the dln_gpio.h file.

DlnGpioPinOpendrainIsEnabled() Function

The DlnGpioPinOpendrainIsEnabled() function informs whether the pin output is currently configured as push-pull or Open Drain.

Syntax
C/C++
DLN_RESULT DlnGpioPinOpendrainIsEnabled(
   HDLN handle,
   uint8_t pin,
   uint8_t* enabled
);
Parameters
handle

A handle to the DLN-series adapter.

pin

A number of the pin that you want to check.

enabled

A pointer to an unsigned 8-bit integer. After the function execution, this integer is set to the current pin configuration. The following values are available:

ValueDescription

1

The output is Open Drain.

0

The output is push-pull.

Return Value
DLN_RES_SUCCESS (0x00)

The function retrieved the open drain mode configuration successfully.

DLN_RES_INVALID_PIN_NUMBER (0xAB)

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

Remarks
Most pins of DLN-1 and DLN-2 adapters do not support the Open Drain mode.

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

DlnGpioPinPullupEnable() Function

The DlnGpioPinPullupEnable() function activates an embedded pull-up resistor for the specified pin. For more information, read Pull-up/Pull-down Resistors.

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

A handle to the DLN-series adapter.

pin

A number of the pin for which you want to enable a pull-up resistor.

Return Value
DLN_RES_SUCCESS (0x00)

The function activated the pull-up resistor successfully.

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 pull-up resistors are active for GPIO pins. You can change this configuration by using the DlnGpioPinPullupDisable() function. To check the current configuration setting for a pin, use the DlnGpioPinPullupIsEnabled() function.

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

DlnGpioPinPullupDisable() Function

The DlnGpioPinPullupDisable() deactivates an embedded pull-up resistor for the specified pin. For more information, read Pull-up/Pull-down Resistors.

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

A handle to the DLN-series adapter.

pin

A number of the pin for which you want to disable a pull-up resistor.

Return Value
DLN_RES_SUCCESS (0x00)

The function deactivated the pull-up resistor successfully.

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, pull-up resistors are active for GPIO pins. You can activate it manually by using the DlnGpioPinPullupEnable() function. To check the current configuration set for a pin, use the DlnGpioPinPullupIsEnabled() function.

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

DlnGpioPinPullupIsEnabled() Function

The DlnGpioPinPullupIsEnabled() function informs whether an embedded pull-up resistor is currently enabled for the specified pin.

Syntax
C/C++
DLN_RESULT DlnGpioPinPullupIsEnabled(
    HDLN handle,
    uint8_t pin,
    uint8_t* enabled
 );
Parameters
handle

A handle to the DLN-series adapter.

pin

A number of the pin from which you want to retrieve information.

enabled

A pointer to an unsigned 8-bit integer. After the function execution, this integer is filled with current state of a pull-up resistor. The following values are available:

ValueDescription

1

The pull-up resistor is active.

0

The pull-up resistor is not active.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the current state of the pull-up resistor.

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 pull-up resistors are active for GPIO pins. You can activate it manually by using the DlnGpioPinPullupEnable() function. To deactivate the Pull-up/Pull-down Resistors for GPIO pins, use the DlnGpioPinPullupDisable() function.

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

DlnGpioPinPulldownEnable() Function

The DlnGpioPinPulldownEnable() function activates an embedded pull-down resistor for the specified pin. For more information, read Pull-up/Pull-down Resistors.

Syntax
C/C++
DLN_RESULT DlnGpioPinPulldownEnable(
   HDLN handle, 
   uint16_t pin
);
Parameters
handle

A handle to the DLN-series adapter.

pin

The number of the pin that you want to configure.

Return Value
DLN_RES_SUCCESS

The function successfully activated the pull-down resistor.

DLN_RES_INVALID_PIN_NUMBER

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

DLN_RES_COMMAND_NOT_SUPPORTED

The DLN adapter does not support pull-down resistors.

Remarks
DLN-1 and DLN-2 adapters do not support pull-down resistors.

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

DlnGpioPinPulldownDisable() Function

The DlnGpioPinPulldownDisable() function deactivates an embedded pull-down resistor for the specified pin.

Syntax
C/C++
DLN_RESULT DlnGpioPinPulldownDisable(
   HDLN handle, 
   uint16_t pin
);
Parameters
handle

A handle to the DLN-series adapter.

pin

The number of the pin that you want to configure.

Return Value
DLN_RES_SUCCESS

The function successfully deactivated the pull-down resistor.

DLN_RES_INVALID_PIN_NUMBER

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

DLN_RES_COMMAND_NOT_SUPPORTED

The DLN adapter does not support pull-down resistors.

Remarks
DLN-1 and DLN-2 adapters do not support pull-down resistors.

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

DlnGpioPinPulldownIsEnabled() Function

The DlnGpioPinPulldownIsEnabled() function informs whether an embedded pull-down resistor is active for the specified pin.

Syntax
C/C++
DLN_RESULT DlnGpioPinPulldownIsEnabled(
   HDLN handle, 
   uint16_t pin, 
   uint8_t* enabled
);
Parameters
handle

A handle to the DLN-series adapter.

pin

The number of the pin from which you want to retrieve information.

enabled

A pointer to an unsigned 8-bit integer. After the function execution, the integer is set to the current state of a pull-down resistor.

Return Value
DLN_RES_SUCCESS

The function successfully retrieved the current state of the pull-down resistor.

DLN_RES_INVALID_PIN_NUMBER

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

DLN_RES_COMMAND_NOT_SUPPORTED

The DLN adapter does not support pull-down resistors.

Remarks
DLN-1 and DLN-2 adapters do not support pull-down resistors.

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

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.

DlnGpioPinGetCfg() Function

The DlnGpioPinGetCfg() function retrieves the current configuration of the specified GPIO pin.

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

A handle to the DLN-series adapter.

pin

A number of the pin which configuration you want to know.

config

A pointer to the DLN_GPIO_PIN_CONFIG structure which is set to the configuration (after the function execution). This structure contains the following fields:

FieldDescription

cfg

A bit field that defines the pin configuration.

eventType

A type of the event.

eventPeriod

An interval for repeating events.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the pin configuration.

DLN_RES_INVALID_HANDLE (0x8F)

The specified handle is not valid.

DLN_RES_CONNECTION_LOST (0xA0)

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.

Remarks

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