Lines Matching +full:high +full:- +full:side
4 * SPDX-License-Identifier: Apache-2.0
65 const struct spi_nrfx_config *dev_config = dev->config; in configure()
66 struct spi_nrfx_data *dev_data = dev->data; in configure()
67 struct spi_context *ctx = &dev_data->ctx; in configure()
74 if (spi_cfg->operation & SPI_HALF_DUPLEX) { in configure()
75 LOG_ERR("Half-duplex not supported"); in configure()
76 return -ENOTSUP; in configure()
79 if (SPI_OP_MODE_GET(spi_cfg->operation) == SPI_OP_MODE_MASTER) { in configure()
80 LOG_ERR("Master mode is not supported on %s", dev->name); in configure()
81 return -EINVAL; in configure()
84 if (spi_cfg->operation & SPI_MODE_LOOP) { in configure()
86 return -EINVAL; in configure()
90 (spi_cfg->operation & SPI_LINES_MASK) != SPI_LINES_SINGLE) { in configure()
92 return -EINVAL; in configure()
95 if (SPI_WORD_SIZE_GET(spi_cfg->operation) != 8) { in configure()
97 return -EINVAL; in configure()
102 return -EINVAL; in configure()
105 ctx->config = spi_cfg; in configure()
107 nrf_spis_configure(dev_config->spis.p_reg, in configure()
108 get_nrf_spis_mode(spi_cfg->operation), in configure()
109 get_nrf_spis_bit_order(spi_cfg->operation)); in configure()
118 const struct spi_nrfx_config *dev_config = dev->config; in prepare_for_transfer()
121 if (tx_buf_len > dev_config->max_buf_len || in prepare_for_transfer()
122 rx_buf_len > dev_config->max_buf_len) { in prepare_for_transfer()
125 return -EINVAL; in prepare_for_transfer()
128 result = nrfx_spis_buffers_set(&dev_config->spis, in prepare_for_transfer()
132 return -EIO; in prepare_for_transfer()
143 const struct spi_nrfx_config *dev_config = dev_data->dev->config; in wake_callback()
145 (void)gpio_pin_interrupt_configure_dt(&dev_config->wake_gpio, in wake_callback()
147 k_sem_give(&dev_data->wake_sem); in wake_callback()
153 /* If the WAKE line is low, wait until it goes high - this is a signal in wait_for_wake()
156 if (gpio_pin_get_raw(dev_config->wake_gpio.port, in wait_for_wake()
157 dev_config->wake_gpio.pin) == 0) { in wait_for_wake()
158 (void)gpio_pin_interrupt_configure_dt(&dev_config->wake_gpio, in wait_for_wake()
160 (void)k_sem_take(&dev_data->wake_sem, K_FOREVER); in wait_for_wake()
172 struct spi_nrfx_data *dev_data = dev->data; in transceive()
173 const struct spi_nrfx_config *dev_config = dev->config; in transceive()
174 const struct spi_buf *tx_buf = tx_bufs ? tx_bufs->buffers : NULL; in transceive()
175 const struct spi_buf *rx_buf = rx_bufs ? rx_bufs->buffers : NULL; in transceive()
178 spi_context_lock(&dev_data->ctx, asynchronous, cb, userdata, spi_cfg); in transceive()
183 } else if ((tx_bufs && tx_bufs->count > 1) || in transceive()
184 (rx_bufs && rx_bufs->count > 1)) { in transceive()
186 error = -ENOTSUP; in transceive()
187 } else if (tx_buf && tx_buf->len && !nrfx_is_in_ram(tx_buf->buf)) { in transceive()
189 error = -ENOTSUP; in transceive()
191 if (dev_config->wake_gpio.port) { in transceive()
194 nrf_spis_enable(dev_config->spis.p_reg); in transceive()
198 tx_buf ? tx_buf->buf : NULL, in transceive()
199 tx_buf ? tx_buf->len : 0, in transceive()
200 rx_buf ? rx_buf->buf : NULL, in transceive()
201 rx_buf ? rx_buf->len : 0); in transceive()
203 if (dev_config->wake_gpio.port) { in transceive()
207 gpio_pin_set_raw(dev_config->wake_gpio.port, in transceive()
208 dev_config->wake_gpio.pin, in transceive()
210 /* Set the WAKE line back high (i.e. disconnect in transceive()
213 * by the other side again. in transceive()
215 gpio_pin_set_raw(dev_config->wake_gpio.port, in transceive()
216 dev_config->wake_gpio.pin, in transceive()
220 error = spi_context_wait_for_completion(&dev_data->ctx); in transceive()
223 if (dev_config->wake_gpio.port) { in transceive()
224 nrf_spis_disable(dev_config->spis.p_reg); in transceive()
228 spi_context_release(&dev_data->ctx, error); in transceive()
256 struct spi_nrfx_data *dev_data = dev->data; in spi_nrfx_release()
258 if (!spi_context_configured(&dev_data->ctx, spi_cfg)) { in spi_nrfx_release()
259 return -EINVAL; in spi_nrfx_release()
262 spi_context_unlock_unconditionally(&dev_data->ctx); in spi_nrfx_release()
282 if (p_event->evt_type == NRFX_SPIS_XFER_DONE) { in event_handler()
283 spi_context_complete(&dev_data->ctx, dev_data->dev, in event_handler()
284 p_event->rx_amount); in event_handler()
290 const struct spi_nrfx_config *dev_config = dev->config; in spi_nrfx_init()
291 struct spi_nrfx_data *dev_data = dev->data; in spi_nrfx_init()
295 err = pinctrl_apply_state(dev_config->pcfg, PINCTRL_STATE_DEFAULT); in spi_nrfx_init()
303 result = nrfx_spis_init(&dev_config->spis, &dev_config->config, in spi_nrfx_init()
307 LOG_ERR("Failed to initialize device: %s", dev->name); in spi_nrfx_init()
308 return -EBUSY; in spi_nrfx_init()
311 if (dev_config->wake_gpio.port) { in spi_nrfx_init()
312 if (!gpio_is_ready_dt(&dev_config->wake_gpio)) { in spi_nrfx_init()
313 return -ENODEV; in spi_nrfx_init()
317 * the high state, so the following will effectively configure in spi_nrfx_init()
320 err = gpio_pin_configure_dt(&dev_config->wake_gpio, in spi_nrfx_init()
328 gpio_init_callback(&dev_data->wake_cb_data, wake_callback, in spi_nrfx_init()
329 BIT(dev_config->wake_gpio.pin)); in spi_nrfx_init()
330 err = gpio_add_callback(dev_config->wake_gpio.port, in spi_nrfx_init()
331 &dev_data->wake_cb_data); in spi_nrfx_init()
339 * Waiting for the WAKE line to go high, what can be done using in spi_nrfx_init()
344 nrf_spis_disable(dev_config->spis.p_reg); in spi_nrfx_init()
347 spi_context_unlock_unconditionally(&dev_data->ctx); in spi_nrfx_init()
355 * - HAL design (requirement of drv_inst_idx in nrfx_spis_t)
356 * - Name-based HAL IRQ handlers, e.g. nrfx_spis_0_irq_handler
396 "WAKE line must be configured as active high"); \