Lines Matching +full:out +full:- +full:gpio

4  * SPDX-License-Identifier: Apache-2.0
10 * @brief 1-Wire Bus Master driver using Zephyr GPIO interface.
12 * This file contains the implementation of the 1-Wire Bus Master driver using
13 * the Zephyr GPIO interface. The driver is based on GPIO bit-banging and
14 * follows the timing specifications for 1-Wire communication.
21 * - w1_zephyr_serial.c: drivers/w1/w1_zephyr_serial.c
22 * - Analog Devices 1-Wire Communication Through Software:
23 * https://www.analog.com/en/resources/technical-articles/1wire-communication-through-software.html
26 #include <zephyr/drivers/gpio.h>
96 /** GPIO device used for 1-Wire communication */
103 /** timing parameters for 1-Wire communication */
137 const struct w1_gpio_config *cfg = dev->config; in w1_gpio_reset_bus()
138 const struct w1_gpio_data *data = dev->data; in w1_gpio_reset_bus()
140 const struct gpio_dt_spec *spec = &cfg->spec; in w1_gpio_reset_bus()
141 const struct w1_gpio_timing *timing = data->timing; in w1_gpio_reset_bus()
146 W1_GPIO_WAIT_US(timing->g); in w1_gpio_reset_bus()
149 goto out; in w1_gpio_reset_bus()
152 W1_GPIO_WAIT_US(timing->h); in w1_gpio_reset_bus()
155 goto out; in w1_gpio_reset_bus()
158 W1_GPIO_WAIT_US(timing->i); in w1_gpio_reset_bus()
161 goto out; in w1_gpio_reset_bus()
165 W1_GPIO_WAIT_US(timing->j); in w1_gpio_reset_bus()
166 out: in w1_gpio_reset_bus()
173 const struct w1_gpio_config *cfg = dev->config; in w1_gpio_read_bit()
174 const struct w1_gpio_data *data = dev->data; in w1_gpio_read_bit()
176 const struct gpio_dt_spec *spec = &cfg->spec; in w1_gpio_read_bit()
177 const struct w1_gpio_timing *timing = data->timing; in w1_gpio_read_bit()
184 goto out; in w1_gpio_read_bit()
187 W1_GPIO_WAIT_US(timing->a); in w1_gpio_read_bit()
190 goto out; in w1_gpio_read_bit()
193 W1_GPIO_WAIT_US(timing->e); in w1_gpio_read_bit()
196 goto out; in w1_gpio_read_bit()
200 W1_GPIO_WAIT_US(timing->f); in w1_gpio_read_bit()
201 out: in w1_gpio_read_bit()
208 const struct w1_gpio_config *cfg = dev->config; in w1_gpio_write_bit()
209 const struct w1_gpio_data *data = dev->data; in w1_gpio_write_bit()
211 const struct gpio_dt_spec *spec = &cfg->spec; in w1_gpio_write_bit()
212 const struct w1_gpio_timing *timing = data->timing; in w1_gpio_write_bit()
219 goto out; in w1_gpio_write_bit()
222 W1_GPIO_WAIT_US(bit ? timing->a : timing->c); in w1_gpio_write_bit()
225 goto out; in w1_gpio_write_bit()
228 W1_GPIO_WAIT_US(bit ? timing->b : timing->d); in w1_gpio_write_bit()
229 out: in w1_gpio_write_bit()
272 struct w1_gpio_data *data = dev->data; in w1_gpio_configure()
276 data->overdrive_active = (value != 0); in w1_gpio_configure()
277 data->timing = data->overdrive_active ? &od : &std; in w1_gpio_configure()
280 return -ENOTSUP; in w1_gpio_configure()
286 const struct w1_gpio_config *cfg = dev->config; in w1_gpio_init()
287 const struct gpio_dt_spec *spec = &cfg->spec; in w1_gpio_init()
288 struct w1_gpio_data *data = dev->data; in w1_gpio_init()
294 LOG_ERR("Failed to configure GPIO port %s pin %d", spec->port->name, in w1_gpio_init()
295 spec->pin); in w1_gpio_init()
299 LOG_ERR("GPIO port %s is not ready", spec->port->name); in w1_gpio_init()
300 return -ENODEV; in w1_gpio_init()
303 data->timing = &std; in w1_gpio_init()
304 data->overdrive_active = false; in w1_gpio_init()
306 LOG_DBG("w1-gpio initialized, with %d slave devices", cfg->master_config.slave_count); in w1_gpio_init()