From d7b39eed5194f0bfe7f5c8713abb6f99607f5081 Mon Sep 17 00:00:00 2001 From: Diego Roversi Date: Sun, 11 Mar 2018 11:36:20 +0100 Subject: add serial ACM handling --- TERES-HID/Descriptors.c | 124 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 112 insertions(+), 12 deletions(-) (limited to 'TERES-HID/Descriptors.c') diff --git a/TERES-HID/Descriptors.c b/TERES-HID/Descriptors.c index 213e230..2d04b49 100644 --- a/TERES-HID/Descriptors.c +++ b/TERES-HID/Descriptors.c @@ -108,8 +108,9 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = { const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Config = { .Header = {.Size = - sizeof(USB_Descriptor_Configuration_Header_t),. - Type = DTYPE_Configuration} + sizeof + (USB_Descriptor_Configuration_Header_t),.Type = + DTYPE_Configuration} , .TotalConfigurationSize = @@ -124,11 +125,109 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) } , + .CDC_IAD = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation}, + + .FirstInterfaceIndex = INTERFACE_ID_CDC_CCI, + .TotalInterfaces = 2, + + .Class = CDC_CSCP_CDCClass, + .SubClass = CDC_CSCP_ACMSubclass, + .Protocol = CDC_CSCP_ATCommandProtocol, + + .IADStrIndex = NO_DESCRIPTOR + }, + .CDC_CCI_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = INTERFACE_ID_CDC_CCI, + .AlternateSetting = 0, + + .TotalEndpoints = 1, + + .Class = CDC_CSCP_CDCClass, + .SubClass = CDC_CSCP_ACMSubclass, + .Protocol = CDC_CSCP_ATCommandProtocol, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + .CDC_Functional_Header = + { + .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, + .Subtype = CDC_DSUBTYPE_CSInterface_Header, + + .CDCSpecification = VERSION_BCD(1,1,0), + }, + + .CDC_Functional_ACM = + { + .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, + .Subtype = CDC_DSUBTYPE_CSInterface_ACM, + + .Capabilities = 0x06, + }, + + .CDC_Functional_Union = + { + .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, + .Subtype = CDC_DSUBTYPE_CSInterface_Union, + + .MasterInterfaceNumber = INTERFACE_ID_CDC_CCI, + .SlaveInterfaceNumber = INTERFACE_ID_CDC_DCI, + }, + + .CDC_NotificationEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = CDC_NOTIFICATION_EPADDR, + .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CDC_NOTIFICATION_EPSIZE, + .PollingIntervalMS = 0xFF + }, + + .CDC_DCI_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = INTERFACE_ID_CDC_DCI, + .AlternateSetting = 0, + + .TotalEndpoints = 2, + + .Class = CDC_CSCP_CDCDataClass, + .SubClass = CDC_CSCP_NoDataSubclass, + .Protocol = CDC_CSCP_NoDataProtocol, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .CDC_DataOutEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = CDC_RX_EPADDR, + .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CDC_TXRX_EPSIZE, + .PollingIntervalMS = 0x05 + }, + + .CDC_DataInEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = CDC_TX_EPADDR, + .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CDC_TXRX_EPSIZE, + .PollingIntervalMS = 0x05 + }, .HID1_KeyboardInterface = { .Header = {.Size = sizeof - (USB_Descriptor_Interface_t),. - Type = DTYPE_Interface} + (USB_Descriptor_Interface_t),.Type + = DTYPE_Interface} , .InterfaceNumber = INTERFACE_ID_Keyboard, @@ -145,8 +244,8 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .HID1_KeyboardHID = { .Header = {.Size = - sizeof(USB_HID_Descriptor_HID_t),. - Type = HID_DTYPE_HID} + sizeof(USB_HID_Descriptor_HID_t),.Type + = HID_DTYPE_HID} , .HIDSpec = VERSION_BCD(1, 1, 1), @@ -160,8 +259,8 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .HID1_ReportINEndpoint = { .Header = {.Size = sizeof - (USB_Descriptor_Endpoint_t),. - Type = DTYPE_Endpoint} + (USB_Descriptor_Endpoint_t),.Type + = DTYPE_Endpoint} , .EndpointAddress = KEYBOARD_IN_EPADDR, @@ -174,8 +273,9 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .HID2_MouseInterface = { .Header = {.Size = - sizeof(USB_Descriptor_Interface_t),. - Type = DTYPE_Interface} + sizeof + (USB_Descriptor_Interface_t),.Type = + DTYPE_Interface} , .InterfaceNumber = INTERFACE_ID_Mouse, @@ -207,8 +307,8 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .HID2_ReportINEndpoint = { .Header = {.Size = sizeof - (USB_Descriptor_Endpoint_t),. - Type = DTYPE_Endpoint} + (USB_Descriptor_Endpoint_t),.Type + = DTYPE_Endpoint} , .EndpointAddress = MOUSE_IN_EPADDR, -- cgit v1.2.3