Zephyr Project API 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Emulated GPIO backend API. More...

Functions

int gpio_emul_input_set_masked (const struct device *port, gpio_port_pins_t pins, gpio_port_value_t values)
 Modify the values of one or more emulated GPIO input pins.
 
static int gpio_emul_input_set (const struct device *port, gpio_pin_t pin, int value)
 Modify the value of one emulated GPIO input pin.
 
static int gpio_emul_input_set_dt (const struct gpio_dt_spec *spec, int value)
 Modify the value of one emulated GPIO input pin from a gpio_dt_spec.
 
int gpio_emul_output_get_masked (const struct device *port, gpio_port_pins_t pins, gpio_port_value_t *values)
 Read the value of one or more emulated GPIO output pins.
 
static int gpio_emul_output_get (const struct device *port, gpio_pin_t pin)
 Read the value of one emulated GPIO output pin.
 
static int gpio_emul_output_get_dt (const struct gpio_dt_spec *spec)
 Read the value of one emulated GPIO output pin from a gpio_dt_spec.
 
int gpio_emul_flags_get (const struct device *port, gpio_pin_t pin, gpio_flags_t *flags)
 Get flags for a given emulated GPIO pin.
 
static int gpio_emul_flags_get_dt (const struct gpio_dt_spec *spec, gpio_flags_t *flags)
 Get flags for a given emulated GPIO pin from a gpio_dt_spec.
 

Detailed Description

Emulated GPIO backend API.

Behaviour of emulated GPIO is application-defined. As-such, each application may

An example of an appropriate Device Tree overlay file is in tests/drivers/gpio/gpio_basic_api/boards/native_sim.overlay.

An example of registering a callback to emulate "wiring" as well as an example of calling gpio_emul_input_set is in the file tests/drivers/gpio/gpio_basic_api/src/main.c .

Function Documentation

◆ gpio_emul_flags_get()

int gpio_emul_flags_get ( const struct device port,
gpio_pin_t  pin,
gpio_flags_t flags 
)

#include <include/zephyr/drivers/gpio/gpio_emul.h>

Get flags for a given emulated GPIO pin.

For more information on available flags, see GPIO.

Parameters
portThe emulated GPIO port
pinThe pin to retrieve flags for
flagsa pointer to where the flags for pin will be stored
Returns
0 on success
-EINVAL if an invalid argument is provided

◆ gpio_emul_flags_get_dt()

static int gpio_emul_flags_get_dt ( const struct gpio_dt_spec spec,
gpio_flags_t flags 
)
inlinestatic

#include <include/zephyr/drivers/gpio/gpio_emul.h>

Get flags for a given emulated GPIO pin from a gpio_dt_spec.

This is equivalent to:

gpio_emul_flags_get(spec->port, spec->pin, flags);

For more information on available flags, see GPIO.

Parameters
specThe emulated GPIO specification from devicetree
flagsa pointer to where the flags for the pin will be stored
Returns
a value from gpio_emul_flags_get()

◆ gpio_emul_input_set()

static int gpio_emul_input_set ( const struct device port,
gpio_pin_t  pin,
int  value 
)
inlinestatic

#include <include/zephyr/drivers/gpio/gpio_emul.h>

Modify the value of one emulated GPIO input pin.

Parameters
portThe emulated GPIO port
pinThe pin to modify
valueNew values to assign to pin
Returns
0 on success
-EINVAL if an invalid argument is provided

◆ gpio_emul_input_set_dt()

static int gpio_emul_input_set_dt ( const struct gpio_dt_spec spec,
int  value 
)
inlinestatic

#include <include/zephyr/drivers/gpio/gpio_emul.h>

Modify the value of one emulated GPIO input pin from a gpio_dt_spec.

This is equivalent to:

gpio_emul_input_set(spec->port, spec->pin, value);
Parameters
specThe emulated GPIO specification from devicetree
valueNew values to assign to the pin
Returns
a value from gpio_emul_input_set()

◆ gpio_emul_input_set_masked()

int gpio_emul_input_set_masked ( const struct device port,
gpio_port_pins_t  pins,
gpio_port_value_t  values 
)

#include <include/zephyr/drivers/gpio/gpio_emul.h>

Modify the values of one or more emulated GPIO input pins.

Parameters
portThe emulated GPIO port
pinsThe mask of pins that have changed
valuesNew values to assign to pins
Returns
0 on success
-EINVAL if an invalid argument is provided

◆ gpio_emul_output_get()

static int gpio_emul_output_get ( const struct device port,
gpio_pin_t  pin 
)
inlinestatic

#include <include/zephyr/drivers/gpio/gpio_emul.h>

Read the value of one emulated GPIO output pin.

Parameters
portThe emulated GPIO port
pinThe pin to read
Returns
0 or 1 on success
-EINVAL if an invalid argument is provided

◆ gpio_emul_output_get_dt()

static int gpio_emul_output_get_dt ( const struct gpio_dt_spec spec)
inlinestatic

#include <include/zephyr/drivers/gpio/gpio_emul.h>

Read the value of one emulated GPIO output pin from a gpio_dt_spec.

This is equivalent to:

gpio_emul_output_get(spec->port, spec->pin);
Parameters
specThe emulated GPIO specification from devicetree
Returns
a value from gpio_emul_output_get()

◆ gpio_emul_output_get_masked()

int gpio_emul_output_get_masked ( const struct device port,
gpio_port_pins_t  pins,
gpio_port_value_t values 
)

#include <include/zephyr/drivers/gpio/gpio_emul.h>

Read the value of one or more emulated GPIO output pins.

Parameters
portThe emulated GPIO port
pinsThe mask of pins that have changed
valuesA pointer to where the value of pins will be stored
Returns
0 on success
-EINVAL if an invalid argument is provided