Lines Matching +full:ready +full:- +full:high +full:- +full:drive

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>
61 /* Initializes output to a high state. */
71 /** Configures GPIO pin as output and initializes it to a high state. */
90 * considered as logical level 1 (an active state), physical level high will
132 /* Trigger detection on input state is (or transitions to) physical high or
186 /** Configures GPIO interrupt to be triggered on pin physical level high and
239 * The value for a pin with index n is high (physical mode) or active
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
785 * physical high. (Edge Rising or Active High) */
829 * @brief Validate that GPIO port is ready.
833 * @retval true if the GPIO spec is ready for use.
834 * @retval false if the GPIO spec is not ready for use.
838 /* Validate port is ready */ in gpio_is_ready_dt()
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()
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()
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()
963 * flags', 'GPIO pin drive flags', 'GPIO pin bias flags'.
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()
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()
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()
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()
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()
1245 * A low physical level on the pin will be interpreted as value 0. A high
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()
1278 * If pin is configured as Active High, a low physical level will be interpreted
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()
1311 * value 1 will set it to a high physical level. This function ignores
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()
1348 * logical 1 / active state. If pin is configured as Active High, the default,
1351 * pin to a high physical level.
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()
1409 * @retval -EIO I/O error when accessing an external GPIO chip.
1410 * @retval -EWOULDBLOCK if operation would block.
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()
1452 * @retval -EIO I/O error when accessing an external GPIO chip.
1453 * @retval -EWOULDBLOCK if operation would block.
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()
1492 * @param set_pins Value indicating which pins will be set to high.
1496 * @retval -EIO I/O error when accessing an external GPIO chip.
1497 * @retval -EWOULDBLOCK if operation would block.
1516 * @retval -EIO I/O error when accessing an external GPIO chip.
1517 * @retval -EWOULDBLOCK if operation would block.
1531 * A low physical level on the pin will be interpreted as value 0. A high
1538 * @retval 1 If pin physical level is high.
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()
1565 * If pin is configured as Active High, a low physical level will be interpreted
1569 * Note: If pin is configured as Active High, the default, gpio_pin_get()
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()
1617 * value other than 0 will set it to a high physical level. This function
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()
1653 * High, the default, setting it in inactive state will force the pin to a low
1655 * state will force the pin to a high physical level.
1657 * Note: If pin is configured as Active High, gpio_pin_set() function is
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()
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()