aboutsummaryrefslogtreecommitdiffstats
path: root/core/usb/descriptors.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/usb/descriptors.c')
-rw-r--r--core/usb/descriptors.c165
1 files changed, 86 insertions, 79 deletions
diff --git a/core/usb/descriptors.c b/core/usb/descriptors.c
index 27d4250..7ff26a2 100644
--- a/core/usb/descriptors.c
+++ b/core/usb/descriptors.c
@@ -2,6 +2,8 @@
#include "descriptors.h"
+#include "libmaple.h"
+#include "usb_config.h"
const USB_Descriptor_Device usbVcomDescriptor_Device = {
bLength: sizeof(USB_Descriptor_Device),
@@ -20,22 +22,19 @@ const USB_Descriptor_Device usbVcomDescriptor_Device = {
bNumConfigurations: 0x01
};
-const USB_Descriptor_Configuration usbVcomDescriptor_Config = {
- Header:
- {
- bLength: sizeof(USB_Descriptor_Config_Header),
- bDescriptorType: USB_DESCRIPTOR_TYPE_CONFIGURATION,
- wTotalLength: sizeof(USB_Descriptor_Configuration),
- bNumInterfaces: 0x02,
- bConfigurationValue: 0x01,
- iConfiguration: 0x00,
- bmAttributes: (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATT_SELF_POWERED),
- bMaxPower: USB_CONFIG_MAX_POWER
- },
+const USB_Descriptor_Config usbVcomDescriptor_Config = {
+ bLength: 0x09,//sizeof(USB_Descriptor_Config_Header),
+ bDescriptorType: USB_DESCRIPTOR_TYPE_CONFIGURATION,
+ wTotalLength: 0x43,//sizeof(USB_Descriptor_Config),
+ bNumInterfaces: 0x02,
+ bConfigurationValue: 0x01,
+ iConfiguration: 0x00,
+ bmAttributes: (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELF_POWERED),
+ bMaxPower: USB_CONFIG_MAX_POWER,
CCI_Interface:
{
- bLength: sizeof(USB_Descriptor_Interface),
+ bLength: 0x09,//sizeof(USB_Descriptor_Interface),
bDescriptorType: USB_DESCRIPTOR_TYPE_INTERFACE,
bInterfaceNumber: 0x00,
bAlternateSetting: 0x00,
@@ -48,7 +47,7 @@ const USB_Descriptor_Configuration usbVcomDescriptor_Config = {
CDC_Functional_IntHeader:
{
- bLength: sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)),
+ bLength: 0x05,//sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)),
bDescriptorType: 0x24,
SubType: 0x00,
Data: {0x01, 0x10}
@@ -56,7 +55,7 @@ const USB_Descriptor_Configuration usbVcomDescriptor_Config = {
CDC_Functional_CallManagement:
{
- bLength: sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)),
+ bLength: 0x05,//sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)),
bDescriptorType: 0x24,
SubType: 0x01,
Data: {0x03, 0x01}
@@ -64,7 +63,7 @@ const USB_Descriptor_Configuration usbVcomDescriptor_Config = {
CDC_Functional_ACM:
{
- bLength: sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)),
+ bLength: 0x04,//sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)),
bDescriptorType: 0x24,
SubType: 0x02,
Data: {0x06}
@@ -72,54 +71,59 @@ const USB_Descriptor_Configuration usbVcomDescriptor_Config = {
CDC_Functional_Union:
{
- bLength: sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)),
+ bLength: 0x05,//sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)),
bDescriptorType: 0x24,
SubType: 0x06,
Data: {0x00, 0x01}
},
- ManagementEndpoint:
- {
- bLength: sizeof(USB_Descriptor_Endpoint),
- bDescriptorType: USB_DESCRIPTOR_TYPE_ENDPOINT,
- bEndpointAddress: (USB_DESCRIPTOR_ENDPOINT_IN | VCOM_NOTIFICATION_EPNUM),
- bmAttributes: EP_TYPE_INTERRUPT,
- wMaxPacketSize: VCOM_NOTIFICATION_EPSIZE,
- bInterval: 0xFF
- },
-
- DCI_Interface:
- {
- bLength: sizeof(USB_Descriptor_Interface),
- bDescriptorType: USB_DESCRIPTOR_TYPE_INTERFACE,
- bInterfaceNumber: 0x01,
- bAlternateSetting: 0x00,
- bNumEndpoints: 0x02,
- bInterfaceClass: 0x0A,
- bInterfaceSubClass: 0x00,
- bInterfaceProtocol: 0x00,
- iInterface: 0x00
- }.
-
- DataOutEndpoint:
- {
- bLength: sizeof(USB_Descriptor_Endpoint),
- bDescriptorType: USB_DESCRIPTOR_TYPE_ENDPOINT,
- bEndpointAddress: (USB_DESCRIPTOR_ENDPOINT_OUT | VCOM_RX_EPNUM),
- bmAttributes: EP_TYPE_BULK,
- wMaxPacketSize: VCOM_RX_EPSIZE,
- bInterval: 0x00
- },
-
- DataInPoiint:
- {
- bLength: sizeof(USB_Descriptor_Endpoint),
- bDescriptorType: USB_DESCRIPTOR_TYPE_ENDPOINT,
- bEndpointAddress: (USB_DESCRIPTOR_ENDPOINT_IN | VCOM_TX_EPNUM),
- bmAttributes: EP_TYPE_BULK,
- wMaxPacketSize: VCOM_TX_EPSIZE,
- bInterval: 0x00
- }
+ // ManagementEndpoint:
+ // {
+ EP1_bLength: 0x07,//sizeof(USB_Descriptor_Endpoint),
+ EP1_bDescriptorType: USB_DESCRIPTOR_TYPE_ENDPOINT,
+ EP1_bEndpointAddress: (USB_DESCRIPTOR_ENDPOINT_IN | VCOM_NOTIFICATION_EPNUM),
+ EP1_bmAttributes: EP_TYPE_INTERRUPT,
+ EP1_wMaxPacketSize0: VCOM_NOTIFICATION_EPSIZE,
+ EP1_wMaxPacketSize1: 0x00,
+ EP1_bInterval: 0xFF,
+ // },
+
+ // DCI_Interface:
+ // {
+ DCI_bLength: 0x09,//sizeof(USB_Descriptor_Interface),
+ DCI_bDescriptorType: USB_DESCRIPTOR_TYPE_INTERFACE,
+ DCI_bInterfaceNumber: 0x01,
+ DCI_bAlternateSetting: 0x00,
+ DCI_bNumEndpoints: 0x02,
+ DCI_bInterfaceClass: 0x0A,
+ DCI_bInterfaceSubClass: 0x00,
+ DCI_bInterfaceProtocol: 0x00,
+ DCI_iInterface: 0x00,
+ // },
+
+ //DataOutEndpoint:
+ // {
+ // },
+ EP2_bLength: 0x07,//sizeof(USB_Descriptor_Endpoint),
+ EP2_bDescriptorType: USB_DESCRIPTOR_TYPE_ENDPOINT,
+ EP2_bEndpointAddress: (USB_DESCRIPTOR_ENDPOINT_OUT | VCOM_RX_EPNUM),
+ EP2_bmAttributes: EP_TYPE_BULK,
+ EP2_wMaxPacketSize0: VCOM_RX_EPSIZE,
+ EP2_wMaxPacketSize1: 0x00,
+ EP2_bInterval: 0x00,
+
+
+ // DataInEndpoint:
+ // {
+ EP3_bLength: 0x07,//sizeof(USB_Descriptor_Endpoint),
+ EP3_bDescriptorType: USB_DESCRIPTOR_TYPE_ENDPOINT,
+ EP3_bEndpointAddress: (USB_DESCRIPTOR_ENDPOINT_IN | VCOM_TX_EPNUM),
+ EP3_bmAttributes: EP_TYPE_BULK,
+ EP3_wMaxPacketSize0: VCOM_TX_EPSIZE,
+ EP3_wMaxPacketSize1: 0x00,
+ EP3_bInterval: 0x00
+
+ // }
};
/*
@@ -139,23 +143,26 @@ const USB_Descriptor_Configuration usbVcomDescriptor_Config = {
which is 0x0409 for US English
*/
-const USB_Descriptor_String usbVcomDescriptor_LangID =
- {
- bLength: USB_DESCRIPTOR_STRING_LEN(1),
- bDescriptorType: USB_DESCRIPTOR_TYPE_STRING,
- bString: 0x0409
- };
-
-const USB_Descriptor_String usbVcomDescriptor_iManufacturer =
- {
- bLength: USB_DESCRIPTOR_STRING_LEN(8),
- bDescriptorType: USB_DESCRIPTOR_TYPE_STRING,
- bString: L"LeafLabs"
- };
-
-const USB_Descriptor_String usbVcomDescriptor_iProduct =
- {
- bLength: USB_DESCRIPTOR_STRING_LEN(8),
- bDescriptorType: USB_DESCRIPTOR_TYPE_STRING,
- bString: L"Maple R3"
- };
+uint8 usbVcomDescriptor_LangID[USB_DESCRIPTOR_STRING_LEN(1)] =
+{
+ USB_DESCRIPTOR_STRING_LEN(1),
+ USB_DESCRIPTOR_TYPE_STRING,
+ 0x09,
+ 0x04
+};
+
+uint8 usbVcomDescriptor_iManufacturer[USB_DESCRIPTOR_STRING_LEN(8)] =
+{
+ USB_DESCRIPTOR_STRING_LEN(8),
+ USB_DESCRIPTOR_TYPE_STRING,
+ 'L', 0, 'e', 0, 'a', 0, 'f', 0,
+ 'L', 0, 'a', 0, 'b', 0, 's', 0
+};
+
+uint8 usbVcomDescriptor_iProduct[USB_DESCRIPTOR_STRING_LEN(8)] =
+{
+ USB_DESCRIPTOR_STRING_LEN(8),
+ USB_DESCRIPTOR_TYPE_STRING,
+ 'M', 0, 'a', 0, 'p', 0, 'l', 0,
+ 'e', 0, ' ', 0, 'R', 0, '3', 0
+};