2 * This file is part of the sigrok project.
4 * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
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_TEKPOWER_DMM_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_TEKPOWER_DMM_PROTOCOL_H
23 /* Message logging helpers with driver-specific prefix string. */
24 #define DRIVER_LOG_DOMAIN "tekpower-dmm: "
25 #define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
26 #define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
27 #define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
28 #define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
29 #define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
30 #define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
32 #define DMM_BUFSIZE 256
34 /* Flags present in the packet */
35 #define LCD14_AC (1 << 23)
36 #define LCD14_DC (1 << 22)
37 #define LCD14_AUTO (1 << 21)
38 #define LCD14_RS232 (1 << 20)
39 #define LCD14_MICRO (1 << 19)
40 #define LCD14_NANO (1 << 18)
41 #define LCD14_KILO (1 << 17)
42 #define LCD14_DIODE (1 << 16)
43 #define LCD14_MILLI (1 << 15)
44 #define LCD14_DUTY (1 << 14)
45 #define LCD14_MEGA (1 << 13)
46 #define LCD14_BEEP (1 << 12)
47 #define LCD14_FARAD (1 << 11)
48 #define LCD14_OHM (1 << 10)
49 #define LCD14_REL (1 << 9)
50 #define LCD14_HOLD (1 << 8)
51 #define LCD14_AMP (1 << 7)
52 #define LCD14_VOLT (1 << 6)
53 #define LCD14_HZ (1 << 5)
54 #define LCD14_LOW_BATT (1 << 4)
55 #define LCD14_HFE (1 << 3)
56 #define LCD14_CELSIUS (1 << 2)
57 #define LCD14_RSVD1 (1 << 1)
58 #define LCD14_RSVD0 (0 << 0)
60 /* Mask used to remove the decimal point from a digit. */
61 #define LCD14_DP_MASK 0x80
62 #define LCD14_D0_NEG LCD14_DP_MASK
63 /* Mask used to remove the syncronization nibble. */
64 #define LCD14_SYNC_MASK 0xf0
66 /* What the LCD values represent */
67 #define LCD14_LCD_0 0x7d
68 #define LCD14_LCD_1 0x05
69 #define LCD14_LCD_2 0x5b
70 #define LCD14_LCD_3 0x1f
71 #define LCD14_LCD_4 0x27
72 #define LCD14_LCD_5 0x3e
73 #define LCD14_LCD_6 0x7e
74 #define LCD14_LCD_7 0x15
75 #define LCD14_LCD_8 0x7f
76 #define LCD14_LCD_9 0x3f
78 #define LCD14_LCD_INVALID 0xff
80 #define LCD14_PACKET_SIZE 14
83 uint8_t raw[LCD14_PACKET_SIZE];
91 SR_PRIV gboolean lcd14_is_packet_valid(const struct lcd14_packet *packet,
92 struct lcd14_data *data);
94 /** Private, per-device-instance driver context. */
96 /** The current sampling limit (in number of samples). */
97 uint64_t limit_samples;
99 /** Opaque pointer passed in by the frontend. */
102 /** The current number of already received samples. */
103 uint64_t num_samples;
105 struct sr_serial_dev_inst *serial;
108 uint8_t buf[DMM_BUFSIZE];
113 SR_PRIV int tekpower_dmm_receive_data(int fd, int revents, void *cb_data);