]> sigrok.org Git - libsigrok.git/blob - src/hardware/chromium-twinkie/protocol.h
CHROMIUM: Add driver for Chromium Twinkie dongle
[libsigrok.git] / src / hardware / chromium-twinkie / protocol.h
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright 2014 Google, Inc
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, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef LIBSIGROK_HARDWARE_CHROMIUM_TWINKIE_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_CHROMIUM_TWINKIE_PROTOCOL_H
22
23 #include <stdint.h>
24 #include <glib.h>
25 #include <libsigrok/libsigrok.h>
26 #include "libsigrok-internal.h"
27
28 #define LOG_PREFIX "twinkie"
29
30 /** Private, per-CC logical channel context. */
31 struct cc_context {
32         int idx;
33         int rollbacks;
34         uint8_t prev_src;
35         uint8_t level;
36 };
37
38 /** Private, per-device-instance driver context. */
39 struct dev_context {
40         /** Maximum number of samples to capture, if nonzero. */
41         uint64_t limit_samples;
42
43         int64_t sent_samples;
44         int submitted_transfers;
45         uint8_t *convbuffer;
46         size_t convbuffer_size;
47
48         unsigned int num_transfers;
49         struct libusb_transfer **transfers;
50         struct sr_context *ctx;
51
52         struct cc_context cc[2];
53 };
54
55 SR_PRIV int twinkie_start_acquisition(const struct sr_dev_inst *sdi);
56 SR_PRIV int twinkie_init_device(const struct sr_dev_inst *sdi);
57 SR_PRIV void twinkie_receive_transfer(struct libusb_transfer *transfer);
58
59 #endif