forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
w1_test.c
74 lines (61 loc) · 1.68 KB
/
w1_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
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Copyright (c) 2022 Thomas Stranger
*
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT vnd_w1
/*
* This is not a real 1-Wire driver. It is only used to instantiate struct
* devices for the "vnd,w1" devicetree compatibe used in test code.
*/
#include <zephyr/drivers/w1.h>
struct w1_vnd_config {
/** w1 master config, common to all drivers */
struct w1_master_config master_config;
};
struct w1_vnd_data {
/** w1 master data, common to all drivers */
struct w1_master_data master_data;
};
static int w1_vnd_reset_bus(const struct device *dev)
{
return -ENOTSUP;
}
static int w1_vnd_read_bit(const struct device *dev)
{
return -ENOTSUP;
}
static int w1_vnd_write_bit(const struct device *dev, const bool bit)
{
return -ENOTSUP;
}
static int w1_vnd_read_byte(const struct device *dev)
{
return -ENOTSUP;
}
static int w1_vnd_write_byte(const struct device *dev, const uint8_t byte)
{
return -ENOTSUP;
}
static int w1_vnd_configure(const struct device *dev,
enum w1_settings_type type, uint32_t value)
{
return -ENOTSUP;
}
static DEVICE_API(w1, w1_vnd_api) = {
.reset_bus = w1_vnd_reset_bus,
.read_bit = w1_vnd_read_bit,
.write_bit = w1_vnd_write_bit,
.read_byte = w1_vnd_read_byte,
.write_byte = w1_vnd_write_byte,
.configure = w1_vnd_configure,
};
#define W1_VND_INIT(n) \
static const struct w1_vnd_config w1_vnd_cfg_##inst = { \
.master_config.slave_count = W1_INST_SLAVE_COUNT(inst) \
}; \
static struct w1_vnd_data w1_vnd_data_##inst = {}; \
DEVICE_DT_INST_DEFINE(n, NULL, NULL, &w1_vnd_data_##inst, \
&w1_vnd_cfg_##inst, POST_KERNEL, \
CONFIG_W1_INIT_PRIORITY, &w1_vnd_api);
DT_INST_FOREACH_STATUS_OKAY(W1_VND_INIT)