X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Ffx2lafw%2Fprotocol.c;h=e2112af13abc6d96a0f1893f60451d0e04e22d72;hb=42be2adb5ab329a0b22d9df392d8eca84d5d9acf;hp=8e69b77fd545eb38641d1fe34252cd6b182c16e0;hpb=bee2b0168c087676c1b365861d8c2d4714afa9b9;p=libsigrok.git diff --git a/src/hardware/fx2lafw/protocol.c b/src/hardware/fx2lafw/protocol.c index 8e69b77f..e2112af1 100644 --- a/src/hardware/fx2lafw/protocol.c +++ b/src/hardware/fx2lafw/protocol.c @@ -126,7 +126,7 @@ SR_PRIV int fx2lafw_command_start_acquisition(const struct sr_dev_inst *sdi) cmd.flags |= devc->sample_wide ? CMD_START_FLAGS_SAMPLE_16BIT : CMD_START_FLAGS_SAMPLE_8BIT; /* Enable CTL2 clock. */ - cmd.flags |= (devc->profile->dev_caps & DEV_CAPS_AX_ANALOG) ? CMD_START_FLAGS_CLK_CTL2 : 0; + cmd.flags |= (g_slist_length(devc->enabled_analog_channels) > 0) ? CMD_START_FLAGS_CLK_CTL2 : 0; /* Send the control message. */ ret = libusb_control_transfer(usb->devhdl, LIBUSB_REQUEST_TYPE_VENDOR | @@ -338,9 +338,11 @@ static void finish_acquisition(struct sr_dev_inst *sdi) devc->num_transfers = 0; g_free(devc->transfers); - /* Free the deinterlace buffers if we had them */ - g_free(devc->logic_buffer); - g_free(devc->analog_buffer); + /* Free the deinterlace buffers if we had them. */ + if (g_slist_length(devc->enabled_analog_channels) > 0) { + g_free(devc->logic_buffer); + g_free(devc->analog_buffer); + } if (devc->stl) { soft_trigger_logic_free(devc->stl); @@ -390,6 +392,10 @@ SR_PRIV void mso_send_data_proc(struct sr_dev_inst *sdi, { size_t i; struct dev_context *devc; + struct sr_datafeed_analog analog; + struct sr_analog_encoding encoding; + struct sr_analog_meaning meaning; + struct sr_analog_spec spec; (void)sample_width; @@ -399,9 +405,9 @@ SR_PRIV void mso_send_data_proc(struct sr_dev_inst *sdi, /* Send the logic */ for (i = 0; i < length; i++) { - devc->logic_buffer[i] = data[i * 2]; + devc->logic_buffer[i] = data[i * 2]; /* Rescale to -10V - +10V from 0-255. */ - devc->analog_buffer[i] = data[i * 2 + 1] - 128.0f / 12.8f; + devc->analog_buffer[i] = (data[i * 2 + 1] - 128.0f) / 12.8f; }; const struct sr_datafeed_logic logic = { @@ -417,17 +423,16 @@ SR_PRIV void mso_send_data_proc(struct sr_dev_inst *sdi, sr_session_send(sdi, &logic_packet); - const struct sr_datafeed_analog_old analog = { - .channels = devc->enabled_analog_channels, - .num_samples = length, - .mq = SR_MQ_VOLTAGE, - .unit = SR_UNIT_VOLT, - .mqflags = 0 /*SR_MQFLAG_DC*/, - .data = devc->analog_buffer - }; + sr_analog_init(&analog, &encoding, &meaning, &spec, 2); + analog.meaning->channels = devc->enabled_analog_channels; + analog.meaning->mq = SR_MQ_VOLTAGE; + analog.meaning->unit = SR_UNIT_VOLT; + analog.meaning->mqflags = 0 /* SR_MQFLAG_DC */; + analog.num_samples = length; + analog.data = devc->analog_buffer; const struct sr_datafeed_packet analog_packet = { - .type = SR_DF_ANALOG_OLD, + .type = SR_DF_ANALOG, .payload = &analog };