]> sigrok.org Git - libsigrok.git/blame - hardware/openbench-logic-sniffer/ols.h
ols: Use logging helper macro.
[libsigrok.git] / hardware / openbench-logic-sniffer / ols.h
CommitLineData
4fe9a6da
BV
1/*
2 * This file is part of the sigrok project.
3 *
c73d2ea4 4 * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com>
4fe9a6da
BV
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
0f8522bf
UH
20#ifndef LIBSIGROK_HARDWARE_OPENBENCH_LOGIC_SNIFFER_OLS_H
21#define LIBSIGROK_HARDWARE_OPENBENCH_LOGIC_SNIFFER_OLS_H
4fe9a6da 22
a567547e
UH
23/* Message logging helpers with driver-specific prefix string. */
24#define DRIVER_LOG_DOMAIN "ols: "
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)
31
4fe9a6da
BV
32#define NUM_PROBES 32
33#define NUM_TRIGGER_STAGES 4
34#define TRIGGER_TYPES "01"
35#define SERIAL_SPEED B115200
36#define CLOCK_RATE SR_MHZ(100)
37#define MIN_NUM_SAMPLES 4
38
39/* Command opcodes */
40#define CMD_RESET 0x00
41#define CMD_RUN 0x01
42#define CMD_ID 0x02
43#define CMD_METADATA 0x04
44#define CMD_SET_FLAGS 0x82
45#define CMD_SET_DIVIDER 0x80
46#define CMD_CAPTURE_SIZE 0x81
47#define CMD_SET_TRIGGER_MASK_0 0xc0
48#define CMD_SET_TRIGGER_MASK_1 0xc4
49#define CMD_SET_TRIGGER_MASK_2 0xc8
50#define CMD_SET_TRIGGER_MASK_3 0xcc
51#define CMD_SET_TRIGGER_VALUE_0 0xc1
52#define CMD_SET_TRIGGER_VALUE_1 0xc5
53#define CMD_SET_TRIGGER_VALUE_2 0xc9
54#define CMD_SET_TRIGGER_VALUE_3 0xcd
55#define CMD_SET_TRIGGER_CONFIG_0 0xc2
56#define CMD_SET_TRIGGER_CONFIG_1 0xc6
57#define CMD_SET_TRIGGER_CONFIG_2 0xca
58#define CMD_SET_TRIGGER_CONFIG_3 0xce
59
60/* Bitmasks for CMD_FLAGS */
61#define FLAG_DEMUX 0x01
62#define FLAG_FILTER 0x02
63#define FLAG_CHANNELGROUP_1 0x04
64#define FLAG_CHANNELGROUP_2 0x08
65#define FLAG_CHANNELGROUP_3 0x10
66#define FLAG_CHANNELGROUP_4 0x20
67#define FLAG_CLOCK_EXTERNAL 0x40
68#define FLAG_CLOCK_INVERTED 0x80
69#define FLAG_RLE 0x0100
70
ea9cfed7 71/* Private, per-device-instance driver context. */
fefc4b85 72struct dev_context {
4fe9a6da
BV
73 uint32_t max_samplerate;
74 uint32_t max_samples;
75 uint32_t protocol_version;
4fe9a6da
BV
76
77 uint64_t cur_samplerate;
78 uint32_t cur_samplerate_divider;
79 uint64_t limit_samples;
80 /* Current state of the flag register */
81 uint32_t flag_reg;
82
83 /* Pre/post trigger capture ratio, in percentage.
84 * 0 means no pre-trigger data. */
85 int capture_ratio;
86 int trigger_at;
87 uint32_t probe_mask;
88 uint32_t trigger_mask[4];
89 uint32_t trigger_value[4];
90 int num_stages;
91
92 unsigned int num_transfers;
22130421 93 unsigned int num_samples;
3a4d09c0 94 int rle_count;
4fe9a6da 95 int num_bytes;
4fe9a6da
BV
96 unsigned char sample[4];
97 unsigned char tmp_sample[4];
98 unsigned char *raw_sample_buf;
69890f73 99
d68e2d1a 100 struct sr_serial_dev_inst *serial;
4fe9a6da
BV
101};
102
0f8522bf 103#endif