mirror of
https://github.com/STMicroelectronics/stm32-mw-usb-device.git
synced 2026-02-08 20:18:07 -05:00
Release v2.10.0
This commit is contained in:
@@ -57,7 +57,10 @@ extern "C" {
|
||||
#define AUDIO_FS_BINTERVAL 0x01U
|
||||
#endif /* AUDIO_FS_BINTERVAL */
|
||||
|
||||
#ifndef AUDIO_OUT_EP
|
||||
#define AUDIO_OUT_EP 0x01U
|
||||
#endif /* AUDIO_OUT_EP */
|
||||
|
||||
#define USB_AUDIO_CONFIG_DESC_SIZ 0x6DU
|
||||
#define AUDIO_INTERFACE_DESC_SIZE 0x09U
|
||||
#define USB_AUDIO_DESC_SIZ 0x09U
|
||||
@@ -166,6 +169,115 @@ typedef struct
|
||||
int8_t (*PeriodicTC)(uint8_t *pbuf, uint32_t size, uint8_t cmd);
|
||||
int8_t (*GetState)(void);
|
||||
} USBD_AUDIO_ItfTypeDef;
|
||||
|
||||
/*
|
||||
* Audio Class specification release 1.0
|
||||
*/
|
||||
|
||||
/* Table 4-2: Class-Specific AC Interface Header Descriptor */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubtype;
|
||||
uint16_t bcdADC;
|
||||
uint16_t wTotalLength;
|
||||
uint8_t bInCollection;
|
||||
uint8_t baInterfaceNr;
|
||||
} __PACKED USBD_SpeakerIfDescTypeDef;
|
||||
|
||||
/* Table 4-3: Input Terminal Descriptor */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubtype;
|
||||
uint8_t bTerminalID;
|
||||
uint16_t wTerminalType;
|
||||
uint8_t bAssocTerminal;
|
||||
uint8_t bNrChannels;
|
||||
uint16_t wChannelConfig;
|
||||
uint8_t iChannelNames;
|
||||
uint8_t iTerminal;
|
||||
} __PACKED USBD_SpeakerInDescTypeDef;
|
||||
|
||||
/* USB Speaker Audio Feature Unit Descriptor */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubtype;
|
||||
uint8_t bUnitID;
|
||||
uint8_t bSourceID;
|
||||
uint8_t bControlSize;
|
||||
uint16_t bmaControls;
|
||||
uint8_t iTerminal;
|
||||
} __PACKED USBD_SpeakerFeatureDescTypeDef;
|
||||
|
||||
/* Table 4-4: Output Terminal Descriptor */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubtype;
|
||||
uint8_t bTerminalID;
|
||||
uint16_t wTerminalType;
|
||||
uint8_t bAssocTerminal;
|
||||
uint8_t bSourceID;
|
||||
uint8_t iTerminal;
|
||||
} __PACKED USBD_SpeakerOutDescTypeDef;
|
||||
|
||||
/* Table 4-19: Class-Specific AS Interface Descriptor */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubtype;
|
||||
uint8_t bTerminalLink;
|
||||
uint8_t bDelay;
|
||||
uint16_t wFormatTag;
|
||||
} __PACKED USBD_SpeakerStreamIfDescTypeDef;
|
||||
|
||||
/* USB Speaker Audio Type III Format Interface Descriptor */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubtype;
|
||||
uint8_t bFormatType;
|
||||
uint8_t bNrChannels;
|
||||
uint8_t bSubFrameSize;
|
||||
uint8_t bBitResolution;
|
||||
uint8_t bSamFreqType;
|
||||
uint8_t tSamFreq2;
|
||||
uint8_t tSamFreq1;
|
||||
uint8_t tSamFreq0;
|
||||
} USBD_SpeakerIIIFormatIfDescTypeDef;
|
||||
|
||||
/* Table 4-17: Standard AC Interrupt Endpoint Descriptor */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bEndpointAddress;
|
||||
uint8_t bmAttributes;
|
||||
uint16_t wMaxPacketSize;
|
||||
uint8_t bInterval;
|
||||
uint8_t bRefresh;
|
||||
uint8_t bSynchAddress;
|
||||
} __PACKED USBD_SpeakerEndDescTypeDef;
|
||||
|
||||
/* Table 4-21: Class-Specific AS Isochronous Audio Data Endpoint Descriptor */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptor;
|
||||
uint8_t bmAttributes;
|
||||
uint8_t bLockDelayUnits;
|
||||
uint16_t wLockDelay;
|
||||
} __PACKED USBD_SpeakerEndStDescTypeDef;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -197,6 +309,11 @@ uint8_t USBD_AUDIO_RegisterInterface(USBD_HandleTypeDef *pdev,
|
||||
USBD_AUDIO_ItfTypeDef *fops);
|
||||
|
||||
void USBD_AUDIO_Sync(USBD_HandleTypeDef *pdev, AUDIO_OffsetTypeDef offset);
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
uint32_t USBD_AUDIO_GetEpPcktSze(USBD_HandleTypeDef *pdev, uint8_t If, uint8_t Ep);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -99,6 +99,9 @@ EndBSPDependencies */
|
||||
#define AUDIO_PACKET_SZE(frq) \
|
||||
(uint8_t)(((frq * 2U * 2U) / 1000U) & 0xFFU), (uint8_t)((((frq * 2U * 2U) / 1000U) >> 8) & 0xFFU)
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
#define AUDIO_PACKET_SZE_WORD(frq) (uint32_t)((((frq) * 2U * 2U)/1000U))
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -112,9 +115,10 @@ static uint8_t USBD_AUDIO_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
|
||||
|
||||
static uint8_t USBD_AUDIO_Setup(USBD_HandleTypeDef *pdev,
|
||||
USBD_SetupReqTypedef *req);
|
||||
|
||||
#ifndef USE_USBD_COMPOSITE
|
||||
static uint8_t *USBD_AUDIO_GetCfgDesc(uint16_t *length);
|
||||
static uint8_t *USBD_AUDIO_GetDeviceQualifierDesc(uint16_t *length);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
static uint8_t USBD_AUDIO_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
static uint8_t USBD_AUDIO_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
static uint8_t USBD_AUDIO_EP0_RxReady(USBD_HandleTypeDef *pdev);
|
||||
@@ -125,6 +129,7 @@ static uint8_t USBD_AUDIO_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnu
|
||||
static uint8_t USBD_AUDIO_IsoOutIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
|
||||
static void AUDIO_REQ_SetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
|
||||
static void *USBD_AUDIO_GetAudioHeaderDesc(uint8_t *pConfDesc);
|
||||
|
||||
/**
|
||||
* @}
|
||||
@@ -146,12 +151,20 @@ USBD_ClassTypeDef USBD_AUDIO =
|
||||
USBD_AUDIO_SOF,
|
||||
USBD_AUDIO_IsoINIncomplete,
|
||||
USBD_AUDIO_IsoOutIncomplete,
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
#else
|
||||
USBD_AUDIO_GetCfgDesc,
|
||||
USBD_AUDIO_GetCfgDesc,
|
||||
USBD_AUDIO_GetCfgDesc,
|
||||
USBD_AUDIO_GetDeviceQualifierDesc,
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
};
|
||||
|
||||
#ifndef USE_USBD_COMPOSITE
|
||||
/* USB AUDIO device Configuration Descriptor */
|
||||
__ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALIGN_END =
|
||||
{
|
||||
@@ -167,7 +180,7 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALI
|
||||
0xC0, /* bmAttributes: Bus Powered according to user configuration */
|
||||
#else
|
||||
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||
#endif
|
||||
#endif /* USBD_SELF_POWERED */
|
||||
USBD_MAX_POWER, /* MaxPower (mA) */
|
||||
/* 09 byte*/
|
||||
|
||||
@@ -318,7 +331,9 @@ __ALIGN_BEGIN static uint8_t USBD_AUDIO_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIE
|
||||
0x01,
|
||||
0x00,
|
||||
};
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
static uint8_t AUDIOOutEpAdd = AUDIO_OUT_EP;
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -344,24 +359,30 @@ static uint8_t USBD_AUDIO_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||
|
||||
if (haudio == NULL)
|
||||
{
|
||||
pdev->pClassData = NULL;
|
||||
pdev->pClassDataCmsit[pdev->classId] = NULL;
|
||||
return (uint8_t)USBD_EMEM;
|
||||
}
|
||||
|
||||
pdev->pClassData = (void *)haudio;
|
||||
pdev->pClassDataCmsit[pdev->classId] = (void *)haudio;
|
||||
pdev->pClassData = pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
/* Get the Endpoints addresses allocated for this class instance */
|
||||
AUDIOOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_ISOC);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||
{
|
||||
pdev->ep_out[AUDIO_OUT_EP & 0xFU].bInterval = AUDIO_HS_BINTERVAL;
|
||||
pdev->ep_out[AUDIOOutEpAdd & 0xFU].bInterval = AUDIO_HS_BINTERVAL;
|
||||
}
|
||||
else /* LOW and FULL-speed endpoints */
|
||||
{
|
||||
pdev->ep_out[AUDIO_OUT_EP & 0xFU].bInterval = AUDIO_FS_BINTERVAL;
|
||||
pdev->ep_out[AUDIOOutEpAdd & 0xFU].bInterval = AUDIO_FS_BINTERVAL;
|
||||
}
|
||||
|
||||
/* Open EP OUT */
|
||||
(void)USBD_LL_OpenEP(pdev, AUDIO_OUT_EP, USBD_EP_TYPE_ISOC, AUDIO_OUT_PACKET);
|
||||
pdev->ep_out[AUDIO_OUT_EP & 0xFU].is_used = 1U;
|
||||
(void)USBD_LL_OpenEP(pdev, AUDIOOutEpAdd, USBD_EP_TYPE_ISOC, AUDIO_OUT_PACKET);
|
||||
pdev->ep_out[AUDIOOutEpAdd & 0xFU].is_used = 1U;
|
||||
|
||||
haudio->alt_setting = 0U;
|
||||
haudio->offset = AUDIO_OFFSET_UNKNOWN;
|
||||
@@ -370,15 +391,15 @@ static uint8_t USBD_AUDIO_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||
haudio->rd_enable = 0U;
|
||||
|
||||
/* Initialize the Audio output Hardware layer */
|
||||
if (((USBD_AUDIO_ItfTypeDef *)pdev->pUserData)->Init(USBD_AUDIO_FREQ,
|
||||
AUDIO_DEFAULT_VOLUME,
|
||||
0U) != 0U)
|
||||
if (((USBD_AUDIO_ItfTypeDef *)pdev->pUserData[pdev->classId])->Init(USBD_AUDIO_FREQ,
|
||||
AUDIO_DEFAULT_VOLUME,
|
||||
0U) != 0U)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
/* Prepare Out endpoint to receive 1st packet */
|
||||
(void)USBD_LL_PrepareReceive(pdev, AUDIO_OUT_EP, haudio->buffer,
|
||||
(void)USBD_LL_PrepareReceive(pdev, AUDIOOutEpAdd, haudio->buffer,
|
||||
AUDIO_OUT_PACKET);
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
@@ -395,16 +416,22 @@ static uint8_t USBD_AUDIO_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||
{
|
||||
UNUSED(cfgidx);
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
/* Get the Endpoints addresses allocated for this class instance */
|
||||
AUDIOOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_ISOC);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
/* Open EP OUT */
|
||||
(void)USBD_LL_CloseEP(pdev, AUDIO_OUT_EP);
|
||||
pdev->ep_out[AUDIO_OUT_EP & 0xFU].is_used = 0U;
|
||||
pdev->ep_out[AUDIO_OUT_EP & 0xFU].bInterval = 0U;
|
||||
(void)USBD_LL_CloseEP(pdev, AUDIOOutEpAdd);
|
||||
pdev->ep_out[AUDIOOutEpAdd & 0xFU].is_used = 0U;
|
||||
pdev->ep_out[AUDIOOutEpAdd & 0xFU].bInterval = 0U;
|
||||
|
||||
/* DeInit physical Interface components */
|
||||
if (pdev->pClassData != NULL)
|
||||
if (pdev->pClassDataCmsit[pdev->classId] != NULL)
|
||||
{
|
||||
((USBD_AUDIO_ItfTypeDef *)pdev->pUserData)->DeInit(0U);
|
||||
(void)USBD_free(pdev->pClassData);
|
||||
((USBD_AUDIO_ItfTypeDef *)pdev->pUserData[pdev->classId])->DeInit(0U);
|
||||
(void)USBD_free(pdev->pClassDataCmsit[pdev->classId]);
|
||||
pdev->pClassDataCmsit[pdev->classId] = NULL;
|
||||
pdev->pClassData = NULL;
|
||||
}
|
||||
|
||||
@@ -427,7 +454,7 @@ static uint8_t USBD_AUDIO_Setup(USBD_HandleTypeDef *pdev,
|
||||
uint16_t status_info = 0U;
|
||||
USBD_StatusTypeDef ret = USBD_OK;
|
||||
|
||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassData;
|
||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
if (haudio == NULL)
|
||||
{
|
||||
@@ -472,10 +499,17 @@ static uint8_t USBD_AUDIO_Setup(USBD_HandleTypeDef *pdev,
|
||||
case USB_REQ_GET_DESCRIPTOR:
|
||||
if ((req->wValue >> 8) == AUDIO_DESCRIPTOR_TYPE)
|
||||
{
|
||||
pbuf = USBD_AUDIO_CfgDesc + 18;
|
||||
len = MIN(USB_AUDIO_DESC_SIZ, req->wLength);
|
||||
|
||||
(void)USBD_CtlSendData(pdev, pbuf, len);
|
||||
pbuf = (uint8_t *)USBD_AUDIO_GetAudioHeaderDesc(pdev->pConfDesc);
|
||||
if (pbuf != NULL)
|
||||
{
|
||||
len = MIN(USB_AUDIO_DESC_SIZ, req->wLength);
|
||||
(void)USBD_CtlSendData(pdev, pbuf, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
USBD_CtlError(pdev, req);
|
||||
ret = USBD_FAIL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -530,7 +564,7 @@ static uint8_t USBD_AUDIO_Setup(USBD_HandleTypeDef *pdev,
|
||||
return (uint8_t)ret;
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_USBD_COMPOSITE
|
||||
/**
|
||||
* @brief USBD_AUDIO_GetCfgDesc
|
||||
* return configuration descriptor
|
||||
@@ -543,7 +577,7 @@ static uint8_t *USBD_AUDIO_GetCfgDesc(uint16_t *length)
|
||||
|
||||
return USBD_AUDIO_CfgDesc;
|
||||
}
|
||||
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
/**
|
||||
* @brief USBD_AUDIO_DataIn
|
||||
* handle data IN Stage
|
||||
@@ -569,7 +603,7 @@ static uint8_t USBD_AUDIO_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
static uint8_t USBD_AUDIO_EP0_RxReady(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_AUDIO_HandleTypeDef *haudio;
|
||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassData;
|
||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
if (haudio == NULL)
|
||||
{
|
||||
@@ -582,7 +616,7 @@ static uint8_t USBD_AUDIO_EP0_RxReady(USBD_HandleTypeDef *pdev)
|
||||
|
||||
if (haudio->control.unit == AUDIO_OUT_STREAMING_CTRL)
|
||||
{
|
||||
((USBD_AUDIO_ItfTypeDef *)pdev->pUserData)->MuteCtl(haudio->control.data[0]);
|
||||
((USBD_AUDIO_ItfTypeDef *)pdev->pUserData[pdev->classId])->MuteCtl(haudio->control.data[0]);
|
||||
haudio->control.cmd = 0U;
|
||||
haudio->control.len = 0U;
|
||||
}
|
||||
@@ -628,12 +662,12 @@ void USBD_AUDIO_Sync(USBD_HandleTypeDef *pdev, AUDIO_OffsetTypeDef offset)
|
||||
USBD_AUDIO_HandleTypeDef *haudio;
|
||||
uint32_t BufferSize = AUDIO_TOTAL_BUF_SIZE / 2U;
|
||||
|
||||
if (pdev->pClassData == NULL)
|
||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassData;
|
||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
haudio->offset = offset;
|
||||
|
||||
@@ -679,8 +713,8 @@ void USBD_AUDIO_Sync(USBD_HandleTypeDef *pdev, AUDIO_OffsetTypeDef offset)
|
||||
|
||||
if (haudio->offset == AUDIO_OFFSET_FULL)
|
||||
{
|
||||
((USBD_AUDIO_ItfTypeDef *)pdev->pUserData)->AudioCmd(&haudio->buffer[0],
|
||||
BufferSize, AUDIO_CMD_PLAY);
|
||||
((USBD_AUDIO_ItfTypeDef *)pdev->pUserData[pdev->classId])->AudioCmd(&haudio->buffer[0],
|
||||
BufferSize, AUDIO_CMD_PLAY);
|
||||
haudio->offset = AUDIO_OFFSET_NONE;
|
||||
}
|
||||
}
|
||||
@@ -725,21 +759,26 @@ static uint8_t USBD_AUDIO_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
uint16_t PacketSize;
|
||||
USBD_AUDIO_HandleTypeDef *haudio;
|
||||
|
||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassData;
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
/* Get the Endpoints addresses allocated for this class instance */
|
||||
AUDIOOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_ISOC);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
if (haudio == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
if (epnum == AUDIO_OUT_EP)
|
||||
if (epnum == AUDIOOutEpAdd)
|
||||
{
|
||||
/* Get received data packet length */
|
||||
PacketSize = (uint16_t)USBD_LL_GetRxDataSize(pdev, epnum);
|
||||
|
||||
/* Packet received Callback */
|
||||
((USBD_AUDIO_ItfTypeDef *)pdev->pUserData)->PeriodicTC(&haudio->buffer[haudio->wr_ptr],
|
||||
PacketSize, AUDIO_OUT_TC);
|
||||
((USBD_AUDIO_ItfTypeDef *)pdev->pUserData[pdev->classId])->PeriodicTC(&haudio->buffer[haudio->wr_ptr],
|
||||
PacketSize, AUDIO_OUT_TC);
|
||||
|
||||
/* Increment the Buffer pointer or roll it back when all buffers are full */
|
||||
haudio->wr_ptr += PacketSize;
|
||||
@@ -751,9 +790,9 @@ static uint8_t USBD_AUDIO_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
|
||||
if (haudio->offset == AUDIO_OFFSET_UNKNOWN)
|
||||
{
|
||||
((USBD_AUDIO_ItfTypeDef *)pdev->pUserData)->AudioCmd(&haudio->buffer[0],
|
||||
AUDIO_TOTAL_BUF_SIZE / 2U,
|
||||
AUDIO_CMD_START);
|
||||
((USBD_AUDIO_ItfTypeDef *)pdev->pUserData[pdev->classId])->AudioCmd(&haudio->buffer[0],
|
||||
AUDIO_TOTAL_BUF_SIZE / 2U,
|
||||
AUDIO_CMD_START);
|
||||
haudio->offset = AUDIO_OFFSET_NONE;
|
||||
}
|
||||
}
|
||||
@@ -767,7 +806,7 @@ static uint8_t USBD_AUDIO_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
}
|
||||
|
||||
/* Prepare Out endpoint to receive next audio packet */
|
||||
(void)USBD_LL_PrepareReceive(pdev, AUDIO_OUT_EP,
|
||||
(void)USBD_LL_PrepareReceive(pdev, AUDIOOutEpAdd,
|
||||
&haudio->buffer[haudio->wr_ptr],
|
||||
AUDIO_OUT_PACKET);
|
||||
}
|
||||
@@ -785,7 +824,7 @@ static uint8_t USBD_AUDIO_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||
{
|
||||
USBD_AUDIO_HandleTypeDef *haudio;
|
||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassData;
|
||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
if (haudio == NULL)
|
||||
{
|
||||
@@ -809,7 +848,7 @@ static void AUDIO_REQ_GetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
|
||||
static void AUDIO_REQ_SetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||
{
|
||||
USBD_AUDIO_HandleTypeDef *haudio;
|
||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassData;
|
||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
if (haudio == NULL)
|
||||
{
|
||||
@@ -827,7 +866,7 @@ static void AUDIO_REQ_SetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_USBD_COMPOSITE
|
||||
/**
|
||||
* @brief DeviceQualifierDescriptor
|
||||
* return Device Qualifier descriptor
|
||||
@@ -840,7 +879,7 @@ static uint8_t *USBD_AUDIO_GetDeviceQualifierDesc(uint16_t *length)
|
||||
|
||||
return USBD_AUDIO_DeviceQualifierDesc;
|
||||
}
|
||||
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
/**
|
||||
* @brief USBD_AUDIO_RegisterInterface
|
||||
* @param pdev: device instance
|
||||
@@ -855,10 +894,66 @@ uint8_t USBD_AUDIO_RegisterInterface(USBD_HandleTypeDef *pdev,
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
pdev->pUserData = fops;
|
||||
pdev->pUserData[pdev->classId] = fops;
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
/**
|
||||
* @brief USBD_AUDIO_GetEpPcktSze
|
||||
* @param pdev: device instance (reserved for future use)
|
||||
* @param If: Interface number (reserved for future use)
|
||||
* @param Ep: Endpoint number (reserved for future use)
|
||||
* @retval status
|
||||
*/
|
||||
uint32_t USBD_AUDIO_GetEpPcktSze(USBD_HandleTypeDef *pdev, uint8_t If, uint8_t Ep)
|
||||
{
|
||||
uint32_t mps;
|
||||
|
||||
UNUSED(pdev);
|
||||
UNUSED(If);
|
||||
UNUSED(Ep);
|
||||
|
||||
mps = AUDIO_PACKET_SZE_WORD(USBD_AUDIO_FREQ);
|
||||
|
||||
/* Return the wMaxPacketSize value in Bytes (Freq(Samples)*2(Stereo)*2(HalfWord)) */
|
||||
return mps;
|
||||
}
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
/**
|
||||
* @brief USBD_AUDIO_GetAudioHeaderDesc
|
||||
* This function return the Audio descriptor
|
||||
* @param pdev: device instance
|
||||
* @param pConfDesc: pointer to Bos descriptor
|
||||
* @retval pointer to the Audio AC Header descriptor
|
||||
*/
|
||||
static void *USBD_AUDIO_GetAudioHeaderDesc(uint8_t *pConfDesc)
|
||||
{
|
||||
USBD_ConfigDescTypeDef *desc = (USBD_ConfigDescTypeDef *)(void *)pConfDesc;
|
||||
USBD_DescHeaderTypeDef *pdesc = (USBD_DescHeaderTypeDef *)(void *)pConfDesc;
|
||||
uint8_t *pAudioDesc = NULL;
|
||||
uint16_t ptr;
|
||||
|
||||
if (desc->wTotalLength > desc->bLength)
|
||||
{
|
||||
ptr = desc->bLength;
|
||||
|
||||
while (ptr < desc->wTotalLength)
|
||||
{
|
||||
pdesc = USBD_GetNextDesc((uint8_t *)pdesc, &ptr);
|
||||
if ((pdesc->bDescriptorType == AUDIO_INTERFACE_DESCRIPTOR_TYPE) &&
|
||||
(pdesc->bDescriptorSubType == AUDIO_CONTROL_HEADER))
|
||||
{
|
||||
pAudioDesc = (uint8_t *)pdesc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pAudioDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user