Lines Matching +full:positive +full:- +full:cs

4  * SPDX-License-Identifier: Apache-2.0
25 #include <zephyr/dt-bindings/spi/spi.h>
68 * Whatever data is transmitted is looped-back to the receiving buffer of
105 /* Requests - if possible - to keep CS asserted after the transaction */
114 /* Active high logic on CS - Usually, and by default, CS logic is active
118 * the CS control to a gpio line through struct spi_cs_control would be
144 * This can be used to control a CS line via a GPIO line, instead of
145 * using the controller inner CS logic.
150 * GPIO devicetree specification of CS GPIO.
151 * The device pointer can be set to NULL to fully inhibit CS control if
159 * transmission and before releasing the CS line.
176 * cs-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>,
179 * a: spi-dev-a@0 {
183 * b: spi-dev-b@1 {
229 * cs-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
230 * spidev: spi-device@0 { ... };
292 * - 0: Master or slave.
293 * - 1..3: Polarity, phase and loop mode.
294 * - 4: LSB or MSB first.
295 * - 5..10: Size of a data frame in bits.
296 * - 11: Full/half duplex.
297 * - 12: Hold on the CS line if possible.
298 * - 13: Keep resource locked for the caller.
299 * - 14: Active high CS logic.
300 * - 15: Motorola or TI frame format (optional).
304 * - 16..17: MISO lines (Single/Dual/Quad/Octal).
305 * - 18..31: Reserved for future use.
311 * @brief GPIO chip-select line (optional, must be initialized to zero
314 struct spi_cs_control cs; member
322 * @p cs data from the devicetree.
337 .cs = SPI_CS_CONTROL_INIT(node_id, delay_), \
369 * spi_dt_spec</tt> by reading the relevant bus, frequency, slave, and cs
452 CONTAINER_OF(dev_->state, struct spi_device_state, devstate)->stats
497 CONTAINER_OF(dev->state, struct spi_device_state, devstate); \
498 stats_init(&state->stats.s_hdr, STATS_SIZE_32, 3, \
500 stats_register(dev->name, &(state->stats.s_hdr)); \
549 tx_bytes = tx_bufs->count ? tx_bufs->buffers->len : 0; in spi_transceive_stats()
554 rx_bytes = rx_bufs->count ? rx_bufs->buffers->len : 0; in spi_transceive_stats()
593 * @param result Result code of the transfer request. 0 is success, -errno for failure.
645 * @brief Check if SPI CS is controlled using a GPIO.
648 * @return true If CS is controlled using a GPIO.
649 * @return false If CS is controlled by hardware or any other means.
653 return config->cs.gpio.port != NULL; in spi_cs_is_gpio()
657 * @brief Check if SPI CS in @ref spi_dt_spec is controlled using a GPIO.
660 * @return true If CS is controlled using a GPIO.
661 * @return false If CS is controlled by hardware or any other means.
665 return spi_cs_is_gpio(&spec->config); in spi_cs_is_gpio_dt()
680 if (!device_is_ready(spec->bus)) { in spi_is_ready()
683 /* Validate CS gpio port is ready, if it is used */ in spi_is_ready()
685 !gpio_is_ready_dt(&spec->config.cs.gpio)) { in spi_is_ready()
692 * @brief Validate that SPI bus (and CS gpio if defined) is ready.
697 * @retval false if the SPI bus (or the CS gpio defined) is not ready for use.
702 if (!device_is_ready(spec->bus)) { in spi_is_ready_dt()
705 /* Validate CS gpio port is ready, if it is used */ in spi_is_ready_dt()
707 !gpio_is_ready_dt(&spec->config.cs.gpio)) { in spi_is_ready_dt()
720 * Pointer-comparison may be used to detect changes from
727 * @retval frames Positive number of frames received in slave mode.
729 * @retval -errno Negative errno code on failure.
742 (const struct spi_driver_api *)dev->api; in z_impl_spi_transceive()
745 ret = api->transceive(dev, config, tx_bufs, rx_bufs); in z_impl_spi_transceive()
756 * spi_transceive(spec->bus, &spec->config, tx_bufs, rx_bufs);
770 return spi_transceive(spec->bus, &spec->config, tx_bufs, rx_bufs); in spi_transceive_dt()
782 * Pointer-comparison may be used to detect changes from
787 * @retval -errno Negative errno code on failure.
801 * spi_read(spec->bus, &spec->config, rx_bufs);
811 return spi_read(spec->bus, &spec->config, rx_bufs); in spi_read_dt()
823 * Pointer-comparison may be used to detect changes from
828 * @retval -errno Negative errno code on failure.
842 * spi_write(spec->bus, &spec->config, tx_bufs);
852 return spi_write(spec->bus, &spec->config, tx_bufs); in spi_write_dt()
867 * Pointer-comparison may be used to detect changes from
879 * @retval frames Positive number of frames received in slave mode.
881 * @retval -errno Negative errno code on failure.
891 (const struct spi_driver_api *)dev->api; in spi_transceive_cb()
893 return api->transceive_async(dev, config, tx_bufs, rx_bufs, callback, userdata); in spi_transceive_cb()
912 * Pointer-comparison may be used to detect changes from
923 * @retval frames Positive number of frames received in slave mode.
925 * @retval -errno Negative errno code on failure.
934 (const struct spi_driver_api *)dev->api; in spi_transceive_signal()
937 return api->transceive_async(dev, config, tx_bufs, rx_bufs, cb, sig); in spi_transceive_signal()
966 * Pointer-comparison may be used to detect changes from
975 * @retval -errno Negative errno code on failure.
1010 * Pointer-comparison may be used to detect changes from
1019 * @retval -errno Negative errno code on failure.
1058 const struct spi_dt_spec *dt_spec = iodev_sqe->sqe.iodev->data; in spi_iodev_submit()
1059 const struct device *dev = dt_spec->bus; in spi_iodev_submit()
1060 const struct spi_driver_api *api = (const struct spi_driver_api *)dev->api; in spi_iodev_submit()
1062 api->iodev_submit(dt_spec->bus, iodev_sqe); in spi_iodev_submit()
1084 * @brief Validate that SPI bus (and CS gpio if defined) is ready.
1089 * @retval false if the SPI bus (or the CS gpio defined) is not ready for use.
1093 struct spi_dt_spec *spec = spi_iodev->data; in spi_is_ready_iodev()
1108 * @retval -ENOMEM out of memory
1117 size_t tx_count = tx_bufs ? tx_bufs->count : 0; in spi_rtio_copy()
1118 size_t rx_count = rx_bufs ? rx_bufs->count : 0; in spi_rtio_copy()
1127 tx_buf = tx_bufs->buffers[tx].buf; in spi_rtio_copy()
1128 tx_len = tx_bufs->buffers[tx].len; in spi_rtio_copy()
1131 tx_len = rx_bufs->buffers[rx].len; in spi_rtio_copy()
1135 rx_buf = rx_bufs->buffers[rx].buf; in spi_rtio_copy()
1136 rx_len = rx_bufs->buffers[rx].len; in spi_rtio_copy()
1139 rx_len = tx_bufs->buffers[tx].len; in spi_rtio_copy()
1147 ret = -ENOMEM; in spi_rtio_copy()
1169 rx_buf = rx_bufs->buffers[rx].buf; in spi_rtio_copy()
1170 rx_len = rx_bufs->buffers[rx].len; in spi_rtio_copy()
1176 tx_buf = tx_bufs->buffers[tx].buf; in spi_rtio_copy()
1177 tx_len = tx_bufs->buffers[tx].len; in spi_rtio_copy()
1189 rx_buf = rx_bufs->buffers[rx].buf; in spi_rtio_copy()
1190 rx_len = rx_bufs->buffers[rx].len; in spi_rtio_copy()
1202 tx_buf = rx_bufs->buffers[rx].buf; in spi_rtio_copy()
1203 tx_len = rx_bufs->buffers[rx].len; in spi_rtio_copy()
1214 tx_len -= rx_len; in spi_rtio_copy()
1218 rx_buf = rx_bufs->buffers[rx].buf; in spi_rtio_copy()
1219 rx_len = rx_bufs->buffers[rx].len; in spi_rtio_copy()
1230 rx_len -= tx_len; in spi_rtio_copy()
1234 tx_buf = tx_bufs->buffers[tx].buf; in spi_rtio_copy()
1235 tx_len = tx_bufs->buffers[tx].len; in spi_rtio_copy()
1244 sqe->flags = RTIO_SQE_TRANSACTION; in spi_rtio_copy()
1248 sqe->flags = 0; in spi_rtio_copy()
1259 * @brief Release the SPI device locked on and/or the CS by the current config
1262 * SPI device and/or the CS line that was kept if, and if only,
1276 * @retval -errno Negative errno code on failure.
1285 (const struct spi_driver_api *)dev->api; in z_impl_spi_release()
1287 return api->release(dev, config); in z_impl_spi_release()
1295 * spi_release(spec->bus, &spec->config);
1303 return spi_release(spec->bus, &spec->config); in spi_release_dt()