]>
Commit | Line | Data |
---|---|---|
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 | ||
3544f848 | 29 | #define LOG_PREFIX "rigol-ds" |
f4816ac6 | 30 | |
d22250a9 | 31 | /* Analog waveform block sizes */ |
babab622 ML |
32 | #define DS1000_ANALOG_LIVE_WAVEFORM_SIZE 600 |
33 | #define DS2000_ANALOG_LIVE_WAVEFORM_SIZE 1400 | |
962af1a3 | 34 | #define VS5000_ANALOG_LIVE_WAVEFORM_SIZE 2048 |
0d9f5a12 | 35 | #define DSO1000_ANALOG_LIVE_WAVEFORM_SIZE 600 |
babab622 ML |
36 | #define DS2000_ANALOG_MEM_WAVEFORM_SIZE_1C 14000 |
37 | #define DS2000_ANALOG_MEM_WAVEFORM_SIZE_2C 7000 | |
d22250a9 ML |
38 | |
39 | /* Digital waveform block size */ | |
40 | #define DS1000_DIGITAL_WAVEFORM_SIZE 1200 | |
41 | #define VS5000_DIGITAL_WAVEFORM_SIZE 4096 | |
42 | ||
babab622 ML |
43 | /* Size of acquisition buffers */ |
44 | #define ACQ_BUFFER_SIZE 32768 | |
45 | ||
821fbcad ML |
46 | #define MAX_ANALOG_PROBES 4 |
47 | #define MAX_DIGITAL_PROBES 16 | |
48 | ||
babab622 | 49 | enum rigol_ds_series { |
470140fc | 50 | RIGOL_VS5000, |
babab622 ML |
51 | RIGOL_DS1000, |
52 | RIGOL_DS1000Z, | |
53 | RIGOL_DS2000, | |
54 | RIGOL_DS4000, | |
55 | RIGOL_DS6000, | |
10afee13 | 56 | AGILENT_DSO1000, |
babab622 ML |
57 | }; |
58 | ||
59 | enum rigol_protocol_flavor { | |
962af1a3 | 60 | /* Used by DS1000 and VS5000 series */ |
babab622 ML |
61 | PROTOCOL_LEGACY, |
62 | /* Used by DS2000, DS4000, DS6000, ... series */ | |
63 | PROTOCOL_IEEE488_2, | |
64 | }; | |
65 | ||
66 | enum data_source { | |
67 | DATA_SOURCE_LIVE, | |
68 | DATA_SOURCE_MEMORY, | |
69 | DATA_SOURCE_SEGMENTED, | |
70 | }; | |
e0b7d23c | 71 | |
bafd4890 | 72 | struct rigol_ds_model { |
10afee13 | 73 | char *vendor; |
bafd4890 | 74 | char *name; |
babab622 ML |
75 | enum rigol_ds_series series; |
76 | enum rigol_protocol_flavor protocol; | |
bafd4890 ML |
77 | uint64_t min_timebase[2]; |
78 | uint64_t max_timebase[2]; | |
79 | uint64_t min_vdiv[2]; | |
821fbcad | 80 | unsigned int analog_channels; |
bafd4890 | 81 | bool has_digital; |
babab622 ML |
82 | int num_horizontal_divs; |
83 | }; | |
84 | ||
85 | enum wait_events { | |
86 | WAIT_NONE, /* Don't wait */ | |
87 | WAIT_TRIGGER, /* Wait for trigger (only live capture) */ | |
88 | WAIT_BLOCK, /* Wait for block data (only when reading sample mem) */ | |
89 | WAIT_STOP, /* Wait for scope stopping (only single shots) */ | |
bafd4890 ML |
90 | }; |
91 | ||
f4816ac6 ML |
92 | /** Private, per-device-instance driver context. */ |
93 | struct dev_context { | |
bafd4890 ML |
94 | /* Device model */ |
95 | const struct rigol_ds_model *model; | |
96 | ||
97 | /* Device properties */ | |
98 | const uint64_t (*timebases)[2]; | |
99 | uint64_t num_timebases; | |
100 | const uint64_t (*vdivs)[2]; | |
101 | uint64_t num_vdivs; | |
6bb192bc | 102 | |
3d3a601e | 103 | /* Probe groups */ |
821fbcad | 104 | struct sr_probe_group analog_groups[MAX_ANALOG_PROBES]; |
3d3a601e ML |
105 | struct sr_probe_group digital_group; |
106 | ||
254dd102 | 107 | /* Acquisition settings */ |
6bb192bc ML |
108 | GSList *enabled_analog_probes; |
109 | GSList *enabled_digital_probes; | |
e0b7d23c | 110 | uint64_t limit_frames; |
f4816ac6 | 111 | void *cb_data; |
babab622 ML |
112 | enum data_source data_source; |
113 | uint64_t analog_frame_size; | |
d22250a9 | 114 | uint64_t digital_frame_size; |
f4816ac6 | 115 | |
254dd102 | 116 | /* Device settings */ |
821fbcad ML |
117 | gboolean analog_channels[MAX_ANALOG_PROBES]; |
118 | gboolean digital_channels[MAX_DIGITAL_PROBES]; | |
04e8e01e | 119 | gboolean la_enabled; |
254dd102 | 120 | float timebase; |
821fbcad ML |
121 | float vdiv[MAX_ANALOG_PROBES]; |
122 | int vert_reference[MAX_ANALOG_PROBES]; | |
123 | float vert_offset[MAX_ANALOG_PROBES]; | |
254dd102 BV |
124 | char *trigger_source; |
125 | float horiz_triggerpos; | |
126 | char *trigger_slope; | |
821fbcad | 127 | char *coupling[MAX_ANALOG_PROBES]; |
254dd102 BV |
128 | |
129 | /* Operational state */ | |
0d87bd93 ML |
130 | |
131 | /* Number of frames received in total. */ | |
254dd102 | 132 | uint64_t num_frames; |
821fbcad ML |
133 | /* GSList entry for the current channel. */ |
134 | GSList *channel_entry; | |
f76c24f6 ML |
135 | /* Number of bytes received for current channel. */ |
136 | uint64_t num_channel_bytes; | |
bafd4890 ML |
137 | /* Number of bytes in current data block, if 0 block header expected */ |
138 | uint64_t num_block_bytes; | |
139 | /* Number of data block bytes already read */ | |
140 | uint64_t num_block_read; | |
babab622 ML |
141 | /* What to wait for in *_receive */ |
142 | enum wait_events wait_event; | |
143 | /* Trigger/block copying/stop waiting status */ | |
144 | int wait_status; | |
145 | /* Acq buffers used for reading from the scope and sending data to app */ | |
146 | unsigned char *buffer; | |
147 | float *data; | |
f4816ac6 ML |
148 | }; |
149 | ||
babab622 | 150 | SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi); |
677f85d0 | 151 | SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi); |
3086efdd | 152 | SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data); |
3086efdd | 153 | SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi); |
e0b7d23c | 154 | |
f4816ac6 | 155 | #endif |