Loading...
Searching...
No Matches
Line configuration objects

## Functions

struct gpiod_line_config * | gpiod_line_config_new (void)
| Create a new line config object.
void | gpiod_line_config_free (struct gpiod_line_config *config)
| Free the line config object and release all associated resources.
void | gpiod_line_config_reset (struct gpiod_line_config *config)
| Reset the line config object.
int | gpiod_line_config_add_line_settings (struct gpiod_line_config *config, const unsigned int *offsets, size_t num_offsets, struct gpiod_line_settings *settings)
| Add line settings for a set of offsets.
struct gpiod_line_settings * | gpiod_line_config_get_line_settings (struct gpiod_line_config *config, unsigned int offset)
| Get line settings for offset.
int | gpiod_line_config_set_output_values (struct gpiod_line_config *config, const enum gpiod_line_value *values, size_t num_values)
| Set output values for a number of lines.
size_t | gpiod_line_config_get_num_configured_offsets (struct gpiod_line_config *config)
| Get the number of configured line offsets.
size_t | gpiod_line_config_get_configured_offsets (struct gpiod_line_config *config, unsigned int *offsets, size_t max_offsets)
| Get configured offsets.

## Detailed Description

Functions for manipulating line configuration objects.

The line-config object contains the configuration for lines that can be used in two cases:

- when making a line request
- when reconfiguring a set of already requested lines.

A new line-config object is empty. Using it in a request will lead to an error. In order to a line-config to become useful, it needs to be assigned at least one offset-to-settings mapping by calling gpiod_line_config_add_line_settings.

When calling gpiod_chip_request_lines, the library will request all offsets that were assigned settings in the order that they were assigned. If any of the offsets was duplicated, the last one will take precedence.

## Function Documentation

## gpiod_line_config_add_line_settings()

int gpiod_line_config_add_line_settings | ( | struct gpiod_line_config * | config,
|  | const unsigned int * | offsets,
|  | size_t | num_offsets,
|  | struct gpiod_line_settings * | settings )

Add line settings for a set of offsets.

Parameters

  config | Line config object.
  offsets | Array of offsets for which to apply the settings.
  num_offsets | Number of offsets stored in the offsets array.
  settings | Line settings to apply.

Returns
  0 on success, -1 on failure.

## gpiod_line_config_free()

void gpiod_line_config_free | ( | struct gpiod_line_config * | config | ) |

Free the line config object and release all associated resources.

Parameters

  config | Line config object to free.

## gpiod_line_config_get_configured_offsets()

size_t gpiod_line_config_get_configured_offsets | ( | struct gpiod_line_config * | config,
|  | unsigned int * | offsets,
|  | size_t | max_offsets )

Get configured offsets.

Parameters

  config | Line config object.
  offsets | Array to store offsets.
  max_offsets | Number of offsets that can be stored in the offsets array.

Returns
  Number of offsets stored in the offsets array.

If max_offsets is lower than the number of lines actually requested (this value can be retrieved using gpiod_line_config_get_num_configured_offsets), then only up to max_lines offsets will be stored in offsets.

## gpiod_line_config_get_line_settings()

struct gpiod_line_settings * gpiod_line_config_get_line_settings | ( | struct gpiod_line_config * | config,
|  | unsigned int | offset )

Get line settings for offset.

Parameters

  config | Line config object.
  offset | Offset for which to get line settings.

Returns
  New line settings object (must be freed by the caller) or NULL on error.

## gpiod_line_config_get_num_configured_offsets()

size_t gpiod_line_config_get_num_configured_offsets | ( | struct gpiod_line_config * | config | ) |

Get the number of configured line offsets.

Parameters

  config | Line config object.

Returns
  Number of offsets for which line settings have been added.

## gpiod_line_config_new()

struct gpiod_line_config * gpiod_line_config_new | ( | void |  | ) |

Create a new line config object.

Returns
  New line config object or NULL on error. The returned object must be freed by the caller using gpiod_line_config_free.

## gpiod_line_config_reset()

void gpiod_line_config_reset | ( | struct gpiod_line_config * | config | ) |

Reset the line config object.

Parameters

  config | Line config object to free.

Resets the entire configuration stored in the object. This is useful if the user wants to reuse the object without reallocating it.

## gpiod_line_config_set_output_values()

int gpiod_line_config_set_output_values | ( | struct gpiod_line_config * | config,
|  | const enum gpiod_line_value * | values,
|  | size_t | num_values )

Set output values for a number of lines.

Parameters

  config | Line config object.
  values | Buffer containing the output values.
  num_values | Number of values in the buffer.

Returns
  0 on success, -1 on error.

This is a helper that allows users to set multiple (potentially different) output values at once while using the same line settings object. Instead of modifying the output value in the settings object and calling gpiod_line_config_add_line_settings multiple times, we can specify the settings, add them for a set of offsets and then call this function to set the output values.

Values set by this function override whatever values were specified in the regular line settings.

Each value must be associated with the line identified by the corresponding entry in the offset array filled by gpiod_line_request_get_requested_offsets.