Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
gpio_emul.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Friedt Professional Engineering Services, Inc
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_DRIVERS_GPIO_GPIO_EMUL_H_
13#define ZEPHYR_INCLUDE_DRIVERS_GPIO_GPIO_EMUL_H_
14
15#include <zephyr/types.h>
16#include <zephyr/drivers/gpio.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
57 gpio_port_value_t values);
58
69static inline int gpio_emul_input_set(const struct device *port, gpio_pin_t pin,
70 int value)
71{
72 return gpio_emul_input_set_masked(port, BIT(pin), value ? BIT(pin) : 0);
73}
74
86 gpio_port_value_t *values);
87
97static inline int gpio_emul_output_get(const struct device *port, gpio_pin_t pin)
98{
99 int ret;
100 gpio_port_value_t values;
101
102 ret = gpio_emul_output_get_masked(port, BIT(pin), &values);
103 if (ret == 0) {
104 ret = (values & BIT(pin)) ? 1 : 0;
105 }
106
107 return ret;
108}
109
123
128#ifdef __cplusplus
129}
130#endif
131
132#endif /* ZEPHYR_INCLUDE_DRIVERS_GPIO_GPIO_EMUL_H_ */
Public APIs for GPIO drivers.
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.
Definition gpio_emul.h:69
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_output_get(const struct device *port, gpio_pin_t pin)
Read the value of one emulated GPIO output pin.
Definition gpio_emul.h:97
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.
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.
uint8_t gpio_pin_t
Provides a type to hold a GPIO pin index.
Definition gpio.h:254
uint32_t gpio_flags_t
Provides a type to hold GPIO configuration flags.
Definition gpio.h:274
uint32_t gpio_port_pins_t
Identifies a set of pins associated with a port.
Definition gpio.h:233
uint32_t gpio_port_value_t
Provides values for a set of pins associated with a port.
Definition gpio.h:246
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
flags
Definition parser.h:96
Runtime device structure (in ROM) per driver instance.
Definition device.h:412