GPIO Structures

This section describes the structures used for the GPIO module. These structures are declared in the dln_gpio.h file.

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

DLN_GPIO_PIN_EVENT_TYPES Structure

The DLN_GPIO_PIN_EVENT_TYPES structure contains information about the event types supported for a pin.

Syntax
C/C++
typedef struct
{
	uint8_t count;
	uint8_t eventTypes[8];
} __PACKED_ATTR DLN_GPIO_PIN_EVENT_TYPES;
Structure Members
count

The number of available event types.

eventTypes

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

DLN_GPIO_PIN_CONFIG Structure

The DLN_GPIO_PIN_CONFIG structure contains information about the pin configuration.

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

A bit field that defines the pin configuration and consists of 16 bits. Each of the bits 0-6, 8-9 corresponds to a specific parameter, that defines the pin configuration. The bits 7, 10-15 are reserved.

BitValueDescriptionConstant

0

0

The pin is not configured as a GPIO.

DLN_GPIO_DISABLED

0

1

The pin is configured as a GPIO.

DLN_GPIO_ENABLED

1

0

The pin is an input.

DLN_GPIO_INPUT

1

1

The pin is an output.

DLN_GPIO_OUTPUT

2

0

The output value is 0.

DLN_GPIO_OUTPUT_VAL_0

2

1

The output value is 1.

DLN_GPIO_OUTPUT_VAL_1

3

0

The output is open drain.

DLN_GPIO_OPEN_DRAIN_DISABLED

3

1

The output is push-pull.

DLN_GPIO_OPEN_DRAIN_ENABLED

4

0

The pull-up resistor is not active.

DLN_GPIO_PULLUP_DISABLED

4

1

The pull-up resistor is active.

DLN_GPIO_PULLUP_ENABLED

5

0

The debounce filter is not active.

DLN_GPIO_DEBOUNCE_DISABLED

5

1

The debounce filter is active.

DLN_GPIO_DEBOUNCE_ENABLED

6

0

The pull-down resistor is not active.

DLN_GPIO_PULLDOWN_DISABLED

6

1

The pull-down resistor is active.

DLN_GPIO_PULLDOWN_ENABLED

7

Reserved.

8

0

No events are generated.

DLN_GPIO_EVENT_DISABLED

8

1

Events are generated.

DLN_GPIO_EVENT_ENABLED

9

0

Single events are generated.

DLN_GPIO_EVENT_SINGLE

9

1

Periodical events are generated.

DLN_GPIO_EVENT_PERIODIC

10

Reserved.

11

Reserved.

12

Reserved.

13

Reserved.

14

Reserved.

15

Reserved.

eventType

A type of the event. The following values are available:

ValueConstantDescription

0

DLN_GPIO_EVENT_NONE

No events are generated.

1

DLN_GPIO_EVENT_CHANGE

Events are generated when the input value changes.

2

DLN_GPIO_EVENT_LEVEL_HIGH

Events are generated when the high level (logic 1) is detected.

3

DLN_GPIO_EVENT_LEVEL_LOW

Events are generated when the low level (logic 0) is detected.

4

DLN_GPIO_EVENT_ALWAYS

The events are generated periodically with the predefined interval.

For detailed information, read Digital Input Events.

eventPeriod

An interval in milliseconds (ms) at which the events are generated. If the interval is zero, the DLN adapter generates a single event when the level change meets the specified conditions.