X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Frigol-ds%2Fapi.c;h=c39e10c80229294afc1dc4d1165059ee9befcb40;hb=0f8bee7162f41095ca1975fec9a87975ce5a554a;hp=8bf40c5e22a9edfb84edda6b685f8d03a55a8a98;hpb=105df67463b84683a35f3474eccc871e5aa4ed0e;p=libsigrok.git diff --git a/src/hardware/rigol-ds/api.c b/src/hardware/rigol-ds/api.c index 8bf40c5e..c39e10c8 100644 --- a/src/hardware/rigol-ds/api.c +++ b/src/hardware/rigol-ds/api.c @@ -126,9 +126,6 @@ static const uint64_t vdivs[][2] = { { 100, 1 }, }; -#define NUM_TIMEBASE ARRAY_SIZE(timebases) -#define NUM_VDIV ARRAY_SIZE(vdivs) - static const char *trigger_sources[] = { "CH1", "CH2", @@ -206,8 +203,8 @@ static const struct rigol_ds_vendor supported_vendors[] = { }; #define VENDOR(x) &supported_vendors[x] -/* vendor, series, protocol, max timebase, min vdiv, number of horizontal divs, - * live waveform samples, memory buffer samples */ +/* vendor, series/name, protocol, data format, max timebase, min vdiv, + * number of horizontal divs, live waveform samples, memory buffer samples */ static const struct rigol_ds_series supported_series[] = { [VS5000] = {VENDOR(RIGOL), "VS5000", PROTOCOL_V1, FORMAT_RAW, {50, 1}, {2, 1000}, 14, 2048, 0}, @@ -397,18 +394,18 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) devc->digital_group); } - for (i = 0; i < NUM_TIMEBASE; i++) { + for (i = 0; i < ARRAY_SIZE(timebases); i++) { if (!memcmp(&devc->model->min_timebase, &timebases[i], sizeof(uint64_t[2]))) devc->timebases = &timebases[i]; if (!memcmp(&devc->model->series->max_timebase, &timebases[i], sizeof(uint64_t[2]))) devc->num_timebases = &timebases[i] - devc->timebases + 1; } - for (i = 0; i < NUM_VDIV; i++) { + for (i = 0; i < ARRAY_SIZE(vdivs); i++) { if (!memcmp(&devc->model->series->min_vdiv, &vdivs[i], sizeof(uint64_t[2]))) { devc->vdivs = &vdivs[i]; - devc->num_vdivs = NUM_VDIV - i; + devc->num_vdivs = ARRAY_SIZE(vdivs) - i; } } @@ -856,7 +853,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * } else { for (i = 0; i < devc->model->analog_channels; i++) { if (cg == devc->analog_groups[i]) { - *data = std_gvar_array_u32(devopts_cg_analog, ARRAY_SIZE(devopts_cg_analog)); + *data = std_gvar_array_u32(ARRAY_AND_SIZE(devopts_cg_analog)); return SR_OK; } } @@ -866,12 +863,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_COUPLING: if (!cg) return SR_ERR_CHANNEL_GROUP; - *data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(coupling)); break; case SR_CONF_PROBE_FACTOR: if (!cg) return SR_ERR_CHANNEL_GROUP; - *data = std_gvar_array_u64(probe_factor, ARRAY_SIZE(probe_factor)); + *data = std_gvar_array_u64(ARRAY_AND_SIZE(probe_factor)); break; case SR_CONF_VDIV: if (!devc) @@ -897,7 +894,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * devc->model->has_digital ? ARRAY_SIZE(trigger_sources) : 4); break; case SR_CONF_TRIGGER_SLOPE: - *data = g_variant_new_strv(trigger_slopes, ARRAY_SIZE(trigger_slopes)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(trigger_slopes)); break; case SR_CONF_DATA_SOURCE: if (!devc) @@ -911,7 +908,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources) - 1); break; default: - *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources)); + *data = g_variant_new_strv(ARRAY_AND_SIZE(data_sources)); break; } break;