Zephyr API 3.6.99
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
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33struct spi_msg;
34struct spi_emul_api;
35
37struct spi_emul {
39
41 const struct emul *target;
42
43 /* API provided for this device */
44 const struct spi_emul_api *api;
45
51
52 /* SPI chip-select of the emulated device */
54};
55
72typedef int (*spi_emul_io_t)(const struct emul *target, const struct spi_config *config,
73 const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs);
74
82int spi_emul_register(const struct device *dev, struct spi_emul *emul);
83
88
96
97#ifdef __cplusplus
98}
99#endif
100
105#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:72
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:403
An emulator instance - represents the target emulated device/peripheral that is interacted with throu...
Definition emul.h:82
SPI buffer array structure.
Definition spi.h:471
SPI controller configuration structure.
Definition spi.h:301
Definition of the emulator API.
Definition spi_emul.h:85
spi_emul_io_t io
Definition spi_emul.h:86
Node in a linked list of emulators for SPI devices.
Definition spi_emul.h:37
const struct emul * target
Target emulator - REQUIRED for all bus emulators.
Definition spi_emul.h:41
sys_snode_t node
Definition spi_emul.h:38
struct spi_emul_api * mock_api
A mock API that if not NULL will take precedence over the actual API.
Definition spi_emul.h:50
uint16_t chipsel
Definition spi_emul.h:53
const struct spi_emul_api * api
Definition spi_emul.h:44