2 * This file is part of the libsigrok project.
4 * Copyright (C) 2018 James Churchill <pelrun@gmail.com>
5 * Copyright (C) 2019 Frank Stettner <frank-stettner@gmx.net>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef LIBSIGROK_HARDWARE_RDTECH_DPS_PROTOCOL_H
22 #define LIBSIGROK_HARDWARE_RDTECH_DPS_PROTOCOL_H
26 #include <libsigrok/libsigrok.h>
27 #include "libsigrok-internal.h"
29 #define LOG_PREFIX "rdtech-dps"
31 struct rdtech_dps_model {
34 unsigned int max_current;
35 unsigned int max_voltage;
36 unsigned int max_power;
40 const struct rdtech_dps_model *model;
41 struct sr_sw_limits limits;
45 enum rdtech_dps_register {
46 REG_USET = 0x00, /* Mirror of 0x50 */
47 REG_ISET = 0x01, /* Mirror of 0x51 */
56 REG_BACKLIGHT = 0x0A, /* Mirror of 0x55 */
60 REG_PRESET = 0x23, /* Loads a preset into preset 0. */
63 * Add (preset * 0x10) to each of the following, for preset 1-9.
64 * Preset 0 regs below are the active output settings.
72 PRE_DISABLE = 0x56, /* Disable output if 0 is copied here from a preset (1 is no change). */
73 PRE_BOOT = 0x57, /* Enable output at boot if 1. */
76 enum rdtech_dps_state {
83 enum rdtech_dps_mode {
88 SR_PRIV int rdtech_dps_get_reg(const struct sr_dev_inst *sdi, uint16_t address, uint16_t *value);
89 SR_PRIV int rdtech_dps_set_reg(const struct sr_dev_inst *sdi, uint16_t address, uint16_t value);
91 SR_PRIV int rdtech_dps_get_model_version(struct sr_modbus_dev_inst *modbus,
92 uint16_t *model, uint16_t *version);
94 SR_PRIV int rdtech_dps_receive_data(int fd, int revents, void *cb_data);