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;
38 const struct maynuo_m97_model *model;
39 struct sr_sw_limits limits;
40 int expecting_registers;
43 enum maynuo_m97_coil {
66 enum maynuo_m97_register {
111 enum maynuo_m97_mode {
133 SR_PRIV int maynuo_m97_get_bit(struct sr_modbus_dev_inst *modbus,
134 enum maynuo_m97_coil address, int *value);
135 SR_PRIV int maynuo_m97_set_bit(struct sr_modbus_dev_inst *modbus,
136 enum maynuo_m97_coil address, int value);
137 SR_PRIV int maynuo_m97_get_float(struct sr_modbus_dev_inst *modbus,
138 enum maynuo_m97_register address, float *value);
139 SR_PRIV int maynuo_m97_set_float(struct sr_modbus_dev_inst *modbus,
140 enum maynuo_m97_register address, float value);
142 SR_PRIV int maynuo_m97_get_mode(struct sr_modbus_dev_inst *modbus,
143 enum maynuo_m97_mode *mode);
144 SR_PRIV int maynuo_m97_set_mode(struct sr_modbus_dev_inst *modbus,
145 enum maynuo_m97_mode mode);
146 SR_PRIV int maynuo_m97_set_input(struct sr_modbus_dev_inst *modbus, int enable);
147 SR_PRIV int maynuo_m97_get_model_version(struct sr_modbus_dev_inst *modbus,
148 uint16_t *model, uint16_t *version);
150 SR_PRIV const char *maynuo_m97_mode_to_str(enum maynuo_m97_mode mode);
152 SR_PRIV int maynuo_m97_capture_start(const struct sr_dev_inst *sdi);
153 SR_PRIV int maynuo_m97_receive_data(int fd, int revents, void *cb_data);