forked from Ivasoft/DSView
Improve usb transfer and othre minor issues
This commit is contained in:
@@ -305,3 +305,22 @@ SR_PRIV int command_rd_nvm(libusb_device_handle *devhdl, unsigned char *ctx, uin
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
SR_PRIV int command_get_fpga_done(libusb_device_handle *devhdl,
|
||||
uint8_t *fpga_done)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
|
||||
LIBUSB_ENDPOINT_IN, CMD_FPGA_DONE, 0x0000, 0x0000,
|
||||
fpga_done, 1, 3000);
|
||||
|
||||
if (ret < 0) {
|
||||
sr_err("Unable to get fpga done info: %s.",
|
||||
libusb_error_name(ret));
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#define CMD_WR_NVM 0xb9
|
||||
#define CMD_RD_NVM 0xba
|
||||
#define CMD_RD_NVM_PRE 0xbb
|
||||
#define CMD_FPGA_DONE 0xbc
|
||||
|
||||
#define CMD_START_FLAGS_MODE_POS 4
|
||||
#define CMD_START_FLAGS_WIDE_POS 5
|
||||
@@ -165,4 +166,6 @@ SR_PRIV int command_wr_reg(libusb_device_handle *devhdl, uint8_t value, uint8_t
|
||||
SR_PRIV int command_wr_nvm(libusb_device_handle *devhdl, unsigned char *ctx, uint8_t len);
|
||||
SR_PRIV int command_rd_nvm(libusb_device_handle *devhdl, unsigned char *ctx, uint8_t addr, uint8_t len);
|
||||
|
||||
SR_PRIV int command_get_fpga_done(libusb_device_handle *devhdl,
|
||||
uint8_t *fpga_done);
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -121,6 +121,11 @@
|
||||
#define CALI_VGAIN_RANGE 100
|
||||
#define CALI_VOFF_RANGE (1024-DSCOPE20_DEFAULT_TRANS)
|
||||
|
||||
#define DSO_AUTOTRIG_THRESHOLD 16
|
||||
|
||||
#define TRIG_CHECKID 0xa500005a
|
||||
#define DSO_PKTID 0xa500
|
||||
|
||||
struct DSL_profile {
|
||||
uint16_t vid;
|
||||
uint16_t pid;
|
||||
@@ -175,6 +180,17 @@ static const struct DSL_profile supported_DSCope[3] = {
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
static const gboolean default_ms_en[DSO_MS_END - DSO_MS_BEGIN] = {
|
||||
FALSE, /* DSO_MS_BEGIN */
|
||||
TRUE, /* DSO_MS_FREQ */
|
||||
FALSE, /* DSO_MS_PERD */
|
||||
TRUE, /* DSO_MS_VMAX */
|
||||
TRUE, /* DSO_MS_VMIN */
|
||||
FALSE, /* DSO_MS_VRMS */
|
||||
FALSE, /* DSO_MS_VMEA */
|
||||
FALSE, /* DSO_MS_VP2P */
|
||||
FALSE, /* DSO_MS_END */
|
||||
};
|
||||
|
||||
enum {
|
||||
DSL_ERROR = -1,
|
||||
@@ -184,6 +200,7 @@ enum {
|
||||
DSL_TRIGGERED = 3,
|
||||
DSL_DATA = 4,
|
||||
DSL_STOP = 5,
|
||||
DSL_FINISH = 6,
|
||||
};
|
||||
|
||||
struct DSL_context {
|
||||
@@ -210,6 +227,7 @@ struct DSL_context {
|
||||
uint16_t op_mode;
|
||||
uint16_t ch_mode;
|
||||
uint16_t samplerates_size;
|
||||
uint16_t samplecounts_size;
|
||||
uint16_t th_level;
|
||||
double vth;
|
||||
uint16_t filter;
|
||||
@@ -219,6 +237,7 @@ struct DSL_context {
|
||||
uint16_t trigger_buffer[NUM_TRIGGER_STAGES];
|
||||
uint64_t timebase;
|
||||
uint8_t max_height;
|
||||
uint8_t trigger_channel;
|
||||
uint8_t trigger_slope;
|
||||
uint8_t trigger_source;
|
||||
uint8_t trigger_hrate;
|
||||
@@ -235,7 +254,6 @@ struct DSL_context {
|
||||
uint8_t dso_bits;
|
||||
|
||||
int num_samples;
|
||||
uint64_t sent_samples;
|
||||
int submitted_transfers;
|
||||
int empty_transfer_count;
|
||||
|
||||
@@ -249,6 +267,7 @@ struct DSL_context {
|
||||
|
||||
int status;
|
||||
gboolean mstatus_valid;
|
||||
gboolean abort;
|
||||
};
|
||||
|
||||
struct DSL_setting {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -100,6 +100,7 @@ struct dev_context {
|
||||
GIOChannel *channel;
|
||||
uint64_t cur_samplerate;
|
||||
uint64_t limit_samples;
|
||||
uint64_t limit_samples_show;
|
||||
uint64_t limit_msec;
|
||||
uint8_t sample_generator;
|
||||
uint64_t samples_counter;
|
||||
@@ -285,6 +286,18 @@ static const char *probe_names[NUM_PROBES + 1] = {
|
||||
|
||||
};
|
||||
|
||||
static const gboolean default_ms_en[DSO_MS_END - DSO_MS_BEGIN] = {
|
||||
FALSE, /* DSO_MS_BEGIN */
|
||||
TRUE, /* DSO_MS_FREQ */
|
||||
FALSE, /* DSO_MS_PERD */
|
||||
TRUE, /* DSO_MS_VMAX */
|
||||
TRUE, /* DSO_MS_VMIN */
|
||||
FALSE, /* DSO_MS_VRMS */
|
||||
FALSE, /* DSO_MS_VMEA */
|
||||
FALSE, /* DSO_MS_VP2P */
|
||||
FALSE, /* DSO_MS_END */
|
||||
};
|
||||
|
||||
/* Private, per-device-instance driver context. */
|
||||
/* TODO: struct context as with the other drivers. */
|
||||
|
||||
@@ -341,6 +354,7 @@ static GSList *hw_scan(GSList *options)
|
||||
devc->sdi = sdi;
|
||||
devc->cur_samplerate = SR_MHZ(1);
|
||||
devc->limit_samples = SR_MB(1);
|
||||
devc->limit_samples_show = devc->limit_samples;
|
||||
devc->limit_msec = 0;
|
||||
devc->sample_generator = PATTERN_SINE;
|
||||
devc->timebase = 200;
|
||||
@@ -457,6 +471,20 @@ static int hw_cleanup(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int en_ch_num(const struct sr_dev_inst *sdi)
|
||||
{
|
||||
GSList *l;
|
||||
int channel_en_cnt = 0;
|
||||
|
||||
for (l = sdi->channels; l; l = l->next) {
|
||||
struct sr_channel *probe = (struct sr_channel *)l->data;
|
||||
channel_en_cnt += probe->enabled;
|
||||
}
|
||||
channel_en_cnt += (channel_en_cnt == 0);
|
||||
|
||||
return channel_en_cnt;
|
||||
}
|
||||
|
||||
static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
const struct sr_channel *ch,
|
||||
const struct sr_channel_group *cg)
|
||||
@@ -470,7 +498,7 @@ static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
|
||||
*data = g_variant_new_uint64(devc->cur_samplerate);
|
||||
break;
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
*data = g_variant_new_uint64(devc->limit_samples);
|
||||
*data = g_variant_new_uint64(devc->limit_samples_show);
|
||||
break;
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
*data = g_variant_new_uint64(devc->limit_msec);
|
||||
@@ -546,7 +574,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
struct sr_channel *ch,
|
||||
const struct sr_channel_group *cg)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t i, j;
|
||||
int ret;
|
||||
const char *stropt;
|
||||
struct sr_channel *probe;
|
||||
@@ -567,14 +595,19 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
devc->cur_samplerate);
|
||||
ret = SR_OK;
|
||||
} else if (id == SR_CONF_LIMIT_SAMPLES) {
|
||||
devc->limit_msec = 0;
|
||||
devc->limit_samples = g_variant_get_uint64(data);
|
||||
devc->limit_msec = 0;
|
||||
devc->limit_samples = g_variant_get_uint64(data);
|
||||
devc->limit_samples_show = devc->limit_samples;
|
||||
if (sdi->mode == DSO && en_ch_num(sdi) == 1) {
|
||||
devc->limit_samples /= 2;
|
||||
}
|
||||
sr_dbg("%s: setting limit_samples to %" PRIu64, __func__,
|
||||
devc->limit_samples);
|
||||
ret = SR_OK;
|
||||
} else if (id == SR_CONF_LIMIT_MSEC) {
|
||||
devc->limit_msec = g_variant_get_uint64(data);
|
||||
devc->limit_samples = 0;
|
||||
devc->limit_samples_show = devc->limit_samples;
|
||||
sr_dbg("%s: setting limit_msec to %" PRIu64, __func__,
|
||||
devc->limit_msec);
|
||||
ret = SR_OK;
|
||||
@@ -590,6 +623,9 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
else
|
||||
sdi->channels = g_slist_append(sdi->channels, probe);
|
||||
}
|
||||
devc->cur_samplerate = SR_MHZ(1);
|
||||
devc->limit_samples = SR_MB(1);
|
||||
devc->limit_samples_show = devc->limit_samples;
|
||||
} else if (sdi->mode == DSO) {
|
||||
sr_dev_probes_free(sdi);
|
||||
for (i = 0; i < DEMO_MAX_DSO_PROBES_NUM; i++) {
|
||||
@@ -603,10 +639,14 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
probe->trig_value = 0x80;
|
||||
probe->vpos = (probe->index == 0 ? 0.5 : -0.5)*probe->vdiv;
|
||||
sdi->channels = g_slist_append(sdi->channels, probe);
|
||||
probe->ms_show = TRUE;
|
||||
for (j = DSO_MS_BEGIN; j < DSO_MS_END; j++)
|
||||
probe->ms_en[j] = default_ms_en[j];
|
||||
}
|
||||
}
|
||||
devc->cur_samplerate = DEMO_MAX_DSO_SAMPLERATE / DEMO_MAX_DSO_PROBES_NUM;
|
||||
devc->limit_samples = DEMO_MAX_DSO_DEPTH / DEMO_MAX_DSO_PROBES_NUM;
|
||||
devc->limit_samples_show = devc->limit_samples;
|
||||
} else if (sdi->mode == ANALOG) {
|
||||
sr_dev_probes_free(sdi);
|
||||
for (i = 0; i < DS_MAX_ANALOG_PROBES_NUM; i++) {
|
||||
@@ -618,6 +658,7 @@ static int config_set(int id, GVariant *data, struct sr_dev_inst *sdi,
|
||||
}
|
||||
devc->cur_samplerate = SR_HZ(100);
|
||||
devc->limit_samples = SR_KB(1);
|
||||
devc->limit_samples_show = devc->limit_samples;
|
||||
} else {
|
||||
ret = SR_ERR;
|
||||
}
|
||||
@@ -980,6 +1021,8 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
|
||||
dso.num_samples = sending_now;
|
||||
else
|
||||
dso.num_samples = devc->samples_counter;
|
||||
if (en_ch_num(sdi) == 1)
|
||||
dso.num_samples *= 2;
|
||||
dso.mq = SR_MQ_VOLTAGE;
|
||||
dso.unit = SR_UNIT_VOLT;
|
||||
dso.mqflags = SR_MQFLAG_AC;
|
||||
@@ -997,8 +1040,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
|
||||
|
||||
if (sdi->mode == DSO && !devc->instant) {
|
||||
devc->pre_index += sending_now;
|
||||
if (sdi->mode == DSO && !devc->instant &&
|
||||
devc->pre_index >= devc->limit_samples)
|
||||
if (devc->pre_index >= devc->limit_samples)
|
||||
devc->pre_index = 0;
|
||||
}
|
||||
|
||||
@@ -1012,7 +1054,7 @@ static int receive_data(int fd, int revents, const struct sr_dev_inst *sdi)
|
||||
}
|
||||
}
|
||||
|
||||
if ((sdi->mode == LOGIC || devc->instant) && devc->limit_samples &&
|
||||
if ((sdi->mode != DSO || devc->instant) && devc->limit_samples &&
|
||||
devc->samples_counter >= devc->limit_samples) {
|
||||
sr_info("Requested number of samples reached.");
|
||||
hw_dev_acquisition_stop(sdi, NULL);
|
||||
|
||||
@@ -76,6 +76,8 @@ static struct sr_config_info sr_config_info_data[] = {
|
||||
"Trigger slope", "Trigger slope", NULL},
|
||||
{SR_CONF_TRIGGER_SOURCE, SR_T_UINT8, "triggersource",
|
||||
"Trigger source", "Trigger source", NULL},
|
||||
{SR_CONF_TRIGGER_CHANNEL, SR_T_UINT8, "triggerchannel",
|
||||
"Trigger channel", "Trigger channel", NULL},
|
||||
{SR_CONF_HORIZ_TRIGGERPOS, SR_T_UINT8, "horiz_triggerpos",
|
||||
"Horizontal trigger position", "Horizontal trigger position", NULL},
|
||||
{SR_CONF_TRIGGER_HOLDOFF, SR_T_UINT64, "triggerholdoff",
|
||||
|
||||
@@ -288,6 +288,18 @@ enum {
|
||||
SR_MQFLAG_SPL_PCT_OVER_ALARM = 0x10000,
|
||||
};
|
||||
|
||||
enum DSO_MEASURE_TYPE {
|
||||
DSO_MS_BEGIN = 0,
|
||||
DSO_MS_FREQ,
|
||||
DSO_MS_PERD,
|
||||
DSO_MS_VMAX,
|
||||
DSO_MS_VMIN,
|
||||
DSO_MS_VRMS,
|
||||
DSO_MS_VMEA,
|
||||
DSO_MS_VP2P,
|
||||
DSO_MS_END,
|
||||
};
|
||||
|
||||
struct sr_context;
|
||||
|
||||
struct sr_datafeed_packet {
|
||||
@@ -327,6 +339,8 @@ struct sr_datafeed_dso {
|
||||
uint64_t mqflags;
|
||||
/** samplerate different from last packet */
|
||||
gboolean samplerate_tog;
|
||||
/** trig flag */
|
||||
gboolean trig_flag;
|
||||
/** The analog value(s). The data is interleaved according to
|
||||
* the probes list. */
|
||||
void *data;
|
||||
@@ -575,6 +589,8 @@ struct sr_channel {
|
||||
uint8_t trig_value;
|
||||
int8_t comb_diff_top;
|
||||
int8_t comb_diff_bom;
|
||||
gboolean ms_show;
|
||||
gboolean ms_en[DSO_MS_END - DSO_MS_BEGIN];
|
||||
};
|
||||
|
||||
/** Structure for groups of channels that have common properties. */
|
||||
@@ -632,6 +648,9 @@ struct sr_status {
|
||||
gboolean stream_mode;
|
||||
uint32_t sample_divider;
|
||||
gboolean sample_divider_tog;
|
||||
gboolean trig_flag;
|
||||
|
||||
uint16_t pkt_id;
|
||||
};
|
||||
|
||||
enum {
|
||||
@@ -718,6 +737,9 @@ enum {
|
||||
/** Trigger source. */
|
||||
SR_CONF_TRIGGER_SOURCE,
|
||||
|
||||
/** Trigger channel */
|
||||
SR_CONF_TRIGGER_CHANNEL,
|
||||
|
||||
/** Trigger Value. */
|
||||
SR_CONF_TRIGGER_VALUE,
|
||||
|
||||
@@ -1099,10 +1121,11 @@ struct ds_trigger {
|
||||
};
|
||||
|
||||
struct ds_trigger_pos {
|
||||
uint32_t check_id;
|
||||
uint32_t real_pos;
|
||||
uint32_t ram_saddr;
|
||||
uint32_t remain_cnt;
|
||||
unsigned char first_block[500];
|
||||
unsigned char first_block[496];
|
||||
};
|
||||
|
||||
#include "proto.h"
|
||||
|
||||
Reference in New Issue
Block a user