]> sigrok.org Git - libsigrok.git/blob - hardware/openbench-logic-sniffer/ols.h
b9bbc67c6287775496de21b9263db42bde2de9a3
[libsigrok.git] / hardware / openbench-logic-sniffer / ols.h
1 /*
2  * This file is part of the sigrok project.
3  *
4  * Copyright (C) 2011 Bert Vermeulen <bert@biot.com>
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
20
21 #ifndef OLS_H_
22 #define OLS_H_
23
24 #define NUM_PROBES             32
25 #define NUM_TRIGGER_STAGES     4
26 #define TRIGGER_TYPES          "01"
27 #define SERIAL_SPEED           B115200
28 #define CLOCK_RATE             SR_MHZ(100)
29 #define MIN_NUM_SAMPLES        4
30
31 /* Command opcodes */
32 #define CMD_RESET                  0x00
33 #define CMD_RUN                    0x01
34 #define CMD_ID                     0x02
35 #define CMD_METADATA               0x04
36 #define CMD_SET_FLAGS              0x82
37 #define CMD_SET_DIVIDER            0x80
38 #define CMD_CAPTURE_SIZE           0x81
39 #define CMD_SET_TRIGGER_MASK_0     0xc0
40 #define CMD_SET_TRIGGER_MASK_1     0xc4
41 #define CMD_SET_TRIGGER_MASK_2     0xc8
42 #define CMD_SET_TRIGGER_MASK_3     0xcc
43 #define CMD_SET_TRIGGER_VALUE_0    0xc1
44 #define CMD_SET_TRIGGER_VALUE_1    0xc5
45 #define CMD_SET_TRIGGER_VALUE_2    0xc9
46 #define CMD_SET_TRIGGER_VALUE_3    0xcd
47 #define CMD_SET_TRIGGER_CONFIG_0   0xc2
48 #define CMD_SET_TRIGGER_CONFIG_1   0xc6
49 #define CMD_SET_TRIGGER_CONFIG_2   0xca
50 #define CMD_SET_TRIGGER_CONFIG_3   0xce
51
52 /* Bitmasks for CMD_FLAGS */
53 #define FLAG_DEMUX                 0x01
54 #define FLAG_FILTER                0x02
55 #define FLAG_CHANNELGROUP_1        0x04
56 #define FLAG_CHANNELGROUP_2        0x08
57 #define FLAG_CHANNELGROUP_3        0x10
58 #define FLAG_CHANNELGROUP_4        0x20
59 #define FLAG_CLOCK_EXTERNAL        0x40
60 #define FLAG_CLOCK_INVERTED        0x80
61 #define FLAG_RLE                   0x0100
62
63
64 struct ols_device {
65         uint32_t max_samplerate;
66         uint32_t max_samples;
67         uint32_t protocol_version;
68         int num_probes;
69
70         uint64_t cur_samplerate;
71         uint32_t cur_samplerate_divider;
72         uint64_t limit_samples;
73         /* Current state of the flag register */
74         uint32_t flag_reg;
75
76         /* Pre/post trigger capture ratio, in percentage.
77          * 0 means no pre-trigger data. */
78         int capture_ratio;
79         int trigger_at;
80         uint32_t probe_mask;
81         uint32_t trigger_mask[4];
82         uint32_t trigger_value[4];
83         int num_stages;
84
85         unsigned int num_transfers;
86         int num_bytes;
87         char last_sample[4];
88         unsigned char sample[4];
89         unsigned char tmp_sample[4];
90         unsigned char *raw_sample_buf;
91 };
92
93 #endif /* OLS_H_ */