DLN_GPIO_PIN_CONFIG Structure

Syntax

C/C++
 typedef struct
 {
    uint16_t cfg;
    uint8_t eventType;
    uint16_t eventPeriod;       
 } __PACKED_ATTR DLN_GPIO_PIN_CONFIG;
     

This structure is used to store configuration of a single GPIO pin.

Members:

cfg

A bit field, consisting of 16 bits. Each of the bits 0-5 corresponds to a specific parameter, that defines the pin configuration. The bits 6 and 7 are reserved. You can also use special constants, defined in the dln_gpio.h file for each of the bits.

Bit Value Description Constant
0 1 The pin is configured as a general purpose input/output. DLN_GPIO_ENABLED
0 0 The pin is not configured as a general purpose input/output. DLN_GPIO_DISABLED
1 1 The pin is configured as output. DLN_GPIO_OUTPUT
1 0 The pin is configured as input. DLN_GPIO_INPUT
2 1 The output value on the pin is 1. DLN_GPIO_OUTPUT_VAL_1
2 0 The output value on the pin is 0. DLN_GPIO_OUTPUT_VAL_0
3 1 The output is open drain. DLN_GPIO_OPEN_DRAIN_ENABLED
3 0 The output is push pull. DLN_GPIO_OPEN_DRAIN_DISABLED
4 1 The pull-up resistor is on. DLN_GPIO_PULLUP_ENABLED
4 0 The pull-up resistor is off. DLN_GPIO_PULLUP_DISABLED
5 1 The debounce filter is switched on. DLN_GPIO_DEBOUNCE_ENABLED
5 0 The debounce filter is switched off. DLN_GPIO_DEBOUNCE_DISABLED
6   Reserved.  
7   Reserved.  
8 1 Events are enabled. DLN_GPIO_EVENT_ENABLED
8 0 Events are disabled. DLN_GPIO_EVENT_DISABLED
9 1 Events are periodic. DLN_GPIO_EVENT_PERIODIC
9 0 A single event is generated. DLN_GPIO_EVENT_SINGLE
10   Reserved.  
11   Reserved.  
12   Reserved.  
13   Reserved.  
14   Reserved.  
15   Reserved.  

DLN_GPIO_ENABLE_BIT

The zeroth bit in the cfg parameter. It defines whether the pin is configured as general purpose input/output or not. The following values are available.

Value Constant Description
1 DLN_GPIO_ENABLED Pin is configured as general purpose I/O.
0 DLN_GPIO_DISABLED Pin is disconnected from the GPIO module.
DLN_GPIO_OUTPUT_BIT

The first bit in the cfg parameter. It defines whether the pin is configured as input or as output. The following values are available:

Value Constant Description
1 DLN_GPIO_OUTPUT Pin is configured as output.
0 DLN_GPIO_INPUT Pin is configured as input.
DLN_GPIO_OUTPUT_VAL_BIT

The second bit in the cfg parameter. It defines the output value on the pin. If the pin is an output, the value is applied immediately. If the pin is an input, the value is stored in a latch. This value will be applied when the pin becomes an output. The following values are available:

Value Constant Description
1 DLN_GPIO_OUTPUT_VAL_1 Pin outputs high level (logic 1).
0 DLN_GPIO_OUTPUT_VAL_0 Pin outputs low level (logic 0).
DLN_GPIO_OPEN_DRAIN_BIT

The third bit in the cfg parameter. Defines whether the output is push pull or open drain. If the pin is an output, the parameter is applied immediately. If the pin is an input, the parameter is stored in a latch. This parameter will be applied when the pin becomes an output. The following values are available:

Value Constant Description
1 DLN_GPIO_OPEN_DRAIN_ENABLED Pin is an open drain output
0 DLN_GPIO_OPEN_DRAIN_DISABLED Pin is a push pull output.
DLN_GPIO_PULL_UP_BIT

The fourth bit in the cfg parameter. Defines whether the pull-up resistor is on or off. The following values are available:

Value Constant Description
1 DLN_GPIO_PULLUP_ENABLED Pull-up on the pin is switched on.
0 DLN_GPIO_OPEN_DRAIN_DISABLED Pull-up on the pin is switched off.
DLN_GPIO_DEBOUNCE_BIT

The fifth bit in the cfg parameter. Defines whether the debounce filter is switched on or not. The following values are available:

Value Constant Description
1 DLN_GPIO_DEBOUNCE_ENABLED Debounce filter is applied to the pin.
0 DLN_GPIO_DEBOUNCE_DISABLED Debounce filter is not applied to the pin.

The debounce duration is set with DLN_GPIO_SET_DEBOUNCE command.

DLN_GPIO_EVENT_TYPE_BIT

The eighth bit in the cfg parameter. Defines whether event generation on the pin is enabled as well as the condition of event generation for the pin. The following values are available:

Value Constant Description
1 DLN_GPIO_EVENT_ENABLED Events are generated on the pin.
0 DLN_GPIO_EVENT_DISABLED No events are generated on the pin.

For more detailed information about the event generation see GPIO Event

DLN_GPIO_EVENT_PERIOD_BIT

The ninth bit in the cfg parameter. Defines whether the DLN_GPIO_CONDIION_MET event is single or periodic. The following values are available:

Value Constant Description
1 DLN_GPIO_EVENT_PERIODIC events are generated periodically.
0 DLN_GPIO_EVENT_SINGLE A single event is generated.
eventType

Defines the condition of event generation for the pin. The following values are available:

Condition Description
DLN_GPIO_EVENT_NONE No events are sent for current pin.
DLN_GPIO_EVENT_CHANGE An event is sent when the input value on the pin changes.
DLN_GPIO_EVENT_LEVEL_HIGH Events are generated when the high level (logical 1) is detected on the digital input line.
DLN_GPIO_EVENT_LEVEL_LOW Events are generated the event is sent when the low level (logical 0) is detected on the digital input line.
DLN_GPIO_EVENT_ALWAYS Events are sent periodically with predefined repeat interval.

The non-zero interval must be specified for this event type.

For more detailed information about the event generation see GPIO Event

eventPeriod

Defines the repeat interval for DLN_GPIO_CONDIION_MET_EV event generation on the pin. The repeat interval is set in ms (1 to 65,535ms). If the repeat interval is set to 0, the device will send a single event when the level on the line changes to meet the specified conditions.