]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * This file is part of the sigrok project. | |
3 | * | |
4 | * Copyright (C) 2012 Bert Vermeulen <bert@biot.com> | |
5 | * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com> | |
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_RADIOSHACK_DMM_H | |
22 | #define LIBSIGROK_RADIOSHACK_DMM_H | |
23 | ||
24 | #define RS_DMM_BUFSIZE 256 | |
25 | ||
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) | |
57 | ||
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 | |
69 | ||
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 | |
79 | ||
80 | typedef struct { | |
81 | uint8_t mode; | |
82 | uint8_t indicatrix1; | |
83 | uint8_t indicatrix2; | |
84 | uint8_t digit4; | |
85 | uint8_t digit3; | |
86 | uint8_t digit2; | |
87 | uint8_t digit1; | |
88 | uint8_t info; | |
89 | uint8_t checksum; | |
90 | } rs_22_812_packet; | |
91 | ||
92 | #define RS_22_812_PACKET_SIZE (sizeof(rs_22_812_packet)) | |
93 | ||
94 | typedef enum { | |
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, | |
122 | } rs_22_812_mode; | |
123 | ||
124 | SR_PRIV gboolean rs_22_812_is_packet_valid(const rs_22_812_packet *data ); | |
125 | ||
126 | /* Supported models */ | |
127 | typedef enum { | |
128 | RADIOSHACK_22_812 = 1, | |
129 | } radioshack_model; | |
130 | ||
131 | /* Supported device profiles */ | |
132 | struct radioshackdmm_profile { | |
133 | radioshack_model model; | |
134 | const char *modelname; | |
135 | /* How often to poll, in ms. */ | |
136 | int poll_period; | |
137 | }; | |
138 | ||
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; | |
144 | char *serialcomm; | |
145 | ||
146 | /* Opaque pointer passed in by the frontend. */ | |
147 | void *cb_data; | |
148 | ||
149 | /* Runtime. */ | |
150 | uint64_t num_samples; | |
151 | uint8_t buf[RS_DMM_BUFSIZE]; | |
152 | size_t bufoffset; | |
153 | size_t buflen; | |
154 | } rs_dev_ctx; | |
155 | ||
156 | ||
157 | SR_PRIV int radioshack_receive_data(int fd, int revents, void *cb_data); | |
158 | ||
159 | #endif /* LIBSIGROK_RADIOSHACK_DMM_H */ |