libgpiod  0.3.2
Functions
GPIO chip operations

Functions and data structures dealing with GPIO chips. More...

Functions

struct gpiod_chip * gpiod_chip_open (const char *path) GPIOD_API
 Open a gpiochip by path. More...
 
struct gpiod_chip * gpiod_chip_open_by_name (const char *name) GPIOD_API
 Open a gpiochip by name. More...
 
struct gpiod_chip * gpiod_chip_open_by_number (unsigned int num) GPIOD_API
 Open a gpiochip by number. More...
 
struct gpiod_chip * gpiod_chip_open_by_label (const char *label) GPIOD_API
 Open a gpiochip by label. More...
 
struct gpiod_chip * gpiod_chip_open_lookup (const char *descr) GPIOD_API
 Open a gpiochip based on the best guess what the path is. More...
 
void gpiod_chip_close (struct gpiod_chip *chip) GPIOD_API
 Close a GPIO chip handle and release all allocated resources. More...
 
const char * gpiod_chip_name (struct gpiod_chip *chip) GPIOD_API
 Get the GPIO chip name as represented in the kernel. More...
 
const char * gpiod_chip_label (struct gpiod_chip *chip) GPIOD_API
 Get the GPIO chip label as represented in the kernel. More...
 
unsigned int gpiod_chip_num_lines (struct gpiod_chip *chip) GPIOD_API
 Get the number of GPIO lines exposed by this chip. More...
 
struct gpiod_line * gpiod_chip_get_line (struct gpiod_chip *chip, unsigned int offset) GPIOD_API
 Get the handle to the GPIO line at given offset. More...
 

Detailed Description

Functions and data structures dealing with GPIO chips.

Function Documentation

◆ gpiod_chip_close()

void gpiod_chip_close ( struct gpiod_chip *  chip)

Close a GPIO chip handle and release all allocated resources.

Parameters
chipThe GPIO chip object.

◆ gpiod_chip_get_line()

struct gpiod_line* gpiod_chip_get_line ( struct gpiod_chip *  chip,
unsigned int  offset 
)

Get the handle to the GPIO line at given offset.

Parameters
chipThe GPIO chip object.
offsetThe offset of the GPIO line.
Returns
Pointer to the GPIO line handle or NULL if an error occured.

◆ gpiod_chip_label()

const char* gpiod_chip_label ( struct gpiod_chip *  chip)

Get the GPIO chip label as represented in the kernel.

Parameters
chipThe GPIO chip object.
Returns
Pointer to a human-readable string containing the chip label.

◆ gpiod_chip_name()

const char* gpiod_chip_name ( struct gpiod_chip *  chip)

Get the GPIO chip name as represented in the kernel.

Parameters
chipThe GPIO chip object.
Returns
Pointer to a human-readable string containing the chip name.

◆ gpiod_chip_num_lines()

unsigned int gpiod_chip_num_lines ( struct gpiod_chip *  chip)

Get the number of GPIO lines exposed by this chip.

Parameters
chipThe GPIO chip object.
Returns
Number of GPIO lines.

◆ gpiod_chip_open()

struct gpiod_chip* gpiod_chip_open ( const char *  path)

Open a gpiochip by path.

Parameters
pathPath to the gpiochip device file.
Returns
GPIO chip handle or NULL if an error occurred.

◆ gpiod_chip_open_by_label()

struct gpiod_chip* gpiod_chip_open_by_label ( const char *  label)

Open a gpiochip by label.

Parameters
labelLabel of the gpiochip to open.
Returns
GPIO chip handle or NULL if the chip with given label was not found or an error occured.

◆ gpiod_chip_open_by_name()

struct gpiod_chip* gpiod_chip_open_by_name ( const char *  name)

Open a gpiochip by name.

Parameters
nameName of the gpiochip to open.
Returns
GPIO chip handle or NULL if an error occurred.

This routine appends name to '/dev/' to create the path.

◆ gpiod_chip_open_by_number()

struct gpiod_chip* gpiod_chip_open_by_number ( unsigned int  num)

Open a gpiochip by number.

Parameters
numNumber of the gpiochip.
Returns
GPIO chip handle or NULL if an error occurred.

This routine appends num to '/dev/gpiochip' to create the path.

◆ gpiod_chip_open_lookup()

struct gpiod_chip* gpiod_chip_open_lookup ( const char *  descr)

Open a gpiochip based on the best guess what the path is.

Parameters
descrString describing the gpiochip.
Returns
GPIO chip handle or NULL if an error occurred.

This routine tries to figure out whether the user passed it the path to the GPIO chip, its name, label or number as a string. Then it tries to open it using one of the other gpiod_chip_open** routines.