X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fdemo%2Fapi.c;h=9c1b7c4466590a7975565b3652e46f7ab6b1dfe8;hb=cf398cc0589fe37589c7e6750cf6b735b77494df;hp=96f5c07818b114e726a9d164f2576cd147667f83;hpb=2ea1fdf12113311cbe1a4316e9e2efe4d8ac40f0;p=libsigrok.git diff --git a/src/hardware/demo/api.c b/src/hardware/demo/api.c index 96f5c078..9c1b7c44 100644 --- a/src/hardware/demo/api.c +++ b/src/hardware/demo/api.c @@ -29,16 +29,23 @@ #include "protocol.h" #define DEFAULT_NUM_LOGIC_CHANNELS 8 -#define DEFAULT_NUM_ANALOG_CHANNELS 4 +#define DEFAULT_ENABLED_LOGIC_CHANNELS 8 +#define DEFAULT_LOGIC_PATTERN PATTERN_SIGROK +#define DEFAULT_NUM_ANALOG_CHANNELS 4 +#define DEFAULT_ENABLED_ANALOG_CHANNELS 4 #define DEFAULT_ANALOG_AMPLITUDE 10 +/* Note: No spaces allowed because of sigrok-cli. */ static const char *logic_pattern_str[] = { "sigrok", "random", "incremental", + "walking-one", + "walking-zero", "all-low", "all-high", + "squid", }; static const uint32_t drvopts[] = { @@ -91,6 +98,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) GSList *l; int num_logic_channels, num_analog_channels, pattern, i; char channel_name[16]; + gboolean enabled; num_logic_channels = DEFAULT_NUM_LOGIC_CHANNELS; num_analog_channels = DEFAULT_NUM_ANALOG_CHANNELS; @@ -114,7 +122,7 @@ 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->logic_pattern = PATTERN_SIGROK; + devc->logic_pattern = DEFAULT_LOGIC_PATTERN; devc->num_analog_channels = num_analog_channels; if (num_logic_channels > 0) { @@ -123,7 +131,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) cg->name = g_strdup("Logic"); for (i = 0; i < num_logic_channels; i++) { sprintf(channel_name, "D%d", i); - ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name); + enabled = (i < DEFAULT_ENABLED_LOGIC_CHANNELS) ? TRUE : FALSE; + ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, enabled, channel_name); cg->channels = g_slist_append(cg->channels, ch); } sdi->channel_groups = g_slist_append(NULL, cg); @@ -140,8 +149,9 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) devc->ch_ag = g_hash_table_new(g_direct_hash, g_direct_equal); for (i = 0; i < num_analog_channels; i++) { snprintf(channel_name, 16, "A%d", i); + enabled = (i < DEFAULT_ENABLED_ANALOG_CHANNELS) ? TRUE : FALSE; ch = sr_channel_new(sdi, i + num_logic_channels, SR_CHANNEL_ANALOG, - TRUE, channel_name); + enabled, channel_name); acg->channels = g_slist_append(acg->channels, ch); /* Every analog channel gets its own channel group as well. */ @@ -472,6 +482,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) /* We use this timestamp to decide how many more samples to send. */ devc->start_us = g_get_monotonic_time(); devc->spent_us = 0; + devc->step = 0; return SR_OK; }