2 * This file is part of the libsigrok project.
4 * Copyright (C) 2015 Tilman Sauerbeck <tilman@code-monkey.de>
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 LIBSIGROK_HARDWARE_LECROY_LOGICSTUDIO_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_LECROY_LOGICSTUDIO_PROTOCOL_H
25 #include <libsigrok/libsigrok.h>
26 #include "libsigrok-internal.h"
28 #define LOG_PREFIX "lecroy-logicstudio"
30 #define SAMPLE_BUF_SIZE 40960u
31 #define CONV_8TO16_BUF_SIZE 8192
32 #define INTR_BUF_SIZE 32
34 struct samplerate_info;
37 struct libusb_transfer *intr_xfer;
38 struct libusb_transfer *bulk_xfer;
40 const struct samplerate_info *samplerate_info;
43 * When the device is opened, this will point at a buffer
44 * of SAMPLE_BUF_SIZE bytes.
46 uint8_t *fetched_samples;
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.
55 int64_t fw_updated; /* Time of last FX2 firmware upload. */
57 /** The pre-trigger capture ratio in percent. */
58 uint64_t capture_ratio;
60 uint64_t earliest_sample;
61 uint64_t trigger_sample;
63 /** The number of eight-channel groups enabled (either 1 or 2). */
64 uint32_t num_enabled_channel_groups;
67 * The number of samples to acquire (in thousands).
68 * This is not customizable, but depending on the number
69 * of enabled channel groups.
71 uint32_t num_thousand_samples;
73 uint32_t total_received_sample_bytes;
75 /** Mask of enabled channels. */
76 uint16_t channel_mask;
78 uint16_t acquisition_id;
80 gboolean want_trigger;
81 gboolean abort_acquisition;
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.
88 uint8_t magic_arm_trigger;
89 uint8_t magic_fetch_samples;
92 * Buffer for interrupt transfers (acquisition state notifications).
94 uint8_t intr_buf[INTR_BUF_SIZE];
97 SR_PRIV void lls_update_channel_mask(const struct sr_dev_inst *sdi);
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);
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);