]> sigrok.org Git - libsigrok.git/blob - src/hardware/greatfet/protocol.h
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / hardware / greatfet / protocol.h
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright (C) 2019 Katherine J. Temkin <k@ktemkin.com>
5  * Copyright (C) 2019 Mikaela Szekely <qyriad@gmail.com>
6  * Copyright (C) 2023 Gerhard Sittig <gerhard.sittig@gmx.net>
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22 #ifndef LIBSIGROK_HARDWARE_GREATFET_PROTOCOL_H
23 #define LIBSIGROK_HARDWARE_GREATFET_PROTOCOL_H
24
25 #include <glib.h>
26 #include <libsigrok/libsigrok.h>
27 #include <stdint.h>
28
29 #include "libsigrok-internal.h"
30
31 #define LOG_PREFIX "greatfet"
32
33 struct dev_context {
34         struct sr_dev_inst *sdi;
35         GString *usb_comm_buffer;
36         char *firmware_version;
37         char *serial_number;
38         size_t channel_count;
39         char **channel_names;
40         size_t feed_unit_size;
41         struct sr_sw_limits sw_limits;
42         uint64_t samplerate;
43         struct dev_acquisition_t {
44                 uint64_t bandwidth_threshold;
45                 size_t wire_unit_size;
46                 struct feed_queue_logic *feed_queue;
47                 size_t capture_channels;
48                 gboolean use_upper_pins;
49                 size_t channel_shift;
50                 size_t points_per_byte;
51                 uint64_t capture_samplerate;
52                 size_t firmware_bufsize;
53                 uint8_t samples_endpoint;
54                 uint8_t control_interface;
55                 uint8_t samples_interface;
56                 enum {
57                         ACQ_IDLE,
58                         ACQ_PREPARE,
59                         ACQ_RECEIVE,
60                         ACQ_SHUTDOWN,
61                 } acquisition_state;
62                 gboolean frame_begin_sent;
63                 gboolean control_interface_claimed;
64                 gboolean samples_interface_claimed;
65                 gboolean start_req_sent;
66         } acquisition;
67         struct dev_transfers_t {
68                 size_t transfer_bufsize;
69                 size_t transfers_count;
70                 uint8_t *transfer_buffer;
71                 struct libusb_transfer **transfers;
72                 size_t active_transfers;
73                 size_t capture_bufsize;
74         } transfers;
75 };
76
77 SR_PRIV int greatfet_get_serial_number(const struct sr_dev_inst *sdi);
78 SR_PRIV int greatfet_get_version_number(const struct sr_dev_inst *sdi);
79
80 SR_PRIV int greatfet_setup_acquisition(const struct sr_dev_inst *sdi);
81 SR_PRIV int greatfet_start_acquisition(const struct sr_dev_inst *sdi);
82 SR_PRIV void greatfet_abort_acquisition(const struct sr_dev_inst *sdi);
83 SR_PRIV int greatfet_stop_acquisition(const struct sr_dev_inst *sdi);
84 SR_PRIV void greatfet_release_resources(const struct sr_dev_inst *sdi);
85
86 SR_PRIV int greatfet_receive_data(int fd, int revents, void *cb_data);
87
88 #endif