From: eightdot Date: Mon, 16 Mar 2015 09:34:08 +0000 (+0100) Subject: Various fixes/updates to make the driver compile. X-Git-Tag: libsigrok-0.4.0~602 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6fcf3f0a22e3dd2467fd09b0cad92b36e0409fc4;p=libsigrok.git Various fixes/updates to make the driver compile. This patchset was originally done by eightdot by manually forward-porting parts of the changes done by Bert Vermeulen (see previous commits), but then heavily modified by Uwe Hermann to be based on top off the (git-)rebased patches from Bert Vermeulen instead. Note: This initial DSLogic code is *not* yet in a working or usable state. It should be considered as a basis for further work only, for now. --- diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index 1e6d4011..46520eb4 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -626,7 +626,6 @@ static int start_transfers(const struct sr_dev_inst *sdi) devc = sdi->priv; usb = sdi->conn; - devc->cb_data = cb_data; devc->sent_samples = 0; devc->acq_aborted = FALSE; devc->empty_transfer_count = 0; @@ -679,9 +678,7 @@ static int start_transfers(const struct sr_dev_inst *sdi) } /* Send header packet to the session bus. */ - std_session_send_df_header(devc->cb_data, LOG_PREFIX); - - usb_source_add(sdi->session, devc->ctx, timeout, receive_data, NULL); + std_session_send_df_header(sdi, LOG_PREFIX); return SR_OK; } @@ -751,12 +748,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) drvc = di->priv; devc = sdi->priv; - /* Configures devc->trigger_* and devc->sample_wide */ - if (fx2lafw_configure_channels(sdi) != SR_OK) { - sr_err("Failed to configure channels."); - return SR_ERR; - } - devc->ctx = drvc->sr_ctx; devc->cb_data = cb_data; devc->sent_samples = 0; @@ -764,7 +755,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) devc->acq_aborted = FALSE; timeout = fx2lafw_get_timeout(devc); - usb_source_add(devc->ctx, timeout, receive_data, NULL); + usb_source_add(sdi->session, devc->ctx, timeout, receive_data, NULL); if (devc->dslogic) { dslogic_trigger_request(sdi); diff --git a/src/hardware/fx2lafw/dslogic.h b/src/hardware/fx2lafw/dslogic.h index 4070eea7..83d5f4e4 100644 --- a/src/hardware/fx2lafw/dslogic.h +++ b/src/hardware/fx2lafw/dslogic.h @@ -18,17 +18,20 @@ * along with this program. If not, see . */ +#ifndef LIBSIGROK_HARDWARE_FX2LAFW_DSLOGIC_H +#define LIBSIGROK_HARDWARE_FX2LAFW_DSLOGIC_H + /* Modified protocol commands & flags used by DSLogic */ #define DS_CMD_GET_FW_VERSION 0xb0 #define DS_CMD_GET_REVID_VERSION 0xb1 -#define DS_CMD_START 0xb2 -#define DS_CMD_FPGA_FW 0xb3 -#define DS_CMD_CONFIG 0xb4 +#define DS_CMD_START 0xb2 +#define DS_CMD_FPGA_FW 0xb3 +#define DS_CMD_CONFIG 0xb4 -#define DS_NUM_TRIGGER_STAGES 16 -#define DS_START_FLAGS_STOP (1 << 7) -#define DS_START_FLAGS_CLK_48MHZ (1 << 6) -#define DS_START_FLAGS_SAMPLE_WIDE (1 << 5) +#define DS_NUM_TRIGGER_STAGES 16 +#define DS_START_FLAGS_STOP (1 << 7) +#define DS_START_FLAGS_CLK_48MHZ (1 << 6) +#define DS_START_FLAGS_SAMPLE_WIDE (1 << 5) enum dslogic_operation_modes { DS_OP_NORMAL, @@ -62,7 +65,7 @@ struct dslogic_trigger_pos { #define _DS_CFG(variable, wordcnt) ((variable << 8) | wordcnt) #define _DS_CFG_PAD(variable, wordcnt) ((_DS_CFG(variable, wordcnt) << 16) | 0xffff) #define DS_CFG_START 0xffffffff -#define DS_CFG_MODE _DS_CFG(0, 1) +#define DS_CFG_MODE _DS_CFG(0, 1) #define DS_CFG_DIVIDER _DS_CFG_PAD(1, 2) #define DS_CFG_COUNT _DS_CFG_PAD(3, 2) #define DS_CFG_TRIG_POS _DS_CFG_PAD(5, 2) @@ -79,7 +82,7 @@ struct dslogic_trigger_pos { #define DS_CFG_TRIG_COUNT1 _DS_CFG_PAD(29, 16) #define DS_CFG_TRIG_LOGIC0 _DS_CFG_PAD(32, 16) #define DS_CFG_TRIG_LOGIC1 _DS_CFG_PAD(33, 16) -#define DS_CFG_END 0x00000000 +#define DS_CFG_END 0x00000000 struct dslogic_fpga_config { uint32_t sync; @@ -120,9 +123,10 @@ struct dslogic_fpga_config { uint32_t end_sync; }; - int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi, const char *filename); int dslogic_start_acquisition(const struct sr_dev_inst *sdi); int dslogic_stop_acquisition(const struct sr_dev_inst *sdi); int dslogic_fpga_configure(const struct sr_dev_inst *sdi); + +#endif diff --git a/src/hardware/fx2lafw/protocol.c b/src/hardware/fx2lafw/protocol.c index e12fd0bd..bd0d4fb8 100644 --- a/src/hardware/fx2lafw/protocol.c +++ b/src/hardware/fx2lafw/protocol.c @@ -140,7 +140,7 @@ SR_PRIV int fx2lafw_command_start_acquisition(const struct sr_dev_inst *sdi) * Check the USB configuration to determine if this is an fx2lafw device. * * @return TRUE if the device's configuration profile matches fx2lafw - * configuration, FALSE otherwise. + * configuration, FALSE otherwise. */ SR_PRIV gboolean match_manuf_prod(libusb_device *dev, const char *manufacturer, const char *product) diff --git a/src/hardware/fx2lafw/protocol.h b/src/hardware/fx2lafw/protocol.h index 3fbf15e0..3be87182 100644 --- a/src/hardware/fx2lafw/protocol.h +++ b/src/hardware/fx2lafw/protocol.h @@ -133,4 +133,5 @@ SR_PRIV void fx2lafw_receive_transfer(struct libusb_transfer *transfer); SR_PRIV size_t fx2lafw_get_buffer_size(struct dev_context *devc); SR_PRIV unsigned int fx2lafw_get_number_of_transfers(struct dev_context *devc); SR_PRIV unsigned int fx2lafw_get_timeout(struct dev_context *devc); + #endif