2 * This file is part of the libsigrok project.
4 * Copyright (C) 2013 Marcus Comstedt <marcus@mc.pp.se>
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.
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.
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/>.
22 SR_PRIV struct sr_dev_driver saleae_logic16_driver_info;
23 static struct sr_dev_driver *di = &saleae_logic16_driver_info;
26 static int init(struct sr_context *sr_ctx)
28 return std_init(sr_ctx, di, LOG_PREFIX);
31 static GSList *scan(GSList *options)
33 struct drv_context *drvc;
40 drvc->instances = NULL;
42 /* TODO: scan for devices, either based on a SR_CONF_CONN option
43 * or on a USB scan. */
48 static GSList *dev_list(void)
50 struct drv_context *drvc;
54 return drvc->instances;
57 static int dev_clear(void)
59 return std_dev_clear(di, NULL);
62 static int dev_open(struct sr_dev_inst *sdi)
66 /* TODO: get handle from sdi->conn and open it. */
68 sdi->status = SR_ST_ACTIVE;
73 static int dev_close(struct sr_dev_inst *sdi)
77 /* TODO: get handle from sdi->conn and close it. */
79 sdi->status = SR_ST_INACTIVE;
84 static int cleanup(void)
88 /* TODO: free other driver resources, if any. */
93 static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi)
110 static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi)
116 if (sdi->status != SR_ST_ACTIVE)
117 return SR_ERR_DEV_CLOSED;
129 static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
146 static int dev_acquisition_start(const struct sr_dev_inst *sdi,
152 if (sdi->status != SR_ST_ACTIVE)
153 return SR_ERR_DEV_CLOSED;
155 /* TODO: configure hardware, reset acquisition state, set up
156 * callbacks and send header packet. */
161 static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
165 if (sdi->status != SR_ST_ACTIVE)
166 return SR_ERR_DEV_CLOSED;
168 /* TODO: stop acquisition. */
173 SR_PRIV struct sr_dev_driver saleae_logic16_driver_info = {
174 .name = "saleae-logic16",
175 .longname = "Saleae Logic16",
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,