]> sigrok.org Git - libsigrok.git/blobdiff - hardware/cem-dt-885x/protocol.h
cem-dt-885x: Fix datalog on/off setting in max/min hold mode
[libsigrok.git] / hardware / cem-dt-885x / protocol.h
index f3809fc27d37d53da25f20fb1f45375dc03d8d41..a7d6203baf70151dc92aad4e81d4173e1071cde1 100644 (file)
@@ -35,6 +35,9 @@
 #define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
 
 #define BUF_SIZE 32
+/* When in hold mode, force the last measurement out at this interval.
+ * We're using 50ms, which duplicates the non-hold 20Hz update rate. */
+#define HOLD_REPEAT_INTERVAL 50 * 1000
 
 enum {
        TOKEN_WEIGHT_TIME_FAST = 0x02,
@@ -63,15 +66,25 @@ enum {
        TOKEN_MEAS_RANGE_80_130 = 0x4c,
 };
 
+enum {
+       CMD_TOGGLE_RECORDING = 0x55,
+       CMD_TOGGLE_WEIGHT_FREQ = 0x99,
+       CMD_TOGGLE_WEIGHT_TIME = 0x77,
+       CMD_TOGGLE_HOLD_MAX_MIN = 0x11,
+};
+
 /** Private, per-device-instance driver context. */
 struct dev_context {
+       /* Device state */
+       uint64_t cur_mqflags;
+       int recording;
+
        /* Acquisition settings */
        uint64_t limit_samples;
 
        /* Operational state */
        int state;
        uint64_t num_samples;
-       uint64_t cur_mqflags;
 
        /* Temporary state across callbacks */
        void *cb_data;
@@ -80,7 +93,7 @@ struct dev_context {
        int buf_len;
        unsigned char buf[BUF_SIZE];
        float last_spl;
-
+       gint64 hold_last_sent;
 };
 
 /* Parser state machine. */
@@ -92,5 +105,15 @@ enum {
 };
 
 SR_PRIV int cem_dt_885x_receive_data(int fd, int revents, void *cb_data);
+SR_PRIV int cem_dt_885x_recording_set(const struct sr_dev_inst *sdi, gboolean start);
+SR_PRIV gboolean cem_dt_885x_recording_get(const struct sr_dev_inst *sdi,
+               int *state);
+SR_PRIV int cem_dt_885x_weight_freq_get(const struct sr_dev_inst *sdi);
+SR_PRIV int cem_dt_885x_weight_freq_set(const struct sr_dev_inst *sdi, int freqw);
+SR_PRIV int cem_dt_885x_weight_time_get(const struct sr_dev_inst *sdi);
+SR_PRIV int cem_dt_885x_weight_time_set(const struct sr_dev_inst *sdi, int timew);
+SR_PRIV int cem_dt_885x_holdmode_get(const struct sr_dev_inst *sdi,
+               gboolean *holdmode);
+SR_PRIV int cem_dt_885x_holdmode_set(const struct sr_dev_inst *sdi, int holdmode);
 
 #endif