]> sigrok.org Git - libsigrok.git/blame - src/hardware/pce-322a/protocol.h
pce-322a: Initial driver implementation.
[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>
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_PCE_322A_PROTOCOL_H
21#define LIBSIGROK_HARDWARE_PCE_322A_PROTOCOL_H
22
23#include <stdint.h>
24#include <glib.h>
25#include <libsigrok/libsigrok.h>
26#include "libsigrok-internal.h"
27
28#define LOG_PREFIX "pce-322a"
29
30#define BUFFER_SIZE 13
31
32enum {
33 CMD_CONNECT = 0xacff,
34 CMD_DISCONNECT = 0xcaff,
35 CMD_TOGGLE_WEIGHT_FREQ = 0xaaf1,
36 CMD_TOGGLE_MEAS_RANGE = 0xaaf2,
37 CMD_TOGGLE_HOLD_MAX_MIN = 0xaaf3,
38 CMD_TOGGLE_WEIGHT_TIME = 0xaaf4,
39 CMD_TOGGLE_HOLD = 0xaaf5,
40 CMD_TOGGLE_BACKLIGHT = 0xaaf6,
41 CMD_TOGGLE_DATE_TIME = 0xaaf7,
42 CMD_LOG_START = 0x7e00,
43 CMD_MEMORY_STATUS = 0xadda,
44 CMD_MEMORY_TRANSFER = 0xd3da,
45 CMD_MEMORY_CLEAR = 0xaac1,
46 CMD_POWER_OFF = 0xaaf8,
47};
48
49enum {
50 MEAS_RANGE_30_130 = 0,
51 MEAS_RANGE_30_80 = 1,
52 MEAS_RANGE_50_100 = 2,
53 MEAS_RANGE_80_130 = 3,
54};
55
56/** Private, per-device-instance driver context. */
57struct dev_context {
58 /* Model-specific information */
59 uint64_t cur_mqflags;
60 uint8_t cur_meas_range;
61
62 /* Acquisition settings */
63 uint64_t limit_samples;
64
65 /* Operational state */
66 uint64_t num_samples;
67
68 /* Temporary state across callbacks */
69 uint8_t buffer[BUFFER_SIZE];
70 int buffer_len;
71};
72
73SR_PRIV int pce_322a_connect(const struct sr_dev_inst *sdi);
74SR_PRIV int pce_322a_disconnect(const struct sr_dev_inst *sdi);
75SR_PRIV int pce_322a_receive_data(int fd, int revents, void *cb_data);
76SR_PRIV uint64_t pce_322a_weight_freq_get(const struct sr_dev_inst *sdi);
77SR_PRIV int pce_322a_weight_freq_set(const struct sr_dev_inst *sdi, uint64_t freqw);
78SR_PRIV uint64_t pce_322a_weight_time_get(const struct sr_dev_inst *sdi);
79SR_PRIV int pce_322a_weight_time_set(const struct sr_dev_inst *sdi, uint64_t timew);
80SR_PRIV int pce_322a_meas_range_get(const struct sr_dev_inst *sdi,
81 uint64_t *low, uint64_t *high);
82SR_PRIV int pce_322a_meas_range_set(const struct sr_dev_inst *sdi,
83 uint64_t low, uint64_t high);
84SR_PRIV int pce_322a_power_off(const struct sr_dev_inst *sdi);
85
86#endif