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_TRIGGER_LEVEL | SR_CONF_GET | SR_CONF_SET,
SR_CONF_PROBE_FACTOR | SR_CONF_GET | SR_CONF_SET,
};
}
}
+static void mso_limit_trigger_level(struct dev_context *devc)
+{
+ double max_level = 2.0 * devc->dso_probe_factor;
+ if (devc->dso_trigger_level < -max_level) {
+ devc->dso_trigger_adjusted = -max_level;
+ } else if (devc->dso_trigger_level > max_level) {
+ devc->dso_trigger_adjusted = max_level;
+ } else if (devc->dso_trigger_level != devc->dso_trigger_adjusted){
+ devc->dso_trigger_adjusted = devc->dso_trigger_level;
+ } else {
+ return;
+ }
+ sr_info("Adjusted dso trigger level to %f", devc->dso_trigger_adjusted);
+}
+
static GSList* scan_handle_port(GSList *devices, struct sp_port *port)
{
int usb_vid, usb_pid;
else
return SR_ERR_NA;
break;
+ case SR_CONF_TRIGGER_LEVEL:
+ if (!cg_is_analog(cg))
+ return SR_ERR_ARG;
+ *data = g_variant_new_double(devc->dso_trigger_level);
+ break;
default:
return SR_ERR_NA;
}
}
mso_update_trigger_slope(devc);
break;
+ case SR_CONF_TRIGGER_LEVEL:
+ if (!cg_is_analog(cg))
+ return SR_ERR_ARG;
+ devc->dso_trigger_level = g_variant_get_double(data);
+ mso_limit_trigger_level(devc);
+ break;
case SR_CONF_HORIZ_TRIGGERPOS:
pos = g_variant_get_double(data);
if (pos < 0 || pos > 255) {
if (!tmp_u64)
return SR_ERR_ARG;
devc->dso_probe_factor = tmp_u64;
+ mso_limit_trigger_level(devc);
break;
default:
return SR_ERR_NA;
SR_PRIV int mso_configure_trigger(const struct sr_dev_inst *sdi)
{
struct dev_context *devc = sdi->priv;
- uint16_t threshold_value = mso_calc_raw_from_mv(devc);
+ uint16_t threshold_value = mso_calc_trigger_threshold(devc);
- // Use 0x200 temporary value till we can properly calculate it.
- threshold_value = 0x200;
TRIG_UPDATE_THRESH_MSB(devc->ctltrig, threshold_value);
uint16_t ops[] = {
return mso_send_control_message(devc->serial, ARRAY_AND_SIZE(ops));
}
-SR_PRIV uint16_t mso_calc_raw_from_mv(struct dev_context *devc)
+SR_PRIV uint16_t mso_calc_trigger_threshold(struct dev_context *devc)
{
return (uint16_t) (0x200 -
- ((devc->dso_trigger_voltage / devc->dso_probe_factor) /
+ ((devc->dso_trigger_adjusted / devc->dso_probe_factor) /
devc->vbit));
}
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;
trigger = sr_session_trigger_get(sdi->session);
if (!trigger)
return SR_OK;
uint8_t la_trigger_slope;
uint8_t la_trigger;
uint8_t la_trigger_mask;
- double dso_trigger_voltage;
+ double dso_trigger_level;
+ double dso_trigger_adjusted;
uint16_t dso_trigger_width;
struct mso_prototrig protocol_trigger;
uint16_t buffer_n;
SR_PRIV int mso_arm(const struct sr_dev_inst *sdi);
SR_PRIV int mso_force_capture(struct sr_dev_inst *sdi);
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);
+SR_PRIV uint16_t mso_calc_trigger_threshold(struct dev_context *devc);
SR_PRIV int mso_reset_fsm(const struct sr_dev_inst *sdi);
SR_PRIV int mso_configure_channels(const struct sr_dev_inst *sdi);