2 * This file is part of the sigrok project.
4 * Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
5 * With protocol information from the hantekdso project,
6 * Copyright (C) 2008 Oleg Khudyakov <prcoder@gmail.com>
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef LIBSIGROK_HARDWARE_HANTEK_DSO_H
23 #define LIBSIGROK_HARDWARE_HANTEK_DSO_H
25 #define USB_INTERFACE 0
26 #define USB_CONFIGURATION 1
27 #define DSO_EP_IN 0x86
28 #define DSO_EP_OUT 0x02
30 /* FX2 renumeration delay in ms */
31 #define MAX_RENUM_DELAY 3000
33 #define MAX_CAPTURE_EMPTY 3
35 #define DEFAULT_VOLTAGE VOLTAGE_2V
36 #define DEFAULT_FRAMESIZE FRAMESIZE_SMALL
37 #define DEFAULT_TIMEBASE TIME_100us
38 #define DEFAULT_TRIGGER_SOURCE "CH1"
39 #define DEFAULT_COUPLING COUPLING_AC
40 #define DEFAULT_HORIZ_TRIGGERPOS 0.5
41 #define DEFAULT_VERT_OFFSET 0.5
42 #define DEFAULT_VERT_TRIGGERPOS 0.0
44 #define MAX_VERT_TRIGGER 0xfe
46 /* Hantek DSO-specific protocol values */
47 #define EEPROM_CHANNEL_OFFSETS 0x08
49 #define FRAMESIZE_SMALL 10240
50 #define FRAMESIZE_LARGE 32768
53 enum control_requests {
54 CTRL_READ_EEPROM = 0xa2,
56 CTRL_BEGINCOMMAND = 0xb3,
57 CTRL_SETOFFSET = 0xb4,
63 CMD_SET_TRIGGER_SAMPLERATE,
110 enum trigger_slopes {
115 enum trigger_sources {
124 CAPTURE_READY_8BIT = 2,
125 CAPTURE_READY_9BIT = 7,
126 CAPTURE_TIMEOUT = 127,
127 CAPTURE_UNKNOWN = 255
144 /* VID/PID after cold boot */
147 /* VID/PID after firmware upload */
158 struct dso_profile *profile;
159 struct sr_usb_dev_inst *usb;
161 uint64_t limit_frames;
163 /* We can't keep track of an FX2-based device after upgrading
164 * the firmware (it re-enumerates into a different device address
165 * after the upgrade) this is like a global lock. No device will open
166 * until a proper delay after the last device was upgraded.
169 int epin_maxpacketsize;
170 int capture_empty_count;
171 int current_transfer;
175 gboolean ch1_enabled;
176 gboolean ch2_enabled;
181 // voltage offset (vertical position)
184 float voffset_trigger;
185 uint16_t channel_levels[2][9][2];
189 gboolean filter_trigger;
192 float triggerposition;
196 SR_PRIV int dso_open(int dev_index);
197 SR_PRIV void dso_close(struct sr_dev_inst *sdi);
198 SR_PRIV int dso_enable_trigger(struct context *ctx);
199 SR_PRIV int dso_force_trigger(struct context *ctx);
200 SR_PRIV int dso_init(struct context *ctx);
201 SR_PRIV uint8_t dso_get_capturestate(struct context *ctx);
202 SR_PRIV uint8_t dso_capture_start(struct context *ctx);
203 SR_PRIV int dso_get_channeldata(struct context *ctx, libusb_transfer_cb_fn cb);