mirror of
https://github.com/STMicroelectronics/stm32-mw-usb-device.git
synced 2026-02-08 12:08:06 -05:00
Release v2.10.0
This commit is contained in:
@@ -113,8 +113,7 @@ typedef struct
|
||||
|
||||
__IO uint32_t TxState;
|
||||
__IO uint32_t RxState;
|
||||
}
|
||||
USBD_PRNT_HandleTypeDef;
|
||||
} USBD_PRNT_HandleTypeDef;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -102,27 +102,13 @@ static uint8_t USBD_PRNT_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
||||
static uint8_t USBD_PRNT_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
static uint8_t USBD_PRNT_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum);
|
||||
|
||||
#ifndef USE_USBD_COMPOSITE
|
||||
static uint8_t *USBD_PRNT_GetFSCfgDesc(uint16_t *length);
|
||||
static uint8_t *USBD_PRNT_GetHSCfgDesc(uint16_t *length);
|
||||
static uint8_t *USBD_PRNT_GetOtherSpeedCfgDesc(uint16_t *length);
|
||||
static uint8_t *USBD_PRNT_GetOtherSpeedCfgDesc(uint16_t *length);
|
||||
uint8_t *USBD_PRNT_GetDeviceQualifierDescriptor(uint16_t *length);
|
||||
|
||||
/* USB Standard Device Descriptor */
|
||||
__ALIGN_BEGIN static uint8_t USBD_PRNT_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
|
||||
{
|
||||
USB_LEN_DEV_QUALIFIER_DESC,
|
||||
USB_DESC_TYPE_DEVICE_QUALIFIER,
|
||||
0x00,
|
||||
0x02,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
};
|
||||
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -144,14 +130,22 @@ USBD_ClassTypeDef USBD_PRNT =
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
#else
|
||||
USBD_PRNT_GetHSCfgDesc,
|
||||
USBD_PRNT_GetFSCfgDesc,
|
||||
USBD_PRNT_GetOtherSpeedCfgDesc,
|
||||
USBD_PRNT_GetDeviceQualifierDescriptor,
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
};
|
||||
|
||||
#ifndef USE_USBD_COMPOSITE
|
||||
/* USB PRNT device Configuration Descriptor */
|
||||
__ALIGN_BEGIN static uint8_t USBD_PRNT_CfgHSDesc[] __ALIGN_END =
|
||||
__ALIGN_BEGIN static uint8_t USBD_PRNT_CfgDesc[] __ALIGN_END =
|
||||
{
|
||||
/*Configuration Descriptor*/
|
||||
0x09, /* bLength: Configuration Descriptor size */
|
||||
@@ -165,56 +159,7 @@ __ALIGN_BEGIN static uint8_t USBD_PRNT_CfgHSDesc[] __ALIGN_END =
|
||||
0xC0, /* bmAttributes: Self Powered according to user configuration */
|
||||
#else
|
||||
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||
#endif
|
||||
USBD_MAX_POWER, /* MaxPower in mA */
|
||||
|
||||
/* Interface Descriptor */
|
||||
0x09, /* bLength: Interface Descriptor size */
|
||||
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */
|
||||
0x00, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x02, /* bNumEndpoints: 2 endpoints used */
|
||||
0x07, /* bInterfaceClass: Communication Interface Class */
|
||||
0x01, /* bInterfaceSubClass: Abstract Control Model */
|
||||
USB_PRNT_BIDIRECTIONAL, /* bDeviceProtocol */
|
||||
0x00, /* iInterface */
|
||||
|
||||
/* Endpoint IN Descriptor */
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
|
||||
PRNT_IN_EP, /* bEndpointAddress */
|
||||
0x02, /* bmAttributes: Bulk */
|
||||
LOBYTE(PRNT_DATA_HS_IN_PACKET_SIZE), /* wMaxPacketSize */
|
||||
HIBYTE(PRNT_DATA_HS_IN_PACKET_SIZE),
|
||||
0x00, /* bInterval */
|
||||
|
||||
/* Endpoint OUT Descriptor */
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
|
||||
PRNT_OUT_EP, /* bEndpointAddress */
|
||||
0x02, /* bmAttributes: Bulk */
|
||||
LOBYTE(PRNT_DATA_HS_OUT_PACKET_SIZE),/* wMaxPacketSize */
|
||||
HIBYTE(PRNT_DATA_HS_OUT_PACKET_SIZE),
|
||||
0x00 /* bInterval */
|
||||
};
|
||||
|
||||
|
||||
/* USB PRNT device Configuration Descriptor */
|
||||
__ALIGN_BEGIN static uint8_t USBD_PRNT_CfgFSDesc[] __ALIGN_END =
|
||||
{
|
||||
/*Configuration Descriptor*/
|
||||
0x09, /* bLength: Configuration Descriptor size */
|
||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||
USB_PRNT_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */
|
||||
0x00,
|
||||
0x01, /* bNumInterfaces: 1 interface */
|
||||
0x01, /* bConfigurationValue: Configuration value */
|
||||
0x00, /* iConfiguration: Index of string descriptor describing the configuration */
|
||||
#if (USBD_SELF_POWERED == 1U)
|
||||
0xC0, /* bmAttributes: Self Powered according to user configuration */
|
||||
#else
|
||||
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||
#endif
|
||||
#endif /* USBD_SELF_POWERED */
|
||||
USBD_MAX_POWER, /* MaxPower in mA */
|
||||
|
||||
/*Interface Descriptor */
|
||||
@@ -247,52 +192,24 @@ __ALIGN_BEGIN static uint8_t USBD_PRNT_CfgFSDesc[] __ALIGN_END =
|
||||
0x00 /* bInterval */
|
||||
};
|
||||
|
||||
__ALIGN_BEGIN static uint8_t USBD_PRNT_OtherSpeedCfgDesc[] __ALIGN_END =
|
||||
/* USB Standard Device Descriptor */
|
||||
__ALIGN_BEGIN static uint8_t USBD_PRNT_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
|
||||
{
|
||||
/*Configuration Descriptor*/
|
||||
0x09, /* bLength: Configuration Descriptor size */
|
||||
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
|
||||
USB_PRNT_CONFIG_DESC_SIZ, /* wTotalLength:no of returned bytes */
|
||||
USB_LEN_DEV_QUALIFIER_DESC,
|
||||
USB_DESC_TYPE_DEVICE_QUALIFIER,
|
||||
0x00,
|
||||
0x02,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x40,
|
||||
0x01,
|
||||
0x00,
|
||||
0x01, /* bNumInterfaces: 1 interface */
|
||||
0x01, /* bConfigurationValue: Configuration value */
|
||||
0x00, /* iConfiguration: Index of string descriptor describing the configuration */
|
||||
#if (USBD_SELF_POWERED == 1U)
|
||||
0xC0, /* bmAttributes: Self Powered according to user configuration */
|
||||
#else
|
||||
0x80, /* bmAttributes: Bus Powered according to user configuration */
|
||||
#endif
|
||||
USBD_MAX_POWER, /* MaxPower in mA */
|
||||
|
||||
/*Interface Descriptor */
|
||||
0x09, /* bLength: Interface Descriptor size */
|
||||
USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */
|
||||
0x00, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x02, /* bNumEndpoints: 2 endpoints used */
|
||||
0x07, /* bInterfaceClass: Communication Interface Class */
|
||||
0x01, /* bInterfaceSubClass: Abstract Control Model */
|
||||
USB_PRNT_BIDIRECTIONAL, /* bDeviceProtocol */
|
||||
0x00, /* iInterface */
|
||||
|
||||
/*Endpoint IN Descriptor*/
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
|
||||
PRNT_IN_EP, /* bEndpointAddress */
|
||||
0x02, /* bmAttributes: Bulk */
|
||||
LOBYTE(PRNT_DATA_FS_IN_PACKET_SIZE), /* wMaxPacketSize */
|
||||
HIBYTE(PRNT_DATA_FS_IN_PACKET_SIZE),
|
||||
0x00, /* bInterval */
|
||||
|
||||
/*Endpoint OUT Descriptor*/
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
|
||||
PRNT_OUT_EP, /* bEndpointAddress */
|
||||
0x02, /* bmAttributes: Bulk */
|
||||
LOBYTE(PRNT_DATA_FS_OUT_PACKET_SIZE),/* wMaxPacketSize */
|
||||
HIBYTE(PRNT_DATA_FS_OUT_PACKET_SIZE),
|
||||
0x00 /* bInterval */
|
||||
};
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
static uint8_t PRNTInEpAdd = PRNT_IN_EP;
|
||||
static uint8_t PRNTOutEpAdd = PRNT_OUT_EP;
|
||||
|
||||
/**
|
||||
* @}
|
||||
@@ -315,16 +232,26 @@ static uint8_t USBD_PRNT_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||
|
||||
USBD_PRNT_HandleTypeDef *hPRNT;
|
||||
uint16_t mps;
|
||||
|
||||
hPRNT = (USBD_PRNT_HandleTypeDef *)USBD_malloc(sizeof(USBD_PRNT_HandleTypeDef));
|
||||
|
||||
if (hPRNT == NULL)
|
||||
{
|
||||
pdev->pClassData = NULL;
|
||||
pdev->pClassDataCmsit[pdev->classId] = NULL;
|
||||
return (uint8_t)USBD_EMEM;
|
||||
}
|
||||
|
||||
(void)USBD_memset(hPRNT, 0, sizeof(USBD_PRNT_HandleTypeDef));
|
||||
|
||||
/* Setup the pClassData pointer */
|
||||
pdev->pClassData = (void *)hPRNT;
|
||||
pdev->pClassDataCmsit[pdev->classId] = (void *)hPRNT;
|
||||
pdev->pClassData = pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
/* Get the Endpoints addresses allocated for this class instance */
|
||||
PRNTInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
||||
PRNTOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
/* Setup the max packet size according to selected speed */
|
||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||
@@ -337,22 +264,29 @@ static uint8_t USBD_PRNT_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||
}
|
||||
|
||||
/* Open EP IN */
|
||||
(void)USBD_LL_OpenEP(pdev, PRNT_IN_EP, USBD_EP_TYPE_BULK, mps);
|
||||
(void)USBD_LL_OpenEP(pdev, PRNTInEpAdd, USBD_EP_TYPE_BULK, mps);
|
||||
|
||||
/* Set endpoint as used */
|
||||
pdev->ep_in[PRNT_IN_EP & 0xFU].is_used = 1U;
|
||||
pdev->ep_in[PRNTInEpAdd & 0xFU].is_used = 1U;
|
||||
|
||||
/* Open EP OUT */
|
||||
(void)USBD_LL_OpenEP(pdev, PRNT_OUT_EP, USBD_EP_TYPE_BULK, mps);
|
||||
(void)USBD_LL_OpenEP(pdev, PRNTOutEpAdd, USBD_EP_TYPE_BULK, mps);
|
||||
|
||||
/* Set endpoint as used */
|
||||
pdev->ep_out[PRNT_OUT_EP & 0xFU].is_used = 1U;
|
||||
pdev->ep_out[PRNTOutEpAdd & 0xFU].is_used = 1U;
|
||||
|
||||
hPRNT->RxBuffer = NULL;
|
||||
|
||||
/* Init physical Interface components */
|
||||
((USBD_PRNT_ItfTypeDef *)pdev->pUserData)->Init();
|
||||
((USBD_PRNT_ItfTypeDef *)pdev->pUserData[pdev->classId])->Init();
|
||||
|
||||
if (hPRNT->RxBuffer == NULL)
|
||||
{
|
||||
return (uint8_t)USBD_EMEM;
|
||||
}
|
||||
|
||||
/* Prepare Out endpoint to receive next packet */
|
||||
(void)USBD_LL_PrepareReceive(pdev, PRNT_OUT_EP, hPRNT->RxBuffer, mps);
|
||||
(void)USBD_LL_PrepareReceive(pdev, PRNTOutEpAdd, hPRNT->RxBuffer, mps);
|
||||
|
||||
/* End of initialization phase */
|
||||
return (uint8_t)USBD_OK;
|
||||
@@ -369,19 +303,26 @@ static uint8_t USBD_PRNT_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||
{
|
||||
UNUSED(cfgidx);
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
/* Get the Endpoints addresses allocated for this class instance */
|
||||
PRNTInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
||||
PRNTOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
/* Close EP IN */
|
||||
(void)USBD_LL_CloseEP(pdev, PRNT_IN_EP);
|
||||
pdev->ep_in[PRNT_IN_EP & 0xFU].is_used = 0U;
|
||||
(void)USBD_LL_CloseEP(pdev, PRNTInEpAdd);
|
||||
pdev->ep_in[PRNTInEpAdd & 0xFU].is_used = 0U;
|
||||
|
||||
/* Close EP OUT */
|
||||
(void)USBD_LL_CloseEP(pdev, PRNT_OUT_EP);
|
||||
pdev->ep_out[PRNT_OUT_EP & 0xFU].is_used = 0U;
|
||||
(void)USBD_LL_CloseEP(pdev, PRNTOutEpAdd);
|
||||
pdev->ep_out[PRNTOutEpAdd & 0xFU].is_used = 0U;
|
||||
|
||||
/* DeInit physical Interface components */
|
||||
if (pdev->pClassData != NULL)
|
||||
if (pdev->pClassDataCmsit[pdev->classId] != NULL)
|
||||
{
|
||||
((USBD_PRNT_ItfTypeDef *)pdev->pUserData)->DeInit();
|
||||
(void)USBD_free(pdev->pClassData);
|
||||
((USBD_PRNT_ItfTypeDef *)pdev->pUserData[pdev->classId])->DeInit();
|
||||
(void)USBD_free(pdev->pClassDataCmsit[pdev->classId]);
|
||||
pdev->pClassDataCmsit[pdev->classId] = NULL;
|
||||
pdev->pClassData = NULL;
|
||||
}
|
||||
|
||||
@@ -397,8 +338,8 @@ static uint8_t USBD_PRNT_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
|
||||
*/
|
||||
static uint8_t USBD_PRNT_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
|
||||
{
|
||||
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_PRNT_ItfTypeDef *hPRNTitf = (USBD_PRNT_ItfTypeDef *)pdev->pUserData;
|
||||
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
USBD_PRNT_ItfTypeDef *hPRNTitf = (USBD_PRNT_ItfTypeDef *)pdev->pUserData[pdev->classId];
|
||||
|
||||
USBD_StatusTypeDef ret = USBD_OK;
|
||||
uint16_t status_info = 0U;
|
||||
@@ -495,7 +436,7 @@ static uint8_t USBD_PRNT_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *r
|
||||
*/
|
||||
static uint8_t USBD_PRNT_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
{
|
||||
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
PCD_HandleTypeDef *hpcd = pdev->pData;
|
||||
|
||||
if (hPRNT == NULL)
|
||||
@@ -503,11 +444,11 @@ static uint8_t USBD_PRNT_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
return (uint8_t)USBD_FAIL;
|
||||
}
|
||||
|
||||
if ((pdev->ep_in[epnum].total_length > 0U) &&
|
||||
((pdev->ep_in[epnum].total_length % hpcd->IN_ep[epnum].maxpacket) == 0U))
|
||||
if ((pdev->ep_in[epnum & 0xFU].total_length > 0U) &&
|
||||
((pdev->ep_in[epnum & 0xFU].total_length % hpcd->IN_ep[epnum & 0xFU].maxpacket) == 0U))
|
||||
{
|
||||
/* Update the packet total length */
|
||||
pdev->ep_in[epnum].total_length = 0U;
|
||||
pdev->ep_in[epnum & 0xFU].total_length = 0U;
|
||||
|
||||
/* Send ZLP */
|
||||
(void) USBD_LL_Transmit(pdev, epnum, NULL, 0U);
|
||||
@@ -528,7 +469,7 @@ static uint8_t USBD_PRNT_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
*/
|
||||
static uint8_t USBD_PRNT_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
{
|
||||
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
if (hPRNT == NULL)
|
||||
{
|
||||
@@ -540,11 +481,12 @@ static uint8_t USBD_PRNT_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_PRNT_ItfTypeDef *)pdev->pUserData)->Receive(hPRNT->RxBuffer, &hPRNT->RxLength);
|
||||
((USBD_PRNT_ItfTypeDef *)pdev->pUserData[pdev->classId])->Receive(hPRNT->RxBuffer, &hPRNT->RxLength);
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
||||
#ifndef USE_USBD_COMPOSITE
|
||||
/**
|
||||
* @brief USBD_PRNT_GetFSCfgDesc
|
||||
* Return configuration descriptor
|
||||
@@ -553,8 +495,21 @@ static uint8_t USBD_PRNT_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
|
||||
*/
|
||||
static uint8_t *USBD_PRNT_GetFSCfgDesc(uint16_t *length)
|
||||
{
|
||||
*length = (uint16_t) sizeof(USBD_PRNT_CfgFSDesc);
|
||||
return USBD_PRNT_CfgFSDesc;
|
||||
USBD_EpDescTypeDef *pEpInDesc = USBD_GetEpDesc(USBD_PRNT_CfgDesc, PRNT_IN_EP);
|
||||
USBD_EpDescTypeDef *pEpOutDesc = USBD_GetEpDesc(USBD_PRNT_CfgDesc, PRNT_OUT_EP);
|
||||
|
||||
if (pEpInDesc != NULL)
|
||||
{
|
||||
pEpInDesc->wMaxPacketSize = PRNT_DATA_FS_IN_PACKET_SIZE;
|
||||
}
|
||||
|
||||
if (pEpOutDesc != NULL)
|
||||
{
|
||||
pEpOutDesc->wMaxPacketSize = PRNT_DATA_FS_OUT_PACKET_SIZE;
|
||||
}
|
||||
|
||||
*length = (uint16_t) sizeof(USBD_PRNT_CfgDesc);
|
||||
return USBD_PRNT_CfgDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -565,8 +520,21 @@ static uint8_t *USBD_PRNT_GetFSCfgDesc(uint16_t *length)
|
||||
*/
|
||||
static uint8_t *USBD_PRNT_GetHSCfgDesc(uint16_t *length)
|
||||
{
|
||||
*length = (uint16_t) sizeof(USBD_PRNT_CfgHSDesc);
|
||||
return USBD_PRNT_CfgHSDesc;
|
||||
USBD_EpDescTypeDef *pEpInDesc = USBD_GetEpDesc(USBD_PRNT_CfgDesc, PRNT_IN_EP);
|
||||
USBD_EpDescTypeDef *pEpOutDesc = USBD_GetEpDesc(USBD_PRNT_CfgDesc, PRNT_OUT_EP);
|
||||
|
||||
if (pEpInDesc != NULL)
|
||||
{
|
||||
pEpInDesc->wMaxPacketSize = PRNT_DATA_HS_IN_PACKET_SIZE;
|
||||
}
|
||||
|
||||
if (pEpOutDesc != NULL)
|
||||
{
|
||||
pEpOutDesc->wMaxPacketSize = PRNT_DATA_HS_OUT_PACKET_SIZE;
|
||||
}
|
||||
|
||||
*length = (uint16_t) sizeof(USBD_PRNT_CfgDesc);
|
||||
return USBD_PRNT_CfgDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -577,8 +545,21 @@ static uint8_t *USBD_PRNT_GetHSCfgDesc(uint16_t *length)
|
||||
*/
|
||||
static uint8_t *USBD_PRNT_GetOtherSpeedCfgDesc(uint16_t *length)
|
||||
{
|
||||
*length = (uint16_t) sizeof(USBD_PRNT_OtherSpeedCfgDesc);
|
||||
return USBD_PRNT_OtherSpeedCfgDesc;
|
||||
USBD_EpDescTypeDef *pEpInDesc = USBD_GetEpDesc(USBD_PRNT_CfgDesc, PRNT_IN_EP);
|
||||
USBD_EpDescTypeDef *pEpOutDesc = USBD_GetEpDesc(USBD_PRNT_CfgDesc, PRNT_OUT_EP);
|
||||
|
||||
if (pEpInDesc != NULL)
|
||||
{
|
||||
pEpInDesc->wMaxPacketSize = PRNT_DATA_FS_IN_PACKET_SIZE;
|
||||
}
|
||||
|
||||
if (pEpOutDesc != NULL)
|
||||
{
|
||||
pEpOutDesc->wMaxPacketSize = PRNT_DATA_FS_OUT_PACKET_SIZE;
|
||||
}
|
||||
|
||||
*length = (uint16_t) sizeof(USBD_PRNT_CfgDesc);
|
||||
return USBD_PRNT_CfgDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -592,6 +573,7 @@ uint8_t *USBD_PRNT_GetDeviceQualifierDescriptor(uint16_t *length)
|
||||
*length = (uint16_t)sizeof(USBD_PRNT_DeviceQualifierDesc);
|
||||
return USBD_PRNT_DeviceQualifierDesc;
|
||||
}
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
/**
|
||||
* @brief USBD_PRNT_RegisterInterface
|
||||
@@ -608,7 +590,7 @@ uint8_t USBD_PRNT_RegisterInterface(USBD_HandleTypeDef *pdev, USBD_PRNT_ItfTypeD
|
||||
}
|
||||
|
||||
/* Setup the fops pointer */
|
||||
pdev->pUserData = fops;
|
||||
pdev->pUserData[pdev->classId] = fops;
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
@@ -621,7 +603,7 @@ uint8_t USBD_PRNT_RegisterInterface(USBD_HandleTypeDef *pdev, USBD_PRNT_ItfTypeD
|
||||
*/
|
||||
uint8_t USBD_PRNT_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
|
||||
{
|
||||
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *) pdev->pClassData;
|
||||
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *) pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
hPRNT->RxBuffer = pbuff;
|
||||
|
||||
@@ -636,7 +618,13 @@ uint8_t USBD_PRNT_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
|
||||
*/
|
||||
uint8_t USBD_PRNT_ReceivePacket(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *)pdev->pClassData;
|
||||
USBD_PRNT_HandleTypeDef *hPRNT = (USBD_PRNT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
|
||||
|
||||
#ifdef USE_USBD_COMPOSITE
|
||||
/* Get the Endpoints addresses allocated for this class instance */
|
||||
PRNTInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK);
|
||||
PRNTOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK);
|
||||
#endif /* USE_USBD_COMPOSITE */
|
||||
|
||||
if (hPRNT == NULL)
|
||||
{
|
||||
@@ -646,18 +634,19 @@ uint8_t USBD_PRNT_ReceivePacket(USBD_HandleTypeDef *pdev)
|
||||
if (pdev->dev_speed == USBD_SPEED_HIGH)
|
||||
{
|
||||
/* Prepare Out endpoint to receive next packet */
|
||||
(void)USBD_LL_PrepareReceive(pdev, PRNT_OUT_EP, hPRNT->RxBuffer,
|
||||
(void)USBD_LL_PrepareReceive(pdev, PRNTOutEpAdd, hPRNT->RxBuffer,
|
||||
PRNT_DATA_HS_OUT_PACKET_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Prepare Out endpoint to receive next packet */
|
||||
(void)USBD_LL_PrepareReceive(pdev, PRNT_OUT_EP, hPRNT->RxBuffer,
|
||||
(void)USBD_LL_PrepareReceive(pdev, PRNTOutEpAdd, hPRNT->RxBuffer,
|
||||
PRNT_DATA_FS_OUT_PACKET_SIZE);
|
||||
}
|
||||
|
||||
return (uint8_t)USBD_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user