]> sigrok.org Git - libsigrok.git/blobdiff - hardware/zeroplus-logic-cube/protocol.c
zeroplus: Add voltage threshold support
[libsigrok.git] / hardware / zeroplus-logic-cube / protocol.c
index 205bf560e168f45f043f11385cadf0e149222203..20adc389eea6679e2e46db4bff457772d98f645b 100644 (file)
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <math.h>
 #include "protocol.h"
 
 SR_PRIV unsigned int get_memory_size(int type)
@@ -91,6 +92,22 @@ SR_PRIV int set_capture_ratio(struct dev_context *devc, uint64_t ratio)
        return SR_OK;
 }
 
+SR_PRIV int set_voltage_threshold(struct dev_context *devc, double thresh)
+{
+       if (thresh > 6.0)
+               thresh = 6.0;
+       if (thresh < -6.0)
+               thresh = -6.0;
+
+       devc->cur_threshold = thresh;
+
+       analyzer_set_voltage_threshold((int) round(-9.1*thresh + 62.6));
+
+       sr_info("Setting voltage threshold to %fV.", devc->cur_threshold);
+
+       return SR_OK;
+}
+
 SR_PRIV void set_triggerbar(struct dev_context *devc)
 {
        unsigned int trigger_depth, triggerbar, ramsize_trigger;