2 * This file is part of the libsigrok project.
4 * Copyright (C) 2020 Timo Kokkonen <tjko@iki.fi>
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_RIGOL_DG_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_RIGOL_DG_PROTOCOL_H
25 #include <libsigrok/libsigrok.h>
26 #include "libsigrok-internal.h"
28 #define LOG_PREFIX "rigol-dg"
30 /* Device/firmware specific quirks. */
31 #define RIGOL_DG_COUNTER_BUG (1UL << 0)
32 #define RIGOL_DG_COUNTER_CH2_CONFLICT (1UL << 1)
34 #define RIGOL_DG_COUNTER_BUG_DELAY (1000 * 1000)
39 PSG_CMD_SELECT_CHANNEL,
46 PSG_CMD_SET_FREQUENCY,
47 PSG_CMD_GET_FREQUENCY,
48 PSG_CMD_SET_AMPLITUDE,
49 PSG_CMD_GET_AMPLITUDE,
54 PSG_CMD_GET_DCYCL_PULSE,
55 PSG_CMD_SET_DCYCL_PULSE,
56 PSG_CMD_GET_DCYCL_SQUARE,
57 PSG_CMD_SET_DCYCL_SQUARE,
58 PSG_CMD_COUNTER_GET_ENABLED,
59 PSG_CMD_COUNTER_SET_ENABLE,
60 PSG_CMD_COUNTER_SET_DISABLE,
61 PSG_CMD_COUNTER_MEASURE,
74 enum waveform_options {
82 struct waveform_spec {
84 enum waveform_type waveform;
93 const struct waveform_spec *waveforms;
94 uint32_t num_waveforms;
97 struct channel_status {
98 enum waveform_type wf;
99 const struct waveform_spec *wf_spec;
109 const uint32_t *devopts;
110 const uint32_t num_devopts;
111 const uint32_t *devopts_cg;
112 const uint32_t num_devopts_cg;
113 const struct channel_spec *channels;
114 const uint32_t num_channels;
115 const struct scpi_command *cmdset;
119 const struct scpi_command *cmdset;
120 const struct device_spec *device;
121 struct channel_status *ch_status;
122 struct sr_sw_limits limits;
123 gboolean counter_enabled;
127 SR_PRIV const char *rigol_dg_waveform_to_string(enum waveform_type type);
128 SR_PRIV const struct waveform_spec *rigol_dg_get_waveform_spec(
129 const struct channel_spec *ch, enum waveform_type wf);
130 SR_PRIV int rigol_dg_get_channel_state(const struct sr_dev_inst *sdi,
131 const struct sr_channel_group *cg);
132 SR_PRIV int rigol_dg_receive_data(int fd, int revents, void *cb_data);