Zephyr API Documentation 4.4.99
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
706
719
720struct gpio_callback;
721
733typedef void (*gpio_callback_handler_t)(const struct device *port,
734 struct gpio_callback *cb,
735 gpio_port_pins_t pins);
736
764
770
771/* Used by driver api function pin_interrupt_configure, these are defined
772 * in terms of the public flags so we can just mask and pass them
773 * through to the driver api
774 */
775enum gpio_int_mode {
776 GPIO_INT_MODE_DISABLED = GPIO_INT_DISABLE,
777 GPIO_INT_MODE_LEVEL = GPIO_INT_ENABLE,
778 GPIO_INT_MODE_EDGE = GPIO_INT_ENABLE | GPIO_INT_EDGE,
779#ifdef CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT
780 GPIO_INT_MODE_DISABLE_ONLY = GPIO_INT_DISABLE | GPIO_INT_ENABLE_DISABLE_ONLY,
781 GPIO_INT_MODE_ENABLE_ONLY = GPIO_INT_ENABLE | GPIO_INT_ENABLE_DISABLE_ONLY,
782#endif /* CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT */
783};
784
785enum gpio_int_trig {
786 /* Trigger detection when input state is (or transitions to)
787 * physical low. (Edge Falling or Active Low)
788 */
789 GPIO_INT_TRIG_LOW = GPIO_INT_LOW_0,
790 /* Trigger detection when input state is (or transitions to)
791 * physical high. (Edge Rising or Active High) */
792 GPIO_INT_TRIG_HIGH = GPIO_INT_HIGH_1,
793 /* Trigger detection on pin rising or falling edge. */
794 GPIO_INT_TRIG_BOTH = GPIO_INT_LOW_0 | GPIO_INT_HIGH_1,
795 /* Trigger a system wakeup. */
796 GPIO_INT_TRIG_WAKE = GPIO_INT_WAKEUP,
797 /* Trigger a system wakeup when input state is (or transitions to)
798 * physical low. (Edge Falling or Active Low)
799 */
800 GPIO_INT_TRIG_WAKE_LOW = GPIO_INT_LOW_0 | GPIO_INT_WAKEUP,
801 /* Trigger a system wakeup when input state is (or transitions to)
802 * physical high. (Edge Rising or Active High)
803 */
804 GPIO_INT_TRIG_WAKE_HIGH = GPIO_INT_HIGH_1 | GPIO_INT_WAKEUP,
805 /* Trigger a system wakeup on pin rising or falling edge. */
806 GPIO_INT_TRIG_WAKE_BOTH = GPIO_INT_LOW_0 | GPIO_INT_HIGH_1 | GPIO_INT_WAKEUP,
807};
808
809__subsystem struct gpio_driver_api {
810 int (*pin_configure)(const struct device *port, gpio_pin_t pin,
812#ifdef CONFIG_GPIO_GET_CONFIG
813 int (*pin_get_config)(const struct device *port, gpio_pin_t pin,
815#endif
816 int (*port_get_raw)(const struct device *port,
817 gpio_port_value_t *value);
818 int (*port_set_masked_raw)(const struct device *port,
819 gpio_port_pins_t mask,
820 gpio_port_value_t value);
821 int (*port_set_bits_raw)(const struct device *port,
822 gpio_port_pins_t pins);
823 int (*port_clear_bits_raw)(const struct device *port,
824 gpio_port_pins_t pins);
825 int (*port_toggle_bits)(const struct device *port,
826 gpio_port_pins_t pins);
827 int (*pin_interrupt_configure)(const struct device *port,
828 gpio_pin_t pin,
829 enum gpio_int_mode mode,
830 enum gpio_int_trig trig);
831 int (*manage_callback)(const struct device *port,
832 struct gpio_callback *cb,
833 bool set);
834 uint32_t (*get_pending_int)(const struct device *dev);
835#ifdef CONFIG_GPIO_GET_DIRECTION
836 int (*port_get_direction)(const struct device *port, gpio_port_pins_t map,
837 gpio_port_pins_t *inputs, gpio_port_pins_t *outputs);
838#endif /* CONFIG_GPIO_GET_DIRECTION */
839};
840
844
853static inline bool gpio_is_ready_dt(const struct gpio_dt_spec *spec)
854{
855 /* Validate port is ready */
856 return device_is_ready(spec->port);
857}
858
882__syscall int gpio_pin_interrupt_configure(const struct device *port,
883 gpio_pin_t pin,
885
886static inline int z_impl_gpio_pin_interrupt_configure(const struct device *port,
887 gpio_pin_t pin,
889{
890 const struct gpio_driver_api *api = DEVICE_API_GET(gpio, port);
891 __unused const struct gpio_driver_config *const cfg =
892 (const struct gpio_driver_config *)port->config;
893 const struct gpio_driver_data *const data =
894 (const struct gpio_driver_data *)port->data;
895 enum gpio_int_trig trig;
896 enum gpio_int_mode mode;
897 int ret;
898
899 SYS_PORT_TRACING_FUNC_ENTER(gpio_pin, interrupt_configure, port, pin, flags);
900
901 if (api->pin_interrupt_configure == NULL) {
902 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, interrupt_configure, port, pin, -ENOSYS);
903 return -ENOSYS;
904 }
905
906 __ASSERT((flags & (GPIO_INT_DISABLE | GPIO_INT_ENABLE))
907 != (GPIO_INT_DISABLE | GPIO_INT_ENABLE),
908 "Cannot both enable and disable interrupts");
909
910 __ASSERT((flags & (GPIO_INT_DISABLE | GPIO_INT_ENABLE)) != 0U,
911 "Must either enable or disable interrupts");
912
913 __ASSERT(((flags & GPIO_INT_ENABLE) == 0) ||
914 ((flags & GPIO_INT_EDGE) != 0) ||
915 ((flags & (GPIO_INT_LOW_0 | GPIO_INT_HIGH_1)) !=
916 (GPIO_INT_LOW_0 | GPIO_INT_HIGH_1)),
917 "Only one of GPIO_INT_LOW_0, GPIO_INT_HIGH_1 can be "
918 "enabled for a level interrupt.");
919
920#ifdef CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT
921#define GPIO_INT_ENABLE_DISABLE_ONLY_VALUE GPIO_INT_ENABLE_DISABLE_ONLY
922#else
923#define GPIO_INT_ENABLE_DISABLE_ONLY_VALUE 0
924#endif /* CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT */
925
926 __ASSERT(((flags & GPIO_INT_ENABLE) == 0) ||
927 ((flags & (GPIO_INT_LOW_0 | GPIO_INT_HIGH_1)) != 0) ||
929 "At least one of GPIO_INT_LOW_0, GPIO_INT_HIGH_1 has to be enabled.");
930#undef GPIO_INT_ENABLE_DISABLE_ONLY_VALUE
931 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U,
932 "Unsupported pin");
933
934 if (((flags & GPIO_INT_LEVELS_LOGICAL) != 0) &&
935 ((data->invert & (gpio_port_pins_t)BIT(pin)) != 0)) {
936 /* Invert signal bits */
937 flags ^= (GPIO_INT_LOW_0 | GPIO_INT_HIGH_1);
938 }
939
940 trig = (enum gpio_int_trig)(flags & (GPIO_INT_LOW_0 | GPIO_INT_HIGH_1 | GPIO_INT_WAKEUP));
941#ifdef CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT
942 mode = (enum gpio_int_mode)(flags & (GPIO_INT_EDGE | GPIO_INT_DISABLE | GPIO_INT_ENABLE |
943 GPIO_INT_ENABLE_DISABLE_ONLY));
944#else
945 mode = (enum gpio_int_mode)(flags & (GPIO_INT_EDGE | GPIO_INT_DISABLE | GPIO_INT_ENABLE));
946#endif /* CONFIG_GPIO_ENABLE_DISABLE_INTERRUPT */
947
948 ret = api->pin_interrupt_configure(port, pin, mode, trig);
949 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, interrupt_configure, port, pin, ret);
950 return ret;
951}
952
970static inline int gpio_pin_interrupt_configure_dt(const struct gpio_dt_spec *spec,
972{
973 return gpio_pin_interrupt_configure(spec->port, spec->pin,
974 flags | (spec->dt_flags & GPIO_INT_WAKEUP));
975}
976
992__syscall int gpio_pin_configure(const struct device *port,
993 gpio_pin_t pin,
995
996static inline int z_impl_gpio_pin_configure(const struct device *port,
997 gpio_pin_t pin,
999{
1000 const struct gpio_driver_api *api = DEVICE_API_GET(gpio, port);
1001 __unused const struct gpio_driver_config *const cfg =
1002 (const struct gpio_driver_config *)port->config;
1003 struct gpio_driver_data *data =
1004 (struct gpio_driver_data *)port->data;
1005 int ret;
1006
1007 SYS_PORT_TRACING_FUNC_ENTER(gpio_pin, configure, port, pin, flags);
1008
1009 __ASSERT((flags & GPIO_INT_MASK) == 0,
1010 "Interrupt flags are not supported");
1011
1012 __ASSERT((flags & (GPIO_PULL_UP | GPIO_PULL_DOWN)) !=
1014 "Pull Up and Pull Down should not be enabled simultaneously");
1015
1016 __ASSERT(!((flags & GPIO_INPUT) && !(flags & GPIO_OUTPUT) && (flags & GPIO_SINGLE_ENDED)),
1017 "Input cannot be enabled for 'Open Drain', 'Open Source' modes without Output");
1018
1019 __ASSERT_NO_MSG((flags & GPIO_SINGLE_ENDED) != 0 ||
1020 (flags & GPIO_LINE_OPEN_DRAIN) == 0);
1021
1022 __ASSERT((flags & (GPIO_OUTPUT_INIT_LOW | GPIO_OUTPUT_INIT_HIGH)) == 0
1023 || (flags & GPIO_OUTPUT) != 0,
1024 "Output needs to be enabled to be initialized low or high");
1025
1026 __ASSERT((flags & (GPIO_OUTPUT_INIT_LOW | GPIO_OUTPUT_INIT_HIGH))
1027 != (GPIO_OUTPUT_INIT_LOW | GPIO_OUTPUT_INIT_HIGH),
1028 "Output cannot be initialized low and high");
1029
1030 if (((flags & GPIO_OUTPUT_INIT_LOGICAL) != 0)
1031 && ((flags & (GPIO_OUTPUT_INIT_LOW | GPIO_OUTPUT_INIT_HIGH)) != 0)
1032 && ((flags & GPIO_ACTIVE_LOW) != 0)) {
1033 flags ^= GPIO_OUTPUT_INIT_LOW | GPIO_OUTPUT_INIT_HIGH;
1034 }
1035
1036 flags &= ~GPIO_OUTPUT_INIT_LOGICAL;
1037
1038 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U,
1039 "Unsupported pin");
1040
1041 if ((flags & GPIO_ACTIVE_LOW) != 0) {
1042 data->invert |= (gpio_port_pins_t)BIT(pin);
1043 } else {
1044 data->invert &= ~(gpio_port_pins_t)BIT(pin);
1045 }
1046
1047 ret = api->pin_configure(port, pin, flags);
1048 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, configure, port, pin, ret);
1049 return ret;
1050}
1051
1063static inline int gpio_pin_configure_dt(const struct gpio_dt_spec *spec,
1064 gpio_flags_t extra_flags)
1065{
1066 return gpio_pin_configure(spec->port,
1067 spec->pin,
1068 spec->dt_flags | extra_flags);
1069}
1070
1089__syscall int gpio_port_get_direction(const struct device *port, gpio_port_pins_t map,
1090 gpio_port_pins_t *inputs, gpio_port_pins_t *outputs);
1091
1092#ifdef CONFIG_GPIO_GET_DIRECTION
1093static inline int z_impl_gpio_port_get_direction(const struct device *port, gpio_port_pins_t map,
1094 gpio_port_pins_t *inputs,
1095 gpio_port_pins_t *outputs)
1096{
1097 const struct gpio_driver_api *api = DEVICE_API_GET(gpio, port);
1098 int ret;
1099
1100 SYS_PORT_TRACING_FUNC_ENTER(gpio_port, get_direction, port, map, inputs, outputs);
1101
1102 if (api->port_get_direction == NULL) {
1103 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, get_direction, port, -ENOSYS);
1104 return -ENOSYS;
1105 }
1106
1107 ret = api->port_get_direction(port, map, inputs, outputs);
1108 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, get_direction, port, ret);
1109 return ret;
1110}
1111#endif /* CONFIG_GPIO_GET_DIRECTION */
1112
1125static inline int gpio_pin_is_input(const struct device *port, gpio_pin_t pin)
1126{
1127 int rv;
1128 gpio_port_pins_t pins;
1129 __unused const struct gpio_driver_config *cfg =
1130 (const struct gpio_driver_config *)port->config;
1131
1132 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, "Unsupported pin");
1133
1134 rv = gpio_port_get_direction(port, BIT(pin), &pins, NULL);
1135 if (rv < 0) {
1136 return rv;
1137 }
1138
1139 return (int)!!((gpio_port_pins_t)BIT(pin) & pins);
1140}
1141
1153static inline int gpio_pin_is_input_dt(const struct gpio_dt_spec *spec)
1154{
1155 return gpio_pin_is_input(spec->port, spec->pin);
1156}
1157
1170static inline int gpio_pin_is_output(const struct device *port, gpio_pin_t pin)
1171{
1172 int rv;
1173 gpio_port_pins_t pins;
1174 __unused const struct gpio_driver_config *cfg =
1175 (const struct gpio_driver_config *)port->config;
1176
1177 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, "Unsupported pin");
1178
1179 rv = gpio_port_get_direction(port, BIT(pin), NULL, &pins);
1180 if (rv < 0) {
1181 return rv;
1182 }
1183
1184 return (int)!!((gpio_port_pins_t)BIT(pin) & pins);
1185}
1186
1198static inline int gpio_pin_is_output_dt(const struct gpio_dt_spec *spec)
1199{
1200 return gpio_pin_is_output(spec->port, spec->pin);
1201}
1202
1218__syscall int gpio_pin_get_config(const struct device *port, gpio_pin_t pin,
1220
1221#ifdef CONFIG_GPIO_GET_CONFIG
1222static inline int z_impl_gpio_pin_get_config(const struct device *port,
1223 gpio_pin_t pin,
1225{
1226 const struct gpio_driver_api *api = DEVICE_API_GET(gpio, port);
1227 int ret;
1228
1229 SYS_PORT_TRACING_FUNC_ENTER(gpio_pin, get_config, port, pin, *flags);
1230
1231 if (api->pin_get_config == NULL) {
1232 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, get_config, port, pin, -ENOSYS);
1233 return -ENOSYS;
1234 }
1235
1236 ret = api->pin_get_config(port, pin, flags);
1237 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, get_config, port, pin, ret);
1238 return ret;
1239}
1240#endif
1241
1254static inline int gpio_pin_get_config_dt(const struct gpio_dt_spec *spec,
1256{
1257 return gpio_pin_get_config(spec->port, spec->pin, flags);
1258}
1259
1277__syscall int gpio_port_get_raw(const struct device *port,
1278 gpio_port_value_t *value);
1279
1280static inline int z_impl_gpio_port_get_raw(const struct device *port, gpio_port_value_t *value)
1281{
1282 const struct gpio_driver_api *api = DEVICE_API_GET(gpio, port);
1283 int ret;
1284
1285 SYS_PORT_TRACING_FUNC_ENTER(gpio_port, get_raw, port, value);
1286
1287 ret = api->port_get_raw(port, value);
1288 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, get_raw, port, ret);
1289 return ret;
1290}
1291
1310static inline int gpio_port_get(const struct device *port,
1311 gpio_port_value_t *value)
1312{
1313 const struct gpio_driver_data *const data =
1314 (const struct gpio_driver_data *)port->data;
1315 int ret;
1316
1317 ret = gpio_port_get_raw(port, value);
1318 if (ret == 0) {
1319 *value ^= data->invert;
1320 }
1321
1322 return ret;
1323}
1324
1342__syscall int gpio_port_set_masked_raw(const struct device *port,
1343 gpio_port_pins_t mask,
1344 gpio_port_value_t value);
1345
1346static inline int z_impl_gpio_port_set_masked_raw(const struct device *port,
1347 gpio_port_pins_t mask,
1348 gpio_port_value_t value)
1349{
1350 const struct gpio_driver_api *api = DEVICE_API_GET(gpio, port);
1351 int ret;
1352
1353 SYS_PORT_TRACING_FUNC_ENTER(gpio_port, set_masked_raw, port, mask, value);
1354
1355 ret = api->port_set_masked_raw(port, mask, value);
1356 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, set_masked_raw, port, ret);
1357 return ret;
1358}
1359
1380static inline int gpio_port_set_masked(const struct device *port,
1381 gpio_port_pins_t mask,
1382 gpio_port_value_t value)
1383{
1384 const struct gpio_driver_data *const data =
1385 (const struct gpio_driver_data *)port->data;
1386
1387 value ^= data->invert;
1388
1389 return gpio_port_set_masked_raw(port, mask, value);
1390}
1391
1402__syscall int gpio_port_set_bits_raw(const struct device *port,
1403 gpio_port_pins_t pins);
1404
1405static inline int z_impl_gpio_port_set_bits_raw(const struct device *port,
1406 gpio_port_pins_t pins)
1407{
1408 const struct gpio_driver_api *api = DEVICE_API_GET(gpio, port);
1409 int ret;
1410
1411 SYS_PORT_TRACING_FUNC_ENTER(gpio_port, set_bits_raw, port, pins);
1412
1413 ret = api->port_set_bits_raw(port, pins);
1414 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, set_bits_raw, port, ret);
1415 return ret;
1416}
1417
1428static inline int gpio_port_set_bits(const struct device *port,
1429 gpio_port_pins_t pins)
1430{
1431 return gpio_port_set_masked(port, pins, pins);
1432}
1433
1444__syscall int gpio_port_clear_bits_raw(const struct device *port,
1445 gpio_port_pins_t pins);
1446
1447static inline int z_impl_gpio_port_clear_bits_raw(const struct device *port,
1448 gpio_port_pins_t pins)
1449{
1450 const struct gpio_driver_api *api = DEVICE_API_GET(gpio, port);
1451 int ret;
1452
1453 SYS_PORT_TRACING_FUNC_ENTER(gpio_port, clear_bits_raw, port, pins);
1454
1455 ret = api->port_clear_bits_raw(port, pins);
1456 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, clear_bits_raw, port, ret);
1457 return ret;
1458}
1459
1470static inline int gpio_port_clear_bits(const struct device *port,
1471 gpio_port_pins_t pins)
1472{
1473 return gpio_port_set_masked(port, pins, 0);
1474}
1475
1486__syscall int gpio_port_toggle_bits(const struct device *port,
1487 gpio_port_pins_t pins);
1488
1489static inline int z_impl_gpio_port_toggle_bits(const struct device *port,
1490 gpio_port_pins_t pins)
1491{
1492 const struct gpio_driver_api *api = DEVICE_API_GET(gpio, port);
1493 int ret;
1494
1495 SYS_PORT_TRACING_FUNC_ENTER(gpio_port, toggle_bits, port, pins);
1496
1497 ret = api->port_toggle_bits(port, pins);
1498 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, toggle_bits, port, ret);
1499 return ret;
1500}
1501
1513static inline int gpio_port_set_clr_bits_raw(const struct device *port,
1514 gpio_port_pins_t set_pins,
1515 gpio_port_pins_t clear_pins)
1516{
1517 __ASSERT((set_pins & clear_pins) == 0, "Set and Clear pins overlap");
1518
1519 return gpio_port_set_masked_raw(port, set_pins | clear_pins, set_pins);
1520}
1521
1533static inline int gpio_port_set_clr_bits(const struct device *port,
1534 gpio_port_pins_t set_pins,
1535 gpio_port_pins_t clear_pins)
1536{
1537 __ASSERT((set_pins & clear_pins) == 0, "Set and Clear pins overlap");
1538
1539 return gpio_port_set_masked(port, set_pins | clear_pins, set_pins);
1540}
1541
1557static inline int gpio_pin_get_raw(const struct device *port, gpio_pin_t pin)
1558{
1559 __unused const struct gpio_driver_config *const cfg =
1560 (const struct gpio_driver_config *)port->config;
1561 gpio_port_value_t value;
1562 int ret;
1563
1564 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U,
1565 "Unsupported pin");
1566
1567 ret = gpio_port_get_raw(port, &value);
1568 if (ret == 0) {
1569 ret = (value & (gpio_port_pins_t)BIT(pin)) != 0 ? 1 : 0;
1570 }
1571
1572 return ret;
1573}
1574
1594static inline int gpio_pin_get(const struct device *port, gpio_pin_t pin)
1595{
1596 __unused const struct gpio_driver_config *const cfg =
1597 (const struct gpio_driver_config *)port->config;
1598 gpio_port_value_t value;
1599 int ret;
1600
1601 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U,
1602 "Unsupported pin");
1603
1604 ret = gpio_port_get(port, &value);
1605 if (ret == 0) {
1606 ret = (value & (gpio_port_pins_t)BIT(pin)) != 0 ? 1 : 0;
1607 }
1608
1609 return ret;
1610}
1611
1622static inline int gpio_pin_get_dt(const struct gpio_dt_spec *spec)
1623{
1624 return gpio_pin_get(spec->port, spec->pin);
1625}
1626
1642static inline int gpio_pin_set_raw(const struct device *port, gpio_pin_t pin,
1643 int value)
1644{
1645 __unused const struct gpio_driver_config *const cfg =
1646 (const struct gpio_driver_config *)port->config;
1647 int ret;
1648
1649 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U,
1650 "Unsupported pin");
1651
1652 if (value != 0) {
1653 ret = gpio_port_set_bits_raw(port, (gpio_port_pins_t)BIT(pin));
1654 } else {
1656 }
1657
1658 return ret;
1659}
1660
1682static inline int gpio_pin_set(const struct device *port, gpio_pin_t pin,
1683 int value)
1684{
1685 __unused const struct gpio_driver_config *const cfg =
1686 (const struct gpio_driver_config *)port->config;
1687 const struct gpio_driver_data *const data =
1688 (const struct gpio_driver_data *)port->data;
1689
1690 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U,
1691 "Unsupported pin");
1692
1693 if (data->invert & (gpio_port_pins_t)BIT(pin)) {
1694 value = (value != 0) ? 0 : 1;
1695 }
1696
1697 return gpio_pin_set_raw(port, pin, value);
1698}
1699
1711static inline int gpio_pin_set_dt(const struct gpio_dt_spec *spec, int value)
1712{
1713 return gpio_pin_set(spec->port, spec->pin, value);
1714}
1715
1726static inline int gpio_pin_toggle(const struct device *port, gpio_pin_t pin)
1727{
1728 __unused const struct gpio_driver_config *const cfg =
1729 (const struct gpio_driver_config *)port->config;
1730
1731 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U,
1732 "Unsupported pin");
1733
1734 return gpio_port_toggle_bits(port, (gpio_port_pins_t)BIT(pin));
1735}
1736
1747static inline int gpio_pin_toggle_dt(const struct gpio_dt_spec *spec)
1748{
1749 return gpio_pin_toggle(spec->port, spec->pin);
1750}
1751
1758static inline void gpio_init_callback(struct gpio_callback *callback,
1760 gpio_port_pins_t pin_mask)
1761{
1762 SYS_PORT_TRACING_FUNC_ENTER(gpio, init_callback, callback, handler, pin_mask);
1763
1764 __ASSERT(callback, "Callback pointer should not be NULL");
1765 __ASSERT(handler, "Callback handler pointer should not be NULL");
1766
1767 callback->handler = handler;
1768 callback->pin_mask = pin_mask;
1769
1770 SYS_PORT_TRACING_FUNC_EXIT(gpio, init_callback, callback);
1771}
1772
1787static inline int gpio_add_callback(const struct device *port,
1788 struct gpio_callback *callback)
1789{
1790 const struct gpio_driver_api *api = DEVICE_API_GET(gpio, port);
1791 int ret;
1792
1793 SYS_PORT_TRACING_FUNC_ENTER(gpio, add_callback, port, callback);
1794
1795 if (api->manage_callback == NULL) {
1796 SYS_PORT_TRACING_FUNC_EXIT(gpio, add_callback, port, -ENOSYS);
1797 return -ENOSYS;
1798 }
1799
1800 ret = api->manage_callback(port, callback, true);
1801 SYS_PORT_TRACING_FUNC_EXIT(gpio, add_callback, port, ret);
1802 return ret;
1803}
1804
1816static inline int gpio_add_callback_dt(const struct gpio_dt_spec *spec,
1817 struct gpio_callback *callback)
1818{
1819 return gpio_add_callback(spec->port, callback);
1820}
1821
1840static inline int gpio_remove_callback(const struct device *port,
1841 struct gpio_callback *callback)
1842{
1843 const struct gpio_driver_api *api = DEVICE_API_GET(gpio, port);
1844 int ret;
1845
1846 SYS_PORT_TRACING_FUNC_ENTER(gpio, remove_callback, port, callback);
1847
1848 if (api->manage_callback == NULL) {
1849 SYS_PORT_TRACING_FUNC_EXIT(gpio, remove_callback, port, -ENOSYS);
1850 return -ENOSYS;
1851 }
1852
1853 ret = api->manage_callback(port, callback, false);
1854 SYS_PORT_TRACING_FUNC_EXIT(gpio, remove_callback, port, ret);
1855 return ret;
1856}
1857
1869static inline int gpio_remove_callback_dt(const struct gpio_dt_spec *spec,
1870 struct gpio_callback *callback)
1871{
1872 return gpio_remove_callback(spec->port, callback);
1873}
1874
1889__syscall int gpio_get_pending_int(const struct device *dev);
1890
1891static inline int z_impl_gpio_get_pending_int(const struct device *dev)
1892{
1893 const struct gpio_driver_api *api = DEVICE_API_GET(gpio, dev);
1894 int ret;
1895
1896 SYS_PORT_TRACING_FUNC_ENTER(gpio, get_pending_int, dev);
1897
1898 if (api->get_pending_int == NULL) {
1899 SYS_PORT_TRACING_FUNC_EXIT(gpio, get_pending_int, dev, -ENOSYS);
1900 return -ENOSYS;
1901 }
1902
1903 ret = api->get_pending_int(dev);
1904 SYS_PORT_TRACING_FUNC_EXIT(gpio, get_pending_int, dev, ret);
1905 return ret;
1906}
1907
1911
1912#ifdef __cplusplus
1913}
1914#endif
1915
1916#include <zephyr/syscalls/gpio.h>
1917
1918#endif /* ZEPHYR_INCLUDE_DRIVERS_GPIO_H_ */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1425
#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:1787
#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:1557
int gpio_pin_get_config(const struct device *port, gpio_pin_t pin, gpio_flags_t *flags)
Get a configuration of a single pin.
static int gpio_pin_is_input(const struct device *port, gpio_pin_t pin)
Check if pin is configured for input.
Definition gpio.h:1125
static int gpio_pin_get(const struct device *port, gpio_pin_t pin)
Get logical level of an input pin.
Definition gpio.h:1594
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:1198
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:970
static int gpio_remove_callback_dt(const struct gpio_dt_spec *spec, struct gpio_callback *callback)
Remove an application callback.
Definition gpio.h:1869
static int gpio_pin_toggle_dt(const struct gpio_dt_spec *spec)
Toggle pin level from a gpio_dt_spec.
Definition gpio.h:1747
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:1170
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:1063
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:1711
static int gpio_add_callback_dt(const struct gpio_dt_spec *spec, struct gpio_callback *callback)
Add an application callback.
Definition gpio.h:1816
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:1428
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:1513
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:1533
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:1758
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:1153
#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:1254
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:1622
static int gpio_pin_toggle(const struct device *port, gpio_pin_t pin)
Toggle pin level.
Definition gpio.h:1726
static bool gpio_is_ready_dt(const struct gpio_dt_spec *spec)
Validate that GPIO port is ready.
Definition gpio.h:853
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:1682
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:1470
static int gpio_remove_callback(const struct device *port, struct gpio_callback *callback)
Remove an application callback.
Definition gpio.h:1840
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:1380
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:1642
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:1310
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:733
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 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:513
void * data
Address of the device instance private data.
Definition device.h:523
const void * config
Address of device instance config information.
Definition device.h:517
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
This structure is common to all GPIO drivers and is expected to be the first element in the object po...
Definition gpio.h:698
gpio_port_pins_t port_pin_mask
Mask identifying pins supported by the controller.
Definition gpio.h:704
This structure is common to all GPIO drivers and is expected to be the first element in the driver's ...
Definition gpio.h:711
gpio_port_pins_t invert
Mask identifying pins that are configured as active low.
Definition gpio.h:717
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.