summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-09-26 00:38:37 +0700
committerGitHub <[email protected]>2019-09-26 00:38:37 +0700
commit9a8d23e95ed6a48b3a3d43f7cf7d3f360ee61977 (patch)
tree8f918208a29c15988396e910f679ec399cd8826c /src/device
parent1d49fb42ce1ab206eb0518d57fb67e9ac28a3206 (diff)
parent6841b236e89cad45024280c44a77e43490635af2 (diff)
Merge pull request #160 from pigrew/usbtmc
Add usbtmc class driver (READY FOR TESTING)
Diffstat (limited to 'src/device')
-rw-r--r--src/device/usbd.c17
-rw-r--r--src/device/usbd.h31
2 files changed, 48 insertions, 0 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 50964bdee..3700fb988 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -145,6 +145,23 @@ static usbd_class_driver_t const usbd_class_drivers[] =
.sof = NULL
},
#endif
+
+ #if CFG_TUD_USBTMC
+ // Presently USBTMC is the only defined class with the APP_SPECIFIC class code.
+ // We maybe need to add subclass codes here, or a callback to ask if a driver can
+ // handle a particular interface.
+ {
+ .class_code = TUD_USBTMC_APP_CLASS,
+ //.subclass_code = TUD_USBTMC_APP_SUBCLASS
+ .init = usbtmcd_init_cb,
+ .reset = usbtmcd_reset_cb,
+ .open = usbtmcd_open_cb,
+ .control_request = usbtmcd_control_request_cb,
+ .control_complete = usbtmcd_control_complete_cb,
+ .xfer_cb = usbtmcd_xfer_cb,
+ .sof = NULL
+ },
+ #endif
};
enum { USBD_CLASS_DRIVER_COUNT = TU_ARRAY_SIZE(usbd_class_drivers) };
diff --git a/src/device/usbd.h b/src/device/usbd.h
index 5f96e55a4..f0887f0db 100644
--- a/src/device/usbd.h
+++ b/src/device/usbd.h
@@ -261,6 +261,37 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re
/* MS Endpoint (connected to embedded jack out) */\
5, TUSB_DESC_CS_ENDPOINT, MIDI_CS_ENDPOINT_GENERAL, 1, 3
+//------------- TUD_USBTMC/USB488 -------------//
+#define TUD_USBTMC_APP_CLASS (TUSB_CLASS_APPLICATION_SPECIFIC)
+#define TUD_USBTMC_APP_SUBCLASS 0x03u
+
+#define TUD_USBTMC_PROTOCOL_STD 0x00u
+#define TUD_USBTMC_PROTOCOL_USB488 0x01u
+
+// Interface number, number of endpoints, EP string index, USB_TMC_PROTOCOL*, bulk-out endpoint ID,
+// bulk-in endpoint ID
+#define TUD_USBTMC_IF_DESCRIPTOR(_itfnum, _bNumEndpoints, _stridx, _itfProtocol) \
+/* Interface */ \
+ 0x09, TUSB_DESC_INTERFACE, _itfnum, 0x00, _bNumEndpoints, TUD_USBTMC_APP_CLASS, TUD_USBTMC_APP_SUBCLASS, _itfProtocol, _stridx
+
+#define TUD_USBTMC_IF_DESCRIPTOR_LEN 9u
+
+#define TUD_USBTMC_BULK_DESCRIPTORS(_epout, _epin, _bulk_epsize) \
+/* Endpoint Out */ \
+7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_bulk_epsize), 0u, \
+/* Endpoint In */ \
+7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_BULK, U16_TO_U8S_LE(_bulk_epsize), 0u
+
+#define TUD_USBTMC_BULK_DESCRIPTORS_LEN (7u+7u)
+
+/* optional interrupt endpoint */ \
+// _int_pollingInterval : for LS/FS, expressed in frames (1ms each). 16 may be a good number?
+#define TUD_USBTMC_INT_DESCRIPTOR(_ep_interrupt, _ep_interrupt_size, _int_pollingInterval ) \
+7, TUSB_DESC_ENDPOINT, _ep_interrupt, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_ep_interrupt_size), 0x16
+
+#define TUD_USBTMC_INT_DESCRIPTOR_LEN (7u)
+
+
//------------- Vendor -------------//
#define TUD_VENDOR_DESC_LEN (9+7+7)