]> sigrok.org Git - libsigrok.git/blobdiff - src/serial_hid.h
serial_hid: implement serial over HID transport
[libsigrok.git] / src / serial_hid.h
diff --git a/src/serial_hid.h b/src/serial_hid.h
new file mode 100644 (file)
index 0000000..d147978
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the libsigrok project.
+ *
+ * Copyright (C) 2017-2019 Gerhard Sittig <gerhard.sittig@gmx.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SERIAL_HID_H
+#define SERIAL_HID_H
+
+/* The prefix for port names which are HID based. */
+#define SER_HID_CONN_PREFIX    "hid"
+#define SER_HID_USB_PREFIX     "usb="
+#define SER_HID_RAW_PREFIX     "raw="
+#define SER_HID_SNR_PREFIX     "sn="
+
+/*
+ * The maximum number of bytes any supported HID chip can communicate
+ * within a single request.
+ *
+ * CP2110: up to 63bytes
+ * CH9325: up to 7 bytes
+ */
+#define SER_HID_CHUNK_SIZE     64
+
+/*
+ * Routines to get/set reports/data, provided by serial_hid.c and used
+ * in serial_hid_<chip>.c files.
+ */
+SR_PRIV int ser_hid_hidapi_get_report(struct sr_serial_dev_inst *serial,
+       uint8_t *data, size_t len);
+SR_PRIV int ser_hid_hidapi_set_report(struct sr_serial_dev_inst *serial,
+       const uint8_t *data, size_t len);
+SR_PRIV int ser_hid_hidapi_get_data(struct sr_serial_dev_inst *serial,
+       uint8_t ep, uint8_t *data, size_t len, int timeout);
+SR_PRIV int ser_hid_hidapi_set_data(struct sr_serial_dev_inst *serial,
+       uint8_t ep, const uint8_t *data, size_t len, int timeout);
+
+#endif