2 * This file is part of the sigrok project.
4 * Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
5 * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
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.
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.
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/>.
21 #ifndef LIBSIGROK_RADIOSHACK_DMM_H
22 #define LIBSIGROK_RADIOSHACK_DMM_H
24 #define RS_DMM_BUFSIZE 256
26 /* Byte 1 of the packet, and the modes it represents */
27 #define RS_22_812_IND1_HZ (0x80)
28 #define RS_22_812_IND1_OHM (0x40)
29 #define RS_22_812_IND1_KILO (0x20)
30 #define RS_22_812_IND1_MEGA (0x10)
31 #define RS_22_812_IND1_FARAD (0x08)
32 #define RS_22_812_IND1_AMP (0x04)
33 #define RS_22_812_IND1_VOLT (0x02)
34 #define RS_22_812_IND1_MILI (0x01)
35 /* Byte 2 of the packet, and the modes it represents */
36 #define RS_22_812_IND2_MICRO (0x80)
37 #define RS_22_812_IND2_NANO (0x40)
38 #define RS_22_812_IND2_DBM (0x20)
39 #define RS_22_812_IND2_SEC (0x10)
40 #define RS_22_812_IND2_DUTY (0x08)
41 #define RS_22_812_IND2_HFE (0x04)
42 #define RS_22_812_IND2_REL (0x02)
43 #define RS_22_812_IND2_MIN (0x01)
44 /* Byte 7 of the packet, and the modes it represents */
45 #define RS_22_812_INFO_BEEP (0x80)
46 #define RS_22_812_INFO_DIODE (0x30)
47 #define RS_22_812_INFO_BAT (0x20)
48 #define RS_22_812_INFO_HOLD (0x10)
49 #define RS_22_812_INFO_NEG (0x08)
50 #define RS_22_812_INFO_AC (0x04)
51 #define RS_22_812_INFO_RS232 (0x02)
52 #define RS_22_812_INFO_AUTO (0x01)
53 /* Instead of a decimal point, digit 4 carries the MAX flag */
54 #define RS_22_812_DIG4_MAX (0x08)
55 /* mask to remove the decimal point fr0m a digit */
56 #define RS_22_812_DP_MASK (0x08)
58 /* What the LCD values represent */
59 #define RS_22_812_LCD_0 0xd7
60 #define RS_22_812_LCD_1 0x50
61 #define RS_22_812_LCD_2 0xb5
62 #define RS_22_812_LCD_3 0xf1
63 #define RS_22_812_LCD_4 0x72
64 #define RS_22_812_LCD_5 0xe3
65 #define RS_22_812_LCD_6 0xe7
66 #define RS_22_812_LCD_7 0x51
67 #define RS_22_812_LCD_8 0xf7
68 #define RS_22_812_LCD_9 0xf3
70 #define RS_22_812_LCD_C 0x87
71 #define RS_22_812_LCD_E
72 #define RS_22_812_LCD_F
73 #define RS_22_812_LCD_h 0x66
74 #define RS_22_812_LCD_H 0x76
75 #define RS_22_812_LCD_I
76 #define RS_22_812_LCD_n
77 #define RS_22_812_LCD_P 0x37
78 #define RS_22_812_LCD_r
92 #define RS_22_812_PACKET_SIZE (sizeof(rs_22_812_packet))
95 RS_22_812_MODE_DC_V = 0,
96 RS_22_812_MODE_AC_V = 1,
97 RS_22_812_MODE_DC_UA = 2,
98 RS_22_812_MODE_DC_MA = 3,
99 RS_22_812_MODE_DC_A = 4,
100 RS_22_812_MODE_AC_UA = 5,
101 RS_22_812_MODE_AC_MA = 6,
102 RS_22_812_MODE_AC_A = 7,
103 RS_22_812_MODE_OHM = 8,
104 RS_22_812_MODE_FARAD = 9,
105 RS_22_812_MODE_HZ = 10,
106 RS_22_812_MODE_VOLT_HZ = 11,
107 RS_22_812_MODE_AMP_HZ = 12,
108 RS_22_812_MODE_DUTY = 13,
109 RS_22_812_MODE_VOLT_DUTY= 14,
110 RS_22_812_MODE_AMP_DUTY = 15,
111 RS_22_812_MODE_WIDTH = 16,
112 RS_22_812_MODE_VOLT_WIDTH = 17,
113 RS_22_812_MODE_AMP_WIDTH = 18,
114 RS_22_812_MODE_DIODE = 19,
115 RS_22_812_MODE_CONT = 20,
116 RS_22_812_MODE_HFE = 21,
117 RS_22_812_MODE_LOGIC = 22,
118 RS_22_812_MODE_DBM = 23,
119 //RS_22_812_MODE_ EF = 24,
120 RS_22_812_MODE_TEMP = 25,
121 RS_22_812_MODE_INVALID = 26,
124 SR_PRIV gboolean rs_22_812_is_packet_valid(const rs_22_812_packet *data );
126 /* Supported models */
128 RADIOSHACK_22_812 = 1,
131 /* Supported device profiles */
132 struct radioshackdmm_profile {
133 radioshack_model model;
134 const char *modelname;
135 /* How often to poll, in ms. */
139 /* Private, per-device-instance driver context. */
140 typedef struct dev_context {
141 /* const struct radioshackdmm_profile *profile; */
142 uint64_t limit_samples;
143 struct sr_serial_dev_inst *serial;
146 /* Opaque pointer passed in by the frontend. */
150 uint64_t num_samples;
151 uint8_t buf[RS_DMM_BUFSIZE];
157 SR_PRIV int radioshack_receive_data(int fd, int revents, void *cb_data);
159 #endif /* LIBSIGROK_RADIOSHACK_DMM_H */