]> sigrok.org Git - sigrok-util.git/blame - source/drv-api.c
saleae-logicpro16: Decode more commands and registers
[sigrok-util.git] / source / drv-api.c
CommitLineData
a65d66c0 1/*
4b527a01 2 * This file is part of the libsigrok project.
a65d66c0 3 *
bc02c2bf 4 * Copyright (C) {year} {author} <{email}>
a65d66c0
BV
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
4dfd6ece 20#include <config.h>
a65d66c0
BV
21#include "protocol.h"
22
bc02c2bf 23SR_PRIV struct sr_dev_driver {lib}_driver_info;
a65d66c0 24
87604b0c 25static GSList *scan(struct sr_dev_driver *di, GSList *options)
bc02c2bf 26{{
a65d66c0
BV
27 struct drv_context *drvc;
28 GSList *devices;
29
30 (void)options;
126eded0 31
a65d66c0 32 devices = NULL;
f03716cf 33 drvc = di->context;
a65d66c0
BV
34 drvc->instances = NULL;
35
87c5b243
BV
36 /* TODO: scan for devices, either based on a SR_CONF_CONN option
37 * or on a USB scan. */
a65d66c0
BV
38
39 return devices;
bc02c2bf 40}}
a65d66c0 41
87604b0c 42static int dev_clear(const struct sr_dev_driver *di)
bc02c2bf 43{{
87c5b243 44 return std_dev_clear(di, NULL);
bc02c2bf 45}}
87c5b243
BV
46
47static int dev_open(struct sr_dev_inst *sdi)
bc02c2bf 48{{
3aef82b3
UH
49 (void)sdi;
50
87c5b243
BV
51 /* TODO: get handle from sdi->conn and open it. */
52
a65d66c0 53 return SR_OK;
bc02c2bf 54}}
a65d66c0 55
87c5b243 56static int dev_close(struct sr_dev_inst *sdi)
bc02c2bf 57{{
3aef82b3
UH
58 (void)sdi;
59
87c5b243
BV
60 /* TODO: get handle from sdi->conn and close it. */
61
a65d66c0 62 return SR_OK;
bc02c2bf 63}}
a65d66c0 64
df382df5
UH
65static int config_get(uint32_t key, GVariant **data,
66 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
bc02c2bf 67{{
87c5b243
BV
68 int ret;
69
3aef82b3 70 (void)sdi;
87c5b243 71 (void)data;
d73e0933 72 (void)cg;
3aef82b3 73
87c5b243 74 ret = SR_OK;
bc02c2bf 75 switch (key) {{
a65d66c0
BV
76 /* TODO */
77 default:
87c5b243 78 return SR_ERR_NA;
bc02c2bf 79 }}
a65d66c0 80
87c5b243 81 return ret;
bc02c2bf 82}}
a65d66c0 83
df382df5
UH
84static int config_set(uint32_t key, GVariant *data,
85 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
bc02c2bf 86{{
a65d66c0
BV
87 int ret;
88
87c5b243 89 (void)data;
d73e0933 90 (void)cg;
87c5b243 91
a65d66c0 92 ret = SR_OK;
bc02c2bf 93 switch (key) {{
a65d66c0
BV
94 /* TODO */
95 default:
87c5b243 96 ret = SR_ERR_NA;
bc02c2bf 97 }}
a65d66c0
BV
98
99 return ret;
bc02c2bf 100}}
a65d66c0 101
df382df5
UH
102static int config_list(uint32_t key, GVariant **data,
103 const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
bc02c2bf 104{{
87c5b243
BV
105 int ret;
106
3aef82b3
UH
107 (void)sdi;
108 (void)data;
d73e0933 109 (void)cg;
3aef82b3 110
87c5b243 111 ret = SR_OK;
bc02c2bf 112 switch (key) {{
87c5b243 113 /* TODO */
3aef82b3 114 default:
87c5b243 115 return SR_ERR_NA;
bc02c2bf 116 }}
3aef82b3 117
87c5b243 118 return ret;
bc02c2bf 119}}
3aef82b3 120
f87108ec 121static int dev_acquisition_start(const struct sr_dev_inst *sdi)
bc02c2bf 122{{
87c5b243
BV
123 /* TODO: configure hardware, reset acquisition state, set up
124 * callbacks and send header packet. */
a65d66c0
BV
125
126 return SR_OK;
bc02c2bf 127}}
a65d66c0 128
f87108ec 129static int dev_acquisition_stop(struct sr_dev_inst *sdi)
bc02c2bf 130{{
87c5b243 131 /* TODO: stop acquisition. */
a65d66c0
BV
132
133 return SR_OK;
bc02c2bf 134}}
a65d66c0 135
bc02c2bf
DD
136SR_PRIV struct sr_dev_driver {lib}_driver_info = {{
137 .name = "{short}",
138 .longname = "{name}",
a65d66c0 139 .api_version = 1,
f87108ec
UH
140 .init = std_init,
141 .cleanup = std_cleanup,
87c5b243 142 .scan = scan,
f87108ec 143 .dev_list = std_dev_list,
87c5b243
BV
144 .dev_clear = dev_clear,
145 .config_get = config_get,
146 .config_set = config_set,
147 .config_list = config_list,
148 .dev_open = dev_open,
149 .dev_close = dev_close,
150 .dev_acquisition_start = dev_acquisition_start,
151 .dev_acquisition_stop = dev_acquisition_stop,
f03716cf 152 .context = NULL,
bc02c2bf 153}};
466005f1
DD
154
155SR_REGISTER_DEV_DRIVER({lib}_driver_info);