]>
Commit | Line | Data |
---|---|---|
b908f067 UH |
1 | /* |
2 | * This file is part of the sigrok project. | |
3 | * | |
4 | * Copyright (C) 2011-2012 Uwe Hermann <uwe@hermann-uwe.de> | |
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 2 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, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
45e080b6 UH |
21 | #ifndef LIBSIGROK_HARDWARE_CHRONOVU_LA8_PROTOCOL_H |
22 | #define LIBSIGROK_HARDWARE_CHRONOVU_LA8_PROTOCOL_H | |
b908f067 UH |
23 | |
24 | #include <glib.h> | |
25 | #include <ftdi.h> | |
26 | #include <stdint.h> | |
45c59c8b BV |
27 | #include "libsigrok.h" |
28 | #include "libsigrok-internal.h" | |
b908f067 | 29 | |
f3a35908 UH |
30 | /* Message logging helpers with driver-specific prefix string. */ |
31 | #define DRIVER_LOG_DOMAIN "la8: " | |
32 | #define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args) | |
33 | #define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args) | |
34 | #define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args) | |
35 | #define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args) | |
36 | #define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args) | |
37 | #define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args) | |
38 | ||
b908f067 | 39 | #define USB_VENDOR_ID 0x0403 |
b908f067 UH |
40 | #define USB_DESCRIPTION "ChronoVu LA8" |
41 | #define USB_VENDOR_NAME "ChronoVu" | |
42 | #define USB_MODEL_NAME "LA8" | |
43 | #define USB_MODEL_VERSION "" | |
44 | ||
45 | #define NUM_PROBES 8 | |
c50277a6 | 46 | #define TRIGGER_TYPE "01" |
b908f067 UH |
47 | #define SDRAM_SIZE (8 * 1024 * 1024) |
48 | #define MIN_NUM_SAMPLES 1 | |
49 | ||
50 | #define BS 4096 /* Block size */ | |
51 | #define NUM_BLOCKS 2048 /* Number of blocks */ | |
52 | ||
53 | /* Private, per-device-instance driver context. */ | |
1644fb24 | 54 | struct dev_context { |
b908f067 UH |
55 | /** FTDI device context (used by libftdi). */ |
56 | struct ftdi_context *ftdic; | |
57 | ||
58 | /** The currently configured samplerate of the device. */ | |
59 | uint64_t cur_samplerate; | |
60 | ||
61 | /** The current sampling limit (in ms). */ | |
62 | uint64_t limit_msec; | |
63 | ||
64 | /** The current sampling limit (in number of samples). */ | |
65 | uint64_t limit_samples; | |
66 | ||
67 | /** TODO */ | |
68 | void *session_dev_id; | |
69 | ||
70 | /** | |
71 | * A buffer containing some (mangled) samples from the device. | |
72 | * Format: Pretty mangled-up (due to hardware reasons), see code. | |
73 | */ | |
74 | uint8_t mangled_buf[BS]; | |
75 | ||
76 | /** | |
77 | * An 8MB buffer where we'll store the de-mangled samples. | |
78 | * Format: Each sample is 1 byte, MSB is channel 7, LSB is channel 0. | |
79 | */ | |
80 | uint8_t *final_buf; | |
81 | ||
82 | /** | |
83 | * Trigger pattern (MSB = channel 7, LSB = channel 0). | |
84 | * A 1 bit matches a high signal, 0 matches a low signal on a probe. | |
85 | * Only low/high triggers (but not e.g. rising/falling) are supported. | |
86 | */ | |
87 | uint8_t trigger_pattern; | |
88 | ||
89 | /** | |
90 | * Trigger mask (MSB = channel 7, LSB = channel 0). | |
91 | * A 1 bit means "must match trigger_pattern", 0 means "don't care". | |
92 | */ | |
93 | uint8_t trigger_mask; | |
94 | ||
95 | /** Time (in seconds) before the trigger times out. */ | |
96 | uint64_t trigger_timeout; | |
97 | ||
98 | /** Tells us whether an SR_DF_TRIGGER packet was already sent. */ | |
99 | int trigger_found; | |
100 | ||
101 | /** TODO */ | |
102 | time_t done; | |
103 | ||
104 | /** Counter/index for the data block to be read. */ | |
105 | int block_counter; | |
106 | ||
107 | /** The divcount value (determines the sample period) for the LA8. */ | |
108 | uint8_t divcount; | |
74e5f12d UH |
109 | |
110 | /** This ChronoVu LA8's USB PID (multiple versions exist). */ | |
111 | uint16_t usb_pid; | |
b908f067 UH |
112 | }; |
113 | ||
45e080b6 | 114 | /* protocol.c */ |
b908f067 UH |
115 | extern SR_PRIV uint64_t supported_samplerates[]; |
116 | extern SR_PRIV const int hwcaps[]; | |
117 | extern SR_PRIV const char *probe_names[]; | |
118 | extern const struct sr_samplerates samplerates; | |
119 | SR_PRIV void fill_supported_samplerates_if_needed(void); | |
120 | SR_PRIV int is_valid_samplerate(uint64_t samplerate); | |
121 | SR_PRIV uint8_t samplerate_to_divcount(uint64_t samplerate); | |
1644fb24 BV |
122 | SR_PRIV int la8_write(struct dev_context *devc, uint8_t *buf, int size); |
123 | SR_PRIV int la8_read(struct dev_context *devc, uint8_t *buf, int size); | |
124 | SR_PRIV int la8_close(struct dev_context *devc); | |
125 | SR_PRIV int la8_close_usb_reset_sequencer(struct dev_context *devc); | |
126 | SR_PRIV int la8_reset(struct dev_context *devc); | |
014359e3 | 127 | SR_PRIV int configure_probes(const struct sr_dev_inst *sdi); |
6f4b1868 | 128 | SR_PRIV int set_samplerate(const struct sr_dev_inst *sdi, uint64_t samplerate); |
1644fb24 BV |
129 | SR_PRIV int la8_read_block(struct dev_context *devc); |
130 | SR_PRIV void send_block_to_session_bus(struct dev_context *devc, int block); | |
b908f067 UH |
131 | |
132 | #endif |