]> sigrok.org Git - libsigrok.git/blob - src/hardware/devantech-eth008/protocol.h
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / hardware / devantech-eth008 / protocol.h
1 /*
2  * This file is part of the libsigrok project.
3  *
4  * Copyright (C) 2023 Gerhard Sittig <gerhard.sittig@gmx.net>
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_DEVANTECH_ETH008_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_DEVANTECH_ETH008_PROTOCOL_H
22
23 #include <glib.h>
24 #include <libsigrok/libsigrok.h>
25 #include <stdint.h>
26
27 #include "libsigrok-internal.h"
28
29 #define LOG_PREFIX "devantech-eth008"
30
31 /*
32  * See developer notes in the protocol.c source file for details on the
33  * feature set and communication protocol variants across the series.
34  * This 'model' description tells their discriminating properties apart.
35  */
36 struct devantech_eth008_model {
37         uint8_t code;           /**!< model ID */
38         const char *name;       /**!< model name */
39         size_t ch_count_do;     /**!< digital output channel count */
40         size_t ch_count_di;     /**!< digital input channel count */
41         size_t ch_count_ai;     /**!< analog input channel count */
42         uint8_t min_serno_fw;   /**!< min FW version to get serial nr */
43         size_t width_do;        /**!< digital output image width */
44         size_t width_di;        /**!< digital input image width */
45         uint32_t mask_do_missing; /**!< missing digital output channels */
46 };
47
48 struct channel_group_context {
49         size_t index;
50         size_t number;
51         enum devantech_eth008_channel_type {
52                 DV_CH_DIGITAL_OUTPUT,
53                 DV_CH_DIGITAL_INPUT,
54                 DV_CH_ANALOG_INPUT,
55                 DV_CH_SUPPLY_VOLTAGE,
56         } ch_type;
57 };
58
59 struct dev_context {
60         uint8_t model_code, hardware_version, firmware_version;
61         const struct devantech_eth008_model *model;
62         uint32_t mask_do;
63         uint32_t curr_do;
64         uint32_t curr_di;
65 };
66
67 SR_PRIV int devantech_eth008_get_model(struct sr_serial_dev_inst *serial,
68         uint8_t *model_code, uint8_t *hw_version, uint8_t *fw_version);
69 SR_PRIV int devantech_eth008_get_serno(struct sr_serial_dev_inst *serial,
70         char *text_buffer, size_t text_length);
71 SR_PRIV int devantech_eth008_cache_state(const struct sr_dev_inst *sdi);
72 SR_PRIV int devantech_eth008_query_do(const struct sr_dev_inst *sdi,
73         const struct sr_channel_group *cg, gboolean *on);
74 SR_PRIV int devantech_eth008_setup_do(const struct sr_dev_inst *sdi,
75         const struct sr_channel_group *cg, gboolean on);
76 SR_PRIV int devantech_eth008_query_di(const struct sr_dev_inst *sdi,
77         const struct sr_channel_group *cg, gboolean *on);
78 SR_PRIV int devantech_eth008_query_ai(const struct sr_dev_inst *sdi,
79         const struct sr_channel_group *cg, uint16_t *adc_value);
80 SR_PRIV int devantech_eth008_query_supply(const struct sr_dev_inst *sdi,
81         const struct sr_channel_group *cg, uint16_t *millivolts);
82
83 #endif