Lines Matching +full:enable +full:- +full:output +full:- +full:invert

2  * Copyright (c) 2019-2020 Nordic Semiconductor ASA
5 * Copyright (c) 2015-2016 Intel Corporation.
7 * SPDX-License-Identifier: Apache-2.0
27 #include <zephyr/dt-bindings/gpio/gpio.h>
43 * @name GPIO input/output configuration flags
50 /** Enables pin as output, no change to the output state. */
53 /** Disables pin for both input and output. */
58 /* Initializes output to a low state. */
61 /* Initializes output to a high state. */
64 /* Initializes output based on logic level */
69 /** Configures GPIO pin as output and initializes it to a low state. */
71 /** Configures GPIO pin as output and initializes it to a high state. */
73 /** Configures GPIO pin as output and initializes it to a logic 0. */
77 /** Configures GPIO pin as output and initializes it to a logic 1. */
95 * `GPIO_INT_MODE_DISABLE_ONLY` flags to enable and disable interrupts on the
141 /* Disable/Enable interrupt functionality without changing other interrupt
252 * This reduced-size type is sufficient to record a pin number,
261 * bits of the full flags field, so use a reduced-size type to record
307 * foo-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>,
328 * @param prop lowercase-and-underscores property name
350 * @param prop lowercase-and-underscores property name
365 * @param prop lowercase-and-underscores property name
377 * @param prop lowercase-and-underscores property name
390 * @param prop lowercase-and-underscores property name
403 * @param prop lowercase-and-underscores property name
418 * @param prop lowercase-and-underscores property name
430 * @param prop lowercase-and-underscores property name
448 * @param prop lowercase-and-underscores array property name
457 DT_PROP_BY_IDX(node_id, prop, sz_idx) - 1, \
463 * from @p "gpio-reserved-ranges"
481 * @brief Makes a bitmask of reserved GPIOs from DT @p "gpio-reserved-ranges"
484 * This macro returns the value as a bitmask of the @p "gpio-reserved-ranges"
486 * range @p 0...ngpios-1 and is specified as an array of value's pairs that
489 * For example, setting "gpio-reserved-ranges = <3 2>, <10 1>;"
507 * compatible = "some,gpio-controller";
509 * gpio-reserved-ranges = <0 4>, <5 3>, <9 5>, <11 2>, <15 2>,
514 * compatible = "some,gpio-controller";
516 * gpio-reserved-ranges = <3 2>, <10 1>;
570 (GENMASK64(BITS_PER_LONG_LONG - 1, ngpios) \
578 * @brief Makes a bitmask of reserved GPIOs from the @p "gpio-reserved-ranges"
589 * @p "gpio-reserved-ranges" property and @p "ngpios" argument
601 * @p "gpio-reserved-ranges" and @p "ngpios" properties
611 * @brief Makes a bitmask of allowed GPIOs from DT @p "gpio-reserved-ranges"
621 * compatible = "some,gpio-controller";
623 * gpio-reserved-ranges = <0 8>, <9 5>, <15 16>;
663 ((GENMASK64(ngpios - 1, 0) & \
665 (GENMASK64(ngpios - 1, 0))) \
671 * @p "gpio-reserved-ranges" property and @p "ngpios" argument
710 gpio_port_pins_t invert; member
839 return device_is_ready(spec->port); in gpio_is_ready_dt()
856 * @retval -ENOSYS If the operation is not implemented by the driver.
857 * @retval -ENOTSUP If any of the configuration options is not supported
859 * @retval -EINVAL Invalid argument.
860 * @retval -EBUSY Interrupt line required to configure pin interrupt is
862 * @retval -EIO I/O error when accessing an external GPIO chip.
863 * @retval -EWOULDBLOCK if operation would block.
874 (const struct gpio_driver_api *)port->api; in z_impl_gpio_pin_interrupt_configure()
876 (const struct gpio_driver_config *)port->config; in z_impl_gpio_pin_interrupt_configure()
878 (const struct gpio_driver_data *)port->data; in z_impl_gpio_pin_interrupt_configure()
885 if (api->pin_interrupt_configure == NULL) { in z_impl_gpio_pin_interrupt_configure()
886 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, interrupt_configure, port, pin, -ENOSYS); in z_impl_gpio_pin_interrupt_configure()
887 return -ENOSYS; in z_impl_gpio_pin_interrupt_configure()
892 "Cannot both enable and disable interrupts"); in z_impl_gpio_pin_interrupt_configure()
895 "Must either enable or disable interrupts"); in z_impl_gpio_pin_interrupt_configure()
914 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in z_impl_gpio_pin_interrupt_configure()
918 ((data->invert & (gpio_port_pins_t)BIT(pin)) != 0)) { in z_impl_gpio_pin_interrupt_configure()
919 /* Invert signal bits */ in z_impl_gpio_pin_interrupt_configure()
931 ret = api->pin_interrupt_configure(port, pin, mode, trig); in z_impl_gpio_pin_interrupt_configure()
943 * gpio_pin_interrupt_configure(spec->port, spec->pin, flags);
945 * The <tt>spec->dt_flags</tt> value is not used.
954 return gpio_pin_interrupt_configure(spec->port, spec->pin, flags); in gpio_pin_interrupt_configure_dt()
962 * @param flags Flags for pin configuration: 'GPIO input/output configuration
966 * @retval -ENOTSUP if any of the configuration options is not supported
968 * @retval -EINVAL Invalid argument.
969 * @retval -EIO I/O error when accessing an external GPIO chip.
970 * @retval -EWOULDBLOCK if operation would block.
981 (const struct gpio_driver_api *)port->api; in z_impl_gpio_pin_configure()
983 (const struct gpio_driver_config *)port->config; in z_impl_gpio_pin_configure()
985 (struct gpio_driver_data *)port->data; in z_impl_gpio_pin_configure()
998 "Input cannot be enabled for 'Open Drain', 'Open Source' modes without Output"); in z_impl_gpio_pin_configure()
1005 "Output needs to be enabled to be initialized low or high"); in z_impl_gpio_pin_configure()
1009 "Output cannot be initialized low and high"); in z_impl_gpio_pin_configure()
1019 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in z_impl_gpio_pin_configure()
1023 data->invert |= (gpio_port_pins_t)BIT(pin); in z_impl_gpio_pin_configure()
1025 data->invert &= ~(gpio_port_pins_t)BIT(pin); in z_impl_gpio_pin_configure()
1028 ret = api->pin_configure(port, pin, flags); in z_impl_gpio_pin_configure()
1038 * gpio_pin_configure(spec->port, spec->pin, spec->dt_flags | extra_flags);
1047 return gpio_pin_configure(spec->port, in gpio_pin_configure_dt()
1048 spec->pin, in gpio_pin_configure_dt()
1049 spec->dt_flags | extra_flags); in gpio_pin_configure_dt()
1058 * respective input or output direction information.
1063 * @param outputs Pointer to a variable where output directions will be stored.
1066 * @retval -ENOSYS if the underlying driver does not support this call.
1067 * @retval -EIO I/O error when accessing an external GPIO chip.
1068 * @retval -EWOULDBLOCK if operation would block.
1078 const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->api; in z_impl_gpio_port_get_direction()
1083 if (api->port_get_direction == NULL) { in z_impl_gpio_port_get_direction()
1084 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, get_direction, port, -ENOSYS); in z_impl_gpio_port_get_direction()
1085 return -ENOSYS; in z_impl_gpio_port_get_direction()
1088 ret = api->port_get_direction(port, map, inputs, outputs); in z_impl_gpio_port_get_direction()
1102 * @retval -ENOSYS if the underlying driver does not support this call.
1103 * @retval -EIO I/O error when accessing an external GPIO chip.
1104 * @retval -EWOULDBLOCK if operation would block.
1111 (const struct gpio_driver_config *)port->config; in gpio_pin_is_input()
1113 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, "Unsupported pin"); in gpio_pin_is_input()
1128 * gpio_pin_is_input(spec->port, spec->pin);
1136 return gpio_pin_is_input(spec->port, spec->pin); in gpio_pin_is_input_dt()
1140 * @brief Check if @p pin is configured for output
1147 * @retval -ENOSYS if the underlying driver does not support this call.
1148 * @retval -EIO I/O error when accessing an external GPIO chip.
1149 * @retval -EWOULDBLOCK if operation would block.
1156 (const struct gpio_driver_config *)port->config; in gpio_pin_is_output()
1158 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, "Unsupported pin"); in gpio_pin_is_output()
1169 * @brief Check if a single pin from @p gpio_dt_spec is configured for output
1173 * gpio_pin_is_output(spec->port, spec->pin);
1181 return gpio_pin_is_output(spec->port, spec->pin); in gpio_pin_is_output_dt()
1193 * @retval -ENOSYS if getting current pin configuration is not implemented
1195 * @retval -EINVAL Invalid argument.
1196 * @retval -EIO I/O error when accessing an external GPIO chip.
1197 * @retval -EWOULDBLOCK if operation would block.
1208 (const struct gpio_driver_api *)port->api; in z_impl_gpio_pin_get_config()
1213 if (api->pin_get_config == NULL) { in z_impl_gpio_pin_get_config()
1214 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, get_config, port, pin, -ENOSYS); in z_impl_gpio_pin_get_config()
1215 return -ENOSYS; in z_impl_gpio_pin_get_config()
1218 ret = api->pin_get_config(port, pin, flags); in z_impl_gpio_pin_get_config()
1229 * gpio_pin_get_config(spec->port, spec->pin, flags);
1239 return gpio_pin_get_config(spec->port, spec->pin, flags); in gpio_pin_get_config_dt()
1256 * @retval -EIO I/O error when accessing an external GPIO chip.
1257 * @retval -EWOULDBLOCK if operation would block.
1264 const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->api; in z_impl_gpio_port_get_raw()
1269 ret = api->port_get_raw(port, value); in z_impl_gpio_port_get_raw()
1289 * @retval -EIO I/O error when accessing an external GPIO chip.
1290 * @retval -EWOULDBLOCK if operation would block.
1296 (const struct gpio_driver_data *)port->data; in gpio_port_get()
1301 *value ^= data->invert; in gpio_port_get()
1308 * @brief Set physical level of output pins in a port.
1318 * @param value Value assigned to the output pins.
1321 * @retval -EIO I/O error when accessing an external GPIO chip.
1322 * @retval -EWOULDBLOCK if operation would block.
1333 (const struct gpio_driver_api *)port->api; in z_impl_gpio_port_set_masked_raw()
1338 ret = api->port_set_masked_raw(port, mask, value); in z_impl_gpio_port_set_masked_raw()
1344 * @brief Set logical level of output pins in a port.
1346 * Set logical level of an output pin taking into account GPIO_ACTIVE_LOW flag.
1357 * @param value Value assigned to the output pins.
1360 * @retval -EIO I/O error when accessing an external GPIO chip.
1361 * @retval -EWOULDBLOCK if operation would block.
1368 (const struct gpio_driver_data *)port->data; in gpio_port_set_masked()
1370 value ^= data->invert; in gpio_port_set_masked()
1376 * @brief Set physical level of selected output pins to high.
1382 * @retval -EIO I/O error when accessing an external GPIO chip.
1383 * @retval -EWOULDBLOCK if operation would block.
1392 (const struct gpio_driver_api *)port->api; in z_impl_gpio_port_set_bits_raw()
1397 ret = api->port_set_bits_raw(port, pins); in z_impl_gpio_port_set_bits_raw()
1403 * @brief Set logical level of selected output pins to active.
1409 * @retval -EIO I/O error when accessing an external GPIO chip.
1410 * @retval -EWOULDBLOCK if operation would block.
1419 * @brief Set physical level of selected output pins to low.
1425 * @retval -EIO I/O error when accessing an external GPIO chip.
1426 * @retval -EWOULDBLOCK if operation would block.
1435 (const struct gpio_driver_api *)port->api; in z_impl_gpio_port_clear_bits_raw()
1440 ret = api->port_clear_bits_raw(port, pins); in z_impl_gpio_port_clear_bits_raw()
1446 * @brief Set logical level of selected output pins to inactive.
1452 * @retval -EIO I/O error when accessing an external GPIO chip.
1453 * @retval -EWOULDBLOCK if operation would block.
1462 * @brief Toggle level of selected output pins.
1468 * @retval -EIO I/O error when accessing an external GPIO chip.
1469 * @retval -EWOULDBLOCK if operation would block.
1478 (const struct gpio_driver_api *)port->api; in z_impl_gpio_port_toggle_bits()
1483 ret = api->port_toggle_bits(port, pins); in z_impl_gpio_port_toggle_bits()
1489 * @brief Set physical level of selected output pins.
1496 * @retval -EIO I/O error when accessing an external GPIO chip.
1497 * @retval -EWOULDBLOCK if operation would block.
1509 * @brief Set logical level of selected output pins.
1516 * @retval -EIO I/O error when accessing an external GPIO chip.
1517 * @retval -EWOULDBLOCK if operation would block.
1540 * @retval -EIO I/O error when accessing an external GPIO chip.
1541 * @retval -EWOULDBLOCK if operation would block.
1546 (const struct gpio_driver_config *)port->config; in gpio_pin_get_raw()
1550 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in gpio_pin_get_raw()
1577 * @retval -EIO I/O error when accessing an external GPIO chip.
1578 * @retval -EWOULDBLOCK if operation would block.
1583 (const struct gpio_driver_config *)port->config; in gpio_pin_get()
1587 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in gpio_pin_get()
1603 * gpio_pin_get(spec->port, spec->pin);
1610 return gpio_pin_get(spec->port, spec->pin); in gpio_pin_get_dt()
1614 * @brief Set physical level of an output pin.
1625 * @retval -EIO I/O error when accessing an external GPIO chip.
1626 * @retval -EWOULDBLOCK if operation would block.
1632 (const struct gpio_driver_config *)port->config; in gpio_pin_set_raw()
1635 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in gpio_pin_set_raw()
1648 * @brief Set logical level of an output pin.
1650 * Set logical level of an output pin taking into account GPIO_ACTIVE_LOW flag.
1665 * @retval -EIO I/O error when accessing an external GPIO chip.
1666 * @retval -EWOULDBLOCK if operation would block.
1672 (const struct gpio_driver_config *)port->config; in gpio_pin_set()
1674 (const struct gpio_driver_data *)port->data; in gpio_pin_set()
1676 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in gpio_pin_set()
1679 if (data->invert & (gpio_port_pins_t)BIT(pin)) { in gpio_pin_set()
1687 * @brief Set logical level of a output pin from a @p gpio_dt_spec.
1691 * gpio_pin_set(spec->port, spec->pin, value);
1699 return gpio_pin_set(spec->port, spec->pin, value); in gpio_pin_set_dt()
1709 * @retval -EIO I/O error when accessing an external GPIO chip.
1710 * @retval -EWOULDBLOCK if operation would block.
1715 (const struct gpio_driver_config *)port->config; in gpio_pin_toggle()
1717 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in gpio_pin_toggle()
1728 * gpio_pin_toggle(spec->port, spec->pin);
1735 return gpio_pin_toggle(spec->port, spec->pin); in gpio_pin_toggle_dt()
1753 callback->handler = handler; in gpio_init_callback()
1754 callback->pin_mask = pin_mask; in gpio_init_callback()
1764 * @retval -ENOSYS If driver does not implement the operation
1765 * @retval -errno Other negative errno code on failure.
1777 (const struct gpio_driver_api *)port->api; in gpio_add_callback()
1782 if (api->manage_callback == NULL) { in gpio_add_callback()
1783 SYS_PORT_TRACING_FUNC_EXIT(gpio, add_callback, port, -ENOSYS); in gpio_add_callback()
1784 return -ENOSYS; in gpio_add_callback()
1787 ret = api->manage_callback(port, callback, true); in gpio_add_callback()
1797 * gpio_add_callback(spec->port, callback);
1806 return gpio_add_callback(spec->port, callback); in gpio_add_callback_dt()
1814 * @retval -ENOSYS If driver does not implement the operation
1815 * @retval -errno Other negative errno code on failure.
1831 (const struct gpio_driver_api *)port->api; in gpio_remove_callback()
1836 if (api->manage_callback == NULL) { in gpio_remove_callback()
1837 SYS_PORT_TRACING_FUNC_EXIT(gpio, remove_callback, port, -ENOSYS); in gpio_remove_callback()
1838 return -ENOSYS; in gpio_remove_callback()
1841 ret = api->manage_callback(port, callback, false); in gpio_remove_callback()
1851 * gpio_remove_callback(spec->port, callback);
1860 return gpio_remove_callback(spec->port, callback); in gpio_remove_callback_dt()
1875 * @retval -ENOSYS If driver does not implement the operation
1882 (const struct gpio_driver_api *)dev->api; in z_impl_gpio_get_pending_int()
1887 if (api->get_pending_int == NULL) { in z_impl_gpio_get_pending_int()
1888 SYS_PORT_TRACING_FUNC_EXIT(gpio, get_pending_int, dev, -ENOSYS); in z_impl_gpio_get_pending_int()
1889 return -ENOSYS; in z_impl_gpio_get_pending_int()
1892 ret = api->get_pending_int(dev); in z_impl_gpio_get_pending_int()