]> sigrok.org Git - libsigrok.git/blame - src/hardware/rdtech-dps/protocol.h
Add udev rule for Lecroy WaveRunner oscilloscope
[libsigrok.git] / src / hardware / rdtech-dps / protocol.h
CommitLineData
0549416e
JC
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2018 James Churchill <pelrun@gmail.com>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBSIGROK_HARDWARE_RDTECH_DPS_PROTOCOL_H
21#define LIBSIGROK_HARDWARE_RDTECH_DPS_PROTOCOL_H
22
23#include <stdint.h>
24#include <glib.h>
25#include <libsigrok/libsigrok.h>
26#include "libsigrok-internal.h"
27
28#define LOG_PREFIX "rdtech-dps"
29
69b05583
JC
30struct rdtech_dps_model {
31 unsigned int id;
32 const char *name;
33 unsigned int max_current;
34 unsigned int max_voltage;
35 unsigned int max_power;
36};
37
0549416e 38struct dev_context {
69b05583
JC
39 const struct rdtech_dps_model *model;
40 struct sr_sw_limits limits;
41 int expecting_registers;
42};
43
44enum rdtech_dps_register {
45 REG_USET = 0x00, /* Mirror of 0x50 */
46 REG_ISET = 0x01, /* Mirror of 0x51 */
47 REG_UOUT = 0x02,
48 REG_IOUT = 0x03,
49 REG_POWER = 0x04,
50 REG_UIN = 0x05,
51 REG_LOCK = 0x06,
52 REG_PROTECT = 0x07,
53 REG_CV_CC = 0x08,
54 REG_ENABLE = 0x09,
55 REG_BACKLIGHT = 0x0A, /* Mirror of 0x55 */
56 REG_MODEL = 0x0B,
57 REG_VERSION = 0x0C,
58
59 REG_PRESET = 0x23, /* Loads a preset into preset 0. */
60
61/*
62 * Add (preset * 0x10) to each of the following, for preset 1-9.
63 * Preset 0 regs below are the active output settings.
64 */
65 PRE_USET = 0x50,
66 PRE_ISET = 0x51,
67 PRE_OVPSET = 0x52,
68 PRE_OCPSET = 0x53,
69 PRE_OPPSET = 0x54,
70 PRE_BACKLIGHT = 0x55,
71 PRE_DISABLE = 0x56, /* Disable output if 0 is copied here from a preset (1 is no change). */
72 PRE_BOOT = 0x57, /* Enable output at boot if 1. */
73};
74
75enum rdtech_dps_state {
76 STATE_NORMAL = 0,
77 STATE_OVP = 1,
78 STATE_OCP = 2,
79 STATE_OPP = 3,
0549416e
JC
80};
81
69b05583
JC
82enum rdtech_dps_mode {
83 MODE_CV = 0,
84 MODE_CC = 1,
85};
86
87SR_PRIV int rdtech_dps_get_reg(struct sr_modbus_dev_inst *modbus, uint16_t address, uint16_t *value);
88SR_PRIV int rdtech_dps_set_reg(struct sr_modbus_dev_inst *modbus, uint16_t address, uint16_t value);
89
90SR_PRIV int rdtech_dps_get_model_version(struct sr_modbus_dev_inst *modbus,
91 uint16_t *model, uint16_t *version);
92
93SR_PRIV int rdtech_dps_capture_start(const struct sr_dev_inst *sdi);
0549416e
JC
94SR_PRIV int rdtech_dps_receive_data(int fd, int revents, void *cb_data);
95
96#endif