]>
Commit | Line | Data |
---|---|---|
0549416e JC |
1 | /* |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2018 James Churchill <pelrun@gmail.com> | |
7c0891b0 | 5 | * Copyright (C) 2019 Frank Stettner <frank-stettner@gmx.net> |
d7a4dad8 | 6 | * Copyright (C) 2021 Gerhard Sittig <gerhard.sittig@gmx.net> |
0549416e JC |
7 | * |
8 | * This program is free software: you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation, either version 3 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 | */ | |
21 | ||
22 | #ifndef LIBSIGROK_HARDWARE_RDTECH_DPS_PROTOCOL_H | |
23 | #define LIBSIGROK_HARDWARE_RDTECH_DPS_PROTOCOL_H | |
24 | ||
d7a4dad8 GS |
25 | #include <config.h> |
26 | ||
0549416e JC |
27 | #include <glib.h> |
28 | #include <libsigrok/libsigrok.h> | |
d7a4dad8 GS |
29 | #include <stdint.h> |
30 | ||
0549416e JC |
31 | #include "libsigrok-internal.h" |
32 | ||
33 | #define LOG_PREFIX "rdtech-dps" | |
34 | ||
69b05583 JC |
35 | struct rdtech_dps_model { |
36 | unsigned int id; | |
37 | const char *name; | |
38 | unsigned int max_current; | |
39 | unsigned int max_voltage; | |
40 | unsigned int max_power; | |
cce6a8a1 FS |
41 | unsigned int current_digits; |
42 | unsigned int voltage_digits; | |
69b05583 JC |
43 | }; |
44 | ||
0549416e | 45 | struct dev_context { |
69b05583 | 46 | const struct rdtech_dps_model *model; |
cce6a8a1 FS |
47 | double current_multiplier; |
48 | double voltage_multiplier; | |
d7a4dad8 GS |
49 | struct sr_sw_limits limits; |
50 | GMutex rw_mutex; | |
51 | gboolean curr_ovp_state; | |
52 | gboolean curr_ocp_state; | |
53 | gboolean curr_cc_state; | |
54 | gboolean curr_out_state; | |
0549416e JC |
55 | }; |
56 | ||
d7a4dad8 GS |
57 | /* Container to get and set parameter values. */ |
58 | struct rdtech_dps_state { | |
59 | enum rdtech_dps_state_mask { | |
60 | STATE_LOCK = 1 << 0, | |
61 | STATE_OUTPUT_ENABLED = 1 << 1, | |
62 | STATE_REGULATION_CC = 1 << 2, | |
63 | STATE_PROTECT_OVP = 1 << 3, | |
64 | STATE_PROTECT_OCP = 1 << 4, | |
65 | STATE_PROTECT_ENABLED = 1 << 5, | |
66 | STATE_VOLTAGE_TARGET = 1 << 6, | |
67 | STATE_CURRENT_LIMIT = 1 << 7, | |
68 | STATE_OVP_THRESHOLD = 1 << 8, | |
69 | STATE_OCP_THRESHOLD = 1 << 9, | |
70 | STATE_VOLTAGE = 1 << 10, | |
71 | STATE_CURRENT = 1 << 11, | |
72 | STATE_POWER = 1 << 12, | |
73 | } mask; | |
74 | gboolean lock; | |
75 | gboolean output_enabled, regulation_cc; | |
76 | gboolean protect_ovp, protect_ocp, protect_enabled; | |
77 | float voltage_target, current_limit; | |
78 | float ovp_threshold, ocp_threshold; | |
79 | float voltage, current, power; | |
69b05583 JC |
80 | }; |
81 | ||
d7a4dad8 GS |
82 | SR_PRIV int rdtech_dps_get_state(const struct sr_dev_inst *sdi, |
83 | struct rdtech_dps_state *state); | |
84 | SR_PRIV int rdtech_dps_set_state(const struct sr_dev_inst *sdi, | |
85 | struct rdtech_dps_state *state); | |
69b05583 JC |
86 | |
87 | SR_PRIV int rdtech_dps_get_model_version(struct sr_modbus_dev_inst *modbus, | |
d7a4dad8 GS |
88 | uint16_t *model, uint16_t *version); |
89 | SR_PRIV int rdtech_dps_seed_receive(const struct sr_dev_inst *sdi); | |
0549416e JC |
90 | SR_PRIV int rdtech_dps_receive_data(int fd, int revents, void *cb_data); |
91 | ||
92 | #endif |