forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspi_test.c
61 lines (51 loc) · 1.39 KB
/
spi_test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Copyright (c) 2021, Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* This is not a real SPI driver. It is used to instantiate struct
* devices for the "vnd,spi" devicetree compatible used in test code.
*/
#include <zephyr.h>
#include <drivers/spi.h>
#define DT_DRV_COMPAT vnd_spi
static int vnd_spi_transceive(const struct device *dev,
const struct spi_config *spi_cfg,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs)
{
return -ENOTSUP;
}
#ifdef CONFIG_SPI_ASYNC
static int vnd_spi_transceive_async(const struct device *dev,
const struct spi_config *spi_cfg,
const struct spi_buf_set *tx_bufs,
const struct spi_buf_set *rx_bufs,
struct k_poll_signal *async)
{
return -ENOTSUP;
}
#endif
static int vnd_spi_release(const struct device *dev,
const struct spi_config *spi_cfg)
{
return -ENOTSUP;
}
static const struct spi_driver_api vnd_spi_api = {
.transceive = vnd_spi_transceive,
#ifdef CONFIG_SPI_ASYNC
.transceive_async = vnd_spi_transceive_async,
#endif
.release = vnd_spi_release,
};
static int vnd_spi_init(const struct device *dev)
{
return 0;
}
#define VND_SPI_INIT(n) \
DEVICE_DT_INST_DEFINE(n, &vnd_spi_init, NULL, \
NULL, NULL, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
&vnd_spi_api);
DT_INST_FOREACH_STATUS_OKAY(VND_SPI_INIT)