X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=hardware%2Fatten-pps3xxx%2Fprotocol.h;h=1441305d9730c0d28552f0147615c3b63c6c041a;hp=a049c7d8f1d5a7370a95670cb4d55cbd9f7be4fe;hb=43cd4637285833706f8a404ca027bcf0ee75b9ae;hpb=fa0d6afe19c3a545f3f940933ed079966525d142 diff --git a/hardware/atten-pps3xxx/protocol.h b/hardware/atten-pps3xxx/protocol.h index a049c7d8..1441305d 100644 --- a/hardware/atten-pps3xxx/protocol.h +++ b/hardware/atten-pps3xxx/protocol.h @@ -25,21 +25,78 @@ #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