]> sigrok.org Git - libsigrok.git/blame - hardware/rigol-ds/protocol.h
Fix handling second channel on DS2000 series.
[libsigrok.git] / hardware / rigol-ds / protocol.h
CommitLineData
f4816ac6
ML
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2012 Martin Ling <martin-git@earth.li>
88e429c9 5 * Copyright (C) 2013 Bert Vermeulen <bert@biot.com>
f4816ac6
ML
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
3086efdd
ML
21#ifndef LIBSIGROK_HARDWARE_RIGOL_DS_PROTOCOL_H
22#define LIBSIGROK_HARDWARE_RIGOL_DS_PROTOCOL_H
f4816ac6
ML
23
24#include <stdint.h>
bafd4890 25#include <stdbool.h>
f4816ac6
ML
26#include "libsigrok.h"
27#include "libsigrok-internal.h"
28
29a27196 29/* Message logging helpers with subsystem-specific prefix string. */
3086efdd 30#define LOG_PREFIX "rigol-ds: "
29a27196
UH
31#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args)
32#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args)
33#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args)
34#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args)
35#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args)
36#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
f4816ac6 37
bafd4890
ML
38#define DS1000_ANALOG_WAVEFORM_SIZE 600
39#define DS2000_ANALOG_WAVEFORM_SIZE 1400
6bb192bc 40#define DIGITAL_WAVEFORM_SIZE 1210
e0b7d23c 41
bafd4890
ML
42struct rigol_ds_model {
43 char *name;
44 unsigned int series;
45 uint64_t min_timebase[2];
46 uint64_t max_timebase[2];
47 uint64_t min_vdiv[2];
48 bool has_digital;
49};
50
f4816ac6
ML
51/** Private, per-device-instance driver context. */
52struct dev_context {
bafd4890
ML
53 /* Device model */
54 const struct rigol_ds_model *model;
55
56 /* Device properties */
57 const uint64_t (*timebases)[2];
58 uint64_t num_timebases;
59 const uint64_t (*vdivs)[2];
60 uint64_t num_vdivs;
6bb192bc 61
3d3a601e
ML
62 /* Probe groups */
63 struct sr_probe_group analog_groups[2];
64 struct sr_probe_group digital_group;
65
254dd102 66 /* Acquisition settings */
6bb192bc
ML
67 GSList *enabled_analog_probes;
68 GSList *enabled_digital_probes;
e0b7d23c 69 uint64_t limit_frames;
f4816ac6
ML
70 void *cb_data;
71
254dd102 72 /* Device settings */
6bb192bc
ML
73 gboolean analog_channels[2];
74 gboolean digital_channels[16];
254dd102
BV
75 float timebase;
76 float vdiv[2];
bafd4890 77 int vert_reference[2];
254dd102
BV
78 float vert_offset[2];
79 char *trigger_source;
80 float horiz_triggerpos;
81 char *trigger_slope;
82 char *coupling[2];
83
84 /* Operational state */
254dd102 85 uint64_t num_frames;
bafd4890 86 /* FIXME: misnomer, actually this is number of frame samples? */
ee7e9bee 87 uint64_t num_frame_bytes;
254dd102 88 struct sr_probe *channel_frame;
bafd4890
ML
89 /* Number of bytes in current data block, if 0 block header expected */
90 uint64_t num_block_bytes;
91 /* Number of data block bytes already read */
92 uint64_t num_block_read;
93 /* Trigger waiting status, 0 - don't wait */
94 int trigger_wait_status;
f4816ac6
ML
95};
96
bafd4890 97SR_PRIV int rigol_ds2xx2_acquisition_start(const struct sr_dev_inst *sdi, gboolean wait_for_trigger);
3086efdd
ML
98SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data);
99SR_PRIV int rigol_ds_send(const struct sr_dev_inst *sdi, const char *format, ...);
100SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi);
e0b7d23c 101
f4816ac6 102#endif