Exemple #1
0
/*
 * Configuration Descriptor wrapper.
 */
static const USBDescriptor vcom_configuration_descriptor = {
  sizeof vcom_configuration_descriptor_data,
  vcom_configuration_descriptor_data
};

/*
 * U.S. English language identifier.
 */
static const uint8_t vcom_string0[] = {
  USB_DESC_BYTE(4),                     /* bLength.                         */
  USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType.                 */
  USB_DESC_WORD(0x0409)                 /* wLANGID (U.S. English).          */
};

/*
 * Vendor string.
 */
static const uint8_t vcom_string1[] = {
  USB_DESC_BYTE(38),                    /* bLength.                         */
  USB_DESC_BYTE(USB_DESCRIPTOR_STRING), /* bDescriptorType.                 */
  'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0,
  'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0,
  'c', 0, 's', 0
};

/*
 * Device Description string.
  USB_DESC_INTERFACE(0,        /* bInterfaceNumber */
                     0,        /* bAlternateSetting */
                     1,        /* bNumEndpoints */
                     0x03,     /* bInterfaceClass: HID */
                     0x00,     /* bInterfaceSubClass: None */
                     0x00,     /* bInterfaceProtocol: None */
                     0),       /* iInterface */

  /* HID descriptor (9 bytes) */
  USB_DESC_BYTE(9),            /* bLength */
  USB_DESC_BYTE(0x21),         /* bDescriptorType (HID class) */
  USB_DESC_BCD(0x0111),        /* bcdHID: HID version 1.11 */
  USB_DESC_BYTE(0),            /* bCountryCode */
  USB_DESC_BYTE(1),            /* bNumDescriptors */
  USB_DESC_BYTE(0x22),         /* bDescriptorType (report desc) */
  USB_DESC_WORD(sizeof(hid_report_descriptor_data)), /* wDescriptorLength */

  /* HID debug Endpoint (IN) Descriptor (7 bytes) */
  USB_DESC_ENDPOINT(DEBUG_TX_ENDPOINT | 0x80,  /* bEndpointAddress */
                    0x03,      /* bmAttributes (Interrupt) */
                    DEBUG_TX_SIZE, /* wMaxPacketSize */
                    1)         /* bInterval */
};

/* Configuration Descriptor wrapper */
static const USBDescriptor hid_configuration_descriptor = {
  sizeof hid_configuration_descriptor_data,
  hid_configuration_descriptor_data
};

/* HID descriptor wrapper */
Exemple #3
0
     64,                    /* max packet size                                */
     0x05                   /* polling interval (ignored for bulk end-points) */
    )
};
static const USBDescriptor configurationDescriptor =
{
  sizeof(configurationDescriptorData),
  configurationDescriptorData
};

/* Language descriptor */
static const uint8_t languageDescriptorData[] =
{
  USB_DESC_BYTE(4),
  USB_DESC_BYTE(USB_DESCRIPTOR_STRING),
  USB_DESC_WORD(0x0409) /* U.S. english */
};
static const USBDescriptor languageDescriptor =
{
  sizeof(languageDescriptorData),
  languageDescriptorData
};

/* Vendor descriptor */
static const uint8_t vendorDescriptorData[] =
{
  USB_DESC_BYTE(20),
  USB_DESC_BYTE(USB_DESCRIPTOR_STRING),
  'P', 0, 'a', 0, 'p', 0, 'a', 0, 'r', 0, 'a', 0, 'z', 0, 'z', 0, 'i', 0
};
static const USBDescriptor vendorDescriptor =
Exemple #4
0
//Macro to calculate the Unicode length of a string with a given number of Unicode characters
#define USB_STRING_LEN(UnicodeChars)      (2 + ((UnicodeChars) << 1))
// Helper macro for byte values into descriptor strings.
#define USB_DESC_BYTE(b) ((uint8_t)(b))
// Helper macro for word values into descriptor strings.
#define USB_DESC_WORD(w)                                                    \
  (uint8_t)((w) & 255),                                                     \
  (uint8_t)(((w) >> 8) & 255)


// ============================== Descriptors ==================================
// Device
static const uint8_t DeviceDescriptor[] = {
        USB_DESC_BYTE(18),
        USB_DESC_BYTE(dtDevice),
        USB_DESC_WORD(0x0200),     // USB 2.0
        USB_DESC_BYTE(0x02),       // bDeviceClass (CDC)
        USB_DESC_BYTE(0x00),       // bDeviceSubClass
        USB_DESC_BYTE(0x00),       // bDeviceProtocol
        USB_DESC_BYTE(0x40),       // bMaxPacketSize.
        USB_DESC_WORD(0x0483),     // idVendor (ST).
        USB_DESC_WORD(0x5740),     // idProduct.
        USB_DESC_WORD(0x0200),     // bcdDevice.
        USB_DESC_BYTE(1),          // iManufacturer.
        USB_DESC_BYTE(2),          // iProduct.
        USB_DESC_BYTE(0),          // iSerialNumber.
        USB_DESC_BYTE(1)           // bNumConfigurations.
};

// Configuration
static const uint8_t ConfigDescriptor[] = {
Exemple #5
0
};

/*
 * HID Report Descriptor
 *
 * This is the description of the format and the content of the
 * different IN or/and OUT reports that your application can
 * receive/send
 *
 * See "Device Class Definition for Human Interface Devices (HID)"
 * (http://www.usb.org/developers/hidpage/HID1_11.pdf) for the
 * detailed description of all the fields
 */
static const uint8_t hid_report_descriptor_data[] = {
  USB_DESC_BYTE (0x06),                 /* Usage Page -                     */
  USB_DESC_WORD (0xFF00),               /*   Vendor Defined.                */
  USB_DESC_BYTE (0x09),                 /* Usage -                          */
  USB_DESC_BYTE (0x01),                 /*   Vendor Defined.                */
  USB_DESC_BYTE (0xA1),                 /* Collection -                     */
  USB_DESC_BYTE (0x01),                 /*   Application.                   */

  USB_DESC_BYTE (0x09),                 /* Usage -                          */
  USB_DESC_BYTE (0x01),                 /*   Vendor Defined.                */
  USB_DESC_BYTE (0x15),                 /* Logical Minimum -                */
  USB_DESC_BYTE (0x00),                 /*   0.                             */
  USB_DESC_BYTE (0x26),                 /* Logical Maximum -                */
  USB_DESC_WORD (0x00FF),               /*   255.                           */
  USB_DESC_BYTE (0x75),                 /* Report size -                    */
  USB_DESC_BYTE (0x08),                 /*   8 bits.                        */
  USB_DESC_BYTE (0x95),                 /* Report count -                   */
  USB_DESC_BYTE (0x01),                 /*   1.                             */