]> sigrok.org Git - libsigrok.git/commitdiff
link-mso19: Add probe_factor config option
authorPaul Kasemir <redacted>
Mon, 14 Dec 2020 04:32:57 +0000 (21:32 -0700)
committerSoeren Apel <redacted>
Wed, 16 Oct 2024 22:08:28 +0000 (00:08 +0200)
src/hardware/link-mso19/api.c
src/hardware/link-mso19/protocol.c
src/hardware/link-mso19/protocol.h

index f0fbd32920fa4d67ba19db06527412e5f617959d..3a720124875e54c324b6539a0d2a0e20e08e8672 100644 (file)
@@ -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;
        }
index 4a8d5713b408823afa0519526ab4d696ba143517..8abb4ae89433dda39589cf0f53efd1ccca529f46 100644 (file)
@@ -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;
index 5d1cb64879a876ab1526252dd4d8f5684cb1ea66..86345f498f73372f8366f4767d856b95236486fa 100644 (file)
@@ -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;