00001 /* 00002 * This file is part of the sigrok project. 00003 * 00004 * Copyright (C) 2010-2012 Bert Vermeulen <bert@biot.com> 00005 * 00006 * This program is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef LIBSIGROK_HARDWARE_OPENBENCH_LOGIC_SNIFFER_OLS_H 00021 #define LIBSIGROK_HARDWARE_OPENBENCH_LOGIC_SNIFFER_OLS_H 00022 00023 #define NUM_PROBES 32 00024 #define NUM_TRIGGER_STAGES 4 00025 #define TRIGGER_TYPES "01" 00026 #define SERIAL_SPEED B115200 00027 #define CLOCK_RATE SR_MHZ(100) 00028 #define MIN_NUM_SAMPLES 4 00029 00030 /* Command opcodes */ 00031 #define CMD_RESET 0x00 00032 #define CMD_RUN 0x01 00033 #define CMD_ID 0x02 00034 #define CMD_METADATA 0x04 00035 #define CMD_SET_FLAGS 0x82 00036 #define CMD_SET_DIVIDER 0x80 00037 #define CMD_CAPTURE_SIZE 0x81 00038 #define CMD_SET_TRIGGER_MASK_0 0xc0 00039 #define CMD_SET_TRIGGER_MASK_1 0xc4 00040 #define CMD_SET_TRIGGER_MASK_2 0xc8 00041 #define CMD_SET_TRIGGER_MASK_3 0xcc 00042 #define CMD_SET_TRIGGER_VALUE_0 0xc1 00043 #define CMD_SET_TRIGGER_VALUE_1 0xc5 00044 #define CMD_SET_TRIGGER_VALUE_2 0xc9 00045 #define CMD_SET_TRIGGER_VALUE_3 0xcd 00046 #define CMD_SET_TRIGGER_CONFIG_0 0xc2 00047 #define CMD_SET_TRIGGER_CONFIG_1 0xc6 00048 #define CMD_SET_TRIGGER_CONFIG_2 0xca 00049 #define CMD_SET_TRIGGER_CONFIG_3 0xce 00050 00051 /* Bitmasks for CMD_FLAGS */ 00052 #define FLAG_DEMUX 0x01 00053 #define FLAG_FILTER 0x02 00054 #define FLAG_CHANNELGROUP_1 0x04 00055 #define FLAG_CHANNELGROUP_2 0x08 00056 #define FLAG_CHANNELGROUP_3 0x10 00057 #define FLAG_CHANNELGROUP_4 0x20 00058 #define FLAG_CLOCK_EXTERNAL 0x40 00059 #define FLAG_CLOCK_INVERTED 0x80 00060 #define FLAG_RLE 0x0100 00061 00062 /* Private, per-device-instance driver context. */ 00063 struct context { 00064 uint32_t max_samplerate; 00065 uint32_t max_samples; 00066 uint32_t protocol_version; 00067 int num_probes; 00068 00069 uint64_t cur_samplerate; 00070 uint32_t cur_samplerate_divider; 00071 uint64_t limit_samples; 00072 /* Current state of the flag register */ 00073 uint32_t flag_reg; 00074 00075 /* Pre/post trigger capture ratio, in percentage. 00076 * 0 means no pre-trigger data. */ 00077 int capture_ratio; 00078 int trigger_at; 00079 uint32_t probe_mask; 00080 uint32_t trigger_mask[4]; 00081 uint32_t trigger_value[4]; 00082 int num_stages; 00083 00084 unsigned int num_transfers; 00085 unsigned int num_samples; 00086 int rle_count; 00087 int num_bytes; 00088 unsigned char sample[4]; 00089 unsigned char tmp_sample[4]; 00090 unsigned char *raw_sample_buf; 00091 00092 struct sr_serial_dev_inst *serial; 00093 }; 00094 00095 #endif