13#ifndef ZEPHYR_INCLUDE_DRIVERS_GPIO_GPIO_UTILS_H_
14#define ZEPHYR_INCLUDE_DRIVERS_GPIO_GPIO_UTILS_H_
41#define GPIO_PORT_PIN_MASK_FROM_NGPIOS(ngpios) \
42 ((gpio_port_pins_t)(((uint64_t)1 << (ngpios)) - 1U))
52#define GPIO_PORT_PIN_MASK_FROM_DT_NODE(node_id) \
53 GPIO_DT_PORT_PIN_MASK_NGPIOS_EXC(node_id, DT_PROP(node_id, ngpios))
63#define GPIO_PORT_PIN_MASK_FROM_DT_INST(inst) \
64 GPIO_PORT_PIN_MASK_FROM_DT_NODE(DT_DRV_INST(inst))
79 __ASSERT(callback,
"No callback!");
80 __ASSERT(callback->
handler,
"No callback handler!");
107 const struct device *port,
116 __ASSERT(cb->
handler,
"No callback handler!");
Public APIs for GPIO drivers.
static void gpio_fire_callbacks(sys_slist_t *list, const struct device *port, uint32_t pins)
Generic function to go through and fire callback from a callback list.
Definition gpio_utils.h:106
static int gpio_manage_callback(sys_slist_t *callbacks, struct gpio_callback *callback, bool set)
Generic function to insert or remove a callback from a callback list.
Definition gpio_utils.h:75
static bool sys_slist_find_and_remove(sys_slist_t *list, sys_snode_t *node)
Find and remove a node from a list.
Definition slist.h:448
struct _slist sys_slist_t
Single-linked list structure.
Definition slist.h:49
static void sys_slist_prepend(sys_slist_t *list, sys_snode_t *node)
Prepend a node to the given list.
Definition slist.h:305
#define SYS_SLIST_FOR_EACH_CONTAINER_SAFE(__sl, __cn, __cns, __n)
Provide the primitive to safely iterate on a list under a container Note: __cn can be detached,...
Definition slist.h:183
static bool sys_slist_is_empty(const sys_slist_t *list)
Test if the given list is empty.
Definition slist.h:268
#define sys_port_trace_gpio_fire_callbacks_enter(list, port, pins)
Definition tracing.h:2730
#define sys_port_trace_gpio_fire_callback(port, callback)
Definition tracing.h:2737
#define EINVAL
Invalid argument.
Definition errno.h:60
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Runtime device structure (in ROM) per driver instance.
Definition device.h:510
GPIO callback structure.
Definition gpio.h:747
sys_snode_t node
This is meant to be used in the driver and the user should not mess with it (see drivers/gpio/gpio_ut...
Definition gpio.h:751
gpio_port_pins_t pin_mask
A mask of pins the callback is interested in, if 0 the callback will never be called.
Definition gpio.h:762
gpio_callback_handler_t handler
Actual callback function being called when relevant.
Definition gpio.h:754