2 * This file is part of the libsigrok project.
4 * Copyright (C) 2017 Frank Stettner <frank-stettner@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_HP_3478A_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_HP_3478A_PROTOCOL_H
25 #include <libsigrok/libsigrok.h>
26 #include "libsigrok-internal.h"
28 #define LOG_PREFIX "hp-3478a"
30 #define SB1_FUNCTION_BLOCK 0b11100000
31 #define SB1_RANGE_BLOCK 0b00011100
32 #define SB1_DIGITS_BLOCK 0b00000011
34 /* Status Byte 1 (Function) */
36 FUNCTION_VDC = 0b00100000,
37 FUNCTION_VAC = 0b01000000,
38 FUNCTION_2WR = 0b01100000,
39 FUNCTION_4WR = 0b10000000,
40 FUNCTION_ADC = 0b10100000,
41 FUNCTION_AAC = 0b11000000,
42 FUNCTION_EXR = 0b11100000,
45 /* Status Byte 1 (Range V DC) */
47 RANGE_VDC_30MV = 0b00000100,
48 RANGE_VDC_300MV = 0b00001000,
49 RANGE_VDC_3V = 0b00001100,
50 RANGE_VDC_30V = 0b00010000,
51 RANGE_VDC_300V = 0b00010100,
54 /* Status Byte 1 (Range V AC) */
56 RANGE_VAC_300MV = 0b00000100,
57 RANGE_VAC_3V = 0b00001000,
58 RANGE_VAC_30V = 0b00001100,
59 RANGE_VAC_300V = 0b00010000,
62 /* Status Byte 1 (Range A) */
64 RANGE_A_300MA = 0b00000100,
65 RANGE_A_3A = 0b00001000,
68 /* Status Byte 1 (Range Ohm) */
70 RANGE_OHM_30R = 0b00000100,
71 RANGE_OHM_300R = 0b00001000,
72 RANGE_OHM_3KR = 0b00001100,
73 RANGE_OHM_30KR = 0b00010000,
74 RANGE_OHM_300KR = 0b00010100,
75 RANGE_OHM_3MR = 0b00011000,
76 RANGE_OHM_30MR = 0b00011100,
79 /* Status Byte 1 (Digits) */
81 DIGITS_5_5 = 0b00000001,
82 DIGITS_4_5 = 0b00000010,
83 DIGITS_3_5 = 0b00000011,
88 STATUS_INT_TRIGGER = (1 << 0),
89 STATUS_AUTO_RANGE = (1 << 1),
90 STATUS_AUTO_ZERO = (1 << 2),
91 STATUS_50HZ = (1 << 3),
92 STATUS_FRONT_TERMINAL = (1 << 4),
93 STATUS_CAL_RAM = (1 << 5),
94 STATUS_EXT_TRIGGER = (1 << 6),
97 /* Status Byte 3 (Serial Poll Mask) */
99 SRQ_BUS_AVAIL = (1 << 0),
100 SRQ_SYNTAX_ERR = (1 << 2),
101 SRQ_HARDWARE_ERR = (1 << 3),
102 SRQ_KEYBORD = (1 << 4),
103 SRQ_CAL_FAILED = (1 << 5),
104 SRQ_POWER_ON = (1 << 7),
107 /* Status Byte 4 (Error) */
109 ERROR_SELF_TEST = (1 << 0),
110 ERROR_RAM_SELF_TEST = (1 << 1),
111 ERROR_ROM_SELF_TEST = (1 << 2),
112 ERROR_AD_SLOPE = (1 << 3),
113 ERROR_AD_SELF_TEST = (1 << 4),
114 ERROR_AD_LINK = (1 << 5),
117 /* Channel connector (front terminals or rear terminals. */
118 enum terminal_connector {
123 /* Possible triggers */
130 /* Possible line frequencies */
137 struct sr_sw_limits limits;
140 enum sr_mq measurement_mq;
141 enum sr_mqflag measurement_mq_flags;
142 enum sr_unit measurement_unit;
146 enum terminal_connector terminal;
147 enum trigger_state trigger;
150 gboolean calibration;
153 struct channel_context {
155 enum terminal_connector location;
158 SR_PRIV int hp_3478a_set_mq(const struct sr_dev_inst *sdi, enum sr_mq mq,
159 enum sr_mqflag mq_flags);
160 SR_PRIV int hp_3478a_get_status_bytes(const struct sr_dev_inst *sdi);
161 SR_PRIV int hp_3478a_receive_data(int fd, int revents, void *cb_data);