2 * This file is part of the libsigrok project.
4 * Copyright (C) 2015 Aurelien Jacobs <aurel@gnuage.org>
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_MAYNUO_M97_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_MAYNUO_M97_PROTOCOL_H
24 #include <libsigrok/libsigrok.h>
25 #include "libsigrok-internal.h"
27 #define LOG_PREFIX "maynuo-m97"
29 struct maynuo_m97_model {
32 unsigned int max_current;
33 unsigned int max_voltage;
34 unsigned int max_power;
37 /** Private, per-device-instance driver context. */
39 /* Model-specific information */
40 const struct maynuo_m97_model *model;
42 /* Acquisition settings */
43 uint64_t limit_samples;
46 /* Operational state */
49 int expecting_registers;
52 enum maynuo_m97_coil {
75 enum maynuo_m97_register {
120 enum maynuo_m97_mode {
142 SR_PRIV int maynuo_m97_get_bit(struct sr_modbus_dev_inst *modbus,
143 enum maynuo_m97_coil address, int *value);
144 SR_PRIV int maynuo_m97_set_bit(struct sr_modbus_dev_inst *modbus,
145 enum maynuo_m97_coil address, int value);
146 SR_PRIV int maynuo_m97_get_float(struct sr_modbus_dev_inst *modbus,
147 enum maynuo_m97_register address, float *value);
148 SR_PRIV int maynuo_m97_set_float(struct sr_modbus_dev_inst *modbus,
149 enum maynuo_m97_register address, float value);
151 SR_PRIV int maynuo_m97_get_mode(struct sr_modbus_dev_inst *modbus,
152 enum maynuo_m97_mode *mode);
153 SR_PRIV int maynuo_m97_set_mode(struct sr_modbus_dev_inst *modbus,
154 enum maynuo_m97_mode mode);
155 SR_PRIV int maynuo_m97_set_input(struct sr_modbus_dev_inst *modbus, int enable);
156 SR_PRIV int maynuo_m97_get_model_version(struct sr_modbus_dev_inst *modbus,
157 uint16_t *model, uint16_t *version);
159 SR_PRIV const char *maynuo_m97_mode_to_str(enum maynuo_m97_mode mode);
161 SR_PRIV int maynuo_m97_capture_start(const struct sr_dev_inst *sdi);
162 SR_PRIV int maynuo_m97_receive_data(int fd, int revents, void *cb_data);