]> sigrok.org Git - libsigrok.git/blobdiff - hardware/asix-sigma/asix-sigma.c
Sigma: Update set_configuration to reflect API.
[libsigrok.git] / hardware / asix-sigma / asix-sigma.c
index f356c8482fdbf3e1791378098cda179a09853faf..3828d55a3a72074a7dda95e95057e15bafc44302 100644 (file)
@@ -760,11 +760,17 @@ static int hw_set_configuration(int device_index, int capability, void *value)
        } else if (capability == HWCAP_PROBECONFIG) {
                ret = configure_probes(sdi, value);
        } else if (capability == HWCAP_LIMIT_MSEC) {
-               sigma->limit_msec = strtoull(value, NULL, 10);
-               ret = SIGROK_OK;
+               sigma->limit_msec = *(uint64_t*) value;
+               if (sigma->limit_msec > 0)
+                       ret = SIGROK_OK;
+               else
+                       ret = SIGROK_ERR;
        } else if (capability == HWCAP_CAPTURE_RATIO) {
-               sigma->capture_ratio = strtoull(value, NULL, 10);
-               ret = SIGROK_OK;
+               sigma->capture_ratio = *(uint64_t*) value;
+               if (sigma->capture_ratio < 0 || sigma->capture_ratio > 100)
+                       ret = SIGROK_ERR;
+               else
+                       ret = SIGROK_OK;
        } else {
                ret = SIGROK_ERR;
        }
@@ -951,7 +957,7 @@ static int receive_data(int fd, int revents, void *user_data)
        const int chunks_per_read = 32;
        unsigned char buf[chunks_per_read * CHUNK_SIZE];
        int bufsz, numchunks, i, newchunks;
-       uint32_t running_msec;
+       uint64_t running_msec;
        struct timeval tv;
 
        fd = fd;
@@ -1209,9 +1215,9 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
 
        sigma = sdi->priv;
 
-       /* If the samplerate has not been set, default to 50 MHz. */
+       /* If the samplerate has not been set, default to 200 KHz. */
        if (sigma->cur_firmware == -1)
-               set_samplerate(sdi, MHZ(50));
+               set_samplerate(sdi, KHZ(200));
 
        /* Enter trigger programming mode. */
        sigma_set_register(WRITE_TRIGGER_SELECT1, 0x20, sigma);