diff options
| author | hathach <[email protected]> | 2019-04-17 13:43:07 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-04-17 13:43:07 +0700 |
| commit | 516964b3d3532bc8defc21336a0a7b6f69de4ecf (patch) | |
| tree | 7cd10a85488a030faee2b36c3c57805cc701b43d /src/class/cdc | |
| parent | 72575534f84c815e812beb7165c98d74aaa8f487 (diff) | |
add interface descriptor template
Diffstat (limited to 'src/class/cdc')
| -rw-r--r-- | src/class/cdc/cdc_device.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h index 25c721e13..23f4f609a 100644 --- a/src/class/cdc/cdc_device.h +++ b/src/class/cdc/cdc_device.h @@ -104,6 +104,38 @@ bool cdcd_control_request_complete (uint8_t rhport, tusb_control_request_t const bool cdcd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
void cdcd_reset (uint8_t rhport);
+
+//--------------------------------------------------------------------+
+// Interface Descriptor Template
+//--------------------------------------------------------------------+
+
+// Length of template descriptor: 66 bytes
+#define TUD_CDC_DESC_LEN (8+9+5+5+4+5+7+9+7+7)
+
+// CDC Descriptor Template
+// interface number, string index, EP notification address and size, EP data address (out,in) and size.
+#define TUD_CDC_DESCRIPTOR(_itfnum, _stridx, _ep_notif, _ep_notif_size, _epout, _epin, _epsize) \
+ /* Interface Associate */\
+ 0x08, TUSB_DESC_INTERFACE_ASSOCIATION, _itfnum, 0x02, TUSB_CLASS_CDC, CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL, CDC_COMM_PROTOCOL_ATCOMMAND, 0x00,\
+ /* CDC Control Interface */\
+ 0x09, TUSB_DESC_INTERFACE, _itfnum, 0x00, 0x01, TUSB_CLASS_CDC, CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL, CDC_COMM_PROTOCOL_ATCOMMAND, _stridx,\
+ /* CDC Header */\
+ 0x05, TUSB_DESC_CLASS_SPECIFIC, CDC_FUNC_DESC_HEADER, U16_TO_U8S_LE(0x0120),\
+ /* CDC Call */\
+ 0x05, TUSB_DESC_CLASS_SPECIFIC, CDC_FUNC_DESC_CALL_MANAGEMENT, 0x00, (_itfnum) + 1,\
+ /* CDC ACM: support line request */\
+ 0x04, TUSB_DESC_CLASS_SPECIFIC, CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT, 0x02,\
+ /* CDC Union */\
+ 0x05, TUSB_DESC_CLASS_SPECIFIC, CDC_FUNC_DESC_UNION, _itfnum, (_itfnum) + 1,\
+ /* Endpoint Notification */\
+ 0x07, TUSB_DESC_ENDPOINT, _ep_notif, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_ep_notif_size), 0x10,\
+ /* CDC Data Interface */\
+ 0x09, TUSB_DESC_INTERFACE, (_itfnum)+1, 0x00, 0x02, TUSB_CLASS_CDC_DATA, 0x00, 0x00, 0x00,\
+ /* Endpoint Out */\
+ 0x07, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0x00,\
+ /* Endpoint In */\
+ 0x07, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0x00
+
#ifdef __cplusplus
}
#endif
|
