]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/dcttech-usbrelay/protocol.h
dcttech-usbrelay: implement multiplexer driver for USB relay card
[libsigrok.git] / src / hardware / dcttech-usbrelay / protocol.h
index 519518426fd69af9960825857fad8a9c446e37c1..45b8ec4bfca0ec7556ffdc6e24e7c53eb9b087bf 100644 (file)
 #ifndef LIBSIGROK_HARDWARE_DCTTECH_USBRELAY_PROTOCOL_H
 #define LIBSIGROK_HARDWARE_DCTTECH_USBRELAY_PROTOCOL_H
 
-#include <stdint.h>
 #include <glib.h>
+#include <hidapi.h>
 #include <libsigrok/libsigrok.h>
+#include <stdint.h>
+
 #include "libsigrok-internal.h"
 
 #define LOG_PREFIX "dcttech-usbrelay"
 
+/* USB identification. */
+#define VENDOR_ID 0x16c0
+#define PRODUCT_ID 0x05df
+#define VENDOR_STRING "www.dcttech.com"
+#define PRODUCT_STRING_PREFIX "USBRelay"
+
+/* HID report layout. */
+#define REPORT_NUMBER 0
+#define REPORT_BYTECOUNT 8
+#define SERNO_LENGTH 5
+#define STATE_INDEX 7
+
 struct dev_context {
+       char *hid_path;
+       hid_device *hid_dev;
+       size_t relay_count;
+       uint32_t relay_mask;
+       uint32_t relay_state;
+};
+
+struct channel_group_context {
+       size_t number;
 };
 
-SR_PRIV int dcttech_usbrelay_receive_data(int fd, int revents, void *cb_data);
+SR_PRIV int dcttech_usbrelay_update_state(const struct sr_dev_inst *sdi);
+SR_PRIV int dcttech_usbrelay_switch_cg(const struct sr_dev_inst *sdi,
+       const struct sr_channel_group *cg, gboolean on);
+SR_PRIV int dcttech_usbrelay_query_cg(const struct sr_dev_inst *sdi,
+       const struct sr_channel_group *cg, gboolean *on);
 
 #endif