Zephyr Project API 4.3.2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
gpio.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019-2020 Nordic Semiconductor ASA
3 * Copyright (c) 2019 Piotr Mienkowski
4 * Copyright (c) 2017 ARM Ltd
5 * Copyright (c) 2015-2016 Intel Corporation.
6 *
7 * SPDX-License-Identifier: Apache-2.0
8 */
9
15
16#ifndef ZEPHYR_INCLUDE_DRIVERS_GPIO_H_
17#define ZEPHYR_INCLUDE_DRIVERS_GPIO_H_
18
19#include <errno.h>
20
21#include <zephyr/sys/__assert.h>
22#include <zephyr/sys/slist.h>
24
25#include <zephyr/types.h>
26#include <stddef.h>
27#include <zephyr/device.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
48
53
55#define GPIO_INPUT BIT(16)
56
58#define GPIO_OUTPUT BIT(17)
59
61#define GPIO_DISCONNECTED 0
62
64
65/* Initializes output to a low state. */
66#define GPIO_OUTPUT_INIT_LOW BIT(18)
67
68/* Initializes output to a high state. */
69#define GPIO_OUTPUT_INIT_HIGH BIT(19)
70
71/* Initializes output based on logic level */
72#define GPIO_OUTPUT_INIT_LOGICAL BIT(20)
73
75
77#define GPIO_OUTPUT_LOW (GPIO_OUTPUT | GPIO_OUTPUT_INIT_LOW)
79#define GPIO_OUTPUT_HIGH (GPIO_OUTPUT | GPIO_OUTPUT_INIT_HIGH)
81#define GPIO_OUTPUT_INACTIVE (GPIO_OUTPUT | \
82 GPIO_OUTPUT_INIT_LOW | \
83 GPIO_OUTPUT_INIT_LOGICAL)
84
85#define GPIO_OUTPUT_ACTIVE (GPIO_OUTPUT | \
86 GPIO_OUTPUT_INIT_HIGH | \
87 GPIO_OUTPUT_INIT_LOGICAL)
88
90
106
108#define GPIO_INT_DISABLE BIT(21)
109
111
112/* Enables GPIO pin interrupt. */
113#define GPIO_INT_ENABLE BIT(22)
114
115/* GPIO interrupt is sensitive to logical levels.
116 *
117 * This is a component flag that should be combined with other
118 * `GPIO_INT_*` flags to produce a meaningful configuration.
119 */
120#define GPIO_INT_LEVELS_LOGICAL BIT(23)
121
122/* GPIO interrupt is edge sensitive.
123 *
124 * Note: by default interrupts are level sensitive.
125 *
126 * This is a component flag that should be combined with other
127 * `GPIO_INT_*` flags to produce a meaningful configuration.
128 */
129#define GPIO_INT_EDGE BIT(24)
130
131/* Trigger detection when input state is (or transitions to) physical low or
132 * logical 0 level.
133 *
134 * This is a component flag that should be combined with other
135 * `GPIO_INT_*` flags to produce a meaningful configuration.
136 */
137#define GPIO_INT_LOW_0 BIT(25)
138
139/* Trigger detection on input state is (or transitions to) physical high or
140 * logical 1 level.
141 *
142 * This is a component flag that should be combined with other
143 * `GPIO_INT_*` flags to produce a meaningful configuration.
144 */
145#define GPIO_INT_HIGH_1 BIT(26)
146
147#ifdef CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT
148/* Disable/Enable interrupt functionality without changing other interrupt
149 * related register, such as clearing the pending register.
150 *
151 * This is a component flag that should be combined with `GPIO_INT_ENABLE` or
152 * `GPIO_INT_DISABLE` flags to produce a meaningful configuration.
153 */
154#define GPIO_INT_ENABLE_DISABLE_ONLY BIT(27)
155#endif /* CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT */
156
157#define GPIO_INT_MASK (GPIO_INT_DISABLE | \
158 GPIO_INT_ENABLE | \
159 GPIO_INT_LEVELS_LOGICAL | \
160 GPIO_INT_EDGE | \
161 GPIO_INT_LOW_0 | \
162 GPIO_INT_HIGH_1)
163
165
168#define GPIO_INT_EDGE_RISING (GPIO_INT_ENABLE | \
169 GPIO_INT_EDGE | \
170 GPIO_INT_HIGH_1)
171
175#define GPIO_INT_EDGE_FALLING (GPIO_INT_ENABLE | \
176 GPIO_INT_EDGE | \
177 GPIO_INT_LOW_0)
178
182#define GPIO_INT_EDGE_BOTH (GPIO_INT_ENABLE | \
183 GPIO_INT_EDGE | \
184 GPIO_INT_LOW_0 | \
185 GPIO_INT_HIGH_1)
186
190#define GPIO_INT_LEVEL_LOW (GPIO_INT_ENABLE | \
191 GPIO_INT_LOW_0)
192
196#define GPIO_INT_LEVEL_HIGH (GPIO_INT_ENABLE | \
197 GPIO_INT_HIGH_1)
198
202#define GPIO_INT_EDGE_TO_INACTIVE (GPIO_INT_ENABLE | \
203 GPIO_INT_LEVELS_LOGICAL | \
204 GPIO_INT_EDGE | \
205 GPIO_INT_LOW_0)
206
210#define GPIO_INT_EDGE_TO_ACTIVE (GPIO_INT_ENABLE | \
211 GPIO_INT_LEVELS_LOGICAL | \
212 GPIO_INT_EDGE | \
213 GPIO_INT_HIGH_1)
214
218#define GPIO_INT_LEVEL_INACTIVE (GPIO_INT_ENABLE | \
219 GPIO_INT_LEVELS_LOGICAL | \
220 GPIO_INT_LOW_0)
221
225#define GPIO_INT_LEVEL_ACTIVE (GPIO_INT_ENABLE | \
226 GPIO_INT_LEVELS_LOGICAL | \
227 GPIO_INT_HIGH_1)
228
230
232#define GPIO_DIR_MASK (GPIO_INPUT | GPIO_OUTPUT)
234
242
255
263
275
283
304
339#define GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, idx) \
340 { \
341 .port = DEVICE_DT_GET(DT_GPIO_CTLR_BY_IDX(node_id, prop, idx)),\
342 .pin = DT_GPIO_PIN_BY_IDX(node_id, prop, idx), \
343 .dt_flags = DT_GPIO_FLAGS_BY_IDX(node_id, prop, idx), \
344 }
345
363#define GPIO_DT_SPEC_GET_BY_IDX_OR(node_id, prop, idx, default_value) \
364 COND_CODE_1(DT_PROP_HAS_IDX(node_id, prop, idx), \
365 (GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, idx)), \
366 (default_value))
367
376#define GPIO_DT_SPEC_GET(node_id, prop) \
377 GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, 0)
378
389#define GPIO_DT_SPEC_GET_OR(node_id, prop, default_value) \
390 GPIO_DT_SPEC_GET_BY_IDX_OR(node_id, prop, 0, default_value)
391
402#define GPIO_DT_SPEC_INST_GET_BY_IDX(inst, prop, idx) \
403 GPIO_DT_SPEC_GET_BY_IDX(DT_DRV_INST(inst), prop, idx)
404
416#define GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, prop, idx, default_value) \
417 COND_CODE_1(DT_PROP_HAS_IDX(DT_DRV_INST(inst), prop, idx), \
418 (GPIO_DT_SPEC_GET_BY_IDX(DT_DRV_INST(inst), prop, idx)), \
419 (default_value))
420
429#define GPIO_DT_SPEC_INST_GET(inst, prop) \
430 GPIO_DT_SPEC_INST_GET_BY_IDX(inst, prop, 0)
431
442#define GPIO_DT_SPEC_INST_GET_OR(inst, prop, default_value) \
443 GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, prop, 0, default_value)
444
445/*
446 * @cond INTERNAL_HIDDEN
447 */
448
459#define Z_GPIO_GEN_BITMASK_COND(node_id, prop, off_idx, sz_idx) \
460 COND_CODE_1(DT_PROP_HAS_IDX(node_id, prop, off_idx), \
461 (COND_CODE_0(DT_PROP_BY_IDX(node_id, prop, sz_idx), \
462 (0), \
463 (GENMASK64(DT_PROP_BY_IDX(node_id, prop, off_idx) + \
464 DT_PROP_BY_IDX(node_id, prop, sz_idx) - 1, \
465 DT_PROP_BY_IDX(node_id, prop, off_idx)))) \
466 ), (0))
467
475#define Z_GPIO_GEN_RESERVED_RANGES_COND(odd_it, node_id) \
476 COND_CODE_1(DT_PROP_HAS_IDX(node_id, gpio_reserved_ranges, odd_it), \
477 (Z_GPIO_GEN_BITMASK_COND(node_id, \
478 gpio_reserved_ranges, \
479 GET_ARG_N(odd_it, Z_SPARSE_LIST_EVEN_NUMBERS), \
480 odd_it)), \
481 (0))
482
486
574#define GPIO_DT_RESERVED_RANGES_NGPIOS(node_id, ngpios) \
575 ((gpio_port_pins_t) \
576 COND_CODE_1(DT_NODE_HAS_PROP(node_id, gpio_reserved_ranges), \
577 (GENMASK64(BITS_PER_LONG_LONG - 1, ngpios) \
578 | FOR_EACH_FIXED_ARG(Z_GPIO_GEN_RESERVED_RANGES_COND, \
579 (|), \
580 node_id, \
581 LIST_DROP_EMPTY(Z_SPARSE_LIST_ODD_NUMBERS))), \
582 (0)))
583
591#define GPIO_DT_RESERVED_RANGES(node_id) \
592 GPIO_DT_RESERVED_RANGES_NGPIOS(node_id, DT_PROP(node_id, ngpios))
593
603#define GPIO_DT_INST_RESERVED_RANGES_NGPIOS(inst, ngpios) \
604 GPIO_DT_RESERVED_RANGES_NGPIOS(DT_DRV_INST(inst), ngpios)
605
614#define GPIO_DT_INST_RESERVED_RANGES(inst) \
615 GPIO_DT_RESERVED_RANGES(DT_DRV_INST(inst))
616
665#define GPIO_DT_PORT_PIN_MASK_NGPIOS_EXC(node_id, ngpios) \
666 ((gpio_port_pins_t) \
667 COND_CODE_0(ngpios, \
668 (0), \
669 (COND_CODE_1(DT_NODE_HAS_PROP(node_id, gpio_reserved_ranges), \
670 ((GENMASK64(ngpios - 1, 0) & \
671 ~GPIO_DT_RESERVED_RANGES_NGPIOS(node_id, ngpios))), \
672 (GENMASK64(ngpios - 1, 0))) \
673 ) \
674 ))
675
685#define GPIO_DT_INST_PORT_PIN_MASK_NGPIOS_EXC(inst, ngpios) \
686 GPIO_DT_PORT_PIN_MASK_NGPIOS_EXC(DT_DRV_INST(inst), ngpios)
687
691#define GPIO_MAX_PINS_PER_PORT (sizeof(gpio_port_pins_t) * __CHAR_BIT__)
692
708static inline bool gpio_port_pin_is_supported(gpio_port_pins_t port_pin_mask, gpio_pin_t pin)
709{
710 if (pin >= GPIO_MAX_PINS_PER_PORT) {
711 return false;
712 }
713
714 return (port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U;
715}
716
730
743
744struct gpio_callback;
745
758typedef void (*gpio_callback_handler_t)(const struct device *port,
759 struct gpio_callback *cb,
760 gpio_port_pins_t pins);
761
789
795
796/* Used by driver api function pin_interrupt_configure, these are defined
797 * in terms of the public flags so we can just mask and pass them
798 * through to the driver api
799 */
800enum gpio_int_mode {
801 GPIO_INT_MODE_DISABLED = GPIO_INT_DISABLE,
802 GPIO_INT_MODE_LEVEL = GPIO_INT_ENABLE,
803 GPIO_INT_MODE_EDGE = GPIO_INT_ENABLE | GPIO_INT_EDGE,
804#ifdef CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT
805 GPIO_INT_MODE_DISABLE_ONLY = GPIO_INT_DISABLE | GPIO_INT_ENABLE_DISABLE_ONLY,
806 GPIO_INT_MODE_ENABLE_ONLY = GPIO_INT_ENABLE | GPIO_INT_ENABLE_DISABLE_ONLY,
807#endif /* CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT */
808};
809
810enum gpio_int_trig {
811 /* Trigger detection when input state is (or transitions to)
812 * physical low. (Edge Falling or Active Low)
813 */
814 GPIO_INT_TRIG_LOW = GPIO_INT_LOW_0,
815 /* Trigger detection when input state is (or transitions to)
816 * physical high. (Edge Rising or Active High) */
817 GPIO_INT_TRIG_HIGH = GPIO_INT_HIGH_1,
818 /* Trigger detection on pin rising or falling edge. */
819 GPIO_INT_TRIG_BOTH = GPIO_INT_LOW_0 | GPIO_INT_HIGH_1,
820 /* Trigger a system wakeup. */
821 GPIO_INT_TRIG_WAKE = GPIO_INT_WAKEUP,
822 /* Trigger a system wakeup when input state is (or transitions to)
823 * physical low. (Edge Falling or Active Low)
824 */
825 GPIO_INT_TRIG_WAKE_LOW = GPIO_INT_LOW_0 | GPIO_INT_WAKEUP,
826 /* Trigger a system wakeup when input state is (or transitions to)
827 * physical high. (Edge Rising or Active High)
828 */
829 GPIO_INT_TRIG_WAKE_HIGH = GPIO_INT_HIGH_1 | GPIO_INT_WAKEUP,
830 /* Trigger a system wakeup on pin rising or falling edge. */
831 GPIO_INT_TRIG_WAKE_BOTH = GPIO_INT_LOW_0 | GPIO_INT_HIGH_1 | GPIO_INT_WAKEUP,
832};
833
834__subsystem struct gpio_driver_api {
835 int (*pin_configure)(const struct device *port, gpio_pin_t pin,
837#ifdef CONFIG_GPIO_GET_CONFIG
838 int (*pin_get_config)(const struct device *port, gpio_pin_t pin,
840#endif
841 int (*port_get_raw)(const struct device *port,
842 gpio_port_value_t *value);
843 int (*port_set_masked_raw)(const struct device *port,
844 gpio_port_pins_t mask,
845 gpio_port_value_t value);
846 int (*port_set_bits_raw)(const struct device *port,
847 gpio_port_pins_t pins);
848 int (*port_clear_bits_raw)(const struct device *port,
849 gpio_port_pins_t pins);
850 int (*port_toggle_bits)(const struct device *port,
851 gpio_port_pins_t pins);
852 int (*pin_interrupt_configure)(const struct device *port,
853 gpio_pin_t pin,
854 enum gpio_int_mode mode,
855 enum gpio_int_trig trig);
856 int (*manage_callback)(const struct device *port,
857 struct gpio_callback *cb,
858 bool set);
859 uint32_t (*get_pending_int)(const struct device *dev);
860#ifdef CONFIG_GPIO_GET_DIRECTION
861 int (*port_get_direction)(const struct device *port, gpio_port_pins_t map,
862 gpio_port_pins_t *inputs, gpio_port_pins_t *outputs);
863#endif /* CONFIG_GPIO_GET_DIRECTION */
864};
865
869
878static inline bool gpio_is_ready_dt(const struct gpio_dt_spec *spec)
879{
880 /* Validate port is ready */
881 return device_is_ready(spec->port);
882}
883
907__syscall int gpio_pin_interrupt_configure(const struct device *port,
908 gpio_pin_t pin,
910
911static inline int z_impl_gpio_pin_interrupt_configure(const struct device *port,
912 gpio_pin_t pin,
914{
915 const struct gpio_driver_api *api =
916 (const struct gpio_driver_api *)port->api;
917 __unused const struct gpio_driver_config *const cfg =
918 (const struct gpio_driver_config *)port->config;
919 const struct gpio_driver_data *const data =
920 (const struct gpio_driver_data *)port->data;
921 enum gpio_int_trig trig;
922 enum gpio_int_mode mode;
923 int ret;
924
925 SYS_PORT_TRACING_FUNC_ENTER(gpio_pin, interrupt_configure, port, pin, flags);
926
927 if (api->pin_interrupt_configure == NULL) {
928 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, interrupt_configure, port, pin, -ENOSYS);
929 return -ENOSYS;
930 }
931
932 __ASSERT((flags & (GPIO_INT_DISABLE | GPIO_INT_ENABLE))
933 != (GPIO_INT_DISABLE | GPIO_INT_ENABLE),
934 "Cannot both enable and disable interrupts");
935
936 __ASSERT((flags & (GPIO_INT_DISABLE | GPIO_INT_ENABLE)) != 0U,
937 "Must either enable or disable interrupts");
938
939 __ASSERT(((flags & GPIO_INT_ENABLE) == 0) ||
940 ((flags & GPIO_INT_EDGE) != 0) ||
941 ((flags & (GPIO_INT_LOW_0 | GPIO_INT_HIGH_1)) !=
942 (GPIO_INT_LOW_0 | GPIO_INT_HIGH_1)),
943 "Only one of GPIO_INT_LOW_0, GPIO_INT_HIGH_1 can be "
944 "enabled for a level interrupt.");
945
946#ifdef CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT
947#define GPIO_INT_ENABLE_DISABLE_ONLY_VALUE GPIO_INT_ENABLE_DISABLE_ONLY
948#else
949#define GPIO_INT_ENABLE_DISABLE_ONLY_VALUE 0
950#endif /* CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT */
951
952 __ASSERT(((flags & GPIO_INT_ENABLE) == 0) ||
953 ((flags & (GPIO_INT_LOW_0 | GPIO_INT_HIGH_1)) != 0) ||
955 "At least one of GPIO_INT_LOW_0, GPIO_INT_HIGH_1 has to be enabled.");
956#undef GPIO_INT_ENABLE_DISABLE_ONLY_VALUE
957 __ASSERT(gpio_port_pin_is_supported(cfg->port_pin_mask, pin), "Unsupported pin");
958
959 /* See the note in z_impl_gpio_pin_configure(). */
960 if (pin >= GPIO_MAX_PINS_PER_PORT) {
961 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, interrupt_configure, port, pin, -EINVAL);
962 return -EINVAL;
963 }
964
965 if (((flags & GPIO_INT_LEVELS_LOGICAL) != 0) &&
966 ((data->invert & (gpio_port_pins_t)BIT(pin)) != 0)) {
967 /* Invert signal bits */
968 flags ^= (GPIO_INT_LOW_0 | GPIO_INT_HIGH_1);
969 }
970
971 trig = (enum gpio_int_trig)(flags & (GPIO_INT_LOW_0 | GPIO_INT_HIGH_1 | GPIO_INT_WAKEUP));
972#ifdef CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT
973 mode = (enum gpio_int_mode)(flags & (GPIO_INT_EDGE | GPIO_INT_DISABLE | GPIO_INT_ENABLE |
974 GPIO_INT_ENABLE_DISABLE_ONLY));
975#else
976 mode = (enum gpio_int_mode)(flags & (GPIO_INT_EDGE | GPIO_INT_DISABLE | GPIO_INT_ENABLE));
977#endif /* CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT */
978
979 ret = api->pin_interrupt_configure(port, pin, mode, trig);
980 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, interrupt_configure, port, pin, ret);
981 return ret;
982}
983
1001static inline int gpio_pin_interrupt_configure_dt(const struct gpio_dt_spec *spec,
1003{
1004 return gpio_pin_interrupt_configure(spec->port, spec->pin,
1005 flags | (spec->dt_flags & GPIO_INT_WAKEUP));
1006}
1007
1023__syscall int gpio_pin_configure(const struct device *port,
1024 gpio_pin_t pin,
1026
1027static inline int z_impl_gpio_pin_configure(const struct device *port,
1028 gpio_pin_t pin,
1030{
1031 const struct gpio_driver_api *api =
1032 (const struct gpio_driver_api *)port->api;
1033 __unused const struct gpio_driver_config *const cfg =
1034 (const struct gpio_driver_config *)port->config;
1035 struct gpio_driver_data *data =
1036 (struct gpio_driver_data *)port->data;
1037 int ret;
1038
1039 SYS_PORT_TRACING_FUNC_ENTER(gpio_pin, configure, port, pin, flags);
1040
1041 __ASSERT((flags & GPIO_INT_MASK) == 0,
1042 "Interrupt flags are not supported");
1043
1044 __ASSERT((flags & (GPIO_PULL_UP | GPIO_PULL_DOWN)) !=
1046 "Pull Up and Pull Down should not be enabled simultaneously");
1047
1048 __ASSERT(!((flags & GPIO_INPUT) && !(flags & GPIO_OUTPUT) && (flags & GPIO_SINGLE_ENDED)),
1049 "Input cannot be enabled for 'Open Drain', 'Open Source' modes without Output");
1050
1051 __ASSERT_NO_MSG((flags & GPIO_SINGLE_ENDED) != 0 ||
1052 (flags & GPIO_LINE_OPEN_DRAIN) == 0);
1053
1054 __ASSERT((flags & (GPIO_OUTPUT_INIT_LOW | GPIO_OUTPUT_INIT_HIGH)) == 0
1055 || (flags & GPIO_OUTPUT) != 0,
1056 "Output needs to be enabled to be initialized low or high");
1057
1058 __ASSERT((flags & (GPIO_OUTPUT_INIT_LOW | GPIO_OUTPUT_INIT_HIGH))
1059 != (GPIO_OUTPUT_INIT_LOW | GPIO_OUTPUT_INIT_HIGH),
1060 "Output cannot be initialized low and high");
1061
1062 if (((flags & GPIO_OUTPUT_INIT_LOGICAL) != 0)
1063 && ((flags & (GPIO_OUTPUT_INIT_LOW | GPIO_OUTPUT_INIT_HIGH)) != 0)
1064 && ((flags & GPIO_ACTIVE_LOW) != 0)) {
1065 flags ^= GPIO_OUTPUT_INIT_LOW | GPIO_OUTPUT_INIT_HIGH;
1066 }
1067
1068 flags &= ~GPIO_OUTPUT_INIT_LOGICAL;
1069
1070 __ASSERT(gpio_port_pin_is_supported(cfg->port_pin_mask, pin), "Unsupported pin");
1071
1072 /*
1073 * pin is passed on to the driver as-is, where it is commonly used as an
1074 * array index, so it must be range checked even when assertions are
1075 * compiled out.
1076 */
1077 if (pin >= GPIO_MAX_PINS_PER_PORT) {
1078 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, configure, port, pin, -EINVAL);
1079 return -EINVAL;
1080 }
1081
1082 if ((flags & GPIO_ACTIVE_LOW) != 0) {
1083 data->invert |= (gpio_port_pins_t)BIT(pin);
1084 } else {
1085 data->invert &= ~(gpio_port_pins_t)BIT(pin);
1086 }
1087
1088 ret = api->pin_configure(port, pin, flags);
1089 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, configure, port, pin, ret);
1090 return ret;
1091}
1092
1104static inline int gpio_pin_configure_dt(const struct gpio_dt_spec *spec,
1105 gpio_flags_t extra_flags)
1106{
1107 return gpio_pin_configure(spec->port,
1108 spec->pin,
1109 spec->dt_flags | extra_flags);
1110}
1111
1130__syscall int gpio_port_get_direction(const struct device *port, gpio_port_pins_t map,
1131 gpio_port_pins_t *inputs, gpio_port_pins_t *outputs);
1132
1133#ifdef CONFIG_GPIO_GET_DIRECTION
1134static inline int z_impl_gpio_port_get_direction(const struct device *port, gpio_port_pins_t map,
1135 gpio_port_pins_t *inputs,
1136 gpio_port_pins_t *outputs)
1137{
1138 const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->api;
1139 int ret;
1140
1141 SYS_PORT_TRACING_FUNC_ENTER(gpio_port, get_direction, port, map, inputs, outputs);
1142
1143 if (api->port_get_direction == NULL) {
1144 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, get_direction, port, -ENOSYS);
1145 return -ENOSYS;
1146 }
1147
1148 ret = api->port_get_direction(port, map, inputs, outputs);
1149 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, get_direction, port, ret);
1150 return ret;
1151}
1152#endif /* CONFIG_GPIO_GET_DIRECTION */
1153
1166static inline int gpio_pin_is_input(const struct device *port, gpio_pin_t pin)
1167{
1168 int rv;
1169 gpio_port_pins_t pins;
1170 __unused const struct gpio_driver_config *cfg =
1171 (const struct gpio_driver_config *)port->config;
1172
1173 __ASSERT(gpio_port_pin_is_supported(cfg->port_pin_mask, pin), "Unsupported pin");
1174
1175 rv = gpio_port_get_direction(port, BIT(pin), &pins, NULL);
1176 if (rv < 0) {
1177 return rv;
1178 }
1179
1180 return (int)!!((gpio_port_pins_t)BIT(pin) & pins);
1181}
1182
1194static inline int gpio_pin_is_input_dt(const struct gpio_dt_spec *spec)
1195{
1196 return gpio_pin_is_input(spec->port, spec->pin);
1197}
1198
1211static inline int gpio_pin_is_output(const struct device *port, gpio_pin_t pin)
1212{
1213 int rv;
1214 gpio_port_pins_t pins;
1215 __unused const struct gpio_driver_config *cfg =
1216 (const struct gpio_driver_config *)port->config;
1217
1218 __ASSERT(gpio_port_pin_is_supported(cfg->port_pin_mask, pin), "Unsupported pin");
1219
1220 rv = gpio_port_get_direction(port, BIT(pin), NULL, &pins);
1221 if (rv < 0) {
1222 return rv;
1223 }
1224
1225 return (int)!!((gpio_port_pins_t)BIT(pin) & pins);
1226}
1227
1239static inline int gpio_pin_is_output_dt(const struct gpio_dt_spec *spec)
1240{
1241 return gpio_pin_is_output(spec->port, spec->pin);
1242}
1243
1259__syscall int gpio_pin_get_config(const struct device *port, gpio_pin_t pin,
1261
1262#ifdef CONFIG_GPIO_GET_CONFIG
1263static inline int z_impl_gpio_pin_get_config(const struct device *port,
1264 gpio_pin_t pin,
1266{
1267 const struct gpio_driver_api *api =
1268 (const struct gpio_driver_api *)port->api;
1269 int ret;
1270
1271 SYS_PORT_TRACING_FUNC_ENTER(gpio_pin, get_config, port, pin, *flags);
1272
1273 if (api->pin_get_config == NULL) {
1274 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, get_config, port, pin, -ENOSYS);
1275 return -ENOSYS;
1276 }
1277
1278 /* See the note in z_impl_gpio_pin_configure(). */
1279 if (pin >= GPIO_MAX_PINS_PER_PORT) {
1280 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, get_config, port, pin, -EINVAL);
1281 return -EINVAL;
1282 }
1283
1284 ret = api->pin_get_config(port, pin, flags);
1285 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, get_config, port, pin, ret);
1286 return ret;
1287}
1288#endif
1289
1302static inline int gpio_pin_get_config_dt(const struct gpio_dt_spec *spec,
1304{
1305 return gpio_pin_get_config(spec->port, spec->pin, flags);
1306}
1307
1325__syscall int gpio_port_get_raw(const struct device *port,
1326 gpio_port_value_t *value);
1327
1328static inline int z_impl_gpio_port_get_raw(const struct device *port, gpio_port_value_t *value)
1329{
1330 const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->api;
1331 int ret;
1332
1333 SYS_PORT_TRACING_FUNC_ENTER(gpio_port, get_raw, port, value);
1334
1335 ret = api->port_get_raw(port, value);
1336 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, get_raw, port, ret);
1337 return ret;
1338}
1339
1358static inline int gpio_port_get(const struct device *port,
1359 gpio_port_value_t *value)
1360{
1361 const struct gpio_driver_data *const data =
1362 (const struct gpio_driver_data *)port->data;
1363 int ret;
1364
1365 ret = gpio_port_get_raw(port, value);
1366 if (ret == 0) {
1367 *value ^= data->invert;
1368 }
1369
1370 return ret;
1371}
1372
1390__syscall int gpio_port_set_masked_raw(const struct device *port,
1391 gpio_port_pins_t mask,
1392 gpio_port_value_t value);
1393
1394static inline int z_impl_gpio_port_set_masked_raw(const struct device *port,
1395 gpio_port_pins_t mask,
1396 gpio_port_value_t value)
1397{
1398 const struct gpio_driver_api *api =
1399 (const struct gpio_driver_api *)port->api;
1400 int ret;
1401
1402 SYS_PORT_TRACING_FUNC_ENTER(gpio_port, set_masked_raw, port, mask, value);
1403
1404 ret = api->port_set_masked_raw(port, mask, value);
1405 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, set_masked_raw, port, ret);
1406 return ret;
1407}
1408
1429static inline int gpio_port_set_masked(const struct device *port,
1430 gpio_port_pins_t mask,
1431 gpio_port_value_t value)
1432{
1433 const struct gpio_driver_data *const data =
1434 (const struct gpio_driver_data *)port->data;
1435
1436 value ^= data->invert;
1437
1438 return gpio_port_set_masked_raw(port, mask, value);
1439}
1440
1451__syscall int gpio_port_set_bits_raw(const struct device *port,
1452 gpio_port_pins_t pins);
1453
1454static inline int z_impl_gpio_port_set_bits_raw(const struct device *port,
1455 gpio_port_pins_t pins)
1456{
1457 const struct gpio_driver_api *api =
1458 (const struct gpio_driver_api *)port->api;
1459 int ret;
1460
1461 SYS_PORT_TRACING_FUNC_ENTER(gpio_port, set_bits_raw, port, pins);
1462
1463 ret = api->port_set_bits_raw(port, pins);
1464 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, set_bits_raw, port, ret);
1465 return ret;
1466}
1467
1478static inline int gpio_port_set_bits(const struct device *port,
1479 gpio_port_pins_t pins)
1480{
1481 return gpio_port_set_masked(port, pins, pins);
1482}
1483
1494__syscall int gpio_port_clear_bits_raw(const struct device *port,
1495 gpio_port_pins_t pins);
1496
1497static inline int z_impl_gpio_port_clear_bits_raw(const struct device *port,
1498 gpio_port_pins_t pins)
1499{
1500 const struct gpio_driver_api *api =
1501 (const struct gpio_driver_api *)port->api;
1502 int ret;
1503
1504 SYS_PORT_TRACING_FUNC_ENTER(gpio_port, clear_bits_raw, port, pins);
1505
1506 ret = api->port_clear_bits_raw(port, pins);
1507 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, clear_bits_raw, port, ret);
1508 return ret;
1509}
1510
1521static inline int gpio_port_clear_bits(const struct device *port,
1522 gpio_port_pins_t pins)
1523{
1524 return gpio_port_set_masked(port, pins, 0);
1525}
1526
1537__syscall int gpio_port_toggle_bits(const struct device *port,
1538 gpio_port_pins_t pins);
1539
1540static inline int z_impl_gpio_port_toggle_bits(const struct device *port,
1541 gpio_port_pins_t pins)
1542{
1543 const struct gpio_driver_api *api =
1544 (const struct gpio_driver_api *)port->api;
1545 int ret;
1546
1547 SYS_PORT_TRACING_FUNC_ENTER(gpio_port, toggle_bits, port, pins);
1548
1549 ret = api->port_toggle_bits(port, pins);
1550 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, toggle_bits, port, ret);
1551 return ret;
1552}
1553
1565static inline int gpio_port_set_clr_bits_raw(const struct device *port,
1566 gpio_port_pins_t set_pins,
1567 gpio_port_pins_t clear_pins)
1568{
1569 __ASSERT((set_pins & clear_pins) == 0, "Set and Clear pins overlap");
1570
1571 return gpio_port_set_masked_raw(port, set_pins | clear_pins, set_pins);
1572}
1573
1585static inline int gpio_port_set_clr_bits(const struct device *port,
1586 gpio_port_pins_t set_pins,
1587 gpio_port_pins_t clear_pins)
1588{
1589 __ASSERT((set_pins & clear_pins) == 0, "Set and Clear pins overlap");
1590
1591 return gpio_port_set_masked(port, set_pins | clear_pins, set_pins);
1592}
1593
1609static inline int gpio_pin_get_raw(const struct device *port, gpio_pin_t pin)
1610{
1611 __unused const struct gpio_driver_config *const cfg =
1612 (const struct gpio_driver_config *)port->config;
1613 gpio_port_value_t value;
1614 int ret;
1615
1616 __ASSERT(gpio_port_pin_is_supported(cfg->port_pin_mask, pin), "Unsupported pin");
1617
1618 ret = gpio_port_get_raw(port, &value);
1619 if (ret == 0) {
1620 ret = (value & (gpio_port_pins_t)BIT(pin)) != 0 ? 1 : 0;
1621 }
1622
1623 return ret;
1624}
1625
1645static inline int gpio_pin_get(const struct device *port, gpio_pin_t pin)
1646{
1647 __unused const struct gpio_driver_config *const cfg =
1648 (const struct gpio_driver_config *)port->config;
1649 gpio_port_value_t value;
1650 int ret;
1651
1652 __ASSERT(gpio_port_pin_is_supported(cfg->port_pin_mask, pin), "Unsupported pin");
1653
1654 ret = gpio_port_get(port, &value);
1655 if (ret == 0) {
1656 ret = (value & (gpio_port_pins_t)BIT(pin)) != 0 ? 1 : 0;
1657 }
1658
1659 return ret;
1660}
1661
1672static inline int gpio_pin_get_dt(const struct gpio_dt_spec *spec)
1673{
1674 return gpio_pin_get(spec->port, spec->pin);
1675}
1676
1692static inline int gpio_pin_set_raw(const struct device *port, gpio_pin_t pin,
1693 int value)
1694{
1695 __unused const struct gpio_driver_config *const cfg =
1696 (const struct gpio_driver_config *)port->config;
1697 int ret;
1698
1699 __ASSERT(gpio_port_pin_is_supported(cfg->port_pin_mask, pin), "Unsupported pin");
1700
1701 if (value != 0) {
1702 ret = gpio_port_set_bits_raw(port, (gpio_port_pins_t)BIT(pin));
1703 } else {
1705 }
1706
1707 return ret;
1708}
1709
1731static inline int gpio_pin_set(const struct device *port, gpio_pin_t pin,
1732 int value)
1733{
1734 __unused const struct gpio_driver_config *const cfg =
1735 (const struct gpio_driver_config *)port->config;
1736 const struct gpio_driver_data *const data =
1737 (const struct gpio_driver_data *)port->data;
1738
1739 __ASSERT(gpio_port_pin_is_supported(cfg->port_pin_mask, pin), "Unsupported pin");
1740
1741 if (data->invert & (gpio_port_pins_t)BIT(pin)) {
1742 value = (value != 0) ? 0 : 1;
1743 }
1744
1745 return gpio_pin_set_raw(port, pin, value);
1746}
1747
1759static inline int gpio_pin_set_dt(const struct gpio_dt_spec *spec, int value)
1760{
1761 return gpio_pin_set(spec->port, spec->pin, value);
1762}
1763
1774static inline int gpio_pin_toggle(const struct device *port, gpio_pin_t pin)
1775{
1776 __unused const struct gpio_driver_config *const cfg =
1777 (const struct gpio_driver_config *)port->config;
1778
1779 __ASSERT(gpio_port_pin_is_supported(cfg->port_pin_mask, pin), "Unsupported pin");
1780
1781 return gpio_port_toggle_bits(port, (gpio_port_pins_t)BIT(pin));
1782}
1783
1794static inline int gpio_pin_toggle_dt(const struct gpio_dt_spec *spec)
1795{
1796 return gpio_pin_toggle(spec->port, spec->pin);
1797}
1798
1805static inline void gpio_init_callback(struct gpio_callback *callback,
1807 gpio_port_pins_t pin_mask)
1808{
1809 SYS_PORT_TRACING_FUNC_ENTER(gpio, init_callback, callback, handler, pin_mask);
1810
1811 __ASSERT(callback, "Callback pointer should not be NULL");
1812 __ASSERT(handler, "Callback handler pointer should not be NULL");
1813
1814 callback->handler = handler;
1815 callback->pin_mask = pin_mask;
1816
1817 SYS_PORT_TRACING_FUNC_EXIT(gpio, init_callback, callback);
1818}
1819
1834static inline int gpio_add_callback(const struct device *port,
1835 struct gpio_callback *callback)
1836{
1837 const struct gpio_driver_api *api =
1838 (const struct gpio_driver_api *)port->api;
1839 int ret;
1840
1841 SYS_PORT_TRACING_FUNC_ENTER(gpio, add_callback, port, callback);
1842
1843 if (api->manage_callback == NULL) {
1844 SYS_PORT_TRACING_FUNC_EXIT(gpio, add_callback, port, -ENOSYS);
1845 return -ENOSYS;
1846 }
1847
1848 ret = api->manage_callback(port, callback, true);
1849 SYS_PORT_TRACING_FUNC_EXIT(gpio, add_callback, port, ret);
1850 return ret;
1851}
1852
1864static inline int gpio_add_callback_dt(const struct gpio_dt_spec *spec,
1865 struct gpio_callback *callback)
1866{
1867 return gpio_add_callback(spec->port, callback);
1868}
1869
1888static inline int gpio_remove_callback(const struct device *port,
1889 struct gpio_callback *callback)
1890{
1891 const struct gpio_driver_api *api =
1892 (const struct gpio_driver_api *)port->api;
1893 int ret;
1894
1895 SYS_PORT_TRACING_FUNC_ENTER(gpio, remove_callback, port, callback);
1896
1897 if (api->manage_callback == NULL) {
1898 SYS_PORT_TRACING_FUNC_EXIT(gpio, remove_callback, port, -ENOSYS);
1899 return -ENOSYS;
1900 }
1901
1902 ret = api->manage_callback(port, callback, false);
1903 SYS_PORT_TRACING_FUNC_EXIT(gpio, remove_callback, port, ret);
1904 return ret;
1905}
1906
1918static inline int gpio_remove_callback_dt(const struct gpio_dt_spec *spec,
1919 struct gpio_callback *callback)
1920{
1921 return gpio_remove_callback(spec->port, callback);
1922}
1923
1938__syscall int gpio_get_pending_int(const struct device *dev);
1939
1940static inline int z_impl_gpio_get_pending_int(const struct device *dev)
1941{
1942 const struct gpio_driver_api *api =
1943 (const struct gpio_driver_api *)dev->api;
1944 int ret;
1945
1946 SYS_PORT_TRACING_FUNC_ENTER(gpio, get_pending_int, dev);
1947
1948 if (api->get_pending_int == NULL) {
1949 SYS_PORT_TRACING_FUNC_EXIT(gpio, get_pending_int, dev, -ENOSYS);
1950 return -ENOSYS;
1951 }
1952
1953 ret = api->get_pending_int(dev);
1954 SYS_PORT_TRACING_FUNC_EXIT(gpio, get_pending_int, dev, ret);
1955 return ret;
1956}
1957
1961
1962#ifdef __cplusplus
1963}
1964#endif
1965
1966#include <zephyr/syscalls/gpio.h>
1967
1968#endif /* ZEPHYR_INCLUDE_DRIVERS_GPIO_H_ */
#define GPIO_INT_ENABLE_DISABLE_ONLY_VALUE
System error numbers.
bool device_is_ready(const struct device *dev)
Verify that a device is ready for use.
static int gpio_add_callback(const struct device *port, struct gpio_callback *callback)
Add an application callback.
Definition gpio.h:1834
#define GPIO_OUTPUT
Enables pin as output, no change to the output state.
Definition gpio.h:58
static int gpio_pin_get_raw(const struct device *port, gpio_pin_t pin)
Get physical level of an input pin.
Definition gpio.h:1609
int gpio_pin_get_config(const struct device *port, gpio_pin_t pin, gpio_flags_t *flags)
Get a configuration of a single pin.
#define GPIO_MAX_PINS_PER_PORT
Maximum number of pins that are supported by gpio_port_pins_t.
Definition gpio.h:691
static int gpio_pin_is_input(const struct device *port, gpio_pin_t pin)
Check if pin is configured for input.
Definition gpio.h:1166
static int gpio_pin_get(const struct device *port, gpio_pin_t pin)
Get logical level of an input pin.
Definition gpio.h:1645
int gpio_port_set_bits_raw(const struct device *port, gpio_port_pins_t pins)
Set physical level of selected output pins to high.
static int gpio_pin_is_output_dt(const struct gpio_dt_spec *spec)
Check if a single pin from gpio_dt_spec is configured for output.
Definition gpio.h:1239
static int gpio_pin_interrupt_configure_dt(const struct gpio_dt_spec *spec, gpio_flags_t flags)
Configure pin interrupts from a gpio_dt_spec.
Definition gpio.h:1001
static int gpio_remove_callback_dt(const struct gpio_dt_spec *spec, struct gpio_callback *callback)
Remove an application callback.
Definition gpio.h:1918
static int gpio_pin_toggle_dt(const struct gpio_dt_spec *spec)
Toggle pin level from a gpio_dt_spec.
Definition gpio.h:1794
uint8_t gpio_pin_t
Provides a type to hold a GPIO pin index.
Definition gpio.h:262
static int gpio_pin_is_output(const struct device *port, gpio_pin_t pin)
Check if pin is configured for output.
Definition gpio.h:1211
int gpio_get_pending_int(const struct device *dev)
Function to get pending interrupts.
static int gpio_pin_configure_dt(const struct gpio_dt_spec *spec, gpio_flags_t extra_flags)
Configure a single pin from a gpio_dt_spec and some extra flags.
Definition gpio.h:1104
static int gpio_pin_set_dt(const struct gpio_dt_spec *spec, int value)
Set logical level of a output pin from a gpio_dt_spec.
Definition gpio.h:1759
static int gpio_add_callback_dt(const struct gpio_dt_spec *spec, struct gpio_callback *callback)
Add an application callback.
Definition gpio.h:1864
static int gpio_port_set_bits(const struct device *port, gpio_port_pins_t pins)
Set logical level of selected output pins to active.
Definition gpio.h:1478
uint32_t gpio_flags_t
Provides a type to hold GPIO configuration flags.
Definition gpio.h:282
#define GPIO_ACTIVE_LOW
GPIO pin is active (has logical value '1') in low state.
Definition gpio.h:24
#define GPIO_INT_WAKEUP
Configures GPIO interrupt to wakeup the system from low power mode.
Definition gpio.h:83
static int gpio_port_set_clr_bits_raw(const struct device *port, gpio_port_pins_t set_pins, gpio_port_pins_t clear_pins)
Set physical level of selected output pins.
Definition gpio.h:1565
static int gpio_port_set_clr_bits(const struct device *port, gpio_port_pins_t set_pins, gpio_port_pins_t clear_pins)
Set logical level of selected output pins.
Definition gpio.h:1585
static void gpio_init_callback(struct gpio_callback *callback, gpio_callback_handler_t handler, gpio_port_pins_t pin_mask)
Helper to initialize a struct gpio_callback properly.
Definition gpio.h:1805
static int gpio_pin_is_input_dt(const struct gpio_dt_spec *spec)
Check if a single pin from gpio_dt_spec is configured for input.
Definition gpio.h:1194
#define GPIO_INPUT
Enables pin as input.
Definition gpio.h:55
uint32_t gpio_port_pins_t
Identifies a set of pins associated with a port.
Definition gpio.h:241
static int gpio_pin_get_config_dt(const struct gpio_dt_spec *spec, gpio_flags_t *flags)
Get a configuration of a single pin from a gpio_dt_spec.
Definition gpio.h:1302
int gpio_port_toggle_bits(const struct device *port, gpio_port_pins_t pins)
Toggle level of selected output pins.
#define GPIO_INT_DISABLE
Disables GPIO pin interrupt.
Definition gpio.h:108
int gpio_pin_interrupt_configure(const struct device *port, gpio_pin_t pin, gpio_flags_t flags)
Configure pin interrupt.
int gpio_port_clear_bits_raw(const struct device *port, gpio_port_pins_t pins)
Set physical level of selected output pins to low.
int gpio_port_set_masked_raw(const struct device *port, gpio_port_pins_t mask, gpio_port_value_t value)
Set physical level of output pins in a port.
#define GPIO_PULL_UP
Enables GPIO pin pull-up.
Definition gpio.h:73
static int gpio_pin_get_dt(const struct gpio_dt_spec *spec)
Get logical level of an input pin from a gpio_dt_spec.
Definition gpio.h:1672
static int gpio_pin_toggle(const struct device *port, gpio_pin_t pin)
Toggle pin level.
Definition gpio.h:1774
static bool gpio_is_ready_dt(const struct gpio_dt_spec *spec)
Validate that GPIO port is ready.
Definition gpio.h:878
static bool gpio_port_pin_is_supported(gpio_port_pins_t port_pin_mask, gpio_pin_t pin)
Check whether a pin is in range and supported by a GPIO controller.
Definition gpio.h:708
uint32_t gpio_port_value_t
Provides values for a set of pins associated with a port.
Definition gpio.h:254
static int gpio_pin_set(const struct device *port, gpio_pin_t pin, int value)
Set logical level of an output pin.
Definition gpio.h:1731
static int gpio_port_clear_bits(const struct device *port, gpio_port_pins_t pins)
Set logical level of selected output pins to inactive.
Definition gpio.h:1521
static int gpio_remove_callback(const struct device *port, struct gpio_callback *callback)
Remove an application callback.
Definition gpio.h:1888
static int gpio_port_set_masked(const struct device *port, gpio_port_pins_t mask, gpio_port_value_t value)
Set logical level of output pins in a port.
Definition gpio.h:1429
int gpio_port_get_direction(const struct device *port, gpio_port_pins_t map, gpio_port_pins_t *inputs, gpio_port_pins_t *outputs)
Get direction of select pins in a port.
uint16_t gpio_dt_flags_t
Provides a type to hold GPIO devicetree flags.
Definition gpio.h:274
#define GPIO_PULL_DOWN
Enable GPIO pin pull-down.
Definition gpio.h:76
static int gpio_pin_set_raw(const struct device *port, gpio_pin_t pin, int value)
Set physical level of an output pin.
Definition gpio.h:1692
int gpio_port_get_raw(const struct device *port, gpio_port_value_t *value)
Get physical level of all input pins in a port.
static int gpio_port_get(const struct device *port, gpio_port_value_t *value)
Get logical level of all input pins in a port.
Definition gpio.h:1358
int gpio_pin_configure(const struct device *port, gpio_pin_t pin, gpio_flags_t flags)
Configure a single pin.
void(* gpio_callback_handler_t)(const struct device *port, struct gpio_callback *cb, gpio_port_pins_t pins)
Define the application callback handler function signature.
Definition gpio.h:758
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
#define SYS_PORT_TRACING_FUNC_ENTER(type, func,...)
Tracing macro for the entry into a function that might or might not return a value.
Definition tracing_macros.h:257
#define SYS_PORT_TRACING_FUNC_EXIT(type, func,...)
Tracing macro for when a function ends its execution.
Definition tracing_macros.h:283
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
#define EINVAL
Invalid argument.
Definition errno.h:60
#define ENOSYS
Function not implemented.
Definition errno.h:82
#define NULL
Definition iar_missing_defs.h:20
flags
Definition parser.h:97
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:510
void * data
Address of the device instance private data.
Definition device.h:520
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:516
const void * config
Address of device instance config information.
Definition device.h:514
GPIO callback structure.
Definition gpio.h:772
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:776
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:787
gpio_callback_handler_t handler
Actual callback function being called when relevant.
Definition gpio.h:779
This structure is common to all GPIO drivers and is expected to be the first element in the object po...
Definition gpio.h:722
gpio_port_pins_t port_pin_mask
Mask identifying pins supported by the controller.
Definition gpio.h:728
This structure is common to all GPIO drivers and is expected to be the first element in the driver's ...
Definition gpio.h:735
gpio_port_pins_t invert
Mask identifying pins that are configured as active low.
Definition gpio.h:741
Container for GPIO pin information specified in devicetree.
Definition gpio.h:296
const struct device * port
GPIO device controlling the pin.
Definition gpio.h:298
gpio_pin_t pin
The pin's number on the device.
Definition gpio.h:300
gpio_dt_flags_t dt_flags
The pin's configuration flags as specified in devicetree.
Definition gpio.h:302
Main header file for tracing subsystem API.