add Custom Interface
change interface descriptor
This commit is contained in:
		 Submodule lib/tinyusb updated: 2b85a8fd46...5692b84ddf
									
								
							| @@ -125,6 +125,7 @@ C_SOURCE_FILES += $(TUSB_PATH)/common/tusb_fifo.c | |||||||
| C_SOURCE_FILES += $(TUSB_PATH)/device/usbd.c | C_SOURCE_FILES += $(TUSB_PATH)/device/usbd.c | ||||||
| C_SOURCE_FILES += $(TUSB_PATH)/class/cdc/cdc_device.c | C_SOURCE_FILES += $(TUSB_PATH)/class/cdc/cdc_device.c | ||||||
| C_SOURCE_FILES += $(TUSB_PATH)/class/msc/msc_device.c | C_SOURCE_FILES += $(TUSB_PATH)/class/msc/msc_device.c | ||||||
|  | C_SOURCE_FILES += $(TUSB_PATH)/class/custom/custom_device.c | ||||||
| C_SOURCE_FILES += $(TUSB_PATH)/tusb.c | C_SOURCE_FILES += $(TUSB_PATH)/tusb.c | ||||||
|  |  | ||||||
| #****************************************************************************** | #****************************************************************************** | ||||||
| @@ -271,10 +272,10 @@ all: | |||||||
| 	@echo Making Feather52840 board | 	@echo Making Feather52840 board | ||||||
| 	@echo ---------------------- | 	@echo ---------------------- | ||||||
| 	@$(MAKE) -s -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e feather52840 | 	@$(MAKE) -s -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e feather52840 | ||||||
| 	@$(MAKE) -s -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e clean | 	#@$(MAKE) -s -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e clean | ||||||
| 	@echo Making Metro52 board | 	#@echo Making Metro52 board | ||||||
| 	@echo -------------------- | 	#@echo -------------------- | ||||||
| 	@$(MAKE) -s -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e metro52 | 	#@$(MAKE) -s -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e metro52 | ||||||
|  |  | ||||||
| #target for printing all targets | #target for printing all targets | ||||||
| help: | help: | ||||||
|   | |||||||
| @@ -185,6 +185,10 @@ | |||||||
|               <file file_name="../../lib/tinyusb/tinyusb/class/msc/msc_device.c" /> |               <file file_name="../../lib/tinyusb/tinyusb/class/msc/msc_device.c" /> | ||||||
|               <file file_name="../../lib/tinyusb/tinyusb/class/msc/msc_device.h" /> |               <file file_name="../../lib/tinyusb/tinyusb/class/msc/msc_device.h" /> | ||||||
|             </folder> |             </folder> | ||||||
|  |             <folder Name="custom"> | ||||||
|  |               <file file_name="../../lib/tinyusb/tinyusb/class/custom/custom_device.c" /> | ||||||
|  |               <file file_name="../../lib/tinyusb/tinyusb/class/custom/custom_device.h" /> | ||||||
|  |             </folder> | ||||||
|           </folder> |           </folder> | ||||||
|           <folder Name="common"> |           <folder Name="common"> | ||||||
|             <file file_name="../../lib/tinyusb/tinyusb/common/binary.h" /> |             <file file_name="../../lib/tinyusb/tinyusb/common/binary.h" /> | ||||||
|   | |||||||
| @@ -67,6 +67,8 @@ | |||||||
| #define CFG_TUD_MSC                 1 | #define CFG_TUD_MSC                 1 | ||||||
| #define CFG_TUD_CDC                 1 | #define CFG_TUD_CDC                 1 | ||||||
|  |  | ||||||
|  | #define CFG_TUD_CUSTOM_CLASS        1 | ||||||
|  |  | ||||||
|  |  | ||||||
| /*------------------------------------------------------------------*/ | /*------------------------------------------------------------------*/ | ||||||
| /* CLASS DRIVER | /* CLASS DRIVER | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ app_descriptor_configuration_t const desc_configuration = | |||||||
|         .bConfigurationValue = 1, |         .bConfigurationValue = 1, | ||||||
|         .iConfiguration      = 0x00, |         .iConfiguration      = 0x00, | ||||||
|         .bmAttributes        = TUSB_DESC_CONFIG_ATT_BUS_POWER, |         .bmAttributes        = TUSB_DESC_CONFIG_ATT_BUS_POWER, | ||||||
|         .bMaxPower           = TUSB_DESC_CONFIG_POWER_MA(500) |         .bMaxPower           = TUSB_DESC_CONFIG_POWER_MA(100) | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
| #if CFG_TUD_CDC | #if CFG_TUD_CDC | ||||||
| @@ -114,7 +114,7 @@ app_descriptor_configuration_t const desc_configuration = | |||||||
|           .bInterfaceClass    = TUSB_CLASS_CDC, |           .bInterfaceClass    = TUSB_CLASS_CDC, | ||||||
|           .bInterfaceSubClass = CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL, |           .bInterfaceSubClass = CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL, | ||||||
|           .bInterfaceProtocol = CDC_COMM_PROTOCOL_ATCOMMAND, |           .bInterfaceProtocol = CDC_COMM_PROTOCOL_ATCOMMAND, | ||||||
|           .iInterface         = 0x00 |           .iInterface         = 0x04 | ||||||
|       }, |       }, | ||||||
|  |  | ||||||
|       .header = |       .header = | ||||||
| @@ -202,7 +202,7 @@ app_descriptor_configuration_t const desc_configuration = | |||||||
| #if CFG_TUD_MSC | #if CFG_TUD_MSC | ||||||
|     .msc = |     .msc = | ||||||
|     { |     { | ||||||
|       .interface = |       .itf = | ||||||
|       { |       { | ||||||
|           .bLength            = sizeof(tusb_desc_interface_t), |           .bLength            = sizeof(tusb_desc_interface_t), | ||||||
|           .bDescriptorType    = TUSB_DESC_INTERFACE, |           .bDescriptorType    = TUSB_DESC_INTERFACE, | ||||||
| @@ -212,7 +212,7 @@ app_descriptor_configuration_t const desc_configuration = | |||||||
|           .bInterfaceClass    = TUSB_CLASS_MSC, |           .bInterfaceClass    = TUSB_CLASS_MSC, | ||||||
|           .bInterfaceSubClass = MSC_SUBCLASS_SCSI, |           .bInterfaceSubClass = MSC_SUBCLASS_SCSI, | ||||||
|           .bInterfaceProtocol = MSC_PROTOCOL_BOT, |           .bInterfaceProtocol = MSC_PROTOCOL_BOT, | ||||||
|           .iInterface         = 0x07 |           .iInterface         = 0x05 | ||||||
|       }, |       }, | ||||||
|  |  | ||||||
|       .ep_out = |       .ep_out = | ||||||
| @@ -234,6 +234,44 @@ app_descriptor_configuration_t const desc_configuration = | |||||||
|           .wMaxPacketSize   = { .size = MSC_EDPT_SIZE}, |           .wMaxPacketSize   = { .size = MSC_EDPT_SIZE}, | ||||||
|           .bInterval        = 1 |           .bInterval        = 1 | ||||||
|       } |       } | ||||||
|  |     }, | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #if CFG_TUD_CUSTOM_CLASS | ||||||
|  |     .cus = | ||||||
|  |     { | ||||||
|  |       .itf = | ||||||
|  |       { | ||||||
|  |           .bLength            = sizeof(tusb_desc_interface_t), | ||||||
|  |           .bDescriptorType    = TUSB_DESC_INTERFACE, | ||||||
|  |           .bInterfaceNumber   = ITF_NUM_CUS, | ||||||
|  |           .bAlternateSetting  = 0x00, | ||||||
|  |           .bNumEndpoints      = 2, | ||||||
|  |           .bInterfaceClass    = TUSB_CLASS_VENDOR_SPECIFIC, | ||||||
|  |           .bInterfaceSubClass = 0, | ||||||
|  |           .bInterfaceProtocol = 0, | ||||||
|  |           .iInterface         = 0x06 | ||||||
|  |       }, | ||||||
|  |  | ||||||
|  |       .ep_out = | ||||||
|  |       { | ||||||
|  |           .bLength          = sizeof(tusb_desc_endpoint_t), | ||||||
|  |           .bDescriptorType  = TUSB_DESC_ENDPOINT, | ||||||
|  |           .bEndpointAddress = CUS_EDPT_OUT, | ||||||
|  |           .bmAttributes     = { .xfer = TUSB_XFER_BULK }, | ||||||
|  |           .wMaxPacketSize   = { .size = CUS_EDPT_SIZE}, | ||||||
|  |           .bInterval        = 1 | ||||||
|  |       }, | ||||||
|  |  | ||||||
|  |       .ep_in = | ||||||
|  |       { | ||||||
|  |           .bLength          = sizeof(tusb_desc_endpoint_t), | ||||||
|  |           .bDescriptorType  = TUSB_DESC_ENDPOINT, | ||||||
|  |           .bEndpointAddress = CUS_EDPT_IN, | ||||||
|  |           .bmAttributes     = { .xfer = TUSB_XFER_BULK }, | ||||||
|  |           .wMaxPacketSize   = { .size = CUS_EDPT_SIZE}, | ||||||
|  |           .bInterval        = 1 | ||||||
|  |       } | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
| }; | }; | ||||||
| @@ -253,38 +291,33 @@ uint16_t const * const string_descriptor_arr [] = | |||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     [1] = (uint16_t []) { // manufacturer |     [1] = (uint16_t []) { // manufacturer | ||||||
|         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(11), TUSB_DESC_STRING), |         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(19), TUSB_DESC_STRING), | ||||||
|         't', 'i', 'n', 'y', 'u', 's', 'b', '.', 'o', 'r', 'g' // len = 11 |         'A','d','a','f','r','u','i','t',' ','I','n','d','u','s','t','r','i','e','s' | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     [2] = (uint16_t []) { // product |     [2] = (uint16_t []) { // product | ||||||
|         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(14), TUSB_DESC_STRING), |         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(18), TUSB_DESC_STRING), | ||||||
|         't', 'i', 'n', 'y', 'u', 's', 'b', ' ', 'd', 'e', 'v', 'i', 'c', 'e' // len = 14 |         'B','l','u','e','f','r','u','i','t',' ','n','R','F','5','2','8','4','0' | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     [3] = (uint16_t []) { // serials |     [3] = (uint16_t []) { // serials TODO use chip ID | ||||||
|         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(4), TUSB_DESC_STRING), |         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(4), TUSB_DESC_STRING), | ||||||
|         '1', '2', '3', '4' // len = 4 |         '1', '2', '3', '4' // len = 4 | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     [4] = (uint16_t []) { // CDC Interface |     [4] = (uint16_t []) { // CDC Interface | ||||||
|         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(3), TUSB_DESC_STRING), |         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(16), TUSB_DESC_STRING), | ||||||
|         'c', 'd', 'c' // len = 3 |         'B','l','u','e','f','r','u','i','t',' ','S','e','r','i','a','l' | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     [5] = (uint16_t []) { // Keyboard Interface |     [5] = (uint16_t []) { // MSC Interface | ||||||
|         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(5), TUSB_DESC_STRING), |         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(17), TUSB_DESC_STRING), | ||||||
|         'm', 'o', 'u', 's', 'e' // len = 5 |         'B','l','u','e','f','r','u','i','t',' ','S','t','o','r','a','g','e' | ||||||
|     }, |     }, | ||||||
|  |  | ||||||
|     [6] = (uint16_t []) { // Keyboard Interface |     [6] = (uint16_t []) { // Custom Interface | ||||||
|         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(8), TUSB_DESC_STRING), |         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(16), TUSB_DESC_STRING), | ||||||
|         'k', 'e', 'y', 'b', 'o', 'a', 'r', 'd' // len = 8 |         'B','l','u','e','f','r','u','i','t',' ','C','u','s','t','o','m' | ||||||
|     }, |  | ||||||
|  |  | ||||||
|     [7] = (uint16_t []) { // MSC Interface |  | ||||||
|         ENDIAN_BE16_FROM( STRING_LEN_UNICODE(3), TUSB_DESC_STRING), |  | ||||||
|         'm', 's', 'c' // len = 3 |  | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -58,9 +58,10 @@ | |||||||
|  |  | ||||||
| #define ITF_NUM_CDC    0 | #define ITF_NUM_CDC    0 | ||||||
| #define ITF_NUM_MSC    2 | #define ITF_NUM_MSC    2 | ||||||
|  | #define ITF_NUM_CUS    3 | ||||||
|  |  | ||||||
| // total number of interfaces | // total number of interfaces | ||||||
| #define ITF_TOTAL      (CFG_TUD_CDC*2 + CFG_TUD_MSC) | #define ITF_TOTAL      (CFG_TUD_CDC*2 + CFG_TUD_MSC + CFG_TUD_CUSTOM_CLASS) | ||||||
|  |  | ||||||
| //--------------------------------------------------------------------+ | //--------------------------------------------------------------------+ | ||||||
| // Endpoints Address & Max Packet Size | // Endpoints Address & Max Packet Size | ||||||
| @@ -79,6 +80,10 @@ | |||||||
| #define MSC_EDPT_IN          EDPT_IN(3) | #define MSC_EDPT_IN          EDPT_IN(3) | ||||||
| #define MSC_EDPT_SIZE        64 | #define MSC_EDPT_SIZE        64 | ||||||
|  |  | ||||||
|  | #define CUS_EDPT_OUT         EDPT_OUT(4) | ||||||
|  | #define CUS_EDPT_IN          EDPT_IN(4) | ||||||
|  | #define CUS_EDPT_SIZE        64 | ||||||
|  |  | ||||||
|  |  | ||||||
| //--------------------------------------------------------------------+ | //--------------------------------------------------------------------+ | ||||||
| // CONFIGURATION DESCRIPTOR | // CONFIGURATION DESCRIPTOR | ||||||
| @@ -110,12 +115,21 @@ typedef struct ATTR_PACKED | |||||||
| #if CFG_TUD_MSC | #if CFG_TUD_MSC | ||||||
|   struct ATTR_PACKED |   struct ATTR_PACKED | ||||||
|   { |   { | ||||||
|     tusb_desc_interface_t             interface; |     tusb_desc_interface_t             itf; | ||||||
|     tusb_desc_endpoint_t              ep_out; |     tusb_desc_endpoint_t              ep_out; | ||||||
|     tusb_desc_endpoint_t              ep_in; |     tusb_desc_endpoint_t              ep_in; | ||||||
|   }msc; |   }msc; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #if CFG_TUD_CUSTOM_CLASS | ||||||
|  |   struct ATTR_PACKED | ||||||
|  |   { | ||||||
|  |     tusb_desc_interface_t             itf; | ||||||
|  |     tusb_desc_endpoint_t              ep_out; | ||||||
|  |     tusb_desc_endpoint_t              ep_in; | ||||||
|  |   }cus; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| } app_descriptor_configuration_t; | } app_descriptor_configuration_t; | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user