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 cdc_keyboard_class.c
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb cdc and keyboard 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_cdc_keyboard_class
* @brief usb device class composite cdc and keyboard
* @{
*/
*/
/** @defgroup USB_cdc_keyboard_class_private_functions
* @{
@@ -70,7 +70,7 @@ const static unsigned char _asciimap[128] =
0x2A,// BS Backspace
0x2B,// TAB Tab
0x28,// LF Enter
0x00,// VT
0x00,// VT
0x00,// FF
0x00,// CR
0x00,// SO
@@ -202,7 +202,7 @@ linecoding_type linecoding_vcpkybrd =
/* usb device class handler */
usbd_class_handler cdc_keyboard_class_handler =
usbd_class_handler cdc_keyboard_class_handler =
{
class_init_handler,
class_clear_handler,
@@ -219,7 +219,7 @@ usbd_class_handler cdc_keyboard_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
*/
static usb_sts_type class_init_handler(void *udev)
{
@@ -233,25 +233,25 @@ static usb_sts_type class_init_handler(void *udev)
usbd_ept_buf_custom_define(pudev, USBD_VCPKYBRD_CDC_BULK_OUT_EPT, EPT1_RX_ADDR);
usbd_ept_buf_custom_define(pudev, USBD_VCPKYBRD_HID_IN_EPT, EPT3_TX_ADDR);
#endif
/* open in endpoint */
usbd_ept_open(pudev, USBD_VCPKYBRD_CDC_INT_EPT, EPT_INT_TYPE, USBD_VCPKYBRD_CMD_MAXPACKET_SIZE);
/* open in endpoint */
usbd_ept_open(pudev, USBD_VCPKYBRD_CDC_BULK_IN_EPT, EPT_BULK_TYPE, USBD_VCPKYBRD_IN_MAXPACKET_SIZE);
/* open out endpoint */
usbd_ept_open(pudev, USBD_VCPKYBRD_CDC_BULK_OUT_EPT, EPT_BULK_TYPE, USBD_VCPKYBRD_OUT_MAXPACKET_SIZE);
/* open hid in endpoint */
usbd_ept_open(pudev, USBD_VCPKYBRD_HID_IN_EPT, EPT_INT_TYPE, USBD_VCPKYBRD_IN_MAXPACKET_SIZE);
/* set out endpoint to receive status */
usbd_ept_recv(pudev, USBD_VCPKYBRD_CDC_BULK_OUT_EPT, vcpkybrd->g_rx_buff, USBD_VCPKYBRD_OUT_MAXPACKET_SIZE);
vcpkybrd->g_tx_completed = 1;
vcpkybrd->g_keyboard_tx_completed = 1;
vcpkybrd->linecoding.bitrate = linecoding_vcpkybrd.bitrate;
vcpkybrd->linecoding.data = linecoding_vcpkybrd.data;
vcpkybrd->linecoding.format = linecoding_vcpkybrd.format;
@@ -262,25 +262,25 @@ static usb_sts_type class_init_handler(void *udev)
/**
* @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 in endpoint */
usbd_ept_close(pudev, USBD_VCPKYBRD_CDC_INT_EPT);
/* close in endpoint */
usbd_ept_close(pudev, USBD_VCPKYBRD_CDC_BULK_IN_EPT);
/* close out endpoint */
usbd_ept_close(pudev, USBD_VCPKYBRD_CDC_BULK_OUT_EPT);
/* close in endpoint */
usbd_ept_close(pudev, USBD_VCPKYBRD_HID_IN_EPT);
return status;
}
@@ -288,7 +288,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)
{
@@ -308,7 +308,7 @@ static usb_sts_type class_setup_handler(void *udev, usb_setup_type *setup)
break;
case USB_REQ_RECIPIENT_ENDPOINT:
break;
}
return status;
}
@@ -317,7 +317,7 @@ static usb_sts_type class_setup_handler(void *udev, usb_setup_type *setup)
* @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 cdc_class_setup_handler(void *udev, usb_setup_type *setup)
{
@@ -341,7 +341,7 @@ static usb_sts_type cdc_class_setup_handler(void *udev, usb_setup_type *setup)
vcpkybrd->g_req = setup->bRequest;
vcpkybrd->g_len = setup->wLength;
usbd_ctrl_recv(pudev, vcpkybrd->g_cmd, vcpkybrd->g_len);
}
}
break;
@@ -373,7 +373,7 @@ static usb_sts_type cdc_class_setup_handler(void *udev, usb_setup_type *setup)
* @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 keyboard_class_setup_handler(void *udev, usb_setup_type *setup)
{
@@ -447,21 +447,21 @@ static usb_sts_type keyboard_class_setup_handler(void *udev, usb_setup_type *set
/**
* @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)
{
@@ -475,7 +475,7 @@ static usb_sts_type class_ept0_rx_handler(void *udev)
/* class process */
usb_vcp_cmd_process(udev, vcpkybrd->g_req, vcpkybrd->g_cmd, recv_len);
}
if( vcpkybrd->hid_state == HID_REQ_SET_REPORT)
{
/* hid buffer process */
@@ -488,14 +488,14 @@ 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;
usbd_core_type *pudev = (usbd_core_type *)udev;
vcp_keyboard_type *vcpkybrd = (vcp_keyboard_type *)pudev->class_handler->pdata;
/* ...user code...
trans next packet data
*/
@@ -507,8 +507,8 @@ static usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
{
vcpkybrd->g_keyboard_tx_completed = 1;
}
return status;
}
@@ -516,34 +516,34 @@ 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;
vcp_keyboard_type *vcpkybrd = (vcp_keyboard_type *)pudev->class_handler->pdata;
/* get endpoint receive data length */
vcpkybrd->g_rxlen = usbd_get_recv_len(pudev, ept_num);
/*set recv flag*/
vcpkybrd->g_rx_completed = 1;
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;
}
@@ -551,7 +551,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)
{
@@ -559,18 +559,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;
@@ -582,7 +582,7 @@ static usb_sts_type class_event_handler(void *udev, usbd_event_type event)
* @brief usb device class rx data process
* @param udev: to the structure of usbd_core_type
* @param recv_data: receive buffer
* @retval receive data len
* @retval receive data len
*/
uint16_t usb_vcpkybrd_vcp_get_rxdata(void *udev, uint8_t *recv_data)
{
@@ -590,21 +590,21 @@ uint16_t usb_vcpkybrd_vcp_get_rxdata(void *udev, uint8_t *recv_data)
usbd_core_type *pudev = (usbd_core_type *)udev;
vcp_keyboard_type *vcpkybrd = (vcp_keyboard_type *)pudev->class_handler->pdata;
uint16_t tmp_len = 0;
if(vcpkybrd->g_rx_completed == 0)
{
return 0;
}
vcpkybrd->g_rx_completed = 0;
tmp_len = vcpkybrd->g_rxlen;
for(i_index = 0; i_index < vcpkybrd->g_rxlen; i_index ++)
{
recv_data[i_index] = vcpkybrd->g_rx_buff[i_index];
}
usbd_ept_recv(pudev, USBD_VCPKYBRD_CDC_BULK_OUT_EPT, vcpkybrd->g_rx_buff, USBD_VCPKYBRD_OUT_MAXPACKET_SIZE);
return tmp_len;
}
@@ -613,7 +613,7 @@ uint16_t usb_vcpkybrd_vcp_get_rxdata(void *udev, uint8_t *recv_data)
* @param udev: to the structure of usbd_core_type
* @param send_data: send data buffer
* @param len: send length
* @retval error status
* @retval error status
*/
error_status usb_vcpkybrd_vcp_send_data(void *udev, uint8_t *send_data, uint16_t len)
{
@@ -639,7 +639,7 @@ error_status usb_vcpkybrd_vcp_send_data(void *udev, uint8_t *send_data, uint16_t
* @param cmd: request number
* @param buff: request buffer
* @param len: buffer length
* @retval none
* @retval none
*/
static void usb_vcp_cmd_process(void *udev, uint8_t cmd, uint8_t *buff, uint16_t len)
{
@@ -653,7 +653,7 @@ static void usb_vcp_cmd_process(void *udev, uint8_t cmd, uint8_t *buff, uint16_t
vcpkybrd->linecoding.parity = buff[5];
vcpkybrd->linecoding.data = buff[6];
break;
case GET_LINE_CODING:
buff[0] = (uint8_t)vcpkybrd->linecoding.bitrate;
buff[1] = (uint8_t)(vcpkybrd->linecoding.bitrate >> 8);
@@ -663,7 +663,7 @@ static void usb_vcp_cmd_process(void *udev, uint8_t cmd, uint8_t *buff, uint16_t
buff[5] = (uint8_t)(vcpkybrd->linecoding.parity);
buff[6] = (uint8_t)(vcpkybrd->linecoding.data);
break;
default:
break;
}
@@ -674,7 +674,7 @@ static void usb_vcp_cmd_process(void *udev, uint8_t cmd, uint8_t *buff, uint16_t
* @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 usb_vcpkybrd_class_send_report(void *udev, uint8_t *report, uint16_t len)
{
@@ -683,7 +683,7 @@ usb_sts_type usb_vcpkybrd_class_send_report(void *udev, uint8_t *report, uint16_
if(usbd_connect_state_get(pudev) == USB_CONN_STATE_CONFIGURED)
usbd_ept_send(pudev, USBD_VCPKYBRD_HID_IN_EPT, report, len);
return status;
}
@@ -692,14 +692,14 @@ usb_sts_type usb_vcpkybrd_class_send_report(void *udev, uint8_t *report, uint16_
* @brief usb keyoard send char
* @param udev: to the structure of usbd_core_type
* @param op: operation
* @retval none
* @retval none
*/
void usb_vcpkybrd_keyboard_send_char(void *udev, uint8_t ascii_code)
{
uint8_t key_data = 0;
static uint8_t temp = 0;
static uint8_t keyboard_buf[8] = {0, 0, 6, 0, 0, 0, 0, 0};
if(ascii_code > 128)
{
ascii_code = 0;
@@ -711,14 +711,14 @@ void usb_vcpkybrd_keyboard_send_char(void *udev, uint8_t ascii_code)
{
ascii_code = 0;
}
if(ascii_code & SHIFT)
{
key_data = 0x2;
ascii_code &= 0x7F;
}
}
if((temp == ascii_code) && (ascii_code != 0))
{
keyboard_buf[0] = 0;
@@ -735,7 +735,7 @@ void usb_vcpkybrd_keyboard_send_char(void *udev, uint8_t ascii_code)
/**
* @}
*/
*/
/**
* @}

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file cdc_keyboard_class.h
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb cdc and keyboard class 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 __CDC_KEYBOARD_CLASS_H
#define __CDC_KEYBOARD_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_cdc_keyboard_class
* @{
*/
/** @defgroup USB_cdc_keyboard_class_definition
/** @defgroup USB_cdc_keyboard_class_definition
* @{
*/
@@ -83,10 +83,10 @@ typedef struct
uint8_t g_req;
uint8_t hid_state;
uint16_t g_len, g_rxlen;
__IO uint8_t g_tx_completed;
__IO uint8_t g_tx_completed;
__IO uint8_t g_rx_completed;
__IO uint8_t g_keyboard_tx_completed;
linecoding_type linecoding;
}vcp_keyboard_type;
@@ -110,7 +110,7 @@ void usb_vcpkybrd_keyboard_send_char(void *udev, uint8_t ascii_code);
/**
* @}
*/
/**
* @}
*/

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file cdc_keyboard_desc.c
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb cdc and keyboard 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,
@@ -30,11 +30,11 @@
/** @addtogroup AT32F413_middlewares_usbd_class
* @{
*/
/** @defgroup USB_cdc_keyboard_desc
* @brief usb device cdc keyboard descriptor
* @{
*/
*/
/** @defgroup USB_cdc_keyboard_desc_private_functions
* @{
@@ -119,7 +119,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_VCPKYBRD_CONFIG_DESC_SIZE]
the configuration */
0xC0, /* bmAttributes: self powered */
0x32, /* MaxPower 100 mA: this current is used for detecting vbus */
0x08, /* bLength */
0x0B, /* bDescriptorType */
0x00, /* bFirstInterface */
@@ -128,7 +128,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_VCPKYBRD_CONFIG_DESC_SIZE]
0x02, /* bFunctionSubClass */
0x01, /* bFunctionProtocol */
0x00, /* iFunction (Index of string descriptor describing this function) */
USB_DEVICE_IF_DESC_LEN, /* bLength: interface descriptor size */
USB_DESCIPTOR_TYPE_INTERFACE, /* bDescriptorType: interface descriptor type */
VCPKYBRD_CDC_INTERFACE, /* bInterfaceNumber: number of interface */
@@ -138,30 +138,30 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_VCPKYBRD_CONFIG_DESC_SIZE]
0x02, /* bInterfaceSubClass: subclass code, Abstract Control Model*/
0x01, /* bInterfaceProtocol: protocol code, AT Command */
0x00, /* iInterface: index of string descriptor */
0x05, /* bFunctionLength: size of this descriptor in bytes */
USBD_CDC_CS_INTERFACE, /* bDescriptorType: CDC interface descriptor type */
USBD_CDC_SUBTYPE_HEADER, /* bDescriptorSubtype: Header function Descriptor 0x00*/
LBYTE(VCPKYBRD_BCD_NUM),
HBYTE(VCPKYBRD_BCD_NUM), /* bcdCDC: USB class definitions for communications */
0x05, /* bFunctionLength: size of this descriptor in bytes */
USBD_CDC_CS_INTERFACE, /* bDescriptorType: CDC interface descriptor type */
USBD_CDC_SUBTYPE_CMF, /* bDescriptorSubtype: Call Management function descriptor subtype 0x01 */
0x00, /* bmCapabilities: 0x00*/
0x01, /* bDataInterface: interface number of data class interface optionally used for call management */
0x04, /* bFunctionLength: size of this descriptor in bytes */
USBD_CDC_CS_INTERFACE, /* bDescriptorType: CDC interface descriptor type */
USBD_CDC_SUBTYPE_ACM, /* bDescriptorSubtype: Abstract Control Management functional descriptor subtype 0x02 */
0x02, /* bmCapabilities: Support Set_Line_Coding and Get_Line_Coding 0x02 */
0x05, /* bFunctionLength: size of this descriptor in bytes */
USBD_CDC_CS_INTERFACE, /* bDescriptorType: CDC interface descriptor type */
USBD_CDC_CS_INTERFACE, /* bDescriptorType: CDC interface descriptor type */
USBD_CDC_SUBTYPE_UFD, /* bDescriptorSubtype: Union Function Descriptor subtype 0x06 */
0x00, /* bControlInterface: The interface number of the communications or data class interface 0x00 */
0x01, /* bSubordinateInterface0: interface number of first subordinate interface in the union */
USB_DEVICE_EPT_LEN, /* bLength: size of endpoint descriptor in bytes */
USB_DESCIPTOR_TYPE_ENDPOINT, /* bDescriptorType: endpoint descriptor type */
USBD_VCPKYBRD_CDC_INT_EPT, /* bEndpointAddress: the address of endpoint on usb device described by this descriptor */
@@ -169,8 +169,8 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_VCPKYBRD_CONFIG_DESC_SIZE]
LBYTE(USBD_VCPKYBRD_CMD_MAXPACKET_SIZE),
HBYTE(USBD_VCPKYBRD_CMD_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
VCPKYBRD_HID_BINTERVAL_TIME, /* bInterval: interval for polling endpoint for data transfers */
USB_DEVICE_IF_DESC_LEN, /* bLength: interface descriptor size */
USB_DESCIPTOR_TYPE_INTERFACE, /* bDescriptorType: interface descriptor type */
VCPKYBRD_CDC_DATA_INTERFACE, /* bInterfaceNumber: number of interface */
@@ -180,7 +180,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_VCPKYBRD_CONFIG_DESC_SIZE]
0x00, /* bInterfaceSubClass: Data interface subclass code 0x00*/
0x00, /* bInterfaceProtocol: data class protocol code 0x00 */
0x00, /* iInterface: index of string descriptor */
USB_DEVICE_EPT_LEN, /* bLength: size of endpoint descriptor in bytes */
USB_DESCIPTOR_TYPE_ENDPOINT, /* bDescriptorType: endpoint descriptor type */
USBD_VCPKYBRD_CDC_BULK_IN_EPT, /* bEndpointAddress: the address of endpoint on usb device described by this descriptor */
@@ -188,15 +188,15 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_VCPKYBRD_CONFIG_DESC_SIZE]
LBYTE(USBD_VCPKYBRD_IN_MAXPACKET_SIZE),
HBYTE(USBD_VCPKYBRD_IN_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
0x00, /* 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_VCPKYBRD_CDC_BULK_OUT_EPT, /* bEndpointAddress: the address of endpoint on usb device described by this descriptor */
USB_EPT_DESC_BULK, /* bmAttributes: endpoint attributes */
LBYTE(USBD_VCPKYBRD_OUT_MAXPACKET_SIZE),
LBYTE(USBD_VCPKYBRD_OUT_MAXPACKET_SIZE),
HBYTE(USBD_VCPKYBRD_OUT_MAXPACKET_SIZE),/* wMaxPacketSize: maximum packe size this endpoint */
0x00, /* bInterval: interval for polling endpoint for data transfers */
0x08, /* bLength */
0x0B, /* bDescriptorType */
0x02, /* bFirstInterface */
@@ -205,7 +205,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_VCPKYBRD_CONFIG_DESC_SIZE]
0x00, /* bFunctionSubClass */
0x01, /* bFunctionProtocol */
0x00, /* iFunction (Index of string descriptor describing this function) */
USB_DEVICE_IF_DESC_LEN, /* bLength: interface descriptor size */
USB_DESCIPTOR_TYPE_INTERFACE, /* bDescriptorType: interface descriptor type */
VCPKYBRD_KEYBOARD_INTERFACE, /* bInterfaceNumber: number of interface */
@@ -215,7 +215,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_VCPKYBRD_CONFIG_DESC_SIZE]
0x01, /* bInterfaceSubClass: subclass code */
0x01, /* 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(VCPKYBRD_BCD_NUM),
@@ -225,7 +225,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_VCPKYBRD_CONFIG_DESC_SIZE]
HID_CLASS_DESC_REPORT, /* bDescriptorType: report descriptor type */
LBYTE(sizeof(g_usbd_vcpkybrd_hid_report)),
HBYTE(sizeof(g_usbd_vcpkybrd_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_VCPKYBRD_HID_IN_EPT, /* bEndpointAddress: the address of endpoint on usb device described by this descriptor */
@@ -241,7 +241,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_VCPKYBRD_CONFIG_DESC_SIZE]
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t g_vcpkybrd_hid_usb_desc[9] ALIGNED_TAIL =
ALIGNED_HEAD uint8_t g_vcpkybrd_hid_usb_desc[9] ALIGNED_TAIL =
{
0x09, /* bLength: size of HID descriptor in bytes */
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
@@ -260,7 +260,7 @@ ALIGNED_HEAD uint8_t g_vcpkybrd_hid_usb_desc[9] ALIGNED_TAIL =
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t g_usbd_vcpkybrd_hid_report[USBD_VCPKYBRD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
ALIGNED_HEAD uint8_t g_usbd_vcpkybrd_hid_report[USBD_VCPKYBRD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
{
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
@@ -293,7 +293,7 @@ ALIGNED_HEAD uint8_t g_usbd_vcpkybrd_hid_report[USBD_VCPKYBRD_HID_SIZ_REPORT_DES
0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
0x81, 0x00, // INPUT (Data,Ary,Abs)
0xc0 // END_COLLECTION
0xc0 // END_COLLECTION
};
/**
* @brief usb string lang id
@@ -356,24 +356,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;
}
@@ -382,12 +382,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 )
@@ -396,11 +396,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;
}
}
@@ -408,18 +408,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);
@@ -430,7 +430,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)
{
@@ -440,7 +440,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)
{
@@ -450,7 +450,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)
{
@@ -460,7 +460,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)
{
@@ -470,7 +470,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)
{
@@ -481,7 +481,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)
{
@@ -493,7 +493,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)
{
@@ -505,7 +505,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)
{
@@ -516,7 +516,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)
{
@@ -528,7 +528,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)
{
@@ -539,7 +539,7 @@ static usbd_desc_t *get_device_config_string(void)
/**
* @}
*/
*/
/**
* @}

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file cdc_keyboard_desc.h
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb cdc and keyboard 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 __CDC_KEYBOARD_DESC_H
#define __CDC_KEYBOARD_DESC_H
@@ -31,19 +31,19 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "cdc_keyboard_class.h"
#include "usbd_core.h"
/** @addtogroup AT32F413_middlewares_usbd_class
* @{
*/
/** @addtogroup USB_cdc_keyboard_desc
* @{
*/
/** @defgroup USB_cdc_keyboard_desc_definition
/** @defgroup USB_cdc_keyboard_desc_definition
* @{
*/
@@ -56,7 +56,7 @@ extern "C" {
* @brief usb vendor id and product id define
*/
#define USBD_VCPKYBRD_VENDOR_ID 0x2E3C
#define USBD_VCPKYBRD_PRODUCT_ID 0x5750
#define USBD_VCPKYBRD_PRODUCT_ID 0x5750
/**
@@ -76,7 +76,7 @@ extern "C" {
#define USBD_VCPKYBRD_DESC_INTERFACE_STRING "Composite VCP and Keyboard Interface"
/**
* @brief usb endpoint interval define
* @brief usb endpoint interval define
*/
#define VCPKYBRD_HID_BINTERVAL_TIME 0x0A
@@ -105,7 +105,7 @@ extern usbd_desc_handler cdc_keyboard_desc_handler;
/**
* @}
*/
/**
* @}
*/