2 * This file is part of the libsigrok project.
4 * Copyright (C) 2014 Bert Vermeulen <bert@biot.com>
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.
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.
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/>.
20 #ifndef LIBSIGROK_HARDWARE_TESTO_PROTOCOL_H
21 #define LIBSIGROK_HARDWARE_TESTO_PROTOCOL_H
25 #include "libsigrok.h"
26 #include "libsigrok-internal.h"
28 #define LOG_PREFIX "testo"
30 #define MAX_REPLY_SIZE 128
31 #define MAX_CHANNELS 16
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
45 #define EP_IN 1 | LIBUSB_ENDPOINT_IN
46 #define EP_OUT 2 | LIBUSB_ENDPOINT_OUT
51 unsigned char *request;
54 /** Private, per-device-instance driver context. */
56 /* Model-specific information */
57 struct testo_model *model;
59 /* Acquisition settings */
61 uint64_t limit_samples;
64 /* Operational state */
67 uint8_t channel_units[MAX_CHANNELS];
70 /* Temporary state across callbacks */
71 struct libusb_transfer *out_transfer;
72 unsigned char reply[MAX_REPLY_SIZE];
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);
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);
82 SR_PRIV void testo_receive_packet(const struct sr_dev_inst *sdi);