X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Frdtech-dps%2Fprotocol.h;h=3224e1b5220f1750c9cfe914e458e178efc4aa9b;hb=69b05583955761d24c86cf1f46c1d1dba8c6176c;hp=a5747fd8958eb91054db40fc306f6ba2cbdf6116;hpb=0549416e36730bb455068fd6a68b856d817fb087;p=libsigrok.git diff --git a/src/hardware/rdtech-dps/protocol.h b/src/hardware/rdtech-dps/protocol.h index a5747fd8..3224e1b5 100644 --- a/src/hardware/rdtech-dps/protocol.h +++ b/src/hardware/rdtech-dps/protocol.h @@ -27,9 +27,70 @@ #define LOG_PREFIX "rdtech-dps" +struct rdtech_dps_model { + unsigned int id; + const char *name; + unsigned int max_current; + unsigned int max_voltage; + unsigned int max_power; +}; + struct dev_context { + const struct rdtech_dps_model *model; + struct sr_sw_limits limits; + int expecting_registers; +}; + +enum rdtech_dps_register { + REG_USET = 0x00, /* Mirror of 0x50 */ + REG_ISET = 0x01, /* Mirror of 0x51 */ + REG_UOUT = 0x02, + REG_IOUT = 0x03, + REG_POWER = 0x04, + REG_UIN = 0x05, + REG_LOCK = 0x06, + REG_PROTECT = 0x07, + REG_CV_CC = 0x08, + REG_ENABLE = 0x09, + REG_BACKLIGHT = 0x0A, /* Mirror of 0x55 */ + REG_MODEL = 0x0B, + REG_VERSION = 0x0C, + + REG_PRESET = 0x23, /* Loads a preset into preset 0. */ + +/* + * Add (preset * 0x10) to each of the following, for preset 1-9. + * Preset 0 regs below are the active output settings. + */ + PRE_USET = 0x50, + PRE_ISET = 0x51, + PRE_OVPSET = 0x52, + PRE_OCPSET = 0x53, + PRE_OPPSET = 0x54, + PRE_BACKLIGHT = 0x55, + PRE_DISABLE = 0x56, /* Disable output if 0 is copied here from a preset (1 is no change). */ + PRE_BOOT = 0x57, /* Enable output at boot if 1. */ +}; + +enum rdtech_dps_state { + STATE_NORMAL = 0, + STATE_OVP = 1, + STATE_OCP = 2, + STATE_OPP = 3, }; +enum rdtech_dps_mode { + MODE_CV = 0, + MODE_CC = 1, +}; + +SR_PRIV int rdtech_dps_get_reg(struct sr_modbus_dev_inst *modbus, uint16_t address, uint16_t *value); +SR_PRIV int rdtech_dps_set_reg(struct sr_modbus_dev_inst *modbus, uint16_t address, uint16_t value); + +SR_PRIV int rdtech_dps_get_model_version(struct sr_modbus_dev_inst *modbus, + uint16_t *model, uint16_t *version); + +SR_PRIV int rdtech_dps_capture_start(const struct sr_dev_inst *sdi); SR_PRIV int rdtech_dps_receive_data(int fd, int revents, void *cb_data); #endif