Вы здесь

Digital Input Events

There are two ways of monitoring changes on the digital input line:

  • To poll the input pin periodically. In this case, you can potentially miss an input if your application reads the value at the wrong time.

  • To receive events when the input value changes. You can configure event generation for specific changes, for example, when the level on a pin rises. You can also configure the adapter to generate events periodically.

To configure events, use the DlnGpioPinSetEventCfg() function. You need to specify the eventType and the eventPeriod parameters. The DlnGpioPinGetSupportedEventTypes() function returns the list of event types available for a pin.

The eventType parameter can have one of the following values:

Event TypeDescription

DLN_GPIO_EVENT_NONE

A DLN adapter does not generate any events.

DLN_GPIO_EVENT_CHANGE

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

DLN_GPIO_EVENT_LEVEL_HIGH

A 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

DLN_GPIO_EVENT_LEVEL_LOW

A 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

DLN_GPIO_EVENT_ALWAYS

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

The eventPeriod parameter defines the interval between repeated events in milliseconds (ms). This parameter must be non-zero for the DLN_GPIO_EVENT_ALWAYS events. For other events, this parameter is optional.

If the Debounce Filter in enabled on a pin, the level change event is generated after the debounce filter accepts a new value.

You can configure events for each input pin individually. If the pin is configured as a digital input, the new settings are applied immediately. If you configure events when a pin is defined as an output or is not assigned to the GPIO module at all, this configuration is saved in the internal memory and is applied when the pin becomes a GPIO input.

When an event occurs, your application is notified (see the Notifications section). Call the DlnGetMessage() function to obtain the event details. The DLN_GPIO_CONDITION_MET_EV structure describes this information.

By default, event generation is disabled for all pins (the eventType parameter is set to DLN_GPIO_EVENT_NONE).

The DLN-1 adapters do not support events.

The following GPIO Interface functions can be used to control and monitor events:

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.

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

Языки

Вход на сайт