2 * This file is part of the libsigrok project.
4 * Copyright (C) 2023 Gerhard Sittig <gerhard.sittig@gmx.net>
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_DEVANTECH_ETH008_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_DEVANTECH_ETH008_PROTOCOL_H
24 #include <libsigrok/libsigrok.h>
27 #include "libsigrok-internal.h"
29 #define LOG_PREFIX "devantech-eth008"
32 * Models have differing capabilities, and slightly different protocol
33 * variants. Setting the output state of individual relays usually takes
34 * one byte which carries the channel number. Requests are of identical
35 * length. Getting relay state takes a variable number of bytes to carry
36 * the bit fields. Response length depends on the model's relay count.
37 * As does request length for setting the state of several relays at the
38 * same time. Some models have gaps in their relay channel numbers
39 * (ETH484 misses R5..R8).
41 * Some models have digital inputs and analog inputs. These features
42 * currently are not supported in this implementation.
44 struct devantech_eth008_model {
50 uint32_t mask_do_missing;
53 enum devantech_eth008_channel_type {
58 struct channel_group_context {
61 enum devantech_eth008_channel_type ch_type;
65 uint8_t model_code, hardware_version, firmware_version;
66 const struct devantech_eth008_model *model;
71 SR_PRIV int devantech_eth008_get_model(struct sr_serial_dev_inst *serial,
72 uint8_t *model_code, uint8_t *hw_version, uint8_t *fw_version);
73 SR_PRIV int devantech_eth008_get_serno(struct sr_serial_dev_inst *serial,
74 char *text_buffer, size_t text_length);
75 SR_PRIV int devantech_eth008_cache_state(const struct sr_dev_inst *sdi);
76 SR_PRIV int devantech_eth008_query_do(const struct sr_dev_inst *sdi,
77 const struct sr_channel_group *cg, gboolean *on);
78 SR_PRIV int devantech_eth008_setup_do(const struct sr_dev_inst *sdi,
79 const struct sr_channel_group *cg, gboolean on);
80 SR_PRIV int devantech_eth008_query_supply(const struct sr_dev_inst *sdi,
81 const struct sr_channel_group *cg, uint16_t *millivolts);