libgpiod
2.0.1
|
Functions for manipulating line configuration objects. More...
Functions | |
struct gpiod_line_config * | gpiod_line_config_new (void) |
Create a new line config object. More... | |
void | gpiod_line_config_free (struct gpiod_line_config *config) |
Free the line config object and release all associated resources. More... | |
void | gpiod_line_config_reset (struct gpiod_line_config *config) |
Reset the line config object. More... | |
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. More... | |
struct gpiod_line_settings * | gpiod_line_config_get_line_settings (struct gpiod_line_config *config, unsigned int offset) |
Get line settings for offset. More... | |
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. More... | |
size_t | gpiod_line_config_get_num_configured_offsets (struct gpiod_line_config *config) |
Get the number of configured line offsets. More... | |
size_t | gpiod_line_config_get_configured_offsets (struct gpiod_line_config *config, unsigned int *offsets, size_t max_offsets) |
Get configured offsets. More... | |
Functions for manipulating line configuration objects.
The line-config object contains the configuration for lines that can be used in two cases:
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.
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.
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. |
void gpiod_line_config_free | ( | struct gpiod_line_config * | config | ) |
Free the line config object and release all associated resources.
config | Line config object to free. |
size_t gpiod_line_config_get_configured_offsets | ( | struct gpiod_line_config * | config, |
unsigned int * | offsets, | ||
size_t | max_offsets | ||
) |
Get configured offsets.
config | Line config object. |
offsets | Array to store offsets. |
max_offsets | Number of offsets that can be 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.
struct gpiod_line_settings* gpiod_line_config_get_line_settings | ( | struct gpiod_line_config * | config, |
unsigned int | offset | ||
) |
Get line settings for offset.
config | Line config object. |
offset | Offset for which to get line settings. |
size_t gpiod_line_config_get_num_configured_offsets | ( | struct gpiod_line_config * | config | ) |
Get the number of configured line offsets.
config | Line config object. |
struct gpiod_line_config* gpiod_line_config_new | ( | void | ) |
Create a new line config object.
void gpiod_line_config_reset | ( | struct gpiod_line_config * | config | ) |
Reset the line config object.
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.
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.
config | Line config object. |
values | Buffer containing the output values. |
num_values | Number of values in the buffer. |
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.