libgpiod  1.0.1
Enumerations | Functions
Collaboration diagram for Line info:

Enumerations

enum  { GPIOD_LINE_DIRECTION_INPUT, GPIOD_LINE_DIRECTION_OUTPUT }
 Possible direction settings. More...
 
enum  { GPIOD_LINE_ACTIVE_STATE_HIGH, GPIOD_LINE_ACTIVE_STATE_LOW }
 Possible active state settings. More...
 

Functions

unsigned int gpiod_line_offset (struct gpiod_line *line) GPIOD_API
 Read the GPIO line offset. More...
 
const char * gpiod_line_name (struct gpiod_line *line) GPIOD_API
 Read the GPIO line name. More...
 
const char * gpiod_line_consumer (struct gpiod_line *line) GPIOD_API
 Read the GPIO line consumer name. More...
 
int gpiod_line_direction (struct gpiod_line *line) GPIOD_API
 Read the GPIO line direction setting. More...
 
int gpiod_line_active_state (struct gpiod_line *line) GPIOD_API
 Read the GPIO line active state setting. More...
 
bool gpiod_line_is_used (struct gpiod_line *line) GPIOD_API
 Check if the line is currently in use. More...
 
bool gpiod_line_is_open_drain (struct gpiod_line *line) GPIOD_API
 Check if the line is an open-drain GPIO. More...
 
bool gpiod_line_is_open_source (struct gpiod_line *line) GPIOD_API
 Check if the line is an open-source GPIO. More...
 
int gpiod_line_update (struct gpiod_line *line) GPIOD_API
 Re-read the line info. More...
 
bool gpiod_line_needs_update (struct gpiod_line *line) GPIOD_API
 Check if the line info needs to be updated. More...
 

Detailed Description

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Possible direction settings.

Enumerator
GPIOD_LINE_DIRECTION_INPUT 

Direction is input - we're reading the state of a GPIO line.

GPIOD_LINE_DIRECTION_OUTPUT 

Direction is output - we're driving the GPIO line.

Definition at line 533 of file gpiod.h.

◆ anonymous enum

anonymous enum

Possible active state settings.

Enumerator
GPIOD_LINE_ACTIVE_STATE_HIGH 

The active state of a GPIO is active-high.

GPIOD_LINE_ACTIVE_STATE_LOW 

The active state of a GPIO is active-low.

Definition at line 543 of file gpiod.h.

Function Documentation

◆ gpiod_line_active_state()

int gpiod_line_active_state ( struct gpiod_line *  line)

Read the GPIO line active state setting.

Parameters
lineGPIO line object.
Returns
Returns GPIOD_ACTIVE_STATE_HIGH or GPIOD_ACTIVE_STATE_LOW.

◆ gpiod_line_consumer()

const char* gpiod_line_consumer ( struct gpiod_line *  line)

Read the GPIO line consumer name.

Parameters
lineGPIO line object.
Returns
Name of the GPIO consumer name as it is represented in the kernel. This routine returns a pointer to a null-terminated string or NULL if the line is not used.

◆ gpiod_line_direction()

int gpiod_line_direction ( struct gpiod_line *  line)

Read the GPIO line direction setting.

Parameters
lineGPIO line object.
Returns
Returns GPIOD_DIRECTION_INPUT or GPIOD_DIRECTION_OUTPUT.

◆ gpiod_line_is_open_drain()

bool gpiod_line_is_open_drain ( struct gpiod_line *  line)

Check if the line is an open-drain GPIO.

Parameters
lineGPIO line object.
Returns
True if the line is an open-drain GPIO, false otherwise.

◆ gpiod_line_is_open_source()

bool gpiod_line_is_open_source ( struct gpiod_line *  line)

Check if the line is an open-source GPIO.

Parameters
lineGPIO line object.
Returns
True if the line is an open-source GPIO, false otherwise.

◆ gpiod_line_is_used()

bool gpiod_line_is_used ( struct gpiod_line *  line)

Check if the line is currently in use.

Parameters
lineGPIO line object.
Returns
True if the line is in use, false otherwise.

The user space can't know exactly why a line is busy. It may have been requested by another process or hogged by the kernel. It only matters that the line is used and we can't request it.

◆ gpiod_line_name()

const char* gpiod_line_name ( struct gpiod_line *  line)

Read the GPIO line name.

Parameters
lineGPIO line object.
Returns
Name of the GPIO line as it is represented in the kernel. This routine returns a pointer to a null-terminated string or NULL if the line is unnamed.

◆ gpiod_line_needs_update()

bool gpiod_line_needs_update ( struct gpiod_line *  line)

Check if the line info needs to be updated.

Parameters
lineGPIO line object.
Returns
Returns false if the line is up-to-date. True otherwise.

The line is updated by calling gpiod_line_update() from within gpiod_chip_get_line() and on every line request/release. However: an error returned from gpiod_line_update() only breaks the execution of the former. The request/release routines only set the internal up-to-date flag to false and continue their execution. This routine allows to check if a line info update failed at some point and we should call gpiod_line_update() explicitly.

◆ gpiod_line_offset()

unsigned int gpiod_line_offset ( struct gpiod_line *  line)

Read the GPIO line offset.

Parameters
lineGPIO line object.
Returns
Line offset.

◆ gpiod_line_update()

int gpiod_line_update ( struct gpiod_line *  line)

Re-read the line info.

Parameters
lineGPIO line object.
Returns
0 is the operation succeeds. In case of an error this routine returns -1 and sets the last error number.

The line info is initially retrieved from the kernel by gpiod_chip_get_line(). Users can use this line to manually re-read the line info.