X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhp-3457a%2Fapi.c;h=195b9804f8ed081f0f820a5eebcc3dd9e213afd0;hb=093e1cba6b7bf14cfb77fa36f59b0c16e6fca7cc;hp=eae8195ce48a716b2d8b8159425caa2f9de6f592;hpb=9a093be9f5df5e058e7f4f0c6fcc9ed013f803a2;p=libsigrok.git diff --git a/src/hardware/hp-3457a/api.c b/src/hardware/hp-3457a/api.c index eae8195c..195b9804 100644 --- a/src/hardware/hp-3457a/api.c +++ b/src/hardware/hp-3457a/api.c @@ -31,13 +31,13 @@ static const uint32_t drvopts[] = { }; static const uint32_t devopts[] = { - SR_CONF_CONTINUOUS | SR_CONF_SET, + SR_CONF_CONTINUOUS, SR_CONF_LIMIT_SAMPLES | SR_CONF_SET, SR_CONF_MEASURED_QUANTITY | SR_CONF_SET, SR_CONF_ADC_POWERLINE_CYCLES | SR_CONF_SET | SR_CONF_GET, }; -SR_PRIV struct sr_dev_driver hp_3457a_driver_info; +static struct sr_dev_driver hp_3457a_driver_info; static int create_front_channel(struct sr_dev_inst *sdi, int chan_idx) { @@ -166,26 +166,11 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) return sdi; } -static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) -{ - return std_init(sr_ctx, di, LOG_PREFIX); -} - static GSList *scan(struct sr_dev_driver *di, GSList *options) { return sr_scpi_scan(di->context, options, probe_device); } -static GSList *dev_list(const struct sr_dev_driver *di) -{ - return ((struct drv_context *)(di->context))->instances; -} - -static int dev_clear(const struct sr_dev_driver *di) -{ - return std_dev_clear(di, NULL); -} - /* * We need to set the HP 3457A to a known state, and there are quite a number * of knobs to tweak. Here's a brief explanation of what's going on. For more @@ -213,7 +198,7 @@ static int dev_open(struct sr_dev_inst *sdi) if (sr_scpi_open(scpi) != SR_OK) return SR_ERR; - devc=sdi->priv; + devc = sdi->priv; sr_scpi_send(scpi, "PRESET"); sr_scpi_send(scpi, "INBUF ON"); @@ -229,9 +214,6 @@ static int dev_close(struct sr_dev_inst *sdi) { struct sr_scpi_dev_inst *scpi = sdi->conn; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - /* Disable scan-advance (preserve relay life). */ sr_scpi_send(scpi, "SADV HOLD"); /* Switch back to auto-triggering. */ @@ -244,11 +226,6 @@ static int dev_close(struct sr_dev_inst *sdi) return SR_OK; } -static int cleanup(const struct sr_dev_driver *di) -{ - return dev_clear(di); -} - static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -283,9 +260,6 @@ static int config_set(uint32_t key, GVariant *data, (void)cg; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - devc = sdi->priv; ret = SR_OK; @@ -376,7 +350,7 @@ static void create_channel_index_list(GSList *channels, GArray **arr) * channel in the scan list to the A/D converter. This way, we do not need to * occupy the HP-IB bus to send channel select commands. */ -static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi) { int ret; gboolean front_selected, rear_selected; @@ -387,11 +361,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) GArray *ch_list; GSList *channels; - (void)cb_data; - - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - scpi = sdi->conn; devc = sdi->priv; @@ -400,7 +369,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (ret != SR_OK) return ret; - std_session_send_df_header(sdi, LOG_PREFIX); + std_session_send_df_header(sdi); front_selected = rear_selected = FALSE; devc->active_channels = NULL; @@ -448,30 +417,25 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) +static int dev_acquisition_stop(struct sr_dev_inst *sdi) { struct dev_context *devc; - (void)cb_data; devc = sdi->priv; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - g_slist_free(devc->active_channels); return SR_OK; } -SR_PRIV struct sr_dev_driver hp_3457a_driver_info = { +static struct sr_dev_driver hp_3457a_driver_info = { .name = "hp-3457a", .longname = "HP 3457A", .api_version = 1, - .init = init, - .cleanup = cleanup, + .init = std_init, + .cleanup = std_cleanup, .scan = scan, - .dev_list = dev_list, - .dev_clear = dev_clear, + .dev_list = std_dev_list, .config_get = config_get, .config_set = config_set, .config_list = config_list, @@ -481,3 +445,4 @@ SR_PRIV struct sr_dev_driver hp_3457a_driver_info = { .dev_acquisition_stop = dev_acquisition_stop, .context = NULL, }; +SR_REGISTER_DEV_DRIVER(hp_3457a_driver_info);