X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fasix-sigma%2Fasix-sigma.c;h=8ff2e159101a79386603f6e7c1a1a83895c3ccb7;hb=65faa197ae4c607c9c127af99af6c8e5b6acd7b3;hp=c014e3a1647e7f743990bb0db289bf2311b5a74a;hpb=64d33dc28e0e815cade56feb65f26a3d36421a96;p=libsigrok.git diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index c014e3a1..8ff2e159 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -41,7 +41,7 @@ #define NUM_PROBES 16 SR_PRIV struct sr_dev_driver asix_sigma_driver_info; -static struct sr_dev_driver *adi = &asix_sigma_driver_info; +static struct sr_dev_driver *di = &asix_sigma_driver_info; static int hw_dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data); static const uint64_t supported_samplerates[] = { @@ -64,22 +64,8 @@ static const uint64_t supported_samplerates[] = { * (the cable has two additional GND pins, and a TI and TO pin) */ static const char *probe_names[NUM_PROBES + 1] = { - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "10", - "11", - "12", - "13", - "14", - "15", - "16", + "1", "2", "3", "4", "5", "6", "7", "8", + "9", "10", "11", "12", "13", "14", "15", "16", NULL, }; @@ -411,7 +397,7 @@ static int clear_instances(void) struct drv_context *drvc; struct dev_context *devc; - drvc = adi->priv; + drvc = di->priv; /* Properly close all devices. */ for (l = drvc->instances; l; l = l->next) { @@ -432,7 +418,7 @@ static int clear_instances(void) return SR_OK; } -static int hw_init(void) +static int hw_init(struct sr_context *sr_ctx) { struct drv_context *drvc; @@ -440,7 +426,8 @@ static int hw_init(void) sr_err("Driver context malloc failed."); return SR_ERR_MALLOC; } - adi->priv = drvc; + drvc->sr_ctx = sr_ctx; + di->priv = drvc; return SR_OK; } @@ -459,7 +446,7 @@ static GSList *hw_scan(GSList *options) (void)options; - drvc = adi->priv; + drvc = di->priv; devices = NULL; clear_instances(); @@ -507,10 +494,10 @@ static GSList *hw_scan(GSList *options) sr_err("%s: sdi was NULL", __func__); goto free; } - sdi->driver = adi; + sdi->driver = di; for (i = 0; probe_names[i]; i++) { - if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, + if (!(probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, probe_names[i]))) return NULL; sdi->probes = g_slist_append(sdi->probes, probe); @@ -535,7 +522,7 @@ static GSList *hw_dev_list(void) { struct drv_context *drvc; - drvc = adi->priv; + drvc = di->priv; return drvc->instances; } @@ -661,6 +648,8 @@ static int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate) int i, ret; struct dev_context *devc = sdi->priv; + ret = SR_OK; + for (i = 0; supported_samplerates[i]; i++) { if (supported_samplerates[i] == samplerate) break; @@ -790,7 +779,7 @@ static int hw_dev_close(struct sr_dev_inst *sdi) static int hw_cleanup(void) { - if (!adi->priv) + if (!di->priv) return SR_OK; clear_instances(); @@ -1066,7 +1055,9 @@ static int receive_data(int fd, int revents, void *cb_data) else hw_dev_acquisition_stop(sdi, sdi); - } else if (devc->state.state == SIGMA_DOWNLOAD) { + } + + if (devc->state.state == SIGMA_DOWNLOAD) { if (devc->state.chunks_downloaded >= numchunks) { /* End of samples. */ packet.type = SR_DF_END; @@ -1289,7 +1280,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, struct sr_datafeed_meta_logic meta; struct clockselect_50 clockselect; int frac, triggerpin, ret; - uint8_t triggerselect; + uint8_t triggerselect = 0; struct triggerinout triggerinout_conf; struct triggerlut lut;