]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2014 Uwe Hermann <uwe@hermann-uwe.de> | |
5 | * Copyright (C) 2014 Matthias Heidbrink <m-sigrok@heidbrink.biz> | |
6 | * | |
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 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
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. | |
16 | * | |
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/>. | |
19 | */ | |
20 | ||
21 | #ifndef LIBSIGROK_HARDWARE_MANSON_HCS_3XXX_PROTOCOL_H | |
22 | #define LIBSIGROK_HARDWARE_MANSON_HCS_3XXX_PROTOCOL_H | |
23 | ||
24 | #include <stdint.h> | |
25 | #include <string.h> | |
26 | #include <math.h> | |
27 | #include <glib.h> | |
28 | #include <libsigrok/libsigrok.h> | |
29 | #include "libsigrok-internal.h" | |
30 | ||
31 | #define LOG_PREFIX "manson-hcs-3xxx" | |
32 | ||
33 | enum { | |
34 | MANSON_HCS_3100, | |
35 | MANSON_HCS_3102, | |
36 | MANSON_HCS_3104, | |
37 | MANSON_HCS_3150, | |
38 | MANSON_HCS_3200, | |
39 | MANSON_HCS_3202, | |
40 | MANSON_HCS_3204, | |
41 | MANSON_HCS_3300, | |
42 | MANSON_HCS_3302, | |
43 | MANSON_HCS_3304, | |
44 | MANSON_HCS_3400, | |
45 | MANSON_HCS_3402, | |
46 | MANSON_HCS_3404, | |
47 | MANSON_HCS_3600, | |
48 | MANSON_HCS_3602, | |
49 | MANSON_HCS_3604, | |
50 | }; | |
51 | ||
52 | /** Information on a single model. */ | |
53 | struct hcs_model { | |
54 | int model_id; /**< Model info */ | |
55 | const char *name; /**< Model name */ | |
56 | const char *id; /**< Model ID, like delivered by interface */ | |
57 | double voltage[3]; /**< Min, max, step */ | |
58 | double current[3]; /**< Min, max, step */ | |
59 | }; | |
60 | ||
61 | struct dev_context { | |
62 | const struct hcs_model *model; /**< Model information. */ | |
63 | ||
64 | struct sr_sw_limits limits; | |
65 | int64_t req_sent_at; | |
66 | gboolean reply_pending; | |
67 | ||
68 | float current; /**< Last current value [A] read from device. */ | |
69 | float current_max; /**< Output current set. */ | |
70 | float current_max_device;/**< Device-provided maximum output current. */ | |
71 | float voltage; /**< Last voltage value [V] read from device. */ | |
72 | float voltage_max; /**< Output voltage set. */ | |
73 | float voltage_max_device;/**< Device-provided maximum output voltage. */ | |
74 | gboolean cc_mode; /**< Device is in constant current mode (otherwise constant voltage). */ | |
75 | ||
76 | gboolean output_enabled; /**< Is the output enabled? */ | |
77 | ||
78 | char buf[50]; | |
79 | int buflen; | |
80 | }; | |
81 | ||
82 | SR_PRIV int hcs_parse_volt_curr_mode(struct sr_dev_inst *sdi, char **tokens); | |
83 | SR_PRIV int hcs_read_reply(struct sr_serial_dev_inst *serial, int lines, char *buf, int buflen); | |
84 | SR_PRIV int hcs_send_cmd(struct sr_serial_dev_inst *serial, const char *cmd, ...); | |
85 | SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data); | |
86 | ||
87 | #endif |