]>
Commit | Line | Data |
---|---|---|
b5089195 JH |
1 | /* |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2014 Janne Huttunen <jahuttun@gmail.com> | |
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 <stdint.h> | |
21 | #include <string.h> | |
22 | #include <math.h> | |
23 | #include <glib.h> | |
c1aae900 | 24 | #include <libsigrok/libsigrok.h> |
b5089195 JH |
25 | #include "libsigrok-internal.h" |
26 | ||
27 | static void std_dev_attach(struct sr_dev_driver *di, struct sr_dev_inst *sdi) | |
28 | { | |
29 | struct drv_context *drvc; | |
30 | ||
41812aca | 31 | drvc = di->context; |
b5089195 JH |
32 | |
33 | sdi->driver = di; | |
34 | drvc->instances = g_slist_append(drvc->instances, sdi); | |
35 | } | |
36 | ||
4f840ce9 | 37 | static GSList *dev_list(const struct sr_dev_driver *di) |
b5089195 | 38 | { |
41812aca | 39 | return ((struct drv_context *)di->context)->instances; |
b5089195 JH |
40 | } |
41 | ||
42 | #define LOG_PREFIX "deree-de5000" | |
43 | ||
44 | SR_PRIV struct sr_dev_driver deree_de5000_driver_info; | |
45 | ||
4f840ce9 | 46 | static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) |
b5089195 | 47 | { |
4f840ce9 | 48 | return std_init(sr_ctx, di, LOG_PREFIX); |
b5089195 JH |
49 | } |
50 | ||
4f840ce9 | 51 | static int cleanup(const struct sr_dev_driver *di) |
b5089195 | 52 | { |
4f840ce9 | 53 | return std_dev_clear(di, es51919_serial_clean); |
b5089195 JH |
54 | } |
55 | ||
4f840ce9 | 56 | static GSList *scan(struct sr_dev_driver *di, GSList *options) |
b5089195 JH |
57 | { |
58 | struct sr_dev_inst *sdi; | |
59 | ||
60 | if (!(sdi = es51919_serial_scan(options, "DER EE", "DE-5000"))) | |
61 | return NULL; | |
62 | ||
4f840ce9 | 63 | std_dev_attach(di, sdi); |
b5089195 JH |
64 | |
65 | return g_slist_append(NULL, sdi); | |
66 | } | |
67 | ||
b5089195 JH |
68 | SR_PRIV struct sr_dev_driver deree_de5000_driver_info = { |
69 | .name = "deree-de5000", | |
70 | .longname = "DER EE DE-5000", | |
71 | .api_version = 1, | |
72 | .init = init, | |
73 | .cleanup = cleanup, | |
74 | .scan = scan, | |
75 | .dev_list = dev_list, | |
76 | .dev_clear = NULL, | |
77 | .config_get = es51919_serial_config_get, | |
78 | .config_set = es51919_serial_config_set, | |
79 | .config_list = es51919_serial_config_list, | |
80 | .dev_open = std_serial_dev_open, | |
81 | .dev_close = std_serial_dev_close, | |
82 | .dev_acquisition_start = es51919_serial_acquisition_start, | |
83 | .dev_acquisition_stop = es51919_serial_acquisition_stop, | |
41812aca | 84 | .context = NULL, |
b5089195 | 85 | }; |