2 * This file is part of the sigrok project.
4 * Copyright (C) 2011 Bert Vermeulen <bert@biot.com>
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/>.
20 #ifndef SIGROK_SIGROK_PROTO_H
21 #define SIGROK_SIGROK_PROTO_H
23 /*--- backend.c -------------------------------------------------------------*/
28 /*--- datastore.c -----------------------------------------------------------*/
30 int sr_datastore_new(int unitsize, struct sr_datastore **ds);
31 int sr_datastore_destroy(struct sr_datastore *ds);
32 void sr_datastore_put(struct sr_datastore *ds, void *data, unsigned int length,
33 int in_unitsize, int *probelist);
35 /*--- device.c --------------------------------------------------------------*/
37 void sr_device_scan(void);
38 int sr_device_plugin_init(struct sr_device_plugin *plugin);
39 void sr_device_close_all(void);
40 GSList *sr_device_list(void);
41 struct sr_device *sr_device_new(struct sr_device_plugin *plugin,
42 int plugin_index, int num_probes);
43 void sr_device_clear(struct sr_device *device);
44 void sr_device_destroy(struct sr_device *dev);
46 void sr_device_probe_clear(struct sr_device *device, int probenum);
47 void sr_device_probe_add(struct sr_device *device, char *name);
48 struct sr_probe *sr_device_probe_find(struct sr_device *device, int probenum);
49 void sr_device_probe_name(struct sr_device *device, int probenum, char *name);
51 void sr_device_trigger_clear(struct sr_device *device);
52 void sr_device_trigger_set(struct sr_device *device, int probenum,
54 gboolean sr_device_has_hwcap(struct sr_device *device, int hwcap);
56 /*--- filter.c --------------------------------------------------------------*/
58 int filter_probes(int in_unitsize, int out_unitsize, int *probelist,
59 char *data_in, uint64_t length_in, char **data_out,
60 uint64_t *length_out);
62 /*--- hwplugin.c ------------------------------------------------------------*/
64 GSList *sr_list_hwplugins(void);
66 /* Generic device instances */
67 struct sr_device_instance *sr_device_instance_new(int index,
68 int status, const char *vendor, const char *model, const char *version);
69 struct sr_device_instance *sr_get_device_instance(GSList *device_instances,
71 void sr_device_instance_free(struct sr_device_instance *sdi);
73 /* USB-specific instances */
74 #ifdef HAVE_LIBUSB_1_0
75 struct sr_usb_device_instance *sr_usb_device_instance_new(uint8_t bus,
76 uint8_t address, struct libusb_device_handle *hdl);
77 void sr_usb_device_instance_free(struct sr_usb_device_instance *usb);
80 /* Serial-specific instances */
81 struct sr_serial_device_instance *sr_serial_device_instance_new(
82 const char *port, int fd);
83 void sr_serial_device_instance_free(struct sr_serial_device_instance *serial);
85 int sr_find_hwcap(int *capabilities, int hwcap);
86 struct sr_hwcap_option *sr_find_hwcap_option(int hwcap);
87 void sr_source_remove(int fd);
88 void sr_source_add(int fd, int events, int timeout,
89 receive_data_callback rcv_cb, void *user_data);
91 /*--- session.c -------------------------------------------------------------*/
93 typedef void (*source_callback_remove) (int fd);
94 typedef void (*source_callback_add) (int fd, int events, int timeout,
95 receive_data_callback callback, void *user_data);
96 typedef void (*datafeed_callback) (struct sr_device *device,
97 struct sr_datafeed_packet *packet);
100 int sr_session_load(const char *filename);
101 struct sr_session *sr_session_new(void);
102 void sr_session_destroy(void);
103 void sr_session_device_clear(void);
104 int sr_session_device_add(struct sr_device *device);
106 /* Protocol analyzers setup */
107 void sr_session_pa_clear(void);
108 void sr_session_pa_add(struct analyzer *pa);
111 void sr_session_datafeed_callback_clear(void);
112 void sr_session_datafeed_callback_add(datafeed_callback callback);
114 /* Session control */
115 int sr_session_start(void);
116 void sr_session_run(void);
117 void sr_session_halt(void);
118 void sr_session_stop(void);
119 void sr_session_bus(struct sr_device *device,
120 struct sr_datafeed_packet *packet);
121 int sr_session_save(char *filename);
122 void sr_session_source_add(int fd, int events, int timeout,
123 receive_data_callback callback, void *user_data);
124 void sr_session_source_remove(int fd);
126 /*--- input/input.c ---------------------------------------------------------*/
128 struct sr_input_format **sr_input_list(void);
130 /*--- output/output.c -------------------------------------------------------*/
132 struct sr_output_format **sr_output_list(void);
134 /*--- output/common.c -------------------------------------------------------*/
136 char *sr_samplerate_string(uint64_t samplerate);
137 char *sr_period_string(uint64_t frequency);
138 char **sr_parse_triggerstring(struct sr_device *device,
139 const char *triggerstring);
140 uint64_t sr_parse_sizestring(const char *sizestring);
141 uint64_t sr_parse_timestring(const char *timestring);