X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Frdtech-dps%2Fprotocol.h;h=990addb2af707c3c289556f3f81d49eb30e5dd8c;hb=62f3228bc94224e54a1474365a84b7157791dc34;hp=fc23ed3ab1c087e2fdbe86484e330c4728386dc4;hpb=d7a4dad881bf78ce17519d3d7728f74d0ec11415;p=libsigrok.git diff --git a/src/hardware/rdtech-dps/protocol.h b/src/hardware/rdtech-dps/protocol.h index fc23ed3a..990addb2 100644 --- a/src/hardware/rdtech-dps/protocol.h +++ b/src/hardware/rdtech-dps/protocol.h @@ -22,7 +22,7 @@ #ifndef LIBSIGROK_HARDWARE_RDTECH_DPS_PROTOCOL_H #define LIBSIGROK_HARDWARE_RDTECH_DPS_PROTOCOL_H -#include +#include "config.h" #include #include @@ -32,9 +32,14 @@ #define LOG_PREFIX "rdtech-dps" -struct rdtech_dps_model { - unsigned int id; - const char *name; +enum rdtech_dps_model_type { + MODEL_NONE, + MODEL_DPS, + MODEL_RD, +}; + +struct rdtech_dps_range { + const char *range_str; unsigned int max_current; unsigned int max_voltage; unsigned int max_power; @@ -42,6 +47,14 @@ struct rdtech_dps_model { unsigned int voltage_digits; }; +struct rdtech_dps_model { + enum rdtech_dps_model_type model_type; + unsigned int id; + const char *name; + struct rdtech_dps_range *ranges; + unsigned int n_ranges; +}; + struct dev_context { const struct rdtech_dps_model *model; double current_multiplier; @@ -52,6 +65,8 @@ struct dev_context { gboolean curr_ocp_state; gboolean curr_cc_state; gboolean curr_out_state; + unsigned int curr_range; + gboolean acquisition_started; }; /* Container to get and set parameter values. */ @@ -70,6 +85,7 @@ struct rdtech_dps_state { STATE_VOLTAGE = 1 << 10, STATE_CURRENT = 1 << 11, STATE_POWER = 1 << 12, + STATE_RANGE = 1 << 13, } mask; gboolean lock; gboolean output_enabled, regulation_cc; @@ -77,15 +93,25 @@ struct rdtech_dps_state { float voltage_target, current_limit; float ovp_threshold, ocp_threshold; float voltage, current, power; + unsigned int range; }; +enum rdtech_dps_state_context { + ST_CTX_NONE, + ST_CTX_CONFIG, + ST_CTX_PRE_ACQ, + ST_CTX_IN_ACQ, +}; SR_PRIV int rdtech_dps_get_state(const struct sr_dev_inst *sdi, - struct rdtech_dps_state *state); + struct rdtech_dps_state *state, enum rdtech_dps_state_context reason); SR_PRIV int rdtech_dps_set_state(const struct sr_dev_inst *sdi, struct rdtech_dps_state *state); SR_PRIV int rdtech_dps_get_model_version(struct sr_modbus_dev_inst *modbus, - uint16_t *model, uint16_t *version); + enum rdtech_dps_model_type model_type, + uint16_t *model, uint16_t *version, uint32_t *serno); +SR_PRIV void rdtech_dps_update_multipliers(const struct sr_dev_inst *sdi); +SR_PRIV int rdtech_dps_update_range(const struct sr_dev_inst *sdi); SR_PRIV int rdtech_dps_seed_receive(const struct sr_dev_inst *sdi); SR_PRIV int rdtech_dps_receive_data(int fd, int revents, void *cb_data);