]>
Commit | Line | Data |
---|---|---|
744e43bc VP |
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 | ||
fcc65337 VP |
38 | enum vbus_group_index { |
39 | VBUS_V = 0, | |
40 | VBUS_A = 1, | |
41 | ||
42 | VBUS_GRP_COUNT = 2 | |
43 | }; | |
44 | ||
744e43bc VP |
45 | /** Private, per-device-instance driver context. */ |
46 | struct dev_context { | |
47 | /** Maximum number of samples to capture, if nonzero. */ | |
48 | uint64_t limit_samples; | |
49 | ||
50 | int64_t sent_samples; | |
51 | int submitted_transfers; | |
52 | uint8_t *convbuffer; | |
53 | size_t convbuffer_size; | |
54 | ||
55 | unsigned int num_transfers; | |
56 | struct libusb_transfer **transfers; | |
57 | struct sr_context *ctx; | |
58 | ||
59 | struct cc_context cc[2]; | |
fcc65337 VP |
60 | int vbus_channels; |
61 | char vbus_data[64]; | |
62 | uint64_t vbus_t0; | |
63 | uint64_t vbus_delta; | |
64 | struct sr_datafeed_analog vbus_packet[VBUS_GRP_COUNT]; | |
65 | struct sr_analog_meaning vbus_meaning[VBUS_GRP_COUNT]; | |
66 | struct sr_analog_encoding vbus_encoding; | |
67 | struct sr_analog_spec vbus_spec; | |
744e43bc VP |
68 | }; |
69 | ||
70 | SR_PRIV int twinkie_start_acquisition(const struct sr_dev_inst *sdi); | |
71 | SR_PRIV int twinkie_init_device(const struct sr_dev_inst *sdi); | |
72 | SR_PRIV void LIBUSB_CALL twinkie_receive_transfer(struct libusb_transfer *transfer); | |
fcc65337 VP |
73 | SR_PRIV void LIBUSB_CALL twinkie_vbus_sent(struct libusb_transfer *transfer); |
74 | SR_PRIV void LIBUSB_CALL twinkie_vbus_recv(struct libusb_transfer *transfer); | |
744e43bc VP |
75 | |
76 | #endif |