From: Paul Kasemir Date: Mon, 14 Dec 2020 04:32:57 +0000 (-0700) Subject: link-mso19: Add probe_factor config option X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4008a876c8cc77a6e9961c5707ac80e1f1b154fd;p=libsigrok.git link-mso19: Add probe_factor config option --- diff --git a/src/hardware/link-mso19/api.c b/src/hardware/link-mso19/api.c index f0fbd329..3a720124 100644 --- a/src/hardware/link-mso19/api.c +++ b/src/hardware/link-mso19/api.c @@ -44,6 +44,7 @@ static const uint32_t devopts[] = { static const uint32_t devopts_cg_analog[] = { SR_CONF_COUPLING | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, SR_CONF_TRIGGER_SLOPE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, + SR_CONF_PROBE_FACTOR | SR_CONF_GET | SR_CONF_SET, }; static const uint32_t devopts_cg_digital[] = { @@ -160,7 +161,7 @@ static GSList* scan_handle_port(GSList *devices, struct sp_port *port) mso_update_trigger_slope(devc); devc->coupling = coupling[0]; devc->cur_rate = SR_KHZ(10); - devc->dso_probe_attn = 10; + devc->dso_probe_factor = 10; devc->limit_samples = MSO_NUM_SAMPLES; devc->protocol_trigger.spimode = 0; @@ -293,6 +294,11 @@ static int config_get(uint32_t key, GVariant **data, return SR_ERR_NA; *data = g_variant_new_string(devc->coupling); break; + case SR_CONF_PROBE_FACTOR: + if (!cg_is_analog(cg)) + return SR_ERR_NA; + *data = g_variant_new_uint64(devc->dso_probe_factor); + break; case SR_CONF_TRIGGER_SOURCE: *data = g_variant_new_string(trigger_sources[devc->trigger_source]); break; @@ -315,7 +321,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; - uint64_t num_samples; + uint64_t tmp_u64; int trigger_pos; double pos; int idx; @@ -327,12 +333,12 @@ static int config_set(uint32_t key, GVariant *data, // FIXME return mso_configure_rate(sdi, g_variant_get_uint64(data)); case SR_CONF_LIMIT_SAMPLES: - num_samples = g_variant_get_uint64(data); - if (num_samples != MSO_NUM_SAMPLES) { + tmp_u64 = g_variant_get_uint64(data); + if (tmp_u64 != MSO_NUM_SAMPLES) { sr_err("Only %d samples are supported.", MSO_NUM_SAMPLES); return SR_ERR_ARG; } - devc->limit_samples = num_samples; + devc->limit_samples = tmp_u64; break; case SR_CONF_CAPTURE_RATIO: break; @@ -384,6 +390,14 @@ static int config_set(uint32_t key, GVariant *data, return SR_ERR_ARG; devc->coupling = coupling[idx]; break; + case SR_CONF_PROBE_FACTOR: + if (!cg_is_analog(cg)) + return SR_ERR_ARG; + tmp_u64 = g_variant_get_uint64(data); + if (!tmp_u64) + return SR_ERR_ARG; + devc->dso_probe_factor = tmp_u64; + break; default: return SR_ERR_NA; } diff --git a/src/hardware/link-mso19/protocol.c b/src/hardware/link-mso19/protocol.c index 4a8d5713..8abb4ae8 100644 --- a/src/hardware/link-mso19/protocol.c +++ b/src/hardware/link-mso19/protocol.c @@ -171,7 +171,7 @@ SR_PRIV int mso_dac_out(const struct sr_dev_inst *sdi, uint16_t val) SR_PRIV uint16_t mso_calc_raw_from_mv(struct dev_context *devc) { return (uint16_t) (0x200 - - ((devc->dso_trigger_voltage / devc->dso_probe_attn) / + ((devc->dso_trigger_voltage / devc->dso_probe_factor) / devc->vbit)); } @@ -379,7 +379,7 @@ SR_PRIV int mso_receive_data(int fd, int revents, void *cb_data) analog_out[i] = (devc->buffer[i * 3] & 0x3f) | ((devc->buffer[i * 3 + 1] & 0xf) << 6); analog_out[i] = (512.0 - analog_out[i]) * devc->vbit - * devc->dso_probe_attn; + * devc->dso_probe_factor; logic_out[i] = ((devc->buffer[i * 3 + 1] & 0x30) >> 4) | ((devc->buffer[i * 3 + 2] & 0x3f) << 2); } @@ -428,7 +428,6 @@ SR_PRIV int mso_configure_channels(const struct sr_dev_inst *sdi) devc->la_trigger_mask = 0xFF; //the mask for the LA_TRIGGER (bits set to 0 matter, those set to 1 are ignored). devc->la_trigger = 0x00; //The value of the LA byte that generates a trigger event (in that mode). devc->dso_trigger_voltage = 3; - devc->dso_probe_attn = 1; trigger = sr_session_trigger_get(sdi->session); if (!trigger) return SR_OK; diff --git a/src/hardware/link-mso19/protocol.h b/src/hardware/link-mso19/protocol.h index 5d1cb648..86345f49 100644 --- a/src/hardware/link-mso19/protocol.h +++ b/src/hardware/link-mso19/protocol.h @@ -93,7 +93,7 @@ struct dev_context { uint8_t la_threshold; uint64_t cur_rate; const char *coupling; - uint8_t dso_probe_attn; + uint16_t dso_probe_factor; uint8_t trigger_source; uint8_t dso_trigger_slope; uint8_t trigger_outsrc;