X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fpipistrello-ols%2Fprotocol.c;h=dbe79c6a5a385283e5912d1b12231ab40cc6565c;hb=91057d2fc24c0ca058aa08c8ea6ada4eadf05ffd;hp=3db3aa4b5eaf01d9a6f04f061fc5c4499084fa8c;hpb=6433156c3275df933e4bf6dcfb020c91fca0ae86;p=libsigrok.git diff --git a/src/hardware/pipistrello-ols/protocol.c b/src/hardware/pipistrello-ols/protocol.c index 3db3aa4b..dbe79c6a 100644 --- a/src/hardware/pipistrello-ols/protocol.c +++ b/src/hardware/pipistrello-ols/protocol.c @@ -17,10 +17,9 @@ * along with this program. If not, see . */ +#include #include "protocol.h" -extern SR_PRIV struct sr_dev_driver p_ols_driver_info; - SR_PRIV int write_shortcommand(struct dev_context *devc, uint8_t command) { uint8_t buf[1]; @@ -81,7 +80,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ftdi_get_error_string(devc->ftdic)); return SR_ERR; } - sr_dbg("FTDI chip interface B set successfully."); /* Check for the device and temporarily open it. */ ret = ftdi_usb_open_desc(devc->ftdic, USB_VENDOR_ID, USB_DEVICE_ID, @@ -93,7 +91,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ftdi_get_error_string(devc->ftdic)); return SR_ERR; } - sr_dbg("FTDI device opened successfully."); /* Purge RX/TX buffers in the FTDI chip. */ if ((ret = ftdi_usb_purge_buffers(devc->ftdic)) < 0) { @@ -101,7 +98,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ret, ftdi_get_error_string(devc->ftdic)); goto err_open_close_ftdic; } - sr_dbg("FTDI chip buffers purged successfully."); /* Reset the FTDI bitmode. */ ret = ftdi_set_bitmode(devc->ftdic, 0xff, BITMODE_RESET); @@ -110,7 +106,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ret, ftdi_get_error_string(devc->ftdic)); goto err_open_close_ftdic; } - sr_dbg("FTDI chip bitmode reset successfully."); /* Set the FTDI latency timer to 16. */ ret = ftdi_set_latency_timer(devc->ftdic, 16); @@ -119,7 +114,6 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ret, ftdi_get_error_string(devc->ftdic)); goto err_open_close_ftdic; } - sr_dbg("FTDI chip latency timer set successfully."); /* Set the FTDI read data chunk size to 64kB. */ ret = ftdi_read_data_set_chunksize(devc->ftdic, 64 * 1024); @@ -128,12 +122,12 @@ SR_PRIV int p_ols_open(struct dev_context *devc) ret, ftdi_get_error_string(devc->ftdic)); goto err_open_close_ftdic; } - sr_dbg("FTDI chip read data chunk size set successfully."); - + return SR_OK; err_open_close_ftdic: ftdi_usb_close(devc->ftdic); + return SR_ERR; } @@ -226,7 +220,6 @@ SR_PRIV struct sr_dev_inst *p_ols_get_metadata(uint8_t *buf, int bytes_read, str sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->status = SR_ST_INACTIVE; - sdi->driver = &p_ols_driver_info; sdi->priv = devc; devname = g_string_new(""); @@ -426,7 +419,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) if (bytes_read < 0) { sr_err("Failed to read FTDI data (%d): %s.", bytes_read, ftdi_get_error_string(devc->ftdic)); - sdi->driver->dev_acquisition_stop(sdi, sdi); + sr_dev_acquisition_stop(sdi); return FALSE; } if (bytes_read == 0) { @@ -445,7 +438,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) sr_spew("Received byte 0x%.2x.", byte); if ((devc->flag_reg & FLAG_DEMUX) && (devc->flag_reg & FLAG_RLE)) { - /* RLE in demux mode must be processed differently + /* RLE in demux mode must be processed differently * since in this case the RLE encoder is operating on pairs of samples. */ if (devc->num_bytes == num_channels * 2) { @@ -501,7 +494,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) * sample. */ devc->tmp_sample[i] = devc->sample[j++]; - } + } } /* Clear out the most significant bit of the sample */ devc->tmp_sample[devc->num_bytes - 1] &= 0x7f; @@ -519,7 +512,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) * sample. */ devc->tmp_sample2[i] = devc->sample[j++]; - } + } } /* Clear out the most significant bit of the sample */ devc->tmp_sample2[devc->num_bytes - 1] &= 0x7f; @@ -599,7 +592,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) * sample. */ devc->tmp_sample[i] = devc->sample[j++]; - } + } } memcpy(devc->sample, devc->tmp_sample, 4); sr_spew("Expanded sample: 0x%.8x.", sample); @@ -647,12 +640,12 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) logic.unitsize = 4; logic.data = devc->raw_sample_buf + (devc->limit_samples - devc->num_samples) * 4; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } /* Send the trigger. */ packet.type = SR_DF_TRIGGER; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); /* Send post-trigger samples. */ packet.type = SR_DF_LOGIC; @@ -661,7 +654,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) logic.unitsize = 4; logic.data = devc->raw_sample_buf + devc->trigger_at * 4 + (devc->limit_samples - devc->num_samples) * 4; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } else { /* no trigger was used */ packet.type = SR_DF_LOGIC; @@ -670,11 +663,11 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data) logic.unitsize = 4; logic.data = devc->raw_sample_buf + (devc->limit_samples - devc->num_samples) * 4; - sr_session_send(cb_data, &packet); + sr_session_send(sdi, &packet); } g_free(devc->raw_sample_buf); - sdi->driver->dev_acquisition_stop(sdi, cb_data); + sr_dev_acquisition_stop(sdi); } return TRUE;