X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fbeaglelogic%2Fapi.c;h=3c8cc3b39f72c309c56cccaef94b04b06632285c;hb=5a971f66a37df7c4dbe7799b3c7fc7eb30055a61;hp=cd0023e4dc62be89080df9546810b5611f2a2c73;hpb=f254bc4bba68d2cade0c8f7993d8fa8d3d9b556a;p=libsigrok.git diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index cd0023e4..3c8cc3b3 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -23,16 +23,19 @@ SR_PRIV struct sr_dev_driver beaglelogic_driver_info; static struct sr_dev_driver *di = &beaglelogic_driver_info; -/* Hardware capabiities */ +/* Scan options */ +static const uint32_t scanopts[] = { + SR_CONF_NUM_LOGIC_CHANNELS, +}; + +/* Hardware capabilities */ static const uint32_t devopts[] = { SR_CONF_LOGIC_ANALYZER, - SR_CONF_SAMPLERATE, - SR_CONF_TRIGGER_MATCH, - - SR_CONF_LIMIT_SAMPLES, SR_CONF_CONTINUOUS, - - SR_CONF_NUM_LOGIC_CHANNELS, + SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, + SR_CONF_SAMPLERATE | SR_CONF_GET | SR_CONF_SET, + SR_CONF_TRIGGER_MATCH | SR_CONF_LIST, + SR_CONF_NUM_LOGIC_CHANNELS | SR_CONF_GET, }; /* Trigger matching capabilities */ @@ -52,9 +55,9 @@ SR_PRIV const char *beaglelogic_channel_names[NUM_CHANNELS + 1] = { /* Possible sample rates : 10 Hz to 100 MHz = (100 / x) MHz */ static const uint64_t samplerates[] = { - SR_HZ(10), - SR_MHZ(100), - SR_HZ(1), + SR_HZ(10), + SR_MHZ(100), + SR_HZ(1), }; static int init(struct sr_context *sr_ctx) @@ -62,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; @@ -94,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 */ @@ -131,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); } @@ -302,6 +306,10 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * ret = SR_OK; switch (key) { + case SR_CONF_SCAN_OPTIONS: + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, + scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t)); + break; case SR_CONF_DEVICE_OPTIONS: *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, devopts, ARRAY_SIZE(devopts), sizeof(uint32_t)); @@ -314,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; @@ -353,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;