]>
Commit | Line | Data |
---|---|---|
0acdd793 BV |
1 | /* |
2 | * This file is part of the libsigrok project. | |
3 | * | |
4 | * Copyright (C) 2014 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 | #ifndef LIBSIGROK_HARDWARE_TESTO_PROTOCOL_H | |
21 | #define LIBSIGROK_HARDWARE_TESTO_PROTOCOL_H | |
22 | ||
23 | #include <stdint.h> | |
24 | #include <glib.h> | |
25 | #include "libsigrok.h" | |
26 | #include "libsigrok-internal.h" | |
27 | ||
28 | #define LOG_PREFIX "testo" | |
29 | ||
6dcb9723 BV |
30 | #define MAX_REPLY_SIZE 128 |
31 | #define MAX_CHANNELS 16 | |
32 | ||
33 | /* FTDI commands */ | |
34 | #define FTDI_SET_MODEMCTRL 0x01 | |
35 | #define FTDI_SET_FLOWCTRL 0x02 | |
36 | #define FTDI_SET_BAUDRATE 0x03 | |
37 | #define FTDI_SET_PARAMS 0x04 | |
38 | /* FTDI command values */ | |
39 | #define FTDI_BAUDRATE_115200 0x001a | |
40 | #define FTDI_PARAMS_8N1 0x0008 | |
41 | #define FTDI_FLOW_NONE 0x0008 | |
42 | #define FTDI_MODEM_ALLHIGH 0x0303 | |
43 | #define FTDI_INDEX 0x0000 | |
44 | /* FTDI USB stuff */ | |
45 | #define EP_IN 1 | LIBUSB_ENDPOINT_IN | |
46 | #define EP_OUT 2 | LIBUSB_ENDPOINT_OUT | |
47 | ||
48 | struct testo_model { | |
49 | char *name; | |
50 | int request_size; | |
51 | unsigned char *request; | |
52 | }; | |
53 | ||
0acdd793 BV |
54 | /** Private, per-device-instance driver context. */ |
55 | struct dev_context { | |
56 | /* Model-specific information */ | |
6dcb9723 | 57 | struct testo_model *model; |
0acdd793 BV |
58 | |
59 | /* Acquisition settings */ | |
6dcb9723 BV |
60 | uint64_t limit_msec; |
61 | uint64_t limit_samples; | |
62 | void *cb_data; | |
0acdd793 BV |
63 | |
64 | /* Operational state */ | |
6dcb9723 BV |
65 | gint64 end_time; |
66 | uint64_t num_samples; | |
67 | uint8_t channel_units[MAX_CHANNELS]; | |
68 | int num_channels; | |
0acdd793 BV |
69 | |
70 | /* Temporary state across callbacks */ | |
6dcb9723 BV |
71 | struct libusb_transfer *out_transfer; |
72 | unsigned char reply[MAX_REPLY_SIZE]; | |
73 | int reply_size; | |
0acdd793 BV |
74 | }; |
75 | ||
6dcb9723 BV |
76 | SR_PRIV int testo_set_serial_params(struct sr_usb_dev_inst *usb); |
77 | SR_PRIV int testo_probe_channels(struct sr_dev_inst *sdi); | |
78 | SR_PRIV void receive_transfer(struct libusb_transfer *transfer); | |
79 | SR_PRIV int testo_request_packet(const struct sr_dev_inst *sdi); | |
87895640 BV |
80 | SR_PRIV gboolean testo_check_packet_prefix(unsigned char *buf, int len); |
81 | SR_PRIV uint16_t crc16_mcrf4xx(uint16_t crc, uint8_t *data, size_t len); | |
6dcb9723 | 82 | SR_PRIV void testo_receive_packet(const struct sr_dev_inst *sdi); |
0acdd793 | 83 | #endif |