X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fzeroplus-logic-cube%2Fzeroplus.c;h=eef93cbfe265e592f187c578105484886f5873c9;hb=921e753f7e2bef9590b1e344200b736a0faa18cc;hp=8b18cc67e890905c036b2b73135a4aabd41daea0;hpb=408e719989d0b4d4408439bf84b87edea8ce85d6;p=libsigrok.git diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index 8b18cc67..eef93cbf 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -140,36 +140,37 @@ static unsigned int get_memory_size(int type) return 0; } -static int opendev3(struct sigrok_device_instance **sdi, libusb_device *dev, +static int opendev4(struct sigrok_device_instance **sdi, libusb_device *dev, struct libusb_device_descriptor *des) { - int j, err; + unsigned int i; + int err; if ((err = libusb_get_device_descriptor(dev, des))) { g_warning("failed to get device descriptor: %d", err); return -1; } - if (des.idVendor != USB_VENDOR) + if (des->idVendor != USB_VENDOR) return 0; if (libusb_get_bus_number(dev) == (*sdi)->usb->bus && libusb_get_device_address(dev) == (*sdi)->usb->address) { - for (j = 0; j < ARRAY_SIZE(zeroplus_models); j++) { - if (!(des.idProduct == zeroplus_models[j].pid)) + for (i = 0; i < ARRAY_SIZE(zeroplus_models); i++) { + if (!(des->idProduct == zeroplus_models[i].pid)) continue; - g_message("Found PID=%04X (%s)", des.idProduct, - zeroplus_models[j].model_name); - num_channels = zeroplus_models[j].channels; - memory_size = zeroplus_models[j].sample_depth * 1024; + g_message("Found PID=%04X (%s)", des->idProduct, + zeroplus_models[i].model_name); + num_channels = zeroplus_models[i].channels; + memory_size = zeroplus_models[i].sample_depth * 1024; break; } if (num_channels == 0) { g_warning("Unknown ZeroPlus device %04X", - des.idProduct); + des->idProduct); return -2; } @@ -193,7 +194,6 @@ struct sigrok_device_instance *zp_open_device(int device_index) struct sigrok_device_instance *sdi; libusb_device **devlist; struct libusb_device_descriptor des; - unsigned int j; int err, i; if (!(sdi = get_sigrok_device_instance(device_instances, device_index))) @@ -205,7 +205,7 @@ struct sigrok_device_instance *zp_open_device(int device_index) libusb_get_device_list(usb_context, &devlist); for (i = 0; devlist[i]; i++) { /* TODO: Error handling. */ - err = opendev3(&sdi, devlist[i], &des); + err = opendev4(&sdi, devlist[i], &des); } } else { /* Status must be ST_ACTIVE, i.e. already in use... */ @@ -340,7 +340,6 @@ static int hw_opendev(int device_index) } analyzer_reset(sdi->usb->devhdl); analyzer_initialize(sdi->usb->devhdl); - analyzer_configure(sdi->usb->devhdl); analyzer_set_memory_size(MEMORY_SIZE_512K); // analyzer_set_freq(g_freq, g_freq_scale); @@ -444,7 +443,7 @@ static int *hw_get_capabilities(void) /* TODO: This will set the same samplerate for all devices. */ static int set_configuration_samplerate(uint64_t samplerate) { - g_message("%s(%llu)", __FUNCTION__, samplerate); + g_message("%s(%" PRIu64 ")", __FUNCTION__, samplerate); if (samplerate > MHZ(1)) analyzer_set_freq(samplerate / MHZ(1), FREQ_SCALE_MHZ); else if (samplerate > KHZ(1)) @@ -472,7 +471,8 @@ static int hw_set_configuration(int device_index, int capability, void *value) case HWCAP_PROBECONFIG: return configure_probes((GSList *) value); case HWCAP_LIMIT_SAMPLES: - limit_samples = strtoull(value, NULL, 10); + tmp_u64 = value; + limit_samples = *tmp_u64; return SIGROK_OK; default: return SIGROK_ERR; @@ -491,6 +491,9 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id) if (!(sdi = get_sigrok_device_instance(device_instances, device_index))) return SIGROK_ERR; + /* push configured settings to device */ + analyzer_configure(sdi->usb->devhdl); + analyzer_start(sdi->usb->devhdl); g_message("Waiting for data"); analyzer_wait_data(sdi->usb->devhdl); @@ -525,8 +528,9 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id) PACKET_SIZE, res); #endif - packet.type = DF_LOGIC32; + packet.type = DF_LOGIC; packet.length = PACKET_SIZE; + packet.unitsize = 4; packet.payload = buf; session_bus(session_device_id, &packet); }