]> sigrok.org Git - libsigrok.git/blame - src/hardware/pce-322a/protocol.h
uni-t-ut181a: silence compiler warning, use of uninitialized variable
[libsigrok.git] / src / hardware / pce-322a / protocol.h
CommitLineData
5a2c71cc
GH
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2016 George Hopkins <george-hopkins@null.net>
ae87e02f 5 * Copyright (C) 2016 Matthieu Guillaumin <matthieu@guillaum.in>
5a2c71cc
GH
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef LIBSIGROK_HARDWARE_PCE_322A_PROTOCOL_H
22#define LIBSIGROK_HARDWARE_PCE_322A_PROTOCOL_H
23
24#include <stdint.h>
25#include <glib.h>
26#include <libsigrok/libsigrok.h>
27#include "libsigrok-internal.h"
28
29#define LOG_PREFIX "pce-322a"
30
31#define BUFFER_SIZE 13
ae87e02f
MG
32#define MEM_USAGE_BUFFER_SIZE 9
33#define MEM_DATA_BUFFER_SIZE 11
5a2c71cc
GH
34
35enum {
36 CMD_CONNECT = 0xacff,
37 CMD_DISCONNECT = 0xcaff,
38 CMD_TOGGLE_WEIGHT_FREQ = 0xaaf1,
39 CMD_TOGGLE_MEAS_RANGE = 0xaaf2,
40 CMD_TOGGLE_HOLD_MAX_MIN = 0xaaf3,
41 CMD_TOGGLE_WEIGHT_TIME = 0xaaf4,
42 CMD_TOGGLE_HOLD = 0xaaf5,
43 CMD_TOGGLE_BACKLIGHT = 0xaaf6,
44 CMD_TOGGLE_DATE_TIME = 0xaaf7,
45 CMD_LOG_START = 0x7e00,
46 CMD_MEMORY_STATUS = 0xadda,
47 CMD_MEMORY_TRANSFER = 0xd3da,
48 CMD_MEMORY_CLEAR = 0xaac1,
49 CMD_POWER_OFF = 0xaaf8,
50};
51
52enum {
53 MEAS_RANGE_30_130 = 0,
54 MEAS_RANGE_30_80 = 1,
55 MEAS_RANGE_50_100 = 2,
56 MEAS_RANGE_80_130 = 3,
57};
58
ae87e02f
MG
59enum {
60 DATA_SOURCE_LIVE,
61 DATA_SOURCE_MEMORY,
62};
63
64enum {
65 MEM_STATE_REQUEST_MEMORY_USAGE,
66 MEM_STATE_GET_MEMORY_USAGE,
67 MEM_STATE_REQUEST_MEMORY_BLOCK,
68 MEM_STATE_GET_MEMORY_BLOCK,
69};
70
5a2c71cc 71struct dev_context {
5a2c71cc
GH
72 uint64_t cur_mqflags;
73 uint8_t cur_meas_range;
74
ae87e02f 75 uint8_t cur_data_source;
5a2c71cc
GH
76 uint64_t limit_samples;
77
5a2c71cc
GH
78 uint64_t num_samples;
79
ae87e02f
MG
80 /* Memory reading state */
81 uint8_t memory_state; /* State for requesting memory usage before memory blocks. */
82 uint16_t memory_block_usage; /* Store number of memory blocks used. */
83 uint8_t memory_last_block_usage; /* Store size of last memory block. */
84 uint16_t memory_block_counter; /* Number of memory blocks retrieved so far. */
85 uint8_t memory_block_cursor; /* Number of bytes retrieved in current memory block. */
86
5a2c71cc
GH
87 uint8_t buffer[BUFFER_SIZE];
88 int buffer_len;
ae87e02f 89 int buffer_skip; /* Number of bytes to skip in memory mode. */
5a2c71cc
GH
90};
91
92SR_PRIV int pce_322a_connect(const struct sr_dev_inst *sdi);
93SR_PRIV int pce_322a_disconnect(const struct sr_dev_inst *sdi);
ae87e02f
MG
94SR_PRIV int pce_322a_memory_status(const struct sr_dev_inst *sdi);
95SR_PRIV int pce_322a_memory_clear(const struct sr_dev_inst *sdi);
96SR_PRIV int pce_322a_memory_block(const struct sr_dev_inst *sdi, uint16_t memblk);
5a2c71cc
GH
97SR_PRIV int pce_322a_receive_data(int fd, int revents, void *cb_data);
98SR_PRIV uint64_t pce_322a_weight_freq_get(const struct sr_dev_inst *sdi);
99SR_PRIV int pce_322a_weight_freq_set(const struct sr_dev_inst *sdi, uint64_t freqw);
100SR_PRIV uint64_t pce_322a_weight_time_get(const struct sr_dev_inst *sdi);
101SR_PRIV int pce_322a_weight_time_set(const struct sr_dev_inst *sdi, uint64_t timew);
102SR_PRIV int pce_322a_meas_range_get(const struct sr_dev_inst *sdi,
103 uint64_t *low, uint64_t *high);
104SR_PRIV int pce_322a_meas_range_set(const struct sr_dev_inst *sdi,
105 uint64_t low, uint64_t high);
106SR_PRIV int pce_322a_power_off(const struct sr_dev_inst *sdi);
107
108#endif