update version to v2.0.8

This commit is contained in:
Artery-MCU
2022-04-11 19:22:17 +08:00
parent eb00682e95
commit a89a26cea4
2631 changed files with 230547 additions and 26018 deletions

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file keyboard_class.c
* @version v2.0.7
* @date 2022-02-11
* @version v2.0.8
* @date 2022-04-02
* @brief usb hid 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 AT32F403A_407_middlewares_usbd_class
* @{
*/
/** @defgroup USB_keyboard_class
* @brief usb device keyboard demo
* @{
*/
*/
/** @defgroup USB_keyboard_class_private_functions
* @{
@@ -65,7 +65,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
@@ -186,7 +186,7 @@ const static unsigned char _asciimap[128] =
};
/* usb device class handler */
usbd_class_handler keyboard_class_handler =
usbd_class_handler keyboard_class_handler =
{
class_init_handler,
class_clear_handler,
@@ -203,7 +203,7 @@ usbd_class_handler 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)
{
@@ -214,28 +214,28 @@ static usb_sts_type class_init_handler(void *udev)
/* use user define buffer address */
usbd_ept_buf_custom_define(pudev, USBD_KEYBOARD_IN_EPT, EPT1_TX_ADDR);
#endif
/* open hid in endpoint */
usbd_ept_open(pudev, USBD_KEYBOARD_IN_EPT, EPT_INT_TYPE, USBD_KEYBOARD_IN_MAXPACKET_SIZE);
pkeyboard->g_u8tx_completed = 1;
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 hid in endpoint */
usbd_ept_close(pudev, USBD_KEYBOARD_IN_EPT);
return status;
}
@@ -243,7 +243,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)
{
@@ -317,21 +317,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)
{
@@ -345,7 +345,7 @@ static usb_sts_type class_ept0_rx_handler(void *udev)
/* hid buffer process */
pkeyboard->hid_state = 0;
}
return status;
}
@@ -353,19 +353,19 @@ 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;
keyboard_type *pkeyboard = (keyboard_type *)pudev->class_handler->pdata;
/* ...user code...
trans next packet data
*/
pkeyboard->g_u8tx_completed = 1;
return status;
}
@@ -373,26 +373,26 @@ 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;
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;
}
@@ -400,7 +400,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)
{
@@ -410,18 +410,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:
pkeyboard->hid_suspend_flag = 1;
/* ...user code... */
break;
case USBD_WAKEUP_EVENT:
/* ...user code... */
break;
default:
break;
@@ -434,7 +434,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 usb_keyboard_class_send_report(void *udev, uint8_t *report, uint16_t len)
{
@@ -443,7 +443,7 @@ usb_sts_type usb_keyboard_class_send_report(void *udev, uint8_t *report, uint16_
if(usbd_connect_state_get(pudev) == USB_CONN_STATE_CONFIGURED)
usbd_ept_send(pudev, USBD_KEYBOARD_IN_EPT, report, len);
return status;
}
@@ -452,14 +452,14 @@ usb_sts_type usb_keyboard_class_send_report(void *udev, uint8_t *report, uint16_
* @brief usb device class report function
* @param udev: to the structure of usbd_core_type
* @param op: operation
* @retval none
* @retval none
*/
void usb_hid_keyboard_send_char(void *udev, uint8_t ascii_code)
{
uint8_t key_data = 0;
usbd_core_type *pudev = (usbd_core_type *)udev;
keyboard_type *pkeyboard = (keyboard_type *)pudev->class_handler->pdata;
if(ascii_code > 128)
{
ascii_code = 0;
@@ -471,14 +471,14 @@ void usb_hid_keyboard_send_char(void *udev, uint8_t ascii_code)
{
ascii_code = 0;
}
if(ascii_code & SHIFT)
{
key_data = 0x2;
ascii_code &= 0x7F;
}
}
if((pkeyboard->temp == ascii_code) && (ascii_code != 0))
{
pkeyboard->keyboard_buf[0] = 0;
@@ -496,7 +496,7 @@ void usb_hid_keyboard_send_char(void *udev, uint8_t ascii_code)
/**
* @}
*/
*/
/**
* @}

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file keyboard_class.h
* @version v2.0.7
* @date 2022-02-11
* @version v2.0.8
* @date 2022-04-02
* @brief usb hid keyboard 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 __KEYBOARD_CLASS_H
#define __KEYBOARD_CLASS_H
@@ -31,19 +31,19 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "usb_std.h"
#include "usbd_core.h"
/** @addtogroup AT32F403A_407_middlewares_usbd_class
* @{
*/
/** @addtogroup USB_keyboard_class
* @{
*/
/** @defgroup USB_keyboard_class_endpoint_definition
/** @defgroup USB_keyboard_class_endpoint_definition
* @{
*/
@@ -70,12 +70,12 @@ typedef struct
uint32_t alt_setting;
uint8_t hid_set_report[64];
uint8_t keyboard_buf[8];
__IO uint8_t hid_suspend_flag;
__IO uint8_t g_u8tx_completed;
uint8_t hid_state;
uint8_t temp;
}keyboard_type;
/** @defgroup USB_hid_class_exported_functions
@@ -92,7 +92,7 @@ void usb_hid_keyboard_send_char(void *udev, uint8_t ascii_code);
/**
* @}
*/
/**
* @}
*/

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file keyboard_desc.c
* @version v2.0.7
* @date 2022-02-11
* @version v2.0.8
* @date 2022-04-02
* @brief usb hid 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,
@@ -31,11 +31,11 @@
/** @addtogroup AT32F403A_407_middlewares_usbd_class
* @{
*/
/** @defgroup USB_keyboard_desc
* @brief usb device keyboard descriptor
* @{
*/
*/
/** @defgroup USB_keyboard_desc_private_functions
* @{
@@ -120,7 +120,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_KEYBOARD_CONFIG_DESC_SIZE]
the configuration */
0xE0, /* bmAttributes: self powered and support remote wakeup*/
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 */
@@ -130,7 +130,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_KEYBOARD_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(KEYBOARD_BCD_NUM),
@@ -140,7 +140,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_KEYBOARD_CONFIG_DESC_SIZE]
HID_CLASS_DESC_REPORT, /* bDescriptorType: report descriptor type */
LBYTE(sizeof(g_usbd_keyboard_report)),
HBYTE(sizeof(g_usbd_keyboard_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_KEYBOARD_IN_EPT, /* bEndpointAddress: the address of endpoint on usb device described by this descriptor */
@@ -156,7 +156,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_KEYBOARD_CONFIG_DESC_SIZE]
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t g_usbd_keyboard_report[USBD_KEYBOARD_SIZ_REPORT_DESC] ALIGNED_TAIL =
ALIGNED_HEAD uint8_t g_usbd_keyboard_report[USBD_KEYBOARD_SIZ_REPORT_DESC] ALIGNED_TAIL =
{
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
@@ -189,7 +189,7 @@ ALIGNED_HEAD uint8_t g_usbd_keyboard_report[USBD_KEYBOARD_SIZ_REPORT_DESC] ALIGN
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
};
/**
@@ -198,7 +198,7 @@ ALIGNED_HEAD uint8_t g_usbd_keyboard_report[USBD_KEYBOARD_SIZ_REPORT_DESC] ALIGN
#if defined ( __ICCARM__ ) /* iar compiler */
#pragma data_alignment=4
#endif
ALIGNED_HEAD uint8_t g_keyboard_usb_desc[9] ALIGNED_TAIL =
ALIGNED_HEAD uint8_t g_keyboard_usb_desc[9] ALIGNED_TAIL =
{
0x09, /* bLength: size of HID descriptor in bytes */
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
@@ -273,24 +273,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;
}
@@ -299,12 +299,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 )
@@ -313,11 +313,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;
}
}
@@ -325,18 +325,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);
@@ -347,7 +347,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)
{
@@ -357,7 +357,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)
{
@@ -367,7 +367,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)
{
@@ -377,7 +377,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)
{
@@ -387,7 +387,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)
{
@@ -398,7 +398,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)
{
@@ -410,7 +410,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)
{
@@ -422,7 +422,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)
{
@@ -433,7 +433,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)
{
@@ -445,7 +445,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)
{
@@ -456,7 +456,7 @@ static usbd_desc_t *get_device_config_string(void)
/**
* @}
*/
*/
/**
* @}

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file keyboard_desc.h
* @version v2.0.7
* @date 2022-02-11
* @version v2.0.8
* @date 2022-04-02
* @brief usb 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 __KEYBOARD_DESC_H
#define __KEYBOARD_DESC_H
@@ -31,19 +31,19 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "keyboard_class.h"
#include "usbd_core.h"
/** @addtogroup AT32F403A_407_middlewares_usbd_class
* @{
*/
/** @addtogroup USB_keyboard_desc
* @{
*/
/** @defgroup USB_keyboard_desc_definition
/** @defgroup USB_keyboard_desc_definition
* @{
*/
@@ -56,7 +56,7 @@ extern "C" {
* @brief usb vendor id and product id define
*/
#define USBD_KEYBOARD_VENDOR_ID 0x2E3C
#define USBD_KEYBOARD_PRODUCT_ID 0x6040
#define USBD_KEYBOARD_PRODUCT_ID 0x6040
/**
* @brief usb descriptor size define
@@ -75,7 +75,7 @@ extern "C" {
#define USBD_KEYBOARD_DESC_INTERFACE_STRING "Keyboard Interface"
/**
* @brief usb hid endpoint interval define
* @brief usb hid endpoint interval define
*/
#define KEYBOARD_BINTERVAL_TIME 0x0A
@@ -96,7 +96,7 @@ extern usbd_desc_handler keyboard_desc_handler;
/**
* @}
*/
/**
* @}
*/