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