2 * This file is part of the libsigrok project.
4 * Copyright (C) 2018 Bastian Schmitz <bastian.schmitz@udo.edu>
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.
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.
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/>.
20 #ifndef LIBSIGROK_HARDWARE_GWINSTEK_GPD_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_GWINSTEK_GPD_PROTOCOL_H
25 #include <libsigrok/libsigrok.h>
26 #include "libsigrok-internal.h"
28 #define LOG_PREFIX "gwinstek-gpd"
34 /* Maximum number of output channels handled by this driver. */
35 #define MAX_CHANNELS 2
37 #define CHANMODE_INDEPENDENT (1 << 0)
38 #define CHANMODE_SERIES (1 << 1)
39 #define CHANMODE_PARALLEL (1 << 2)
51 unsigned int num_channels;
52 struct channel_spec channels[MAX_CHANNELS];
55 struct per_channel_config {
56 /* Received from device. */
57 float output_voltage_last;
58 float output_current_last;
59 /* Set by frontend. */
60 float output_voltage_max;
61 float output_current_max;
65 /* Received from device. */
66 gboolean output_enabled;
68 gboolean reply_pending;
70 struct sr_sw_limits limits;
72 struct per_channel_config *config;
73 const struct gpd_model *model;
76 SR_PRIV int gpd_send_cmd(struct sr_serial_dev_inst *serial, const char *cmd, ...);
77 SR_PRIV int gpd_receive_data(int fd, int revents, void *cb_data);
78 SR_PRIV int gpd_receive_reply(struct sr_serial_dev_inst *serial, char *buf, int buflen);