Soletta™ Framework
|
GPIO (General Purpose Input/Output) API for Soletta. More...
Data Structures | |
struct | sol_gpio_config |
Structure to hold the configuration of a GPIO device. More... | |
Typedefs | |
typedef struct sol_gpio | sol_gpio |
A handle to a GPIO. More... | |
typedef struct sol_gpio_config | sol_gpio_config |
Structure to hold the configuration of a GPIO device. More... | |
Enumerations | |
enum | sol_gpio_direction { SOL_GPIO_DIR_OUT = 0, SOL_GPIO_DIR_IN = 1 } |
Possible values for the direction of a GPIO. More... | |
enum | sol_gpio_drive { SOL_GPIO_DRIVE_NONE = 0, SOL_GPIO_DRIVE_PULL_UP, SOL_GPIO_DRIVE_PULL_DOWN } |
Possible values for pull-up or pull-down resistor of a GPIO. More... | |
enum | sol_gpio_edge { SOL_GPIO_EDGE_NONE = 0, SOL_GPIO_EDGE_RISING, SOL_GPIO_EDGE_FALLING, SOL_GPIO_EDGE_BOTH } |
Possible values for the edge mode of a GPIO. More... | |
Functions | |
void | sol_gpio_close (struct sol_gpio *gpio) |
Closes a given GPIO pin. More... | |
enum sol_gpio_direction | sol_gpio_direction_from_str (const char *direction) |
Converts a string GPIO direction to sol_gpio_direction. More... | |
const char * | sol_gpio_direction_to_str (enum sol_gpio_direction direction) |
Converts sol_gpio_direction to a string name. More... | |
enum sol_gpio_drive | sol_gpio_drive_from_str (const char *drive) |
Converts a string GPIO drive to sol_gpio_drive. More... | |
const char * | sol_gpio_drive_to_str (enum sol_gpio_drive drive) |
Converts sol_gpio_drive to a string name. More... | |
enum sol_gpio_edge | sol_gpio_edge_from_str (const char *edge) |
Converts a string GPIO edge to sol_gpio_edge. More... | |
const char * | sol_gpio_edge_to_str (enum sol_gpio_edge edge) |
Converts sol_gpio_edge to a string name. More... | |
struct sol_gpio * | sol_gpio_open (uint32_t pin, const struct sol_gpio_config *config) |
Opens a given pin as general purpose input or output. More... | |
struct sol_gpio * | sol_gpio_open_by_label (const char *label, const struct sol_gpio_config *config) |
Opens a given pin by its board label as general purpose input or output. More... | |
struct sol_gpio * | sol_gpio_open_raw (uint32_t pin, const struct sol_gpio_config *config) |
Opens a given pin as general purpose input or output. More... | |
int | sol_gpio_read (struct sol_gpio *gpio) |
Get the current value set to pin . More... | |
bool | sol_gpio_write (struct sol_gpio *gpio, bool value) |
Set an arbitrary value to pin . More... | |
GPIO (General Purpose Input/Output) API for Soletta.
A handle to a GPIO.
typedef struct sol_gpio_config sol_gpio_config |
Structure to hold the configuration of a GPIO device.
When opening a GPIO with sol_gpio_open_by_label(), sol_gpio_open() or sol_gpio_open_raw(), the parameters with which the GPIO is configured are those defined in this structure.
If there's a need to change any of these parameters, the GPIO must be closed and opened again with a new configuration.
enum sol_gpio_direction |
enum sol_gpio_drive |
Possible values for pull-up or pull-down resistor of a GPIO.
It will avoid values to float when this pin isn't connected. It'll define output value if nothing else is defined by software.
enum sol_gpio_edge |
Possible values for the edge mode of a GPIO.
This indicate when an interrupt event should be generated.
void sol_gpio_close | ( | struct sol_gpio * | gpio | ) |
Closes a given GPIO pin.
gpio | The open sol_gpio representing the pin to be closed. |
Referenced by shutdown().
enum sol_gpio_direction sol_gpio_direction_from_str | ( | const char * | direction | ) |
Converts a string GPIO direction to sol_gpio_direction.
This function converts a string GPIO direction to enumeration sol_gpio_direction.
direction | Valid values are "in", "out". |
const char* sol_gpio_direction_to_str | ( | enum sol_gpio_direction | direction | ) |
Converts sol_gpio_direction to a string name.
This function converts sol_gpio_direction enumeration to a string GPIO direction name.
direction | sol_gpio_direction. |
enum sol_gpio_drive sol_gpio_drive_from_str | ( | const char * | drive | ) |
Converts a string GPIO drive to sol_gpio_drive.
This function converts a string GPIO drive to enumeration sol_gpio_drive.
drive | Valid values are "none", "up", "down". |
const char* sol_gpio_drive_to_str | ( | enum sol_gpio_drive | drive | ) |
Converts sol_gpio_drive to a string name.
This function converts sol_gpio_drive enumeration to a string GPIO drive name.
drive | sol_gpio_drive. |
enum sol_gpio_edge sol_gpio_edge_from_str | ( | const char * | edge | ) |
Converts a string GPIO edge to sol_gpio_edge.
This function converts a string GPIO edge to enumeration sol_gpio_edge
edge | Valid values are "none", "rising", "falling", "any". |
const char* sol_gpio_edge_to_str | ( | enum sol_gpio_edge | edge | ) |
Converts sol_gpio_edge to a string name.
This function converts sol_gpio_edge enumeration to a string GPIO edge name
edge | sol_gpio_edge |
struct sol_gpio* sol_gpio_open | ( | uint32_t | pin, |
const struct sol_gpio_config * | config | ||
) |
Opens a given pin as general purpose input or output.
A pin should be opened just once, calling this function more than once for the same pin results in undefined behaviour - per platform basis.
pin | The pin to be opened. |
config | Contains the pin configuration. |
sol_gpio
instance on success, NULL
otherwise. Referenced by startup().
struct sol_gpio* sol_gpio_open_by_label | ( | const char * | label, |
const struct sol_gpio_config * | config | ||
) |
Opens a given pin by its board label as general purpose input or output.
This function only works when the board was successfully detected by Soletta and a corresponding pin multiplexer module was found.
A pin should be opened just once, calling this function more than once for the same pin results in undefined behavior - per platform basis.
label | The pin to be opened. |
config | Contains the pin configuration. |
sol_gpio
instance on success, NULL
otherwise. struct sol_gpio* sol_gpio_open_raw | ( | uint32_t | pin, |
const struct sol_gpio_config * | config | ||
) |
Opens a given pin as general purpose input or output.
A pin should be opened just once, calling this function more than once for the same pin results in undefined behaviour - per platform basis.
pin | The pin to be opened. |
config | Contains the pin configuration. |
sol_gpio
instance on success, NULL
otherwise. int sol_gpio_read | ( | struct sol_gpio * | gpio | ) |
Get the current value
set to pin
.
gpio | The opened sol_gpio that contains the pin that will be read. |
bool sol_gpio_write | ( | struct sol_gpio * | gpio, |
bool | value | ||
) |
Set an arbitrary value
to pin
.
gpio | The opened sol_gpio that contains the pin that will be used. |
value | The value that will be set to the pin. |
true
on success, otherwise false
. Referenced by on_timeout().