]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/demo/api.c
demo: introduce graycode generator mode
[libsigrok.git] / src / hardware / demo / api.c
index 5c1543cb1113229ff7849eaa8d4b1352ef9dff70..d0abe4ff92e053f111c6cb44b7cc9e66f9aa0f50 100644 (file)
@@ -44,6 +44,7 @@ static const char *logic_pattern_str[] = {
        "all-low",
        "all-high",
        "squid",
+       "graycode",
 };
 
 static const uint32_t scanopts[] = {
@@ -119,6 +120,9 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
        devc->cur_samplerate = SR_KHZ(200);
        devc->num_logic_channels = num_logic_channels;
        devc->logic_unitsize = (devc->num_logic_channels + 7) / 8;
+       devc->all_logic_channels_mask = 1UL << 0;
+       devc->all_logic_channels_mask <<= devc->num_logic_channels;
+       devc->all_logic_channels_mask--;
        devc->logic_pattern = DEFAULT_LOGIC_PATTERN;
        devc->num_analog_channels = num_analog_channels;
 
@@ -400,6 +404,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
        devc = sdi->priv;
        devc->sent_samples = 0;
+       devc->sent_frame_samples = 0;
 
        /*
         * Determine the numbers of logic and analog channels that are
@@ -453,6 +458,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
        std_session_send_df_header(sdi);
 
+       if (SAMPLES_PER_FRAME > 0)
+               std_session_send_frame_begin(sdi);
+
        /* We use this timestamp to decide how many more samples to send. */
        devc->start_us = g_get_monotonic_time();
        devc->spent_us = 0;
@@ -464,6 +472,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
        sr_session_source_remove(sdi->session, -1);
+
+       if (SAMPLES_PER_FRAME > 0)
+               std_session_send_frame_end(sdi);
+
        std_session_send_df_end(sdi);
 
        return SR_OK;