Digital Inputs

Each of the adapter pins can be configured as a general purpose digital input.

This can be done using the DlnGpioPortSetCfg() function.

You must specify the corresponding handle and port values, as well as configure validFields, mask and config parameters.

In order to configure pin direction, a user must set the first bit in the validFields parameter to 1. This way the corresponding configuration field (isOutput) becomes valid.

The config parameter contains the DLN_GPIO_PORT_CONFIG structure, which is filled with new configuration values to be set. Its second field - isOutput - triggers the pin direction and must be set to 0 for input.

The mask parameter is used to define the I/O lines, whose I/O configuration must be triggered. Set the bits, corresponding to the pins to be affected to 1.

In order to use a pin as a digital input, it must be connected to GPIO module. To do this, you must first set the zeroth bit in the validFields parameter to 1. Then you must set all the corresponding bits from the isEnabled parameter to 1.

A user can enable embedded Pull-Up resistors and the Debounce Filter for each of the digital inputs.

The current level on each I/O line can be determined using the DlnGpioPortGetVal() function. This function returns the level on an I/O line regardless of its configuration, whether it is configured as a GPIO input or output or even not connected to the GPIO module at all.

Digital inputs can be configured to send events on an I/O line level change. The DLN-adapter can also generate periodical events containing current state of the line. The period can be defined using the eventPeriod parameter of the DLN_GPIO_PORT_CONFIG structure. This way a user can continuously monitor the input value on the line. For details see "Digital Input Events".