]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/zeroplus-logic-cube/protocol.c
scpi-pps: Add support for Owon P4000 series.
[libsigrok.git] / src / hardware / zeroplus-logic-cube / protocol.c
index ce20ccf4012f1a5fadd9098b82ef32e10b0a8c50..bc517c35acbf526d9c513d11fb50dd9e15417e8a 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include <math.h>
 #include "protocol.h"
 
 SR_PRIV unsigned int get_memory_size(int type)
 {
        if (type == MEMORY_SIZE_8K)
-               return 8 * 1024;
+               return (8 * 1024);
        else if (type <= MEMORY_SIZE_8M)
                return (32 * 1024) << type;
        else
@@ -63,9 +64,9 @@ SR_PRIV int set_limit_samples(struct dev_context *devc, uint64_t samples)
 
        devc->limit_samples = samples;
 
-       if (samples <= 2 * 1024)
+       if (samples <= (2 * 1024))
                devc->memory_size = MEMORY_SIZE_8K;
-       else if (samples <= 16 * 1024)
+       else if (samples <= (16 * 1024))
                devc->memory_size = MEMORY_SIZE_64K;
        else
                devc->memory_size = 19 - clz(samples - 1);
@@ -78,20 +79,6 @@ SR_PRIV int set_limit_samples(struct dev_context *devc, uint64_t samples)
        return SR_OK;
 }
 
-SR_PRIV int set_capture_ratio(struct dev_context *devc, uint64_t ratio)
-{
-       if (ratio > 100) {
-               sr_err("Invalid capture ratio: %" PRIu64 ".", ratio);
-               return SR_ERR_ARG;
-       }
-
-       devc->capture_ratio = ratio;
-
-       sr_info("Setting capture ratio to %d%%.", devc->capture_ratio);
-
-       return SR_OK;
-}
-
 SR_PRIV int set_voltage_threshold(struct dev_context *devc, double thresh)
 {
        if (thresh > 6.0)
@@ -117,7 +104,7 @@ SR_PRIV void set_triggerbar(struct dev_context *devc)
                trigger_depth = devc->limit_samples;
 
        if (devc->trigger)
-               triggerbar = trigger_depth * devc->capture_ratio / 100;
+               triggerbar = (trigger_depth * devc->capture_ratio) / 100;
        else
                triggerbar = 0;