mirror of
https://github.com/ArteryTek/AT32F415_Firmware_Library.git
synced 2026-05-21 01:12:20 +00:00
update version to v2.0.4
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_class.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb cdc 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 AT32F415_middlewares_usbd_class
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USB_cdc_class
|
||||
* @brief usb device class cdc demo
|
||||
* @{
|
||||
*/
|
||||
*/
|
||||
|
||||
/** @defgroup USB_cdc_class_private_functions
|
||||
* @{
|
||||
@@ -54,7 +54,7 @@ static usb_sts_type cdc_struct_init(cdc_struct_type *pcdc);
|
||||
extern void usb_usart_config( linecoding_type linecoding);
|
||||
static void usb_vcp_cmd_process(void *udev, uint8_t cmd, uint8_t *buff, uint16_t len);
|
||||
|
||||
linecoding_type linecoding =
|
||||
linecoding_type linecoding =
|
||||
{
|
||||
115200,
|
||||
0,
|
||||
@@ -66,7 +66,7 @@ linecoding_type linecoding =
|
||||
cdc_struct_type cdc_struct;
|
||||
|
||||
/* usb device class handler */
|
||||
usbd_class_handler cdc_class_handler =
|
||||
usbd_class_handler cdc_class_handler =
|
||||
{
|
||||
class_init_handler,
|
||||
class_clear_handler,
|
||||
@@ -82,51 +82,51 @@ usbd_class_handler cdc_class_handler =
|
||||
/**
|
||||
* @brief initialize usb custom hid 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)
|
||||
{
|
||||
usb_sts_type status = USB_OK;
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *)pudev->class_handler->pdata;
|
||||
|
||||
|
||||
/* init cdc struct */
|
||||
cdc_struct_init(pcdc);
|
||||
|
||||
|
||||
/* open in endpoint */
|
||||
usbd_ept_open(pudev, USBD_CDC_INT_EPT, EPT_INT_TYPE, USBD_CDC_CMD_MAXPACKET_SIZE);
|
||||
|
||||
|
||||
/* open in endpoint */
|
||||
usbd_ept_open(pudev, USBD_CDC_BULK_IN_EPT, EPT_BULK_TYPE, USBD_CDC_IN_MAXPACKET_SIZE);
|
||||
|
||||
|
||||
/* open out endpoint */
|
||||
usbd_ept_open(pudev, USBD_CDC_BULK_OUT_EPT, EPT_BULK_TYPE, USBD_CDC_OUT_MAXPACKET_SIZE);
|
||||
|
||||
|
||||
/* set out endpoint to receive status */
|
||||
usbd_ept_recv(pudev, USBD_CDC_BULK_OUT_EPT, pcdc->g_rx_buff, USBD_CDC_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 in endpoint */
|
||||
usbd_ept_close(pudev, USBD_CDC_INT_EPT);
|
||||
|
||||
|
||||
/* close in endpoint */
|
||||
usbd_ept_close(pudev, USBD_CDC_BULK_IN_EPT);
|
||||
|
||||
|
||||
/* close out endpoint */
|
||||
usbd_ept_close(pudev, USBD_CDC_BULK_OUT_EPT);
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,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)
|
||||
{
|
||||
@@ -158,7 +158,7 @@ static usb_sts_type class_setup_handler(void *udev, usb_setup_type *setup)
|
||||
pcdc->g_req = setup->bRequest;
|
||||
pcdc->g_len = setup->wLength;
|
||||
usbd_ctrl_recv(pudev, pcdc->g_cmd, pcdc->g_len);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -189,21 +189,21 @@ static usb_sts_type class_setup_handler(void *udev, usb_setup_type *setup)
|
||||
/**
|
||||
* @brief usb device 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 endpoint 0 out status stage complete
|
||||
* @param udev: usb device core handler type
|
||||
* @retval status of usb_sts_type
|
||||
* @retval status of usb_sts_type
|
||||
*/
|
||||
static usb_sts_type class_ept0_rx_handler(void *udev)
|
||||
{
|
||||
@@ -217,7 +217,7 @@ static usb_sts_type class_ept0_rx_handler(void *udev)
|
||||
/* class process */
|
||||
usb_vcp_cmd_process(udev, pcdc->g_req, pcdc->g_cmd, recv_len);
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -225,20 +225,20 @@ static usb_sts_type class_ept0_rx_handler(void *udev)
|
||||
* @brief usb device 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)
|
||||
{
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *)pudev->class_handler->pdata;
|
||||
usb_sts_type status = USB_OK;
|
||||
|
||||
|
||||
/* ...user code...
|
||||
trans next packet data
|
||||
*/
|
||||
usbd_flush_tx_fifo(pudev, ept_num);
|
||||
pcdc->g_tx_completed = 1;
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -246,34 +246,34 @@ static usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
|
||||
* @brief usb device 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;
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *)pudev->class_handler->pdata;
|
||||
|
||||
|
||||
/* get endpoint receive data length */
|
||||
pcdc->g_rxlen = usbd_get_recv_len(pudev, ept_num);
|
||||
|
||||
|
||||
/*set recv flag*/
|
||||
pcdc->g_rx_completed = 1;
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usb device 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;
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ static usb_sts_type class_sof_handler(void *udev)
|
||||
* @brief usb device 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)
|
||||
{
|
||||
@@ -289,24 +289,24 @@ 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;
|
||||
case USBD_INISOINCOM_EVENT:
|
||||
break;
|
||||
case USBD_OUTISOINCOM_EVENT:
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -316,7 +316,7 @@ static usb_sts_type class_event_handler(void *udev, usbd_event_type event)
|
||||
/**
|
||||
* @brief usb device cdc init
|
||||
* @param pcdc: to the structure of cdc_struct
|
||||
* @retval status of usb_sts_type
|
||||
* @retval status of usb_sts_type
|
||||
*/
|
||||
static usb_sts_type cdc_struct_init(cdc_struct_type *pcdc)
|
||||
{
|
||||
@@ -334,7 +334,7 @@ static usb_sts_type cdc_struct_init(cdc_struct_type *pcdc)
|
||||
* @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_vcp_get_rxdata(void *udev, uint8_t *recv_data)
|
||||
{
|
||||
@@ -342,7 +342,7 @@ uint16_t usb_vcp_get_rxdata(void *udev, uint8_t *recv_data)
|
||||
uint16_t tmp_len = 0;
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
cdc_struct_type *pcdc = (cdc_struct_type *)pudev->class_handler->pdata;
|
||||
|
||||
|
||||
if(pcdc->g_rx_completed == 0)
|
||||
{
|
||||
return 0;
|
||||
@@ -353,9 +353,9 @@ uint16_t usb_vcp_get_rxdata(void *udev, uint8_t *recv_data)
|
||||
{
|
||||
recv_data[i_index] = pcdc->g_rx_buff[i_index];
|
||||
}
|
||||
|
||||
|
||||
usbd_ept_recv(pudev, USBD_CDC_BULK_OUT_EPT, pcdc->g_rx_buff, USBD_CDC_OUT_MAXPACKET_SIZE);
|
||||
|
||||
|
||||
return tmp_len;
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ uint16_t usb_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_vcp_send_data(void *udev, uint8_t *send_data, uint16_t len)
|
||||
{
|
||||
@@ -389,7 +389,7 @@ error_status usb_vcp_send_data(void *udev, uint8_t *send_data, uint16_t len)
|
||||
* @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)
|
||||
{
|
||||
@@ -407,7 +407,7 @@ static void usb_vcp_cmd_process(void *udev, uint8_t cmd, uint8_t *buff, uint16_t
|
||||
usb_usart_config(pcdc->linecoding);
|
||||
#endif
|
||||
break;
|
||||
|
||||
|
||||
case GET_LINE_CODING:
|
||||
buff[0] = (uint8_t)pcdc->linecoding.bitrate;
|
||||
buff[1] = (uint8_t)(pcdc->linecoding.bitrate >> 8);
|
||||
@@ -417,7 +417,7 @@ static void usb_vcp_cmd_process(void *udev, uint8_t cmd, uint8_t *buff, uint16_t
|
||||
buff[5] = (uint8_t)(pcdc->linecoding.parity);
|
||||
buff[6] = (uint8_t)(pcdc->linecoding.data);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -425,7 +425,7 @@ static void usb_vcp_cmd_process(void *udev, uint8_t cmd, uint8_t *buff, uint16_t
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_class.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb cdc 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_CLASS_H
|
||||
#define __CDC_CLASS_H
|
||||
@@ -31,19 +31,19 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "usb_std.h"
|
||||
#include "usbd_core.h"
|
||||
|
||||
/** @addtogroup AT32F415_middlewares_usbd_class
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup USB_cdc_class
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USB_cdc_class_definition
|
||||
/** @defgroup USB_cdc_class_definition
|
||||
* @{
|
||||
*/
|
||||
|
||||
@@ -102,7 +102,7 @@ error_status usb_vcp_send_data(void *udev, uint8_t *send_data, uint16_t len);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_desc.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb cdc 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,
|
||||
@@ -32,11 +32,11 @@
|
||||
/** @addtogroup AT32F415_middlewares_usbd_class
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USB_cdc_desc
|
||||
* @brief usb device cdc descriptor
|
||||
* @{
|
||||
*/
|
||||
*/
|
||||
|
||||
/** @defgroup USB_cdc_desc_private_functions
|
||||
* @{
|
||||
@@ -121,7 +121,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_CDC_CONFIG_DESC_SIZE] ALIG
|
||||
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 */
|
||||
@@ -131,30 +131,30 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_CDC_CONFIG_DESC_SIZE] ALIG
|
||||
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(CDC_BCD_NUM),
|
||||
HBYTE(CDC_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_CDC_INT_EPT, /* bEndpointAddress: the address of endpoint on usb device described by this descriptor */
|
||||
@@ -162,8 +162,8 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_CDC_CONFIG_DESC_SIZE] ALIG
|
||||
LBYTE(USBD_CDC_CMD_MAXPACKET_SIZE),
|
||||
HBYTE(USBD_CDC_CMD_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
|
||||
CDC_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 */
|
||||
0x01, /* bInterfaceNumber: number of interface */
|
||||
@@ -173,22 +173,22 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_CDC_CONFIG_DESC_SIZE] ALIG
|
||||
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_CDC_BULK_IN_EPT, /* bEndpointAddress: the address of endpoint on usb device described by this descriptor */
|
||||
USB_EPT_DESC_BULK, /* bmAttributes: endpoint attributes */
|
||||
LBYTE(USBD_CDC_IN_MAXPACKET_SIZE),
|
||||
HBYTE(USBD_CDC_IN_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
|
||||
0x00, /* bInterval: interval for polling endpoint for data transfers */
|
||||
|
||||
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_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_CDC_OUT_MAXPACKET_SIZE),
|
||||
LBYTE(USBD_CDC_OUT_MAXPACKET_SIZE),
|
||||
HBYTE(USBD_CDC_OUT_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
|
||||
0x00, /* bInterval: interval for polling endpoint for data transfers */
|
||||
0x00, /* bInterval: interval for polling endpoint for data transfers */
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -252,24 +252,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] = (uint8_t)str_len;
|
||||
unicode_buf[1] = USB_DESCIPTOR_TYPE_STRING;
|
||||
|
||||
|
||||
return str_len;
|
||||
}
|
||||
|
||||
@@ -278,12 +278,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 )
|
||||
@@ -292,11 +292,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;
|
||||
}
|
||||
}
|
||||
@@ -304,18 +304,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);
|
||||
@@ -326,7 +326,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)
|
||||
{
|
||||
@@ -336,7 +336,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)
|
||||
{
|
||||
@@ -346,7 +346,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)
|
||||
{
|
||||
@@ -356,7 +356,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)
|
||||
{
|
||||
@@ -366,7 +366,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)
|
||||
{
|
||||
@@ -377,7 +377,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)
|
||||
{
|
||||
@@ -389,7 +389,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)
|
||||
{
|
||||
@@ -401,7 +401,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)
|
||||
{
|
||||
@@ -412,7 +412,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)
|
||||
{
|
||||
@@ -424,7 +424,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)
|
||||
{
|
||||
@@ -435,7 +435,7 @@ static usbd_desc_t *get_device_config_string(void)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_desc.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb cdc 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_DESC_H
|
||||
#define __CDC_DESC_H
|
||||
@@ -31,19 +31,19 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include "cdc_class.h"
|
||||
#include "usbd_core.h"
|
||||
|
||||
/** @addtogroup AT32F415_middlewares_usbd_class
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup USB_cdc_desc
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup USB_cdc_desc_definition
|
||||
/** @defgroup USB_cdc_desc_definition
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ extern "C" {
|
||||
* @brief usb vendor id and product id define
|
||||
*/
|
||||
#define USBD_CDC_VENDOR_ID 0x2E3C
|
||||
#define USBD_CDC_PRODUCT_ID 0x5740
|
||||
#define USBD_CDC_PRODUCT_ID 0x5740
|
||||
|
||||
/**
|
||||
* @brief usb descriptor size define
|
||||
@@ -73,7 +73,7 @@ extern "C" {
|
||||
#define USBD_CDC_DESC_INTERFACE_STRING "Virtual ComPort Interface"
|
||||
|
||||
/**
|
||||
* @brief usb endpoint interval define
|
||||
* @brief usb endpoint interval define
|
||||
*/
|
||||
#define CDC_HID_BINTERVAL_TIME 0xFF
|
||||
|
||||
@@ -86,14 +86,14 @@ extern "C" {
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
extern usbd_desc_handler cdc_desc_handler;
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user