clean up code & comments a bit
This commit is contained in:
parent
19a7aa375a
commit
b244ed5246
|
@ -44,39 +44,33 @@ static const uint32_t devopts[] = {
|
|||
SR_CONF_LOGIC_THRESHOLD | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST,
|
||||
SR_CONF_LOGIC_THRESHOLD_CUSTOM | SR_CONF_GET | SR_CONF_SET,
|
||||
|
||||
/* "frame is a single capture" -> don't use here, not applicable */
|
||||
/*SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET,*/
|
||||
/*SR_CONF_TRIGGER_MATCH | SR_CONF_LIST,*/
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* * CAPTURE_RATIO: units?: int 0..100
|
||||
* * LIMIT_MSEC: units?: milliseconds
|
||||
* * LIMIT_SAMPLES: units?: samples
|
||||
* * SAMPLERATE: "overdrive" to 200 MHz on SQ50 possible??? yes!
|
||||
*
|
||||
* * VOLTAGE_THRESHOLD vs LOGIC_THRESHOLD? LOGIC_THRESHOLD_CUSTOM: ???
|
||||
* * VOLTAGE_THRESHOLD: 2 double values, custom selection?
|
||||
* * LOGIC_THRESHOLD: selection of (max value) voltages
|
||||
* * LOGIC_THRESHOLD_CUSTOM: custom ^
|
||||
/* list of TODO stuff:
|
||||
* * VOLTAGE_THRESHOLD vs LOGIC_THRESHOLD? LOGIC_THRESHOLD_CUSTOM?
|
||||
* * VOLTAGE_THRESHOLD: 2 double values (min, max) with a slider selection GUI
|
||||
* * LOGIC_THRESHOLD: selection of (max, not thresh value) voltages
|
||||
* * LOGIC_THRESHOLD_CUSTOM: custom ^, so kinda boils down to VOLTAGE_THRESHOLD?
|
||||
* * see kingst-la2016/api.c
|
||||
* * VOLTAGE, VOLTAGE_TARGET: ???
|
||||
* * not applicable here
|
||||
* * except maybe VOLTAGE_TARGET is, for PATTERN_MODE?
|
||||
* * BUFFERSIZE: ???
|
||||
* * DATALOG: ???
|
||||
* * PATTERN_MODE: ???
|
||||
* * string of a pattern name?? so uuuh, fuck (-> filename of blob to upload?)
|
||||
* * OUTPUT_FREQUENCY: ??? (used in PATTERN_MODE instead of SAMPLERATE?)
|
||||
* * not applicable here, for analog stuff only
|
||||
* * CONN: ???
|
||||
* * if you need to specify eg. a serial port. not really applicable here
|
||||
* (need to scan by vid:pid)
|
||||
* * currently implemnted as all of them, pulseview gives a simple slider
|
||||
* without value indication, which is not that practical to use...
|
||||
* LOGIC_THRESHOLD(_CUSTOM) seems to give no UI?
|
||||
*
|
||||
* * trigger stuff aaa (TRIGGER_SOURCE, TRIGGER_MATCH, TRIGGER_LEVEL, TRIGGER_PATTERN)
|
||||
* * TRIGGER_SOURCE: probably not useful
|
||||
* * TRIGGER_MATCH: on what can we match? (hi, lo, rise, fall) -> LIST only
|
||||
* * TRIGGER_LEVEL: seems to be an analog thing, not applicable here
|
||||
* * BUFFERSIZE, DATALOG, PATTERN_MODE: should this be used?
|
||||
*
|
||||
* * trigger stuff:
|
||||
* * TRIGGER_MATCH: uncomment when TRIGGER_PATTERN is implemented
|
||||
* * TRIGGER_PATTERN: freeform string
|
||||
* * see asix-sigma/protocol.c:1603 , it has some proposed formats,
|
||||
* however, these aren't sufficient here as the SQ series also allows
|
||||
* varying pulse widths for each trigger step...
|
||||
* * TRIGGER_LEVEL, TRIGGER_SOURCE: not applicable here
|
||||
*
|
||||
* * the SQ50 accepts 200 MHz samplerate and a buffer size longer than it
|
||||
* has available physical backing for, so it's not unlikely that modding
|
||||
* it to have more memory is possible. so maybe memory and frequency
|
||||
* option shouldn't be strictly checked?
|
||||
* see also: https://git.lain.faith/BLAHAJ/sq50-re/wiki/Hardware-info
|
||||
*/
|
||||
};
|
||||
|
||||
|
@ -94,13 +88,20 @@ static const uint64_t samplerates[] = {
|
|||
};
|
||||
|
||||
static const char *thresholds[] = {
|
||||
"1.8V", // 0x46 0x1e | 1.8 0.8 ~44%
|
||||
"2.8V", // 0x6e 0x2c | 2.8 1.1 ~40%
|
||||
"3.3V", // 0x81 0x46 | 3.3 1.8 ~55%
|
||||
"3.6V", // 0x8d 0x4f | 3.6 2.0 ~55%
|
||||
"5V" , // 0xc4 0x72 | 5.0 2.9 ~58%
|
||||
"5VTTL",// 0xc3 0x3b | 5.0 1.5
|
||||
"User" // VOLTAGE_THRESHOLD == LOGIC_THRESHOLD_CUSTOM (?)
|
||||
"1.8V", /* 0x46 0x1e | 1.8 0.8 ~44% */
|
||||
"2.8V", /* 0x6e 0x2c | 2.8 1.1 ~40% */
|
||||
"3.3V", /* 0x81 0x46 | 3.3 1.8 ~55% */
|
||||
"3.6V", /* 0x8d 0x4f | 3.6 2.0 ~55% */
|
||||
"5V" , /* 0xc4 0x72 | 5.0 2.9 ~58% */
|
||||
"5VTTL",/* 0xc3 0x3b | 5.0 1.5 */
|
||||
"User" /* VOLTAGE_THRESHOLD == LOGIC_THRESHOLD_CUSTOM (?) */
|
||||
};
|
||||
|
||||
static const int matches[] = {
|
||||
SR_TRIGGER_ZERO,
|
||||
SR_TRIGGER_ONE,
|
||||
SR_TRIGGER_RISING,
|
||||
SR_TRIGGER_FALLING,
|
||||
};
|
||||
|
||||
static uint64_t dc_samples_to_msec(struct dev_context *dc, uint64_t samples)
|
||||
|
@ -370,15 +371,18 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
dc->samplerate = g_variant_get_uint64(data);
|
||||
break;
|
||||
case SR_CONF_LIMIT_MSEC:
|
||||
/*printf("msec = %lu\n", g_variant_get_uint64(data));*/
|
||||
dc->limit_samples = dc_msec_to_samples(dc, g_variant_get_uint64(data));
|
||||
/* TODO: make this check optional */
|
||||
if (dc->limit_samples > dc->memsize_max * 4)
|
||||
dc->limit_samples = dc->memsize_max * 4;
|
||||
break;
|
||||
case SR_CONF_LIMIT_SAMPLES:
|
||||
/*printf("samples = %lu\n", g_variant_get_uint64(data));*/
|
||||
dc->limit_samples = g_variant_get_uint64(data);
|
||||
/* TODO: make this check optional */
|
||||
if (dc->limit_samples > dc->memsize_max * 4)
|
||||
dc->limit_samples = dc->memsize_max * 4;
|
||||
break;
|
||||
case SR_CONF_CAPTURE_RATIO:
|
||||
/*printf("ratio = %lu\n", g_variant_get_uint64(data));*/
|
||||
dc->capture_ratio = g_variant_get_uint64(data);
|
||||
break;
|
||||
case SR_CONF_VOLTAGE_THRESHOLD:
|
||||
|
@ -389,12 +393,11 @@ static int config_set(uint32_t key, GVariant *data,
|
|||
/* in the LOGIC_THRESHOLD_CUSTOM case: see 'if' stmt before switch */
|
||||
dc->voltage_idx = 6; /* user */
|
||||
dc->voltage.thresh = (int)(volt * 39.2);
|
||||
/* emulate vendor software values in a shitty way. not 100% exact but
|
||||
/* emulate vendor software values in a naive way. not 100% exact but
|
||||
* oh well. */
|
||||
dc->voltage.level = (dc->voltage.thresh < 0x30)
|
||||
? (int)(volt * 39.2 / 0.40)
|
||||
: (int)(volt * 39.2 / 0.55);
|
||||
/*printf("voltage: %02x %02x\n", dc->voltage.level, dc->voltage.thresh);*/
|
||||
break;
|
||||
default:
|
||||
sr_err("%s no conf key %u", __func__, key);
|
||||
|
@ -421,7 +424,10 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
*data = std_gvar_min_max_step_thresholds(0.8, 2.9, 0.1);
|
||||
break;
|
||||
case SR_CONF_LOGIC_THRESHOLD:
|
||||
*data = g_variant_new_strv(thresholds, ARRAY_SIZE(thresholds));
|
||||
*data = g_variant_new_strv(ARRAY_AND_SIZE(thresholds));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MATCH:
|
||||
*data = std_gvar_array_i32(ARRAY_AND_SIZE(matches));
|
||||
break;
|
||||
default:
|
||||
sr_err("%s no conf key %u", __func__, key);
|
||||
|
|
|
@ -30,11 +30,11 @@ SR_PRIV struct dev_context *sq_new(struct ftdi_context *ft)
|
|||
dc = (struct dev_context *)g_malloc0(sizeof(struct dev_context));
|
||||
dc->ft = ft;
|
||||
|
||||
/* some sensible defaults */
|
||||
/* some sensible defaults (mostly the vendor software defaults) */
|
||||
dc->samplerate = SR_MHZ(25);
|
||||
dc->capture_ratio = 10;
|
||||
dc->capture_ratio = 10; /* 10% in */
|
||||
dc->voltage.level = 0x81; /* 3.3v */
|
||||
dc->voltage.thresh = 0x46; /* 1.8v (3.3v cmos thresh- */
|
||||
dc->voltage.thresh = 0x46; /* 1.8v (3.3v cmos thresh) */
|
||||
dc->voltage_idx = 2; /* "3.3V" */
|
||||
|
||||
return dc;
|
||||
|
@ -589,9 +589,9 @@ SR_PRIV int scanaquad_apply_current_settings(struct dev_context *dc, gboolean pa
|
|||
|
||||
/* TODO: more than just capture mode */
|
||||
samplim = dc->limit_samples / 4;
|
||||
/* TODO: switch to override this check */
|
||||
ms1 = (samplim > dc->memsize_max) ? dc->memsize_max : samplim;
|
||||
ms2 = (samplim > dc->memsize_max) ? dc->memsize_max : samplim;
|
||||
/* sample limit vs LA physical memory size check is done in api.c */
|
||||
ms1 = samplim;
|
||||
ms2 = samplim;
|
||||
ms3 = (uint32_t)(dc->memsize_max * (1 - dc->capture_ratio * 0.01));
|
||||
|
||||
sett.memsetting1[0] = (ms1>> 0) & 0xff;
|
||||
|
@ -623,6 +623,7 @@ SR_PRIV int scanaquad_apply_current_triggers(struct dev_context *dc)
|
|||
}
|
||||
|
||||
|
||||
/* finally, we can implement the higher-level functions. */
|
||||
|
||||
|
||||
SR_PRIV int scanaquad_acquisition_start(struct dev_context *dc)
|
||||
|
@ -680,11 +681,6 @@ static void scanaquad_unpack_samples(uint8_t *rdata, size_t totalunpackbytes)
|
|||
rdata[i*2-1] = (rdata[i-1] & 0xf0) >> 4;
|
||||
rdata[i*2-2] = (rdata[i-1] & 0x0f) >> 0;
|
||||
}
|
||||
|
||||
/*for (i = 0; i < totalunpackbytes; ++i) {
|
||||
printf("%01x ", rdata[i]);
|
||||
if ((i & 15) == 15) printf("\n");
|
||||
}*/
|
||||
}
|
||||
|
||||
SR_PRIV int scanaquad_acquisition_finish(struct sr_dev_inst *sdi, struct dev_context *dc)
|
||||
|
@ -736,6 +732,7 @@ SR_PRIV int scanaquad_acquisition_finish(struct sr_dev_inst *sdi, struct dev_con
|
|||
|
||||
scanaquad_unpack_samples(rdata, nbytes * 2);
|
||||
|
||||
/* 3 packets, for trigger indicator */
|
||||
logic1.length = trig_instant;
|
||||
logic1.unitsize = 1;
|
||||
logic1.data = rdata;
|
||||
|
@ -757,7 +754,7 @@ SR_PRIV int scanaquad_acquisition_finish(struct sr_dev_inst *sdi, struct dev_con
|
|||
sr_session_send(sdi, &packet2);
|
||||
sr_session_send(sdi, &packet3);
|
||||
|
||||
/* I hope this is fine to do?? */
|
||||
/* i hope this is fine to do? seems like it does work just fine with pulseview */
|
||||
g_free(rdata);
|
||||
|
||||
return SR_OK;
|
||||
|
@ -797,8 +794,6 @@ SR_PRIV int scanaquad_receive_data(int fd, int revents, void *cb_data)
|
|||
(void)fd;
|
||||
(void)revents;
|
||||
|
||||
/*sr_spew("receive data");*/
|
||||
|
||||
if (!(sdi = cb_data)) return TRUE;
|
||||
if (!(dc = sdi->priv)) return TRUE;
|
||||
if (!dc->ft) return TRUE;
|
||||
|
|
Loading…
Reference in New Issue