]> sigrok.org Git - libsigrok.git/blame - src/hardware/testo/protocol.h
output/csv: use intermediate time_t var, silence compiler warning
[libsigrok.git] / src / hardware / testo / protocol.h
CommitLineData
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>
c1aae900 25#include <libsigrok/libsigrok.h>
0acdd793
BV
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
48struct testo_model {
2c240774 49 const char *name;
6dcb9723 50 int request_size;
329733d9 51 const uint8_t *request;
6dcb9723
BV
52};
53
0acdd793 54struct dev_context {
329733d9 55 const struct testo_model *model;
91b77e6b 56 struct sr_sw_limits sw_limits;
0acdd793 57
6dcb9723
BV
58 uint8_t channel_units[MAX_CHANNELS];
59 int num_channels;
0acdd793 60
6dcb9723 61 struct libusb_transfer *out_transfer;
329733d9 62 uint8_t reply[MAX_REPLY_SIZE];
6dcb9723 63 int reply_size;
0acdd793
BV
64};
65
6dcb9723
BV
66SR_PRIV int testo_set_serial_params(struct sr_usb_dev_inst *usb);
67SR_PRIV int testo_probe_channels(struct sr_dev_inst *sdi);
55462b8b 68SR_PRIV void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer);
6dcb9723 69SR_PRIV int testo_request_packet(const struct sr_dev_inst *sdi);
329733d9 70SR_PRIV gboolean testo_check_packet_prefix(uint8_t *buf, int len);
87895640 71SR_PRIV uint16_t crc16_mcrf4xx(uint16_t crc, uint8_t *data, size_t len);
6dcb9723 72SR_PRIV void testo_receive_packet(const struct sr_dev_inst *sdi);
1beccaed 73
0acdd793 74#endif