From: Bert Vermeulen Date: Sun, 31 Mar 2013 18:47:01 +0000 (+0200) Subject: zeroplus-logic-cube: fix samplerate setting X-Git-Tag: dsupstream~195 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3316e149d0dd03e65aca72183bc15eb839e392c6;p=libsigrok.git zeroplus-logic-cube: fix samplerate setting --- diff --git a/hardware/zeroplus-logic-cube/api.c b/hardware/zeroplus-logic-cube/api.c index eca4bea4..240de8e6 100644 --- a/hardware/zeroplus-logic-cube/api.c +++ b/hardware/zeroplus-logic-cube/api.c @@ -210,6 +210,33 @@ static int configure_probes(const struct sr_dev_inst *sdi) return SR_OK; } +SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate) +{ + int i; + + for (i = 0; ARRAY_SIZE(samplerates_200); i++) + if (samplerate == samplerates_200[i]) + break; + + if (i == ARRAY_SIZE(samplerates_200) || samplerate > devc->max_samplerate) { + sr_err("Unsupported samplerate: %" PRIu64 "Hz.", samplerate); + return SR_ERR_ARG; + } + + sr_info("Setting samplerate to %" PRIu64 "Hz.", samplerate); + + if (samplerate >= SR_MHZ(1)) + analyzer_set_freq(samplerate / SR_MHZ(1), FREQ_SCALE_MHZ); + else if (samplerate >= SR_KHZ(1)) + analyzer_set_freq(samplerate / SR_KHZ(1), FREQ_SCALE_KHZ); + else + analyzer_set_freq(samplerate, FREQ_SCALE_HZ); + + devc->cur_samplerate = samplerate; + + return SR_OK; +} + static int clear_instances(void) { GSList *l; diff --git a/hardware/zeroplus-logic-cube/protocol.c b/hardware/zeroplus-logic-cube/protocol.c index 268be5dd..e9d158b9 100644 --- a/hardware/zeroplus-logic-cube/protocol.c +++ b/hardware/zeroplus-logic-cube/protocol.c @@ -33,33 +33,6 @@ SR_PRIV unsigned int get_memory_size(int type) return 0; } -SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate) -{ - int i; - - for (i = 0; zp_supported_samplerates_200[i]; i++) - if (samplerate == zp_supported_samplerates_200[i]) - break; - - if (!zp_supported_samplerates_200[i] || samplerate > devc->max_samplerate) { - sr_err("Unsupported samplerate: %" PRIu64 "Hz.", samplerate); - return SR_ERR_ARG; - } - - sr_info("Setting samplerate to %" PRIu64 "Hz.", samplerate); - - if (samplerate >= SR_MHZ(1)) - analyzer_set_freq(samplerate / SR_MHZ(1), FREQ_SCALE_MHZ); - else if (samplerate >= SR_KHZ(1)) - analyzer_set_freq(samplerate / SR_KHZ(1), FREQ_SCALE_KHZ); - else - analyzer_set_freq(samplerate, FREQ_SCALE_HZ); - - devc->cur_samplerate = samplerate; - - return SR_OK; -} - SR_PRIV int set_limit_samples(struct dev_context *devc, uint64_t samples) { devc->limit_samples = samples; diff --git a/hardware/zeroplus-logic-cube/protocol.h b/hardware/zeroplus-logic-cube/protocol.h index 30b217da..ee710cd3 100644 --- a/hardware/zeroplus-logic-cube/protocol.h +++ b/hardware/zeroplus-logic-cube/protocol.h @@ -55,8 +55,6 @@ struct dev_context { const struct zp_model *prof; }; -extern const uint64_t zp_supported_samplerates_200[]; - SR_PRIV unsigned int get_memory_size(int type); SR_PRIV int zp_set_samplerate(struct dev_context *devc, uint64_t samplerate); SR_PRIV int set_limit_samples(struct dev_context *devc, uint64_t samples);