]> sigrok.org Git - libsigrok.git/blob - src/hardware/testo/protocol.h
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / hardware / testo / protocol.h
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/libsigrok.h>
26 #include "libsigrok-internal.h"
27
28 #define LOG_PREFIX "testo"
29
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         const char *name;
50         int request_size;
51         const uint8_t *request;
52 };
53
54 struct dev_context {
55         const struct testo_model *model;
56         struct sr_sw_limits sw_limits;
57
58         uint8_t channel_units[MAX_CHANNELS];
59         int num_channels;
60
61         struct libusb_transfer *out_transfer;
62         uint8_t reply[MAX_REPLY_SIZE];
63         int reply_size;
64 };
65
66 SR_PRIV int testo_set_serial_params(struct sr_usb_dev_inst *usb);
67 SR_PRIV int testo_probe_channels(struct sr_dev_inst *sdi);
68 SR_PRIV void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer);
69 SR_PRIV int testo_request_packet(const struct sr_dev_inst *sdi);
70 SR_PRIV gboolean testo_check_packet_prefix(uint8_t *buf, int len);
71 SR_PRIV uint16_t crc16_mcrf4xx(uint16_t crc, uint8_t *data, size_t len);
72 SR_PRIV void testo_receive_packet(const struct sr_dev_inst *sdi);
73
74 #endif