update version to v2.0.4

This commit is contained in:
Artery-MCU
2022-04-11 19:27:58 +08:00
parent d2285506f0
commit eab9bf65de
1451 changed files with 221506 additions and 13129 deletions

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file custom_hid_class.c
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb custom hid class type
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -30,11 +30,11 @@
/** @addtogroup AT32F413_middlewares_usbd_class
* @{
*/
/** @defgroup USB_custom_hid_class
* @brief usb device custom hid demo
* @{
*/
*/
/** @defgroup USB_custom_hid_class_private_functions
* @{
@@ -54,7 +54,7 @@ static void usb_hid_buf_process(void *udev, uint8_t *report, uint16_t len);
custom_hid_type custom_hid_struct;
/* usb device class handler */
usbd_class_handler custom_hid_class_handler =
usbd_class_handler custom_hid_class_handler =
{
class_init_handler,
class_clear_handler,
@@ -71,7 +71,7 @@ usbd_class_handler custom_hid_class_handler =
/**
* @brief initialize usb endpoint
* @param udev: to the structure of usbd_core_type
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
usb_sts_type class_init_handler(void *udev)
{
@@ -83,35 +83,35 @@ usb_sts_type class_init_handler(void *udev)
usbd_ept_buf_custom_define(pudev, USBD_CUSTOM_HID_IN_EPT, EPT1_TX_ADDR);
usbd_ept_buf_custom_define(pudev, USBD_CUSTOM_HID_OUT_EPT, EPT1_RX_ADDR);
#endif
/* open custom hid in endpoint */
usbd_ept_open(pudev, USBD_CUSTOM_HID_IN_EPT, EPT_INT_TYPE, USBD_CUSTOM_IN_MAXPACKET_SIZE);
/* open custom hid out endpoint */
usbd_ept_open(pudev, USBD_CUSTOM_HID_OUT_EPT, EPT_INT_TYPE, USBD_CUSTOM_OUT_MAXPACKET_SIZE);
/* set out endpoint to receive status */
usbd_ept_recv(pudev, USBD_CUSTOM_HID_OUT_EPT, pcshid->g_rxhid_buff, USBD_CUSTOM_OUT_MAXPACKET_SIZE);
return status;
}
/**
* @brief clear endpoint or other state
* @param udev: to the structure of usbd_core_type
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_clear_handler(void *udev)
{
usb_sts_type status = USB_OK;
usbd_core_type *pudev = (usbd_core_type *)udev;
/* close custom hid in endpoint */
usbd_ept_close(pudev, USBD_CUSTOM_HID_IN_EPT);
/* close custom hid out endpoint */
usbd_ept_close(pudev, USBD_CUSTOM_HID_OUT_EPT);
return status;
}
@@ -119,7 +119,7 @@ static usb_sts_type class_clear_handler(void *udev)
* @brief usb device class setup request handler
* @param udev: to the structure of usbd_core_type
* @param setup: setup packet
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_setup_handler(void *udev, usb_setup_type *setup)
{
@@ -193,21 +193,21 @@ static usb_sts_type class_setup_handler(void *udev, usb_setup_type *setup)
/**
* @brief usb device class endpoint 0 in status stage complete
* @param udev: to the structure of usbd_core_type
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_ept0_tx_handler(void *udev)
{
usb_sts_type status = USB_OK;
/* ...user code... */
return status;
}
/**
* @brief usb device class endpoint 0 out status stage complete
* @param udev: to the structure of usbd_core_type
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_ept0_rx_handler(void *udev)
{
@@ -222,7 +222,7 @@ static usb_sts_type class_ept0_rx_handler(void *udev)
usb_hid_buf_process(udev, pcshid->hid_set_report, recv_len);
pcshid->hid_state = 0;
}
return status;
}
@@ -230,16 +230,16 @@ static usb_sts_type class_ept0_rx_handler(void *udev)
* @brief usb device class transmision complete handler
* @param udev: to the structure of usbd_core_type
* @param ept_num: endpoint number
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
{
usb_sts_type status = USB_OK;
/* ...user code...
trans next packet data
*/
return status;
}
@@ -247,37 +247,37 @@ static usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
* @brief usb device class endpoint receive data
* @param udev: to the structure of usbd_core_type
* @param ept_num: endpoint number
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_out_handler(void *udev, uint8_t ept_num)
{
usb_sts_type status = USB_OK;
usbd_core_type *pudev = (usbd_core_type *)udev;
custom_hid_type *pcshid = (custom_hid_type *)pudev->class_handler->pdata;
/* get endpoint receive data length */
uint32_t recv_len = usbd_get_recv_len(pudev, ept_num);
/* hid buffer process */
usb_hid_buf_process(udev, pcshid->g_rxhid_buff, recv_len);
/* start receive next packet */
usbd_ept_recv(pudev, USBD_CUSTOM_HID_OUT_EPT, pcshid->g_rxhid_buff, recv_len);
return status;
}
/**
* @brief usb device class sof handler
* @param udev: to the structure of usbd_core_type
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_sof_handler(void *udev)
{
usb_sts_type status = USB_OK;
/* ...user code... */
return status;
}
@@ -285,7 +285,7 @@ static usb_sts_type class_sof_handler(void *udev)
* @brief usb device class event handler
* @param udev: to the structure of usbd_core_type
* @param event: usb device event
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_event_handler(void *udev, usbd_event_type event)
{
@@ -293,18 +293,18 @@ static usb_sts_type class_event_handler(void *udev, usbd_event_type event)
switch(event)
{
case USBD_RESET_EVENT:
/* ...user code... */
break;
case USBD_SUSPEND_EVENT:
/* ...user code... */
break;
case USBD_WAKEUP_EVENT:
/* ...user code... */
break;
default:
break;
@@ -317,7 +317,7 @@ static usb_sts_type class_event_handler(void *udev, usbd_event_type event)
* @param udev: to the structure of usbd_core_type
* @param report: report buffer
* @param len: report length
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
usb_sts_type custom_hid_class_send_report(void *udev, uint8_t *report, uint16_t len)
{
@@ -326,7 +326,7 @@ usb_sts_type custom_hid_class_send_report(void *udev, uint8_t *report, uint16_t
if(usbd_connect_state_get(pudev) == USB_CONN_STATE_CONFIGURED)
usbd_ept_send(pudev, USBD_CUSTOM_HID_IN_EPT, report, len);
return status;
}
@@ -335,14 +335,14 @@ usb_sts_type custom_hid_class_send_report(void *udev, uint8_t *report, uint16_t
* @param udev: to the structure of usbd_core_type
* @param report: report buffer
* @param len: report length
* @retval none
* @retval none
*/
static void usb_hid_buf_process(void *udev, uint8_t *report, uint16_t len)
{
uint32_t i_index;
usbd_core_type *pudev = (usbd_core_type *)udev;
custom_hid_type *pcshid = (custom_hid_type *)pudev->class_handler->pdata;
switch(report[0])
{
case HID_REPORT_ID_2:
@@ -382,14 +382,14 @@ static void usb_hid_buf_process(void *udev, uint8_t *report, uint16_t len)
}
usbd_ept_send(pudev, USBD_CUSTOM_HID_IN_EPT, pcshid->g_txhid_buff, len);
default:
break;
break;
}
}
/**
* @}
*/
*/
/**
* @}

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file custom_hid_class.h
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb custom hid header file
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -23,7 +23,7 @@
*
**************************************************************************
*/
/* define to prevent recursive inclusion -------------------------------------*/
#ifndef __CUSTOM_HID_CLASS_H
#define __CUSTOM_HID_CLASS_H
@@ -31,19 +31,19 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "usb_std.h"
#include "usbd_core.h"
/** @addtogroup AT32F413_middlewares_usbd_class
* @{
*/
/** @addtogroup USB_custom_hid_class
* @{
*/
/** @defgroup USB_custom_hid_class_endpoint_definition
/** @defgroup USB_custom_hid_class_endpoint_definition
* @{
*/
@@ -63,10 +63,10 @@ extern "C" {
* @}
*/
/** @defgroup USB_custom_hid_class_request_code_definition
/** @defgroup USB_custom_hid_class_request_code_definition
* @{
*/
typedef struct
{
uint8_t g_rxhid_buff[USBD_CUSTOM_OUT_MAXPACKET_SIZE];
@@ -95,7 +95,7 @@ usb_sts_type custom_hid_class_send_report(void *udev, uint8_t *report, uint16_t
/**
* @}
*/
/**
* @}
*/

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file custom_hid_desc.c
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb hid device descriptor
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -31,11 +31,11 @@
/** @addtogroup AT32F413_middlewares_usbd_class
* @{
*/
/** @defgroup USB_custom_hid_desc
* @brief usb device custom_hid descriptor
* @{
*/
*/
/** @defgroup USB_custom_hid_desc_private_functions
* @{
@@ -119,7 +119,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_CUSHID_CONFIG_DESC_SIZE] A
the configuration */
0xC0, /* bmAttributes: self powered */
0x32, /* MaxPower 100 mA: this current is used for detecting vbus */
USB_DEVICE_IF_DESC_LEN, /* bLength: interface descriptor size */
USB_DESCIPTOR_TYPE_INTERFACE, /* bDescriptorType: interface descriptor type */
0x00, /* bInterfaceNumber: number of interface */
@@ -129,7 +129,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_CUSHID_CONFIG_DESC_SIZE] A
0x00, /* bInterfaceSubClass: subclass code */
0x00, /* bInterfaceProtocol: protocol code */
0x00, /* iInterface: index of string descriptor */
0x09, /* bLength: size of HID descriptor in bytes */
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
LBYTE(CUSHID_BCD_NUM),
@@ -139,7 +139,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_CUSHID_CONFIG_DESC_SIZE] A
HID_CLASS_DESC_REPORT, /* bDescriptorType: report descriptor type */
LBYTE(sizeof(g_usbd_custom_hid_report)),
HBYTE(sizeof(g_usbd_custom_hid_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_CUSTOM_HID_IN_EPT, /* bEndpointAddress: the address of endpoint on usb device described by this descriptor */
@@ -147,12 +147,12 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_CUSHID_CONFIG_DESC_SIZE] A
LBYTE(USBD_CUSTOM_IN_MAXPACKET_SIZE),
HBYTE(USBD_CUSTOM_IN_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
CUSHID_BINTERVAL_TIME, /* bInterval: interval for polling endpoint for data transfers */
USB_DEVICE_EPT_LEN, /* bLength: size of endpoint descriptor in bytes */
USB_DESCIPTOR_TYPE_ENDPOINT, /* bDescriptorType: endpoint descriptor type */
USBD_CUSTOM_HID_OUT_EPT, /* bEndpointAddress: the address of endpoint on usb device described by this descriptor */
USB_EPT_DESC_INTERRUPT, /* bmAttributes: endpoint attributes */
LBYTE(USBD_CUSTOM_OUT_MAXPACKET_SIZE),
LBYTE(USBD_CUSTOM_OUT_MAXPACKET_SIZE),
HBYTE(USBD_CUSTOM_OUT_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
CUSHID_BINTERVAL_TIME, /* bInterval: interval for polling endpoint for data transfers */
};
@@ -163,94 +163,94 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_CUSHID_CONFIG_DESC_SIZE] A
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t g_usbd_custom_hid_report[USBD_CUSHID_SIZ_REPORT_DESC] ALIGNED_TAIL =
ALIGNED_HEAD uint8_t g_usbd_custom_hid_report[USBD_CUSHID_SIZ_REPORT_DESC] ALIGNED_TAIL =
{
0x06, 0xFF, 0x00, /* USAGE_PAGE(Vendor Page:0xFF00) */
0x09, 0x01, /* USAGE (Demo Kit) */
0xa1, 0x01, /* COLLECTION (Application) */
0x06, 0xFF, 0x00, /* USAGE_PAGE(Vendor Page:0xFF00) */
0x09, 0x01, /* USAGE (Demo Kit) */
0xa1, 0x01, /* COLLECTION (Application) */
/* 7 */
/* Led 2 */
0x85, HID_REPORT_ID_2, /* REPORT_ID 2 */
0x09, 0x02, /* USAGE (LED 2) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (1) */
0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (1) */
0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
0x85, 0x02, /* REPORT_ID (2) */
0x09, 0x02, /* USAGE (LED 2) */
0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */
/* 27 */
/* Led 3 */
/* Led 3 */
0x85, HID_REPORT_ID_3, /* REPORT_ID (3) */
0x09, 0x03, /* USAGE (LED 3) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (1) */
0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (1) */
0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
0x85, 0x03, /* REPORT_ID (3) */
0x09, 0x03, /* USAGE (LED 3) */
0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */
/* 47 */
/* Led 4 */
0x85, HID_REPORT_ID_4, /* REPORT_ID 4) */
0x09, 0x04, /* USAGE (LED 4) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (1) */
0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (1) */
0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
0x85, 0x04, /* REPORT_ID (4) */
0x09, 0x04, /* USAGE (LED 4) */
0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */
/* 67 */
/* key Push Button */
/* key Push Button */
0x85, HID_REPORT_ID_5, /* REPORT_ID (5) */
0x09, 0x05, /* USAGE (Push Button) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x75, 0x01, /* REPORT_SIZE (1) */
0x81, 0x82, /* INPUT (Data,Var,Abs,Vol) */
0x09, 0x05, /* USAGE (Push Button) */
0x75, 0x01, /* REPORT_SIZE (1) */
0xb1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
0x75, 0x07, /* REPORT_SIZE (7) */
0x81, 0x83, /* INPUT (Cnst,Var,Abs,Vol) */
0x85, 0x05, /* REPORT_ID (5) */
0x75, 0x07, /* REPORT_SIZE (7) */
0xb1, 0x83, /* FEATURE (Cnst,Var,Abs,Vol) */
0x09, 0x05, /* USAGE (Push Button) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
0x75, 0x01, /* REPORT_SIZE (1) */
0x81, 0x82, /* INPUT (Data,Var,Abs,Vol) */
0x09, 0x05, /* USAGE (Push Button) */
0x75, 0x01, /* REPORT_SIZE (1) */
0xb1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
0x75, 0x07, /* REPORT_SIZE (7) */
0x81, 0x83, /* INPUT (Cnst,Var,Abs,Vol) */
0x85, 0x05, /* REPORT_ID (5) */
0x75, 0x07, /* REPORT_SIZE (7) */
0xb1, 0x83, /* FEATURE (Cnst,Var,Abs,Vol) */
/* 95 */
/* Data OUT */
0x85, HID_REPORT_ID_6, /* REPORT_ID (0xF0) */
0x09, 0x06, /* USAGE */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x26, 0x00,0xff, /* LOGICAL_MAXIMUM (255) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (64) */
0x91, 0x02, /* OUTPUT(Data,Var,Abs,Vol) */
/* Data OUT */
0x85, HID_REPORT_ID_6, /* REPORT_ID (0xF0) */
0x09, 0x06, /* USAGE */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x26, 0x00,0xff, /* LOGICAL_MAXIMUM (255) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (64) */
0x91, 0x02, /* OUTPUT(Data,Var,Abs,Vol) */
/* 110 */
/* Data IN */
0x85, HID_REPORT_ID_6, /* REPORT_ID (0xF0) */
0x09, 0x07, /* USAGE */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x26, 0x00,0xff, /* LOGICAL_MAXIMUM (255) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (64) */
0x81, 0x82, /* INPUT(Data,Var,Abs,Vol) */
/* Data IN */
0x85, HID_REPORT_ID_6, /* REPORT_ID (0xF0) */
0x09, 0x07, /* USAGE */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x26, 0x00,0xff, /* LOGICAL_MAXIMUM (255) */
0x75, 0x08, /* REPORT_SIZE (8) */
0x95, 0x3F, /* REPORT_COUNT (64) */
0x81, 0x82, /* INPUT(Data,Var,Abs,Vol) */
/* 125 */
0xc0 /* END_COLLECTION */
};
@@ -261,7 +261,7 @@ ALIGNED_HEAD uint8_t g_usbd_custom_hid_report[USBD_CUSHID_SIZ_REPORT_DESC] ALIGN
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t g_custom_hid_usb_desc[9] ALIGNED_TAIL =
ALIGNED_HEAD uint8_t g_custom_hid_usb_desc[9] ALIGNED_TAIL =
{
0x09, /* bLength: size of HID descriptor in bytes */
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
@@ -336,24 +336,24 @@ static usbd_desc_t vp_desc;
* @brief standard usb unicode convert
* @param string: source string
* @param unicode_buf: unicode buffer
* @retval length
* @retval length
*/
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;
while(*tmp_str != '\0')
{
str_len ++;
unicode_buf[id_pos ++] = *tmp_str ++;
unicode_buf[id_pos ++] = 0x00;
}
str_len = str_len * 2 + 2;
unicode_buf[0] = str_len;
unicode_buf[1] = USB_DESCIPTOR_TYPE_STRING;
return str_len;
}
@@ -362,12 +362,12 @@ static uint16_t usbd_unicode_convert(uint8_t *string, uint8_t *unicode_buf)
* @param value: int value
* @param pbus: unicode buffer
* @param len: length
* @retval none
* @retval none
*/
static void usbd_int_to_unicode (uint32_t value , uint8_t *pbuf , uint8_t len)
{
uint8_t idx = 0;
for( idx = 0 ; idx < len ; idx ++)
{
if( ((value >> 28)) < 0xA )
@@ -376,11 +376,11 @@ static void usbd_int_to_unicode (uint32_t value , uint8_t *pbuf , uint8_t len)
}
else
{
pbuf[2 * idx] = (value >> 28) + 'A' - 10;
pbuf[2 * idx] = (value >> 28) + 'A' - 10;
}
value = value << 4;
pbuf[2 * idx + 1] = 0;
}
}
@@ -388,18 +388,18 @@ static void usbd_int_to_unicode (uint32_t value , uint8_t *pbuf , uint8_t len)
/**
* @brief usb get serial number
* @param none
* @retval none
* @retval none
*/
static void get_serial_num(void)
{
uint32_t serial0, serial1, serial2;
serial0 = *(uint32_t*)MCU_ID1;
serial1 = *(uint32_t*)MCU_ID2;
serial2 = *(uint32_t*)MCU_ID3;
serial0 += serial2;
if (serial0 != 0)
{
usbd_int_to_unicode (serial0, &g_string_serial[2] ,8);
@@ -410,7 +410,7 @@ static void get_serial_num(void)
/**
* @brief get device descriptor
* @param none
* @retval usbd_desc
* @retval usbd_desc
*/
static usbd_desc_t *get_device_descriptor(void)
{
@@ -420,7 +420,7 @@ static usbd_desc_t *get_device_descriptor(void)
/**
* @brief get device qualifier
* @param none
* @retval usbd_desc
* @retval usbd_desc
*/
static usbd_desc_t * get_device_qualifier(void)
{
@@ -430,7 +430,7 @@ static usbd_desc_t * get_device_qualifier(void)
/**
* @brief get config descriptor
* @param none
* @retval usbd_desc
* @retval usbd_desc
*/
static usbd_desc_t *get_device_configuration(void)
{
@@ -440,7 +440,7 @@ static usbd_desc_t *get_device_configuration(void)
/**
* @brief get other speed descriptor
* @param none
* @retval usbd_desc
* @retval usbd_desc
*/
static usbd_desc_t *get_device_other_speed(void)
{
@@ -450,7 +450,7 @@ static usbd_desc_t *get_device_other_speed(void)
/**
* @brief get lang id descriptor
* @param none
* @retval usbd_desc
* @retval usbd_desc
*/
static usbd_desc_t *get_device_lang_id(void)
{
@@ -461,7 +461,7 @@ static usbd_desc_t *get_device_lang_id(void)
/**
* @brief get manufacturer descriptor
* @param none
* @retval usbd_desc
* @retval usbd_desc
*/
static usbd_desc_t *get_device_manufacturer_string(void)
{
@@ -473,7 +473,7 @@ static usbd_desc_t *get_device_manufacturer_string(void)
/**
* @brief get product descriptor
* @param none
* @retval usbd_desc
* @retval usbd_desc
*/
static usbd_desc_t *get_device_product_string(void)
{
@@ -485,7 +485,7 @@ static usbd_desc_t *get_device_product_string(void)
/**
* @brief get serial descriptor
* @param none
* @retval usbd_desc
* @retval usbd_desc
*/
static usbd_desc_t *get_device_serial_string(void)
{
@@ -496,7 +496,7 @@ static usbd_desc_t *get_device_serial_string(void)
/**
* @brief get interface descriptor
* @param none
* @retval usbd_desc
* @retval usbd_desc
*/
static usbd_desc_t *get_device_interface_string(void)
{
@@ -508,7 +508,7 @@ static usbd_desc_t *get_device_interface_string(void)
/**
* @brief get device config descriptor
* @param none
* @retval usbd_desc
* @retval usbd_desc
*/
static usbd_desc_t *get_device_config_string(void)
{
@@ -519,7 +519,7 @@ static usbd_desc_t *get_device_config_string(void)
/**
* @}
*/
*/
/**
* @}

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file custom_hid_desc.h
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb custom hid descriptor header file
**************************************************************************
* Copyright notice & Disclaimer
*
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* The software Board Support Package (BSP) that is made available to
* download from Artery official website is the copyrighted work of Artery.
* Artery authorizes customers to use, copy, and distribute the BSP
* software and its related documentation for the purpose of design and
* development in conjunction with Artery microcontrollers. Use of the
* software is governed by this copyright notice and the following disclaimer.
*
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
@@ -23,7 +23,7 @@
*
**************************************************************************
*/
/* define to prevent recursive inclusion -------------------------------------*/
#ifndef __CUSTOM_HID_DESC_H
#define __CUSTOM_HID_DESC_H
@@ -31,23 +31,23 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "custom_hid_class.h"
#include "usbd_core.h"
/** @addtogroup AT32F413_middlewares_usbd_class
* @{
*/
/** @addtogroup USB_custom_hid_desc
* @{
*/
/** @defgroup USB_custom_hid_desc_definition
/** @defgroup USB_custom_hid_desc_definition
* @{
*/
/**
* @brief usb bcd number define
*/
@@ -57,7 +57,7 @@ extern "C" {
* @brief usb vendor id and product id define
*/
#define USBD_CUSHID_VENDOR_ID 0x2E3C
#define USBD_CUSHID_PRODUCT_ID 0x5745
#define USBD_CUSHID_PRODUCT_ID 0x5745
/**
* @brief usb descriptor size define
@@ -78,10 +78,10 @@ extern "C" {
#define CUSHID_BINTERVAL_TIME 0x0A
/**
* @brief usb hid report id define
* @brief usb hid report id define
*/
/**
* @brief usb hid report id define
* @brief usb hid report id define
*/
#define HID_REPORT_ID_1 0x01
#define HID_REPORT_ID_2 0x02
@@ -107,7 +107,7 @@ extern usbd_desc_handler custom_hid_desc_handler;
/**
* @}
*/
/**
* @}
*/