diff options
Diffstat (limited to 'emb/pastilda/usb/usb_device/usbd_composite_desc.h')
-rw-r--r-- | emb/pastilda/usb/usb_device/usbd_composite_desc.h | 184 |
1 files changed, 81 insertions, 103 deletions
diff --git a/emb/pastilda/usb/usb_device/usbd_composite_desc.h b/emb/pastilda/usb/usb_device/usbd_composite_desc.h index 2c09aa0..b4d0181 100644 --- a/emb/pastilda/usb/usb_device/usbd_composite_desc.h +++ b/emb/pastilda/usb/usb_device/usbd_composite_desc.h @@ -3,7 +3,10 @@ * hosted at http://github.com/thirdpin/pastilda * * Copyright (C) 2016 Third Pin LLC - * Written by Anastasiia Lazareva <a.lazareva@thirdpin.ru> + * + * Written by: + * Anastasiia Lazareva <a.lazareva@thirdpin.ru> + * Dmitrii Lisin <mrlisdim@ya.ru> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,8 +39,8 @@ typedef enum { typedef enum : uint8_t { E_KEYBOARD = 0x81, - E_MASS_STORAGE_IN = 0x83, - E_MASS_STORAGE_OUT = 0x03 + E_MASS_STORAGE_IN = 0x83, + E_MASS_STORAGE_OUT = 0x03 } Endpoint; typedef enum { @@ -63,27 +66,20 @@ public: static constexpr char usb_strings[][30] = { - "Third Pin", + "Third pin", "Composite Device", "Pastilda" }; static constexpr struct usb_device_descriptor dev = { - USB_DT_DEVICE_SIZE, //bLength - USB_DT_DEVICE, //bDescriptorType - 0x0110, //bcdUSB - 0x0, //bDeviceClass - 0x00, //bDeviceSubClass - 0x00, //bDeviceProtocol - 64, //bMaxPacketSize0 - 0x0483, //idVendor - 0x5741, //idProduct - 0x0200, //bcdDevice - 1, //iManufacturer - 2, //iProduct - 3, //iSerialNumber - 1 //bNumConfigurations + USB_DT_DEVICE_SIZE, + USB_DT_DEVICE, + 0x0110, + 0x0, + 0x00, 0x00, 64, + 0x0483, 0x5741, 0x0200, + 1, 2, 3, 1 }; typedef struct __attribute__((packed)) @@ -98,109 +94,91 @@ public: static constexpr type_hid_function keyboard_hid_function = { - { - 9, //bLength - USB_DT_HID, //bDescriptorType - 0x0111, //bcdHID - 0, //bCountryCode - 1 //bNumDescriptors - }, - - { - USB_DT_REPORT, - sizeof(keyboard_report_descriptor) - } + { + 9, + USB_DT_HID, + 0x0111, 0, 1 + }, + + { + USB_DT_REPORT, + sizeof(keyboard_report_descriptor) + } }; static constexpr struct usb_endpoint_descriptor hid_endpoint = { - USB_DT_ENDPOINT_SIZE, //bLength - USB_DT_ENDPOINT, //bDescriptorType - Endpoint::E_KEYBOARD, //bEndpointAddress - USB_ENDPOINT_ATTR_INTERRUPT, //bmAttributes - 64, //wMaxPacketSize - 0x20 //bInterval + USB_DT_ENDPOINT_SIZE, + USB_DT_ENDPOINT, Endpoint::E_KEYBOARD, + USB_ENDPOINT_ATTR_INTERRUPT, + 64, 0x10 }; static constexpr struct usb_endpoint_descriptor msc_endpoint[] = { - { - USB_DT_ENDPOINT_SIZE, //bLength - USB_DT_ENDPOINT, //bDescriptorType - Endpoint::E_MASS_STORAGE_IN, //bEndpointAddress - USB_ENDPOINT_ATTR_BULK, //bmAttributes - 64, //wMaxPacketSize - 0 //bInterval - }, - - { - USB_DT_ENDPOINT_SIZE, //bLength - USB_DT_ENDPOINT, //bDescriptorType - Endpoint::E_MASS_STORAGE_OUT, //bEndpointAddress - USB_ENDPOINT_ATTR_BULK, //bmAttributes - 64, //wMaxPacketSize - 0 //bInterval - } + { + USB_DT_ENDPOINT_SIZE, + USB_DT_ENDPOINT, + Endpoint::E_MASS_STORAGE_IN, USB_ENDPOINT_ATTR_BULK, + 64, 0 + }, + + { + USB_DT_ENDPOINT_SIZE, + USB_DT_ENDPOINT, + Endpoint::E_MASS_STORAGE_OUT, USB_ENDPOINT_ATTR_BULK, + 64, 0 + } }; static constexpr struct usb_interface_descriptor iface[] = { - { - USB_DT_INTERFACE_SIZE, //bLength - USB_DT_INTERFACE, //bDescriptorType - Interface::I_KEYBOARD, //bInterfaceNumber - 0, //bAlternateSetting - 1, //bNumEndpoints - USB_CLASS_HID, //bInterfaceClass - 1, //bInterfaceSubClass - 1, //bInterfaceProtocol - 0, //iInterface - &hid_endpoint, &keyboard_hid_function, - sizeof(keyboard_hid_function) - }, + { + USB_DT_INTERFACE_SIZE, + USB_DT_INTERFACE, + Interface::I_KEYBOARD, 0, 1, + USB_CLASS_HID, + 1, 1, 0, + &hid_endpoint, &keyboard_hid_function, + sizeof(keyboard_hid_function) + }, + + { + USB_DT_INTERFACE_SIZE, + USB_DT_INTERFACE, + Interface::I_MASS_STORAGE, 0, 2, + USB_CLASS_MSC, + USB_MSC_SUBCLASS_SCSI, USB_MSC_PROTOCOL_BBB, 0x00, + msc_endpoint, 0, 0 + }, - { - USB_DT_INTERFACE_SIZE, //bLength - USB_DT_INTERFACE, //bDescriptorType - Interface::I_MASS_STORAGE, //bInterfaceNumber - 0, //bAlternateSetting - 2, //bNumEndpoints - USB_CLASS_MSC, //bInterfaceClass - USB_MSC_SUBCLASS_SCSI, //bInterfaceSubClass - USB_MSC_PROTOCOL_BBB, //bInterfaceProtocol - 0x00, //iInterface - msc_endpoint, 0, 0 - }, }; - + //array static constexpr struct usb_config_descriptor::usb_interface ifaces[] - { - { - (uint8_t *)0, //cur_altsetting - 1, //num_altsetting - (usb_iface_assoc_descriptor*)0, //iface_assoc - &iface[Interface::I_KEYBOARD] //altsetting - }, - - { - (uint8_t *)0, //cur_altsetting - 1, //num_altsetting - (usb_iface_assoc_descriptor*)0, //iface_assoc - &iface[Interface::I_MASS_STORAGE] //altsetting - }, - }; + { + { + (uint8_t *)0, + 1, + (usb_iface_assoc_descriptor*)0, + &iface[Interface::I_KEYBOARD] + }, + + { + (uint8_t *)0, + 1, + (usb_iface_assoc_descriptor*)0, + &iface[Interface::I_MASS_STORAGE] + }, + + }; static constexpr struct usb_config_descriptor config_descr = { - USB_DT_CONFIGURATION_SIZE, //bLength - USB_DT_CONFIGURATION, //bDescriptorType - 0, //wTotalLength - 2, //bNumInterfaces - 1, //bConfigurationValue - 0, //iConfiguration - 0x80, //bmAttributes - 0x50, //bMaxPower - ifaces + USB_DT_CONFIGURATION_SIZE, + USB_DT_CONFIGURATION, + 0, + 2, 1, 0, 0x80, 0x50, + ifaces }; UsbCompositeDescriptors() {} |