mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 19:10:32 +03:00
[H7][LIB][USB] Modify USB Library for composite device
Includes changes from 4e487f6
This commit is contained in:
parent
c3f2632405
commit
fd11348dce
7 changed files with 93 additions and 106 deletions
|
@ -462,11 +462,11 @@ static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||
|
||||
if (hcdc == NULL)
|
||||
{
|
||||
pdev->pClassData = NULL;
|
||||
pdev->pCDC_ClassData = NULL;
|
||||
return (uint8_t)USBD_EMEM;
|
||||
}
|
||||
|
||||
pdev->pClassData = (void *)hcdc;
|
||||
pdev->pCDC_ClassData = (void *)hcdc;
|
||||
|
||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||
{
|
||||
|
@ -508,7 +508,7 @@ static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||
pdev->ep_in[CDC_CMD_EP & 0xFU].is_used = 1U;
|
||||
|
||||
/* Init physical Interface components */
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Init();
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pCDC_UserData)->Init();
|
||||
|
||||
/* Init Xfer states */
|
||||
hcdc->TxState = 0U;
|
||||
|
@ -556,11 +556,11 @@ static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||
pdev->ep_in[CDC_CMD_EP & 0xFU].bInterval = 0U;
|
||||
|
||||
/* DeInit physical Interface components */
|
||||
if (pdev->pClassData != NULL)
|
||||
if (pdev->pCDC_ClassData != NULL)
|
||||
{
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->DeInit();
|
||||
(void)USBD_free(pdev->pClassData);
|
||||
pdev->pClassData = NULL;
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pCDC_UserData)->DeInit();
|
||||
(void)USBD_free(pdev->pCDC_ClassData);
|
||||
pdev->pCDC_ClassData = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -576,7 +576,7 @@ static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||
static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev,
|
||||
USBD_SetupReqTypedef *req)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pCDC_ClassData;
|
||||
uint8_t ifalt = 0U;
|
||||
uint16_t status_info = 0U;
|
||||
USBD_StatusTypeDef ret = USBD_OK;
|
||||
|
@ -588,7 +588,7 @@ static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev,
|
|||
{
|
||||
if ((req->bmRequest & 0x80U) != 0U)
|
||||
{
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest,
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pCDC_UserData)->Control(req->bRequest,
|
||||
(uint8_t *)hcdc->data,
|
||||
req->wLength);
|
||||
|
||||
|
@ -604,7 +604,7 @@ static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev,
|
|||
}
|
||||
else
|
||||
{
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest,
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pCDC_UserData)->Control(req->bRequest,
|
||||
(uint8_t *)req, 0U);
|
||||
}
|
||||
break;
|
||||
|
@ -675,12 +675,12 @@ static uint8_t USBD_CDC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||
USBD_CDC_HandleTypeDef *hcdc;
|
||||
PCD_HandleTypeDef *hpcd = pdev->pData;
|
||||
|
||||
if (pdev->pClassData == NULL)
|
||||
if (pdev->pCDC_ClassData == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
|
||||
hcdc = (USBD_CDC_HandleTypeDef *)pdev->pCDC_ClassData;
|
||||
|
||||
if ((pdev->ep_in[epnum].total_length > 0U) &&
|
||||
((pdev->ep_in[epnum].total_length % hpcd->IN_ep[epnum].maxpacket) == 0U))
|
||||
|
@ -694,7 +694,7 @@ static uint8_t USBD_CDC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||
else
|
||||
{
|
||||
hcdc->TxState = 0U;
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum);
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pCDC_UserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum);
|
||||
}
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
|
@ -709,9 +709,9 @@ static uint8_t USBD_CDC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||
*/
|
||||
static uint8_t USBD_CDC_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pCDC_ClassData;
|
||||
|
||||
if (pdev->pClassData == NULL)
|
||||
if (pdev->pCDC_ClassData == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
@ -722,7 +722,7 @@ static uint8_t USBD_CDC_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||
/* USB data will be immediately processed, this allow next USB traffic being
|
||||
NAKed till the end of the application Xfer */
|
||||
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Receive(hcdc->RxBuffer, &hcdc->RxLength);
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pCDC_UserData)->Receive(hcdc->RxBuffer, &hcdc->RxLength);
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
@ -735,11 +735,11 @@ static uint8_t USBD_CDC_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||
*/
|
||||
static uint8_t USBD_CDC_EP0_RxReady(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pCDC_ClassData;
|
||||
|
||||
if ((pdev->pUserData != NULL) && (hcdc->CmdOpCode != 0xFFU))
|
||||
if ((pdev->pCDC_UserData != NULL) && (hcdc->CmdOpCode != 0xFFU))
|
||||
{
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(hcdc->CmdOpCode,
|
||||
((USBD_CDC_ItfTypeDef *)pdev->pCDC_UserData)->Control(hcdc->CmdOpCode,
|
||||
(uint8_t *)hcdc->data,
|
||||
(uint16_t)hcdc->CmdLength);
|
||||
hcdc->CmdOpCode = 0xFFU;
|
||||
|
@ -818,7 +818,7 @@ uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
|
|||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
pdev->pUserData = fops;
|
||||
pdev->pCDC_UserData = fops;
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
@ -832,7 +832,7 @@ uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
|
|||
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
|
||||
uint8_t *pbuff, uint32_t length)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pCDC_ClassData;
|
||||
|
||||
hcdc->TxBuffer = pbuff;
|
||||
hcdc->TxLength = length;
|
||||
|
@ -849,7 +849,7 @@ uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
|
|||
*/
|
||||
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pCDC_ClassData;
|
||||
|
||||
hcdc->RxBuffer = pbuff;
|
||||
|
||||
|
@ -864,10 +864,10 @@ uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
|
|||
*/
|
||||
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pCDC_ClassData;
|
||||
USBD_StatusTypeDef ret = USBD_BUSY;
|
||||
|
||||
if (pdev->pClassData == NULL)
|
||||
if (pdev->pCDC_ClassData == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
@ -898,9 +898,9 @@ uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev)
|
|||
*/
|
||||
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pCDC_ClassData;
|
||||
|
||||
if (pdev->pClassData == NULL)
|
||||
if (pdev->pCDC_ClassData == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
|
|
@ -41,12 +41,12 @@ extern "C" {
|
|||
/** @defgroup USBD_HID_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
#define HID_EPIN_ADDR 0x81U
|
||||
#define HID_EPIN_SIZE 0x04U
|
||||
#define HID_EPIN_ADDR 0x83U
|
||||
#define HID_EPIN_SIZE 0x08U
|
||||
|
||||
#define USB_HID_CONFIG_DESC_SIZ 34U
|
||||
#define USB_HID_DESC_SIZ 9U
|
||||
#define HID_MOUSE_REPORT_DESC_SIZE 74U
|
||||
#define HID_MOUSE_REPORT_DESC_SIZE 54U
|
||||
|
||||
#define HID_DESCRIPTOR_TYPE 0x21U
|
||||
#define HID_REPORT_DESC 0x22U
|
||||
|
|
|
@ -296,52 +296,34 @@ __ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_
|
|||
};
|
||||
|
||||
__ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] __ALIGN_END = {
|
||||
0x05, 0x01,
|
||||
0x09, 0x02,
|
||||
0xA1, 0x01,
|
||||
0x09, 0x01,
|
||||
|
||||
0xA1, 0x00,
|
||||
0x05, 0x09,
|
||||
0x19, 0x01,
|
||||
0x29, 0x03,
|
||||
|
||||
0x15, 0x00,
|
||||
0x25, 0x01,
|
||||
0x95, 0x03,
|
||||
0x75, 0x01,
|
||||
|
||||
0x81, 0x02,
|
||||
0x95, 0x01,
|
||||
0x75, 0x05,
|
||||
0x81, 0x01,
|
||||
|
||||
0x05, 0x01,
|
||||
0x09, 0x30,
|
||||
0x09, 0x31,
|
||||
0x09, 0x38,
|
||||
|
||||
0x15, 0x81,
|
||||
0x25, 0x7F,
|
||||
0x75, 0x08,
|
||||
0x95, 0x03,
|
||||
|
||||
0x81, 0x06,
|
||||
0xC0, 0x09,
|
||||
0x3c, 0x05,
|
||||
0xff, 0x09,
|
||||
|
||||
0x01, 0x15,
|
||||
0x00, 0x25,
|
||||
0x01, 0x75,
|
||||
0x01, 0x95,
|
||||
|
||||
0x02, 0xb1,
|
||||
0x22, 0x75,
|
||||
0x06, 0x95,
|
||||
0x01, 0xb1,
|
||||
|
||||
0x01, 0xc0
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
0x09, 0x05, // USAGE (Game Pad)
|
||||
0xa1, 0x01, // COLLECTION (Application)
|
||||
0xa1, 0x00, // COLLECTION (Physical)
|
||||
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
||||
0x09, 0x30, // USAGE (X)
|
||||
0x09, 0x31, // USAGE (Y)
|
||||
0x09, 0x32, // USAGE (Z)
|
||||
0x09, 0x33, // USAGE (Rx)
|
||||
0x09, 0x35, // USAGE (Rz)
|
||||
0x09, 0x34, // USAGE (Ry)
|
||||
0x09, 0x36, // USAGE (Slider)
|
||||
0x09, 0x37, // USAGE (Dial)
|
||||
0x15, 0x81, // LOGICAL_MINIMUM (-127)
|
||||
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
|
||||
0x75, 0x08, // REPORT_SIZE (8)
|
||||
0x95, 0x08, // REPORT_COUNT (8)
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
0x05, 0x09, // USAGE_PAGE (Button)
|
||||
0x19, 0x01, // USAGE_MINIMUM (Button 1)
|
||||
0x29, 0x08, // USAGE_MAXIMUM (Button 8)
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
||||
0x95, 0x08, // REPORT_COUNT (8)
|
||||
0x75, 0x01, // REPORT_SIZE (1)
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
0xc0, // END_COLLECTION
|
||||
0xc0 /* END_COLLECTION */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -369,11 +351,11 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||
|
||||
if (hhid == NULL)
|
||||
{
|
||||
pdev->pClassData = NULL;
|
||||
pdev->pHID_ClassData = NULL;
|
||||
return (uint8_t)USBD_EMEM;
|
||||
}
|
||||
|
||||
pdev->pClassData = (void *)hhid;
|
||||
pdev->pHID_ClassData = (void *)hhid;
|
||||
|
||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||
{
|
||||
|
@ -410,10 +392,10 @@ static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||
pdev->ep_in[HID_EPIN_ADDR & 0xFU].bInterval = 0U;
|
||||
|
||||
/* FRee allocated memory */
|
||||
if (pdev->pClassData != NULL)
|
||||
if (pdev->pHID_ClassData != NULL)
|
||||
{
|
||||
(void)USBD_free(pdev->pClassData);
|
||||
pdev->pClassData = NULL;
|
||||
(void)USBD_free(pdev->pHID_ClassData);
|
||||
pdev->pHID_ClassData = NULL;
|
||||
}
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
|
@ -428,7 +410,7 @@ static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||
*/
|
||||
static uint8_t USBD_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||
{
|
||||
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef *)pdev->pHID_ClassData;
|
||||
USBD_StatusTypeDef ret = USBD_OK;
|
||||
uint16_t len;
|
||||
uint8_t *pbuf;
|
||||
|
@ -548,7 +530,7 @@ static uint8_t USBD_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *re
|
|||
*/
|
||||
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev, uint8_t *report, uint16_t len)
|
||||
{
|
||||
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef *)pdev->pHID_ClassData;
|
||||
|
||||
if (pdev->dev_state == USBD_STATE_CONFIGURED)
|
||||
{
|
||||
|
@ -644,7 +626,7 @@ static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||
UNUSED(epnum);
|
||||
/* 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 */
|
||||
((USBD_HID_HandleTypeDef *)pdev->pClassData)->state = HID_IDLE;
|
||||
((USBD_HID_HandleTypeDef *)pdev->pHID_ClassData)->state = HID_IDLE;
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
|
|
@ -285,11 +285,11 @@ uint8_t USBD_MSC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||
|
||||
if (hmsc == NULL)
|
||||
{
|
||||
pdev->pClassData = NULL;
|
||||
pdev->pMSC_ClassData = NULL;
|
||||
return (uint8_t)USBD_EMEM;
|
||||
}
|
||||
|
||||
pdev->pClassData = (void *)hmsc;
|
||||
pdev->pMSC_ClassData = (void *)hmsc;
|
||||
|
||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||
{
|
||||
|
@ -341,10 +341,10 @@ uint8_t USBD_MSC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||
MSC_BOT_DeInit(pdev);
|
||||
|
||||
/* Free MSC Class Resources */
|
||||
if (pdev->pClassData != NULL)
|
||||
if (pdev->pMSC_ClassData != NULL)
|
||||
{
|
||||
(void)USBD_free(pdev->pClassData);
|
||||
pdev->pClassData = NULL;
|
||||
(void)USBD_free(pdev->pMSC_ClassData);
|
||||
pdev->pMSC_ClassData = NULL;
|
||||
}
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
|
@ -358,7 +358,7 @@ uint8_t USBD_MSC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
|||
*/
|
||||
uint8_t USBD_MSC_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||
{
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pMSC_ClassData;
|
||||
USBD_StatusTypeDef ret = USBD_OK;
|
||||
uint16_t status_info = 0U;
|
||||
|
||||
|
@ -372,7 +372,7 @@ uint8_t USBD_MSC_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
|||
if ((req->wValue == 0U) && (req->wLength == 1U) &&
|
||||
((req->bmRequest & 0x80U) == 0x80U))
|
||||
{
|
||||
hmsc->max_lun = (uint32_t)((USBD_StorageTypeDef *)pdev->pUserData)->GetMaxLun();
|
||||
hmsc->max_lun = (uint32_t)((USBD_StorageTypeDef *)pdev->pMSC_UserData)->GetMaxLun();
|
||||
(void)USBD_CtlSendData(pdev, (uint8_t *)&hmsc->max_lun, 1U);
|
||||
}
|
||||
else
|
||||
|
@ -562,7 +562,7 @@ uint8_t USBD_MSC_RegisterStorage(USBD_HandleTypeDef *pdev, USBD_StorageTypeDef *
|
|||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
pdev->pUserData = fops;
|
||||
pdev->pMSC_UserData = fops;
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ static void MSC_BOT_Abort(USBD_HandleTypeDef *pdev);
|
|||
*/
|
||||
void MSC_BOT_Init(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pMSC_ClassData;
|
||||
|
||||
hmsc->bot_state = USBD_BOT_IDLE;
|
||||
hmsc->bot_status = USBD_BOT_STATUS_NORMAL;
|
||||
|
@ -106,7 +106,7 @@ void MSC_BOT_Init(USBD_HandleTypeDef *pdev)
|
|||
hmsc->scsi_sense_head = 0U;
|
||||
hmsc->scsi_medium_state = SCSI_MEDIUM_UNLOCKED;
|
||||
|
||||
((USBD_StorageTypeDef *)pdev->pUserData)->Init(0U);
|
||||
((USBD_StorageTypeDef *)pdev->pMSC_UserData)->Init(0U);
|
||||
|
||||
(void)USBD_LL_FlushEP(pdev, MSC_EPOUT_ADDR);
|
||||
(void)USBD_LL_FlushEP(pdev, MSC_EPIN_ADDR);
|
||||
|
@ -124,7 +124,7 @@ void MSC_BOT_Init(USBD_HandleTypeDef *pdev)
|
|||
*/
|
||||
void MSC_BOT_Reset(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pMSC_ClassData;
|
||||
|
||||
hmsc->bot_state = USBD_BOT_IDLE;
|
||||
hmsc->bot_status = USBD_BOT_STATUS_RECOVERY;
|
||||
|
@ -145,7 +145,7 @@ void MSC_BOT_Reset(USBD_HandleTypeDef *pdev)
|
|||
*/
|
||||
void MSC_BOT_DeInit(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pMSC_ClassData;
|
||||
hmsc->bot_state = USBD_BOT_IDLE;
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ void MSC_BOT_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||
{
|
||||
UNUSED(epnum);
|
||||
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pMSC_ClassData;
|
||||
|
||||
switch (hmsc->bot_state)
|
||||
{
|
||||
|
@ -191,7 +191,7 @@ void MSC_BOT_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||
{
|
||||
UNUSED(epnum);
|
||||
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pMSC_ClassData;
|
||||
|
||||
switch (hmsc->bot_state)
|
||||
{
|
||||
|
@ -219,7 +219,7 @@ void MSC_BOT_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
|||
*/
|
||||
static void MSC_BOT_CBW_Decode(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pMSC_ClassData;
|
||||
|
||||
hmsc->csw.dTag = hmsc->cbw.dTag;
|
||||
hmsc->csw.dDataResidue = hmsc->cbw.dDataLength;
|
||||
|
@ -282,7 +282,7 @@ static void MSC_BOT_CBW_Decode(USBD_HandleTypeDef *pdev)
|
|||
*/
|
||||
static void MSC_BOT_SendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint32_t len)
|
||||
{
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pMSC_ClassData;
|
||||
|
||||
uint32_t length = MIN(hmsc->cbw.dDataLength, len);
|
||||
|
||||
|
@ -302,7 +302,7 @@ static void MSC_BOT_SendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint32_t
|
|||
*/
|
||||
void MSC_BOT_SendCSW(USBD_HandleTypeDef *pdev, uint8_t CSW_Status)
|
||||
{
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pMSC_ClassData;
|
||||
|
||||
hmsc->csw.dSignature = USBD_BOT_CSW_SIGNATURE;
|
||||
hmsc->csw.bStatus = CSW_Status;
|
||||
|
@ -325,7 +325,7 @@ void MSC_BOT_SendCSW(USBD_HandleTypeDef *pdev, uint8_t CSW_Status)
|
|||
|
||||
static void MSC_BOT_Abort(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pMSC_ClassData;
|
||||
|
||||
if ((hmsc->cbw.bmFlags == 0U) &&
|
||||
(hmsc->cbw.dDataLength != 0U) &&
|
||||
|
@ -353,7 +353,7 @@ static void MSC_BOT_Abort(USBD_HandleTypeDef *pdev)
|
|||
|
||||
void MSC_BOT_CplClrFeature(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
{
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pMSC_ClassData;
|
||||
|
||||
if (hmsc->bot_status == USBD_BOT_STATUS_ERROR) /* Bad CBW Signature */
|
||||
{
|
||||
|
|
|
@ -287,11 +287,16 @@ typedef struct _USBD_HandleTypeDef
|
|||
USBD_SetupReqTypedef request;
|
||||
USBD_DescriptorsTypeDef *pDesc;
|
||||
USBD_ClassTypeDef *pClass;
|
||||
void *pClassData;
|
||||
void *pUserData;
|
||||
void *pData;
|
||||
void *pBosDesc;
|
||||
void *pConfDesc;
|
||||
//WARNING: When updating this middleware add this to structure:
|
||||
void *pCDC_ClassData;
|
||||
void *pCDC_UserData;
|
||||
void *pHID_ClassData;
|
||||
void *pHID_UserData;
|
||||
void *pMSC_ClassData;
|
||||
void *pMSC_UserData;
|
||||
void *pData;
|
||||
} USBD_HandleTypeDef;
|
||||
|
||||
/**
|
||||
|
|
|
@ -501,7 +501,7 @@ USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
|
|||
pdev->dev_config = 0U;
|
||||
pdev->dev_remote_wakeup = 0U;
|
||||
|
||||
if (pdev->pClassData != NULL)
|
||||
if (pdev->pMSC_ClassData || pdev->pCDC_ClassData || pdev->pHID_ClassData)
|
||||
{
|
||||
pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue