]> sigrok.org Git - libsigrok.git/blobdiff - hardware/asix-sigma/asix-sigma.c
Revert "re-enable filter and datastore for DF_LOGIC"
[libsigrok.git] / hardware / asix-sigma / asix-sigma.c
index abae17a0127ca9552d7ea3715c616a5489f2626d..41df8e6a171130341255edf5c02eaa2a3b5ec159 100644 (file)
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <zlib.h>
 #include <sigrok.h>
+#include <config.h>
 #include "asix-sigma.h"
 
 #define USB_VENDOR                     0xa600
@@ -407,6 +408,7 @@ static int hw_init(char *deviceinfo)
        sigma->num_probes = 0;
        sigma->samples_per_event = 0;
        sigma->capture_ratio = 50;
+       sigma->use_triggers = 0;
 
        /* Register SIGMA device. */
        sdi = sigrok_device_instance_new(0, ST_INITIALIZING,
@@ -654,6 +656,9 @@ static int configure_probes(struct sigrok_device_instance *sdi, GSList *probes)
                                return SIGROK_ERR;
                        }
                }
+
+               if (trigger_set)
+                       sigma->use_triggers = 1;
        }
 
        return SIGROK_OK;
@@ -756,11 +761,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;
        }
@@ -913,20 +924,25 @@ static int decode_chunk_ts(uint8_t *buf, uint16_t *lastts,
                                sent += tosend;
                        }
 
-                       packet.type = DF_TRIGGER;
-                       packet.length = 0;
-                       packet.payload = 0;
-                       session_bus(sigma->session_id, &packet);
+                       /* Only send trigger if explicitly enabled. */
+                       if (sigma->use_triggers) {
+                               packet.type = DF_TRIGGER;
+                               packet.length = 0;
+                               packet.payload = 0;
+                               session_bus(sigma->session_id, &packet);
+                       }
                }
 
                /* Send rest of the chunk to sigrok. */
                tosend = n - sent;
 
-               packet.type = DF_LOGIC;
-               packet.length = tosend * sizeof(uint16_t);
-               packet.unitsize = 2;
-               packet.payload = samples + sent;
-               session_bus(sigma->session_id, &packet);
+               if (tosend > 0) {
+                       packet.type = DF_LOGIC;
+                       packet.length = tosend * sizeof(uint16_t);
+                       packet.unitsize = 2;
+                       packet.payload = samples + sent;
+                       session_bus(sigma->session_id, &packet);
+               }
 
                *lastsample = samples[n - 1];
        }
@@ -942,7 +958,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;
@@ -1200,9 +1216,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);