X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhantek-4032l%2Fapi.c;h=9da338ab1cf4a8e5c63836b312587e3dc02e66cf;hb=6745488b1a33acda728440e69f83e8bb0a0663f1;hp=d0cbbd547f733ad9d0aee856ae7d380c64df7ea8;hpb=cbc656e45f18065517416566566860c8d156b3ae;p=libsigrok.git diff --git a/src/hardware/hantek-4032l/api.c b/src/hardware/hantek-4032l/api.c index d0cbbd54..9da338ab 100644 --- a/src/hardware/hantek-4032l/api.c +++ b/src/hardware/hantek-4032l/api.c @@ -167,7 +167,7 @@ static const uint64_t samplerates_hw[] = { SR_MHZ(320), }; -SR_PRIV struct sr_dev_driver hantek_4032l_driver_info; +static struct sr_dev_driver hantek_4032l_driver_info; static GSList *scan(struct sr_dev_driver *di, GSList *options) { @@ -252,7 +252,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) /* Initialize command packet. */ devc->cmd_pkt.magic = H4032L_CMD_PKT_MAGIC; - devc->cmd_pkt.sample_size = 16384; + devc->cmd_pkt.sample_size = 16 * 1024; devc->sample_rate = 0; devc->status = H4032L_STATUS_IDLE; @@ -261,8 +261,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) devc->external_clock = FALSE; devc->clock_edge = H4032L_CLOCK_EDGE_TYPE_RISE; - devc->cur_threshold[0] = 2.5; - devc->cur_threshold[1] = 2.5; + /* Create array of thresholds from min to max. */ + GVariant *thresholds = std_gvar_min_max_step_thresholds( + H4032L_THR_VOLTAGE_MIN, H4032L_THR_VOLTAGE_MAX, + H4032L_THR_VOLTAGE_STEP); + /* Take default threshold value from array (FP workaround). */ + g_variant_get_child(thresholds, H4032L_THR_VOLTAGE_DEFAULT, + "(dd)", &devc->cur_threshold[0], &devc->cur_threshold[1]); sdi->priv = devc; devices = g_slist_append(devices, sdi); @@ -387,7 +392,7 @@ static int config_set(uint32_t key, GVariant *data, int idx; struct dev_context *devc = sdi->priv; struct h4032l_cmd_pkt *cmd_pkt = &devc->cmd_pkt; - uint64_t sample_rate, number_samples; + uint64_t sample_rate, num_samples; double low, high; switch (key) { @@ -406,16 +411,16 @@ static int config_set(uint32_t key, GVariant *data, devc->capture_ratio = g_variant_get_uint64(data); break; case SR_CONF_LIMIT_SAMPLES: - number_samples = g_variant_get_uint64(data); - number_samples += 511; - number_samples &= 0xfffffe00; - if (number_samples < H4043L_NUM_SAMPLES_MIN || - number_samples > H4032L_NUM_SAMPLES_MAX) { + num_samples = g_variant_get_uint64(data); + num_samples += 511; + num_samples &= 0xfffffe00; + if (num_samples < H4043L_NUM_SAMPLES_MIN || + num_samples > H4032L_NUM_SAMPLES_MAX) { sr_err("Invalid sample range 2k...64M: %" - PRIu64 ".", number_samples); + PRIu64 ".", num_samples); return SR_ERR; } - cmd_pkt->sample_size = number_samples; + cmd_pkt->sample_size = num_samples; break; case SR_CONF_VOLTAGE_THRESHOLD: if (!cg) @@ -468,7 +473,8 @@ static int config_list(uint32_t key, GVariant **data, *data = std_gvar_array_i32(ARRAY_AND_SIZE(trigger_matches)); break; case SR_CONF_VOLTAGE_THRESHOLD: - *data = std_gvar_min_max_step_thresholds(-6.0, 6.0, 0.1); + *data = std_gvar_min_max_step_thresholds(H4032L_THR_VOLTAGE_MIN, + H4032L_THR_VOLTAGE_MAX, H4032L_THR_VOLTAGE_STEP); break; case SR_CONF_LIMIT_SAMPLES: *data = std_gvar_tuple_u64(H4043L_NUM_SAMPLES_MIN, H4032L_NUM_SAMPLES_MAX); @@ -615,7 +621,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) return h4032l_stop(sdi); } -SR_PRIV struct sr_dev_driver hantek_4032l_driver_info = { +static struct sr_dev_driver hantek_4032l_driver_info = { .name = "hantek-4032l", .longname = "Hantek 4032L", .api_version = 1,