]> sigrok.org Git - libsigrok.git/blob - src/hardware/lecroy-logicstudio/protocol.h
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / hardware / lecroy-logicstudio / protocol.h
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright (C) 2015 Tilman Sauerbeck <tilman@code-monkey.de>
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 #ifndef LIBSIGROK_HARDWARE_LECROY_LOGICSTUDIO_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_LECROY_LOGICSTUDIO_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 "lecroy-logicstudio"
29
30 #define SAMPLE_BUF_SIZE 40960u
31 #define CONV_8TO16_BUF_SIZE 8192
32 #define INTR_BUF_SIZE 32
33
34 struct samplerate_info;
35
36 struct dev_context {
37         struct libusb_transfer *intr_xfer;
38         struct libusb_transfer *bulk_xfer;
39
40         const struct samplerate_info *samplerate_info;
41
42         /**
43          * When the device is opened, this will point at a buffer
44          * of SAMPLE_BUF_SIZE bytes.
45          */
46         uint8_t *fetched_samples;
47
48         /**
49          * Used to convert 8 bit samples (8 channels) to 16 bit samples
50          * (16 channels), thus only used in 8 channel mode.
51          * Holds CONV_8TO16_BUF_SIZE bytes.
52          */
53         uint16_t *conv8to16;
54
55         int64_t fw_updated; /* Time of last FX2 firmware upload. */
56
57         /** The pre-trigger capture ratio in percent. */
58         uint64_t capture_ratio;
59
60         uint64_t earliest_sample;
61         uint64_t trigger_sample;
62
63         /** The number of eight-channel groups enabled (either 1 or 2). */
64         uint32_t num_enabled_channel_groups;
65
66         /**
67          * The number of samples to acquire (in thousands).
68          * This is not customizable, but depending on the number
69          * of enabled channel groups.
70          */
71         uint32_t num_thousand_samples;
72
73         uint32_t total_received_sample_bytes;
74
75         /** Mask of enabled channels. */
76         uint16_t channel_mask;
77
78         uint16_t acquisition_id;
79
80         gboolean want_trigger;
81         gboolean abort_acquisition;
82
83         /**
84          * These two magic values are required in order to fix a sample
85          * buffer corruption. Before the first acquisition is run, they
86          * need to be set to 0.
87          */
88         uint8_t magic_arm_trigger;
89         uint8_t magic_fetch_samples;
90
91         /**
92          * Buffer for interrupt transfers (acquisition state notifications).
93          */
94         uint8_t intr_buf[INTR_BUF_SIZE];
95 };
96
97 SR_PRIV void lls_update_channel_mask(const struct sr_dev_inst *sdi);
98
99 SR_PRIV int lls_set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate);
100 SR_PRIV uint64_t lls_get_samplerate(const struct sr_dev_inst *sdi);
101
102 SR_PRIV int lls_setup_acquisition(const struct sr_dev_inst *sdi);
103 SR_PRIV int lls_start_acquisition(const struct sr_dev_inst *sdi);
104 SR_PRIV int lls_stop_acquisition(const struct sr_dev_inst *sdi);
105
106 #endif