2 * This file is part of the libsigrok project.
4 * Copyright (C) 2014 Bert Vermeulen <bert@biot.com>
5 * Copyright (C) 2017,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_SCPI_PPS_PROTOCOL_H
22 #define LIBSIGROK_HARDWARE_SCPI_PPS_PROTOCOL_H
26 #include <libsigrok/libsigrok.h>
27 #include "libsigrok-internal.h"
30 #define LOG_PREFIX "scpi-pps"
36 SCPI_CMD_BEEPER_ENABLE,
37 SCPI_CMD_BEEPER_DISABLE,
38 SCPI_CMD_SELECT_CHANNEL,
39 SCPI_CMD_GET_MEAS_VOLTAGE,
40 SCPI_CMD_GET_MEAS_CURRENT,
41 SCPI_CMD_GET_MEAS_POWER,
42 SCPI_CMD_GET_MEAS_FREQUENCY,
43 SCPI_CMD_GET_VOLTAGE_TARGET,
44 SCPI_CMD_SET_VOLTAGE_TARGET,
45 SCPI_CMD_GET_FREQUENCY_TARGET,
46 SCPI_CMD_SET_FREQUENCY_TARGET,
47 SCPI_CMD_GET_CURRENT_LIMIT,
48 SCPI_CMD_SET_CURRENT_LIMIT,
49 SCPI_CMD_GET_OUTPUT_ENABLED,
50 SCPI_CMD_SET_OUTPUT_ENABLE,
51 SCPI_CMD_SET_OUTPUT_DISABLE,
52 SCPI_CMD_GET_OUTPUT_REGULATION,
53 SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION,
54 SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE,
55 SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE,
56 SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION_ACTIVE,
57 SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED,
58 SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE,
59 SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE,
60 SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE,
61 SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD,
62 SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD,
63 SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED,
64 SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE,
65 SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE,
66 SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE,
67 SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD,
68 SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD,
71 /* Defines the SCPI dialect */
72 enum pps_scpi_dialect {
73 SCPI_DIALECT_UNKNOWN = 1,
75 SCPI_DIALECT_HP_66XXB,
81 * These are bit values denoting features a device can have either globally,
82 * in scpi_pps.features, or on a per-channel-group basis in
83 * channel_group_spec.features.
89 PPS_INDEPENDENT = (1 << 3),
90 PPS_SERIES = (1 << 4),
91 PPS_PARALLEL = (1 << 5),
97 const enum pps_scpi_dialect dialect;
99 const uint32_t *devopts;
100 unsigned int num_devopts;
101 const uint32_t *devopts_cg;
102 unsigned int num_devopts_cg;
103 const struct channel_spec *channels;
104 unsigned int num_channels;
105 const struct channel_group_spec *channel_groups;
106 unsigned int num_channel_groups;
107 const struct scpi_command *commands;
108 int (*probe_channels) (struct sr_dev_inst *sdi, struct sr_scpi_hw_info *hwinfo,
109 struct channel_spec **channels, unsigned int *num_channels,
110 struct channel_group_spec **channel_groups, unsigned int *num_channel_groups);
111 int (*init_acquisition) (const struct sr_dev_inst *sdi);
112 int (*update_status) (const struct sr_dev_inst *sdi);
115 struct channel_spec {
117 /* Min, max, programming resolution, spec digits, encoding digits. */
126 struct channel_group_spec {
128 uint64_t channel_index_mask;
130 /* The mqflags will only be applied to voltage and current channels! */
131 enum sr_mqflag mqflags;
136 enum sr_mqflag mqflags;
137 unsigned int hw_output_idx;
142 struct pps_channel_instance {
148 struct pps_channel_group {
159 const struct scpi_pps *device;
161 gboolean beeper_was_set;
162 struct channel_spec *channels;
163 struct channel_group_spec *channel_groups;
165 struct sr_channel *cur_acquisition_channel;
166 struct sr_sw_limits limits;
169 SR_PRIV extern unsigned int num_pps_profiles;
170 SR_PRIV extern const struct scpi_pps pps_profiles[];
172 SR_PRIV int select_channel(const struct sr_dev_inst *sdi, struct sr_channel *ch);
173 SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data);