X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fkingst-la2016%2Fapi.c;h=93bc4d668132c2452ebbdbf9ed4e2178926ab807;hb=7047acc8e85b38713450e800037dbcddb1fa98ac;hp=d9cb9b19e0ebf6e95dc7f3f346c458a784c60627;hpb=66a24ab57caebf6ba3abc57ee085a6fd0df37616;p=libsigrok.git diff --git a/src/hardware/kingst-la2016/api.c b/src/hardware/kingst-la2016/api.c index d9cb9b19..93bc4d66 100644 --- a/src/hardware/kingst-la2016/api.c +++ b/src/hardware/kingst-la2016/api.c @@ -1,6 +1,7 @@ /* * This file is part of the libsigrok project. * + * Copyright (C) 2022 Gerhard Sittig * Copyright (C) 2020 Florian Schmidt * Copyright (C) 2013 Marcus Comstedt * Copyright (C) 2013 Bert Vermeulen @@ -517,9 +518,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) * this device. */ devc->fw_uploaded = 0; + devc->usb_pid = pid; if (des.iProduct != LA2016_IPRODUCT_INDEX) { sr_info("Uploading MCU firmware to '%s'.", conn_id); - ret = la2016_upload_firmware(sdi, ctx, dev, pid); + ret = la2016_upload_firmware(sdi, ctx, dev, FALSE); if (ret != SR_OK) { sr_err("MCU firmware upload failed."); kingst_la2016_free_sdi(sdi); @@ -529,6 +531,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) usb->address = 0xff; renum_devices = g_slist_append(renum_devices, sdi); continue; + } else { + ret = la2016_upload_firmware(sdi, NULL, NULL, TRUE); + if (ret != SR_OK) { + sr_err("MCU firmware filename check failed."); + kingst_la2016_free_sdi(sdi); + continue; + } } /* @@ -974,8 +983,10 @@ static int config_list(uint32_t key, GVariant **data, *data = std_gvar_samplerates(ARRAY_AND_SIZE(rates_500mhz)); else if (devc->model->samplerate == SR_MHZ(200)) *data = std_gvar_samplerates(ARRAY_AND_SIZE(rates_200mhz)); - else + else if (devc->model->samplerate == SR_MHZ(100)) *data = std_gvar_samplerates(ARRAY_AND_SIZE(rates_100mhz)); + else + return SR_ERR_BUG; break; case SR_CONF_LIMIT_SAMPLES: *data = std_gvar_tuple_u64(0, LA2016_NUM_SAMPLES_MAX); @@ -1001,6 +1012,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) struct drv_context *drvc; struct sr_context *ctx; struct dev_context *devc; + size_t unitsize; double voltage; int ret; @@ -1010,12 +1022,21 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) devc = sdi->priv; if (!devc->feed_queue) { + if (devc->model->channel_count == 32) + unitsize = sizeof(uint32_t); + else if (devc->model->channel_count == 16) + unitsize = sizeof(uint16_t); + else + return SR_ERR_ARG; devc->feed_queue = feed_queue_logic_alloc(sdi, - LA2016_CONVBUFFER_SIZE, sizeof(uint16_t)); + LA2016_CONVBUFFER_SIZE, unitsize); if (!devc->feed_queue) { sr_err("Cannot allocate buffer for session feed."); return SR_ERR_MALLOC; } + devc->packets_per_chunk = TRANSFER_PACKET_LENGTH; + devc->packets_per_chunk--; + devc->packets_per_chunk /= unitsize + sizeof(uint8_t); } sr_sw_limits_acquisition_start(&devc->sw_limits);