]> sigrok.org Git - libsigrok.git/blob - hardware/center-3xx/api.c
5f61f9bd6f9c976fdeff293673da8bf42c43140d
[libsigrok.git] / hardware / center-3xx / api.c
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright (C) 2013 Uwe Hermann <uwe@hermann-uwe.de>
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 2 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, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19  */
20
21 #include "protocol.h"
22
23 SR_PRIV struct sr_dev_driver center_3xx_driver_info;
24 static struct sr_dev_driver *di = &center_3xx_driver_info;
25
26 static int init(struct sr_context *sr_ctx)
27 {
28         return std_init(sr_ctx, di, LOG_PREFIX);
29 }
30
31 static 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         return devices;
43 }
44
45 static GSList *dev_list(void)
46 {
47         return ((struct drv_context *)(di->priv))->instances;
48 }
49
50 static int dev_clear(void)
51 {
52         return std_dev_clear(di, NULL);
53 }
54
55 static int dev_open(struct sr_dev_inst *sdi)
56 {
57         (void)sdi;
58
59         sdi->status = SR_ST_ACTIVE;
60
61         return SR_OK;
62 }
63
64 static int dev_close(struct sr_dev_inst *sdi)
65 {
66         (void)sdi;
67
68         sdi->status = SR_ST_INACTIVE;
69
70         return SR_OK;
71 }
72
73 static int cleanup(void)
74 {
75         return dev_clear();
76 }
77
78 static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi)
79 {
80         int ret;
81
82         (void)sdi;
83         (void)data;
84
85         ret = SR_OK;
86         switch (key) {
87         default:
88                 return SR_ERR_NA;
89         }
90
91         return ret;
92 }
93
94 static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi)
95 {
96         int ret;
97
98         (void)data;
99
100         if (sdi->status != SR_ST_ACTIVE)
101                 return SR_ERR_DEV_CLOSED;
102
103         ret = SR_OK;
104         switch (key) {
105         default:
106                 ret = SR_ERR_NA;
107         }
108
109         return ret;
110 }
111
112 static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi)
113 {
114         int ret;
115
116         (void)sdi;
117         (void)data;
118
119         ret = SR_OK;
120         switch (key) {
121         default:
122                 return SR_ERR_NA;
123         }
124
125         return ret;
126 }
127
128 static int dev_acquisition_start(const struct sr_dev_inst *sdi,
129                                  void *cb_data)
130 {
131         (void)sdi;
132         (void)cb_data;
133
134         if (sdi->status != SR_ST_ACTIVE)
135                 return SR_ERR_DEV_CLOSED;
136
137         return SR_OK;
138 }
139
140 static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
141 {
142         (void)cb_data;
143
144         if (sdi->status != SR_ST_ACTIVE)
145                 return SR_ERR_DEV_CLOSED;
146
147         return SR_OK;
148 }
149
150 SR_PRIV struct sr_dev_driver center_3xx_driver_info = {
151         .name = "center-3xx",
152         .longname = "Center 3xx",
153         .api_version = 1,
154         .init = init,
155         .cleanup = cleanup,
156         .scan = scan,
157         .dev_list = dev_list,
158         .dev_clear = dev_clear,
159         .config_get = config_get,
160         .config_set = config_set,
161         .config_list = config_list,
162         .dev_open = dev_open,
163         .dev_close = dev_close,
164         .dev_acquisition_start = dev_acquisition_start,
165         .dev_acquisition_stop = dev_acquisition_stop,
166         .priv = NULL,
167 };