]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/asix-sigma/protocol.c
asix-sigma: rephrase firmware dependent param upload at acquisition start
[libsigrok.git] / src / hardware / asix-sigma / protocol.c
index 02b4b658bd7c2c91a81bf13393f252106f8a519d..2aec141a691345ac56879dfac98d35a881f96b84 100644 (file)
@@ -37,7 +37,7 @@
  * few discrete values, while setter routines accept any user specified
  * rate that is supported by the hardware.
  */
-SR_PRIV const uint64_t samplerates[] = {
+static const uint64_t samplerates[] = {
        /* 50MHz and integer divider. 1/2/5 steps (where possible). */
        SR_KHZ(200), SR_KHZ(500),
        SR_MHZ(1), SR_MHZ(2), SR_MHZ(5),
@@ -46,7 +46,10 @@ SR_PRIV const uint64_t samplerates[] = {
        SR_MHZ(100), SR_MHZ(200),
 };
 
-SR_PRIV const size_t samplerates_count = ARRAY_SIZE(samplerates);
+SR_PRIV GVariant *sigma_get_samplerates_list(void)
+{
+       return std_gvar_samplerates(samplerates, ARRAY_SIZE(samplerates));
+}
 
 static const char *firmware_files[] = {
        [SIGMA_FW_50MHZ] = "asix-sigma-50.fw", /* 50MHz, 8bit divider. */
@@ -455,10 +458,13 @@ SR_PRIV int sigma_write_trigger_lut(struct dev_context *devc,
                wrptr = buf;
                write_u8_inc(&wrptr, tmp[0]);
                write_u8_inc(&wrptr, tmp[1]);
-               ret = sigma_write_register(devc, WRITE_TRIGGER_SELECT, buf, wrptr - buf);
+               ret = sigma_write_register(devc, WRITE_TRIGGER_SELECT,
+                       buf, wrptr - buf);
                if (ret != SR_OK)
                        return ret;
-               ret = sigma_set_register(devc, WRITE_TRIGGER_SELECT2, 0x30 | i);
+               ret = sigma_set_register(devc, WRITE_TRIGGER_SELECT2,
+                       TRGSEL2_RESET | TRGSEL2_LUT_WRITE |
+                       (i & TRGSEL2_LUT_ADDR_MASK));
                if (ret != SR_OK)
                        return ret;
        }
@@ -964,6 +970,13 @@ SR_PRIV int sigma_normalize_samplerate(uint64_t want_rate, uint64_t *have_rate)
        return SR_ERR_ARG;
 }
 
+SR_PRIV uint64_t sigma_get_samplerate(const struct sr_dev_inst *sdi)
+{
+       /* TODO Retrieve value from hardware. */
+       (void)sdi;
+       return samplerates[0];
+}
+
 SR_PRIV int sigma_set_samplerate(const struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
@@ -1789,7 +1802,7 @@ static void add_trigger_function(enum triggerop oper, enum triggerfunc func,
 SR_PRIV int sigma_build_basic_trigger(struct dev_context *devc,
        struct triggerlut *lut)
 {
-       int i,j;
+       int i, j;
        uint16_t masks[2];
 
        memset(lut, 0, sizeof(*lut));