库文件的修改:
usbd_audio.h
#define AUDIO_IN_EP 0x82
#define USB_AUDIO_CONFIG_DESC_SIZ (0xC0+32)//109
#define AUDIO_OUT_PACKET_NUM 2//80
usbd_audio.c
#include "usbd_hid.h"
uint8_t HID_OEP4_RX[64] = {0};
static uint8_t USBD_AUDIO_HID_Setup (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
USBD_AUDIO_HID_Setup,//USBD_AUDIO_Setup,
0x04, /* bNumInterfaces */
static uint8_t USBD_AUDIO_Init (USBD_HandleTypeDef *pdev,
uint8_t cfgidx)
USBD_LL_PrepareReceive(pdev,
AUDIO_OUT_EP,
haudio->buffer,
AUDIO_OUT_PACKET);
/*Prepare Out endpoint to receive 1st packet*/
USBD_LL_PrepareReceive(pdev,
CUSTOM_HID_EPOUT_ADDR,
HID_OEP4_RX,
CUSTOM_HID_EPOUT_SIZE);
static uint8_t USBD_AUDIO_DeInit (USBD_HandleTypeDef *pdev,
uint8_t cfgidx)
static uint8_t USBD_AUDIO_HID_Setup (USBD_HandleTypeDef *pdev,
USBD_SetupReqTypedef *req)
usbd_hid.c
__ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] __ALIGN_END =
__ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] __ALIGN_END =
{
// 0x05, 0x01,
// 0x09, 0x02,
// 0xA1, 0x01,
// 0x09, 0x01,
//
// 0xA1, 0x00,
// 0x05, 0x09,
// 0x19, 0x01,
// 0x29, 0x03,
//
// 0x15, 0x00,
// 0x25, 0x01,
// 0x95, 0x03,
// 0x75, 0x01,
//
// 0x81, 0x02,
// 0x95, 0x01,
// 0x75, 0x05,
// 0x81, 0x01,
//
// 0x05, 0x01,
// 0x09, 0x30,
// 0x09, 0x31,
// 0x09, 0x38,
//
// 0x15, 0x81,
// 0x25, 0x7F,
// 0x75, 0x08,
// 0x95, 0x03,
//
// 0x81, 0x06,
// 0xC0, 0x09,
// 0x3c, 0x05,
// 0xff, 0x09,
//
// 0x01, 0x15,
// 0x00, 0x25,
// 0x01, 0x75,
// 0x01, 0x95,
//
// 0x02, 0xb1,
// 0x22, 0x75,
// 0x06, 0x95,
// 0x01, 0xb1,
//
// 0x01, 0xc0
/* USER CODE BEGIN 0 */
0x05, 0x8c, /* USAGE_PAGE (ST Page) */
0x09, 0x01, /* USAGE (Demo Kit) */
0xa1, 0x01, /* COLLECTION (Application) */
// The Input report
0x09,0x03, // USAGE ID - Vendor defined
0x15,0x00, // LOGICAL_MINIMUM (0)
0x26,0x00, 0xFF, // LOGICAL_MAXIMUM (255)
0x75,0x08, // REPORT_SIZE (8bit)
0x95,0x40, // REPORT_COUNT (64Byte)
0x81,0x02, // INPUT (Data,Var,Abs)
// The Output report
0x09,0x04, // USAGE ID - Vendor defined
0x15,0x00, // LOGICAL_MINIMUM (0)
0x26,0x00,0xFF, // LOGICAL_MAXIMUM (255)
0x75,0x08, // REPORT_SIZE (8bit)
0x95,0x40, // REPORT_COUNT (64Byte)
0x91,0x02, // OUTPUT (Data,Var,Abs)
/* USER CODE END 0 */
0xC0 /* END_COLLECTION */
};
usbd_conf.h usbd_conf.c
// HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_HS, 0x200);
// HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x80);
// HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 1, 0x174);
HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_HS, 0x160); //all out endpoints
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x60); //control endpoint
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 2, 0x160); //audio in endpoint
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 3, 0xA0); //hid in endpoint
#define USBD_MAX_NUM_INTERFACES 4
#define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE 2
/*---------- -----------*/
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 33