Zephyr Project API 4.4.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
22
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35struct spi_msg;
36struct spi_emul_api;
37
39struct spi_emul {
42
44 const struct emul *target;
45
47 const struct spi_emul_api *api;
48
54
57};
58
75typedef int (*spi_emul_io_t)(const struct emul *target, const struct spi_config *config,
76 const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs);
77
85int spi_emul_register(const struct device *dev, struct spi_emul *emul);
86
92
100
101#ifdef __cplusplus
102}
103#endif
104
108
109#endif /* ZEPHYR_INCLUDE_DRIVERS_SPI_SPI_EMUL_H_ */
APIs and macros for the Zephyr device model.
Public APIs for the device emulation framework.
Main header file for SPI (Serial Peripheral Interface) driver API.
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:44
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:75
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.
Header file for the single-linked list API.
__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:543
An emulator instance - represents the target emulated device/peripheral that is interacted with throu...
Definition emul.h:88
SPI scatter-gather buffer array structure.
Definition spi.h:679
SPI controller configuration structure.
Definition spi.h:449
Definition of the emulator API.
Definition spi_emul.h:88
spi_emul_io_t io
Passes SPI messages to the emulator.
Definition spi_emul.h:90
Node in a linked list of emulators for SPI devices.
Definition spi_emul.h:39
const struct emul * target
Target emulator - REQUIRED for all bus emulators.
Definition spi_emul.h:44
sys_snode_t node
Node in the controller's linked list of emulators.
Definition spi_emul.h:41
struct spi_emul_api * mock_api
A mock API that if not NULL will take precedence over the actual API.
Definition spi_emul.h:53
uint16_t chipsel
SPI chip-select of the emulated device.
Definition spi_emul.h:56
const struct spi_emul_api * api
API provided for this device.
Definition spi_emul.h:47