]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2015 Daniel Glöckner <daniel-gl@gmx.net> | |
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 <config.h> | |
21 | #include <ieee1284.h> | |
22 | #include <string.h> | |
23 | #include "protocol.h" | |
24 | ||
25 | static const uint32_t scanopts[] = { | |
26 | SR_CONF_CONN, | |
27 | }; | |
28 | ||
29 | static const uint32_t drvopts[] = { | |
30 | SR_CONF_OSCILLOSCOPE, | |
31 | }; | |
32 | ||
33 | static const uint32_t devopts[] = { | |
34 | SR_CONF_CONN | SR_CONF_GET, | |
35 | SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET, | |
36 | SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, | |
37 | SR_CONF_TRIGGER_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, | |
38 | SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, | |
39 | SR_CONF_BUFFERSIZE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, | |
40 | }; | |
41 | ||
42 | static const uint32_t devopts_cg[] = { | |
43 | SR_CONF_VDIV | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, | |
44 | SR_CONF_COUPLING | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, | |
45 | SR_CONF_PROBE_FACTOR | SR_CONF_GET | SR_CONF_SET, | |
46 | }; | |
47 | ||
48 | static const uint64_t samplerates[] = { | |
49 | SR_MHZ(100), SR_MHZ(50), SR_MHZ(25), SR_MHZ(20), | |
50 | SR_MHZ(10), SR_MHZ(5), SR_KHZ(2500), SR_MHZ(2), | |
51 | SR_MHZ(1), SR_KHZ(500), SR_KHZ(250), SR_KHZ(200), | |
52 | SR_KHZ(100), SR_KHZ(50), SR_KHZ(25), SR_KHZ(20), | |
53 | SR_KHZ(10), SR_KHZ(5), SR_HZ(2500), SR_KHZ(2), | |
54 | SR_KHZ(1), SR_HZ(500), SR_HZ(250), SR_HZ(200), | |
55 | SR_HZ(100), SR_HZ(50), SR_HZ(25), SR_HZ(20) | |
56 | }; | |
57 | ||
58 | /* must be in sync with readout_steps[] in protocol.c */ | |
59 | static const uint64_t buffersizes[] = { | |
60 | 2 * 500, 3 * 500, 4 * 500, 5 * 500, | |
61 | 6 * 500, 7 * 500, 8 * 500, 9 * 500, 10 * 500, | |
62 | 12 * 500 - 2, 14 * 500 - 2, 16 * 500 - 2, | |
63 | 18 * 500 - 2, 20 * 500 - 2, 10240 - 2 | |
64 | }; | |
65 | ||
66 | static const uint64_t vdivs[][2] = { | |
67 | { 10, 1000 }, | |
68 | { 20, 1000 }, | |
69 | { 50, 1000 }, | |
70 | { 100, 1000 }, | |
71 | { 200, 1000 }, | |
72 | { 500, 1000 }, | |
73 | { 1, 1 }, | |
74 | { 2, 1 }, | |
75 | { 5, 1 }, | |
76 | }; | |
77 | ||
78 | /* Bits 4 and 5 enable relays that add /10 filters to the chain | |
79 | * Bits 0 and 1 select an output from a resistor array */ | |
80 | static const uint8_t vdivs_map[] = { | |
81 | 0x01, 0x02, 0x03, 0x21, 0x22, 0x23, 0x31, 0x32, 0x33 | |
82 | }; | |
83 | ||
84 | ||
85 | static const char *trigger_sources[] = { | |
86 | "A", "B", "EXT" | |
87 | }; | |
88 | ||
89 | static const uint8_t trigger_sources_map[] = { | |
90 | 0x00, 0x80, 0x40 | |
91 | }; | |
92 | ||
93 | static const char *trigger_slopes[] = { | |
94 | "f", "r" | |
95 | }; | |
96 | ||
97 | static const char *coupling[] = { | |
98 | "DC", "AC", "GND" | |
99 | }; | |
100 | ||
101 | static const uint8_t coupling_map[] = { | |
102 | 0x00, 0x08, 0x04 | |
103 | }; | |
104 | ||
105 | static GSList *scan_port(GSList *devices, struct parport *port) | |
106 | { | |
107 | struct sr_dev_inst *sdi; | |
108 | struct sr_channel *ch; | |
109 | struct sr_channel_group *cg; | |
110 | struct dev_context *devc; | |
111 | int i; | |
112 | ||
113 | if (ieee1284_open(port, 0, &i) != E1284_OK) { | |
114 | sr_err("Can't open parallel port %s", port->name); | |
115 | goto fail1; | |
116 | } | |
117 | ||
118 | if ((i & (CAP1284_RAW | CAP1284_BYTE)) != (CAP1284_RAW | CAP1284_BYTE)) { | |
119 | sr_err("Parallel port %s does not provide low-level bidirection access", | |
120 | port->name); | |
121 | goto fail2; | |
122 | } | |
123 | ||
124 | if (ieee1284_claim(port) != E1284_OK) { | |
125 | sr_err("Parallel port %s already in use", port->name); | |
126 | goto fail2; | |
127 | } | |
128 | ||
129 | if (!hung_chang_dso_2100_check_id(port)) | |
130 | goto fail3; | |
131 | ||
132 | sdi = g_malloc0(sizeof(struct sr_dev_inst)); | |
133 | sdi->status = SR_ST_INACTIVE; | |
134 | sdi->vendor = g_strdup("Hung-Chang"); | |
135 | sdi->model = g_strdup("DSO-2100"); | |
136 | sdi->inst_type = 0; /* FIXME */ | |
137 | sdi->conn = port; | |
138 | ieee1284_ref(port); | |
139 | ||
140 | for (i = 0; i < NUM_CHANNELS; i++) { | |
141 | cg = sr_channel_group_new(sdi, trigger_sources[i], NULL); | |
142 | ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, FALSE, trigger_sources[i]); | |
143 | cg->channels = g_slist_append(cg->channels, ch); | |
144 | } | |
145 | ||
146 | devc = g_malloc0(sizeof(struct dev_context)); | |
147 | devc->enabled_channel = g_slist_append(NULL, NULL); | |
148 | devc->channel = 0; | |
149 | devc->rate = 0; | |
150 | devc->probe[0] = 10; | |
151 | devc->probe[1] = 10; | |
152 | devc->cctl[0] = 0x31; /* 1V/div, DC coupling, trigger on channel A*/ | |
153 | devc->cctl[1] = 0x31; /* 1V/div, DC coupling, no tv sync trigger */ | |
154 | devc->edge = 0; | |
155 | devc->tlevel = 0x80; | |
156 | devc->pos[0] = 0x80; | |
157 | devc->pos[1] = 0x80; | |
158 | devc->offset[0] = 0x80; | |
159 | devc->offset[1] = 0x80; | |
160 | devc->gain[0] = 0x80; | |
161 | devc->gain[1] = 0x80; | |
162 | devc->frame_limit = 0; | |
163 | devc->last_step = 0; /* buffersize = 1000 */ | |
164 | sdi->priv = devc; | |
165 | ||
166 | devices = g_slist_append(devices, sdi); | |
167 | ||
168 | fail3: | |
169 | ieee1284_release(port); | |
170 | fail2: | |
171 | ieee1284_close(port); | |
172 | fail1: | |
173 | return devices; | |
174 | } | |
175 | ||
176 | static GSList *scan(struct sr_dev_driver *di, GSList *options) | |
177 | { | |
178 | struct parport_list ports; | |
179 | struct sr_config *src; | |
180 | const char *conn = NULL; | |
181 | GSList *devices, *option; | |
182 | gboolean port_found; | |
183 | int i; | |
184 | ||
185 | ||
186 | for (option = options; option; option = option->next) { | |
187 | src = option->data; | |
188 | if (src->key == SR_CONF_CONN) { | |
189 | conn = g_variant_get_string(src->data, NULL); | |
190 | break; | |
191 | } | |
192 | } | |
193 | ||
194 | if (!conn) | |
195 | return NULL; | |
196 | ||
197 | if (ieee1284_find_ports(&ports, 0) != E1284_OK) | |
198 | return NULL; | |
199 | ||
200 | devices = NULL; | |
201 | port_found = FALSE; | |
202 | for (i = 0; i < ports.portc; i++) | |
203 | if (!strcmp(ports.portv[i]->name, conn)) { | |
204 | port_found = TRUE; | |
205 | devices = scan_port(devices, ports.portv[i]); | |
206 | } | |
207 | ||
208 | if (!port_found) { | |
209 | sr_err("Parallel port %s not found. Valid names are:", conn); | |
210 | for (i = 0; i < ports.portc; i++) | |
211 | sr_err("\t%s", ports.portv[i]->name); | |
212 | } | |
213 | ||
214 | ieee1284_free_ports(&ports); | |
215 | ||
216 | return std_scan_complete(di, devices); | |
217 | } | |
218 | ||
219 | static void clear_helper(struct dev_context *devc) | |
220 | { | |
221 | g_slist_free(devc->enabled_channel); | |
222 | } | |
223 | ||
224 | static int dev_clear(const struct sr_dev_driver *di) | |
225 | { | |
226 | struct drv_context *drvc = di->context; | |
227 | struct sr_dev_inst *sdi; | |
228 | GSList *l; | |
229 | ||
230 | if (drvc) { | |
231 | for (l = drvc->instances; l; l = l->next) { | |
232 | sdi = l->data; | |
233 | ieee1284_unref(sdi->conn); | |
234 | } | |
235 | } | |
236 | ||
237 | return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); | |
238 | } | |
239 | ||
240 | static int dev_open(struct sr_dev_inst *sdi) | |
241 | { | |
242 | struct dev_context *devc = sdi->priv; | |
243 | int i; | |
244 | ||
245 | if (ieee1284_open(sdi->conn, 0, &i) != E1284_OK) | |
246 | goto fail1; | |
247 | ||
248 | if (ieee1284_claim(sdi->conn) != E1284_OK) | |
249 | goto fail2; | |
250 | ||
251 | if (ieee1284_data_dir(sdi->conn, 1) != E1284_OK) | |
252 | goto fail3; | |
253 | ||
254 | if (hung_chang_dso_2100_move_to(sdi, 1)) | |
255 | goto fail3; | |
256 | ||
257 | devc->samples = g_try_malloc(1000 * sizeof(*devc->samples)); | |
258 | if (!devc->samples) | |
259 | goto fail3; | |
260 | ||
261 | return SR_OK; | |
262 | ||
263 | fail3: | |
264 | hung_chang_dso_2100_reset_port(sdi->conn); | |
265 | ieee1284_release(sdi->conn); | |
266 | fail2: | |
267 | ieee1284_close(sdi->conn); | |
268 | fail1: | |
269 | return SR_ERR; | |
270 | } | |
271 | ||
272 | static int dev_close(struct sr_dev_inst *sdi) | |
273 | { | |
274 | struct dev_context *devc = sdi->priv; | |
275 | ||
276 | g_free(devc->samples); | |
277 | hung_chang_dso_2100_reset_port(sdi->conn); | |
278 | ieee1284_release(sdi->conn); | |
279 | ieee1284_close(sdi->conn); | |
280 | ||
281 | return SR_OK; | |
282 | } | |
283 | ||
284 | static int config_get(uint32_t key, GVariant **data, | |
285 | const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) | |
286 | { | |
287 | struct dev_context *devc = sdi->priv; | |
288 | struct parport *port; | |
289 | int idx, ch = -1; | |
290 | ||
291 | if (cg) /* sr_config_get will validate cg using config_list */ | |
292 | ch = ((struct sr_channel *)cg->channels->data)->index; | |
293 | ||
294 | switch (key) { | |
295 | case SR_CONF_CONN: | |
296 | port = sdi->conn; | |
297 | *data = g_variant_new_string(port->name); | |
298 | break; | |
299 | case SR_CONF_LIMIT_FRAMES: | |
300 | *data = g_variant_new_uint64(devc->frame_limit); | |
301 | break; | |
302 | case SR_CONF_SAMPLERATE: | |
303 | *data = g_variant_new_uint64(samplerates[devc->rate]); | |
304 | break; | |
305 | case SR_CONF_TRIGGER_SOURCE: | |
306 | if ((idx = std_u8_idx_s(devc->cctl[0] & 0xC0, ARRAY_AND_SIZE(trigger_sources_map))) < 0) | |
307 | return SR_ERR_BUG; | |
308 | *data = g_variant_new_string(trigger_sources[idx]); | |
309 | break; | |
310 | case SR_CONF_TRIGGER_SLOPE: | |
311 | if (devc->edge >= ARRAY_SIZE(trigger_slopes)) | |
312 | return SR_ERR; | |
313 | *data = g_variant_new_string(trigger_slopes[devc->edge]); | |
314 | break; | |
315 | case SR_CONF_BUFFERSIZE: | |
316 | *data = g_variant_new_uint64(buffersizes[devc->last_step]); | |
317 | break; | |
318 | case SR_CONF_VDIV: | |
319 | if (!cg) | |
320 | return SR_ERR_CHANNEL_GROUP; | |
321 | if ((idx = std_u8_idx_s(devc->cctl[ch] & 0x33, ARRAY_AND_SIZE(vdivs_map))) < 0) | |
322 | return SR_ERR_BUG; | |
323 | *data = g_variant_new("(tt)", vdivs[idx][0], vdivs[idx][1]); | |
324 | break; | |
325 | case SR_CONF_COUPLING: | |
326 | if (!cg) | |
327 | return SR_ERR_CHANNEL_GROUP; | |
328 | if ((idx = std_u8_idx_s(devc->cctl[ch] & 0x0C, ARRAY_AND_SIZE(coupling_map))) < 0) | |
329 | return SR_ERR_BUG; | |
330 | *data = g_variant_new_string(coupling[idx]); | |
331 | break; | |
332 | case SR_CONF_PROBE_FACTOR: | |
333 | if (!cg) | |
334 | return SR_ERR_CHANNEL_GROUP; | |
335 | *data = g_variant_new_uint64(devc->probe[ch]); | |
336 | break; | |
337 | default: | |
338 | return SR_ERR_NA; | |
339 | } | |
340 | ||
341 | return SR_OK; | |
342 | } | |
343 | ||
344 | static int config_set(uint32_t key, GVariant *data, | |
345 | const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) | |
346 | { | |
347 | struct dev_context *devc = sdi->priv; | |
348 | int idx, ch = -1; | |
349 | uint64_t u; | |
350 | ||
351 | if (cg) /* sr_config_set will validate cg using config_list */ | |
352 | ch = ((struct sr_channel *)cg->channels->data)->index; | |
353 | ||
354 | switch (key) { | |
355 | case SR_CONF_LIMIT_FRAMES: | |
356 | devc->frame_limit = g_variant_get_uint64(data); | |
357 | break; | |
358 | case SR_CONF_SAMPLERATE: | |
359 | if ((idx = std_u64_idx(data, ARRAY_AND_SIZE(samplerates))) < 0) | |
360 | return SR_ERR_ARG; | |
361 | devc->rate = idx; | |
362 | break; | |
363 | case SR_CONF_TRIGGER_SOURCE: | |
364 | if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_sources))) < 0) | |
365 | return SR_ERR_ARG; | |
366 | devc->cctl[0] = (devc->cctl[0] & 0x3F) | trigger_sources_map[idx]; | |
367 | break; | |
368 | case SR_CONF_TRIGGER_SLOPE: | |
369 | if ((idx = std_str_idx(data, ARRAY_AND_SIZE(trigger_slopes))) < 0) | |
370 | return SR_ERR_ARG; | |
371 | devc->edge = idx; | |
372 | break; | |
373 | case SR_CONF_BUFFERSIZE: | |
374 | if ((idx = std_u64_idx(data, ARRAY_AND_SIZE(buffersizes))) < 0) | |
375 | return SR_ERR_ARG; | |
376 | devc->last_step = idx; | |
377 | break; | |
378 | case SR_CONF_VDIV: | |
379 | if (!cg) | |
380 | return SR_ERR_CHANNEL_GROUP; | |
381 | if (!g_variant_is_of_type(data, G_VARIANT_TYPE("(tt)"))) | |
382 | return SR_ERR_ARG; | |
383 | if ((idx = std_u64_tuple_idx(data, ARRAY_AND_SIZE(vdivs))) < 0) | |
384 | return SR_ERR_ARG; | |
385 | devc->cctl[ch] = (devc->cctl[ch] & 0xCC) | vdivs_map[idx]; | |
386 | break; | |
387 | case SR_CONF_COUPLING: | |
388 | if (!cg) | |
389 | return SR_ERR_CHANNEL_GROUP; | |
390 | if ((idx = std_str_idx(data, ARRAY_AND_SIZE(coupling))) < 0) | |
391 | return SR_ERR_ARG; | |
392 | devc->cctl[ch] = (devc->cctl[ch] & 0xF3) | coupling_map[idx]; | |
393 | break; | |
394 | case SR_CONF_PROBE_FACTOR: | |
395 | if (!cg) | |
396 | return SR_ERR_CHANNEL_GROUP; | |
397 | u = g_variant_get_uint64(data); | |
398 | if (!u) | |
399 | return SR_ERR_ARG; | |
400 | devc->probe[ch] = u; | |
401 | break; | |
402 | default: | |
403 | return SR_ERR_NA; | |
404 | } | |
405 | ||
406 | return SR_OK; | |
407 | } | |
408 | ||
409 | static int config_channel_set(const struct sr_dev_inst *sdi, | |
410 | struct sr_channel *ch, unsigned int changes) | |
411 | { | |
412 | struct dev_context *devc = sdi->priv; | |
413 | uint8_t v; | |
414 | ||
415 | if (!(changes & SR_CHANNEL_SET_ENABLED)) | |
416 | return SR_OK; | |
417 | ||
418 | if (ch->enabled) { | |
419 | v = devc->channel | (1 << ch->index); | |
420 | if (v & (v - 1)) | |
421 | return SR_ERR; | |
422 | devc->channel = v; | |
423 | devc->enabled_channel->data = ch; | |
424 | } else { | |
425 | devc->channel &= ~(1 << ch->index); | |
426 | } | |
427 | ||
428 | return SR_OK; | |
429 | } | |
430 | ||
431 | static int config_commit(const struct sr_dev_inst *sdi) | |
432 | { | |
433 | uint8_t state = hung_chang_dso_2100_read_mbox(sdi->conn, 0.02); | |
434 | int ret; | |
435 | ||
436 | switch (state) { | |
437 | case 0x03: | |
438 | case 0x14: | |
439 | case 0x21: | |
440 | /* we will travel the complete config path on our way to state 1 */ | |
441 | break; | |
442 | case 0x00: | |
443 | state = 0x01; | |
444 | /* Fallthrough */ | |
445 | default: | |
446 | ret = hung_chang_dso_2100_move_to(sdi, 1); | |
447 | if (ret != SR_OK) | |
448 | return ret; | |
449 | /* Fallthrough */ | |
450 | case 0x01: | |
451 | hung_chang_dso_2100_write_mbox(sdi->conn, 4); | |
452 | } | |
453 | ret = hung_chang_dso_2100_move_to(sdi, 1); | |
454 | if (ret != SR_OK) | |
455 | return ret; | |
456 | return hung_chang_dso_2100_move_to(sdi, state); | |
457 | } | |
458 | ||
459 | static int config_list(uint32_t key, GVariant **data, | |
460 | const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) | |
461 | { | |
462 | GSList *l; | |
463 | ||
464 | switch (key) { | |
465 | case SR_CONF_SCAN_OPTIONS: | |
466 | case SR_CONF_DEVICE_OPTIONS: | |
467 | break; | |
468 | case SR_CONF_SAMPLERATE: | |
469 | case SR_CONF_TRIGGER_SOURCE: | |
470 | case SR_CONF_TRIGGER_SLOPE: | |
471 | case SR_CONF_BUFFERSIZE: | |
472 | if (!sdi || cg) | |
473 | return SR_ERR_NA; | |
474 | break; | |
475 | case SR_CONF_VDIV: | |
476 | case SR_CONF_COUPLING: | |
477 | if (!sdi) | |
478 | return SR_ERR_NA; | |
479 | if (!cg) | |
480 | return SR_ERR_CHANNEL_GROUP; | |
481 | l = g_slist_find(sdi->channel_groups, cg); | |
482 | if (!l) | |
483 | return SR_ERR_ARG; | |
484 | break; | |
485 | default: | |
486 | return SR_ERR_NA; | |
487 | } | |
488 | ||
489 | switch (key) { | |
490 | case SR_CONF_SCAN_OPTIONS: | |
491 | return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, NO_OPTS, NO_OPTS); | |
492 | case SR_CONF_DEVICE_OPTIONS: | |
493 | if (!cg) | |
494 | return STD_CONFIG_LIST(key, data, sdi, cg, NO_OPTS, drvopts, devopts); | |
495 | *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg)); | |
496 | break; | |
497 | case SR_CONF_SAMPLERATE: | |
498 | *data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates)); | |
499 | break; | |
500 | case SR_CONF_TRIGGER_SOURCE: | |
501 | *data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_sources)); | |
502 | break; | |
503 | case SR_CONF_TRIGGER_SLOPE: | |
504 | *data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_slopes)); | |
505 | break; | |
506 | case SR_CONF_BUFFERSIZE: | |
507 | *data = std_gvar_array_u64(ARRAY_AND_SIZE(buffersizes)); | |
508 | break; | |
509 | case SR_CONF_VDIV: | |
510 | *data = std_gvar_tuple_array(ARRAY_AND_SIZE(vdivs)); | |
511 | break; | |
512 | case SR_CONF_COUPLING: | |
513 | *data = g_variant_new_strv(ARRAY_AND_SIZE(coupling)); | |
514 | break; | |
515 | } | |
516 | ||
517 | return SR_OK; | |
518 | } | |
519 | ||
520 | static int dev_acquisition_start(const struct sr_dev_inst *sdi) | |
521 | { | |
522 | struct dev_context *devc = sdi->priv; | |
523 | int ret; | |
524 | ||
525 | if (devc->channel) { | |
526 | static const float res_array[] = {0.5, 1, 2, 5}; | |
527 | static const uint8_t relays[] = {100, 10, 10, 1}; | |
528 | devc->factor = devc->probe[devc->channel - 1] / 32.0; | |
529 | devc->factor *= res_array[devc->cctl[devc->channel - 1] & 0x03]; | |
530 | devc->factor /= relays[(devc->cctl[devc->channel - 1] >> 4) & 0x03]; | |
531 | } | |
532 | devc->frame = 0; | |
533 | devc->state_known = TRUE; | |
534 | devc->step = 0; | |
535 | devc->adc2 = FALSE; | |
536 | devc->retries = MAX_RETRIES; | |
537 | ||
538 | ret = hung_chang_dso_2100_move_to(sdi, 0x21); | |
539 | if (ret != SR_OK) | |
540 | return ret; | |
541 | ||
542 | std_session_send_df_header(sdi); | |
543 | ||
544 | sr_session_source_add(sdi->session, -1, 0, 8, | |
545 | hung_chang_dso_2100_poll, (void *)sdi); | |
546 | ||
547 | return SR_OK; | |
548 | } | |
549 | ||
550 | static int dev_acquisition_stop(struct sr_dev_inst *sdi) | |
551 | { | |
552 | std_session_send_df_end(sdi); | |
553 | sr_session_source_remove(sdi->session, -1); | |
554 | hung_chang_dso_2100_move_to(sdi, 1); | |
555 | ||
556 | return SR_OK; | |
557 | } | |
558 | ||
559 | static struct sr_dev_driver hung_chang_dso_2100_driver_info = { | |
560 | .name = "hung-chang-dso-2100", | |
561 | .longname = "Hung-Chang DSO-2100", | |
562 | .api_version = 1, | |
563 | .init = std_init, | |
564 | .cleanup = std_cleanup, | |
565 | .scan = scan, | |
566 | .dev_list = std_dev_list, | |
567 | .dev_clear = dev_clear, | |
568 | .config_get = config_get, | |
569 | .config_set = config_set, | |
570 | .config_channel_set = config_channel_set, | |
571 | .config_commit = config_commit, | |
572 | .config_list = config_list, | |
573 | .dev_open = dev_open, | |
574 | .dev_close = dev_close, | |
575 | .dev_acquisition_start = dev_acquisition_start, | |
576 | .dev_acquisition_stop = dev_acquisition_stop, | |
577 | .context = NULL, | |
578 | }; | |
579 | SR_REGISTER_DEV_DRIVER(hung_chang_dso_2100_driver_info); |