]> sigrok.org Git - libsigrok.git/blame - src/hardware/scpi-pps/profiles.c
scpi-pps: Generalize vendor name cleanup.
[libsigrok.git] / src / hardware / scpi-pps / profiles.c
CommitLineData
d4eabea8
BV
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2014 Bert Vermeulen <bert@biot.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
22c18b03 20#include <string.h>
d4eabea8
BV
21#include "protocol.h"
22
23#define CH_IDX(x) (1 << x)
24
22c18b03
BV
25const char *pps_vendors[][2] = {
26 { "RIGOL TECHNOLOGIES", "Rigol" },
d4eabea8
BV
27};
28
22c18b03
BV
29const char *get_vendor(const char *raw_vendor)
30{
31 unsigned int i;
32
33 for (i = 0; i < ARRAY_SIZE(pps_vendors); i++) {
34 if (!strcasecmp(raw_vendor, pps_vendors[i][0]))
35 return pps_vendors[i][1];
36 }
37
38 return raw_vendor;
39}
40
d4eabea8
BV
41/* Rigol DP800 series */
42static const int32_t devopts_rigol_dp800[] = {
43 SR_CONF_POWER_SUPPLY,
44 SR_CONF_CONTINUOUS,
45 SR_CONF_OVER_TEMPERATURE_PROTECTION,
46};
47
48static const int32_t devopts_cg_rigol_dp800[] = {
49 SR_CONF_OUTPUT_REGULATION,
50 SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED,
51 SR_CONF_OVER_VOLTAGE_PROTECTION_ACTIVE,
52 SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD,
53 SR_CONF_OVER_CURRENT_PROTECTION_ENABLED,
54 SR_CONF_OVER_CURRENT_PROTECTION_ACTIVE,
55 SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD,
56 SR_CONF_OUTPUT_VOLTAGE,
57 SR_CONF_OUTPUT_VOLTAGE_MAX,
58 SR_CONF_OUTPUT_CURRENT,
59 SR_CONF_OUTPUT_CURRENT_MAX,
60 SR_CONF_OUTPUT_ENABLED,
61};
62
63struct channel_spec ch_rigol_dp800[] = {
64 { "1", { 0, 30, 0.010 }, { 0, 3, 0.010 } },
65 { "2", { 0, 30, 0.010 }, { 0, 3, 0.010 } },
66 { "3", { 0, 5, 0.010 }, { 0, 3, 0.010 } },
67};
68
69struct channel_group_spec cg_rigol_dp800[] = {
70 { "1", CH_IDX(0), PPS_OVP | PPS_OCP },
71 { "2", CH_IDX(1), PPS_OVP | PPS_OCP },
72 { "3", CH_IDX(2), PPS_OVP | PPS_OCP },
73};
74
75struct scpi_command cmd_rigol_dp800[] = {
76 { SCPI_CMD_KEY_UNLOCK, "SYST:KLOCK OFF" },
77 { SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT? CH%s" },
78 { SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR? CH%s" },
79 { SCPI_CMD_GET_MEAS_POWER, ":MEAS:POWE? CH%s" },
80 { SCPI_CMD_GET_VOLTAGE_MAX, ":SOUR%s:VOLT?" },
81 { SCPI_CMD_SET_VOLTAGE_MAX, ":SOUR%s:VOLT %.6f" },
82 { SCPI_CMD_GET_CURRENT_MAX, ":SOUR%s:CURR?" },
83 { SCPI_CMD_SET_CURRENT_MAX, ":SOUR%s:CURR %.6f" },
84 { SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP? CH%s" },
85 { SCPI_CMD_SET_OUTPUT_ENABLED, ":OUTP CH%s,%s" },
86 { SCPI_CMD_GET_OUTPUT_REGULATION, ":OUTP:MODE? CH%s" },
87 { SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION, ":SYST:OTP?" },
88 { SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION, ":SYST:OTP %s" },
89 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED, ":OUTP:OVP? CH%s" },
90 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLED, ":OUTP:OVP CH%s,%s" },
91 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, ":OUTP:OVP:QUES? CH%s" },
92 { SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL? CH%s" },
93 { SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL CH%s,%.6f" },
94 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":OUTP:OCP? CH%s" },
95 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLED, ":OUTP:OCP CH%s,%s" },
96 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE, ":OUTP:OCP:QUES? CH%s" },
97 { SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL? CH%s" },
98 { SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL CH%s,%.6f" },
99};
100
101SR_PRIV const struct scpi_pps pps_profiles[] = {
102 /* Rigol DP800 series */
22c18b03 103 { "Rigol", "DP832", PPS_OTP,
d4eabea8
BV
104 ARRAY_AND_SIZE(devopts_rigol_dp800),
105 ARRAY_AND_SIZE(devopts_cg_rigol_dp800),
106 ARRAY_AND_SIZE(ch_rigol_dp800),
107 ARRAY_AND_SIZE(cg_rigol_dp800),
108 ARRAY_AND_SIZE(cmd_rigol_dp800),
109 },
110};
111SR_PRIV unsigned int num_pps_profiles = ARRAY_SIZE(pps_profiles);
112