Zephyr Project API 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
spi_emul.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Google LLC
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DRIVERS_SPI_SPI_EMUL_H_
8#define ZEPHYR_INCLUDE_DRIVERS_SPI_SPI_EMUL_H_
9
10#include <zephyr/device.h>
11#include <zephyr/drivers/emul.h>
12#include <zephyr/drivers/spi.h>
13#include <zephyr/sys/slist.h>
14#include <zephyr/types.h>
15
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34struct spi_msg;
35struct spi_emul_api;
36
38struct spi_emul {
40
42 const struct emul *target;
43
44 /* API provided for this device */
45 const struct spi_emul_api *api;
46
52
53 /* SPI chip-select of the emulated device */
55};
56
73typedef int (*spi_emul_io_t)(const struct emul *target, const struct spi_config *config,
74 const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs);
75
83int spi_emul_register(const struct device *dev, struct spi_emul *emul);
84
89
97
98#ifdef __cplusplus
99}
100#endif
101
106#endif /* ZEPHYR_INCLUDE_DRIVERS_SPI_SPI_EMUL_H_ */
Public API for SPI drivers and applications.
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
int(* spi_emul_io_t)(const struct emul *target, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs)
Passes SPI messages to the emulator.
Definition spi_emul.h:73
int spi_emul_register(const struct device *dev, struct spi_emul *emul)
Register an emulated device on the controller.
uint32_t spi_emul_get_config(const struct device *dev)
Back door to allow an emulator to retrieve the host configuration.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:510
An emulator instance - represents the target emulated device/peripheral that is interacted with throu...
Definition emul.h:82
SPI scatter-gather buffer array structure.
Definition spi.h:570
SPI controller configuration structure.
Definition spi.h:390
Definition of the emulator API.
Definition spi_emul.h:86
spi_emul_io_t io
Definition spi_emul.h:87
Node in a linked list of emulators for SPI devices.
Definition spi_emul.h:38
const struct emul * target
Target emulator - REQUIRED for all bus emulators.
Definition spi_emul.h:42
sys_snode_t node
Definition spi_emul.h:39
struct spi_emul_api * mock_api
A mock API that if not NULL will take precedence over the actual API.
Definition spi_emul.h:51
uint16_t chipsel
Definition spi_emul.h:54
const struct spi_emul_api * api
Definition spi_emul.h:45