Zephyr Project API 4.2.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
58 gpio_port_value_t values);
59
70static inline int gpio_emul_input_set(const struct device *port, gpio_pin_t pin,
71 int value)
72{
73 return gpio_emul_input_set_masked(port, BIT(pin), value ? BIT(pin) : 0);
74}
75
87 gpio_port_value_t *values);
88
98static inline int gpio_emul_output_get(const struct device *port, gpio_pin_t pin)
99{
100 int ret;
101 gpio_port_value_t values;
102
103 ret = gpio_emul_output_get_masked(port, BIT(pin), &values);
104 if (ret == 0) {
105 ret = (values & BIT(pin)) ? 1 : 0;
106 }
107
108 return ret;
109}
110
124
129#ifdef __cplusplus
130}
131#endif
132
133#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:70
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:98
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:261
uint32_t gpio_flags_t
Provides a type to hold GPIO configuration flags.
Definition gpio.h:281
uint32_t gpio_port_pins_t
Identifies a set of pins associated with a port.
Definition gpio.h:240
uint32_t gpio_port_value_t
Provides values for a set of pins associated with a port.
Definition gpio.h:253
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
flags
Definition parser.h:97
Runtime device structure (in ROM) per driver instance.
Definition device.h:510