Lines Matching +full:tx +full:- +full:mask
4 * SPDX-License-Identifier: Apache-2.0
46 const struct gpio_sn74hc595_config *config = dev->config; in sn74hc595_spi_write()
52 const struct spi_buf_set tx = { .buffers = tx_buf, .count = 1 }; in sn74hc595_spi_write() local
54 return spi_write_dt(&config->bus, &tx); in sn74hc595_spi_write()
67 struct gpio_sn74hc595_drv_data *drv_data = dev->data; in gpio_sn74hc595_port_get_raw()
69 k_mutex_lock(&drv_data->lock, K_FOREVER); in gpio_sn74hc595_port_get_raw()
71 *value = drv_data->output; in gpio_sn74hc595_port_get_raw()
73 k_mutex_unlock(&drv_data->lock); in gpio_sn74hc595_port_get_raw()
78 static int gpio_sn74hc595_port_set_masked_raw(const struct device *dev, uint32_t mask, in gpio_sn74hc595_port_set_masked_raw() argument
81 struct gpio_sn74hc595_drv_data *drv_data = dev->data; in gpio_sn74hc595_port_set_masked_raw()
85 k_mutex_lock(&drv_data->lock, K_FOREVER); in gpio_sn74hc595_port_set_masked_raw()
89 if ((drv_data->output & mask) != (mask & value)) { in gpio_sn74hc595_port_set_masked_raw()
90 output = (drv_data->output & ~mask) | (mask & value); in gpio_sn74hc595_port_set_masked_raw()
97 drv_data->output = output; in gpio_sn74hc595_port_set_masked_raw()
101 k_mutex_unlock(&drv_data->lock); in gpio_sn74hc595_port_set_masked_raw()
105 static int gpio_sn74hc595_port_set_bits_raw(const struct device *dev, uint32_t mask) in gpio_sn74hc595_port_set_bits_raw() argument
107 return gpio_sn74hc595_port_set_masked_raw(dev, mask, mask); in gpio_sn74hc595_port_set_bits_raw()
110 static int gpio_sn74hc595_port_clear_bits_raw(const struct device *dev, uint32_t mask) in gpio_sn74hc595_port_clear_bits_raw() argument
112 return gpio_sn74hc595_port_set_masked_raw(dev, mask, 0U); in gpio_sn74hc595_port_clear_bits_raw()
115 static int gpio_sn74hc595_port_toggle_bits(const struct device *dev, uint32_t mask) in gpio_sn74hc595_port_toggle_bits() argument
117 struct gpio_sn74hc595_drv_data *drv_data = dev->data; in gpio_sn74hc595_port_toggle_bits()
121 k_mutex_lock(&drv_data->lock, K_FOREVER); in gpio_sn74hc595_port_toggle_bits()
123 toggled_output = drv_data->output ^ mask; in gpio_sn74hc595_port_toggle_bits()
130 drv_data->output ^= mask; in gpio_sn74hc595_port_toggle_bits()
133 k_mutex_unlock(&drv_data->lock); in gpio_sn74hc595_port_toggle_bits()
154 const struct gpio_sn74hc595_config *config = dev->config; in gpio_sn74hc595_init()
155 struct gpio_sn74hc595_drv_data *drv_data = dev->data; in gpio_sn74hc595_init()
157 if (!spi_is_ready_dt(&config->bus)) { in gpio_sn74hc595_init()
158 LOG_ERR("SPI bus %s not ready", config->bus.bus->name); in gpio_sn74hc595_init()
159 return -ENODEV; in gpio_sn74hc595_init()
162 if (!gpio_is_ready_dt(&config->reset_gpio)) { in gpio_sn74hc595_init()
163 LOG_ERR("GPIO port %s not ready", config->reset_gpio.port->name); in gpio_sn74hc595_init()
164 return -ENODEV; in gpio_sn74hc595_init()
167 if (gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT_ACTIVE) < 0) { in gpio_sn74hc595_init()
168 LOG_ERR("Unable to configure RST GPIO pin %u", config->reset_gpio.pin); in gpio_sn74hc595_init()
169 return -EINVAL; in gpio_sn74hc595_init()
172 gpio_pin_set(config->reset_gpio.port, config->reset_gpio.pin, 0); in gpio_sn74hc595_init()
174 drv_data->output = 0U; in gpio_sn74hc595_init()