]> sigrok.org Git - libsigrok.git/blame - src/serial_hid.h
serial_hid: implement serial over HID transport
[libsigrok.git] / src / serial_hid.h
CommitLineData
edec0436
GS
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2017-2019 Gerhard Sittig <gerhard.sittig@gmx.net>
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 SERIAL_HID_H
21#define SERIAL_HID_H
22
23/* The prefix for port names which are HID based. */
24#define SER_HID_CONN_PREFIX "hid"
25#define SER_HID_USB_PREFIX "usb="
26#define SER_HID_RAW_PREFIX "raw="
27#define SER_HID_SNR_PREFIX "sn="
28
29/*
30 * The maximum number of bytes any supported HID chip can communicate
31 * within a single request.
32 *
33 * CP2110: up to 63bytes
34 * CH9325: up to 7 bytes
35 */
36#define SER_HID_CHUNK_SIZE 64
37
38/*
39 * Routines to get/set reports/data, provided by serial_hid.c and used
40 * in serial_hid_<chip>.c files.
41 */
42SR_PRIV int ser_hid_hidapi_get_report(struct sr_serial_dev_inst *serial,
43 uint8_t *data, size_t len);
44SR_PRIV int ser_hid_hidapi_set_report(struct sr_serial_dev_inst *serial,
45 const uint8_t *data, size_t len);
46SR_PRIV int ser_hid_hidapi_get_data(struct sr_serial_dev_inst *serial,
47 uint8_t ep, uint8_t *data, size_t len, int timeout);
48SR_PRIV int ser_hid_hidapi_set_data(struct sr_serial_dev_inst *serial,
49 uint8_t ep, const uint8_t *data, size_t len, int timeout);
50
51#endif