mirror of
https://github.com/ArteryTek/AT32F415_Firmware_Library.git
synced 2026-05-21 01:12:20 +00:00
update version to v2.0.2
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -58,7 +58,7 @@ extern "C" {
|
||||
!defined (AT32F415KBU7_4) && !defined (AT32F415R8T7) && !defined (AT32F415R8T7_7) && \
|
||||
!defined (AT32F415C8T7) && !defined (AT32F415K8U7_4)
|
||||
|
||||
#error "Please select first the target at32f4xx device used in your application (in at32f4xx.h file)"
|
||||
#error "Please select first the target device used in your application (in at32f415.h file)"
|
||||
#endif
|
||||
|
||||
#if defined (AT32F415RCT7) || defined (AT32F415RCT7_7) || defined (AT32F415CCT7) || \
|
||||
@@ -89,7 +89,7 @@ extern "C" {
|
||||
*/
|
||||
#define __AT32F415_LIBRARY_VERSION_MAJOR (0x02) /*!< [31:24] major version */
|
||||
#define __AT32F415_LIBRARY_VERSION_MIDDLE (0x00) /*!< [23:16] middle version */
|
||||
#define __AT32F415_LIBRARY_VERSION_MINOR (0x00) /*!< [15:8] minor version */
|
||||
#define __AT32F415_LIBRARY_VERSION_MINOR (0x02) /*!< [15:8] minor version */
|
||||
#define __AT32F415_LIBRARY_VERSION_RC (0x00) /*!< [7:0] release candidate */
|
||||
#define __AT32F415_LIBRARY_VERSION ((__AT32F415_LIBRARY_VERSION_MAJOR << 24) | \
|
||||
(__AT32F415_LIBRARY_VERSION_MIDDLE << 16) | \
|
||||
@@ -361,6 +361,7 @@ typedef enum {ERROR = 0, SUCCESS = !ERROR} error_status;
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "at32f415_def.h"
|
||||
#include "at32f415_conf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_conf.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 config header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file startup_at32f415.s
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415xx devices vector table for gcc toolchain.
|
||||
* this module performs:
|
||||
* - set the initial sp
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
;**************************************************************************
|
||||
;* @file startup_at32f415.s
|
||||
;* @version v2.0.0
|
||||
;* @date 2021-11-26
|
||||
;* @version v2.0.2
|
||||
;* @date 2021-12-31
|
||||
;* @brief at32f415 startup file for IAR Systems
|
||||
;**************************************************************************
|
||||
;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
;**************************************************************************
|
||||
;* @file startup_at32f415.s
|
||||
;* @version v2.0.0
|
||||
;* @date 2021-11-26
|
||||
;* @version v2.0.2
|
||||
;* @date 2021-12-31
|
||||
;* @brief at32f415 startup file for keil
|
||||
;**************************************************************************
|
||||
;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file system_at32f415.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for cmsis cortex-m4 system source file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file system_at32f415.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief cmsis cortex-m4 system header file.
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_adc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 adc header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_can.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 can header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -110,16 +110,21 @@ extern "C" {
|
||||
/**
|
||||
* @brief can flag clear operation macro definition val
|
||||
*/
|
||||
#define CAN_MSTS_EOIF_VAL ((uint32_t)0x00000004) /*!< eoif bit w1 */
|
||||
#define CAN_MSTS_QDZIF_VAL ((uint32_t)0x00000008) /*!< qdzif bit w1 */
|
||||
#define CAN_MSTS_EDZIF_VAL ((uint32_t)0x00000010) /*!< edzif bit w1 */
|
||||
#define CAN_TSTS_TM0TCF_VAL ((uint32_t)0x00000001) /*!< tm0tcf bit w1 */
|
||||
#define CAN_TSTS_TM1TCF_VAL ((uint32_t)0x00000100) /*!< tm1tcf bit w1 */
|
||||
#define CAN_TSTS_TM2TCF_VAL ((uint32_t)0x00010000) /*!< tm2tcf bit w1 */
|
||||
#define CAN_RF0_RF0FF_VAL ((uint32_t)0x00000008) /*!< rf0ff bit w1 */
|
||||
#define CAN_RF0_RF0OF_VAL ((uint32_t)0x00000010) /*!< rf0of bit w1 */
|
||||
#define CAN_RF1_RF1FF_VAL ((uint32_t)0x00000008) /*!< rf1ff bit w1 */
|
||||
#define CAN_RF1_RF1OF_VAL ((uint32_t)0x00000010) /*!< rf1of bit w1 */
|
||||
#define CAN_MSTS_EOIF_VAL ((uint32_t)0x00000004) /*!< eoif bit value, it clear by writing 1 */
|
||||
#define CAN_MSTS_QDZIF_VAL ((uint32_t)0x00000008) /*!< qdzif bit value, it clear by writing 1 */
|
||||
#define CAN_MSTS_EDZIF_VAL ((uint32_t)0x00000010) /*!< edzif bit value, it clear by writing 1 */
|
||||
#define CAN_TSTS_TM0TCF_VAL ((uint32_t)0x00000001) /*!< tm0tcf bit value, it clear by writing 1 */
|
||||
#define CAN_TSTS_TM1TCF_VAL ((uint32_t)0x00000100) /*!< tm1tcf bit value, it clear by writing 1 */
|
||||
#define CAN_TSTS_TM2TCF_VAL ((uint32_t)0x00010000) /*!< tm2tcf bit value, it clear by writing 1 */
|
||||
#define CAN_TSTS_TM0CT_VAL ((uint32_t)0x00000080) /*!< tm0ct bit value, it clear by writing 1 */
|
||||
#define CAN_TSTS_TM1CT_VAL ((uint32_t)0x00008000) /*!< tm1ct bit value, it clear by writing 1 */
|
||||
#define CAN_TSTS_TM2CT_VAL ((uint32_t)0x00800000) /*!< tm2ct bit value, it clear by writing 1 */
|
||||
#define CAN_RF0_RF0FF_VAL ((uint32_t)0x00000008) /*!< rf0ff bit value, it clear by writing 1 */
|
||||
#define CAN_RF0_RF0OF_VAL ((uint32_t)0x00000010) /*!< rf0of bit value, it clear by writing 1 */
|
||||
#define CAN_RF0_RF0R_VAL ((uint32_t)0x00000020) /*!< rf0r bit value, it clear by writing 1 */
|
||||
#define CAN_RF1_RF1FF_VAL ((uint32_t)0x00000008) /*!< rf1ff bit value, it clear by writing 1 */
|
||||
#define CAN_RF1_RF1OF_VAL ((uint32_t)0x00000010) /*!< rf1of bit value, it clear by writing 1 */
|
||||
#define CAN_RF1_RF1R_VAL ((uint32_t)0x00000020) /*!< rf1r bit value, it clear by writing 1 */
|
||||
|
||||
/** @defgroup CAN_exported_types
|
||||
* @{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_cmp.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 cmp header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_crc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 crc header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_crm.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 crm header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_debug.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 debug header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -133,7 +133,7 @@ typedef struct
|
||||
* @}
|
||||
*/
|
||||
|
||||
#define DEBUG ((debug_type *) DEBUG_BASE)
|
||||
#define DEBUGMCU ((debug_type *) DEBUG_BASE)
|
||||
|
||||
/** @defgroup DEBUG_exported_functions
|
||||
* @{
|
||||
|
||||
69
libraries/drivers/inc/at32f415_def.h
Normal file
69
libraries/drivers/inc/at32f415_def.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_def.h
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 macros 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
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
* GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
|
||||
* TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
|
||||
* STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
|
||||
* INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
||||
*
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __AT32F415_DEF_H
|
||||
#define __AT32F415_DEF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* gnu compiler */
|
||||
#if defined (__GNUC__)
|
||||
#ifndef ALIGNED_HEAD
|
||||
#define ALIGNED_HEAD
|
||||
#endif
|
||||
#ifndef ALIGNED_TAIL
|
||||
#define ALIGNED_TAIL __attribute__ ((aligned (4)))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* arm compiler */
|
||||
#if defined (__CC_ARM)
|
||||
#ifndef ALIGNED_HEAD
|
||||
#define ALIGNED_HEAD __align(4)
|
||||
#endif
|
||||
#ifndef ALIGNED_TAIL
|
||||
#define ALIGNED_TAIL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* iar compiler */
|
||||
#if defined (__ICCARM__)
|
||||
#ifndef ALIGNED_HEAD
|
||||
#define ALIGNED_HEAD
|
||||
#endif
|
||||
#ifndef ALIGNED_TAIL
|
||||
#define ALIGNED_TAIL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_dma.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 dma header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_ertc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 ertc header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_exint.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 exint header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_flash.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 flash header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_gpio.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 gpio header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -423,7 +423,7 @@ typedef struct
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief gpio wcr register, offset:0x10
|
||||
* @brief gpio scr register, offset:0x10
|
||||
*/
|
||||
union
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_i2c.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 i2c header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_misc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 misc header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -64,11 +64,11 @@ extern "C" {
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NVIC_PRIORITY_GROUP_0 = ((uint32_t)0x700), /*!< 0 bits for preemption priority, 4 bits for subpriority */
|
||||
NVIC_PRIORITY_GROUP_1 = ((uint32_t)0x600), /*!< 1 bits for preemption priority, 3 bits for subpriority */
|
||||
NVIC_PRIORITY_GROUP_2 = ((uint32_t)0x500), /*!< 2 bits for preemption priority, 2 bits for subpriority */
|
||||
NVIC_PRIORITY_GROUP_3 = ((uint32_t)0x400), /*!< 3 bits for preemption priority, 1 bits for subpriority */
|
||||
NVIC_PRIORITY_GROUP_4 = ((uint32_t)0x300) /*!< 4 bits for preemption priority, 0 bits for subpriority */
|
||||
NVIC_PRIORITY_GROUP_0 = ((uint32_t)0x7), /*!< 0 bits for preemption priority, 4 bits for subpriority */
|
||||
NVIC_PRIORITY_GROUP_1 = ((uint32_t)0x6), /*!< 1 bits for preemption priority, 3 bits for subpriority */
|
||||
NVIC_PRIORITY_GROUP_2 = ((uint32_t)0x5), /*!< 2 bits for preemption priority, 2 bits for subpriority */
|
||||
NVIC_PRIORITY_GROUP_3 = ((uint32_t)0x4), /*!< 3 bits for preemption priority, 1 bits for subpriority */
|
||||
NVIC_PRIORITY_GROUP_4 = ((uint32_t)0x3) /*!< 4 bits for preemption priority, 0 bits for subpriority */
|
||||
} nvic_priority_group_type;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_pwc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 pwc header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -57,6 +57,11 @@ extern "C" {
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief pwc wakeup pin num definition
|
||||
*/
|
||||
#define PWC_WAKEUP_PIN_1 ((uint32_t)0x00000100) /*!< standby wake-up pin1 */
|
||||
|
||||
/** @defgroup PWC_exported_types
|
||||
* @{
|
||||
*/
|
||||
@@ -159,7 +164,7 @@ void pwc_reset(void);
|
||||
void pwc_battery_powered_domain_access(confirm_state new_state);
|
||||
void pwc_pvm_level_select(pwc_pvm_voltage_type pvm_voltage);
|
||||
void pwc_power_voltage_monitor_enable(confirm_state new_state);
|
||||
void pwc_wakeup_pin_enable(confirm_state new_state);
|
||||
void pwc_wakeup_pin_enable(uint32_t pin_num, confirm_state new_state);
|
||||
void pwc_flag_clear(uint32_t pwc_flag);
|
||||
flag_status pwc_flag_get(uint32_t pwc_flag);
|
||||
void pwc_sleep_mode_enter(pwc_sleep_enter_type pwc_sleep_enter);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_sdio.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 sdio header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_spi.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 spi header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -122,8 +122,8 @@ typedef enum
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SPI_CS_HARDWARE_MODE = 0x00, /*!< cs is software mode */
|
||||
SPI_CS_SOFTWARE_MODE = 0x01 /*!< cs is hardware mode */
|
||||
SPI_CS_HARDWARE_MODE = 0x00, /*!< cs is hardware mode */
|
||||
SPI_CS_SOFTWARE_MODE = 0x01 /*!< cs is software mode */
|
||||
} spi_cs_mode_type;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_tmr.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 tmr header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_usart.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 usart header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_usb.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 usb header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_wdt.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 wdt header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_wwdt.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief at32f415 wwdt header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_adc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the adc firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -911,7 +911,7 @@ flag_status adc_flag_get(adc_type *adc_x, uint8_t adc_flag)
|
||||
*/
|
||||
void adc_flag_clear(adc_type *adc_x, uint32_t adc_flag)
|
||||
{
|
||||
adc_x->sts &= ~adc_flag;
|
||||
adc_x->sts = ~adc_flag;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_can.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the can firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -583,13 +583,13 @@ void can_transmit_cancel(can_type* can_x, can_tx_mailbox_num_type transmit_mailb
|
||||
switch (transmit_mailbox)
|
||||
{
|
||||
case CAN_TX_MAILBOX0:
|
||||
can_x->tsts_bit.tm0ct = TRUE;
|
||||
can_x->tsts = CAN_TSTS_TM0CT_VAL;
|
||||
break;
|
||||
case CAN_TX_MAILBOX1:
|
||||
can_x->tsts_bit.tm1ct = TRUE;
|
||||
can_x->tsts = CAN_TSTS_TM1CT_VAL;
|
||||
break;
|
||||
case CAN_TX_MAILBOX2:
|
||||
can_x->tsts_bit.tm2ct = TRUE;
|
||||
can_x->tsts = CAN_TSTS_TM2CT_VAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -660,10 +660,10 @@ void can_receive_fifo_release(can_type* can_x, can_rx_fifo_num_type fifo_number)
|
||||
switch (fifo_number)
|
||||
{
|
||||
case CAN_RX_FIFO0:
|
||||
can_x->rf0_bit.rf0r = TRUE;
|
||||
can_x->rf0 = CAN_RF0_RF0R_VAL;
|
||||
break;
|
||||
case CAN_RX_FIFO1:
|
||||
can_x->rf1_bit.rf1r = TRUE;
|
||||
can_x->rf1 = CAN_RF1_RF1R_VAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_cmp.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the gpio firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_crc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the crc firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_crm.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the crm firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_debug.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the debug firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -48,7 +48,7 @@
|
||||
*/
|
||||
uint32_t debug_device_id_get(void)
|
||||
{
|
||||
return DEBUG->pid;
|
||||
return DEBUGMCU->pid;
|
||||
}
|
||||
/**
|
||||
* @brief set periph debug mode
|
||||
@@ -75,14 +75,13 @@ uint32_t debug_device_id_get(void)
|
||||
*/
|
||||
void debug_periph_mode_set(uint32_t periph_debug_mode, confirm_state new_state)
|
||||
{
|
||||
|
||||
if(new_state != FALSE)
|
||||
{
|
||||
DEBUG->ctrl |= periph_debug_mode;
|
||||
DEBUGMCU->ctrl |= periph_debug_mode;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG->ctrl &= ~periph_debug_mode;
|
||||
DEBUGMCU->ctrl &= ~periph_debug_mode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_dma.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the dma firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -215,7 +215,6 @@ void dma_channel_enable(dma_channel_type* dmax_channely, confirm_state new_state
|
||||
* - FLEX_CHANNEL5
|
||||
* - FLEX_CHANNEL6
|
||||
* - FLEX_CHANNEL7
|
||||
* - DMA2_CHANNEL8
|
||||
* @param flexible_request: every peripheral have specified hardware_id.
|
||||
* this parameter can be one of the following values:
|
||||
* - DMA_FLEXIBLE_ADC1 - DMA_FLEXIBLE_SPI1_RX - DMA_FLEXIBLE_SPI1_TX - DMA_FLEXIBLE_SPI2_RX
|
||||
@@ -342,9 +341,9 @@ flag_status dma_flag_get(uint32_t dmax_flag)
|
||||
*/
|
||||
void dma_flag_clear(uint32_t dmax_flag)
|
||||
{
|
||||
if(dmax_flag > 0x10000000)
|
||||
if(dmax_flag > ((uint32_t)0x10000000))
|
||||
{
|
||||
DMA2->clr = dmax_flag;
|
||||
DMA2->clr = (uint32_t)(dmax_flag & 0x0FFFFFFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_ertc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the ertc firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -102,7 +102,7 @@ error_status ertc_wait_update(void)
|
||||
ertc_write_protect_disable();
|
||||
|
||||
/* clear updf flag */
|
||||
ERTC->sts_bit.updf = 0;
|
||||
ERTC->sts = ~(ERTC_UPDF_FLAG | 0x00000080) | (ERTC->sts_bit.imen << 7);
|
||||
|
||||
/* enable write protection */
|
||||
ertc_write_protect_enable();
|
||||
@@ -170,7 +170,7 @@ error_status ertc_init_mode_enter(void)
|
||||
if(ERTC->sts_bit.imf == 0)
|
||||
{
|
||||
/* enter init mode */
|
||||
ERTC->sts_bit.imen = 1;
|
||||
ERTC->sts = 0xFFFFFFFF;
|
||||
|
||||
while(ERTC->sts_bit.imf == 0)
|
||||
{
|
||||
@@ -196,7 +196,7 @@ error_status ertc_init_mode_enter(void)
|
||||
*/
|
||||
void ertc_init_mode_exit(void)
|
||||
{
|
||||
ERTC->sts_bit.imen = FALSE;
|
||||
ERTC->sts = 0xFFFFFF7F;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1328,7 +1328,7 @@ void ertc_tamper_enable(ertc_tamper_select_type tamper_x, confirm_state new_stat
|
||||
/**
|
||||
* @brief enable or disable interrupt.
|
||||
* @param source: interrupts sources
|
||||
* this parameter can be one of the following values:
|
||||
* this parameter can be any combination of the following values:
|
||||
* - ERTC_TP_INT: tamper interrupt.
|
||||
* - ERTC_ALA_INT: alarm a interrupt.
|
||||
* - ERTC_ALB_INT: alarm b interrupt.
|
||||
@@ -1463,7 +1463,7 @@ void ertc_flag_clear(uint32_t flag)
|
||||
/* disable write protection */
|
||||
ertc_write_protect_disable();
|
||||
|
||||
ERTC->sts &= ~flag;
|
||||
ERTC->sts = ~(flag | 0x00000080) | (ERTC->sts_bit.imen << 7);
|
||||
|
||||
/* enable write protection */
|
||||
ertc_write_protect_enable();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_exint.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the exint firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_flash.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the flash firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_gpio.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the gpio firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_i2c.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the i2c firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_misc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the misc firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_pwc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the pwc firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -94,15 +94,25 @@ void pwc_power_voltage_monitor_enable(confirm_state new_state)
|
||||
|
||||
/**
|
||||
* @brief enable or disable pwc standby wakeup pin
|
||||
* @param pin_num: choose the wakeup pin.
|
||||
* this parameter can be be any combination of the following values:
|
||||
* - PWC_WAKEUP_PIN_1
|
||||
* @param new_state: new state of the standby wakeup pin.
|
||||
* this parameter can be one of the following values:
|
||||
* - TRUE <wakeup pin is used for wake up cpu from standby mode>
|
||||
* - FALSE <wakeup pin is used for general purpose I/O>
|
||||
* @retval none
|
||||
*/
|
||||
void pwc_wakeup_pin_enable(confirm_state new_state)
|
||||
void pwc_wakeup_pin_enable(uint32_t pin_num, confirm_state new_state)
|
||||
{
|
||||
PWC->ctrlsts_bit.swpen = new_state;
|
||||
if(new_state == TRUE)
|
||||
{
|
||||
PWC->ctrlsts |= pin_num;
|
||||
}
|
||||
else
|
||||
{
|
||||
PWC->ctrlsts &= ~pin_num;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_sdio.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the sdio firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -325,7 +325,7 @@ flag_status sdio_flag_get(sdio_type *sdio_x, uint32_t flag)
|
||||
*/
|
||||
void sdio_flag_clear(sdio_type *sdio_x, uint32_t flag)
|
||||
{
|
||||
sdio_x->intclr |= flag;
|
||||
sdio_x->intclr = flag;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_spi.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the spi firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -580,9 +580,9 @@ flag_status spi_i2s_flag_get(spi_type* spi_x, uint32_t spi_i2s_flag)
|
||||
void spi_i2s_flag_clear(spi_type* spi_x, uint32_t spi_i2s_flag)
|
||||
{
|
||||
volatile uint32_t temp = 0;
|
||||
|
||||
temp = temp;
|
||||
if(spi_i2s_flag == SPI_CCERR_FLAG)
|
||||
spi_x->sts_bit.ccerr = FALSE;
|
||||
spi_x->sts = ~SPI_CCERR_FLAG;
|
||||
else if(spi_i2s_flag == SPI_I2S_RDBF_FLAG)
|
||||
temp = REG32(&spi_x->dt);
|
||||
else if(spi_i2s_flag == I2S_TUERR_FLAG)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_tmr.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the tmr firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -1346,7 +1346,7 @@ flag_status tmr_flag_get(tmr_type *tmr_x, uint32_t tmr_flag)
|
||||
*/
|
||||
void tmr_flag_clear(tmr_type *tmr_x, uint32_t tmr_flag)
|
||||
{
|
||||
tmr_x->ists &= ~tmr_flag;
|
||||
tmr_x->ists = ~tmr_flag;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_usart.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the usart firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_usb.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the usb firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -309,8 +309,7 @@ void usb_set_tx_fifo(otg_global_type *usbx, uint8_t txfifo, uint16_t size)
|
||||
offset = usbx->grxfsiz;
|
||||
if(txfifo == 0)
|
||||
{
|
||||
usbx->gnptxfsiz_ept0tx_bit.nptxfstaddr = offset;
|
||||
usbx->gnptxfsiz_ept0tx_bit.nptxfdep = size;
|
||||
usbx->gnptxfsiz_ept0tx = offset | (size << 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -319,8 +318,7 @@ void usb_set_tx_fifo(otg_global_type *usbx, uint8_t txfifo, uint16_t size)
|
||||
{
|
||||
offset += usbx->dieptxfn_bit[i_index].ineptxfdep;
|
||||
}
|
||||
usbx->dieptxfn_bit[txfifo-1].ineptxfstaddr = offset;
|
||||
usbx->dieptxfn_bit[txfifo-1].ineptxfdep = size;
|
||||
usbx->dieptxfn[txfifo - 1] = offset | (size << 16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,7 +421,11 @@ void usb_write_packet(otg_global_type *usbx, uint8_t *pusr_buf, uint16_t num, ui
|
||||
uint32_t *pbuf = (uint32_t *)pusr_buf;
|
||||
for(n_index = 0; n_index < nhbytes; n_index ++)
|
||||
{
|
||||
#if defined (__ICCARM__) && (__VER__ < 7000000)
|
||||
USB_FIFO(usbx, num) = *(__packed uint32_t *)pbuf;
|
||||
#else
|
||||
USB_FIFO(usbx, num) = __UNALIGNED_UINT32_READ(pbuf);
|
||||
#endif
|
||||
pbuf ++;
|
||||
}
|
||||
}
|
||||
@@ -442,7 +444,11 @@ void usb_read_packet(otg_global_type *usbx, uint8_t *pusr_buf, uint16_t num, uin
|
||||
uint32_t *pbuf = (uint32_t *)pusr_buf;
|
||||
for(n_index = 0; n_index < nhbytes; n_index ++)
|
||||
{
|
||||
#if defined (__ICCARM__) && (__VER__ < 7000000)
|
||||
*(__packed uint32_t *)pbuf = USB_FIFO(usbx, 0);
|
||||
#else
|
||||
__UNALIGNED_UINT32_WRITE(pbuf, (USB_FIFO(usbx, 0)));
|
||||
#endif
|
||||
pbuf ++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_wdt.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the wdt firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f415_wwdt.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief contains all the functions for the wwdt firmware library
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -73,7 +73,7 @@ void wwdt_divider_set(wwdt_division_type division)
|
||||
*/
|
||||
void wwdt_flag_clear(void)
|
||||
{
|
||||
WWDT->sts_bit.rldf = FALSE;
|
||||
WWDT->sts = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file i2c_application.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief the driver library of the i2c peripheral
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file i2c_application.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief i2c application libray header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usb_core.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb core header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usb_std.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb standard header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbd_core.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb device core header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbd_int.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb interrupt header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usb_sdr.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_core.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host core header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -301,6 +301,7 @@ typedef struct
|
||||
|
||||
uint32_t conn_sts; /*!< connect status */
|
||||
uint32_t port_enable; /*!< port enable status */
|
||||
uint32_t timer; /*!< sof timer */
|
||||
|
||||
uint32_t err_cnt[USB_HOST_CHANNEL_NUM]; /*!< error counter */
|
||||
uint32_t xfer_cnt[USB_HOST_CHANNEL_NUM]; /*!< xfer counter */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_ctrl.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_int.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -55,6 +55,7 @@ void usbh_hch_in_handler(usbh_core_type *uhost, uint8_t chn);
|
||||
void usbh_hch_out_handler(usbh_core_type *uhost, uint8_t chn);
|
||||
void usbh_rx_qlvl_handler(usbh_core_type *uhost);
|
||||
void usbh_wakeup_handler(usbh_core_type *uhost);
|
||||
void usbh_sof_handler(usbh_core_type *uhost);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usb_core.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb driver
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbd_core.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb device driver
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -645,7 +645,7 @@ void usbd_enter_suspend(usbd_core_type *udev)
|
||||
void usbd_flush_tx_fifo(usbd_core_type *udev, uint8_t ept_num)
|
||||
{
|
||||
/* flush endpoint tx fifo */
|
||||
usb_flush_tx_fifo(udev->usb_reg, ept_num & 0xF);
|
||||
usb_flush_tx_fifo(udev->usb_reg, ept_num & 0x1F);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbd_int.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb interrupt request
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -425,8 +425,8 @@ void usbd_reset_handler(usbd_core_type *udev)
|
||||
/* endpoint fifo alloc */
|
||||
usbd_fifo_alloc(udev);
|
||||
|
||||
/* flush tx fifo 0 */
|
||||
usb_flush_tx_fifo(usbx, 0);
|
||||
/* flush all tx fifo */
|
||||
usb_flush_tx_fifo(usbx, 0x10);
|
||||
|
||||
/* clear in and out endpoint interrupt flag */
|
||||
for(i_index = 0; i_index < USB_EPT_MAX_NUM; i_index ++)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbd_sdr.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb standard device request
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_core.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host driver
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -512,6 +512,8 @@ usb_sts_type usbh_core_init(usbh_core_type *uhost,
|
||||
/* host user handler */
|
||||
uhost->user_handler->user_init();
|
||||
|
||||
uhost->timer = 0;
|
||||
|
||||
/* usb host cfg default init */
|
||||
usbh_cfg_default_init(uhost);
|
||||
|
||||
@@ -542,9 +544,6 @@ usb_sts_type usbh_core_init(usbh_core_type *uhost,
|
||||
/* clock select */
|
||||
usbh_fsls_clksel(usbx, USB_HCFG_CLK_48M);
|
||||
|
||||
/* reset host port */
|
||||
usbh_reset_port(uhost);
|
||||
|
||||
/* set support ls and fs device */
|
||||
host->hcfg_bit.fslssupp = 0;
|
||||
|
||||
@@ -950,11 +949,13 @@ void usbh_reset_port(usbh_core_type *uhost)
|
||||
/* set port reset */
|
||||
usb_host->hprt = hprt_val | USB_OTG_HPRT_PRTRST;
|
||||
|
||||
usb_delay_ms(10);
|
||||
usb_delay_ms(100);
|
||||
|
||||
/* clear port reset */
|
||||
usb_host->hprt = hprt_val & (~USB_OTG_HPRT_PRTRST);
|
||||
|
||||
usb_delay_ms(20);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -968,9 +969,6 @@ static void usbh_attached(usbh_core_type *uhost)
|
||||
uhost->ctrl.hch_in = usbh_alloc_channel(uhost, 0x80);
|
||||
uhost->ctrl.hch_out = usbh_alloc_channel(uhost, 0x00);
|
||||
|
||||
/* reset port */
|
||||
usbh_reset_port(uhost);
|
||||
|
||||
/* user reset callback handler */
|
||||
uhost->user_handler->user_reset();
|
||||
|
||||
@@ -991,6 +989,9 @@ static void usbh_attached(usbh_core_type *uhost)
|
||||
uhost->ctrl.ept0_size,
|
||||
uhost->dev.speed);
|
||||
|
||||
usb_flush_tx_fifo(uhost->usb_reg, 0x10);
|
||||
usb_flush_rx_fifo(uhost->usb_reg);
|
||||
|
||||
/* user attached callback */
|
||||
uhost->user_handler->user_attached();
|
||||
}
|
||||
@@ -1027,7 +1028,7 @@ static void usbh_class_request(usbh_core_type *uhost)
|
||||
{
|
||||
uhost->global_state = USBH_CLASS;
|
||||
}
|
||||
else if(status == USB_ERROR)
|
||||
else if(status == USB_ERROR || status == USB_FAIL)
|
||||
{
|
||||
uhost->global_state = USBH_ERROR_STATE;
|
||||
}
|
||||
@@ -1134,6 +1135,12 @@ usb_sts_type usbh_loop_handler(usbh_core_type *uhost)
|
||||
{
|
||||
usb_sts_type status = USB_FAIL;
|
||||
|
||||
if(uhost->conn_sts == 0 &&
|
||||
uhost->global_state != USBH_IDLE &&
|
||||
uhost->global_state != USBH_DISCONNECT)
|
||||
{
|
||||
uhost->global_state = USBH_IDLE;
|
||||
}
|
||||
switch(uhost->global_state)
|
||||
{
|
||||
case USBH_IDLE:
|
||||
@@ -1141,6 +1148,9 @@ usb_sts_type usbh_loop_handler(usbh_core_type *uhost)
|
||||
{
|
||||
uhost->global_state = USBH_PORT_EN;
|
||||
|
||||
/* wait stable */
|
||||
usb_delay_ms(200);
|
||||
|
||||
/* port reset */
|
||||
usbh_reset_port(uhost);
|
||||
|
||||
@@ -1153,9 +1163,6 @@ usb_sts_type usbh_loop_handler(usbh_core_type *uhost)
|
||||
if(uhost->port_enable)
|
||||
{
|
||||
uhost->global_state = USBH_ATTACHED;
|
||||
|
||||
/* wait stable */
|
||||
usb_delay_ms(50);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_ctrl.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host control request
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -365,7 +365,10 @@ usb_sts_type usbh_ctrl_error_handler(usbh_core_type *uhost)
|
||||
else
|
||||
{
|
||||
uhost->ctrl.sts = CTRL_FAIL;
|
||||
status = USB_FAIL;
|
||||
uhost->global_state = USBH_DISCONNECT;
|
||||
uhost->ctrl.err_cnt = 0;
|
||||
USBH_DEBUG("control error: device not response");
|
||||
status = USB_ERROR;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file usbh_int.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb host interrupt request
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -59,6 +59,7 @@ void usbh_irq_handler(otg_core_type *otgdev)
|
||||
}
|
||||
if(intsts & USB_OTG_SOF_FLAG)
|
||||
{
|
||||
usbh_sof_handler(uhost);
|
||||
usb_global_clear_interrupt(usbx, USB_OTG_SOF_FLAG);
|
||||
}
|
||||
if(intsts & USB_OTG_MODEMIS_FLAG)
|
||||
@@ -114,6 +115,16 @@ void usbh_wakeup_handler(usbh_core_type *uhost)
|
||||
uhost->global_state = USBH_WAKEUP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usb host sof handler
|
||||
* @param uhost: to the structure of usbh_core_type
|
||||
* @retval none
|
||||
*/
|
||||
void usbh_sof_handler(usbh_core_type *uhost)
|
||||
{
|
||||
uhost->timer ++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief usb host disconnect handler
|
||||
* @param uhost: to the structure of usbh_core_type
|
||||
@@ -194,7 +205,11 @@ void usbh_hch_in_handler(usbh_core_type *uhost, uint8_t chn)
|
||||
usb_chh->hcchar_bit.oddfrm = TRUE;
|
||||
uhost->urb_state[chn] = URB_DONE;
|
||||
}
|
||||
uhost->hch[chn].toggle_in ^= 1;
|
||||
else if(usb_chh->hcchar_bit.eptype == EPT_ISO_TYPE)
|
||||
{
|
||||
uhost->urb_state[chn] = URB_DONE;
|
||||
}
|
||||
uhost->hch[chn].toggle_in ^= 1;
|
||||
}
|
||||
else if(hcint_value & USB_OTG_HC_CHHLTD_FLAG)
|
||||
{
|
||||
@@ -436,8 +451,6 @@ void usbh_port_handler(usbh_core_type *uhost)
|
||||
{
|
||||
if(prt & USB_OTG_HPRT_PRTCONSTS)
|
||||
{
|
||||
/* usb unmask disconnect */
|
||||
usbx->gintmsk_bit.disconintmsk = 0;
|
||||
/* connect callback */
|
||||
uhost->conn_sts = 1;
|
||||
}
|
||||
@@ -466,7 +479,6 @@ void usbh_port_handler(usbh_core_type *uhost)
|
||||
/* clean up hprt */
|
||||
usb_host->hprt &= ~(USB_OTG_HPRT_PRTENA | USB_OTG_HPRT_PRTENCHNG |
|
||||
USB_OTG_HPRT_PRTOVRCACT | USB_OTG_HPRT_PRTCONDET);
|
||||
usbx->gintmsk_bit.disconintmsk = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -62,6 +62,8 @@ void audio_set_interface(void *udev, usb_setup_type *setup);
|
||||
|
||||
usb_audio_type audio_struct = {0, 0, 0, 0, 0, 0x1400, 0, 0, 0, {0x0000, 0x1400, 0x33}, {0x0000, 0x1400, 0x33}};
|
||||
|
||||
static __IO uint16_t audio_feedback_state = 0;
|
||||
static __IO uint8_t audio_spk_out_stage = 0;
|
||||
/* usb device class handler */
|
||||
usbd_class_handler audio_class_handler =
|
||||
{
|
||||
@@ -114,8 +116,10 @@ usb_sts_type class_clear_handler(void *udev)
|
||||
/* close in endpoint */
|
||||
usbd_ept_close(pudev, USBD_AUDIO_MIC_IN_EPT);
|
||||
|
||||
#if AUDIO_SUPPORT_FEEDBACK
|
||||
/* close in endpoint */
|
||||
usbd_ept_close(pudev, USBD_AUDIO_FEEDBACK_EPT);
|
||||
#endif
|
||||
|
||||
/* close out endpoint */
|
||||
usbd_ept_close(pudev, USBD_AUDIO_SPK_OUT_EPT);
|
||||
@@ -294,7 +298,6 @@ usb_sts_type class_ept0_rx_handler(void *udev)
|
||||
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;
|
||||
uint32_t len = 0;
|
||||
|
||||
/* ...user code...
|
||||
@@ -303,15 +306,13 @@ usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
|
||||
if((ept_num & 0x7F) == (USBD_AUDIO_MIC_IN_EPT & 0x7F))
|
||||
{
|
||||
len = audio_codec_mic_get_data(audio_struct.audio_mic_data);
|
||||
usb_flush_tx_fifo(pudev->usb_reg, USBD_AUDIO_MIC_IN_EPT & 0x7F);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_MIC_IN_EPT, audio_struct.audio_mic_data, len);
|
||||
usbd_flush_tx_fifo(udev, USBD_AUDIO_MIC_IN_EPT);
|
||||
usbd_ept_send(udev, USBD_AUDIO_MIC_IN_EPT, audio_struct.audio_mic_data, len);
|
||||
}
|
||||
|
||||
else if((ept_num & 0x7F) == (USBD_AUDIO_FEEDBACK_EPT & 0x7F))
|
||||
{
|
||||
len = audio_codec_spk_feedback(audio_struct.audio_feed_back);
|
||||
usb_flush_tx_fifo(pudev->usb_reg, USBD_AUDIO_FEEDBACK_EPT & 0x7F);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, len);
|
||||
audio_feedback_state = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -336,7 +337,7 @@ usb_sts_type class_out_handler(void *udev, uint8_t ept_num)
|
||||
{
|
||||
/* speaker data*/
|
||||
audio_codec_spk_fifo_write(audio_struct.audio_spk_data, g_rxlen);
|
||||
|
||||
audio_spk_out_stage = 1;
|
||||
/* get next data */
|
||||
usbd_ept_recv(pudev, USBD_AUDIO_SPK_OUT_EPT, audio_struct.audio_spk_data, AUDIO_SPK_OUT_MAXPACKET_SIZE);
|
||||
}
|
||||
@@ -353,6 +354,32 @@ usb_sts_type class_sof_handler(void *udev)
|
||||
{
|
||||
usb_sts_type status = USB_OK;
|
||||
|
||||
#if AUDIO_SUPPORT_FEEDBACK
|
||||
if(audio_spk_out_stage & 2)
|
||||
{
|
||||
audio_spk_out_stage = 0;
|
||||
}
|
||||
else if( audio_spk_out_stage )
|
||||
{
|
||||
audio_spk_out_stage |= 2;
|
||||
|
||||
if( 0 == audio_feedback_state )
|
||||
{
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
int len = audio_codec_spk_feedback(audio_struct.audio_feed_back);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, len);
|
||||
audio_feedback_state = 1;
|
||||
}
|
||||
if( audio_feedback_state++ > (1<<FEEDBACK_REFRESH_TIME) ) //timeout
|
||||
{
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
int len = audio_codec_spk_feedback(audio_struct.audio_feed_back);
|
||||
usbd_flush_tx_fifo(pudev, USBD_AUDIO_FEEDBACK_EPT);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, len);
|
||||
audio_feedback_state = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* ...user code... */
|
||||
|
||||
return status;
|
||||
@@ -403,6 +430,7 @@ usb_sts_type class_event_handler(void *udev, usbd_event_type event)
|
||||
*/
|
||||
void audio_inisoincom_event(void *udev)
|
||||
{
|
||||
#if 0
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
uint32_t fnsof = OTG_DEVICE(pudev->usb_reg)->dsts_bit.soffn;
|
||||
uint32_t epctl_fb = USB_INEPT(pudev->usb_reg, (USBD_AUDIO_FEEDBACK_EPT&0x7F))->diepctl_bit.dpid;
|
||||
@@ -427,7 +455,7 @@ void audio_inisoincom_event(void *udev)
|
||||
len = audio_codec_mic_get_data(audio_struct.audio_mic_data);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_MIC_IN_EPT, audio_struct.audio_mic_data, len);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -443,22 +471,26 @@ void audio_req_get_cur(void *udev, usb_setup_type *setup)
|
||||
{
|
||||
if(HBYTE(setup->wValue) == AUDIO_MUTE_CONTROL)
|
||||
{
|
||||
usbd_ctrl_send(pudev, &audio_struct.spk_mute, setup->wLength);
|
||||
audio_struct.g_audio_cur[0] = audio_struct.spk_mute;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume, setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(HBYTE(setup->wValue) == AUDIO_MUTE_CONTROL)
|
||||
{
|
||||
usbd_ctrl_send(pudev, &audio_struct.mic_mute, setup->wLength);
|
||||
audio_struct.g_audio_cur[0] = audio_struct.mic_mute;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume, setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -514,11 +546,13 @@ void audio_req_get_min(void *udev, usb_setup_type *setup)
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
if(HBYTE(setup->wIndex) == AUDIO_SPK_FEATURE_UNIT_ID)
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume_limits[0], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume_limits[0];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume_limits[0], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume_limits[0];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,11 +567,13 @@ void audio_req_get_max(void *udev, usb_setup_type *setup)
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
if(HBYTE(setup->wIndex) == AUDIO_SPK_FEATURE_UNIT_ID)
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume_limits[1], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume_limits[1];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume_limits[1], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume_limits[1];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,11 +588,13 @@ void audio_req_get_res(void *udev, usb_setup_type *setup)
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
if(HBYTE(setup->wIndex) == AUDIO_SPK_FEATURE_UNIT_ID)
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume_limits[2], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume_limits[2];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume_limits[2], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume_limits[2];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,7 +615,6 @@ void audio_set_interface(void *udev, usb_setup_type *setup)
|
||||
if(audio_struct.spk_alt_setting )
|
||||
{
|
||||
usbd_ept_recv(pudev, USBD_AUDIO_SPK_OUT_EPT, audio_struct.audio_spk_data, AUDIO_SPK_OUT_MAXPACKET_SIZE);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio class file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -58,11 +58,11 @@ extern "C" {
|
||||
/**
|
||||
* @brief endpoint support max size
|
||||
*/
|
||||
#define AUDIO_REMAIN_SIZE 8
|
||||
#define AUDIO_REMAIN_SIZE 40
|
||||
#define AUDIO_MIC_IN_MAXPACKET_SIZE (AUDIO_SUPPORT_MAX_FREQ * AUDIO_MIC_CHANEL_NUM * (AUDIO_MIC_DEFAULT_BITW / 8) + AUDIO_REMAIN_SIZE)
|
||||
#define AUDIO_SPK_OUT_MAXPACKET_SIZE (AUDIO_SUPPORT_MAX_FREQ * AUDIO_SPK_CHANEL_NUM * (AUDIO_SPK_DEFAULT_BITW / 8) + AUDIO_REMAIN_SIZE)
|
||||
#define AUDIO_FEEDBACK_MAXPACKET_SIZE 0x3
|
||||
|
||||
#define FEEDBACK_REFRESH_TIME 0x8
|
||||
/**
|
||||
* @brief request type define
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_conf.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio config
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -46,7 +46,7 @@ extern "C" {
|
||||
*/
|
||||
#define AUDIO_SUPPORT_SPK 1
|
||||
#define AUDIO_SUPPORT_MIC 1
|
||||
#define AUDIO_SUPPORT_FEEDBACK 0
|
||||
#define AUDIO_SUPPORT_FEEDBACK 1
|
||||
|
||||
#define AUDIO_SUPPORT_FREQ_16K 1
|
||||
#define AUDIO_SUPPORT_FREQ_48K 1
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -78,7 +78,10 @@ usbd_desc_handler audio_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -103,7 +106,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -361,8 +367,8 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
0x11, /* bmAttributes: endpoint attributes */
|
||||
LBYTE(AUDIO_FEEDBACK_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
|
||||
HBYTE(AUDIO_FEEDBACK_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
|
||||
HID_BINTERVAL_TIME, /* bInterval: interval for polling endpoint for data transfers */
|
||||
0x08, /* bRefresh: this field indicates the rate at which an iso syncronization
|
||||
1, /* bInterval: interval for polling endpoint for data transfers */
|
||||
FEEDBACK_REFRESH_TIME, /* bRefresh: this field indicates the rate at which an iso syncronization
|
||||
pipe provides new syncronization feedback data. this rate must be a power of
|
||||
2, therefore only the power is reported back and the range of this field is from
|
||||
1(2ms) to 9(512ms) */
|
||||
@@ -375,7 +381,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -386,7 +395,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_conf.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio config
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -48,7 +48,7 @@ extern "C" {
|
||||
#define AUDIO_SUPPORT_MIC 1
|
||||
#define AUDIO_SUPPORT_FEEDBACK 1
|
||||
|
||||
#define AUDIO_SUPPORT_FREQ_16K 1
|
||||
#define AUDIO_SUPPORT_FREQ_16K 0
|
||||
#define AUDIO_SUPPORT_FREQ_48K 1
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -71,7 +71,8 @@ static uint32_t hid_set_idle = 0;
|
||||
static uint32_t alt_setting = 0;
|
||||
static uint8_t hid_state;
|
||||
uint8_t hid_set_report[64];
|
||||
|
||||
static __IO uint16_t audio_feedback_state = 0;
|
||||
static __IO uint8_t audio_spk_out_stage = 0;
|
||||
/* usb device class handler */
|
||||
usbd_class_handler audio_hid_class_handler =
|
||||
{
|
||||
@@ -134,8 +135,10 @@ usb_sts_type class_clear_handler(void *udev)
|
||||
/* close in endpoint */
|
||||
usbd_ept_close(pudev, USBD_AUDIO_MIC_IN_EPT);
|
||||
|
||||
#if AUDIO_SUPPORT_FEEDBACK
|
||||
/* close in endpoint */
|
||||
usbd_ept_close(pudev, USBD_AUDIO_FEEDBACK_EPT);
|
||||
#endif
|
||||
|
||||
/* close out endpoint */
|
||||
usbd_ept_close(pudev, USBD_AUDIO_SPK_OUT_EPT);
|
||||
@@ -441,7 +444,6 @@ usb_sts_type class_ept0_rx_handler(void *udev)
|
||||
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;
|
||||
uint32_t len = 0;
|
||||
|
||||
/* ...user code...
|
||||
@@ -450,19 +452,17 @@ usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
|
||||
if((ept_num & 0x7F) == (USBD_AUDIO_MIC_IN_EPT & 0x7F))
|
||||
{
|
||||
len = audio_codec_mic_get_data(audio_struct.audio_mic_data);
|
||||
usb_flush_tx_fifo(pudev->usb_reg, USBD_AUDIO_MIC_IN_EPT & 0x7F);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_MIC_IN_EPT, audio_struct.audio_mic_data, len);
|
||||
usbd_flush_tx_fifo(udev, USBD_AUDIO_MIC_IN_EPT);
|
||||
usbd_ept_send(udev, USBD_AUDIO_MIC_IN_EPT, audio_struct.audio_mic_data, len);
|
||||
}
|
||||
|
||||
else if((ept_num & 0x7F) == (USBD_AUDIO_FEEDBACK_EPT & 0x7F))
|
||||
{
|
||||
len = audio_codec_spk_feedback(audio_struct.audio_feed_back);
|
||||
usb_flush_tx_fifo(pudev->usb_reg, USBD_AUDIO_FEEDBACK_EPT & 0x7F);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, len);
|
||||
audio_feedback_state = 0;
|
||||
}
|
||||
else if((ept_num & 0x7F) == (USBD_HID_IN_EPT & 0x7F))
|
||||
{
|
||||
usb_flush_tx_fifo(pudev->usb_reg, USBD_HID_IN_EPT & 0x7F);
|
||||
usbd_flush_tx_fifo(udev, USBD_HID_IN_EPT);
|
||||
}
|
||||
|
||||
return status;
|
||||
@@ -487,7 +487,7 @@ usb_sts_type class_out_handler(void *udev, uint8_t ept_num)
|
||||
{
|
||||
/* speaker data*/
|
||||
audio_codec_spk_fifo_write(audio_struct.audio_spk_data, g_rxlen);
|
||||
|
||||
audio_spk_out_stage = 1;
|
||||
/* get next data */
|
||||
usbd_ept_recv(pudev, USBD_AUDIO_SPK_OUT_EPT, audio_struct.audio_spk_data, AUDIO_SPK_OUT_MAXPACKET_SIZE);
|
||||
}
|
||||
@@ -511,6 +511,32 @@ usb_sts_type class_sof_handler(void *udev)
|
||||
{
|
||||
usb_sts_type status = USB_OK;
|
||||
|
||||
#if AUDIO_SUPPORT_FEEDBACK
|
||||
if(audio_spk_out_stage & 2)
|
||||
{
|
||||
audio_spk_out_stage = 0;
|
||||
}
|
||||
else if( audio_spk_out_stage )
|
||||
{
|
||||
audio_spk_out_stage |= 2;
|
||||
|
||||
if( 0 == audio_feedback_state )
|
||||
{
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
int len = audio_codec_spk_feedback(audio_struct.audio_feed_back);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, len);
|
||||
audio_feedback_state = 1;
|
||||
}
|
||||
if( audio_feedback_state++ > (1<<FEEDBACK_REFRESH_TIME) ) //timeout
|
||||
{
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
int len = audio_codec_spk_feedback(audio_struct.audio_feed_back);
|
||||
usbd_flush_tx_fifo(pudev, USBD_AUDIO_FEEDBACK_EPT);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, len);
|
||||
audio_feedback_state = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* ...user code... */
|
||||
|
||||
return status;
|
||||
@@ -561,7 +587,7 @@ usb_sts_type class_event_handler(void *udev, usbd_event_type event)
|
||||
*/
|
||||
void audio_inisoincom_event(void *udev)
|
||||
{
|
||||
|
||||
#if 0
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
uint32_t fnsof = OTG_DEVICE(pudev->usb_reg)->dsts_bit.soffn;
|
||||
uint32_t epctl_fb = USB_INEPT(pudev->usb_reg, (USBD_AUDIO_FEEDBACK_EPT&0x7F))->diepctl_bit.dpid;
|
||||
@@ -586,7 +612,7 @@ void audio_inisoincom_event(void *udev)
|
||||
len = audio_codec_mic_get_data(audio_struct.audio_mic_data);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_MIC_IN_EPT, audio_struct.audio_mic_data, len);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -602,22 +628,26 @@ void audio_req_get_cur(void *udev, usb_setup_type *setup)
|
||||
{
|
||||
if(HBYTE(setup->wValue) == AUDIO_MUTE_CONTROL)
|
||||
{
|
||||
usbd_ctrl_send(pudev, &audio_struct.spk_mute, setup->wLength);
|
||||
audio_struct.g_audio_cur[0] = audio_struct.spk_mute;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume, setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(HBYTE(setup->wValue) == AUDIO_MUTE_CONTROL)
|
||||
{
|
||||
usbd_ctrl_send(pudev, &audio_struct.mic_mute, setup->wLength);
|
||||
audio_struct.g_audio_cur[0] = audio_struct.mic_mute;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume, setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume;
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -673,11 +703,13 @@ void audio_req_get_min(void *udev, usb_setup_type *setup)
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
if(HBYTE(setup->wIndex) == AUDIO_SPK_FEATURE_UNIT_ID)
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume_limits[0], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume_limits[0];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume_limits[0], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume_limits[0];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -692,11 +724,13 @@ void audio_req_get_max(void *udev, usb_setup_type *setup)
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
if(HBYTE(setup->wIndex) == AUDIO_SPK_FEATURE_UNIT_ID)
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume_limits[1], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume_limits[1];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume_limits[1], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume_limits[1];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,11 +745,13 @@ void audio_req_get_res(void *udev, usb_setup_type *setup)
|
||||
usbd_core_type *pudev = (usbd_core_type *)udev;
|
||||
if(HBYTE(setup->wIndex) == AUDIO_SPK_FEATURE_UNIT_ID)
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.spk_volume_limits[2], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.spk_volume_limits[2];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
usbd_ctrl_send(pudev, (uint8_t *)&audio_struct.mic_volume_limits[2], setup->wLength);
|
||||
*((uint16_t *)audio_struct.g_audio_cur) = audio_struct.mic_volume_limits[2];
|
||||
usbd_ctrl_send(pudev, audio_struct.g_audio_cur, setup->wLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -736,7 +772,6 @@ void audio_set_interface(void *udev, usb_setup_type *setup)
|
||||
if(audio_struct.spk_alt_setting )
|
||||
{
|
||||
usbd_ept_recv(pudev, USBD_AUDIO_SPK_OUT_EPT, audio_struct.audio_spk_data, AUDIO_SPK_OUT_MAXPACKET_SIZE);
|
||||
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, audio_struct.audio_feed_back, 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio class file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -70,11 +70,11 @@ extern "C" {
|
||||
/**
|
||||
* @brief endpoint support max size
|
||||
*/
|
||||
#define AUDIO_REMAIN_SIZE 8
|
||||
#define AUDIO_REMAIN_SIZE 40
|
||||
#define AUDIO_MIC_IN_MAXPACKET_SIZE (AUDIO_SUPPORT_MAX_FREQ * AUDIO_MIC_CHANEL_NUM * (AUDIO_MIC_DEFAULT_BITW / 8) + AUDIO_REMAIN_SIZE)
|
||||
#define AUDIO_SPK_OUT_MAXPACKET_SIZE (AUDIO_SUPPORT_MAX_FREQ * AUDIO_SPK_CHANEL_NUM * (AUDIO_SPK_DEFAULT_BITW / 8) + AUDIO_REMAIN_SIZE)
|
||||
#define AUDIO_FEEDBACK_MAXPACKET_SIZE 0x3
|
||||
|
||||
#define FEEDBACK_REFRESH_TIME 0x8
|
||||
/**
|
||||
* @brief request type define
|
||||
*/
|
||||
@@ -89,6 +89,17 @@ extern "C" {
|
||||
#define AUDIO_VOLUME_CONTROL 0x02
|
||||
#define AUDIO_FREQ_SET_CONTROL 0x03
|
||||
|
||||
/**
|
||||
* @brief audio descriptor type
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief audio set cur type define
|
||||
*/
|
||||
#define AUDIO_MUTE_CONTROL 0x01
|
||||
#define AUDIO_VOLUME_CONTROL 0x02
|
||||
#define AUDIO_FREQ_SET_CONTROL 0x03
|
||||
|
||||
/**
|
||||
* @brief audio descriptor type
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -78,7 +78,10 @@ usbd_desc_handler audio_hid_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -90,8 +93,13 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
USB_MAX_EP0_SIZE, /* bMaxPacketSize */
|
||||
LBYTE(USBD_VENDOR_ID), /* idVendor */
|
||||
HBYTE(USBD_VENDOR_ID), /* idVendor */
|
||||
#if AUDIO_SUPPORT_FEEDBACK
|
||||
LBYTE(USBD_PRODUCT_ID), /* idProduct */
|
||||
HBYTE(USBD_PRODUCT_ID), /* idProduct */
|
||||
#else
|
||||
LBYTE(USBD_PRODUCT_ID+1), /* idProduct */
|
||||
HBYTE(USBD_PRODUCT_ID+1), /* idProduct */
|
||||
#endif
|
||||
0x00, /* bcdDevice rel. 2.00 */
|
||||
0x02,
|
||||
USB_MFC_STRING, /* Index of manufacturer string */
|
||||
@@ -103,7 +111,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -149,7 +160,7 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
AUDIO_MIC_INPUT_TERMINAL_ID, /* bTerminalID: id of this input terminal*/
|
||||
LBYTE(AUDIO_INPUT_TERMINAL_MICROPHONE),
|
||||
HBYTE(AUDIO_INPUT_TERMINAL_MICROPHONE),/* wTerminalType: terminal is microphone */
|
||||
0x00, /* bAssocTerminal: no association */
|
||||
AUDIO_MIC_OUTPUT_TERMINAL_ID, /* bAssocTerminal: no association */
|
||||
AUDIO_MIC_CHR, /* bNrChannels: two channel */
|
||||
#if (AUDIO_MIC_CHR == 2)
|
||||
0x03, /* wChannelConfig: left front and right front */
|
||||
@@ -177,7 +188,7 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
AUDIO_MIC_OUTPUT_TERMINAL_ID, /* bTerminalID: id of this output terminal*/
|
||||
LBYTE(AUDIO_TERMINAL_TYPE_STREAMING),
|
||||
HBYTE(AUDIO_TERMINAL_TYPE_STREAMING), /* wTerminalType: usb streaming */
|
||||
0x00, /* bAssocTerminal: unused */
|
||||
AUDIO_MIC_INPUT_TERMINAL_ID, /* bAssocTerminal: unused */
|
||||
AUDIO_MIC_FEATURE_UNIT_ID, /* bSourceID: from feature unit terminal */
|
||||
0x00, /* iTerminal: unused */
|
||||
#endif
|
||||
@@ -190,7 +201,7 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
AUDIO_SPK_INPUT_TERMINAL_ID, /* bTerminalID: id of this input terminal*/
|
||||
LBYTE(AUDIO_TERMINAL_TYPE_STREAMING), /* wTerminalType: usb streaming */
|
||||
HBYTE(AUDIO_TERMINAL_TYPE_STREAMING), /* wTerminalType: usb streaming */
|
||||
0x00, /* bAssocTerminal: no association */
|
||||
AUDIO_SPK_OUTPUT_TERMINAL_ID, /* bAssocTerminal: no association */
|
||||
AUDIO_SPK_CHR, /* bNrChannels: two channel */
|
||||
#if (AUDIO_SPK_CHR == 2)
|
||||
0x03, /* wChannelConfig: left front and right front */
|
||||
@@ -218,7 +229,7 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
AUDIO_SPK_OUTPUT_TERMINAL_ID, /* bTerminalID: id of this output terminal*/
|
||||
LBYTE(AUDIO_OUTPUT_TERMINAL_SPEAKER), /* wTerminalType: usb speaker */
|
||||
HBYTE(AUDIO_OUTPUT_TERMINAL_SPEAKER), /* wTerminalType: usb speaker */
|
||||
0x00, /* bAssocTerminal: unused */
|
||||
AUDIO_SPK_INPUT_TERMINAL_ID, /* bAssocTerminal: unused */
|
||||
AUDIO_SPK_FEATURE_UNIT_ID, /* bSourceID: from feature unit terminal */
|
||||
0x00, /* iTerminal: unused */
|
||||
#endif
|
||||
@@ -361,8 +372,8 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
0x11, /* bmAttributes: endpoint attributes */
|
||||
LBYTE(AUDIO_FEEDBACK_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
|
||||
HBYTE(AUDIO_FEEDBACK_MAXPACKET_SIZE), /* wMaxPacketSize: maximum packe size this endpoint */
|
||||
HID_BINTERVAL_TIME, /* bInterval: interval for polling endpoint for data transfers */
|
||||
0x08, /* bRefresh: this field indicates the rate at which an iso syncronization
|
||||
1, /* bInterval: interval for polling endpoint for data transfers */
|
||||
FEEDBACK_REFRESH_TIME, /* bRefresh: this field indicates the rate at which an iso syncronization
|
||||
pipe provides new syncronization feedback data. this rate must be a power of
|
||||
2, therefore only the power is reported back and the range of this field is from
|
||||
1(2ms) to 9(512ms) */
|
||||
@@ -412,7 +423,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb hid report descriptor
|
||||
*/
|
||||
uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
|
||||
{
|
||||
0x06, 0xFF, 0x00, /* USAGE_PAGE(Vendor Page:0xFF00) */
|
||||
0x09, 0x01, /* USAGE (Demo Kit) */
|
||||
@@ -507,7 +521,10 @@ uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
/**
|
||||
* @brief usb hid descriptor
|
||||
*/
|
||||
uint8_t g_hid_usb_desc[9] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
|
||||
{
|
||||
0x09, /* bLength: size of HID descriptor in bytes */
|
||||
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
|
||||
@@ -524,7 +541,10 @@ uint8_t g_hid_usb_desc[9] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -535,7 +555,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb audio descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -51,7 +51,7 @@ extern "C" {
|
||||
#define BCD_NUM 0x0100
|
||||
|
||||
#define USBD_VENDOR_ID 0x2E3C
|
||||
#define USBD_PRODUCT_ID 0x5550
|
||||
#define USBD_PRODUCT_ID 0x5555
|
||||
|
||||
#define USBD_SIZ_STRING_LANGID 4
|
||||
#define USBD_SIZ_STRING_SERIAL 0x1A
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc class file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -78,7 +78,10 @@ usbd_desc_handler desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -103,7 +106,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -188,7 +194,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -199,7 +208,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_keyboard_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc and keyboard class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -66,7 +66,7 @@ static uint8_t g_req;
|
||||
static uint16_t g_len, g_rxlen;
|
||||
__IO uint8_t g_tx_completed = 1, g_rx_completed = 0;
|
||||
|
||||
uint8_t g_keyboard_tx_completed = 0;
|
||||
__IO uint8_t g_keyboard_tx_completed = 0;
|
||||
|
||||
#define SHIFT 0x80
|
||||
const unsigned char _asciimap[128] =
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_keyboard_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc and keyboard class file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -106,7 +106,7 @@ typedef struct
|
||||
* @{
|
||||
*/
|
||||
extern usbd_class_handler cdc_keyboard_class_handler;
|
||||
extern uint8_t g_keyboard_tx_completed;
|
||||
extern __IO uint8_t g_keyboard_tx_completed;
|
||||
uint16_t usb_vcp_get_rxdata(void *udev, uint8_t *recv_data);
|
||||
error_status usb_vcp_send_data(void *udev, uint8_t *send_data, uint16_t len);
|
||||
usb_sts_type class_send_report(void *udev, uint8_t *report, uint16_t len);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_keyboard_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc and keyboard device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -76,7 +76,10 @@ usbd_desc_handler cdc_keyboard_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -101,7 +104,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -232,7 +238,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb hid descriptor
|
||||
*/
|
||||
uint8_t g_hid_usb_desc[9] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
|
||||
{
|
||||
0x09, /* bLength: size of HID descriptor in bytes */
|
||||
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
|
||||
@@ -248,7 +257,10 @@ uint8_t g_hid_usb_desc[9] =
|
||||
/**
|
||||
* @brief usb hid keyboard report descriptor
|
||||
*/
|
||||
uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
|
||||
{
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
0x09, 0x06, // USAGE (Keyboard)
|
||||
@@ -286,7 +298,10 @@ uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -297,7 +312,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file cdc_keyboard_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb cdc and keyboard descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file custom_hid_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb custom hid class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file custom_hid_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file custom_hid_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -77,7 +77,10 @@ usbd_desc_handler hid_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -102,7 +105,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -155,7 +161,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb hid report descriptor
|
||||
*/
|
||||
uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
|
||||
{
|
||||
0x06, 0xFF, 0x00, /* USAGE_PAGE(Vendor Page:0xFF00) */
|
||||
0x09, 0x01, /* USAGE (Demo Kit) */
|
||||
@@ -250,7 +259,10 @@ uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
/**
|
||||
* @brief usb hid descriptor
|
||||
*/
|
||||
uint8_t g_hid_usb_desc[9] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
|
||||
{
|
||||
0x09, /* bLength: size of HID descriptor in bytes */
|
||||
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
|
||||
@@ -267,7 +279,10 @@ uint8_t g_hid_usb_desc[9] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -278,7 +293,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file custom_hid_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb custom hid descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid iap class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid iap header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid iap device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -79,7 +79,10 @@ usbd_desc_handler hid_iap_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -104,7 +107,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -157,7 +163,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb hid report descriptor
|
||||
*/
|
||||
uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
|
||||
{
|
||||
0x06, 0xFF, 0x00, /* USAGE_PAGE(Vendor Page:0xFF00) */
|
||||
0x09, 0x01, /* USAGE (Demo Kit) */
|
||||
@@ -185,7 +194,10 @@ uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
/**
|
||||
* @brief usb hid descriptor
|
||||
*/
|
||||
uint8_t g_hid_usb_desc[9] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
|
||||
{
|
||||
0x09, /* bLength: size of HID descriptor in bytes */
|
||||
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
|
||||
@@ -202,7 +214,10 @@ uint8_t g_hid_usb_desc[9] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -213,7 +228,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file hid_iap_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid iap descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file keyboard_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid keyboard class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -56,8 +56,8 @@ static uint32_t hid_set_idle = 0;
|
||||
static uint32_t alt_setting = 0;
|
||||
static uint8_t hid_state;
|
||||
uint8_t hid_set_report[64];
|
||||
uint8_t hid_suspend_flag = 0;
|
||||
uint8_t g_u8tx_completed = 0;
|
||||
__IO uint8_t hid_suspend_flag = 0;
|
||||
__IO uint8_t g_u8tx_completed = 0;
|
||||
|
||||
#define SHIFT 0x80
|
||||
const unsigned char _asciimap[128] =
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file keyboard_class.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid keyboard header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -86,7 +86,7 @@ extern "C" {
|
||||
* @{
|
||||
*/
|
||||
extern usbd_class_handler keyboard_class_handler;
|
||||
extern uint8_t g_u8tx_completed;
|
||||
extern __IO uint8_t g_u8tx_completed;
|
||||
|
||||
usb_sts_type class_send_report(void *udev, uint8_t *report, uint16_t len);
|
||||
void usb_hid_keyboard_send_char(void *udev, uint8_t ascii_code);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file keyboard_desc.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid keyboard device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -77,7 +77,10 @@ usbd_desc_handler keyboard_desc_handler =
|
||||
/**
|
||||
* @brief usb device standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_DESC_LEN, /* bLength */
|
||||
USB_DESCIPTOR_TYPE_DEVICE, /* bDescriptorType */
|
||||
@@ -102,7 +105,10 @@ uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN] =
|
||||
/**
|
||||
* @brief usb configuration standard descriptor
|
||||
*/
|
||||
uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] ALIGNED_TAIL =
|
||||
{
|
||||
USB_DEVICE_CFG_DESC_LEN, /* bLength: configuration descriptor size */
|
||||
USB_DESCIPTOR_TYPE_CONFIGURATION, /* bDescriptorType: configuration */
|
||||
@@ -147,7 +153,10 @@ uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE] =
|
||||
/**
|
||||
* @brief usb mouse report descriptor
|
||||
*/
|
||||
uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] ALIGNED_TAIL =
|
||||
{
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
0x09, 0x06, // USAGE (Keyboard)
|
||||
@@ -186,7 +195,10 @@ uint8_t g_usbd_hid_report[USBD_HID_SIZ_REPORT_DESC] =
|
||||
/**
|
||||
* @brief usb hid descriptor
|
||||
*/
|
||||
uint8_t g_hid_usb_desc[9] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_hid_usb_desc[9] ALIGNED_TAIL =
|
||||
{
|
||||
0x09, /* bLength: size of HID descriptor in bytes */
|
||||
HID_CLASS_DESC_HID, /* bDescriptorType: HID descriptor type */
|
||||
@@ -203,7 +215,10 @@ uint8_t g_hid_usb_desc[9] =
|
||||
/**
|
||||
* @brief usb string lang id
|
||||
*/
|
||||
uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_LANGID,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
@@ -214,7 +229,10 @@ uint8_t g_string_lang_id[USBD_SIZ_STRING_LANGID] =
|
||||
/**
|
||||
* @brief usb string serial
|
||||
*/
|
||||
uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] =
|
||||
#if defined ( __ICCARM__ ) /* iar compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
ALIGNED_HEAD uint8_t g_string_serial[USBD_SIZ_STRING_SERIAL] ALIGNED_TAIL =
|
||||
{
|
||||
USBD_SIZ_STRING_SERIAL,
|
||||
USB_DESCIPTOR_TYPE_STRING,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file keyboard_desc.h
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb keyboard descriptor header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file mouse_class.c
|
||||
* @version v2.0.0
|
||||
* @date 2021-11-26
|
||||
* @version v2.0.2
|
||||
* @date 2021-12-31
|
||||
* @brief usb hid mouse class type
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -55,7 +55,7 @@ static uint32_t hid_protocol = 0;
|
||||
static uint32_t hid_set_idle = 0;
|
||||
static uint32_t alt_setting = 0;
|
||||
static uint8_t hid_state;
|
||||
uint8_t hid_suspend_flag = 0;
|
||||
__IO uint8_t hid_suspend_flag = 0;
|
||||
uint8_t hid_set_report[64];
|
||||
|
||||
/* usb device class handler */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user