update version to v2.0.3

This commit is contained in:
Artery-MCU
2022-03-03 19:38:35 +08:00
parent 79c8fdf6b4
commit 07d7347ba4
1063 changed files with 17001 additions and 4410 deletions

View File

@@ -1,8 +1,8 @@
/**
**************************************************************************
* @file mouse_desc.c
* @version v2.0.2
* @date 2021-12-31
* @version v2.0.3
* @date 2022-02-11
* @brief usb hid mouse device descriptor
**************************************************************************
* Copyright notice & Disclaimer
@@ -41,18 +41,18 @@
* @{
*/
usbd_desc_t *get_device_descriptor(void);
usbd_desc_t *get_device_qualifier(void);
usbd_desc_t *get_device_configuration(void);
usbd_desc_t *get_device_other_speed(void);
usbd_desc_t *get_device_lang_id(void);
usbd_desc_t *get_device_manufacturer_string(void);
usbd_desc_t *get_device_product_string(void);
usbd_desc_t *get_device_serial_string(void);
usbd_desc_t *get_device_interface_string(void);
usbd_desc_t *get_device_config_string(void);
static usbd_desc_t *get_device_descriptor(void);
static usbd_desc_t *get_device_qualifier(void);
static usbd_desc_t *get_device_configuration(void);
static usbd_desc_t *get_device_other_speed(void);
static usbd_desc_t *get_device_lang_id(void);
static usbd_desc_t *get_device_manufacturer_string(void);
static usbd_desc_t *get_device_product_string(void);
static usbd_desc_t *get_device_serial_string(void);
static usbd_desc_t *get_device_interface_string(void);
static usbd_desc_t *get_device_config_string(void);
uint16_t usbd_unicode_convert(uint8_t *string, uint8_t *unicode_buf);
static uint16_t usbd_unicode_convert(uint8_t *string, uint8_t *unicode_buf);
static void usbd_int_to_unicode (uint32_t value , uint8_t *pbuf , uint8_t len);
static void get_serial_num(void);
static uint8_t g_usbd_desc_buffer[256];
@@ -80,7 +80,7 @@ usbd_desc_handler mouse_desc_handler =
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
ALIGNED_HEAD static uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
{
USB_DEVICE_DESC_LEN, /* bLength */
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
@@ -90,10 +90,10 @@ ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
0x00, /* bDeviceSubClass */
0x00, /* bDeviceProtocol */
USB_MAX_EP0_SIZE, /* bMaxPacketSize */
LBYTE(USBD_VENDOR_ID), /* idVendor */
HBYTE(USBD_VENDOR_ID), /* idVendor */
LBYTE(USBD_PRODUCT_ID), /* idProduct */
HBYTE(USBD_PRODUCT_ID), /* idProduct */
LBYTE(USBD_MOUSE_VENDOR_ID), /* idVendor */
HBYTE(USBD_MOUSE_VENDOR_ID), /* idVendor */
LBYTE(USBD_MOUSE_PRODUCT_ID), /* idProduct */
HBYTE(USBD_MOUSE_PRODUCT_ID), /* idProduct */
0x00, /* bcdDevice rel. 2.00 */
0x02,
USB_MFC_STRING, /* Index of manufacturer string */
@@ -108,12 +108,12 @@ ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_MOUSE_CONFIG_DESC_SIZE] ALIGNED_TAIL =
{
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
LBYTE(USBD_CONFIG_DESC_SIZE), /* wTotalLength: bytes returned */
HBYTE(USBD_CONFIG_DESC_SIZE), /* wTotalLength: bytes returned */
LBYTE(USBD_MOUSE_CONFIG_DESC_SIZE), /* wTotalLength: bytes returned */
HBYTE(USBD_MOUSE_CONFIG_DESC_SIZE), /* wTotalLength: bytes returned */
0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: configuration value */
0x00, /* iConfiguration: index of string descriptor describing
@@ -133,21 +133,21 @@ ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
0x09, /* bLength: size of HID descriptor in bytes */
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
LBYTE(HID_BCD_NUM),
HBYTE(HID_BCD_NUM), /* bcdHID: HID class specification release number */
LBYTE(MOUSE_BCD_NUM),
HBYTE(MOUSE_BCD_NUM), /* bcdHID: HID class specification release number */
0x00, /* bCountryCode: hardware target conutry */
0x01, /* bNumDescriptors: number of HID class descriptor to follow */
HID_CLASS_DESC_REPORT, /* bDescriptorType: report descriptor type */
LBYTE(sizeof(g_usbd_hid_report)),
HBYTE(sizeof(g_usbd_hid_report)), /* wDescriptorLength: total length of reprot descriptor */
LBYTE(sizeof(g_usbd_mouse_report)),
HBYTE(sizeof(g_usbd_mouse_report)), /* wDescriptorLength: total length of reprot descriptor */
USB_DEVICE_EPT_LEN, /* bLength: size of endpoint descriptor in bytes */
USB_DESCIPTOR_TYPE_ENDPOINT, /* bDescriptorType: endpoint descriptor type */
USBD_HID_IN_EPT, /* bEndpointAddress: the address of endpoint on usb device described by this descriptor */
USBD_MOUSE_IN_EPT, /* bEndpointAddress: the address of endpoint on usb device described by this descriptor */
USB_EPT_DESC_INTERRUPT, /* bmAttributes: endpoint attributes */
LBYTE(USBD_IN_MAXPACKET_SIZE),
HBYTE(USBD_IN_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
HID_BINTERVAL_TIME, /* bInterval: interval for polling endpoint for data transfers */
LBYTE(USBD_MOUSE_IN_MAXPACKET_SIZE),
HBYTE(USBD_MOUSE_IN_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
MOUSE_BINTERVAL_TIME, /* bInterval: interval for polling endpoint for data transfers */
};
/**
@@ -156,7 +156,7 @@ ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
ALIGNED_HEAD uint8_t g_usbd_mouse_report[USBD_MOUSE_SIZ_REPORT_DESC] ALIGNED_TAIL =
{
0x05,0x01,
0x09,0x02,
@@ -212,17 +212,17 @@ ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
ALIGNED_HEAD uint8_t g_mouse_usb_desc[9] ALIGNED_TAIL =
{
0x09, /* bLength: size of HID descriptor in bytes */
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
LBYTE(HID_BCD_NUM),
HBYTE(HID_BCD_NUM), /* bcdHID: HID class specification release number */
LBYTE(MOUSE_BCD_NUM),
HBYTE(MOUSE_BCD_NUM), /* bcdHID: HID class specification release number */
0x00, /* bCountryCode: hardware target conutry */
0x01, /* bNumDescriptors: number of HID class descriptor to follow */
HID_CLASS_DESC_REPORT, /* bDescriptorType: report descriptor type */
LBYTE(sizeof(g_usbd_hid_report)),
HBYTE(sizeof(g_usbd_hid_report)), /* wDescriptorLength: total length of reprot descriptor */
LBYTE(sizeof(g_usbd_mouse_report)),
HBYTE(sizeof(g_usbd_mouse_report)), /* wDescriptorLength: total length of reprot descriptor */
};
@@ -232,9 +232,9 @@ ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
ALIGNED_HEAD static uint8_t g_string_lang_id[USBD_MOUSE_SIZ_STRING_LANGID] ALIGNED_TAIL =
{
USBD_SIZ_STRING_LANGID,
USBD_MOUSE_SIZ_STRING_LANGID,
USB_DESCIPTOR_TYPE_STRING,
0x09,
0x04,
@@ -246,42 +246,42 @@ ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
ALIGNED_HEAD static uint8_t g_string_serial[USBD_MOUSE_SIZ_STRING_SERIAL] ALIGNED_TAIL =
{
USBD_SIZ_STRING_SERIAL,
USBD_MOUSE_SIZ_STRING_SERIAL,
USB_DESCIPTOR_TYPE_STRING,
};
/* device descriptor */
usbd_desc_t device_descriptor =
static usbd_desc_t device_descriptor =
{
USB_DEVICE_DESC_LEN,
g_usbd_descriptor
};
/* config descriptor */
usbd_desc_t config_descriptor =
static usbd_desc_t config_descriptor =
{
USBD_CONFIG_DESC_SIZE,
USBD_MOUSE_CONFIG_DESC_SIZE,
g_usbd_configuration
};
/* langid descriptor */
usbd_desc_t langid_descriptor =
static usbd_desc_t langid_descriptor =
{
USBD_SIZ_STRING_LANGID,
USBD_MOUSE_SIZ_STRING_LANGID,
g_string_lang_id
};
/* serial descriptor */
usbd_desc_t serial_descriptor =
static usbd_desc_t serial_descriptor =
{
USBD_SIZ_STRING_SERIAL,
USBD_MOUSE_SIZ_STRING_SERIAL,
g_string_serial
};
usbd_desc_t vp_desc;
static usbd_desc_t vp_desc;
/**
* @brief standard usb unicode convert
@@ -289,7 +289,7 @@ usbd_desc_t vp_desc;
* @param unicode_buf: unicode buffer
* @retval length
*/
uint16_t usbd_unicode_convert(uint8_t *string, uint8_t *unicode_buf)
static uint16_t usbd_unicode_convert(uint8_t *string, uint8_t *unicode_buf)
{
uint16_t str_len = 0, id_pos = 2;
uint8_t *tmp_str = string;
@@ -363,7 +363,7 @@ static void get_serial_num(void)
* @param none
* @retval usbd_desc
*/
usbd_desc_t *get_device_descriptor(void)
static usbd_desc_t *get_device_descriptor(void)
{
return &device_descriptor;
}
@@ -373,7 +373,7 @@ usbd_desc_t *get_device_descriptor(void)
* @param none
* @retval usbd_desc
*/
usbd_desc_t * get_device_qualifier(void)
static usbd_desc_t * get_device_qualifier(void)
{
return NULL;
}
@@ -383,7 +383,7 @@ usbd_desc_t * get_device_qualifier(void)
* @param none
* @retval usbd_desc
*/
usbd_desc_t *get_device_configuration(void)
static usbd_desc_t *get_device_configuration(void)
{
return &config_descriptor;
}
@@ -393,7 +393,7 @@ usbd_desc_t *get_device_configuration(void)
* @param none
* @retval usbd_desc
*/
usbd_desc_t *get_device_other_speed(void)
static usbd_desc_t *get_device_other_speed(void)
{
return NULL;
}
@@ -403,7 +403,7 @@ usbd_desc_t *get_device_other_speed(void)
* @param none
* @retval usbd_desc
*/
usbd_desc_t *get_device_lang_id(void)
static usbd_desc_t *get_device_lang_id(void)
{
return &langid_descriptor;
}
@@ -414,9 +414,9 @@ usbd_desc_t *get_device_lang_id(void)
* @param none
* @retval usbd_desc
*/
usbd_desc_t *get_device_manufacturer_string(void)
static usbd_desc_t *get_device_manufacturer_string(void)
{
vp_desc.length = usbd_unicode_convert((uint8_t *)USBD_DESC_MANUFACTURER_STRING, g_usbd_desc_buffer);
vp_desc.length = usbd_unicode_convert((uint8_t *)USBD_MOUSE_DESC_MANUFACTURER_STRING, g_usbd_desc_buffer);
vp_desc.descriptor = g_usbd_desc_buffer;
return &vp_desc;
}
@@ -426,9 +426,9 @@ usbd_desc_t *get_device_manufacturer_string(void)
* @param none
* @retval usbd_desc
*/
usbd_desc_t *get_device_product_string(void)
static usbd_desc_t *get_device_product_string(void)
{
vp_desc.length = usbd_unicode_convert((uint8_t *)USBD_DESC_PRODUCT_STRING, g_usbd_desc_buffer);
vp_desc.length = usbd_unicode_convert((uint8_t *)USBD_MOUSE_DESC_PRODUCT_STRING, g_usbd_desc_buffer);
vp_desc.descriptor = g_usbd_desc_buffer;
return &vp_desc;
}
@@ -438,7 +438,7 @@ usbd_desc_t *get_device_product_string(void)
* @param none
* @retval usbd_desc
*/
usbd_desc_t *get_device_serial_string(void)
static usbd_desc_t *get_device_serial_string(void)
{
get_serial_num();
return &serial_descriptor;
@@ -449,9 +449,9 @@ usbd_desc_t *get_device_serial_string(void)
* @param none
* @retval usbd_desc
*/
usbd_desc_t *get_device_interface_string(void)
static usbd_desc_t *get_device_interface_string(void)
{
vp_desc.length = usbd_unicode_convert((uint8_t *)USBD_DESC_INTERFACE_STRING, g_usbd_desc_buffer);
vp_desc.length = usbd_unicode_convert((uint8_t *)USBD_MOUSE_DESC_INTERFACE_STRING, g_usbd_desc_buffer);
vp_desc.descriptor = g_usbd_desc_buffer;
return &vp_desc;
}
@@ -461,9 +461,9 @@ usbd_desc_t *get_device_interface_string(void)
* @param none
* @retval usbd_desc
*/
usbd_desc_t *get_device_config_string(void)
static usbd_desc_t *get_device_config_string(void)
{
vp_desc.length = usbd_unicode_convert((uint8_t *)USBD_DESC_CONFIGURATION_STRING, g_usbd_desc_buffer);
vp_desc.length = usbd_unicode_convert((uint8_t *)USBD_MOUSE_DESC_CONFIGURATION_STRING, g_usbd_desc_buffer);
vp_desc.descriptor = g_usbd_desc_buffer;
return &vp_desc;
}