Debounce Filter

Contact bounce may cause sending numerous events. To avoid it, debounce filter is implemented in the adapter. The new value is only accepted if it is stable for a predefined period of time. This time period (Debounce interval) is defined with DLN_GPIO_SET_DEBOUNCE command in µs. This time period is equal for all pins. The debounce filter can be switched on/off independently for each I/O line.

When the debouncing filter is enabled, a pulse with duration of less than 1/2 of the specified debounce interval is automatically rejected.

A pulse with a duration of 1 or more debounce intervals is accepted, and a respective event is generated.

For pulse durations between 1/2 and 1 debounce interval, the pulse may or may not be taken into account, depending on the precise timing of its occurrence.

Thus for a pulse to be visible it must exceed 1 debounce interval, whereas for a pulse to be reliably filtered out, its duration must be less than 1/2 of selected time period.

Debounce filters can be enabled or disabled using DlnGpioPortSetCfg() function.

To do this you must specify the corresponding handle and port values, as well as configure validFields, mask and config parameters.

In order to trigger debounce filters, a user must set the fifth bit in a validFields parameter to 1 (you can use the DLN_GPIO_FIELD_ISDEBOUNCEEN constant). This way the corresponding configuration field (isDebounceEnabled) becomes valid.

The mask parameter is used to define the I/O lines, whose debounce filter settings must be changed. Set the bits, corresponding to the pins that should be affected to 1.

The config parameter contains the DLN_GPIO_PORT_CONFIG structure, which is filled with new configuration values to be set. Its sixth field - isDebounceEnabled - triggers the debounce filter and must be set to 0 or 1 in order to disable or enable it respectively.

Another way to enable debounce filtering for a single pin is calling the DlnGpioPinDebounceEnable() function. The DlnGpioPinDebounceDisable() function disables the debounce filter, while DlnGpioPinDebounceIsEnabled() retrieves its current state.

By default all the debounce filters are disabled.