mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 19:10:32 +03:00
Use static definition for ClassData to support USB MSC DMA on G4
This commit is contained in:
parent
86aa5cc84e
commit
f39467c396
4 changed files with 14 additions and 34 deletions
|
@ -283,6 +283,7 @@ __ALIGN_BEGIN uint8_t USBD_MSC_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static DMA_DATA_ZERO_INIT USBD_MSC_BOT_HandleTypeDef ClassData;
|
||||||
|
|
||||||
/** @defgroup MSC_CORE_Private_Functions
|
/** @defgroup MSC_CORE_Private_Functions
|
||||||
* @{
|
* @{
|
||||||
|
@ -328,18 +329,12 @@ uint8_t USBD_MSC_Init (USBD_HandleTypeDef *pdev,
|
||||||
USBD_EP_TYPE_BULK,
|
USBD_EP_TYPE_BULK,
|
||||||
MSC_MAX_FS_PACKET);
|
MSC_MAX_FS_PACKET);
|
||||||
}
|
}
|
||||||
pdev->pClassData = USBD_malloc(sizeof (USBD_MSC_BOT_HandleTypeDef));
|
|
||||||
|
pdev->pMSC_ClassData = (void *)&ClassData;
|
||||||
if(pdev->pClassData == NULL)
|
|
||||||
{
|
/* Init the BOT layer */
|
||||||
ret = 1;
|
MSC_BOT_Init(pdev);
|
||||||
}
|
ret = 0;
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Init the BOT layer */
|
|
||||||
MSC_BOT_Init(pdev);
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,8 +281,9 @@ __ALIGN_BEGIN uint8_t USBD_MSC_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static DMA_DATA_ZERO_INIT USBD_MSC_BOT_HandleTypeDef ClassData;
|
||||||
|
|
||||||
/** @defgroup MSC_CORE_Private_Functions
|
/** @defgroup MSC_CORE_Private_Functions
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -317,12 +318,8 @@ uint8_t USBD_MSC_Init (USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||||
USBD_LL_OpenEP(pdev, MSC_EPIN_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
|
USBD_LL_OpenEP(pdev, MSC_EPIN_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
|
||||||
pdev->ep_in[MSC_EPIN_ADDR & 0xFU].is_used = 1U;
|
pdev->ep_in[MSC_EPIN_ADDR & 0xFU].is_used = 1U;
|
||||||
}
|
}
|
||||||
pdev->pMSC_ClassData = USBD_malloc(sizeof (USBD_MSC_BOT_HandleTypeDef));
|
|
||||||
|
|
||||||
if(pdev->pMSC_ClassData == NULL)
|
pdev->pMSC_ClassData = (void *)&ClassData;
|
||||||
{
|
|
||||||
return USBD_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Init the BOT layer */
|
/* Init the BOT layer */
|
||||||
MSC_BOT_Init(pdev);
|
MSC_BOT_Init(pdev);
|
||||||
|
|
|
@ -281,6 +281,7 @@ __ALIGN_BEGIN uint8_t USBD_MSC_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static DMA_DATA_ZERO_INIT USBD_MSC_BOT_HandleTypeDef ClassData;
|
||||||
|
|
||||||
/** @defgroup MSC_CORE_Private_Functions
|
/** @defgroup MSC_CORE_Private_Functions
|
||||||
* @{
|
* @{
|
||||||
|
@ -297,6 +298,8 @@ uint8_t USBD_MSC_Init (USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||||
{
|
{
|
||||||
UNUSED(cfgidx);
|
UNUSED(cfgidx);
|
||||||
|
|
||||||
|
pdev->pMSC_ClassData = (void *)&ClassData;
|
||||||
|
|
||||||
if(pdev->dev_speed == USBD_SPEED_HIGH)
|
if(pdev->dev_speed == USBD_SPEED_HIGH)
|
||||||
{
|
{
|
||||||
/* Open EP OUT */
|
/* Open EP OUT */
|
||||||
|
@ -317,12 +320,6 @@ uint8_t USBD_MSC_Init (USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||||
USBD_LL_OpenEP(pdev, MSC_EPIN_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
|
USBD_LL_OpenEP(pdev, MSC_EPIN_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
|
||||||
pdev->ep_in[MSC_EPIN_ADDR & 0xFU].is_used = 1U;
|
pdev->ep_in[MSC_EPIN_ADDR & 0xFU].is_used = 1U;
|
||||||
}
|
}
|
||||||
pdev->pMSC_ClassData = USBD_malloc(sizeof (USBD_MSC_BOT_HandleTypeDef));
|
|
||||||
|
|
||||||
if(pdev->pMSC_ClassData == NULL)
|
|
||||||
{
|
|
||||||
return USBD_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Init the BOT layer */
|
/* Init the BOT layer */
|
||||||
MSC_BOT_Init(pdev);
|
MSC_BOT_Init(pdev);
|
||||||
|
|
|
@ -281,17 +281,8 @@ static DMA_DATA_ZERO_INIT USBD_MSC_BOT_HandleTypeDef ClassData;
|
||||||
uint8_t USBD_MSC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
uint8_t USBD_MSC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||||
{
|
{
|
||||||
UNUSED(cfgidx);
|
UNUSED(cfgidx);
|
||||||
USBD_MSC_BOT_HandleTypeDef *hmsc;
|
|
||||||
|
|
||||||
hmsc = &ClassData;
|
pdev->pMSC_ClassData = (void *)&ClassData;
|
||||||
|
|
||||||
if (hmsc == NULL)
|
|
||||||
{
|
|
||||||
pdev->pMSC_ClassData = NULL;
|
|
||||||
return (uint8_t)USBD_EMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
pdev->pMSC_ClassData = (void *)hmsc;
|
|
||||||
|
|
||||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue