]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/hameg-hmo/protocol.c
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / hardware / hameg-hmo / protocol.c
index 1e9622af16db9329de6bc827678202cb20737f53..f355e2c272dc882293857a651aaaf73b0361eb84 100644 (file)
@@ -161,6 +161,11 @@ static const char *coupling_options_rtm300x[] = {
        "GND",
 };
 
+static const char *coupling_options_rth100x[] = {
+       "ACL", // AC with 1 MOhm termination
+       "DCL", // DC with 1 MOhm termination
+};
+
 static const char *scope_trigger_slopes[] = {
        "POS",
        "NEG",
@@ -209,6 +214,18 @@ static const char *an2_dig16_sbus_trigger_sources[] = {
        "D8", "D9", "D10", "D11", "D12", "D13", "D14", "D15",
 };
 
+/* RTH1002 */
+static const char *an2_dig8_isol_trigger_sources[] = {
+       "CH1", "CH2",
+       "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
+};
+
+/* RTH1004 */
+static const char *an4_dig8_isol_trigger_sources[] = {
+       "CH1", "CH2", "CH3", "CH4",
+       "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
+};
+
 /* HMO Compact4 */
 static const char *an4_dig8_trigger_sources[] = {
        "CH1", "CH2", "CH3", "CH4",
@@ -330,7 +347,17 @@ static const uint64_t vdivs[][2] = {
        { 2, 1 },
        { 5, 1 },
        { 10, 1 },
+       { 20, 1 },
+       { 50, 1 },
 };
+/*
+ * It feels a little hacky to use a single table yet use different item
+ * count values here. But it simplifies maintenance, reduces redundancy
+ * by avoiding several vdivs[] table versions of mostly identical content,
+ * still references which declare models' capabilities remain readable.
+ */
+#define VDIVS_COUNT_UPTO_10V   (ARRAY_SIZE(vdivs) - 2)
+#define VDIVS_COUNT_UPTO_50V   (ARRAY_SIZE(vdivs))
 
 static const char *scope_analog_channel_names[] = {
        "CH1", "CH2", "CH3", "CH4",
@@ -377,7 +404,7 @@ static struct scope_config scope_models[] = {
                .num_timebases = ARRAY_SIZE(timebases_hmo_compact),
 
                .vdivs = &vdivs,
-               .num_vdivs = ARRAY_SIZE(vdivs),
+               .num_vdivs = VDIVS_COUNT_UPTO_10V,
 
                .num_ydivs = 8,
 
@@ -418,7 +445,7 @@ static struct scope_config scope_models[] = {
                .num_timebases = ARRAY_SIZE(timebases),
 
                .vdivs = &vdivs,
-               .num_vdivs = ARRAY_SIZE(vdivs),
+               .num_vdivs = VDIVS_COUNT_UPTO_10V,
 
                .num_ydivs = 8,
 
@@ -459,7 +486,7 @@ static struct scope_config scope_models[] = {
                .num_timebases = ARRAY_SIZE(timebases),
 
                .vdivs = &vdivs,
-               .num_vdivs = ARRAY_SIZE(vdivs),
+               .num_vdivs = VDIVS_COUNT_UPTO_10V,
 
                .num_ydivs = 8,
 
@@ -500,7 +527,7 @@ static struct scope_config scope_models[] = {
                .num_timebases = ARRAY_SIZE(timebases_hmo_compact),
 
                .vdivs = &vdivs,
-               .num_vdivs = ARRAY_SIZE(vdivs),
+               .num_vdivs = VDIVS_COUNT_UPTO_10V,
 
                .num_ydivs = 8,
 
@@ -540,7 +567,7 @@ static struct scope_config scope_models[] = {
                .num_timebases = ARRAY_SIZE(timebases),
 
                .vdivs = &vdivs,
-               .num_vdivs = ARRAY_SIZE(vdivs),
+               .num_vdivs = VDIVS_COUNT_UPTO_10V,
 
                .num_ydivs = 8,
 
@@ -580,7 +607,7 @@ static struct scope_config scope_models[] = {
                .num_timebases = ARRAY_SIZE(timebases),
 
                .vdivs = &vdivs,
-               .num_vdivs = ARRAY_SIZE(vdivs),
+               .num_vdivs = VDIVS_COUNT_UPTO_50V,
 
                .num_ydivs = 8,
 
@@ -620,7 +647,7 @@ static struct scope_config scope_models[] = {
                .num_timebases = ARRAY_SIZE(timebases),
 
                .vdivs = &vdivs,
-               .num_vdivs = ARRAY_SIZE(vdivs),
+               .num_vdivs = VDIVS_COUNT_UPTO_50V,
 
                .num_ydivs = 8,
 
@@ -660,7 +687,7 @@ static struct scope_config scope_models[] = {
                .num_timebases = ARRAY_SIZE(timebases),
 
                .vdivs = &vdivs,
-               .num_vdivs = ARRAY_SIZE(vdivs),
+               .num_vdivs = VDIVS_COUNT_UPTO_10V,
 
                .num_ydivs = 8,
 
@@ -700,7 +727,7 @@ static struct scope_config scope_models[] = {
                .num_timebases = ARRAY_SIZE(timebases),
 
                .vdivs = &vdivs,
-               .num_vdivs = ARRAY_SIZE(vdivs),
+               .num_vdivs = VDIVS_COUNT_UPTO_10V,
 
                .num_ydivs = 8,
 
@@ -739,6 +766,86 @@ static struct scope_config scope_models[] = {
                .timebases = &timebases,
                .num_timebases = ARRAY_SIZE(timebases),
 
+               .vdivs = &vdivs,
+               .num_vdivs = VDIVS_COUNT_UPTO_10V,
+
+               .num_ydivs = 8,
+
+               .scpi_dialect = &rohde_schwarz_log_not_pod_scpi_dialect,
+       },
+       {
+               .name = {"RTH1002", NULL},
+               .analog_channels = 2,
+               .digital_channels = 8,
+
+               .analog_names = &scope_analog_channel_names,
+               .digital_names = &scope_digital_channel_names,
+
+               .devopts = &devopts,
+               .num_devopts = ARRAY_SIZE(devopts),
+
+               .devopts_cg_analog = &devopts_cg_analog,
+               .num_devopts_cg_analog = ARRAY_SIZE(devopts_cg_analog),
+
+               .devopts_cg_digital = &devopts_cg_digital,
+               .num_devopts_cg_digital = ARRAY_SIZE(devopts_cg_digital),
+
+               .coupling_options = &coupling_options_rth100x,
+               .num_coupling_options = ARRAY_SIZE(coupling_options_rth100x),
+
+               .logic_threshold = &logic_threshold,
+               .num_logic_threshold = ARRAY_SIZE(logic_threshold),
+               .logic_threshold_for_pod = TRUE,
+
+               .trigger_sources = &an2_dig8_isol_trigger_sources,
+               .num_trigger_sources = ARRAY_SIZE(an2_dig8_isol_trigger_sources),
+
+               .trigger_slopes = &scope_trigger_slopes,
+               .num_trigger_slopes = ARRAY_SIZE(scope_trigger_slopes),
+
+               .timebases = &timebases,
+               .num_timebases = ARRAY_SIZE(timebases),
+
+               .vdivs = &vdivs,
+               .num_vdivs = ARRAY_SIZE(vdivs),
+
+               .num_ydivs = 8,
+
+               .scpi_dialect = &rohde_schwarz_log_not_pod_scpi_dialect,
+       },
+       {
+               .name = {"RTH1004", NULL},
+               .analog_channels = 4,
+               .digital_channels = 8,
+
+               .analog_names = &scope_analog_channel_names,
+               .digital_names = &scope_digital_channel_names,
+
+               .devopts = &devopts,
+               .num_devopts = ARRAY_SIZE(devopts),
+
+               .devopts_cg_analog = &devopts_cg_analog,
+               .num_devopts_cg_analog = ARRAY_SIZE(devopts_cg_analog),
+
+               .devopts_cg_digital = &devopts_cg_digital,
+               .num_devopts_cg_digital = ARRAY_SIZE(devopts_cg_digital),
+
+               .coupling_options = &coupling_options_rth100x,
+               .num_coupling_options = ARRAY_SIZE(coupling_options_rth100x),
+
+               .logic_threshold = &logic_threshold,
+               .num_logic_threshold = ARRAY_SIZE(logic_threshold),
+               .logic_threshold_for_pod = TRUE,
+
+               .trigger_sources = &an4_dig8_isol_trigger_sources,
+               .num_trigger_sources = ARRAY_SIZE(an4_dig8_isol_trigger_sources),
+
+               .trigger_slopes = &scope_trigger_slopes,
+               .num_trigger_slopes = ARRAY_SIZE(scope_trigger_slopes),
+
+               .timebases = &timebases,
+               .num_timebases = ARRAY_SIZE(timebases),
+
                .vdivs = &vdivs,
                .num_vdivs = ARRAY_SIZE(vdivs),
 
@@ -896,7 +1003,7 @@ static int analog_channel_state_get(struct sr_dev_inst *sdi,
                if (sr_scpi_get_string(scpi, command, &tmp_str) != SR_OK)
                        return SR_ERR;
 
-               if (array_float_get(tmp_str, ARRAY_AND_SIZE(vdivs), &j) != SR_OK) {
+               if (array_float_get(tmp_str, *(config->vdivs), config->num_vdivs, &j) != SR_OK) {
                        g_free(tmp_str);
                        sr_err("Could not determine array index for vertical div scale.");
                        return SR_ERR;