Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
spi.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_DRIVERS_SPI_H_
14#define ZEPHYR_INCLUDE_DRIVERS_SPI_H_
15
25
26#include <zephyr/types.h>
27#include <stddef.h>
28#include <zephyr/device.h>
30#include <zephyr/drivers/gpio.h>
31#include <zephyr/kernel.h>
32#include <zephyr/sys/__assert.h>
33#include <zephyr/rtio/rtio.h>
34#include <zephyr/stats/stats.h>
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
44
52#define SPI_OP_MODE_MASTER 0U
53
62#define SPI_OP_MODE_SLAVE BIT(0)
63
65#define SPI_OP_MODE_MASK 0x1U
67
71#define SPI_OP_MODE_GET(_operation_) ((_operation_) & SPI_OP_MODE_MASK)
73
74
79
89#define SPI_MODE_CPOL BIT(1)
90
100#define SPI_MODE_CPHA BIT(2)
101
111#define SPI_MODE_LOOP BIT(3)
112
114#define SPI_MODE_MASK (0xEU)
116
120#define SPI_MODE_GET(_mode_) \
121 ((_mode_) & SPI_MODE_MASK)
122
124
125
137
139#define SPI_TRANSFER_MSB (0U)
141#define SPI_TRANSFER_LSB BIT(4)
142
144#define SPI_WORD_SIZE_SHIFT (5U)
145#define SPI_WORD_SIZE_MASK (0x3FU << SPI_WORD_SIZE_SHIFT)
147
154#define SPI_WORD_SIZE_GET(operation) \
155 (((operation) & SPI_WORD_SIZE_MASK) >> SPI_WORD_SIZE_SHIFT)
156
163#define SPI_WORD_SET(word_size) \
164 ((word_size) << SPI_WORD_SIZE_SHIFT)
165
167
168
173
181#define SPI_HOLD_ON_CS BIT(12)
182
196#define SPI_LOCK_ON BIT(13)
197
209#define SPI_CS_ACTIVE_HIGH BIT(14)
210
212
213
223#define SPI_LINES_SINGLE (0U << 16)
224#define SPI_LINES_DUAL (1U << 16)
225#define SPI_LINES_QUAD (2U << 16)
226#define SPI_LINES_OCTAL (3U << 16)
227
228#define SPI_LINES_MASK (0x3U << 16)
229
231
236
259
297#define SPI_CS_GPIOS_DT_SPEC_GET(spi_dev) \
298 GPIO_DT_SPEC_GET_BY_IDX_OR(DT_BUS(spi_dev), cs_gpios, \
299 DT_REG_ADDR_RAW(spi_dev), {})
300
310#define SPI_CS_GPIOS_DT_SPEC_INST_GET(inst) \
311 SPI_CS_GPIOS_DT_SPEC_GET(DT_DRV_INST(inst))
312
351#define SPI_CS_CONTROL_INIT(node_id, delay_) \
352 { \
353 .gpio = SPI_CS_GPIOS_DT_SPEC_GET(node_id), \
354 .delay = (delay_), \
355 }
356
370#define SPI_CS_CONTROL_INIT_INST(inst, delay_) \
371 SPI_CS_CONTROL_INIT(DT_DRV_INST(inst), delay_)
372
374
379#if defined(CONFIG_SPI_EXTENDED_MODES)
381#else
383#endif
384
424
438#define SPI_CONFIG_DT(node_id, operation_, delay_) \
439 { \
440 .frequency = DT_PROP(node_id, spi_max_frequency), \
441 .operation = (operation_) | \
442 DT_PROP(node_id, duplex) | \
443 DT_PROP(node_id, frame_format) | \
444 COND_CODE_1(DT_PROP(node_id, spi_cpol), SPI_MODE_CPOL, (0)) | \
445 COND_CODE_1(DT_PROP(node_id, spi_cpha), SPI_MODE_CPHA, (0)) | \
446 COND_CODE_1(DT_PROP(node_id, spi_hold_cs), SPI_HOLD_ON_CS, (0)), \
447 .slave = DT_REG_ADDR(node_id), \
448 .cs = SPI_CS_CONTROL_INIT(node_id, delay_), \
449 }
450
462#define SPI_CONFIG_DT_INST(inst, operation_, delay_) \
463 SPI_CONFIG_DT(DT_DRV_INST(inst), operation_, delay_)
464
470 const struct device *bus;
473};
474
492#define SPI_DT_SPEC_GET(node_id, operation_, delay_) \
493 { \
494 .bus = DEVICE_DT_GET(DT_BUS(node_id)), \
495 .config = SPI_CONFIG_DT(node_id, operation_, delay_) \
496 }
497
509#define SPI_DT_SPEC_INST_GET(inst, operation_, delay_) \
510 SPI_DT_SPEC_GET(DT_DRV_INST(inst), operation_, delay_)
511
515#define SPI_MOSI_OVERRUN_UNKNOWN 0x100
516
529#define SPI_MOSI_OVERRUN_DT(node_id) \
530 DT_PROP_OR(node_id, overrun_character, SPI_MOSI_OVERRUN_UNKNOWN)
531
543#define SPI_MOSI_OVERRUN_DT_INST(inst) \
544 DT_INST_PROP_OR(inst, overrun_character, SPI_MOSI_OVERRUN_UNKNOWN)
545
554struct spi_buf {
556 void *buf;
558 size_t len;
559};
560
574 const struct spi_buf *buffers;
576 size_t count;
577};
578
583#if defined(CONFIG_SPI_STATS)
585STATS_SECT_ENTRY32(rx_bytes)
586STATS_SECT_ENTRY32(tx_bytes)
587STATS_SECT_ENTRY32(transfer_error)
589
591STATS_NAME(spi, rx_bytes)
592STATS_NAME(spi, tx_bytes)
593STATS_NAME(spi, transfer_error)
594STATS_NAME_END(spi);
595
599struct spi_device_state {
600 struct device_state devstate;
601 struct stats_spi stats;
602};
603
607#define Z_SPI_GET_STATS(dev_) \
608 CONTAINER_OF(dev_->state, struct spi_device_state, devstate)->stats
609
615#define SPI_STATS_RX_BYTES_INCN(dev_, n) \
616 STATS_INCN(Z_SPI_GET_STATS(dev_), rx_bytes, n)
617
623#define SPI_STATS_TX_BYTES_INCN(dev_, n) \
624 STATS_INCN(Z_SPI_GET_STATS(dev_), tx_bytes, n)
625
633#define SPI_STATS_TRANSFER_ERROR_INC(dev_) \
634 STATS_INC(Z_SPI_GET_STATS(dev_), transfer_error)
635
640#define Z_SPI_DEVICE_STATE_DEFINE(dev_id) \
641 static struct spi_device_state Z_DEVICE_STATE_NAME(dev_id) \
642 __attribute__((__section__(".z_devstate")));
643
650#define Z_SPI_INIT_FN(dev_id, init_fn) \
651 static inline int UTIL_CAT(dev_id, _init)(const struct device *dev) \
652 { \
653 struct spi_device_state *state = \
654 CONTAINER_OF(dev->state, struct spi_device_state, devstate); \
655 stats_init(&state->stats.s_hdr, STATS_SIZE_32, 3, \
656 STATS_NAME_INIT_PARMS(spi)); \
657 stats_register(dev->name, &(state->stats.s_hdr)); \
658 return init_fn(dev); \
659 }
661
662#define SPI_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, deinit_fn, \
663 pm_device, data_ptr, cfg_ptr, \
664 level, prio, api_ptr, ...) \
665 Z_SPI_DEVICE_STATE_DEFINE(Z_DEVICE_DT_DEV_ID(node_id)); \
666 Z_SPI_INIT_FN(Z_DEVICE_DT_DEV_ID(node_id), init_fn) \
667 Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
668 DEVICE_DT_NAME(node_id), \
669 &UTIL_CAT(Z_DEVICE_DT_DEV_ID(node_id), _init), \
670 deinit_fn, Z_DEVICE_DT_FLAGS(node_id), \
671 pm_device, data_ptr, cfg_ptr, level, prio, \
672 api_ptr, \
673 &(Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)).devstate), \
674 __VA_ARGS__)
675
676static inline void spi_transceive_stats(const struct device *dev, int error,
677 const struct spi_buf_set *tx_bufs,
678 const struct spi_buf_set *rx_bufs)
679{
680 uint32_t tx_bytes;
681 uint32_t rx_bytes;
682
683 if (error) {
685 }
686
687 if (tx_bufs) {
688 tx_bytes = tx_bufs->count ? tx_bufs->buffers->len : 0;
689 SPI_STATS_TX_BYTES_INCN(dev, tx_bytes);
690 }
691
692 if (rx_bufs) {
693 rx_bytes = rx_bufs->count ? rx_bufs->buffers->len : 0;
694 SPI_STATS_RX_BYTES_INCN(dev, rx_bytes);
695 }
696}
698
699#else /*CONFIG_SPI_STATS*/
700
705
726#define SPI_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, deinit_fn, pm, data, \
727 config, level, prio, api, ...) \
728 Z_DEVICE_STATE_DEFINE(Z_DEVICE_DT_DEV_ID(node_id)); \
729 Z_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_ID(node_id), \
730 DEVICE_DT_NAME(node_id), init_fn, deinit_fn, \
731 Z_DEVICE_DT_FLAGS(node_id), pm, data, config, \
732 level, prio, api, \
733 &Z_DEVICE_STATE_NAME(Z_DEVICE_DT_DEV_ID(node_id)), \
734 __VA_ARGS__)
735
737
738#define SPI_STATS_RX_BYTES_INC(dev_)
739#define SPI_STATS_TX_BYTES_INC(dev_)
740#define SPI_STATS_TRANSFER_ERROR_INC(dev_)
741
742#define spi_transceive_stats(dev, error, tx_bufs, rx_bufs)
743
744#endif /*CONFIG_SPI_STATS*/
745
765#define SPI_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, prio, \
766 api, ...) \
767 SPI_DEVICE_DT_DEINIT_DEFINE(node_id, init_fn, NULL, pm, data, config, \
768 level, prio, api, __VA_ARGS__)
769
778#define SPI_DEVICE_DT_INST_DEINIT_DEFINE(inst, ...) \
779 SPI_DEVICE_DT_DEINIT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
780
789#define SPI_DEVICE_DT_INST_DEFINE(inst, ...) \
790 SPI_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
791
797typedef int (*spi_api_io)(const struct device *dev,
798 const struct spi_config *config,
799 const struct spi_buf_set *tx_bufs,
800 const struct spi_buf_set *rx_bufs);
801
809typedef void (*spi_callback_t)(const struct device *dev, int result, void *data);
810
816typedef int (*spi_api_io_async)(const struct device *dev,
817 const struct spi_config *config,
818 const struct spi_buf_set *tx_bufs,
819 const struct spi_buf_set *rx_bufs,
821 void *userdata);
822
823#if defined(CONFIG_SPI_RTIO) || defined(DOXYGEN)
824
829typedef void (*spi_api_iodev_submit)(const struct device *dev,
830 struct rtio_iodev_sqe *iodev_sqe);
831#endif /* CONFIG_SPI_RTIO */
832
838typedef int (*spi_api_release)(const struct device *dev,
839 const struct spi_config *config);
840
841
846__subsystem struct spi_driver_api {
848#ifdef CONFIG_SPI_ASYNC
849 spi_api_io_async transceive_async;
850#endif /* CONFIG_SPI_ASYNC */
851#ifdef CONFIG_SPI_RTIO
852 spi_api_iodev_submit iodev_submit;
853#endif /* CONFIG_SPI_RTIO */
855};
856
864static inline bool spi_cs_is_gpio(const struct spi_config *config)
865{
866 return config->cs.gpio.port != NULL;
867}
868
876static inline bool spi_cs_is_gpio_dt(const struct spi_dt_spec *spec)
877{
878 return spi_cs_is_gpio(&spec->config);
879}
880
889static inline bool spi_is_ready_dt(const struct spi_dt_spec *spec)
890{
891 /* Validate bus is ready */
892 if (!device_is_ready(spec->bus)) {
893 return false;
894 }
895 /* Validate CS gpio port is ready, if it is used */
896 if (spi_cs_is_gpio_dt(spec) &&
897 !gpio_is_ready_dt(&spec->config.cs.gpio)) {
898 return false;
899 }
900 return true;
901}
902
910
941__syscall int spi_transceive(const struct device *dev,
942 const struct spi_config *config,
943 const struct spi_buf_set *tx_bufs,
944 const struct spi_buf_set *rx_bufs);
945
946static inline int z_impl_spi_transceive(const struct device *dev,
947 const struct spi_config *config,
948 const struct spi_buf_set *tx_bufs,
949 const struct spi_buf_set *rx_bufs)
950{
951 const struct spi_driver_api *api =
952 (const struct spi_driver_api *)dev->api;
953 int ret;
954
955 ret = api->transceive(dev, config, tx_bufs, rx_bufs);
956 spi_transceive_stats(dev, ret, tx_bufs, rx_bufs);
957
958 return ret;
959}
960
976static inline int spi_transceive_dt(const struct spi_dt_spec *spec,
977 const struct spi_buf_set *tx_bufs,
978 const struct spi_buf_set *rx_bufs)
979{
980 return spi_transceive(spec->bus, &spec->config, tx_bufs, rx_bufs);
981}
982
1003static inline int spi_read(const struct device *dev,
1004 const struct spi_config *config,
1005 const struct spi_buf_set *rx_bufs)
1006{
1007 return spi_transceive(dev, config, NULL, rx_bufs);
1008}
1009
1022static inline int spi_read_dt(const struct spi_dt_spec *spec,
1023 const struct spi_buf_set *rx_bufs)
1024{
1025 return spi_read(spec->bus, &spec->config, rx_bufs);
1026}
1027
1047static inline int spi_write(const struct device *dev,
1048 const struct spi_config *config,
1049 const struct spi_buf_set *tx_bufs)
1050{
1051 return spi_transceive(dev, config, tx_bufs, NULL);
1052}
1053
1066static inline int spi_write_dt(const struct spi_dt_spec *spec,
1067 const struct spi_buf_set *tx_bufs)
1068{
1069 return spi_write(spec->bus, &spec->config, tx_bufs);
1070}
1071
1072
1073#if defined(CONFIG_SPI_ASYNC) || defined(__DOXYGEN__)
1085
1118static inline int spi_transceive_cb(const struct device *dev,
1119 const struct spi_config *config,
1120 const struct spi_buf_set *tx_bufs,
1121 const struct spi_buf_set *rx_bufs,
1122 spi_callback_t callback,
1123 void *userdata)
1124{
1125 const struct spi_driver_api *api =
1126 (const struct spi_driver_api *)dev->api;
1127
1128 return api->transceive_async(dev, config, tx_bufs, rx_bufs, callback, userdata);
1129}
1130
1131#if defined(CONFIG_POLL) || defined(__DOXYGEN__)
1132
1134void z_spi_transfer_signal_cb(const struct device *dev, int result, void *userdata);
1136
1168static inline int spi_transceive_signal(const struct device *dev,
1169 const struct spi_config *config,
1170 const struct spi_buf_set *tx_bufs,
1171 const struct spi_buf_set *rx_bufs,
1172 struct k_poll_signal *sig)
1173{
1174 const struct spi_driver_api *api =
1175 (const struct spi_driver_api *)dev->api;
1176 spi_callback_t cb = (sig == NULL) ? NULL : z_spi_transfer_signal_cb;
1177
1178 return api->transceive_async(dev, config, tx_bufs, rx_bufs, cb, sig);
1179}
1180
1208static inline int spi_read_signal(const struct device *dev,
1209 const struct spi_config *config,
1210 const struct spi_buf_set *rx_bufs,
1211 struct k_poll_signal *sig)
1212{
1213 return spi_transceive_signal(dev, config, NULL, rx_bufs, sig);
1214}
1215
1242static inline int spi_write_signal(const struct device *dev,
1243 const struct spi_config *config,
1244 const struct spi_buf_set *tx_bufs,
1245 struct k_poll_signal *sig)
1246{
1247 return spi_transceive_signal(dev, config, tx_bufs, NULL, sig);
1248}
1249
1250#endif /* CONFIG_POLL */
1251
1253#endif /* CONFIG_SPI_ASYNC */
1254
1255
1256#if defined(CONFIG_SPI_RTIO) || defined(__DOXYGEN__)
1257
1272static inline void spi_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
1273{
1274 const struct spi_dt_spec *dt_spec = (const struct spi_dt_spec *)iodev_sqe->sqe.iodev->data;
1275 const struct device *dev = dt_spec->bus;
1276 const struct spi_driver_api *api = (const struct spi_driver_api *)dev->api;
1277
1278 api->iodev_submit(dt_spec->bus, iodev_sqe);
1279}
1280
1282extern const struct rtio_iodev_api spi_iodev_api;
1284
1296#define SPI_DT_IODEV_DEFINE(name, node_id, operation_, delay_) \
1297 const struct spi_dt_spec _spi_dt_spec_##name = \
1298 SPI_DT_SPEC_GET(node_id, operation_, delay_); \
1299 RTIO_IODEV_DEFINE(name, &spi_iodev_api, (void *)&_spi_dt_spec_##name)
1300
1309static inline bool spi_is_ready_iodev(const struct rtio_iodev *spi_iodev)
1310{
1311 struct spi_dt_spec *spec = (struct spi_dt_spec *)spi_iodev->data;
1312
1313 return spi_is_ready_dt(spec);
1314}
1315
1316
1317#endif /* CONFIG_SPI_RTIO */
1318
1339__syscall int spi_release(const struct device *dev,
1340 const struct spi_config *config);
1341
1342static inline int z_impl_spi_release(const struct device *dev,
1343 const struct spi_config *config)
1344{
1345 const struct spi_driver_api *api =
1346 (const struct spi_driver_api *)dev->api;
1347
1348 return api->release(dev, config);
1349}
1350
1362static inline int spi_release_dt(const struct spi_dt_spec *spec)
1363{
1364 return spi_release(spec->bus, &spec->config);
1365}
1366
1367#ifdef __cplusplus
1368}
1369#endif
1370
1374
1375#include <zephyr/syscalls/spi.h>
1376
1380#endif /* ZEPHYR_INCLUDE_DRIVERS_SPI_H_ */
Main header file for GPIO driver API.
bool device_is_ready(const struct device *dev)
Verify that a device is ready for use.
static bool gpio_is_ready_dt(const struct gpio_dt_spec *spec)
Validate that GPIO port is ready.
Definition gpio.h:854
int(* spi_api_io_async)(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, spi_callback_t cb, void *userdata)
Definition spi.h:816
int spi_release(const struct device *dev, const struct spi_config *config)
Release the SPI device locked on and/or the CS by the current config.
void(* spi_callback_t)(const struct device *dev, int result, void *data)
SPI callback for asynchronous transfer requests.
Definition spi.h:809
static int spi_write_dt(const struct spi_dt_spec *spec, const struct spi_buf_set *tx_bufs)
Write data to a SPI bus specified in spi_dt_spec.
Definition spi.h:1066
static bool spi_is_ready_dt(const struct spi_dt_spec *spec)
Validate that SPI bus (and CS gpio if defined) is ready.
Definition spi.h:889
uint16_t spi_operation_t
Opaque type to hold the SPI operation flags.
Definition spi.h:382
int(* spi_api_io)(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs)
Callback API for I/O See spi_transceive() for argument descriptions.
Definition spi.h:797
static int spi_transceive_signal(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, struct k_poll_signal *sig)
Read/write the specified amount of data from the SPI driver.
Definition spi.h:1168
static int spi_read(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *rx_bufs)
Read the specified amount of data from the SPI driver.
Definition spi.h:1003
static int spi_transceive_dt(const struct spi_dt_spec *spec, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs)
Read/write data from an SPI bus specified in spi_dt_spec.
Definition spi.h:976
static int spi_transceive_cb(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, spi_callback_t callback, void *userdata)
Read/write the specified amount of data from the SPI driver.
Definition spi.h:1118
#define SPI_STATS_TRANSFER_ERROR_INC(dev_)
Definition spi.h:740
static int spi_read_dt(const struct spi_dt_spec *spec, const struct spi_buf_set *rx_bufs)
Read data from a SPI bus specified in spi_dt_spec.
Definition spi.h:1022
static int spi_write(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs)
Write the specified amount of data from the SPI driver.
Definition spi.h:1047
static int spi_release_dt(const struct spi_dt_spec *spec)
Release the SPI device specified in spi_dt_spec.
Definition spi.h:1362
static void spi_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
Submit a SPI device with a request.
Definition spi.h:1272
static int spi_read_signal(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *rx_bufs, struct k_poll_signal *sig)
Read the specified amount of data from the SPI driver.
Definition spi.h:1208
static bool spi_cs_is_gpio_dt(const struct spi_dt_spec *spec)
Check if SPI CS in spi_dt_spec is controlled using a GPIO.
Definition spi.h:876
int(* spi_api_release)(const struct device *dev, const struct spi_config *config)
Callback API for unlocking SPI device.
Definition spi.h:838
int spi_transceive(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs)
Read/write the specified amount of data from the SPI driver.
#define spi_transceive_stats(dev, error, tx_bufs, rx_bufs)
Definition spi.h:742
static int spi_write_signal(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, struct k_poll_signal *sig)
Write the specified amount of data from the SPI driver.
Definition spi.h:1242
static bool spi_cs_is_gpio(const struct spi_config *config)
Check if SPI CS is controlled using a GPIO.
Definition spi.h:864
static bool spi_is_ready_iodev(const struct rtio_iodev *spi_iodev)
Validate that SPI bus (and CS gpio if defined) is ready.
Definition spi.h:1309
#define NULL
Definition iar_missing_defs.h:20
Public kernel APIs.
Real-Time IO device API for moving bytes with low effort.
Statistics.
#define STATS_NAME_END(name__)
Definition stats.h:391
#define STATS_NAME(name__, entry__)
Definition stats.h:390
#define STATS_SECT_END
Ends a stats group struct definition.
Definition stats.h:89
#define STATS_SECT_ENTRY32(var__)
Definition stats.h:359
#define STATS_NAME_START(name__)
Definition stats.h:389
#define STATS_SECT_START(group__)
Definition stats.h:354
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device dynamic structure (in RAM) per driver instance.
Definition device.h:455
Runtime device structure (in ROM) per driver instance.
Definition device.h:510
void * data
Address of the device instance private data.
Definition device.h:520
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:516
Container for GPIO pin information specified in devicetree.
Definition gpio.h:296
const struct device * port
GPIO device controlling the pin.
Definition gpio.h:298
Definition kernel.h:6128
API that an RTIO IO device should implement.
Definition rtio.h:524
Compute the mempool block index for a given pointer.
Definition rtio.h:514
struct rtio_sqe sqe
Definition rtio.h:515
An IO device with a function table for submitting requests.
Definition rtio.h:539
void * data
Definition rtio.h:544
const struct rtio_iodev * iodev
Device to operation on.
Definition rtio.h:304
SPI scatter-gather buffer array structure.
Definition spi.h:572
const struct spi_buf * buffers
Pointer to an array of spi_buf, or NULL.
Definition spi.h:574
size_t count
Number of buffers in the array pointed to: by buffers.
Definition spi.h:576
SPI buffer structure.
Definition spi.h:554
size_t len
Length of the buffer buf in bytes, or length of NOP.
Definition spi.h:558
void * buf
Valid pointer to a data buffer, or NULL for NOP indication.
Definition spi.h:556
SPI controller configuration structure.
Definition spi.h:392
uint16_t slave
Slave number from 0 to host controller slave limit.
Definition spi.h:417
struct spi_cs_control cs
GPIO chip-select line (optional, must be initialized to zero if not used).
Definition spi.h:422
spi_operation_t operation
Operation flags.
Definition spi.h:415
uint32_t frequency
Bus frequency in Hertz.
Definition spi.h:394
SPI Chip Select control structure.
Definition spi.h:244
uint32_t delay
Delay in microseconds to wait before starting the transmission and before releasing the CS line.
Definition spi.h:257
struct gpio_dt_spec gpio
GPIO devicetree specification of CS GPIO.
Definition spi.h:252
SPI driver API This is the mandatory API any SPI driver needs to expose.
Definition spi.h:846
spi_api_io transceive
Definition spi.h:847
spi_api_release release
Definition spi.h:854
Complete SPI DT information.
Definition spi.h:468
const struct device * bus
SPI bus.
Definition spi.h:470
struct spi_config config
Slave specific configuration.
Definition spi.h:472