Lines Matching +full:cs +full:- +full:mode

4  * SPDX-License-Identifier: Apache-2.0
27 #include <zephyr/dt-bindings/spi/spi.h>
39 * @name SPI operational mode
42 #define SPI_OP_MODE_MASTER 0U /**< Master mode. */
43 #define SPI_OP_MODE_SLAVE BIT(0) /**< Slave mode. */
47 /** Get SPI operational mode. */
73 * Whatever data is transmitted is looped-back to the receiving buffer of
81 /** Get SPI polarity and phase mode bits. */
115 /** Requests - if possible - to keep CS asserted after the transaction */
124 /** Active high logic on CS. Usually, and by default, CS logic is active
128 * the CS control to a gpio line through struct spi_cs_control would be
155 * This can be used to control a CS line via a GPIO line, instead of
156 * using the controller inner CS logic.
161 * GPIO devicetree specification of CS GPIO.
162 * The device pointer can be set to NULL to fully inhibit CS control if
170 * transmission and before releasing the CS line.
187 * cs-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>,
190 * a: spi-dev-a@0 {
194 * b: spi-dev-b@1 {
241 * cs-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>;
242 * spidev: spi-device@0 { ... };
309 * - 0: Master or slave.
310 * - 1..3: Polarity, phase and loop mode.
311 * - 4: LSB or MSB first.
312 * - 5..10: Size of a data frame (word) in bits.
313 * - 11: Full/half duplex.
314 * - 12: Hold on the CS line if possible.
315 * - 13: Keep resource locked for the caller.
316 * - 14: Active high CS logic.
317 * - 15: Motorola or TI frame format (optional).
321 * - 16..17: MISO lines (Single/Dual/Quad/Octal).
322 * - 18..31: Reserved for future use.
328 * @brief GPIO chip-select line (optional, must be initialized to zero
331 struct spi_cs_control cs; member
339 * @p cs data from the devicetree.
357 .cs = SPI_CS_CONTROL_INIT(node_id, delay_), \
388 * spi_dt_spec</tt> by reading the relevant bus, frequency, slave, and cs
430 * can be queried at compile-time to determine whether allocating a constant
503 CONTAINER_OF(dev_->state, struct spi_device_state, devstate)->stats
548 CONTAINER_OF(dev->state, struct spi_device_state, devstate); \
549 stats_init(&state->stats.s_hdr, STATS_SIZE_32, 3, \
551 stats_register(dev->name, &(state->stats.s_hdr)); \
600 tx_bytes = tx_bufs->count ? tx_bufs->buffers->len : 0; in spi_transceive_stats()
605 rx_bytes = rx_bufs->count ? rx_bufs->buffers->len : 0; in spi_transceive_stats()
655 * @param result Result code of the transfer request. 0 is success, -errno for failure.
707 * @brief Check if SPI CS is controlled using a GPIO.
710 * @return true If CS is controlled using a GPIO.
711 * @return false If CS is controlled by hardware or any other means.
715 return config->cs.gpio.port != NULL; in spi_cs_is_gpio()
719 * @brief Check if SPI CS in @ref spi_dt_spec is controlled using a GPIO.
722 * @return true If CS is controlled using a GPIO.
723 * @return false If CS is controlled by hardware or any other means.
727 return spi_cs_is_gpio(&spec->config); in spi_cs_is_gpio_dt()
731 * @brief Validate that SPI bus (and CS gpio if defined) is ready.
736 * @retval false if the SPI bus (or the CS gpio defined) is not ready for use.
741 if (!device_is_ready(spec->bus)) { in spi_is_ready_dt()
744 /* Validate CS gpio port is ready, if it is used */ in spi_is_ready_dt()
746 !gpio_is_ready_dt(&spec->config.cs.gpio)) { in spi_is_ready_dt()
759 * Pointer-comparison may be used to detect changes from
766 * @retval frames Positive number of frames received in slave mode.
767 * @retval 0 If successful in master mode.
768 * @retval -errno Negative errno code on failure.
781 (const struct spi_driver_api *)dev->api; in z_impl_spi_transceive()
784 ret = api->transceive(dev, config, tx_bufs, rx_bufs); in z_impl_spi_transceive()
795 * spi_transceive(spec->bus, &spec->config, tx_bufs, rx_bufs);
809 return spi_transceive(spec->bus, &spec->config, tx_bufs, rx_bufs); in spi_transceive_dt()
821 * Pointer-comparison may be used to detect changes from
825 * @retval frames Positive number of frames received in slave mode.
827 * @retval -errno Negative errno code on failure.
841 * spi_read(spec->bus, &spec->config, rx_bufs);
851 return spi_read(spec->bus, &spec->config, rx_bufs); in spi_read_dt()
863 * Pointer-comparison may be used to detect changes from
868 * @retval -errno Negative errno code on failure.
882 * spi_write(spec->bus, &spec->config, tx_bufs);
892 return spi_write(spec->bus, &spec->config, tx_bufs); in spi_write_dt()
907 * Pointer-comparison may be used to detect changes from
919 * @retval frames Positive number of frames received in slave mode.
920 * @retval 0 If successful in master mode.
921 * @retval -errno Negative errno code on failure.
931 (const struct spi_driver_api *)dev->api; in spi_transceive_cb()
933 return api->transceive_async(dev, config, tx_bufs, rx_bufs, callback, userdata); in spi_transceive_cb()
952 * Pointer-comparison may be used to detect changes from
963 * @retval frames Positive number of frames received in slave mode.
964 * @retval 0 If successful in master mode.
965 * @retval -errno Negative errno code on failure.
974 (const struct spi_driver_api *)dev->api; in spi_transceive_signal()
977 return api->transceive_async(dev, config, tx_bufs, rx_bufs, cb, sig); in spi_transceive_signal()
992 * Pointer-comparison may be used to detect changes from
1000 * @retval frames Positive number of frames received in slave mode.
1002 * @retval -errno Negative errno code on failure.
1024 * Pointer-comparison may be used to detect changes from
1033 * @retval -errno Negative errno code on failure.
1059 const struct spi_dt_spec *dt_spec = (const struct spi_dt_spec *)iodev_sqe->sqe.iodev->data; in spi_iodev_submit()
1060 const struct device *dev = dt_spec->bus; in spi_iodev_submit()
1061 const struct spi_driver_api *api = (const struct spi_driver_api *)dev->api; in spi_iodev_submit()
1063 api->iodev_submit(dt_spec->bus, iodev_sqe); in spi_iodev_submit()
1076 * @param operation_ SPI operational mode
1085 * @brief Validate that SPI bus (and CS gpio if defined) is ready.
1090 * @retval false if the SPI bus (or the CS gpio defined) is not ready for use.
1094 struct spi_dt_spec *spec = (struct spi_dt_spec *)spi_iodev->data; in spi_is_ready_iodev()
1102 * @brief Release the SPI device locked on and/or the CS by the current config
1105 * SPI device and/or the CS line that was kept if, and if only,
1119 * @retval -errno Negative errno code on failure.
1128 (const struct spi_driver_api *)dev->api; in z_impl_spi_release()
1130 return api->release(dev, config); in z_impl_spi_release()
1138 * spi_release(spec->bus, &spec->config);
1146 return spi_release(spec->bus, &spec->config); in spi_release_dt()