forked from stm/stm32-mw-usb-device
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b06460a43 | ||
|
|
7b5e6886d2 | ||
|
|
bd79085c18 | ||
|
|
dccc30a45a | ||
|
|
2022e75b01 | ||
|
|
555ce2b1f7 |
@@ -368,7 +368,7 @@ static uint8_t USBD_AUDIO_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
AUDIOOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_ISOC);
|
AUDIOOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||||
@@ -418,7 +418,7 @@ static uint8_t USBD_AUDIO_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
AUDIOOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_ISOC);
|
AUDIOOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Open EP OUT */
|
/* Open EP OUT */
|
||||||
@@ -742,8 +742,19 @@ 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 uint8_t USBD_AUDIO_IsoOutIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||||
{
|
{
|
||||||
UNUSED(pdev);
|
USBD_AUDIO_HandleTypeDef *haudio;
|
||||||
UNUSED(epnum);
|
|
||||||
|
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||||
|
{
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
|
||||||
|
/* Prepare Out endpoint to receive next audio packet */
|
||||||
|
(void)USBD_LL_PrepareReceive(pdev, epnum,
|
||||||
|
&haudio->buffer[haudio->wr_ptr],
|
||||||
|
AUDIO_OUT_PACKET);
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
@@ -761,7 +772,7 @@ static uint8_t USBD_AUDIO_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
AUDIOOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_ISOC);
|
AUDIOOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
haudio = (USBD_AUDIO_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
@@ -783,7 +794,7 @@ static uint8_t USBD_AUDIO_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
/* Increment the Buffer pointer or roll it back when all buffers are full */
|
/* Increment the Buffer pointer or roll it back when all buffers are full */
|
||||||
haudio->wr_ptr += PacketSize;
|
haudio->wr_ptr += PacketSize;
|
||||||
|
|
||||||
if (haudio->wr_ptr == AUDIO_TOTAL_BUF_SIZE)
|
if (haudio->wr_ptr >= AUDIO_TOTAL_BUF_SIZE)
|
||||||
{
|
{
|
||||||
/* All buffers are full: roll back */
|
/* All buffers are full: roll back */
|
||||||
haudio->wr_ptr = 0U;
|
haudio->wr_ptr = 0U;
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ typedef struct
|
|||||||
} USBD_CCID_ParamTypeDef;
|
} USBD_CCID_ParamTypeDef;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CCID Class specification revsion 1.1
|
* CCID Class specification revision 1.1
|
||||||
* Smart Card Device Class Descriptor Table
|
* Smart Card Device Class Descriptor Table
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ extern "C" {
|
|||||||
an unimplemented slot, then the Slot Error register shall be set to 5 (index of bSlot field) */
|
an unimplemented slot, then the Slot Error register shall be set to 5 (index of bSlot field) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CCID Class specification revsion 1.1
|
* CCID Class specification revision 1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Following Parameters used in PC_to_RDR_XfrBlock */
|
/* Following Parameters used in PC_to_RDR_XfrBlock */
|
||||||
|
|||||||
@@ -289,9 +289,9 @@ static uint8_t USBD_CCID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
CCIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
CCIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
CCIDOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
CCIDOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
CCIDCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
CCIDCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Init the CCID parameters into a state where it can receive a new command message */
|
/* Init the CCID parameters into a state where it can receive a new command message */
|
||||||
@@ -337,9 +337,9 @@ static uint8_t USBD_CCID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
CCIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
CCIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
CCIDOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
CCIDOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
CCIDCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
CCIDCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Close EP IN */
|
/* Close EP IN */
|
||||||
@@ -474,8 +474,8 @@ static uint8_t USBD_CCID_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
CCIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
CCIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
CCIDCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
CCIDCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (epnum == (CCIDInEpAdd & 0x7FU))
|
if (epnum == (CCIDInEpAdd & 0x7FU))
|
||||||
@@ -530,7 +530,7 @@ static uint8_t USBD_CCID_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
CCIDOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
CCIDOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hccid == NULL)
|
if (hccid == NULL)
|
||||||
@@ -816,7 +816,7 @@ uint8_t USBD_CCID_IntMessage(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
CCIDCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
CCIDCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Check if there is change in Smartcard Slot status */
|
/* Check if there is change in Smartcard Slot status */
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ static void SC_SendData(SC_ADPU_CommandsTypeDef *SCADPU, SC_ADPU_ResponseTypeDef
|
|||||||
*/
|
*/
|
||||||
void SC_Handler(SC_State *SCState, SC_ADPU_CommandsTypeDef *SC_ADPU, SC_ADPU_ResponseTypeDef *SC_Response)
|
void SC_Handler(SC_State *SCState, SC_ADPU_CommandsTypeDef *SC_ADPU, SC_ADPU_ResponseTypeDef *SC_Response)
|
||||||
{
|
{
|
||||||
uint32_t i, j;
|
uint32_t i;
|
||||||
|
uint32_t j;
|
||||||
|
|
||||||
switch (*SCState)
|
switch (*SCState)
|
||||||
{
|
{
|
||||||
@@ -316,8 +317,11 @@ static void SC_AnswerReq(SC_State *SC_state, uint8_t *atr_buffer, uint8_t length
|
|||||||
*/
|
*/
|
||||||
static uint8_t SC_decode_Answer2reset(uint8_t *card)
|
static uint8_t SC_decode_Answer2reset(uint8_t *card)
|
||||||
{
|
{
|
||||||
uint32_t i, flag = 0U, protocol;
|
uint32_t i = 0U;
|
||||||
uint8_t index = 0U, level = 0U;
|
uint32_t flag = 0U;
|
||||||
|
uint32_t protocol;
|
||||||
|
uint8_t index = 0U;
|
||||||
|
uint8_t level = 0U;
|
||||||
|
|
||||||
/******************************TS/T0 Decode************************************/
|
/******************************TS/T0 Decode************************************/
|
||||||
index++;
|
index++;
|
||||||
|
|||||||
@@ -154,12 +154,17 @@ extern USBD_ClassTypeDef USBD_CDC;
|
|||||||
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
|
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
|
||||||
USBD_CDC_ItfTypeDef *fops);
|
USBD_CDC_ItfTypeDef *fops);
|
||||||
|
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
|
||||||
|
uint32_t length, uint8_t ClassId);
|
||||||
|
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId);
|
||||||
|
#else
|
||||||
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
|
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
|
||||||
uint32_t length);
|
uint32_t length);
|
||||||
|
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
|
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
|
||||||
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev);
|
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev);
|
||||||
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev);
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ static uint8_t USBD_CDC_EP0_RxReady(USBD_HandleTypeDef *pdev);
|
|||||||
static uint8_t *USBD_CDC_GetFSCfgDesc(uint16_t *length);
|
static uint8_t *USBD_CDC_GetFSCfgDesc(uint16_t *length);
|
||||||
static uint8_t *USBD_CDC_GetHSCfgDesc(uint16_t *length);
|
static uint8_t *USBD_CDC_GetHSCfgDesc(uint16_t *length);
|
||||||
static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc(uint16_t *length);
|
static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc(uint16_t *length);
|
||||||
static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc(uint16_t *length);
|
|
||||||
uint8_t *USBD_CDC_GetDeviceQualifierDescriptor(uint16_t *length);
|
uint8_t *USBD_CDC_GetDeviceQualifierDescriptor(uint16_t *length);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
@@ -305,9 +304,9 @@ static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
CDCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
CDCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
CDCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
CDCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
CDCCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
CDCCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||||
@@ -393,9 +392,9 @@ static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this CDC class instance */
|
/* Get the Endpoints addresses allocated for this CDC class instance */
|
||||||
CDCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
CDCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
CDCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
CDCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
CDCCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
CDCCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Close EP IN */
|
/* Close EP IN */
|
||||||
@@ -746,17 +745,26 @@ uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
|
|||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_CDC_SetTxBuffer
|
* @brief USBD_CDC_SetTxBuffer
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param pbuff: Tx Buffer
|
* @param pbuff: Tx Buffer
|
||||||
* @param length: Tx Buffer length
|
* @param length: length of data to be sent
|
||||||
|
* @param ClassId: The Class ID
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
|
||||||
|
uint8_t *pbuff, uint32_t length, uint8_t ClassId)
|
||||||
|
{
|
||||||
|
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
|
||||||
|
#else
|
||||||
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
|
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
|
||||||
uint8_t *pbuff, uint32_t length)
|
uint8_t *pbuff, uint32_t length)
|
||||||
{
|
{
|
||||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hcdc == NULL)
|
if (hcdc == NULL)
|
||||||
{
|
{
|
||||||
@@ -789,22 +797,32 @@ uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
|
|||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_CDC_TransmitPacket
|
* @brief USBD_CDC_TransmitPacket
|
||||||
* Transmit packet on IN endpoint
|
* Transmit packet on IN endpoint
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
|
* @param ClassId: The Class ID
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId)
|
||||||
|
{
|
||||||
|
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
|
||||||
|
#else
|
||||||
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev)
|
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
USBD_StatusTypeDef ret = USBD_BUSY;
|
USBD_StatusTypeDef ret = USBD_BUSY;
|
||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
CDCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
CDCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, ClassId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
|
||||||
|
if (hcdc == NULL)
|
||||||
{
|
{
|
||||||
return (uint8_t)USBD_FAIL;
|
return (uint8_t)USBD_FAIL;
|
||||||
}
|
}
|
||||||
@@ -838,7 +856,7 @@ uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
CDCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
CDCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||||
|
|||||||
@@ -243,15 +243,19 @@ extern USBD_ClassTypeDef USBD_CDC_ECM;
|
|||||||
uint8_t USBD_CDC_ECM_RegisterInterface(USBD_HandleTypeDef *pdev,
|
uint8_t USBD_CDC_ECM_RegisterInterface(USBD_HandleTypeDef *pdev,
|
||||||
USBD_CDC_ECM_ItfTypeDef *fops);
|
USBD_CDC_ECM_ItfTypeDef *fops);
|
||||||
|
|
||||||
uint8_t USBD_CDC_ECM_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
|
|
||||||
uint32_t length);
|
|
||||||
|
|
||||||
uint8_t USBD_CDC_ECM_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
|
uint8_t USBD_CDC_ECM_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
|
||||||
|
|
||||||
uint8_t USBD_CDC_ECM_ReceivePacket(USBD_HandleTypeDef *pdev);
|
uint8_t USBD_CDC_ECM_ReceivePacket(USBD_HandleTypeDef *pdev);
|
||||||
|
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_CDC_ECM_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId);
|
||||||
|
uint8_t USBD_CDC_ECM_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
|
||||||
|
uint32_t length, uint8_t ClassId);
|
||||||
|
#else
|
||||||
uint8_t USBD_CDC_ECM_TransmitPacket(USBD_HandleTypeDef *pdev);
|
uint8_t USBD_CDC_ECM_TransmitPacket(USBD_HandleTypeDef *pdev);
|
||||||
|
uint8_t USBD_CDC_ECM_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
|
||||||
|
uint32_t length);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
uint8_t USBD_CDC_ECM_SendNotification(USBD_HandleTypeDef *pdev,
|
uint8_t USBD_CDC_ECM_SendNotification(USBD_HandleTypeDef *pdev,
|
||||||
USBD_CDC_NotifCodeTypeDef Notif,
|
USBD_CDC_NotifCodeTypeDef Notif,
|
||||||
uint16_t bVal, uint8_t *pData);
|
uint16_t bVal, uint8_t *pData);
|
||||||
|
|||||||
@@ -295,9 +295,9 @@ static uint8_t USBD_CDC_ECM_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
ECMInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
ECMInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
ECMOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
ECMOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
ECMCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
ECMCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
hcdc = (USBD_CDC_ECM_HandleTypeDef *)USBD_malloc(sizeof(USBD_CDC_ECM_HandleTypeDef));
|
hcdc = (USBD_CDC_ECM_HandleTypeDef *)USBD_malloc(sizeof(USBD_CDC_ECM_HandleTypeDef));
|
||||||
@@ -364,7 +364,8 @@ static uint8_t USBD_CDC_ECM_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
hcdc->TxLength = 0U;
|
hcdc->TxLength = 0U;
|
||||||
hcdc->LinkStatus = 0U;
|
hcdc->LinkStatus = 0U;
|
||||||
hcdc->NotificationStatus = 0U;
|
hcdc->NotificationStatus = 0U;
|
||||||
hcdc->MaxPcktLen = (pdev->dev_speed == USBD_SPEED_HIGH) ? CDC_ECM_DATA_HS_MAX_PACKET_SIZE : CDC_ECM_DATA_FS_MAX_PACKET_SIZE;
|
hcdc->MaxPcktLen = (pdev->dev_speed == USBD_SPEED_HIGH) ? CDC_ECM_DATA_HS_MAX_PACKET_SIZE : \
|
||||||
|
CDC_ECM_DATA_FS_MAX_PACKET_SIZE;
|
||||||
|
|
||||||
if (hcdc->RxBuffer == NULL)
|
if (hcdc->RxBuffer == NULL)
|
||||||
{
|
{
|
||||||
@@ -390,9 +391,9 @@ static uint8_t USBD_CDC_ECM_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
ECMInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
ECMInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
ECMOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
ECMOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
ECMCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
ECMCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Close EP IN */
|
/* Close EP IN */
|
||||||
@@ -427,8 +428,7 @@ static uint8_t USBD_CDC_ECM_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
* @param req: usb requests
|
* @param req: usb requests
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
static uint8_t USBD_CDC_ECM_Setup(USBD_HandleTypeDef *pdev,
|
static uint8_t USBD_CDC_ECM_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
USBD_SetupReqTypedef *req)
|
|
||||||
{
|
{
|
||||||
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *) pdev->pClassDataCmsit[pdev->classId];
|
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *) pdev->pClassDataCmsit[pdev->classId];
|
||||||
USBD_CDC_ECM_ItfTypeDef *EcmInterface = (USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData[pdev->classId];
|
USBD_CDC_ECM_ItfTypeDef *EcmInterface = (USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData[pdev->classId];
|
||||||
@@ -449,8 +449,7 @@ static uint8_t USBD_CDC_ECM_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
{
|
{
|
||||||
if ((req->bmRequest & 0x80U) != 0U)
|
if ((req->bmRequest & 0x80U) != 0U)
|
||||||
{
|
{
|
||||||
EcmInterface->Control(req->bRequest,
|
EcmInterface->Control(req->bRequest, (uint8_t *)hcdc->data, req->wLength);
|
||||||
(uint8_t *)hcdc->data, req->wLength);
|
|
||||||
|
|
||||||
len = MIN(CDC_ECM_DATA_BUFFER_SIZE, req->wLength);
|
len = MIN(CDC_ECM_DATA_BUFFER_SIZE, req->wLength);
|
||||||
(void)USBD_CtlSendData(pdev, (uint8_t *)hcdc->data, len);
|
(void)USBD_CtlSendData(pdev, (uint8_t *)hcdc->data, len);
|
||||||
@@ -537,7 +536,7 @@ static uint8_t USBD_CDC_ECM_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
ECMInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
ECMInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||||
@@ -561,7 +560,8 @@ static uint8_t USBD_CDC_ECM_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
hcdc->TxState = 0U;
|
hcdc->TxState = 0U;
|
||||||
if (((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData[pdev->classId])->TransmitCplt != NULL)
|
if (((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData[pdev->classId])->TransmitCplt != NULL)
|
||||||
{
|
{
|
||||||
((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData[pdev->classId])->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum);
|
((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData[pdev->classId])->TransmitCplt(hcdc->TxBuffer,
|
||||||
|
&hcdc->TxLength, epnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -569,8 +569,7 @@ static uint8_t USBD_CDC_ECM_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
{
|
{
|
||||||
if (hcdc->NotificationStatus != 0U)
|
if (hcdc->NotificationStatus != 0U)
|
||||||
{
|
{
|
||||||
(void)USBD_CDC_ECM_SendNotification(pdev, CONNECTION_SPEED_CHANGE,
|
(void)USBD_CDC_ECM_SendNotification(pdev, CONNECTION_SPEED_CHANGE, 0U, (uint8_t *)ConnSpeedTab);
|
||||||
0U, (uint8_t *)ConnSpeedTab);
|
|
||||||
|
|
||||||
hcdc->NotificationStatus = 0U;
|
hcdc->NotificationStatus = 0U;
|
||||||
}
|
}
|
||||||
@@ -597,7 +596,7 @@ static uint8_t USBD_CDC_ECM_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
ECMOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
ECMOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||||
@@ -807,7 +806,10 @@ static uint8_t *USBD_CDC_ECM_USRStringDescriptor(USBD_HandleTypeDef *pdev, uint8
|
|||||||
/* Check if the requested string interface is supported */
|
/* Check if the requested string interface is supported */
|
||||||
if (index == CDC_ECM_MAC_STRING_INDEX)
|
if (index == CDC_ECM_MAC_STRING_INDEX)
|
||||||
{
|
{
|
||||||
USBD_GetString((uint8_t *)((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData[pdev->classId])->pStrDesc, USBD_StrDesc, length);
|
USBD_GetString((uint8_t *)((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData[pdev->classId])->pStrDesc,
|
||||||
|
USBD_StrDesc,
|
||||||
|
length);
|
||||||
|
|
||||||
return USBD_StrDesc;
|
return USBD_StrDesc;
|
||||||
}
|
}
|
||||||
/* Not supported Interface Descriptor index */
|
/* Not supported Interface Descriptor index */
|
||||||
@@ -823,11 +825,18 @@ static uint8_t *USBD_CDC_ECM_USRStringDescriptor(USBD_HandleTypeDef *pdev, uint8
|
|||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param pbuff: Tx Buffer
|
* @param pbuff: Tx Buffer
|
||||||
* @param length: Tx Buffer length
|
* @param length: Tx Buffer length
|
||||||
|
* @param ClassId: The Class ID
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_CDC_ECM_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, uint32_t length, uint8_t ClassId)
|
||||||
|
{
|
||||||
|
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
|
||||||
|
#else
|
||||||
uint8_t USBD_CDC_ECM_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, uint32_t length)
|
uint8_t USBD_CDC_ECM_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, uint32_t length)
|
||||||
{
|
{
|
||||||
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hcdc == NULL)
|
if (hcdc == NULL)
|
||||||
{
|
{
|
||||||
@@ -861,23 +870,32 @@ uint8_t USBD_CDC_ECM_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
|
|||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_CDC_ECM_TransmitPacket
|
* @brief USBD_CDC_ECM_TransmitPacket
|
||||||
* Transmit packet on IN endpoint
|
* Transmit packet on IN endpoint
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
|
* @param ClassId: The Class ID
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_CDC_ECM_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId)
|
||||||
|
{
|
||||||
|
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
|
||||||
|
#else
|
||||||
uint8_t USBD_CDC_ECM_TransmitPacket(USBD_HandleTypeDef *pdev)
|
uint8_t USBD_CDC_ECM_TransmitPacket(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_CDC_ECM_HandleTypeDef *hcdc = (USBD_CDC_ECM_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
USBD_StatusTypeDef ret = USBD_BUSY;
|
USBD_StatusTypeDef ret = USBD_BUSY;
|
||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
ECMInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
ECMInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, ClassId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
if (hcdc == NULL)
|
||||||
{
|
{
|
||||||
return (uint8_t)USBD_FAIL;
|
return (uint8_t)USBD_FAIL;
|
||||||
}
|
}
|
||||||
@@ -912,7 +930,7 @@ uint8_t USBD_CDC_ECM_ReceivePacket(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
ECMOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
ECMOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||||
@@ -951,7 +969,7 @@ uint8_t USBD_CDC_ECM_SendNotification(USBD_HandleTypeDef *pdev,
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
ECMCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
ECMCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Initialize the request fields */
|
/* Initialize the request fields */
|
||||||
|
|||||||
@@ -85,7 +85,11 @@ static int8_t CDC_ECM_Itf_Init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set Application Buffers */
|
/* Set Application Buffers */
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
(void)USBD_CDC_ECM_SetTxBuffer(&USBD_Device, UserTxBuffer, 0U, 0U);
|
||||||
|
#else
|
||||||
(void)USBD_CDC_ECM_SetTxBuffer(&USBD_Device, UserTxBuffer, 0U);
|
(void)USBD_CDC_ECM_SetTxBuffer(&USBD_Device, UserTxBuffer, 0U);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
(void)USBD_CDC_ECM_SetRxBuffer(&USBD_Device, UserRxBuffer);
|
(void)USBD_CDC_ECM_SetRxBuffer(&USBD_Device, UserRxBuffer);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
@@ -100,7 +104,8 @@ static int8_t CDC_ECM_Itf_Init(void)
|
|||||||
static int8_t CDC_ECM_Itf_DeInit(void)
|
static int8_t CDC_ECM_Itf_DeInit(void)
|
||||||
{
|
{
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassDataCmsit[USBD_Device.classId]);
|
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *) \
|
||||||
|
(USBD_Device.pClassDataCmsit[USBD_Device.classId]);
|
||||||
#else
|
#else
|
||||||
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassData);
|
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassData);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
@@ -122,7 +127,8 @@ static int8_t CDC_ECM_Itf_DeInit(void)
|
|||||||
static int8_t CDC_ECM_Itf_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length)
|
static int8_t CDC_ECM_Itf_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length)
|
||||||
{
|
{
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassDataCmsit[USBD_Device.classId]);
|
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *) \
|
||||||
|
(USBD_Device.pClassDataCmsit[USBD_Device.classId]);
|
||||||
#else
|
#else
|
||||||
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassData);
|
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassData);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
@@ -197,7 +203,8 @@ static int8_t CDC_ECM_Itf_Receive(uint8_t *Buf, uint32_t *Len)
|
|||||||
{
|
{
|
||||||
/* Get the CDC_ECM handler pointer */
|
/* Get the CDC_ECM handler pointer */
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassDataCmsit[USBD_Device.classId]);
|
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *) \
|
||||||
|
(USBD_Device.pClassDataCmsit[USBD_Device.classId]);
|
||||||
#else
|
#else
|
||||||
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassData);
|
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassData);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|||||||
@@ -493,14 +493,18 @@ extern USBD_ClassTypeDef USBD_CDC_RNDIS;
|
|||||||
*/
|
*/
|
||||||
uint8_t USBD_CDC_RNDIS_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
|
uint8_t USBD_CDC_RNDIS_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
|
||||||
uint8_t USBD_CDC_RNDIS_ReceivePacket(USBD_HandleTypeDef *pdev);
|
uint8_t USBD_CDC_RNDIS_ReceivePacket(USBD_HandleTypeDef *pdev);
|
||||||
uint8_t USBD_CDC_RNDIS_TransmitPacket(USBD_HandleTypeDef *pdev);
|
|
||||||
|
|
||||||
uint8_t USBD_CDC_RNDIS_RegisterInterface(USBD_HandleTypeDef *pdev,
|
uint8_t USBD_CDC_RNDIS_RegisterInterface(USBD_HandleTypeDef *pdev,
|
||||||
USBD_CDC_RNDIS_ItfTypeDef *fops);
|
USBD_CDC_RNDIS_ItfTypeDef *fops);
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_CDC_RNDIS_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId);
|
||||||
|
uint8_t USBD_CDC_RNDIS_SetTxBuffer(USBD_HandleTypeDef *pdev,
|
||||||
|
uint8_t *pbuff, uint32_t length, uint8_t ClassId);
|
||||||
|
#else
|
||||||
|
uint8_t USBD_CDC_RNDIS_TransmitPacket(USBD_HandleTypeDef *pdev);
|
||||||
uint8_t USBD_CDC_RNDIS_SetTxBuffer(USBD_HandleTypeDef *pdev,
|
uint8_t USBD_CDC_RNDIS_SetTxBuffer(USBD_HandleTypeDef *pdev,
|
||||||
uint8_t *pbuff, uint32_t length);
|
uint8_t *pbuff, uint32_t length);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
uint8_t USBD_CDC_RNDIS_SendNotification(USBD_HandleTypeDef *pdev,
|
uint8_t USBD_CDC_RNDIS_SendNotification(USBD_HandleTypeDef *pdev,
|
||||||
USBD_CDC_NotifCodeTypeDef Notif,
|
USBD_CDC_NotifCodeTypeDef Notif,
|
||||||
uint16_t bVal, uint8_t *pData);
|
uint16_t bVal, uint8_t *pData);
|
||||||
|
|||||||
@@ -357,9 +357,9 @@ static uint8_t USBD_CDC_RNDIS_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
RNDISInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
RNDISInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
RNDISOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
RNDISOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
RNDISCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
RNDISCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hcdc == NULL)
|
if (hcdc == NULL)
|
||||||
@@ -427,7 +427,8 @@ static uint8_t USBD_CDC_RNDIS_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
hcdc->TxLength = 0U;
|
hcdc->TxLength = 0U;
|
||||||
hcdc->LinkStatus = 0U;
|
hcdc->LinkStatus = 0U;
|
||||||
hcdc->NotificationStatus = 0U;
|
hcdc->NotificationStatus = 0U;
|
||||||
hcdc->MaxPcktLen = (pdev->dev_speed == USBD_SPEED_HIGH) ? CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE : CDC_RNDIS_DATA_FS_MAX_PACKET_SIZE;
|
hcdc->MaxPcktLen = (pdev->dev_speed == USBD_SPEED_HIGH) ? CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE : \
|
||||||
|
CDC_RNDIS_DATA_FS_MAX_PACKET_SIZE;
|
||||||
|
|
||||||
if (hcdc->RxBuffer == NULL)
|
if (hcdc->RxBuffer == NULL)
|
||||||
{
|
{
|
||||||
@@ -454,9 +455,9 @@ static uint8_t USBD_CDC_RNDIS_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
RNDISInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
RNDISInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
RNDISOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
RNDISOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
RNDISCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
RNDISCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Close EP IN */
|
/* Close EP IN */
|
||||||
@@ -637,7 +638,7 @@ static uint8_t USBD_CDC_RNDIS_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
RNDISInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
RNDISInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||||
@@ -664,7 +665,8 @@ static uint8_t USBD_CDC_RNDIS_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
|
|
||||||
if (((USBD_CDC_RNDIS_ItfTypeDef *)pdev->pUserData[pdev->classId])->TransmitCplt != NULL)
|
if (((USBD_CDC_RNDIS_ItfTypeDef *)pdev->pUserData[pdev->classId])->TransmitCplt != NULL)
|
||||||
{
|
{
|
||||||
((USBD_CDC_RNDIS_ItfTypeDef *)pdev->pUserData[pdev->classId])->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum);
|
((USBD_CDC_RNDIS_ItfTypeDef *)pdev->pUserData[pdev->classId])->TransmitCplt(hcdc->TxBuffer, \
|
||||||
|
&hcdc->TxLength, epnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -699,7 +701,7 @@ static uint8_t USBD_CDC_RNDIS_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
uint32_t CurrPcktLen;
|
uint32_t CurrPcktLen;
|
||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE /* Get the Endpoints addresses allocated for this class instance */
|
#ifdef USE_USBD_COMPOSITE /* Get the Endpoints addresses allocated for this class instance */
|
||||||
RNDISOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
RNDISOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||||
@@ -936,16 +938,25 @@ static uint8_t *USBD_CDC_RNDIS_USRStringDescriptor(USBD_HandleTypeDef *pdev, uin
|
|||||||
}
|
}
|
||||||
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_CDC_RNDIS_SetTxBuffer
|
* @brief USBD_CDC_RNDIS_SetTxBuffer
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param pbuff: Tx Buffer
|
* @param pbuff: Tx Buffer
|
||||||
* @param length: Tx Buffer length
|
* @param length: Tx Buffer length
|
||||||
|
* @param ClassId: The Class ID
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_CDC_RNDIS_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, uint32_t length, uint8_t ClassId)
|
||||||
|
{
|
||||||
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
|
||||||
|
#else
|
||||||
uint8_t USBD_CDC_RNDIS_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, uint32_t length)
|
uint8_t USBD_CDC_RNDIS_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, uint32_t length)
|
||||||
{
|
{
|
||||||
|
|
||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hcdc == NULL)
|
if (hcdc == NULL)
|
||||||
{
|
{
|
||||||
@@ -984,25 +995,32 @@ uint8_t USBD_CDC_RNDIS_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
|
|||||||
* @brief USBD_CDC_RNDIS_TransmitPacket
|
* @brief USBD_CDC_RNDIS_TransmitPacket
|
||||||
* Transmit packet on IN endpoint
|
* Transmit packet on IN endpoint
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
|
* @param ClassId: The Class ID
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_CDC_RNDIS_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId)
|
||||||
|
{
|
||||||
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
|
||||||
|
#else
|
||||||
uint8_t USBD_CDC_RNDIS_TransmitPacket(USBD_HandleTypeDef *pdev)
|
uint8_t USBD_CDC_RNDIS_TransmitPacket(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc;
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
USBD_CDC_RNDIS_PacketMsgTypeDef *PacketMsg;
|
USBD_CDC_RNDIS_PacketMsgTypeDef *PacketMsg;
|
||||||
USBD_StatusTypeDef ret = USBD_BUSY;
|
USBD_StatusTypeDef ret = USBD_BUSY;
|
||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
RNDISInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
RNDISInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, ClassId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
if (hcdc == NULL)
|
||||||
{
|
{
|
||||||
return (uint8_t)USBD_FAIL;
|
return (uint8_t)USBD_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
|
||||||
PacketMsg = (USBD_CDC_RNDIS_PacketMsgTypeDef *)(void *)hcdc->TxBuffer;
|
PacketMsg = (USBD_CDC_RNDIS_PacketMsgTypeDef *)(void *)hcdc->TxBuffer;
|
||||||
|
|
||||||
if (hcdc->TxState == 0U)
|
if (hcdc->TxState == 0U)
|
||||||
@@ -1048,7 +1066,7 @@ uint8_t USBD_CDC_RNDIS_ReceivePacket(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
RNDISOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
RNDISOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
||||||
@@ -1094,7 +1112,7 @@ uint8_t USBD_CDC_RNDIS_SendNotification(USBD_HandleTypeDef *pdev,
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
RNDISCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
RNDISCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Initialize the request fields */
|
/* Initialize the request fields */
|
||||||
@@ -1598,7 +1616,8 @@ static uint8_t USBD_CDC_RNDIS_ProcessResetMsg(USBD_HandleTypeDef *pdev,
|
|||||||
static uint8_t USBD_CDC_RNDIS_ProcessPacketMsg(USBD_HandleTypeDef *pdev,
|
static uint8_t USBD_CDC_RNDIS_ProcessPacketMsg(USBD_HandleTypeDef *pdev,
|
||||||
USBD_CDC_RNDIS_PacketMsgTypeDef *Msg)
|
USBD_CDC_RNDIS_PacketMsgTypeDef *Msg)
|
||||||
{
|
{
|
||||||
uint32_t tmp1, tmp2;
|
uint32_t tmp1;
|
||||||
|
uint32_t tmp2;
|
||||||
|
|
||||||
/* Get the CDC_RNDIS handle pointer */
|
/* Get the CDC_RNDIS handle pointer */
|
||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
|||||||
@@ -95,7 +95,11 @@ static int8_t CDC_RNDIS_Itf_Init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set Application Buffers */
|
/* Set Application Buffers */
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
(void)USBD_CDC_RNDIS_SetTxBuffer(&USBD_Device, UserTxBuffer, 0U, 0U);
|
||||||
|
#else
|
||||||
(void)USBD_CDC_RNDIS_SetTxBuffer(&USBD_Device, UserTxBuffer, 0U);
|
(void)USBD_CDC_RNDIS_SetTxBuffer(&USBD_Device, UserTxBuffer, 0U);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
(void)USBD_CDC_RNDIS_SetRxBuffer(&USBD_Device, UserRxBuffer);
|
(void)USBD_CDC_RNDIS_SetRxBuffer(&USBD_Device, UserRxBuffer);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
@@ -110,7 +114,8 @@ static int8_t CDC_RNDIS_Itf_Init(void)
|
|||||||
static int8_t CDC_RNDIS_Itf_DeInit(void)
|
static int8_t CDC_RNDIS_Itf_DeInit(void)
|
||||||
{
|
{
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc_cdc_rndis = (USBD_CDC_RNDIS_HandleTypeDef *)(USBD_Device.pClassDataCmsit[USBD_Device.classId]);
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc_cdc_rndis = (USBD_CDC_RNDIS_HandleTypeDef *) \
|
||||||
|
(USBD_Device.pClassDataCmsit[USBD_Device.classId]);
|
||||||
#else
|
#else
|
||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc_cdc_rndis = (USBD_CDC_RNDIS_HandleTypeDef *)(USBD_Device.pClassData);
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc_cdc_rndis = (USBD_CDC_RNDIS_HandleTypeDef *)(USBD_Device.pClassData);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
@@ -136,7 +141,8 @@ static int8_t CDC_RNDIS_Itf_DeInit(void)
|
|||||||
static int8_t CDC_RNDIS_Itf_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length)
|
static int8_t CDC_RNDIS_Itf_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length)
|
||||||
{
|
{
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc_cdc_rndis = (USBD_CDC_RNDIS_HandleTypeDef *)(USBD_Device.pClassDataCmsit[USBD_Device.classId]);
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc_cdc_rndis = (USBD_CDC_RNDIS_HandleTypeDef *) \
|
||||||
|
(USBD_Device.pClassDataCmsit[USBD_Device.classId]);
|
||||||
#else
|
#else
|
||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc_cdc_rndis = (USBD_CDC_RNDIS_HandleTypeDef *)(USBD_Device.pClassData);
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc_cdc_rndis = (USBD_CDC_RNDIS_HandleTypeDef *)(USBD_Device.pClassData);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
@@ -183,7 +189,8 @@ static int8_t CDC_RNDIS_Itf_Receive(uint8_t *Buf, uint32_t *Len)
|
|||||||
{
|
{
|
||||||
/* Get the CDC_RNDIS handler pointer */
|
/* Get the CDC_RNDIS handler pointer */
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc_cdc_rndis = (USBD_CDC_RNDIS_HandleTypeDef *)(USBD_Device.pClassDataCmsit[USBD_Device.classId]);
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc_cdc_rndis = (USBD_CDC_RNDIS_HandleTypeDef *) \
|
||||||
|
(USBD_Device.pClassDataCmsit[USBD_Device.classId]);
|
||||||
#else
|
#else
|
||||||
USBD_CDC_RNDIS_HandleTypeDef *hcdc_cdc_rndis = (USBD_CDC_RNDIS_HandleTypeDef *)(USBD_Device.pClassData);
|
USBD_CDC_RNDIS_HandleTypeDef *hcdc_cdc_rndis = (USBD_CDC_RNDIS_HandleTypeDef *)(USBD_Device.pClassData);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ uint8_t USBD_CMPST_ClearConfDesc(USBD_HandleTypeDef *pdev);
|
|||||||
pEpDesc->bDescriptorType = USB_DESC_TYPE_ENDPOINT; \
|
pEpDesc->bDescriptorType = USB_DESC_TYPE_ENDPOINT; \
|
||||||
pEpDesc->bEndpointAddress = (epadd); \
|
pEpDesc->bEndpointAddress = (epadd); \
|
||||||
pEpDesc->bmAttributes = (eptype); \
|
pEpDesc->bmAttributes = (eptype); \
|
||||||
pEpDesc->wMaxPacketSize = (epsize); \
|
pEpDesc->wMaxPacketSize = (uint16_t)(epsize); \
|
||||||
if(speed == (uint8_t)USBD_SPEED_HIGH) \
|
if(speed == (uint8_t)USBD_SPEED_HIGH) \
|
||||||
{ \
|
{ \
|
||||||
pEpDesc->bInterval = HSinterval; \
|
pEpDesc->bInterval = HSinterval; \
|
||||||
|
|||||||
@@ -844,7 +844,7 @@ static void USBD_CMPSIT_HIDMouseDesc(USBD_HandleTypeDef *pdev, uint32_t pConf,
|
|||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = *Sze;
|
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = (uint16_t)(*Sze);
|
||||||
}
|
}
|
||||||
#endif /* USBD_CMPSIT_ACTIVATE_HID == 1 */
|
#endif /* USBD_CMPSIT_ACTIVATE_HID == 1 */
|
||||||
|
|
||||||
@@ -881,7 +881,7 @@ static void USBD_CMPSIT_MSCDesc(USBD_HandleTypeDef *pdev, uint32_t pConf, __IO
|
|||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = *Sze;
|
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = (uint16_t)(*Sze);
|
||||||
}
|
}
|
||||||
#endif /* USBD_CMPSIT_ACTIVATE_MSC == 1 */
|
#endif /* USBD_CMPSIT_ACTIVATE_MSC == 1 */
|
||||||
|
|
||||||
@@ -979,7 +979,7 @@ static void USBD_CMPSIT_CDCDesc(USBD_HandleTypeDef *pdev, uint32_t pConf, __IO
|
|||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 2U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 2U;
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = *Sze;
|
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = (uint16_t)(*Sze);
|
||||||
}
|
}
|
||||||
#endif /* USBD_CMPSIT_ACTIVATE_CDC == 1 */
|
#endif /* USBD_CMPSIT_ACTIVATE_CDC == 1 */
|
||||||
|
|
||||||
@@ -1018,7 +1018,7 @@ static void USBD_CMPSIT_DFUDesc(USBD_HandleTypeDef *pdev, uint32_t pConf, __IO
|
|||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = *Sze;
|
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = (uint16_t)(*Sze);
|
||||||
|
|
||||||
UNUSED(idx);
|
UNUSED(idx);
|
||||||
}
|
}
|
||||||
@@ -1113,7 +1113,7 @@ static void USBD_CMPSIT_CDC_ECMDesc(USBD_HandleTypeDef *pdev, uint32_t pConf, _
|
|||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 2U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 2U;
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = *Sze;
|
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = (uint16_t)(*Sze);
|
||||||
}
|
}
|
||||||
#endif /* USBD_CMPSIT_ACTIVATE_CDC_ECM */
|
#endif /* USBD_CMPSIT_ACTIVATE_CDC_ECM */
|
||||||
|
|
||||||
@@ -1249,7 +1249,7 @@ static void USBD_CMPSIT_AUDIODesc(USBD_HandleTypeDef *pdev, uint32_t pConf, __I
|
|||||||
pSpEpDesc->bDescriptorType = USB_DESC_TYPE_ENDPOINT;
|
pSpEpDesc->bDescriptorType = USB_DESC_TYPE_ENDPOINT;
|
||||||
pSpEpDesc->bEndpointAddress = pdev->tclasslist[pdev->classId].Eps[0].add;
|
pSpEpDesc->bEndpointAddress = pdev->tclasslist[pdev->classId].Eps[0].add;
|
||||||
pSpEpDesc->bmAttributes = USBD_EP_TYPE_ISOC;
|
pSpEpDesc->bmAttributes = USBD_EP_TYPE_ISOC;
|
||||||
pSpEpDesc->wMaxPacketSize = USBD_AUDIO_GetEpPcktSze(pdev, 0U, 0U);
|
pSpEpDesc->wMaxPacketSize = (uint16_t)USBD_AUDIO_GetEpPcktSze(pdev, 0U, 0U);
|
||||||
pSpEpDesc->bInterval = 0x01U;
|
pSpEpDesc->bInterval = 0x01U;
|
||||||
pSpEpDesc->bRefresh = 0x00U;
|
pSpEpDesc->bRefresh = 0x00U;
|
||||||
pSpEpDesc->bSynchAddress = 0x00U;
|
pSpEpDesc->bSynchAddress = 0x00U;
|
||||||
@@ -1267,7 +1267,7 @@ static void USBD_CMPSIT_AUDIODesc(USBD_HandleTypeDef *pdev, uint32_t pConf, __I
|
|||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 2U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 2U;
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = *Sze;
|
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = (uint16_t)(*Sze);
|
||||||
}
|
}
|
||||||
#endif /* USBD_CMPSIT_ACTIVATE_AUDIO */
|
#endif /* USBD_CMPSIT_ACTIVATE_AUDIO */
|
||||||
|
|
||||||
@@ -1363,7 +1363,7 @@ static void USBD_CMPSIT_RNDISDesc(USBD_HandleTypeDef *pdev, uint32_t pConf, __I
|
|||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 2U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 2U;
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = *Sze;
|
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = (uint16_t)(*Sze);
|
||||||
}
|
}
|
||||||
#endif /* USBD_CMPSIT_ACTIVATE_RNDIS == 1 */
|
#endif /* USBD_CMPSIT_ACTIVATE_RNDIS == 1 */
|
||||||
|
|
||||||
@@ -1407,7 +1407,7 @@ static void USBD_CMPSIT_CUSTOMHIDDesc(USBD_HandleTypeDef *pdev, uint32_t pConf,
|
|||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = *Sze;
|
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = (uint16_t)(*Sze);
|
||||||
}
|
}
|
||||||
#endif /* USBD_CMPSIT_ACTIVATE_CUSTOMHID == 1U */
|
#endif /* USBD_CMPSIT_ACTIVATE_CUSTOMHID == 1U */
|
||||||
|
|
||||||
@@ -1585,8 +1585,7 @@ static void USBD_CMPSIT_VIDEODesc(USBD_HandleTypeDef *pdev, uint32_t pConf, __I
|
|||||||
|
|
||||||
/* USB Standard VS Interface Descriptor - data transfer mode */
|
/* USB Standard VS Interface Descriptor - data transfer mode */
|
||||||
/* Interface 1, Alternate Setting 1*/
|
/* Interface 1, Alternate Setting 1*/
|
||||||
__USBD_CMPSIT_SET_IF(1U, 1U, 1U, UVC_CC_VIDEO, \
|
__USBD_CMPSIT_SET_IF(1U, 1U, 1U, UVC_CC_VIDEO, SC_VIDEOSTREAMING, PC_PROTOCOL_UNDEFINED, 0U);
|
||||||
SC_VIDEOSTREAMING, PC_PROTOCOL_UNDEFINED, 0U);
|
|
||||||
|
|
||||||
/* Standard VS (Video Streaming) data Endpoint */
|
/* Standard VS (Video Streaming) data Endpoint */
|
||||||
pSVCDEP = ((USBD_StandardVCDataEPDescTypeDef *)(pConf + *Sze));
|
pSVCDEP = ((USBD_StandardVCDataEPDescTypeDef *)(pConf + *Sze));
|
||||||
@@ -1609,7 +1608,7 @@ static void USBD_CMPSIT_VIDEODesc(USBD_HandleTypeDef *pdev, uint32_t pConf, __I
|
|||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 2U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 2U;
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = *Sze;
|
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = (uint16_t)(*Sze);
|
||||||
}
|
}
|
||||||
#endif /* USBD_CMPSIT_ACTIVATE_VIDEO == 1 */
|
#endif /* USBD_CMPSIT_ACTIVATE_VIDEO == 1 */
|
||||||
|
|
||||||
@@ -1645,7 +1644,7 @@ static void USBD_CMPSIT_PRNTDesc(USBD_HandleTypeDef *pdev, uint32_t pConf, __IO
|
|||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = *Sze;
|
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = (uint16_t)(*Sze);
|
||||||
}
|
}
|
||||||
#endif /* USBD_CMPSIT_ACTIVATE_PRINTER == 1 */
|
#endif /* USBD_CMPSIT_ACTIVATE_PRINTER == 1 */
|
||||||
|
|
||||||
@@ -1715,7 +1714,7 @@ static void USBD_CMPSIT_CCIDDesc(USBD_HandleTypeDef *pdev, uint32_t pConf, __IO
|
|||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = *Sze;
|
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = (uint16_t)(*Sze);
|
||||||
}
|
}
|
||||||
#endif /* USBD_CMPSIT_ACTIVATE_CCID == 1 */
|
#endif /* USBD_CMPSIT_ACTIVATE_CCID == 1 */
|
||||||
|
|
||||||
@@ -1735,8 +1734,8 @@ static void USBD_CMPSIT_MTPDesc(USBD_HandleTypeDef *pdev, uint32_t pConf, __IO
|
|||||||
|
|
||||||
/* Append MTP Interface descriptor */
|
/* Append MTP Interface descriptor */
|
||||||
__USBD_CMPSIT_SET_IF((pdev->tclasslist[pdev->classId].Ifs[0]), (0U), \
|
__USBD_CMPSIT_SET_IF((pdev->tclasslist[pdev->classId].Ifs[0]), (0U), \
|
||||||
(uint8_t)(pdev->tclasslist[pdev->classId].NumEps), USB_MTP_INTRERFACE_CLASS, USB_MTP_INTRERFACE_SUB_CLASS,
|
(uint8_t)(pdev->tclasslist[pdev->classId].NumEps), USB_MTP_INTRERFACE_CLASS, \
|
||||||
USB_MTP_INTRERFACE_PROTOCOL, (0U));
|
USB_MTP_INTRERFACE_SUB_CLASS, USB_MTP_INTRERFACE_PROTOCOL, (0U));
|
||||||
|
|
||||||
if (speed == (uint8_t)USBD_SPEED_HIGH)
|
if (speed == (uint8_t)USBD_SPEED_HIGH)
|
||||||
{
|
{
|
||||||
@@ -1757,7 +1756,7 @@ static void USBD_CMPSIT_MTPDesc(USBD_HandleTypeDef *pdev, uint32_t pConf, __IO
|
|||||||
|
|
||||||
/* Update Config Descriptor and IAD descriptor */
|
/* Update Config Descriptor and IAD descriptor */
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
|
||||||
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = *Sze;
|
((USBD_ConfigDescTypeDef *)pConf)->wTotalLength = (uint16_t)(*Sze);
|
||||||
}
|
}
|
||||||
#endif /* USBD_CMPSIT_ACTIVATE_MTP == 1 */
|
#endif /* USBD_CMPSIT_ACTIVATE_MTP == 1 */
|
||||||
|
|
||||||
@@ -1778,7 +1777,8 @@ uint32_t USBD_CMPSIT_SetClassID(USBD_HandleTypeDef *pdev, USBD_CompositeClassTy
|
|||||||
for (idx = 0U; idx < pdev->NumClasses; idx++)
|
for (idx = 0U; idx < pdev->NumClasses; idx++)
|
||||||
{
|
{
|
||||||
/* Check if the class correspond to the requested type and if it is active */
|
/* Check if the class correspond to the requested type and if it is active */
|
||||||
if (((USBD_CompositeClassTypeDef)(pdev->tclasslist[idx].ClassType) == Class) && ((pdev->tclasslist[idx].Active) == 1U))
|
if (((USBD_CompositeClassTypeDef)(pdev->tclasslist[idx].ClassType) == Class) &&
|
||||||
|
((pdev->tclasslist[idx].Active) == 1U))
|
||||||
{
|
{
|
||||||
if (inst == Instance)
|
if (inst == Instance)
|
||||||
{
|
{
|
||||||
@@ -1817,7 +1817,8 @@ uint32_t USBD_CMPSIT_GetClassID(USBD_HandleTypeDef *pdev, USBD_CompositeClassTy
|
|||||||
for (idx = 0U; idx < pdev->NumClasses; idx++)
|
for (idx = 0U; idx < pdev->NumClasses; idx++)
|
||||||
{
|
{
|
||||||
/* Check if the class correspond to the requested type and if it is active */
|
/* Check if the class correspond to the requested type and if it is active */
|
||||||
if (((USBD_CompositeClassTypeDef)(pdev->tclasslist[idx].ClassType) == Class) && ((pdev->tclasslist[idx].Active) == 1U))
|
if (((USBD_CompositeClassTypeDef)(pdev->tclasslist[idx].ClassType) == Class) &&
|
||||||
|
((pdev->tclasslist[idx].Active) == 1U))
|
||||||
{
|
{
|
||||||
if (inst == Instance)
|
if (inst == Instance)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -106,7 +106,12 @@ typedef struct _USBD_CUSTOM_HID_Itf
|
|||||||
int8_t (* Init)(void);
|
int8_t (* Init)(void);
|
||||||
int8_t (* DeInit)(void);
|
int8_t (* DeInit)(void);
|
||||||
int8_t (* OutEvent)(uint8_t event_idx, uint8_t state);
|
int8_t (* OutEvent)(uint8_t event_idx, uint8_t state);
|
||||||
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
|
||||||
|
int8_t (* CtrlReqComplete)(uint8_t request, uint16_t wLength);
|
||||||
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
||||||
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED
|
||||||
|
uint8_t *(* GetReport)(uint16_t *ReportLength);
|
||||||
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED */
|
||||||
} USBD_CUSTOM_HID_ItfTypeDef;
|
} USBD_CUSTOM_HID_ItfTypeDef;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -162,9 +167,13 @@ extern USBD_ClassTypeDef USBD_CUSTOM_HID;
|
|||||||
/** @defgroup USB_CORE_Exported_Functions
|
/** @defgroup USB_CORE_Exported_Functions
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_CUSTOM_HID_SendReport(USBD_HandleTypeDef *pdev,
|
||||||
|
uint8_t *report, uint16_t len, uint8_t ClassId);
|
||||||
|
#else
|
||||||
uint8_t USBD_CUSTOM_HID_SendReport(USBD_HandleTypeDef *pdev,
|
uint8_t USBD_CUSTOM_HID_SendReport(USBD_HandleTypeDef *pdev,
|
||||||
uint8_t *report, uint16_t len);
|
uint8_t *report, uint16_t len);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
uint8_t USBD_CUSTOM_HID_ReceivePacket(USBD_HandleTypeDef *pdev);
|
uint8_t USBD_CUSTOM_HID_ReceivePacket(USBD_HandleTypeDef *pdev);
|
||||||
|
|
||||||
uint8_t USBD_CUSTOM_HID_RegisterInterface(USBD_HandleTypeDef *pdev,
|
uint8_t USBD_CUSTOM_HID_RegisterInterface(USBD_HandleTypeDef *pdev,
|
||||||
|
|||||||
@@ -136,8 +136,8 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgDesc[USB_CUSTOM_HID_CONFIG_DESC_
|
|||||||
{
|
{
|
||||||
0x09, /* bLength: Configuration Descriptor size */
|
0x09, /* bLength: Configuration Descriptor size */
|
||||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||||
USB_CUSTOM_HID_CONFIG_DESC_SIZ, /* wTotalLength: Bytes returned */
|
LOBYTE(USB_CUSTOM_HID_CONFIG_DESC_SIZ), /* wTotalLength: Bytes returned */
|
||||||
0x00,
|
HIBYTE(USB_CUSTOM_HID_CONFIG_DESC_SIZ),
|
||||||
0x01, /* bNumInterfaces: 1 interface */
|
0x01, /* bNumInterfaces: 1 interface */
|
||||||
0x01, /* bConfigurationValue: Configuration value */
|
0x01, /* bConfigurationValue: Configuration value */
|
||||||
0x00, /* iConfiguration: Index of string descriptor
|
0x00, /* iConfiguration: Index of string descriptor
|
||||||
@@ -170,8 +170,8 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgDesc[USB_CUSTOM_HID_CONFIG_DESC_
|
|||||||
0x01, /* bNumDescriptors: Number of CUSTOM_HID class descriptors
|
0x01, /* bNumDescriptors: Number of CUSTOM_HID class descriptors
|
||||||
to follow */
|
to follow */
|
||||||
0x22, /* bDescriptorType */
|
0x22, /* bDescriptorType */
|
||||||
USBD_CUSTOM_HID_REPORT_DESC_SIZE, /* wItemLength: Total length of Report descriptor */
|
LOBYTE(USBD_CUSTOM_HID_REPORT_DESC_SIZE), /* wItemLength: Total length of Report descriptor */
|
||||||
0x00,
|
HIBYTE(USBD_CUSTOM_HID_REPORT_DESC_SIZE),
|
||||||
/******************** Descriptor of Custom HID endpoints ********************/
|
/******************** Descriptor of Custom HID endpoints ********************/
|
||||||
/* 27 */
|
/* 27 */
|
||||||
0x07, /* bLength: Endpoint Descriptor size */
|
0x07, /* bLength: Endpoint Descriptor size */
|
||||||
@@ -179,8 +179,8 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgDesc[USB_CUSTOM_HID_CONFIG_DESC_
|
|||||||
|
|
||||||
CUSTOM_HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
|
CUSTOM_HID_EPIN_ADDR, /* bEndpointAddress: Endpoint Address (IN) */
|
||||||
0x03, /* bmAttributes: Interrupt endpoint */
|
0x03, /* bmAttributes: Interrupt endpoint */
|
||||||
CUSTOM_HID_EPIN_SIZE, /* wMaxPacketSize: 2 Bytes max */
|
LOBYTE(CUSTOM_HID_EPIN_SIZE), /* wMaxPacketSize: 2 Bytes max */
|
||||||
0x00,
|
HIBYTE(CUSTOM_HID_EPIN_SIZE),
|
||||||
CUSTOM_HID_FS_BINTERVAL, /* bInterval: Polling Interval */
|
CUSTOM_HID_FS_BINTERVAL, /* bInterval: Polling Interval */
|
||||||
/* 34 */
|
/* 34 */
|
||||||
|
|
||||||
@@ -188,8 +188,8 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_CfgDesc[USB_CUSTOM_HID_CONFIG_DESC_
|
|||||||
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: */
|
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: */
|
||||||
CUSTOM_HID_EPOUT_ADDR, /* bEndpointAddress: Endpoint Address (OUT) */
|
CUSTOM_HID_EPOUT_ADDR, /* bEndpointAddress: Endpoint Address (OUT) */
|
||||||
0x03, /* bmAttributes: Interrupt endpoint */
|
0x03, /* bmAttributes: Interrupt endpoint */
|
||||||
CUSTOM_HID_EPOUT_SIZE, /* wMaxPacketSize: 2 Bytes max */
|
LOBYTE(CUSTOM_HID_EPOUT_SIZE), /* wMaxPacketSize: 2 Bytes max */
|
||||||
0x00,
|
HIBYTE(CUSTOM_HID_EPOUT_SIZE),
|
||||||
CUSTOM_HID_FS_BINTERVAL, /* bInterval: Polling Interval */
|
CUSTOM_HID_FS_BINTERVAL, /* bInterval: Polling Interval */
|
||||||
/* 41 */
|
/* 41 */
|
||||||
};
|
};
|
||||||
@@ -207,8 +207,8 @@ __ALIGN_BEGIN static uint8_t USBD_CUSTOM_HID_Desc[USB_CUSTOM_HID_DESC_SIZ] __ALI
|
|||||||
0x01, /* bNumDescriptors: Number of CUSTOM_HID class descriptors
|
0x01, /* bNumDescriptors: Number of CUSTOM_HID class descriptors
|
||||||
to follow */
|
to follow */
|
||||||
0x22, /* bDescriptorType */
|
0x22, /* bDescriptorType */
|
||||||
USBD_CUSTOM_HID_REPORT_DESC_SIZE, /* wItemLength: Total length of Report descriptor */
|
LOBYTE(USBD_CUSTOM_HID_REPORT_DESC_SIZE), /* wItemLength: Total length of Report descriptor */
|
||||||
0x00,
|
HIBYTE(USBD_CUSTOM_HID_REPORT_DESC_SIZE),
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef USE_USBD_COMPOSITE
|
#ifndef USE_USBD_COMPOSITE
|
||||||
@@ -263,8 +263,8 @@ static uint8_t USBD_CUSTOM_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
CUSTOMHIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
CUSTOMHIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
CUSTOMHIDOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_INTR);
|
CUSTOMHIDOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||||
@@ -294,9 +294,11 @@ static uint8_t USBD_CUSTOM_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->Init();
|
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->Init();
|
||||||
|
|
||||||
|
#ifndef USBD_CUSTOMHID_OUT_PREPARE_RECEIVE_DISABLED
|
||||||
/* Prepare Out endpoint to receive 1st packet */
|
/* Prepare Out endpoint to receive 1st packet */
|
||||||
(void)USBD_LL_PrepareReceive(pdev, CUSTOMHIDOutEpAdd, hhid->Report_buf,
|
(void)USBD_LL_PrepareReceive(pdev, CUSTOMHIDOutEpAdd, hhid->Report_buf,
|
||||||
USBD_CUSTOMHID_OUTREPORT_BUF_SIZE);
|
USBD_CUSTOMHID_OUTREPORT_BUF_SIZE);
|
||||||
|
#endif /* USBD_CUSTOMHID_OUT_PREPARE_RECEIVE_DISABLED */
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
@@ -314,8 +316,8 @@ static uint8_t USBD_CUSTOM_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
CUSTOMHIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
CUSTOMHIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
CUSTOMHIDOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_INTR);
|
CUSTOMHIDOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Close CUSTOM_HID EP IN */
|
/* Close CUSTOM_HID EP IN */
|
||||||
@@ -352,6 +354,9 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
{
|
{
|
||||||
USBD_CUSTOM_HID_HandleTypeDef *hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_CUSTOM_HID_HandleTypeDef *hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
uint16_t len = 0U;
|
uint16_t len = 0U;
|
||||||
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED
|
||||||
|
uint16_t ReportLength = 0U;
|
||||||
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED */
|
||||||
uint8_t *pbuf = NULL;
|
uint8_t *pbuf = NULL;
|
||||||
uint16_t status_info = 0U;
|
uint16_t status_info = 0U;
|
||||||
USBD_StatusTypeDef ret = USBD_OK;
|
USBD_StatusTypeDef ret = USBD_OK;
|
||||||
@@ -383,10 +388,59 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CUSTOM_HID_REQ_SET_REPORT:
|
case CUSTOM_HID_REQ_SET_REPORT:
|
||||||
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
|
||||||
|
if (((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->CtrlReqComplete != NULL)
|
||||||
|
{
|
||||||
|
/* Let the application decide when to enable EP0 to receive the next report */
|
||||||
|
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->CtrlReqComplete(req->bRequest,
|
||||||
|
req->wLength);
|
||||||
|
}
|
||||||
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
||||||
|
#ifndef USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED
|
||||||
hhid->IsReportAvailable = 1U;
|
hhid->IsReportAvailable = 1U;
|
||||||
(void)USBD_CtlPrepareRx(pdev, hhid->Report_buf,
|
(void)USBD_CtlPrepareRx(pdev, hhid->Report_buf,
|
||||||
MIN(req->wLength, USBD_CUSTOMHID_OUTREPORT_BUF_SIZE));
|
MIN(req->wLength, USBD_CUSTOMHID_OUTREPORT_BUF_SIZE));
|
||||||
|
#endif /* USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED */
|
||||||
break;
|
break;
|
||||||
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED
|
||||||
|
case CUSTOM_HID_REQ_GET_REPORT:
|
||||||
|
if (((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->GetReport != NULL)
|
||||||
|
{
|
||||||
|
ReportLength = req->wLength;
|
||||||
|
|
||||||
|
/* Get report data buffer */
|
||||||
|
pbuf = ((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->GetReport(&ReportLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((pbuf != NULL) && (ReportLength != 0U))
|
||||||
|
{
|
||||||
|
len = MIN(ReportLength, req->wLength);
|
||||||
|
|
||||||
|
/* Send the report data over EP0 */
|
||||||
|
(void)USBD_CtlSendData(pdev, pbuf, len);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
|
||||||
|
if (((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->CtrlReqComplete != NULL)
|
||||||
|
{
|
||||||
|
/* Let the application decide what to do, keep EP0 data phase in NAK state and
|
||||||
|
use USBD_CtlSendData() when data become available or stall the EP0 data phase */
|
||||||
|
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->CtrlReqComplete(req->bRequest,
|
||||||
|
req->wLength);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Stall EP0 if no data available */
|
||||||
|
USBD_CtlError(pdev, req);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* Stall EP0 if no data available */
|
||||||
|
USBD_CtlError(pdev, req);
|
||||||
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
@@ -425,7 +479,15 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pbuf != NULL)
|
||||||
|
{
|
||||||
(void)USBD_CtlSendData(pdev, pbuf, len);
|
(void)USBD_CtlSendData(pdev, pbuf, len);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
USBD_CtlError(pdev, req);
|
||||||
|
ret = USBD_FAIL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case USB_REQ_GET_INTERFACE:
|
case USB_REQ_GET_INTERFACE:
|
||||||
@@ -475,25 +537,31 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev,
|
|||||||
* Send CUSTOM_HID Report
|
* Send CUSTOM_HID Report
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param buff: pointer to report
|
* @param buff: pointer to report
|
||||||
|
* @param ClassId: The Class ID
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_CUSTOM_HID_SendReport(USBD_HandleTypeDef *pdev,
|
||||||
|
uint8_t *report, uint16_t len, uint8_t ClassId)
|
||||||
|
{
|
||||||
|
USBD_CUSTOM_HID_HandleTypeDef *hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
|
||||||
|
#else
|
||||||
uint8_t USBD_CUSTOM_HID_SendReport(USBD_HandleTypeDef *pdev,
|
uint8_t USBD_CUSTOM_HID_SendReport(USBD_HandleTypeDef *pdev,
|
||||||
uint8_t *report, uint16_t len)
|
uint8_t *report, uint16_t len)
|
||||||
{
|
{
|
||||||
USBD_CUSTOM_HID_HandleTypeDef *hhid;
|
USBD_CUSTOM_HID_HandleTypeDef *hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
|
if (hhid == NULL)
|
||||||
{
|
{
|
||||||
return (uint8_t)USBD_FAIL;
|
return (uint8_t)USBD_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get Endpoint IN address allocated for this class instance */
|
/* Get Endpoint IN address allocated for this class instance */
|
||||||
CUSTOMHIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
CUSTOMHIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, ClassId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
|
||||||
|
|
||||||
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
||||||
{
|
{
|
||||||
if (hhid->state == CUSTOM_HID_IDLE)
|
if (hhid->state == CUSTOM_HID_IDLE)
|
||||||
@@ -657,7 +725,7 @@ uint8_t USBD_CUSTOM_HID_ReceivePacket(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get OUT Endpoint address allocated for this class instance */
|
/* Get OUT Endpoint address allocated for this class instance */
|
||||||
CUSTOMHIDOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_INTR);
|
CUSTOMHIDOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
|||||||
@@ -33,6 +33,14 @@ EndBSPDependencies */
|
|||||||
static int8_t TEMPLATE_CUSTOM_HID_Init(void);
|
static int8_t TEMPLATE_CUSTOM_HID_Init(void);
|
||||||
static int8_t TEMPLATE_CUSTOM_HID_DeInit(void);
|
static int8_t TEMPLATE_CUSTOM_HID_DeInit(void);
|
||||||
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t event_idx, uint8_t state);
|
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t event_idx, uint8_t state);
|
||||||
|
|
||||||
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
|
||||||
|
static int8_t TEMPLATE_CUSTOM_HID_CtrlReqComplete(uint8_t request, uint16_t wLength);
|
||||||
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
||||||
|
|
||||||
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED
|
||||||
|
static uint8_t *TEMPLATE_CUSTOM_HID_GetReport(uint16_t *ReportLength);
|
||||||
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED */
|
||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
extern USBD_HandleTypeDef USBD_Device;
|
extern USBD_HandleTypeDef USBD_Device;
|
||||||
|
|
||||||
@@ -44,6 +52,12 @@ USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_template_fops =
|
|||||||
TEMPLATE_CUSTOM_HID_Init,
|
TEMPLATE_CUSTOM_HID_Init,
|
||||||
TEMPLATE_CUSTOM_HID_DeInit,
|
TEMPLATE_CUSTOM_HID_DeInit,
|
||||||
TEMPLATE_CUSTOM_HID_OutEvent,
|
TEMPLATE_CUSTOM_HID_OutEvent,
|
||||||
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
|
||||||
|
TEMPLATE_CUSTOM_HID_CtrlReqComplete,
|
||||||
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
||||||
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED
|
||||||
|
TEMPLATE_CUSTOM_HID_GetReport,
|
||||||
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
/* Private functions ---------------------------------------------------------*/
|
||||||
@@ -95,3 +109,50 @@ static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t event_idx, uint8_t state)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
|
||||||
|
/**
|
||||||
|
* @brief TEMPLATE_CUSTOM_HID_CtrlReqComplete
|
||||||
|
* Manage the CUSTOM HID control request complete
|
||||||
|
* @param request: control request
|
||||||
|
* @param wLength: request wLength
|
||||||
|
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
||||||
|
*/
|
||||||
|
static int8_t TEMPLATE_CUSTOM_HID_CtrlReqComplete(uint8_t request, uint16_t wLength)
|
||||||
|
{
|
||||||
|
UNUSED(wLength);
|
||||||
|
|
||||||
|
switch (request)
|
||||||
|
{
|
||||||
|
case CUSTOM_HID_REQ_SET_REPORT:
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CUSTOM_HID_REQ_GET_REPORT:
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED
|
||||||
|
/**
|
||||||
|
* @brief TEMPLATE_CUSTOM_HID_GetReport
|
||||||
|
* Manage the CUSTOM HID control Get Report request
|
||||||
|
* @param event_idx: event index
|
||||||
|
* @param state: event state
|
||||||
|
* @retval return pointer to HID report
|
||||||
|
*/
|
||||||
|
static uint8_t *TEMPLATE_CUSTOM_HID_GetReport(uint16_t *ReportLength)
|
||||||
|
{
|
||||||
|
UNUSED(ReportLength);
|
||||||
|
uint8_t *pbuff;
|
||||||
|
|
||||||
|
return (pbuff);
|
||||||
|
}
|
||||||
|
#endif /* USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED */
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define DFU_DESCRIPTOR_TYPE 0x21U
|
#define DFU_DESCRIPTOR_TYPE 0x21U
|
||||||
|
|
||||||
|
#define DFU_VENDOR_CMD_MAX 32U
|
||||||
|
|
||||||
|
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
/* DFU Requests DFU states */
|
/* DFU Requests DFU states */
|
||||||
@@ -126,6 +128,11 @@ extern "C" {
|
|||||||
#define DFU_MANIFEST_MASK (1U << 2)
|
#define DFU_MANIFEST_MASK (1U << 2)
|
||||||
#define DFU_STATUS_DEPTH 6U
|
#define DFU_STATUS_DEPTH 6U
|
||||||
|
|
||||||
|
#define IS_DFU_DOWNLOAD 0x0DFDFU
|
||||||
|
#define IS_DFU_UPLOAD 0x1DFDFU
|
||||||
|
#define IS_DFU_SETADDRESSPOINTER 0x2DFDFU
|
||||||
|
#define IS_DFU_PHY_ADDRESS 0x3DFDFU
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
DFU_DETACH = 0U,
|
DFU_DETACH = 0U,
|
||||||
@@ -176,6 +183,7 @@ typedef struct
|
|||||||
uint32_t wblock_num;
|
uint32_t wblock_num;
|
||||||
uint32_t wlength;
|
uint32_t wlength;
|
||||||
uint32_t data_ptr;
|
uint32_t data_ptr;
|
||||||
|
uint32_t app_addr_ptr;
|
||||||
uint32_t alt_setting;
|
uint32_t alt_setting;
|
||||||
|
|
||||||
uint8_t dev_status[DFU_STATUS_DEPTH];
|
uint8_t dev_status[DFU_STATUS_DEPTH];
|
||||||
@@ -193,6 +201,17 @@ typedef struct
|
|||||||
uint16_t (* Write)(uint8_t *src, uint8_t *dest, uint32_t Len);
|
uint16_t (* Write)(uint8_t *src, uint8_t *dest, uint32_t Len);
|
||||||
uint8_t *(* Read)(uint8_t *src, uint8_t *dest, uint32_t Len);
|
uint8_t *(* Read)(uint8_t *src, uint8_t *dest, uint32_t Len);
|
||||||
uint16_t (* GetStatus)(uint32_t Add, uint8_t cmd, uint8_t *buff);
|
uint16_t (* GetStatus)(uint32_t Add, uint8_t cmd, uint8_t *buff);
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
uint16_t (* GetVendorCMD)(uint8_t *cmd, uint8_t *cmdlength);
|
||||||
|
uint16_t (* VendorDownloadCMD)(uint8_t *pbuf, uint32_t BlockNumber, uint32_t wlength, uint32_t *status);
|
||||||
|
uint16_t (* VendorUploadCMD)(uint32_t Add, uint32_t BlockNumber, uint32_t *status);
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
uint16_t (* VendorCheck)(uint8_t *pbuf, uint32_t ReqType, uint32_t *status);
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
#if (USBD_DFU_VENDOR_EXIT_ENABLED == 1U)
|
||||||
|
uint16_t (* LeaveDFU)(uint32_t Add);
|
||||||
|
#endif /* USBD_DFU_VENDOR_EXIT_ENABLED */
|
||||||
} USBD_DFU_MediaTypeDef;
|
} USBD_DFU_MediaTypeDef;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
@@ -512,6 +512,7 @@ static uint8_t USBD_DFU_EP0_RxReady(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_DFU_EP0_TxReady
|
* @brief USBD_DFU_EP0_TxReady
|
||||||
* handle EP0 TRx Ready event
|
* handle EP0 TRx Ready event
|
||||||
@@ -521,9 +522,13 @@ static uint8_t USBD_DFU_EP0_RxReady(USBD_HandleTypeDef *pdev)
|
|||||||
static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_SetupReqTypedef req;
|
USBD_SetupReqTypedef req;
|
||||||
|
uint32_t app_addr_ptr;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
USBD_DFU_HandleTypeDef *hdfu = (USBD_DFU_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_DFU_HandleTypeDef *hdfu = (USBD_DFU_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
USBD_DFU_MediaTypeDef *DfuInterface = (USBD_DFU_MediaTypeDef *)pdev->pUserData[pdev->classId];
|
USBD_DFU_MediaTypeDef *DfuInterface = (USBD_DFU_MediaTypeDef *)pdev->pUserData[pdev->classId];
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U) || (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
uint32_t VendorStatus = 0U;
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
|
||||||
if (hdfu == NULL)
|
if (hdfu == NULL)
|
||||||
{
|
{
|
||||||
@@ -541,11 +546,43 @@ static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
|||||||
{
|
{
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
}
|
}
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Vendor specific DFU CMD */
|
||||||
|
if (DfuInterface->VendorDownloadCMD(hdfu->buffer.d8, hdfu->wblock_num,
|
||||||
|
hdfu->wlength, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
}
|
}
|
||||||
else if (hdfu->wlength == 5U)
|
else if (hdfu->wlength == 5U)
|
||||||
{
|
{
|
||||||
if (hdfu->buffer.d8[0] == DFU_CMD_SETADDRESSPOINTER)
|
if (hdfu->buffer.d8[0] == DFU_CMD_SETADDRESSPOINTER)
|
||||||
{
|
{
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
if (DfuInterface->VendorCheck(hdfu->buffer.d8, IS_DFU_SETADDRESSPOINTER, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
|
||||||
hdfu->data_ptr = hdfu->buffer.d8[1];
|
hdfu->data_ptr = hdfu->buffer.d8[1];
|
||||||
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[2] << 8;
|
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[2] << 8;
|
||||||
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[3] << 16;
|
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[3] << 16;
|
||||||
@@ -553,43 +590,148 @@ static uint8_t USBD_DFU_EP0_TxReady(USBD_HandleTypeDef *pdev)
|
|||||||
}
|
}
|
||||||
else if (hdfu->buffer.d8[0] == DFU_CMD_ERASE)
|
else if (hdfu->buffer.d8[0] == DFU_CMD_ERASE)
|
||||||
{
|
{
|
||||||
hdfu->data_ptr = hdfu->buffer.d8[1];
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[2] << 8;
|
if (DfuInterface->VendorCheck(hdfu->buffer.d8, IS_DFU_DOWNLOAD, &VendorStatus) != USBD_OK)
|
||||||
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[3] << 16;
|
{
|
||||||
hdfu->data_ptr += (uint32_t)hdfu->buffer.d8[4] << 24;
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
|
||||||
if (DfuInterface->Erase(hdfu->data_ptr) != USBD_OK)
|
app_addr_ptr = hdfu->buffer.d8[1];
|
||||||
|
app_addr_ptr += (uint32_t)hdfu->buffer.d8[2] << 8;
|
||||||
|
app_addr_ptr += (uint32_t)hdfu->buffer.d8[3] << 16;
|
||||||
|
app_addr_ptr += (uint32_t)hdfu->buffer.d8[4] << 24;
|
||||||
|
|
||||||
|
if (DfuInterface->Erase(app_addr_ptr) != USBD_OK)
|
||||||
{
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = DFU_ERROR_VENDOR;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Vendor specific DFU CMD */
|
||||||
|
if (DfuInterface->VendorDownloadCMD(hdfu->buffer.d8, hdfu->wblock_num,
|
||||||
|
hdfu->wlength, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
if (hdfu->wlength > 0U)
|
||||||
|
{
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
if (DfuInterface->VendorCheck(hdfu->buffer.d8, IS_DFU_DOWNLOAD, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
|
||||||
|
/* Vendor specific DFU CMD */
|
||||||
|
if (DfuInterface->VendorDownloadCMD(hdfu->buffer.d8, hdfu->wblock_num,
|
||||||
|
hdfu->wlength, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
return (uint8_t)USBD_FAIL;
|
return (uint8_t)USBD_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return (uint8_t)USBD_FAIL;
|
/* Reset the block number */
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Reset the global length and block number */
|
|
||||||
hdfu->wlength = 0U;
|
|
||||||
hdfu->wblock_num = 0U;
|
hdfu->wblock_num = 0U;
|
||||||
|
|
||||||
/* Call the error management function (command will be NAKed) */
|
/* Call the error management function (command will be NAKed) */
|
||||||
req.bmRequest = 0U;
|
req.bmRequest = 0U;
|
||||||
req.wLength = 1U;
|
req.wLength = 1U;
|
||||||
USBD_CtlError(pdev, &req);
|
USBD_CtlError(pdev, &req);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
/* Reset the global length and block number */
|
||||||
|
hdfu->wlength = 0U;
|
||||||
|
hdfu->wblock_num = 0U;
|
||||||
|
|
||||||
|
/* Call the error management function (command will be NAKed) */
|
||||||
|
req.bmRequest = 0U;
|
||||||
|
req.wLength = 1U;
|
||||||
|
USBD_CtlError(pdev, &req);
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Regular Download Command */
|
/* Regular Download Command */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (hdfu->wblock_num > 1U)
|
if (hdfu->wblock_num > 1U)
|
||||||
{
|
{
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
if (DfuInterface->VendorCheck(hdfu->buffer.d8, IS_DFU_DOWNLOAD, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
return (uint8_t)USBD_FAIL;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
|
||||||
/* Decode the required address */
|
/* Decode the required address */
|
||||||
addr = ((hdfu->wblock_num - 2U) * USBD_DFU_XFER_SIZE) + hdfu->data_ptr;
|
addr = ((hdfu->wblock_num - 2U) * USBD_DFU_XFER_SIZE) + hdfu->data_ptr;
|
||||||
|
|
||||||
/* Perform the write operation */
|
/* Perform the write operation */
|
||||||
if (DfuInterface->Write(hdfu->buffer.d8, (uint8_t *)addr, hdfu->wlength) != USBD_OK)
|
if (DfuInterface->Write(hdfu->buffer.d8, (uint8_t *)addr, hdfu->wlength) != USBD_OK)
|
||||||
{
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = DFU_ERROR_VENDOR;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
return (uint8_t)USBD_FAIL;
|
return (uint8_t)USBD_FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -670,7 +812,7 @@ static uint8_t *USBD_DFU_GetUsrStringDesc(USBD_HandleTypeDef *pdev, uint8_t inde
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Not supported Interface Descriptor index */
|
/* Not supported Interface Descriptor index */
|
||||||
length = 0U;
|
*length = 0U;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -758,6 +900,11 @@ static void DFU_Download(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
{
|
{
|
||||||
USBD_DFU_HandleTypeDef *hdfu = (USBD_DFU_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_DFU_HandleTypeDef *hdfu = (USBD_DFU_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
USBD_DFU_MediaTypeDef *DfuInterface = (USBD_DFU_MediaTypeDef *)pdev->pUserData[pdev->classId];
|
||||||
|
uint32_t VendorStatus = 0U;
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
|
||||||
if (hdfu == NULL)
|
if (hdfu == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -792,6 +939,20 @@ static void DFU_Download(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
/* End of DNLOAD operation */
|
/* End of DNLOAD operation */
|
||||||
if ((hdfu->dev_state == DFU_STATE_DNLOAD_IDLE) || (hdfu->dev_state == DFU_STATE_IDLE))
|
if ((hdfu->dev_state == DFU_STATE_DNLOAD_IDLE) || (hdfu->dev_state == DFU_STATE_IDLE))
|
||||||
{
|
{
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
if (DfuInterface->VendorCheck(hdfu->buffer.d8, IS_DFU_SETADDRESSPOINTER, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_STATE_ERROR;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
{
|
||||||
hdfu->manif_state = DFU_MANIFEST_IN_PROGRESS;
|
hdfu->manif_state = DFU_MANIFEST_IN_PROGRESS;
|
||||||
hdfu->dev_state = DFU_STATE_MANIFEST_SYNC;
|
hdfu->dev_state = DFU_STATE_MANIFEST_SYNC;
|
||||||
hdfu->dev_status[1] = 0U;
|
hdfu->dev_status[1] = 0U;
|
||||||
@@ -799,6 +960,7 @@ static void DFU_Download(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
hdfu->dev_status[3] = 0U;
|
hdfu->dev_status[3] = 0U;
|
||||||
hdfu->dev_status[4] = hdfu->dev_state;
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Call the error management function (command will be NAKed */
|
/* Call the error management function (command will be NAKed */
|
||||||
@@ -820,6 +982,13 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
USBD_DFU_MediaTypeDef *DfuInterface = (USBD_DFU_MediaTypeDef *)pdev->pUserData[pdev->classId];
|
USBD_DFU_MediaTypeDef *DfuInterface = (USBD_DFU_MediaTypeDef *)pdev->pUserData[pdev->classId];
|
||||||
uint8_t *phaddr;
|
uint8_t *phaddr;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
|
uint32_t CmdLength;
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
uint32_t VendorStatus = 0U;
|
||||||
|
uint8_t VendorCmdLength = 0U;
|
||||||
|
uint8_t VendorCmdBuffer[DFU_VENDOR_CMD_MAX];
|
||||||
|
uint8_t idx;
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
|
||||||
if (hdfu == NULL)
|
if (hdfu == NULL)
|
||||||
{
|
{
|
||||||
@@ -851,8 +1020,24 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
hdfu->buffer.d8[1] = DFU_CMD_SETADDRESSPOINTER;
|
hdfu->buffer.d8[1] = DFU_CMD_SETADDRESSPOINTER;
|
||||||
hdfu->buffer.d8[2] = DFU_CMD_ERASE;
|
hdfu->buffer.d8[2] = DFU_CMD_ERASE;
|
||||||
|
|
||||||
|
CmdLength = 3U;
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
if (DfuInterface->GetVendorCMD != NULL)
|
||||||
|
{
|
||||||
|
(void)DfuInterface->GetVendorCMD(VendorCmdBuffer, (uint8_t *)&VendorCmdLength);
|
||||||
|
|
||||||
|
for (idx = 0U; idx < MIN(VendorCmdLength, DFU_VENDOR_CMD_MAX); idx++)
|
||||||
|
{
|
||||||
|
hdfu->buffer.d8[idx + 3U] = VendorCmdBuffer[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
CmdLength += MIN(VendorCmdLength, DFU_VENDOR_CMD_MAX);
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
|
||||||
/* Send the status data over EP0 */
|
/* Send the status data over EP0 */
|
||||||
(void)USBD_CtlSendData(pdev, (uint8_t *)(&(hdfu->buffer.d8[0])), 3U);
|
(void)USBD_CtlSendData(pdev, (uint8_t *)(&(hdfu->buffer.d8[0])), CmdLength);
|
||||||
}
|
}
|
||||||
else if (hdfu->wblock_num > 1U)
|
else if (hdfu->wblock_num > 1U)
|
||||||
{
|
{
|
||||||
@@ -863,14 +1048,49 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
hdfu->dev_status[3] = 0U;
|
hdfu->dev_status[3] = 0U;
|
||||||
hdfu->dev_status[4] = hdfu->dev_state;
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
/* Vendor specific DFU CMD */
|
||||||
|
if (DfuInterface->VendorUploadCMD(hdfu->data_ptr, hdfu->wblock_num, &VendorStatus) != USBD_OK)
|
||||||
|
{
|
||||||
|
/* Update the state machine */
|
||||||
|
hdfu->dev_state = DFU_ERROR_STALLEDPKT;
|
||||||
|
hdfu->dev_status[0] = (uint8_t)VendorStatus;
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
|
||||||
|
/* Call the error management function (command will be NAKed) */
|
||||||
|
USBD_CtlError(pdev, req);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VendorStatus == IS_DFU_PHY_ADDRESS)
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
{
|
||||||
addr = ((hdfu->wblock_num - 2U) * USBD_DFU_XFER_SIZE) + hdfu->data_ptr;
|
addr = ((hdfu->wblock_num - 2U) * USBD_DFU_XFER_SIZE) + hdfu->data_ptr;
|
||||||
|
|
||||||
/* Return the physical address where data are stored */
|
/* Return the physical address where data are stored */
|
||||||
phaddr = DfuInterface->Read((uint8_t *)addr, hdfu->buffer.d8, hdfu->wlength);
|
phaddr = DfuInterface->Read((uint8_t *)addr, hdfu->buffer.d8, hdfu->wlength);
|
||||||
|
|
||||||
|
if (phaddr == NULL)
|
||||||
|
{
|
||||||
|
hdfu->dev_state = DFU_ERROR_STALLEDPKT;
|
||||||
|
|
||||||
|
hdfu->dev_status[1] = 0U;
|
||||||
|
hdfu->dev_status[2] = 0U;
|
||||||
|
hdfu->dev_status[3] = 0U;
|
||||||
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
|
||||||
|
/* Call the error management function (command will be NAKed) */
|
||||||
|
USBD_CtlError(pdev, req);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* Send the status data over EP0 */
|
/* Send the status data over EP0 */
|
||||||
(void)USBD_CtlSendData(pdev, phaddr, hdfu->wlength);
|
(void)USBD_CtlSendData(pdev, phaddr, hdfu->wlength);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else /* unsupported hdfu->wblock_num */
|
else /* unsupported hdfu->wblock_num */
|
||||||
{
|
{
|
||||||
hdfu->dev_state = DFU_ERROR_STALLEDPKT;
|
hdfu->dev_state = DFU_ERROR_STALLEDPKT;
|
||||||
@@ -880,7 +1100,7 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
hdfu->dev_status[3] = 0U;
|
hdfu->dev_status[3] = 0U;
|
||||||
hdfu->dev_status[4] = hdfu->dev_state;
|
hdfu->dev_status[4] = hdfu->dev_state;
|
||||||
|
|
||||||
/* Call the error management function (command will be NAKed */
|
/* Call the error management function (command will be NAKed) */
|
||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -890,7 +1110,7 @@ static void DFU_Upload(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
hdfu->wlength = 0U;
|
hdfu->wlength = 0U;
|
||||||
hdfu->wblock_num = 0U;
|
hdfu->wblock_num = 0U;
|
||||||
|
|
||||||
/* Call the error management function (command will be NAKed */
|
/* Call the error management function (command will be NAKed) */
|
||||||
USBD_CtlError(pdev, req);
|
USBD_CtlError(pdev, req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -944,7 +1164,7 @@ static void DFU_GetStatus(USBD_HandleTypeDef *pdev)
|
|||||||
DfuInterface->GetStatus(hdfu->data_ptr, DFU_MEDIA_PROGRAM, hdfu->dev_status);
|
DfuInterface->GetStatus(hdfu->data_ptr, DFU_MEDIA_PROGRAM, hdfu->dev_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* (hdfu->wlength==0)*/
|
else /* (hdfu->wlength == 0U) */
|
||||||
{
|
{
|
||||||
hdfu->dev_state = DFU_STATE_DNLOAD_IDLE;
|
hdfu->dev_state = DFU_STATE_DNLOAD_IDLE;
|
||||||
|
|
||||||
@@ -1088,9 +1308,10 @@ static void DFU_Abort(USBD_HandleTypeDef *pdev)
|
|||||||
static void DFU_Leave(USBD_HandleTypeDef *pdev)
|
static void DFU_Leave(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_DFU_HandleTypeDef *hdfu = (USBD_DFU_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_DFU_HandleTypeDef *hdfu = (USBD_DFU_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
USBD_DFU_MediaTypeDef *DfuInterface = (USBD_DFU_MediaTypeDef *)pdev->pUserData[pdev->classId];
|
||||||
USBD_DFUFuncDescTypeDef *pDfuFunc = (USBD_DFUFuncDescTypeDef *)USBD_DFU_GetDfuFuncDesc(pdev->pConfDesc);
|
USBD_DFUFuncDescTypeDef *pDfuFunc = (USBD_DFUFuncDescTypeDef *)USBD_DFU_GetDfuFuncDesc(pdev->pConfDesc);
|
||||||
|
|
||||||
if ((hdfu == NULL) || (pDfuFunc == NULL))
|
if ((hdfu == NULL) || (DfuInterface == NULL) || (pDfuFunc == NULL))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1119,8 +1340,13 @@ static void DFU_Leave(USBD_HandleTypeDef *pdev)
|
|||||||
/* Disconnect the USB device */
|
/* Disconnect the USB device */
|
||||||
(void)USBD_Stop(pdev);
|
(void)USBD_Stop(pdev);
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_EXIT_ENABLED == 1U)
|
||||||
|
/* Jump should be ensured by user application */
|
||||||
|
DfuInterface->LeaveDFU(hdfu->data_ptr);
|
||||||
|
#else
|
||||||
/* Generate system reset to allow jumping to the user code */
|
/* Generate system reset to allow jumping to the user code */
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
|
#endif /* USBD_DFU_VENDOR_EXIT_ENABLED */
|
||||||
|
|
||||||
/* The next instructions will not be reached (system reset) */
|
/* The next instructions will not be reached (system reset) */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,17 @@ uint16_t MEM_If_Write(uint8_t *src, uint8_t *dest, uint32_t Len);
|
|||||||
uint8_t *MEM_If_Read(uint8_t *src, uint8_t *dest, uint32_t Len);
|
uint8_t *MEM_If_Read(uint8_t *src, uint8_t *dest, uint32_t Len);
|
||||||
uint16_t MEM_If_DeInit(void);
|
uint16_t MEM_If_DeInit(void);
|
||||||
uint16_t MEM_If_GetStatus(uint32_t Add, uint8_t Cmd, uint8_t *buffer);
|
uint16_t MEM_If_GetStatus(uint32_t Add, uint8_t Cmd, uint8_t *buffer);
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
uint16_t MEM_If_GetVendorCMD(uint8_t *cmd, uint8_t *cmdlength);
|
||||||
|
uint16_t MEM_If_VendorDownloadCMD(uint8_t *pbuf, uint32_t BlockNumber, uint32_t wlength, uint32_t *status);
|
||||||
|
uint16_t MEM_If_VendorUploadCMD(uint32_t Add, uint32_t BlockNumber, uint32_t *status);
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
uint16_t MEM_If_VendorCheck(uint8_t *pbuf, uint32_t ReqType, uint32_t *status);
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
#if (USBD_DFU_VENDOR_EXIT_ENABLED == 1U)
|
||||||
|
uint16_t MEM_If_LeaveDFU(uint32_t Add);
|
||||||
|
#endif /* USBD_DFU_VENDOR_EXIT_ENABLED */
|
||||||
|
|
||||||
USBD_DFU_MediaTypeDef USBD_DFU_MEDIA_Template_fops =
|
USBD_DFU_MediaTypeDef USBD_DFU_MEDIA_Template_fops =
|
||||||
{
|
{
|
||||||
@@ -48,8 +59,19 @@ USBD_DFU_MediaTypeDef USBD_DFU_MEDIA_Template_fops =
|
|||||||
MEM_If_Write,
|
MEM_If_Write,
|
||||||
MEM_If_Read,
|
MEM_If_Read,
|
||||||
MEM_If_GetStatus,
|
MEM_If_GetStatus,
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
MEM_If_GetVendorCMD,
|
||||||
|
MEM_If_VendorDownloadCMD,
|
||||||
|
MEM_If_VendorUploadCMD,
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
MEM_If_VendorCheck,
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
#if (USBD_DFU_VENDOR_EXIT_ENABLED == 1U)
|
||||||
|
MEM_If_LeaveDFU
|
||||||
|
#endif /* USBD_DFU_VENDOR_EXIT_ENABLED */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MEM_If_Init
|
* @brief MEM_If_Init
|
||||||
* Memory initialization routine.
|
* Memory initialization routine.
|
||||||
@@ -115,7 +137,7 @@ uint8_t *MEM_If_Read(uint8_t *src, uint8_t *dest, uint32_t Len)
|
|||||||
UNUSED(Len);
|
UNUSED(Len);
|
||||||
|
|
||||||
/* Return a valid address to avoid HardFault */
|
/* Return a valid address to avoid HardFault */
|
||||||
return (uint8_t *)(0);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,3 +166,85 @@ uint16_t MEM_If_GetStatus(uint32_t Add, uint8_t Cmd, uint8_t *buffer)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_CMD_ENABLED == 1U)
|
||||||
|
/**
|
||||||
|
* @brief Get supported vendor specific commands
|
||||||
|
* @param pointer to supported vendor commands
|
||||||
|
* @param pointer to length of supported vendor commands
|
||||||
|
* @retval 0 if operation is successful
|
||||||
|
*/
|
||||||
|
uint16_t MEM_If_GetVendorCMD(uint8_t *cmd, uint8_t *cmdlength)
|
||||||
|
{
|
||||||
|
UNUSED(cmd);
|
||||||
|
UNUSED(cmdlength);
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Vendor specific download commands
|
||||||
|
* @param pbuf DFU data buffer
|
||||||
|
* @param BlockNumber DFU memory block number
|
||||||
|
* @param wLength DFU request length
|
||||||
|
* @param pointer to DFU status
|
||||||
|
* @retval 0 if operation is successful
|
||||||
|
*/
|
||||||
|
uint16_t MEM_If_VendorDownloadCMD(uint8_t *pbuf, uint32_t BlockNumber, uint32_t wlength, uint32_t *status)
|
||||||
|
{
|
||||||
|
UNUSED(pbuf);
|
||||||
|
UNUSED(BlockNumber);
|
||||||
|
UNUSED(wlength);
|
||||||
|
UNUSED(status);
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Vendor specific upload commands
|
||||||
|
* @param Add memory Address
|
||||||
|
* @param BlockNumber DFU memory block number
|
||||||
|
* @param pointer to DFU status
|
||||||
|
* @retval 0 if operation is successful
|
||||||
|
*/
|
||||||
|
uint16_t MEM_If_VendorUploadCMD(uint32_t Add, uint32_t BlockNumber, uint32_t *status)
|
||||||
|
{
|
||||||
|
UNUSED(Add);
|
||||||
|
UNUSED(BlockNumber);
|
||||||
|
UNUSED(status);
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CMD_ENABLED */
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
|
||||||
|
/**
|
||||||
|
* @brief Vendor memory check
|
||||||
|
* @param pbuf DFU data buffer
|
||||||
|
* @param ReqType IS_DFU_SETADDRESSPOINTER/DOWNLOAD/UPLOAD
|
||||||
|
* @param pointer to DFU status
|
||||||
|
* @retval 0 if operation is successful
|
||||||
|
*/
|
||||||
|
uint16_t MEM_If_VendorCheck(uint8_t *pbuf, uint32_t ReqType, uint32_t *status)
|
||||||
|
{
|
||||||
|
UNUSED(pbuf);
|
||||||
|
UNUSED(ReqType);
|
||||||
|
UNUSED(status);
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_CHECK_ENABLED */
|
||||||
|
|
||||||
|
#if (USBD_DFU_VENDOR_EXIT_ENABLED == 1U)
|
||||||
|
/**
|
||||||
|
* @brief Vendor Leave DFU
|
||||||
|
* @param Application address
|
||||||
|
* @retval 0 if operation is successful
|
||||||
|
*/
|
||||||
|
uint16_t MEM_If_LeaveDFU(uint32_t Add)
|
||||||
|
{
|
||||||
|
UNUSED(Add);
|
||||||
|
|
||||||
|
return 0U;
|
||||||
|
}
|
||||||
|
#endif /* USBD_DFU_VENDOR_EXIT_ENABLED */
|
||||||
|
|||||||
@@ -60,14 +60,14 @@ extern "C" {
|
|||||||
#define HID_FS_BINTERVAL 0x0AU
|
#define HID_FS_BINTERVAL 0x0AU
|
||||||
#endif /* HID_FS_BINTERVAL */
|
#endif /* HID_FS_BINTERVAL */
|
||||||
|
|
||||||
#define HID_REQ_SET_PROTOCOL 0x0BU
|
#define USBD_HID_REQ_SET_PROTOCOL 0x0BU
|
||||||
#define HID_REQ_GET_PROTOCOL 0x03U
|
#define USBD_HID_REQ_GET_PROTOCOL 0x03U
|
||||||
|
|
||||||
#define HID_REQ_SET_IDLE 0x0AU
|
#define USBD_HID_REQ_SET_IDLE 0x0AU
|
||||||
#define HID_REQ_GET_IDLE 0x02U
|
#define USBD_HID_REQ_GET_IDLE 0x02U
|
||||||
|
|
||||||
#define HID_REQ_SET_REPORT 0x09U
|
#define USBD_HID_REQ_SET_REPORT 0x09U
|
||||||
#define HID_REQ_GET_REPORT 0x01U
|
#define USBD_HID_REQ_GET_REPORT 0x01U
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
@@ -78,9 +78,9 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
HID_IDLE = 0,
|
USBD_HID_IDLE = 0,
|
||||||
HID_BUSY,
|
USBD_HID_BUSY,
|
||||||
} HID_StateTypeDef;
|
} USBD_HID_StateTypeDef;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -88,7 +88,7 @@ typedef struct
|
|||||||
uint32_t Protocol;
|
uint32_t Protocol;
|
||||||
uint32_t IdleState;
|
uint32_t IdleState;
|
||||||
uint32_t AltSetting;
|
uint32_t AltSetting;
|
||||||
HID_StateTypeDef state;
|
USBD_HID_StateTypeDef state;
|
||||||
} USBD_HID_HandleTypeDef;
|
} USBD_HID_HandleTypeDef;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -134,7 +134,11 @@ extern USBD_ClassTypeDef USBD_HID;
|
|||||||
/** @defgroup USB_CORE_Exported_Functions
|
/** @defgroup USB_CORE_Exported_Functions
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len, uint8_t ClassId);
|
||||||
|
#else
|
||||||
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len);
|
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
uint32_t USBD_HID_GetPollingInterval(USBD_HandleTypeDef *pdev);
|
uint32_t USBD_HID_GetPollingInterval(USBD_HandleTypeDef *pdev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||||
@@ -311,7 +311,7 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
(void)USBD_LL_OpenEP(pdev, HIDInEpAdd, USBD_EP_TYPE_INTR, HID_EPIN_SIZE);
|
(void)USBD_LL_OpenEP(pdev, HIDInEpAdd, USBD_EP_TYPE_INTR, HID_EPIN_SIZE);
|
||||||
pdev->ep_in[HIDInEpAdd & 0xFU].is_used = 1U;
|
pdev->ep_in[HIDInEpAdd & 0xFU].is_used = 1U;
|
||||||
|
|
||||||
hhid->state = HID_IDLE;
|
hhid->state = USBD_HID_IDLE;
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
@@ -329,7 +329,7 @@ static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Close HID EPs */
|
/* Close HID EPs */
|
||||||
@@ -372,19 +372,19 @@ static uint8_t USBD_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *re
|
|||||||
case USB_REQ_TYPE_CLASS :
|
case USB_REQ_TYPE_CLASS :
|
||||||
switch (req->bRequest)
|
switch (req->bRequest)
|
||||||
{
|
{
|
||||||
case HID_REQ_SET_PROTOCOL:
|
case USBD_HID_REQ_SET_PROTOCOL:
|
||||||
hhid->Protocol = (uint8_t)(req->wValue);
|
hhid->Protocol = (uint8_t)(req->wValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HID_REQ_GET_PROTOCOL:
|
case USBD_HID_REQ_GET_PROTOCOL:
|
||||||
(void)USBD_CtlSendData(pdev, (uint8_t *)&hhid->Protocol, 1U);
|
(void)USBD_CtlSendData(pdev, (uint8_t *)&hhid->Protocol, 1U);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HID_REQ_SET_IDLE:
|
case USBD_HID_REQ_SET_IDLE:
|
||||||
hhid->IdleState = (uint8_t)(req->wValue >> 8);
|
hhid->IdleState = (uint8_t)(req->wValue >> 8);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HID_REQ_GET_IDLE:
|
case USBD_HID_REQ_GET_IDLE:
|
||||||
(void)USBD_CtlSendData(pdev, (uint8_t *)&hhid->IdleState, 1U);
|
(void)USBD_CtlSendData(pdev, (uint8_t *)&hhid->IdleState, 1U);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -472,16 +472,24 @@ static uint8_t USBD_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *re
|
|||||||
return (uint8_t)ret;
|
return (uint8_t)ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_HID_SendReport
|
* @brief USBD_HID_SendReport
|
||||||
* Send HID Report
|
* Send HID Report
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param buff: pointer to report
|
* @param buff: pointer to report
|
||||||
|
* @param ClassId: The Class ID
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len, uint8_t ClassId)
|
||||||
|
{
|
||||||
|
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
|
||||||
|
#else
|
||||||
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len)
|
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len)
|
||||||
{
|
{
|
||||||
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hhid == NULL)
|
if (hhid == NULL)
|
||||||
{
|
{
|
||||||
@@ -490,14 +498,14 @@ uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
HIDInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, ClassId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
||||||
{
|
{
|
||||||
if (hhid->state == HID_IDLE)
|
if (hhid->state == USBD_HID_IDLE)
|
||||||
{
|
{
|
||||||
hhid->state = HID_BUSY;
|
hhid->state = USBD_HID_BUSY;
|
||||||
(void)USBD_LL_Transmit(pdev, HIDInEpAdd, report, len);
|
(void)USBD_LL_Transmit(pdev, HIDInEpAdd, report, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -607,7 +615,7 @@ static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
UNUSED(epnum);
|
UNUSED(epnum);
|
||||||
/* Ensure that the FIFO is empty before a new transfer, this condition could
|
/* Ensure that the FIFO is empty before a new transfer, this condition could
|
||||||
be caused by a new transfer before the end of the previous transfer */
|
be caused by a new transfer before the end of the previous transfer */
|
||||||
((USBD_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId])->state = HID_IDLE;
|
((USBD_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId])->state = USBD_HID_IDLE;
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ extern "C" {
|
|||||||
/** @defgroup USB_INFO_Exported_Defines
|
/** @defgroup USB_INFO_Exported_Defines
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define MODE_SENSE6_LEN 0x17U
|
#define MODE_SENSE6_LEN 0x04U
|
||||||
#define MODE_SENSE10_LEN 0x1BU
|
#define MODE_SENSE10_LEN 0x08U
|
||||||
#define LENGTH_INQUIRY_PAGE00 0x06U
|
#define LENGTH_INQUIRY_PAGE00 0x06U
|
||||||
#define LENGTH_INQUIRY_PAGE80 0x08U
|
#define LENGTH_INQUIRY_PAGE80 0x08U
|
||||||
#define LENGTH_FORMAT_CAPACITIES 0x14U
|
#define LENGTH_FORMAT_CAPACITIES 0x14U
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ extern "C" {
|
|||||||
#define UNIT_ATTENTION 6U
|
#define UNIT_ATTENTION 6U
|
||||||
#define DATA_PROTECT 7U
|
#define DATA_PROTECT 7U
|
||||||
#define BLANK_CHECK 8U
|
#define BLANK_CHECK 8U
|
||||||
#define VENDOR_SPECIFIC 9U
|
#define MSC_VENDOR_SPECIFIC 9U
|
||||||
#define COPY_ABORTED 10U
|
#define COPY_ABORTED 10U
|
||||||
#define ABORTED_COMMAND 11U
|
#define ABORTED_COMMAND 11U
|
||||||
#define VOLUME_OVERFLOW 13U
|
#define VOLUME_OVERFLOW 13U
|
||||||
|
|||||||
@@ -229,8 +229,8 @@ uint8_t USBD_MSC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||||
@@ -273,8 +273,8 @@ uint8_t USBD_MSC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Close MSC EPs */
|
/* Close MSC EPs */
|
||||||
@@ -313,8 +313,8 @@ uint8_t USBD_MSC_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ void MSC_BOT_Init(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
@@ -139,8 +139,8 @@ void MSC_BOT_Reset(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
@@ -259,8 +259,8 @@ static void MSC_BOT_CBW_Decode(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
@@ -335,8 +335,8 @@ static void MSC_BOT_SendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint32_t
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
@@ -366,8 +366,8 @@ void MSC_BOT_SendCSW(USBD_HandleTypeDef *pdev, uint8_t CSW_Status)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
@@ -400,8 +400,8 @@ static void MSC_BOT_Abort(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
@@ -439,8 +439,8 @@ void MSC_BOT_CplClrFeature(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hmsc == NULL)
|
if (hmsc == NULL)
|
||||||
|
|||||||
@@ -91,62 +91,32 @@ uint8_t MSC_Page80_Inquiry_Data[LENGTH_INQUIRY_PAGE80] =
|
|||||||
/* USB Mass storage sense 6 Data */
|
/* USB Mass storage sense 6 Data */
|
||||||
uint8_t MSC_Mode_Sense6_data[MODE_SENSE6_LEN] =
|
uint8_t MSC_Mode_Sense6_data[MODE_SENSE6_LEN] =
|
||||||
{
|
{
|
||||||
0x22,
|
0x03, /* MODE DATA LENGTH. The number of bytes that follow. */
|
||||||
0x00,
|
0x00, /* MEDIUM TYPE. 00h for SBC devices. */
|
||||||
0x00,
|
0x00, /* DEVICE-SPECIFIC PARAMETER. For SBC devices:
|
||||||
0x00,
|
* bit 7: WP. Set to 1 if the media is write-protected.
|
||||||
0x08,
|
* bits 6..5: reserved
|
||||||
0x12,
|
* bit 4: DPOFUA. Set to 1 if the device supports the DPO and FUA bits
|
||||||
0x00,
|
* bits 3..0: reserved */
|
||||||
0x00,
|
0x00 /* BLOCK DESCRIPTOR LENGTH */
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* USB Mass storage sense 10 Data */
|
/* USB Mass storage sense 10 Data */
|
||||||
uint8_t MSC_Mode_Sense10_data[MODE_SENSE10_LEN] =
|
uint8_t MSC_Mode_Sense10_data[MODE_SENSE10_LEN] =
|
||||||
{
|
{
|
||||||
0x00,
|
0x00, /* MODE DATA LENGTH MSB. */
|
||||||
0x26,
|
0x06, /* MODE DATA LENGTH LSB. The number of bytes that follow. */
|
||||||
0x00,
|
0x00, /* MEDIUM TYPE. 00h for SBC devices. */
|
||||||
0x00,
|
0x00, /* DEVICE-SPECIFIC PARAMETER. For SBC devices:
|
||||||
0x00,
|
* bit 7: WP. Set to 1 if the media is write-protected.
|
||||||
0x00,
|
* bits 6..5: reserved
|
||||||
0x00,
|
* bit 4: DPOFUA. Set to 1 if the device supports the DPO and FUA bits
|
||||||
0x00,
|
* bits 3..0: reserved */
|
||||||
0x08,
|
0x00, /* LONGLBA Set to zero */
|
||||||
0x12,
|
0x00, /* Reserved */
|
||||||
0x00,
|
0x00, /* BLOCK DESCRIPTOR LENGTH MSB. */
|
||||||
0x00,
|
0x00 /* BLOCK DESCRIPTOR LENGTH LSB. */
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
|
|||||||
@@ -291,7 +291,8 @@ static int8_t SCSI_Inquiry(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *param
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
pPage = (uint8_t *) & ((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->pInquiry[lun * STANDARD_INQUIRY_DATA_LEN];
|
pPage = (uint8_t *) & ((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId]) \
|
||||||
|
->pInquiry[lun * STANDARD_INQUIRY_DATA_LEN];
|
||||||
len = (uint16_t)pPage[4] + 5U;
|
len = (uint16_t)pPage[4] + 5U;
|
||||||
|
|
||||||
if (params[4] <= len)
|
if (params[4] <= len)
|
||||||
@@ -324,7 +325,8 @@ static int8_t SCSI_ReadCapacity10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->GetCapacity(lun, &hmsc->scsi_blk_nbr, &hmsc->scsi_blk_size);
|
ret = ((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->GetCapacity(lun, &hmsc->scsi_blk_nbr,
|
||||||
|
&hmsc->scsi_blk_size);
|
||||||
|
|
||||||
if ((ret != 0) || (hmsc->scsi_medium_state == SCSI_MEDIUM_EJECTED))
|
if ((ret != 0) || (hmsc->scsi_medium_state == SCSI_MEDIUM_EJECTED))
|
||||||
{
|
{
|
||||||
@@ -359,7 +361,7 @@ static int8_t SCSI_ReadCapacity10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
|
|||||||
static int8_t SCSI_ReadCapacity16(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
static int8_t SCSI_ReadCapacity16(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *params)
|
||||||
{
|
{
|
||||||
UNUSED(params);
|
UNUSED(params);
|
||||||
uint8_t idx;
|
uint32_t idx;
|
||||||
int8_t ret;
|
int8_t ret;
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
|
|
||||||
@@ -368,7 +370,8 @@ static int8_t SCSI_ReadCapacity16(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->GetCapacity(lun, &hmsc->scsi_blk_nbr, &hmsc->scsi_blk_size);
|
ret = ((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->GetCapacity(lun, &hmsc->scsi_blk_nbr,
|
||||||
|
&hmsc->scsi_blk_size);
|
||||||
|
|
||||||
if ((ret != 0) || (hmsc->scsi_medium_state == SCSI_MEDIUM_EJECTED))
|
if ((ret != 0) || (hmsc->scsi_medium_state == SCSI_MEDIUM_EJECTED))
|
||||||
{
|
{
|
||||||
@@ -474,6 +477,12 @@ static int8_t SCSI_ModeSense6(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *pa
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check If media is write-protected */
|
||||||
|
if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->IsWriteProtected(lun) != 0)
|
||||||
|
{
|
||||||
|
MSC_Mode_Sense6_data[2] |= 0x80U;
|
||||||
|
}
|
||||||
|
|
||||||
if (params[4] <= len)
|
if (params[4] <= len)
|
||||||
{
|
{
|
||||||
len = params[4];
|
len = params[4];
|
||||||
@@ -503,6 +512,12 @@ static int8_t SCSI_ModeSense10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *p
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check If media is write-protected */
|
||||||
|
if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->IsWriteProtected(lun) != 0)
|
||||||
|
{
|
||||||
|
MSC_Mode_Sense10_data[3] |= 0x80U;
|
||||||
|
}
|
||||||
|
|
||||||
if (params[8] <= len)
|
if (params[8] <= len)
|
||||||
{
|
{
|
||||||
len = params[8];
|
len = params[8];
|
||||||
@@ -832,7 +847,7 @@ static int8_t SCSI_Write10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *param
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hmsc->bot_state == USBD_BOT_IDLE) /* Idle */
|
if (hmsc->bot_state == USBD_BOT_IDLE) /* Idle */
|
||||||
@@ -921,7 +936,7 @@ static int8_t SCSI_Write12(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *param
|
|||||||
}
|
}
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hmsc->bot_state == USBD_BOT_IDLE) /* Idle */
|
if (hmsc->bot_state == USBD_BOT_IDLE) /* Idle */
|
||||||
@@ -1075,7 +1090,7 @@ static int8_t SCSI_ProcessRead(USBD_HandleTypeDef *pdev, uint8_t lun)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
len = MIN(len, MSC_MEDIA_PACKET);
|
len = MIN(len, MSC_MEDIA_PACKET);
|
||||||
@@ -1124,7 +1139,7 @@ static int8_t SCSI_ProcessWrite(USBD_HandleTypeDef *pdev, uint8_t lun)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
len = MIN(len, MSC_MEDIA_PACKET);
|
len = MIN(len, MSC_MEDIA_PACKET);
|
||||||
|
|||||||
@@ -242,9 +242,9 @@ static uint8_t USBD_MTP_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MTPInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MTPInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MTPCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
MTPCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
|
|
||||||
@@ -292,9 +292,9 @@ static uint8_t USBD_MTP_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this MTP class instance */
|
/* Get the Endpoints addresses allocated for this MTP class instance */
|
||||||
MTPInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MTPInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MTPCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR);
|
MTPCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Close EP IN */
|
/* Close EP IN */
|
||||||
@@ -338,7 +338,7 @@ static uint8_t USBD_MTP_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *re
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this MTP class instance */
|
/* Get the Endpoints addresses allocated for this MTP class instance */
|
||||||
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hmtp == NULL)
|
if (hmtp == NULL)
|
||||||
@@ -460,8 +460,8 @@ static uint8_t USBD_MTP_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this MTP class instance */
|
/* Get the Endpoints addresses allocated for this MTP class instance */
|
||||||
MTPInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MTPInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (epnum == (MTPInEpAdd & 0x7FU))
|
if (epnum == (MTPInEpAdd & 0x7FU))
|
||||||
@@ -516,7 +516,7 @@ static uint8_t USBD_MTP_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this MTP class instance */
|
/* Get the Endpoints addresses allocated for this MTP class instance */
|
||||||
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
(void)USBD_MTP_STORAGE_ReceiveOpt(pdev);
|
(void)USBD_MTP_STORAGE_ReceiveOpt(pdev);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ uint8_t USBD_MTP_STORAGE_Init(USBD_HandleTypeDef *pdev)
|
|||||||
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
USBD_MTP_HandleTypeDef *hmtp = (USBD_MTP_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Initialize the HW layyer of the file system */
|
/* Initialize the HW layyer of the file system */
|
||||||
@@ -205,7 +205,7 @@ uint8_t USBD_MTP_STORAGE_ReceiveOpt(USBD_HandleTypeDef *pdev)
|
|||||||
uint32_t *pMsgBuffer;
|
uint32_t *pMsgBuffer;
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
MTPOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
MTP_DataLength.rx_length = USBD_GetRxCount(pdev, MTPOutEpAdd);
|
MTP_DataLength.rx_length = USBD_GetRxCount(pdev, MTPOutEpAdd);
|
||||||
|
|
||||||
@@ -463,7 +463,7 @@ static uint8_t USBD_MTP_STORAGE_SendData(USBD_HandleTypeDef *pdev, uint8_t *buf
|
|||||||
uint32_t length = MIN(hmtp->GenericContainer.length, len);
|
uint32_t length = MIN(hmtp->GenericContainer.length, len);
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
MTPInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
MTPInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
(void)USBD_LL_Transmit(pdev, MTPInEpAdd, buf, length);
|
(void)USBD_LL_Transmit(pdev, MTPInEpAdd, buf, length);
|
||||||
|
|||||||
@@ -249,8 +249,8 @@ static uint8_t USBD_PRNT_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
PRNTInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
PRNTInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
PRNTOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
PRNTOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Setup the max packet size according to selected speed */
|
/* Setup the max packet size according to selected speed */
|
||||||
@@ -305,8 +305,8 @@ static uint8_t USBD_PRNT_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
PRNTInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
PRNTInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
PRNTOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
PRNTOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Close EP IN */
|
/* Close EP IN */
|
||||||
@@ -622,8 +622,8 @@ uint8_t USBD_PRNT_ReceivePacket(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
PRNTInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
PRNTInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
PRNTOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
PRNTOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
if (hPRNT == NULL)
|
if (hPRNT == NULL)
|
||||||
|
|||||||
@@ -377,7 +377,8 @@ typedef struct
|
|||||||
{
|
{
|
||||||
uint32_t interface;
|
uint32_t interface;
|
||||||
uint32_t uvc_state;
|
uint32_t uvc_state;
|
||||||
uint8_t buffer[UVC_TOTAL_BUF_SIZE];
|
uint32_t uvc_size;
|
||||||
|
uint8_t *uvc_buffer;
|
||||||
VIDEO_OffsetTypeDef offset;
|
VIDEO_OffsetTypeDef offset;
|
||||||
USBD_VIDEO_ControlTypeDef control;
|
USBD_VIDEO_ControlTypeDef control;
|
||||||
} USBD_VIDEO_HandleTypeDef;
|
} USBD_VIDEO_HandleTypeDef;
|
||||||
|
|||||||
@@ -414,7 +414,7 @@ static uint8_t USBD_VIDEO_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
VIDEOinEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_ISOC);
|
VIDEOinEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Open EP IN */
|
/* Open EP IN */
|
||||||
@@ -466,7 +466,7 @@ static uint8_t USBD_VIDEO_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
/* Get the Endpoints addresses allocated for this class instance */
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
VIDEOinEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_ISOC);
|
VIDEOinEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Close EP IN */
|
/* Close EP IN */
|
||||||
@@ -498,6 +498,11 @@ static uint8_t USBD_VIDEO_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *
|
|||||||
uint16_t len;
|
uint16_t len;
|
||||||
uint8_t *pbuf;
|
uint8_t *pbuf;
|
||||||
|
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
|
VIDEOinEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
switch (req->bmRequest & USB_REQ_TYPE_MASK)
|
||||||
{
|
{
|
||||||
/* Class Requests -------------------------------*/
|
/* Class Requests -------------------------------*/
|
||||||
@@ -640,7 +645,13 @@ static uint8_t USBD_VIDEO_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
static uint16_t PcktSze = UVC_PACKET_SIZE;
|
static uint16_t PcktSze = UVC_PACKET_SIZE;
|
||||||
static uint8_t payload_header[2] = {0x02U, 0x00U};
|
static uint8_t payload_header[2] = {0x02U, 0x00U};
|
||||||
uint8_t i = 0U;
|
uint8_t i = 0U;
|
||||||
uint32_t RemainData, DataOffset = 0U;
|
uint32_t RemainData = 0U;
|
||||||
|
uint32_t DataOffset = 0U;
|
||||||
|
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
|
VIDEOinEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Check if the Streaming has already been started */
|
/* Check if the Streaming has already been started */
|
||||||
if (hVIDEO->uvc_state == UVC_PLAY_STATUS_STREAMING)
|
if (hVIDEO->uvc_state == UVC_PLAY_STATUS_STREAMING)
|
||||||
@@ -691,9 +702,12 @@ static uint8_t USBD_VIDEO_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||||||
packet[1] = payload_header[1];
|
packet[1] = payload_header[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hVIDEO->uvc_buffer = (uint8_t *)&packet;
|
||||||
|
hVIDEO->uvc_size = (uint32_t)PcktSze;
|
||||||
|
|
||||||
/* Transmit the packet on Endpoint */
|
/* Transmit the packet on Endpoint */
|
||||||
(void)USBD_LL_Transmit(pdev, (uint8_t)(epnum | 0x80U),
|
(void)USBD_LL_Transmit(pdev, (uint8_t)(epnum | 0x80U),
|
||||||
(uint8_t *)&packet, (uint32_t)PcktSze);
|
hVIDEO->uvc_buffer, hVIDEO->uvc_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Exit with no error code */
|
/* Exit with no error code */
|
||||||
@@ -711,11 +725,19 @@ static uint8_t USBD_VIDEO_SOF(USBD_HandleTypeDef *pdev)
|
|||||||
USBD_VIDEO_HandleTypeDef *hVIDEO = (USBD_VIDEO_HandleTypeDef *) pdev->pClassDataCmsit[pdev->classId];
|
USBD_VIDEO_HandleTypeDef *hVIDEO = (USBD_VIDEO_HandleTypeDef *) pdev->pClassDataCmsit[pdev->classId];
|
||||||
uint8_t payload[2] = {0x02U, 0x00U};
|
uint8_t payload[2] = {0x02U, 0x00U};
|
||||||
|
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
|
VIDEOinEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
/* Check if the Streaming has already been started by SetInterface AltSetting 1 */
|
/* Check if the Streaming has already been started by SetInterface AltSetting 1 */
|
||||||
if (hVIDEO->uvc_state == UVC_PLAY_STATUS_READY)
|
if (hVIDEO->uvc_state == UVC_PLAY_STATUS_READY)
|
||||||
{
|
{
|
||||||
|
hVIDEO->uvc_buffer = (uint8_t *)&payload;
|
||||||
|
hVIDEO->uvc_size = 2U;
|
||||||
|
|
||||||
/* Transmit the first packet indicating that Streaming is starting */
|
/* Transmit the first packet indicating that Streaming is starting */
|
||||||
(void)USBD_LL_Transmit(pdev, VIDEOinEpAdd, (uint8_t *)payload, 2U);
|
(void)USBD_LL_Transmit(pdev, VIDEOinEpAdd, hVIDEO->uvc_buffer, hVIDEO->uvc_size);
|
||||||
|
|
||||||
/* Enable Streaming state */
|
/* Enable Streaming state */
|
||||||
hVIDEO->uvc_state = UVC_PLAY_STATUS_STREAMING;
|
hVIDEO->uvc_state = UVC_PLAY_STATUS_STREAMING;
|
||||||
@@ -734,8 +756,17 @@ static uint8_t USBD_VIDEO_SOF(USBD_HandleTypeDef *pdev)
|
|||||||
*/
|
*/
|
||||||
static uint8_t USBD_VIDEO_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
static uint8_t USBD_VIDEO_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||||
{
|
{
|
||||||
UNUSED(pdev);
|
USBD_VIDEO_HandleTypeDef *hVIDEO = (USBD_VIDEO_HandleTypeDef *) pdev->pClassDataCmsit[pdev->classId];
|
||||||
UNUSED(epnum);
|
|
||||||
|
#ifdef USE_USBD_COMPOSITE
|
||||||
|
/* Get the Endpoints addresses allocated for this class instance */
|
||||||
|
VIDEOinEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_ISOC, (uint8_t)pdev->classId);
|
||||||
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
|
if (epnum == (VIDEOinEpAdd & 0xFU))
|
||||||
|
{
|
||||||
|
(void)USBD_LL_Transmit(pdev, VIDEOinEpAdd, hVIDEO->uvc_buffer, hVIDEO->uvc_size);
|
||||||
|
}
|
||||||
|
|
||||||
return (uint8_t)USBD_OK;
|
return (uint8_t)USBD_OK;
|
||||||
}
|
}
|
||||||
@@ -836,19 +867,18 @@ static void VIDEO_REQ_GetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
|
|||||||
*/
|
*/
|
||||||
static void VIDEO_REQ_SetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void VIDEO_REQ_SetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
USBD_VIDEO_HandleTypeDef *hVIDEO = (USBD_VIDEO_HandleTypeDef *)(pdev->pClassDataCmsit[pdev->classId]);
|
|
||||||
|
|
||||||
/* Check that the request has control data */
|
/* Check that the request has control data */
|
||||||
if (req->wLength > 0U)
|
if (req->wLength > 0U)
|
||||||
{
|
{
|
||||||
/* Prepare the reception of the buffer over EP0 */
|
/* Prepare the reception of the buffer over EP0 */
|
||||||
if (LOBYTE(req->wValue) == (uint8_t)VS_PROBE_CONTROL)
|
if (req->wValue == (uint16_t)VS_PROBE_CONTROL)
|
||||||
{
|
{
|
||||||
/* Probe Request */
|
/* Probe Request */
|
||||||
(void) USBD_CtlPrepareRx(pdev, (uint8_t *)&video_Probe_Control,
|
(void) USBD_CtlPrepareRx(pdev, (uint8_t *)&video_Probe_Control,
|
||||||
MIN(req->wLength, sizeof(USBD_VideoControlTypeDef)));
|
MIN(req->wLength, sizeof(USBD_VideoControlTypeDef)));
|
||||||
}
|
}
|
||||||
else if (LOBYTE(req->wValue) == (uint8_t)VS_COMMIT_CONTROL)
|
else if (req->wValue == (uint16_t)VS_COMMIT_CONTROL)
|
||||||
{
|
{
|
||||||
/* Commit Request */
|
/* Commit Request */
|
||||||
(void) USBD_CtlPrepareRx(pdev, (uint8_t *)&video_Commit_Control,
|
(void) USBD_CtlPrepareRx(pdev, (uint8_t *)&video_Commit_Control,
|
||||||
@@ -856,9 +886,7 @@ static void VIDEO_REQ_SetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Prepare the reception of the buffer over EP0 */
|
(void)USBD_LL_StallEP(pdev, 0x80U);
|
||||||
(void) USBD_CtlPrepareRx(pdev, hVIDEO->control.data,
|
|
||||||
MIN(req->wLength, USB_MAX_EP0_SIZE));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,14 +234,16 @@ static int8_t VIDEO_Itf_Data(uint8_t **pbuf, uint16_t *psize, uint16_t *pcktidx)
|
|||||||
*psize = (uint16_t)UVC_PACKET_SIZE;
|
*psize = (uint16_t)UVC_PACKET_SIZE;
|
||||||
|
|
||||||
/* Get the pointer to the next packet to be transmitted */
|
/* Get the pointer to the next packet to be transmitted */
|
||||||
*pbuf = (uint8_t *)(*(ImagePtr + img_count) + (packet_index * ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U)))));
|
*pbuf = (uint8_t *)(*(ImagePtr + img_count) + \
|
||||||
|
(packet_index * ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U)))));
|
||||||
}
|
}
|
||||||
else if ((packet_index == packet_count))
|
else if ((packet_index == packet_count))
|
||||||
{
|
{
|
||||||
if (packet_remainder != 0U)
|
if (packet_remainder != 0U)
|
||||||
{
|
{
|
||||||
/* Get the pointer to the next packet to be transmitted */
|
/* Get the pointer to the next packet to be transmitted */
|
||||||
*pbuf = (uint8_t *)(*(ImagePtr + img_count) + (packet_index * ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U)))));
|
*pbuf = (uint8_t *)(*(ImagePtr + img_count) + \
|
||||||
|
(packet_index * ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U)))));
|
||||||
|
|
||||||
/* Set the current packet size */
|
/* Set the current packet size */
|
||||||
*psize = (uint16_t)(packet_remainder + (UVC_HEADER_PACKET_CNT * 2U));
|
*psize = (uint16_t)(packet_remainder + (UVC_HEADER_PACKET_CNT * 2U));
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ extern "C" {
|
|||||||
#define USBD_MAX_STR_DESC_SIZ 0x100U
|
#define USBD_MAX_STR_DESC_SIZ 0x100U
|
||||||
#define USBD_SELF_POWERED 1U
|
#define USBD_SELF_POWERED 1U
|
||||||
#define USBD_DEBUG_LEVEL 2U
|
#define USBD_DEBUG_LEVEL 2U
|
||||||
|
/* #define USBD_USER_REGISTER_CALLBACK 1U */
|
||||||
|
|
||||||
/* ECM, RNDIS, DFU Class Config */
|
/* ECM, RNDIS, DFU Class Config */
|
||||||
#define USBD_SUPPORT_USER_STRING_DESC 1U
|
#define USBD_SUPPORT_USER_STRING_DESC 1U
|
||||||
@@ -64,6 +65,8 @@ extern "C" {
|
|||||||
#define USBD_CDC_INTERVAL 2000U
|
#define USBD_CDC_INTERVAL 2000U
|
||||||
|
|
||||||
/* DFU Class Config */
|
/* DFU Class Config */
|
||||||
|
/* #define USBD_DFU_VENDOR_CMD_ENABLED 1U */
|
||||||
|
/* #define USBD_DFU_VENDOR_EXIT_ENABLED 1U */
|
||||||
#define USBD_DFU_MAX_ITF_NUM 1U
|
#define USBD_DFU_MAX_ITF_NUM 1U
|
||||||
#define USBD_DFU_XFERS_IZE 1024U
|
#define USBD_DFU_XFERS_IZE 1024U
|
||||||
|
|
||||||
@@ -76,6 +79,11 @@ extern "C" {
|
|||||||
#define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE 0x02U
|
#define USBD_CUSTOMHID_OUTREPORT_BUF_SIZE 0x02U
|
||||||
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 163U
|
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 163U
|
||||||
|
|
||||||
|
/* #define USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED */
|
||||||
|
/* #define USBD_CUSTOMHID_OUT_PREPARE_RECEIVE_DISABLED */
|
||||||
|
/* #define USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED */
|
||||||
|
/* #define USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
|
||||||
|
|
||||||
/* VIDEO Class Config */
|
/* VIDEO Class Config */
|
||||||
#define UVC_1_1 /* #define UVC_1_0 */
|
#define UVC_1_1 /* #define UVC_1_0 */
|
||||||
|
|
||||||
|
|||||||
@@ -86,13 +86,16 @@ USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev);
|
|||||||
USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev);
|
USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev);
|
||||||
USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev);
|
USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev);
|
||||||
USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass);
|
USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass);
|
||||||
|
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||||
|
USBD_StatusTypeDef USBD_RegisterDevStateCallback(USBD_HandleTypeDef *pdev, USBD_DevStateCallbackTypeDef pUserCallback);
|
||||||
|
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||||
|
|
||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass,
|
USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass,
|
||||||
USBD_CompositeClassTypeDef classtype, uint8_t *EpAddr);
|
USBD_CompositeClassTypeDef classtype, uint8_t *EpAddr);
|
||||||
|
|
||||||
USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev);
|
USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev);
|
||||||
uint8_t USBD_CoreGetEPAdd(USBD_HandleTypeDef *pdev, uint8_t ep_dir, uint8_t ep_type);
|
uint8_t USBD_CoreGetEPAdd(USBD_HandleTypeDef *pdev, uint8_t ep_dir, uint8_t ep_type, uint8_t ClassId);
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
uint8_t USBD_CoreFindIF(USBD_HandleTypeDef *pdev, uint8_t index);
|
uint8_t USBD_CoreFindIF(USBD_HandleTypeDef *pdev, uint8_t index);
|
||||||
|
|||||||
@@ -390,8 +390,15 @@ typedef struct _USBD_HandleTypeDef
|
|||||||
#ifdef USE_USBD_COMPOSITE
|
#ifdef USE_USBD_COMPOSITE
|
||||||
USBD_CompositeElementTypeDef tclasslist[USBD_MAX_SUPPORTED_CLASS];
|
USBD_CompositeElementTypeDef tclasslist[USBD_MAX_SUPPORTED_CLASS];
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||||
|
void (* DevStateCallback)(uint8_t dev_state, uint8_t cfgidx); /*!< User Notification callback */
|
||||||
|
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||||
} USBD_HandleTypeDef;
|
} USBD_HandleTypeDef;
|
||||||
|
|
||||||
|
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||||
|
typedef void (*USBD_DevStateCallbackTypeDef)(uint8_t dev_state, uint8_t cfgidx); /*!< pointer to User callback function */
|
||||||
|
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||||
|
|
||||||
/* USB Device endpoint direction */
|
/* USB Device endpoint direction */
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@@ -416,7 +423,9 @@ typedef enum
|
|||||||
*/
|
*/
|
||||||
__STATIC_INLINE uint16_t SWAPBYTE(uint8_t *addr)
|
__STATIC_INLINE uint16_t SWAPBYTE(uint8_t *addr)
|
||||||
{
|
{
|
||||||
uint16_t _SwapVal, _Byte1, _Byte2;
|
uint16_t _SwapVal;
|
||||||
|
uint16_t _Byte1;
|
||||||
|
uint16_t _Byte2;
|
||||||
uint8_t *_pbuff = addr;
|
uint8_t *_pbuff = addr;
|
||||||
|
|
||||||
_Byte1 = *(uint8_t *)_pbuff;
|
_Byte1 = *(uint8_t *)_pbuff;
|
||||||
|
|||||||
@@ -256,6 +256,7 @@ USBD_StatusTypeDef USBD_LL_SetTestMode(USBD_HandleTypeDef *pdev, uint8_t testmod
|
|||||||
*/
|
*/
|
||||||
void *USBD_static_malloc(uint32_t size)
|
void *USBD_static_malloc(uint32_t size)
|
||||||
{
|
{
|
||||||
|
UNUSED(size);
|
||||||
static uint32_t mem[(sizeof(USBD_HID_HandleTypeDef) / 4) + 1]; /* On 32-bit boundary */
|
static uint32_t mem[(sizeof(USBD_HID_HandleTypeDef) / 4) + 1]; /* On 32-bit boundary */
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
@@ -267,7 +268,7 @@ void *USBD_static_malloc(uint32_t size)
|
|||||||
*/
|
*/
|
||||||
void USBD_static_free(void *p)
|
void USBD_static_free(void *p)
|
||||||
{
|
{
|
||||||
|
UNUSED(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -83,11 +83,11 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_Init
|
* @brief USBD_Init
|
||||||
* Initializes the device stack and load the class driver
|
* Initialize the device stack and load the class driver
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param pdesc: Descriptor structure address
|
* @param pdesc: Descriptor structure address
|
||||||
* @param id: Low level core index
|
* @param id: Low level core index
|
||||||
* @retval None
|
* @retval status: USBD Status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev,
|
USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev,
|
||||||
USBD_DescriptorsTypeDef *pdesc, uint8_t id)
|
USBD_DescriptorsTypeDef *pdesc, uint8_t id)
|
||||||
@@ -142,9 +142,9 @@ USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_DeInit
|
* @brief USBD_DeInit
|
||||||
* Re-Initialize the device library
|
* De-Initialize the device library
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status: status
|
* @retval status: USBD Status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
@@ -195,7 +195,7 @@ USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev)
|
|||||||
/**
|
/**
|
||||||
* @brief USBD_RegisterClass
|
* @brief USBD_RegisterClass
|
||||||
* Link class driver to Device Core.
|
* Link class driver to Device Core.
|
||||||
* @param pDevice : Device Handle
|
* @param pdev: Device Handle
|
||||||
* @param pclass: Class handle
|
* @param pclass: Class handle
|
||||||
* @retval USBD Status
|
* @retval USBD Status
|
||||||
*/
|
*/
|
||||||
@@ -291,7 +291,7 @@ USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_C
|
|||||||
/**
|
/**
|
||||||
* @brief USBD_UnRegisterClassComposite
|
* @brief USBD_UnRegisterClassComposite
|
||||||
* UnLink all composite class drivers from Device Core.
|
* UnLink all composite class drivers from Device Core.
|
||||||
* @param pDevice : Device Handle
|
* @param pdev: Device Handle
|
||||||
* @retval USBD Status
|
* @retval USBD Status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev)
|
||||||
@@ -358,10 +358,23 @@ USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* USE_USBD_COMPOSITE */
|
#endif /* USE_USBD_COMPOSITE */
|
||||||
|
|
||||||
|
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||||
|
/**
|
||||||
|
* @brief USBD_RegisterDevStateCallback
|
||||||
|
* @param pdev : Device Handle
|
||||||
|
* @param pUserCallback: User Callback
|
||||||
|
* @retval USBD Status
|
||||||
|
*/
|
||||||
|
USBD_StatusTypeDef USBD_RegisterDevStateCallback(USBD_HandleTypeDef *pdev, USBD_DevStateCallbackTypeDef pUserCallback)
|
||||||
|
{
|
||||||
|
pdev->DevStateCallback = pUserCallback;
|
||||||
|
|
||||||
|
return USBD_OK;
|
||||||
|
}
|
||||||
|
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USBD_Start
|
* @brief USBD_Start
|
||||||
* Start the USB Device Core.
|
* Start the USB Device Core.
|
||||||
@@ -487,7 +500,7 @@ USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
* Clear current configuration
|
* Clear current configuration
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param cfgidx: configuration index
|
* @param cfgidx: configuration index
|
||||||
* @retval status: USBD_StatusTypeDef
|
* @retval status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||||
{
|
{
|
||||||
@@ -527,6 +540,7 @@ USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||||||
* @brief USBD_LL_SetupStage
|
* @brief USBD_LL_SetupStage
|
||||||
* Handle the setup stage
|
* Handle the setup stage
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
|
* @param psetup: setup packet buffer pointer
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup)
|
USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup)
|
||||||
@@ -629,19 +643,6 @@ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
|
|||||||
(void)USBD_CtlSendStatus(pdev);
|
(void)USBD_CtlSendStatus(pdev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
if (pdev->ep0_state == USBD_EP0_STATUS_OUT)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* STATUS PHASE completed, update ep0_state to idle
|
|
||||||
*/
|
|
||||||
pdev->ep0_state = USBD_EP0_IDLE;
|
|
||||||
(void)USBD_LL_StallEP(pdev, 0U);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -674,6 +675,7 @@ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
|
|||||||
* Handle data in stage
|
* Handle data in stage
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param epnum: endpoint index
|
* @param epnum: endpoint index
|
||||||
|
* @param pdata: data pointer
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
|
USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
|
||||||
@@ -726,16 +728,6 @@ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
if ((pdev->ep0_state == USBD_EP0_STATUS_IN) ||
|
|
||||||
(pdev->ep0_state == USBD_EP0_IDLE))
|
|
||||||
{
|
|
||||||
(void)USBD_LL_StallEP(pdev, 0x80U);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pdev->dev_test_mode != 0U)
|
if (pdev->dev_test_mode != 0U)
|
||||||
{
|
{
|
||||||
@@ -776,7 +768,6 @@ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
|
|||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
|
||||||
USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
USBD_StatusTypeDef ret = USBD_OK;
|
USBD_StatusTypeDef ret = USBD_OK;
|
||||||
@@ -859,10 +850,13 @@ USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev,
|
|||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
|
||||||
USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev)
|
||||||
|
{
|
||||||
|
if (pdev->dev_state != USBD_STATE_SUSPENDED)
|
||||||
{
|
{
|
||||||
pdev->dev_old_state = pdev->dev_state;
|
pdev->dev_old_state = pdev->dev_state;
|
||||||
|
}
|
||||||
|
|
||||||
pdev->dev_state = USBD_STATE_SUSPENDED;
|
pdev->dev_state = USBD_STATE_SUSPENDED;
|
||||||
|
|
||||||
return USBD_OK;
|
return USBD_OK;
|
||||||
@@ -874,7 +868,6 @@ USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev)
|
|||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
|
||||||
USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
if (pdev->dev_state == USBD_STATE_SUSPENDED)
|
if (pdev->dev_state == USBD_STATE_SUSPENDED)
|
||||||
@@ -891,7 +884,6 @@ USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev)
|
|||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
|
|
||||||
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
|
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
|
||||||
{
|
{
|
||||||
/* The SOF event can be distributed for all classes that support it */
|
/* The SOF event can be distributed for all classes that support it */
|
||||||
@@ -932,6 +924,7 @@ USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
|
|||||||
* @brief USBD_LL_IsoINIncomplete
|
* @brief USBD_LL_IsoINIncomplete
|
||||||
* Handle iso in incomplete event
|
* Handle iso in incomplete event
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
|
* @param epnum: Endpoint number
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev,
|
USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev,
|
||||||
@@ -957,6 +950,7 @@ USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev,
|
|||||||
* @brief USBD_LL_IsoOUTIncomplete
|
* @brief USBD_LL_IsoOUTIncomplete
|
||||||
* Handle iso out incomplete event
|
* Handle iso out incomplete event
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
|
* @param epnum: Endpoint number
|
||||||
* @retval status
|
* @retval status
|
||||||
*/
|
*/
|
||||||
USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev,
|
USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev,
|
||||||
@@ -1123,20 +1117,21 @@ uint8_t USBD_CoreFindEP(USBD_HandleTypeDef *pdev, uint8_t index)
|
|||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param ep_dir: USBD_EP_IN or USBD_EP_OUT
|
* @param ep_dir: USBD_EP_IN or USBD_EP_OUT
|
||||||
* @param ep_type: USBD_EP_TYPE_CTRL, USBD_EP_TYPE_ISOC, USBD_EP_TYPE_BULK or USBD_EP_TYPE_INTR
|
* @param ep_type: USBD_EP_TYPE_CTRL, USBD_EP_TYPE_ISOC, USBD_EP_TYPE_BULK or USBD_EP_TYPE_INTR
|
||||||
|
* @param ClassId: The Class ID
|
||||||
* @retval Address of the selected endpoint or 0xFFU if no endpoint found.
|
* @retval Address of the selected endpoint or 0xFFU if no endpoint found.
|
||||||
*/
|
*/
|
||||||
uint8_t USBD_CoreGetEPAdd(USBD_HandleTypeDef *pdev, uint8_t ep_dir, uint8_t ep_type)
|
uint8_t USBD_CoreGetEPAdd(USBD_HandleTypeDef *pdev, uint8_t ep_dir, uint8_t ep_type, uint8_t ClassId)
|
||||||
{
|
{
|
||||||
uint8_t idx;
|
uint8_t idx;
|
||||||
|
|
||||||
/* Find the EP address in the selected class table */
|
/* Find the EP address in the selected class table */
|
||||||
for (idx = 0; idx < pdev->tclasslist[pdev->classId].NumEps; idx++)
|
for (idx = 0; idx < pdev->tclasslist[ClassId].NumEps; idx++)
|
||||||
{
|
{
|
||||||
if (((pdev->tclasslist[pdev->classId].Eps[idx].add & USBD_EP_IN) == ep_dir) && \
|
if (((pdev->tclasslist[ClassId].Eps[idx].add & USBD_EP_IN) == ep_dir) && \
|
||||||
(pdev->tclasslist[pdev->classId].Eps[idx].type == ep_type) && \
|
(pdev->tclasslist[ClassId].Eps[idx].type == ep_type) && \
|
||||||
(pdev->tclasslist[pdev->classId].Eps[idx].is_used != 0U))
|
(pdev->tclasslist[ClassId].Eps[idx].is_used != 0U))
|
||||||
{
|
{
|
||||||
return (pdev->tclasslist[pdev->classId].Eps[idx].add);
|
return (pdev->tclasslist[ClassId].Eps[idx].add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,9 @@
|
|||||||
/** @defgroup USBD_REQ_Private_Defines
|
/** @defgroup USBD_REQ_Private_Defines
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
#ifndef USBD_MAX_STR_DESC_SIZ
|
||||||
|
#define USBD_MAX_STR_DESC_SIZ 64U
|
||||||
|
#endif /* USBD_MAX_STR_DESC_SIZ */
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
@@ -421,7 +423,7 @@ USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
|
|||||||
* Handle Get Descriptor requests
|
* Handle Get Descriptor requests
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval status
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
@@ -558,7 +560,6 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
|||||||
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
|
||||||
pbuf = NULL;
|
pbuf = NULL;
|
||||||
|
|
||||||
|
|
||||||
for (uint32_t idx = 0U; (idx < pdev->NumClasses); idx++)
|
for (uint32_t idx = 0U; (idx < pdev->NumClasses); idx++)
|
||||||
{
|
{
|
||||||
if (pdev->pClass[idx]->GetUsrStrDescriptor != NULL)
|
if (pdev->pClass[idx]->GetUsrStrDescriptor != NULL)
|
||||||
@@ -576,13 +577,12 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||||
|
|
||||||
#if (USBD_CLASS_USER_STRING_DESC == 1U)
|
#if (USBD_CLASS_USER_STRING_DESC == 1U)
|
||||||
if (pdev->pDesc->GetUserStrDescriptor != NULL)
|
if (pdev->pDesc->GetUserStrDescriptor != NULL)
|
||||||
{
|
{
|
||||||
pbuf = pdev->pDesc->GetUserStrDescriptor(pdev->dev_speed, (req->wValue), &len);
|
pbuf = pdev->pDesc->GetUserStrDescriptor(pdev->dev_speed, LOBYTE(req->wValue), &len);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -677,7 +677,7 @@ static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
|||||||
* Set device address
|
* Set device address
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval status
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void USBD_SetAddress(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void USBD_SetAddress(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
@@ -751,6 +751,13 @@ static USBD_StatusTypeDef USBD_SetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReq
|
|||||||
{
|
{
|
||||||
(void)USBD_CtlSendStatus(pdev);
|
(void)USBD_CtlSendStatus(pdev);
|
||||||
pdev->dev_state = USBD_STATE_CONFIGURED;
|
pdev->dev_state = USBD_STATE_CONFIGURED;
|
||||||
|
|
||||||
|
#if (USBD_USER_REGISTER_CALLBACK == 1U)
|
||||||
|
if (pdev->DevStateCallback != NULL)
|
||||||
|
{
|
||||||
|
pdev->DevStateCallback(USBD_STATE_CONFIGURED, cfgidx);
|
||||||
|
}
|
||||||
|
#endif /* USBD_USER_REGISTER_CALLBACK */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -809,7 +816,7 @@ static USBD_StatusTypeDef USBD_SetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReq
|
|||||||
* Handle Get device configuration request
|
* Handle Get device configuration request
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval status
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void USBD_GetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void USBD_GetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
@@ -843,7 +850,7 @@ static void USBD_GetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
* Handle Get Status request
|
* Handle Get Status request
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval status
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void USBD_GetStatus(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void USBD_GetStatus(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
@@ -884,7 +891,7 @@ static void USBD_GetStatus(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
* Handle Set device feature request
|
* Handle Set device feature request
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval status
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void USBD_SetFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void USBD_SetFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
@@ -895,7 +902,7 @@ static void USBD_SetFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
}
|
}
|
||||||
else if (req->wValue == USB_FEATURE_TEST_MODE)
|
else if (req->wValue == USB_FEATURE_TEST_MODE)
|
||||||
{
|
{
|
||||||
pdev->dev_test_mode = req->wIndex >> 8;
|
pdev->dev_test_mode = (uint8_t)(req->wIndex >> 8);
|
||||||
(void)USBD_CtlSendStatus(pdev);
|
(void)USBD_CtlSendStatus(pdev);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -910,7 +917,7 @@ static void USBD_SetFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
* Handle clear device feature request
|
* Handle clear device feature request
|
||||||
* @param pdev: device instance
|
* @param pdev: device instance
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
* @retval status
|
* @retval None
|
||||||
*/
|
*/
|
||||||
static void USBD_ClrFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
static void USBD_ClrFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||||
{
|
{
|
||||||
@@ -936,8 +943,8 @@ static void USBD_ClrFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||||||
/**
|
/**
|
||||||
* @brief USBD_ParseSetupRequest
|
* @brief USBD_ParseSetupRequest
|
||||||
* Copy buffer into setup structure
|
* Copy buffer into setup structure
|
||||||
* @param pdev: device instance
|
|
||||||
* @param req: usb request
|
* @param req: usb request
|
||||||
|
* @param pdata: setup data pointer
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata)
|
void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata)
|
||||||
@@ -997,7 +1004,7 @@ void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pdesc = desc;
|
pdesc = desc;
|
||||||
*len = ((uint16_t)USBD_GetLen(pdesc) * 2U) + 2U;
|
*len = MIN(USBD_MAX_STR_DESC_SIZ, ((uint16_t)USBD_GetLen(pdesc) * 2U) + 2U);
|
||||||
|
|
||||||
unicode[idx] = *(uint8_t *)len;
|
unicode[idx] = *(uint8_t *)len;
|
||||||
idx++;
|
idx++;
|
||||||
|
|||||||
@@ -374,7 +374,9 @@ uint8_t *USBD_Class_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *le
|
|||||||
*/
|
*/
|
||||||
static void Get_SerialNum(void)
|
static void Get_SerialNum(void)
|
||||||
{
|
{
|
||||||
uint32_t deviceserial0, deviceserial1, deviceserial2;
|
uint32_t deviceserial0;
|
||||||
|
uint32_t deviceserial1;
|
||||||
|
uint32_t deviceserial2;
|
||||||
|
|
||||||
deviceserial0 = *(uint32_t *)DEVICE_ID1;
|
deviceserial0 = *(uint32_t *)DEVICE_ID1;
|
||||||
deviceserial1 = *(uint32_t *)DEVICE_ID2;
|
deviceserial1 = *(uint32_t *)DEVICE_ID2;
|
||||||
|
|||||||
86
LICENSE.txt
86
LICENSE.txt
@@ -1,86 +0,0 @@
|
|||||||
This software component is provided to you as part of a software package and
|
|
||||||
applicable license terms are in the Package_license file. If you received this
|
|
||||||
software component outside of a package or without applicable license terms,
|
|
||||||
the terms of the SLA0044 license shall apply and are fully reproduced below:
|
|
||||||
|
|
||||||
SLA0044 Rev5/February 2018
|
|
||||||
|
|
||||||
Software license agreement
|
|
||||||
|
|
||||||
ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT
|
|
||||||
|
|
||||||
BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE
|
|
||||||
OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS
|
|
||||||
INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES
|
|
||||||
(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON
|
|
||||||
BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES
|
|
||||||
TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT.
|
|
||||||
|
|
||||||
Under STMicroelectronics’ intellectual property rights, the redistribution,
|
|
||||||
reproduction and use in source and binary forms of the software or any part
|
|
||||||
thereof, with or without modification, are permitted provided that the following
|
|
||||||
conditions are met:
|
|
||||||
|
|
||||||
1. Redistribution of source code (modified or not) must retain any copyright
|
|
||||||
notice, this list of conditions and the disclaimer set forth below as items 10
|
|
||||||
and 11.
|
|
||||||
|
|
||||||
2. Redistributions in binary form, except as embedded into microcontroller or
|
|
||||||
microprocessor device manufactured by or for STMicroelectronics or a software
|
|
||||||
update for such device, must reproduce any copyright notice provided with the
|
|
||||||
binary code, this list of conditions, and the disclaimer set forth below as
|
|
||||||
items 10 and 11, in documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
|
|
||||||
3. Neither the name of STMicroelectronics nor the names of other contributors to
|
|
||||||
this software may be used to endorse or promote products derived from this
|
|
||||||
software or part thereof without specific written permission.
|
|
||||||
|
|
||||||
4. This software or any part thereof, including modifications and/or derivative
|
|
||||||
works of this software, must be used and execute solely and exclusively on or in
|
|
||||||
combination with a microcontroller or microprocessor device manufactured by or
|
|
||||||
for STMicroelectronics.
|
|
||||||
|
|
||||||
5. No use, reproduction or redistribution of this software partially or totally
|
|
||||||
may be done in any manner that would subject this software to any Open Source
|
|
||||||
Terms. “Open Source Terms” shall mean any open source license which requires as
|
|
||||||
part of distribution of software that the source code of such software is
|
|
||||||
distributed therewith or otherwise made available, or open source license that
|
|
||||||
substantially complies with the Open Source definition specified at
|
|
||||||
www.opensource.org and any other comparable open source license such as for
|
|
||||||
example GNU General Public License (GPL), Eclipse Public License (EPL), Apache
|
|
||||||
Software License, BSD license or MIT license.
|
|
||||||
|
|
||||||
6. STMicroelectronics has no obligation to provide any maintenance, support or
|
|
||||||
updates for the software.
|
|
||||||
|
|
||||||
7. The software is and will remain the exclusive property of STMicroelectronics
|
|
||||||
and its licensors. The recipient will not take any action that jeopardizes
|
|
||||||
STMicroelectronics and its licensors' proprietary rights or acquire any rights
|
|
||||||
in the software, except the limited rights specified hereunder.
|
|
||||||
|
|
||||||
8. The recipient shall comply with all applicable laws and regulations affecting
|
|
||||||
the use of the software or any part thereof including any applicable export
|
|
||||||
control law or regulation.
|
|
||||||
|
|
||||||
9. Redistribution and use of this software or any part thereof other than as
|
|
||||||
permitted under this license is void and will automatically terminate your
|
|
||||||
rights under this license.
|
|
||||||
|
|
||||||
10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE
|
|
||||||
DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL
|
|
||||||
STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
||||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER
|
|
||||||
EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY
|
|
||||||
RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.
|
|
||||||
|
|
||||||
32
README.md
32
README.md
@@ -1,29 +1,31 @@
|
|||||||
# Middleware USB Device MCU Component
|
# Middleware USB Device MCU Component
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
**STM32Cube** is an STMicroelectronics original initiative to ease the developers life by reducing efforts, time and cost.
|
**STM32Cube** is an STMicroelectronics original initiative to ease developers' life by reducing efforts, time and cost.
|
||||||
|
|
||||||
**STM32Cube** covers the overall STM32 products portfolio. It includes a comprehensive embedded software platform, delivered for each STM32 series.
|
**STM32Cube** covers the overall STM32 products portfolio. It includes a comprehensive embedded software platform delivered for each STM32 series.
|
||||||
* The CMSIS modules (core and device) corresponding to the ARM(tm) core implemented in this STM32 product.
|
* The CMSIS modules (core and device) corresponding to the ARM(tm) core implemented in this STM32 product.
|
||||||
* The STM32 HAL-LL drivers : an abstraction drivers layer, the API ensuring maximized portability across the STM32 portfolio.
|
* The STM32 HAL-LL drivers, an abstraction layer offering a set of APIs ensuring maximized portability across the STM32 portfolio.
|
||||||
* The BSP Drivers of each evaluation or demonstration board provided by this STM32 series.
|
* The BSP drivers of each evaluation, demonstration or nucleo board provided for this STM32 series.
|
||||||
* A consistent set of middlewares components such as RTOS, USB, FatFS, Graphics, STM32_TouchSensing_Library...
|
* A consistent set of middleware libraries such as RTOS, USB, FatFS, graphics, touch sensing library...
|
||||||
* A full set of software projects (basic examples, applications or demonstrations) for each board provided by this STM32 series.
|
* A full set of software projects (basic examples, applications, and demonstrations) for each board provided for this STM32 series.
|
||||||
|
|
||||||
Two models of publication are proposed for the STM32Cube embedded software:
|
Two models of publication are proposed for the STM32Cube embedded software:
|
||||||
* The monolithic **MCU Package** : all STM32Cube software modules of one STM32 series are present (Drivers, Middlewares, Projects, Utilities) in the repo (usual name **STM32Cubexx**, xx corresponding to the STM32 series).
|
* The monolithic **MCU Package**: all STM32Cube software modules of one STM32 series are present (Drivers, Middleware, Projects, Utilities) in the repository (usual name **STM32Cubexx**, xx corresponding to the STM32 series).
|
||||||
* The **MCU component** : progressively from November 2019, each STM32Cube software module being part of the STM32Cube MCU Package, will be delivered as an individual repo, allowing the user to select and get only the required software functions.
|
* The **MCU component**: each STM32Cube software module being part of the STM32Cube MCU Package, is delivered as an individual repository, allowing the user to select and get only the required software functions.
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
This **stm32_mw_usb_device** MCU component repository is one element **common to all** STM32Cube MCU embedded software packages, providing the **USB Device MCU Middleware** part.
|
This **stm32_mw_usb_device** MCU component repository is one element **common to all** STM32Cube MCU embedded software packages, providing the **USB Device MCU Middleware** part.
|
||||||
|
|
||||||
## License
|
It represents ST offer to ensure the support of USB Devices on STM32 MCUs.
|
||||||
|
It includes two main modules:
|
||||||
Copyright (c) 2015 STMicroelectronics.
|
* **Core** module for the USB device standard peripheral control APIs. It includes the files ensuring USB 2.0 standard code implementation for an USB device.
|
||||||
|
These files’ APIs will be called within every USB device application regardless of the desired functionality.
|
||||||
This software component is licensed by ST under Ultimate Liberty license SLA0044, the "License". You may not use this file except in compliance with this license. You may obtain a copy of the license [here](https://www.st.com/SLA0044).
|
* **Class** module for the commonly supported classes APIs. it includes the files including different USB device classes. All STM32 USB classes are implemented according to the USB 2.0 and every class’s specifications. These files’ APIs will be called within USB device applications according to the desired functionality.
|
||||||
|
|
||||||
## Release note
|
## Release note
|
||||||
|
|
||||||
@@ -31,6 +33,4 @@ Details about the content of this release are available in the release note [her
|
|||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
If you have any issue with the **software content** of this repository, you can file an issue [here](https://github.com/STMicroelectronics/stm32_mw_usb_device/issues/new/choose).
|
Please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) guide.
|
||||||
|
|
||||||
For any other question related to the product, the tools, the environment, you can submit a topic to the [ST Community](https://community.st.com/s/).
|
|
||||||
2541
Release_Notes.html
2541
Release_Notes.html
File diff suppressed because it is too large
Load Diff
31
SECURITY.md
Normal file
31
SECURITY.md
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# Report potential product security vulnerabilities
|
||||||
|
|
||||||
|
ST places a high priority on security, and our Product Security Incident
|
||||||
|
Response Team (PSIRT) is committed to rapidly addressing potential security
|
||||||
|
vulnerabilities affecting our products. PSIRT's long history and vast experience
|
||||||
|
in security allows ST to perform clear analyses and provide appropriate guidance
|
||||||
|
on mitigations and solutions when applicable.
|
||||||
|
|
||||||
|
If you wish to report potential security vulnerabilities regarding our products,
|
||||||
|
**please do not report them through public GitHub issues.** Instead, we
|
||||||
|
encourage you to report them to our ST PSIRT following the process described at:
|
||||||
|
**https://www.st.com/content/st_com/en/security/report-vulnerabilities.html**
|
||||||
|
|
||||||
|
### IMPORTANT - READ CAREFULLY:
|
||||||
|
|
||||||
|
STMicroelectronics International N.V., on behalf of itself, its affiliates and
|
||||||
|
subsidiaries, (collectively “ST”) takes all potential security vulnerability
|
||||||
|
reports or other related communications (“Report(s)”) seriously. In order to
|
||||||
|
review Your Report (the terms “You” and “Yours” include your employer, and all
|
||||||
|
affiliates, subsidiaries and related persons or entities) and take actions as
|
||||||
|
deemed appropriate, ST requires that we have the rights and Your permission to
|
||||||
|
do so.
|
||||||
|
|
||||||
|
As such, by submitting Your Report to ST, You agree that You have the right to
|
||||||
|
do so, and You grant to ST the rights to use the Report for purposes related to
|
||||||
|
security vulnerability analysis, testing, correction, patching, reporting and
|
||||||
|
any other related purpose or function.
|
||||||
|
|
||||||
|
By submitting Your Report, You agree that ST’s
|
||||||
|
[Privacy Policy](https://www.st.com/content/st_com/en/common/privacy-portal.html)
|
||||||
|
applies to all related communications.
|
||||||
BIN
_htmresc/favicon.png
Normal file
BIN
_htmresc/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
1711
_htmresc/mini-st.css
Normal file
1711
_htmresc/mini-st.css
Normal file
File diff suppressed because it is too large
Load Diff
BIN
_htmresc/st_logo_2020.png
Normal file
BIN
_htmresc/st_logo_2020.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
Reference in New Issue
Block a user