]> sigrok.org Git - libsigrok.git/blame - src/hardware/rigol-dg/protocol.h
itech-it8500: avoid "new" as a variable identifier
[libsigrok.git] / src / hardware / rigol-dg / protocol.h
CommitLineData
068db0fb
TK
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2020 Timo Kokkonen <tjko@iki.fi>
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
20#ifndef LIBSIGROK_HARDWARE_RIGOL_DG_PROTOCOL_H
21#define LIBSIGROK_HARDWARE_RIGOL_DG_PROTOCOL_H
22
23#include <stdint.h>
24#include <glib.h>
25#include <libsigrok/libsigrok.h>
26#include "libsigrok-internal.h"
27
28#define LOG_PREFIX "rigol-dg"
29
02feeb30
TK
30enum psg_commands {
31 PSG_CMD_SETUP_REMOTE,
32 PSG_CMD_SETUP_LOCAL,
33 PSG_CMD_SELECT_CHANNEL,
34 PSG_CMD_GET_CHANNEL,
35 PSG_CMD_GET_ENABLED,
36 PSG_CMD_SET_ENABLE,
37 PSG_CMD_SET_DISABLE,
38 PSG_CMD_GET_SOURCE,
39 PSG_CMD_SET_SOURCE,
40 PSG_CMD_SET_FREQUENCY,
41 PSG_CMD_GET_FREQUENCY,
42 PSG_CMD_SET_AMPLITUDE,
43 PSG_CMD_GET_AMPLITUDE,
44 PSG_CMD_GET_OFFSET,
45 PSG_CMD_SET_OFFSET,
46 PSG_CMD_GET_PHASE,
47 PSG_CMD_SET_PHASE,
48 PSG_CMD_GET_DCYCL_PULSE,
49 PSG_CMD_SET_DCYCL_PULSE,
50 PSG_CMD_GET_DCYCL_SQUARE,
51 PSG_CMD_SET_DCYCL_SQUARE,
52 PSG_CMD_COUNTER_GET_ENABLED,
53 PSG_CMD_COUNTER_SET_ENABLE,
54 PSG_CMD_COUNTER_SET_DISABLE,
55 PSG_CMD_COUNTER_MEASURE,
56};
57
58enum waveform_type {
59 WF_DC = 0,
60 WF_SINE,
61 WF_SQUARE,
62 WF_RAMP,
63 WF_PULSE,
64 WF_NOISE,
65 WF_ARB,
66};
67
68enum waveform_options {
69 WFO_FREQUENCY = 1,
70 WFO_AMPLITUDE = 2,
71 WFO_OFFSET = 4,
72 WFO_PHASE = 8,
73 WFO_DUTY_CYCLE = 16,
74};
75
76struct waveform_spec {
77 const char *name;
78 enum waveform_type waveform;
79 double freq_min;
80 double freq_max;
81 double freq_step;
82 uint32_t opts;
83};
84
85struct channel_spec {
86 const char *name;
87 const struct waveform_spec *waveforms;
88 uint32_t num_waveforms;
89};
90
91struct channel_status {
92 enum waveform_type wf;
93 const struct waveform_spec *wf_spec;
94 double freq;
95 double ampl;
96 double offset;
97 double phase;
98};
99
100struct device_spec {
101 const char *vendor;
102 const char *model;
103 const uint32_t *devopts;
104 const uint32_t num_devopts;
105 const uint32_t *devopts_cg;
106 const uint32_t num_devopts_cg;
107 const struct channel_spec *channels;
108 const uint32_t num_channels;
109 const struct scpi_command *cmdset;
110};
111
068db0fb 112struct dev_context {
02feeb30
TK
113 const struct scpi_command *cmdset;
114 const struct device_spec *device;
115 struct channel_status *ch_status;
116 struct sr_sw_limits limits;
117 gboolean counter_enabled;
068db0fb
TK
118};
119
02feeb30
TK
120SR_PRIV const char *rigol_dg_waveform_to_string(enum waveform_type type);
121SR_PRIV const struct waveform_spec *rigol_dg_get_waveform_spec(
122 const struct channel_spec *ch, enum waveform_type wf);
123SR_PRIV int rigol_dg_get_channel_state(const struct sr_dev_inst *sdi,
124 const struct sr_channel_group *cg);
068db0fb
TK
125SR_PRIV int rigol_dg_receive_data(int fd, int revents, void *cb_data);
126
127#endif