]> sigrok.org Git - libsigrok.git/blobdiff - hardware/atten-pps3xxx/protocol.h
build: Portability fixes.
[libsigrok.git] / hardware / atten-pps3xxx / protocol.h
index a049c7d8f1d5a7370a95670cb4d55cbd9f7be4fe..1441305d9730c0d28552f0147615c3b63c6c041a 100644 (file)
 #include "libsigrok.h"
 #include "libsigrok-internal.h"
 
-/* Message logging helpers with subsystem-specific prefix string. */
 #define LOG_PREFIX "atten-pps3xxx"
 
+/* Packets to/from the device. */
+#define PACKET_SIZE 24
+
+enum {
+       PPS_3203T_3S,
+       PPS_3203T_2S,
+       PPS_3205T_3S,
+       PPS_3205T_2S,
+       PPS_3003S,
+       PPS_3005S,
+};
+
+/* Maximum number of output channels handled by this driver. */
+#define MAX_CHANNELS 3
+
+#define CHANMODE_INDEPENDENT 1 << 0
+#define CHANMODE_SERIES      1 << 1
+#define CHANMODE_PARALLEL    1 << 2
+
+struct channel_spec {
+       /* Min, max, step. */
+       gdouble voltage[3];
+       gdouble current[3];
+};
+
+struct pps_model {
+       int modelid;
+       char *name;
+       int channel_modes;
+       int num_channels;
+       struct channel_spec channels[MAX_CHANNELS];
+};
+
+struct per_channel_config {
+       /* Received from device. */
+       gdouble output_voltage_last;
+       gdouble output_current_last;
+       gboolean output_enabled;
+       /* Set by frontend. */
+       gdouble output_voltage_max;
+       gdouble output_current_max;
+       gboolean output_enabled_set;
+};
+
 /** Private, per-device-instance driver context. */
 struct dev_context {
        /* Model-specific information */
+       struct pps_model *model;
 
-       /* Acquisition settings */
+       /* Acquisition state */
+       gboolean acquisition_running;
 
        /* Operational state */
+       gboolean config_dirty;
+       struct per_channel_config *config;
+       /* Received from device. */
+       int channel_mode;
+       gboolean over_current_protection;
+       /* Set by frontend. */
+       int channel_mode_set;
+       gboolean over_current_protection_set;
 
        /* Temporary state across callbacks */
+       uint8_t packet[PACKET_SIZE];
+       int packet_size;
 
 };
 
 SR_PRIV int atten_pps3xxx_receive_data(int fd, int revents, void *cb_data);
+SR_PRIV void send_packet(const struct sr_dev_inst *sdi, uint8_t *packet);
+SR_PRIV void send_config(const struct sr_dev_inst *sdi);
 
 #endif