]> sigrok.org Git - libsigrok.git/blame - src/hardware/saleae-logic-pro/protocol.h
sr_dev_open(): Set status to SR_ST_ACTIVE upon success.
[libsigrok.git] / src / hardware / saleae-logic-pro / protocol.h
CommitLineData
a8e913c4
JL
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2017 Jan Luebbe <jluebbe@lasnet.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
b6189f7c
UH
20#ifndef LIBSIGROK_HARDWARE_SALEAE_LOGIC_PRO_PROTOCOL_H
21#define LIBSIGROK_HARDWARE_SALEAE_LOGIC_PRO_PROTOCOL_H
a8e913c4
JL
22
23#include <stdint.h>
24#include <glib.h>
25#include <libsigrok/libsigrok.h>
26#include "libsigrok-internal.h"
27
b6189f7c 28#define LOG_PREFIX "saleae-logic-pro"
a8e913c4 29
ca7d19b5 30/* 16 channels * 32 samples */
bb0c5271
UH
31#define CONV_BATCH_SIZE (2 * 32)
32
33/*
34 * One packet + one partial conversion: Worst case is only one active
35 * channel converted to 2 bytes per sample, with 8 * 16384 samples per packet.
ca7d19b5 36 */
bb0c5271 37#define CONV_BUFFER_SIZE (2 * 8 * 16384 + CONV_BATCH_SIZE)
ca7d19b5 38
a8e913c4
JL
39/** Private, per-device-instance driver context. */
40struct dev_context {
a8e913c4 41 /* Acquisition settings */
ca7d19b5
JL
42 unsigned int dig_channel_cnt;
43 uint16_t dig_channel_mask;
44 uint16_t dig_channel_masks[16];
45 uint64_t dig_samplerate;
a8e913c4
JL
46
47 /* Operational state */
ca7d19b5 48 uint32_t lfsr;
a8e913c4
JL
49
50 /* Temporary state across callbacks */
ca7d19b5
JL
51 unsigned int num_transfers;
52 unsigned int submitted_transfers;
53 struct libusb_transfer **transfers;
a8e913c4 54
ca7d19b5
JL
55 /* Conversion buffer */
56 uint8_t *conv_buffer;
57 unsigned int conv_size;
58 unsigned int batch_index;
a8e913c4
JL
59};
60
b6189f7c
UH
61SR_PRIV int saleae_logic_pro_init(const struct sr_dev_inst *sdi);
62SR_PRIV int saleae_logic_pro_prepare(const struct sr_dev_inst *sdi);
63SR_PRIV int saleae_logic_pro_start(const struct sr_dev_inst *sdi);
64SR_PRIV int saleae_logic_pro_stop(const struct sr_dev_inst *sdi);
65SR_PRIV void LIBUSB_CALL saleae_logic_pro_receive_data(struct libusb_transfer *transfer);
a8e913c4
JL
66
67#endif