]> sigrok.org Git - libsigrok.git/blame - hardware/saleae-logic16/api.c
configure.ac: Fix build when libusb-1.0 not available.
[libsigrok.git] / hardware / saleae-logic16 / api.c
CommitLineData
c463dcf0
MC
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2013 Marcus Comstedt <marcus@mc.pp.se>
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
20#include "protocol.h"
21
22SR_PRIV struct sr_dev_driver saleae_logic16_driver_info;
23static struct sr_dev_driver *di = &saleae_logic16_driver_info;
24
25
26static int init(struct sr_context *sr_ctx)
27{
28 return std_init(sr_ctx, di, LOG_PREFIX);
29}
30
31static GSList *scan(GSList *options)
32{
33 struct drv_context *drvc;
34 GSList *devices;
35
36 (void)options;
37
38 devices = NULL;
39 drvc = di->priv;
40 drvc->instances = NULL;
41
42 /* TODO: scan for devices, either based on a SR_CONF_CONN option
43 * or on a USB scan. */
44
45 return devices;
46}
47
48static GSList *dev_list(void)
49{
50 struct drv_context *drvc;
51
52 drvc = di->priv;
53
54 return drvc->instances;
55}
56
57static int dev_clear(void)
58{
59 return std_dev_clear(di, NULL);
60}
61
62static int dev_open(struct sr_dev_inst *sdi)
63{
64 (void)sdi;
65
66 /* TODO: get handle from sdi->conn and open it. */
67
68 sdi->status = SR_ST_ACTIVE;
69
70 return SR_OK;
71}
72
73static int dev_close(struct sr_dev_inst *sdi)
74{
75 (void)sdi;
76
77 /* TODO: get handle from sdi->conn and close it. */
78
79 sdi->status = SR_ST_INACTIVE;
80
81 return SR_OK;
82}
83
84static int cleanup(void)
85{
86 dev_clear();
87
88 /* TODO: free other driver resources, if any. */
89
90 return SR_OK;
91}
92
93static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi)
94{
95 int ret;
96
97 (void)sdi;
98 (void)data;
99
100 ret = SR_OK;
101 switch (key) {
102 /* TODO */
103 default:
104 return SR_ERR_NA;
105 }
106
107 return ret;
108}
109
110static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi)
111{
112 int ret;
113
114 (void)data;
115
116 if (sdi->status != SR_ST_ACTIVE)
117 return SR_ERR_DEV_CLOSED;
118
119 ret = SR_OK;
120 switch (key) {
121 /* TODO */
122 default:
123 ret = SR_ERR_NA;
124 }
125
126 return ret;
127}
128
129static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
130{
131 int ret;
132
133 (void)sdi;
134 (void)data;
135
136 ret = SR_OK;
137 switch (key) {
138 /* TODO */
139 default:
140 return SR_ERR_NA;
141 }
142
143 return ret;
144}
145
146static int dev_acquisition_start(const struct sr_dev_inst *sdi,
147 void *cb_data)
148{
149 (void)sdi;
150 (void)cb_data;
151
152 if (sdi->status != SR_ST_ACTIVE)
153 return SR_ERR_DEV_CLOSED;
154
155 /* TODO: configure hardware, reset acquisition state, set up
156 * callbacks and send header packet. */
157
158 return SR_OK;
159}
160
161static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
162{
163 (void)cb_data;
164
165 if (sdi->status != SR_ST_ACTIVE)
166 return SR_ERR_DEV_CLOSED;
167
168 /* TODO: stop acquisition. */
169
170 return SR_OK;
171}
172
173SR_PRIV struct sr_dev_driver saleae_logic16_driver_info = {
174 .name = "saleae-logic16",
175 .longname = "Saleae Logic16",
176 .api_version = 1,
177 .init = init,
178 .cleanup = cleanup,
179 .scan = scan,
180 .dev_list = dev_list,
181 .dev_clear = dev_clear,
182 .config_get = config_get,
183 .config_set = config_set,
184 .config_list = config_list,
185 .dev_open = dev_open,
186 .dev_close = dev_close,
187 .dev_acquisition_start = dev_acquisition_start,
188 .dev_acquisition_stop = dev_acquisition_stop,
189 .priv = NULL,
190};