]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/beaglelogic/api.c
soft-trigger: Add support for pre-triggering.
[libsigrok.git] / src / hardware / beaglelogic / api.c
index 9732311de386cc655257d94f40add7d07ae3b0ac..3c8cc3b39f72c309c56cccaef94b04b06632285c 100644 (file)
@@ -65,12 +65,11 @@ static int init(struct sr_context *sr_ctx)
        return std_init(sr_ctx, di, LOG_PREFIX);
 }
 
-static struct dev_context * beaglelogic_devc_alloc(void)
+static struct dev_context *beaglelogic_devc_alloc(void)
 {
        struct dev_context *devc;
 
-       /* Allocate zeroed structure */
-       devc = g_try_malloc0(sizeof(*devc));
+       devc = g_malloc0(sizeof(struct dev_context));
 
        /* Default non-zero values (if any) */
        devc->fd = -1;
@@ -97,7 +96,10 @@ static GSList *scan(GSList *options)
        if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS))
                return NULL;
 
-       sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, NULL, "BeagleLogic", "1.0");
+       sdi = g_malloc0(sizeof(struct sr_dev_inst));
+       sdi->status = SR_ST_INACTIVE;
+       sdi->model = g_strdup("BeagleLogic");
+       sdi->version = g_strdup("1.0");
        sdi->driver = di;
 
        /* Unless explicitly specified, keep max channels to 8 only */
@@ -134,9 +136,8 @@ static GSList *scan(GSList *options)
 
        /* Fill the channels */
        for (i = 0; i < maxch; i++) {
-               if (!(ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
-                               beaglelogic_channel_names[i])))
-                       return NULL;
+               ch = sr_channel_new(i, SR_CHANNEL_LOGIC, TRUE,
+                               beaglelogic_channel_names[i]);
                sdi->channels = g_slist_append(sdi->channels, ch);
        }
 
@@ -321,7 +322,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                *data = g_variant_builder_end(&gvb);
                break;
        case SR_CONF_TRIGGER_MATCH:
-               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
+               *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
                                soft_trigger_matches, ARRAY_SIZE(soft_trigger_matches),
                                sizeof(int32_t));
                break;
@@ -360,7 +361,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
 
        /* Configure triggers & send header packet */
        if ((trigger = sr_session_trigger_get(sdi->session))) {
-               devc->stl = soft_trigger_logic_new(sdi, trigger);
+               devc->stl = soft_trigger_logic_new(sdi, trigger, 0);
                devc->trigger_fired = FALSE;
        } else
                devc->trigger_fired = TRUE;