Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ extern "C" {
#define USB_DEVICE_CLASS_AUDIO 0x01U
#define AUDIO_SUBCLASS_AUDIOCONTROL 0x01U
#define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02U
#define AUDIO_SUBCLASS_MIDISTREAMING 0x03U
#define AUDIO_PROTOCOL_UNDEFINED 0x00U
#define AUDIO_STREAMING_GENERAL 0x01U
#define AUDIO_STREAMING_FORMAT_TYPE 0x02U
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ USBD_ClassTypeDef USBD_AUDIO =
USBD_AUDIO_GetCfgDesc,
USBD_AUDIO_GetDeviceQualifierDesc,
#endif /* USE_USBD_COMPOSITE */
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
NULL,
#endif /* USBD_SUPPORT_USER_STRING_DESC */
};

#ifndef USE_USBD_COMPOSITE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ extern "C" {
#define CCID_CMD_FS_BINTERVAL 0x10U
#endif /* CCID_CMD_FS_BINTERVAL */

#ifndef CCID_CMD_PACKET_SIZE
#define CCID_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
#endif /* CCID_CMD_PACKET_SIZE */

#define CCID_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
#define CCID_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
#define CCID_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */

#define USB_CCID_CONFIG_DESC_SIZ 93U
#define CCID_DATA_HS_IN_PACKET_SIZE CCID_DATA_HS_MAX_PACKET_SIZE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ USBD_ClassTypeDef USBD_CCID =
USBD_CCID_GetOtherSpeedCfgDesc,
USBD_CCID_GetDeviceQualifierDescriptor,
#endif /* USE_USBD_COMPOSITE */
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
NULL,
#endif /* USBD_SUPPORT_USER_STRING_DESC */
};

#ifndef USE_USBD_COMPOSITE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ static void CCID_UpdateCommandStatus(USBD_HandleTypeDef *pdev, uint8_t cmd_stat
uint8_t PC_to_RDR_IccPowerOn(USBD_HandleTypeDef *pdev)
{
/* Apply the ICC VCC
Fills the Response buffer with ICC ATR
This Command is returned with RDR_to_PC_DataBlock();
*/
USBD_CCID_HandleTypeDef *hccid = (USBD_CCID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
* Fills the Response buffer with ICC ATR
* This Command is returned with RDR_to_PC_DataBlock();
*/
USBD_CCID_HandleTypeDef *hccid = (USBD_CCID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
uint8_t voltage;
uint8_t sc_voltage = 0U;
uint8_t index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ extern "C" {
#define CDC_FS_BINTERVAL 0x10U
#endif /* CDC_FS_BINTERVAL */

#ifndef CDC_CMD_PACKET_SIZE
#define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
#endif /* CDC_CMD_PACKET_SIZE */

/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
#define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
#define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
#define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */

#define USB_CDC_CONFIG_DESC_SIZ 67U
#define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ USBD_ClassTypeDef USBD_CDC =
USBD_CDC_GetOtherSpeedCfgDesc,
USBD_CDC_GetDeviceQualifierDescriptor,
#endif /* USE_USBD_COMPOSITE */
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
NULL,
#endif /* USBD_SUPPORT_USER_STRING_DESC */
};

#ifndef USE_USBD_COMPOSITE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,17 @@ extern "C" {
#define CDC_ECM_FS_BINTERVAL 0x10U
#endif /* CDC_ECM_FS_BINTERVAL */

#ifndef CDC_ECM_CMD_PACKET_SIZE
#define CDC_ECM_CMD_PACKET_SIZE 16U /* Control Endpoint Packet size */
#endif /* CDC_ECM_CMD_PACKET_SIZE */

#ifndef USBD_SUPPORT_USER_STRING_DESC
#define USBD_SUPPORT_USER_STRING_DESC 1U
#endif /* USBD_SUPPORT_USER_STRING_DESC */

/* CDC_ECM Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
#define CDC_ECM_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
#define CDC_ECM_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
#define CDC_ECM_CMD_PACKET_SIZE 16U /* Control Endpoint Packet size */

#define CDC_ECM_CONFIG_DESC_SIZ 79U

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ extern "C" {
#define CDC_RNDIS_FS_BINTERVAL 0x10U
#endif /* CDC_RNDIS_FS_BINTERVAL */

#ifndef CDC_RNDIS_CMD_PACKET_SIZE
#define CDC_RNDIS_CMD_PACKET_SIZE 16U /* Control Endpoint Packet size */
#endif /* CDC_RNDIS_CMD_PACKET_SIZE */

/* CDC_RNDIS Endpoints parameters: you can fine tune these values
depending on the needed baudrates and performance. */
#define CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
#define CDC_RNDIS_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
#define CDC_RNDIS_CMD_PACKET_SIZE 16U /* Control Endpoint Packet size */

#define CDC_RNDIS_CONFIG_DESC_SIZ 75U
#define CDC_RNDIS_DATA_HS_IN_PACKET_SIZE CDC_RNDIS_DATA_HS_MAX_PACKET_SIZE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessQueryMsg(USBD_HandleTypeDef *pdev,
case OID_GEN_VENDOR_DESCRIPTION:
QueryResponse->InfoBufLength = (strlen(USBD_CDC_RNDIS_VENDOR_DESC) + 1U);
(void)USBD_memcpy(QueryResponse->InfoBuf, USBD_CDC_RNDIS_VENDOR_DESC,
strlen(USBD_CDC_RNDIS_VENDOR_DESC));
strlen(USBD_CDC_RNDIS_VENDOR_DESC) + 1U);

QueryResponse->Status = CDC_RNDIS_STATUS_SUCCESS;
break;
Expand Down Expand Up @@ -1452,7 +1452,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessQueryMsg(USBD_HandleTypeDef *pdev,

case OID_GEN_CURRENT_PACKET_FILTER:
QueryResponse->InfoBufLength = sizeof(uint32_t);
QueryResponse->InfoBuf[0] = 0xFFFFFFU; /* USBD_CDC_RNDIS_DEVICE.packetFilter; */
QueryResponse->InfoBuf[0] = 0xFFFFFFU; /* USBD_CDC_RNDIS_DEVICE.packetFilter */
QueryResponse->Status = CDC_RNDIS_STATUS_SUCCESS;
break;

Expand Down Expand Up @@ -1641,6 +1641,13 @@ static uint8_t USBD_CDC_RNDIS_ProcessPacketMsg(USBD_HandleTypeDef *pdev,
/* Use temporary storage variables to comply with MISRA-C 2012 rule of (+) operand allowed types */
tmp1 = (uint32_t)PacketMsg;
tmp2 = (uint32_t)(PacketMsg->DataOffset);

/* Validate DataOffset and DataLength against the received MsgLength */
if ((tmp2 + CDC_RNDIS_PCKTMSG_DATAOFFSET_OFFSET + PacketMsg->DataLength) > PacketMsg->MsgLength)
{
return (uint8_t)USBD_FAIL;
}

hcdc->RxBuffer = (uint8_t *)(tmp1 + tmp2 + CDC_RNDIS_PCKTMSG_DATAOFFSET_OFFSET);
hcdc->RxLength = PacketMsg->DataLength;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,11 @@ uint8_t USBD_CMPSIT_AddToConfDesc(USBD_HandleTypeDef *pdev)

/* Set IN endpoint slot */
iEp = pdev->tclasslist[pdev->classId].EpAdd[0];
USBD_CMPSIT_AssignEp(pdev, iEp, USBD_EP_TYPE_INTR, pdev->tclasslist[pdev->classId].CurrPcktSze);
USBD_CMPSIT_AssignEp(pdev, iEp, USBD_EP_TYPE_INTR,CUSTOM_HID_EPIN_SIZE);

/* Set OUT endpoint slot */
iEp = pdev->tclasslist[pdev->classId].EpAdd[1];
USBD_CMPSIT_AssignEp(pdev, iEp, USBD_EP_TYPE_INTR, pdev->tclasslist[pdev->classId].CurrPcktSze);
USBD_CMPSIT_AssignEp(pdev, iEp, USBD_EP_TYPE_INTR, CUSTOM_HID_EPOUT_SIZE);

/* Configure and Append the Descriptor */
USBD_CMPSIT_CUSTOMHIDDesc(pdev, (uint32_t)pCmpstFSConfDesc, &CurrFSConfDescSz, (uint8_t)USBD_SPEED_FULL);
Expand Down Expand Up @@ -1393,7 +1393,12 @@ static void USBD_CMPSIT_CUSTOMHIDDesc(USBD_HandleTypeDef *pdev, uint32_t pConf,
pDesc->bCountryCode = 0x00U;
pDesc->bNumDescriptors = 0x01U;
pDesc->bDescriptorType = 0x22U;
#ifdef USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED
pDesc->wItemLength = ((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->wReportDescLen;
#else
pDesc->wItemLength = USBD_CUSTOM_HID_REPORT_DESC_SIZE;
#endif /* USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED */

*Sze += (uint32_t)sizeof(USBD_DescTypeDef);

/* Descriptor of Custom HID endpoints */
Expand All @@ -1403,7 +1408,7 @@ static void USBD_CMPSIT_CUSTOMHIDDesc(USBD_HandleTypeDef *pdev, uint32_t pConf,

/* Append Endpoint descriptor to Configuration descriptor */
__USBD_CMPSIT_SET_EP(pdev->tclasslist[pdev->classId].Eps[1].add, \
USBD_EP_TYPE_INTR, CUSTOM_HID_EPIN_SIZE, CUSTOM_HID_HS_BINTERVAL, CUSTOM_HID_FS_BINTERVAL);
USBD_EP_TYPE_INTR, CUSTOM_HID_EPOUT_SIZE, CUSTOM_HID_HS_BINTERVAL, CUSTOM_HID_FS_BINTERVAL);

/* Update Config Descriptor and IAD descriptor */
((USBD_ConfigDescTypeDef *)pConf)->bNumInterfaces += 1U;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,16 @@ typedef enum
typedef struct _USBD_CUSTOM_HID_Itf
{
uint8_t *pReport;
#ifdef USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED
uint16_t wReportDescLen;
#endif /* USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED */
int8_t (* Init)(void);
int8_t (* DeInit)(void);
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
int8_t (* OutEvent)(uint8_t *report_buffer);
#else
int8_t (* OutEvent)(uint8_t event_idx, uint8_t state);
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
#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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ USBD_ClassTypeDef USBD_CUSTOM_HID =
USBD_CUSTOM_HID_GetOtherSpeedCfgDesc,
USBD_CUSTOM_HID_GetDeviceQualifierDesc,
#endif /* USE_USBD_COMPOSITE */
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
NULL,
#endif /* USBD_SUPPORT_USER_STRING_DESC */
};

#ifndef USE_USBD_COMPOSITE
Expand Down Expand Up @@ -284,6 +287,11 @@ static uint8_t USBD_CUSTOM_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)

pdev->ep_in[CUSTOMHIDInEpAdd & 0xFU].is_used = 1U;

if (USBD_CUSTOMHID_OUTREPORT_BUF_SIZE < CUSTOM_HID_EPOUT_SIZE)
{
return (uint8_t)USBD_FAIL;
}

/* Open EP OUT */
(void)USBD_LL_OpenEP(pdev, CUSTOMHIDOutEpAdd, USBD_EP_TYPE_INTR,
CUSTOM_HID_EPOUT_SIZE);
Expand Down Expand Up @@ -397,9 +405,17 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef *pdev,
}
#endif /* USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED */
#ifndef USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED

if (req->wLength > USBD_CUSTOMHID_OUTREPORT_BUF_SIZE)
{
/* Stall EP0 */
USBD_CtlError(pdev, req);
return USBD_FAIL;
}

hhid->IsReportAvailable = 1U;
(void)USBD_CtlPrepareRx(pdev, hhid->Report_buf,
MIN(req->wLength, USBD_CUSTOMHID_OUTREPORT_BUF_SIZE));

(void)USBD_CtlPrepareRx(pdev, hhid->Report_buf, req->wLength);
#endif /* USBD_CUSTOMHID_EP0_OUT_PREPARE_RECEIVE_DISABLED */
break;
#ifdef USBD_CUSTOMHID_CTRL_REQ_GET_REPORT_ENABLED
Expand Down Expand Up @@ -675,6 +691,11 @@ static uint8_t USBD_CUSTOM_HID_DataIn(USBD_HandleTypeDef *pdev, uint8_t 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 */
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
{
return (uint8_t)USBD_FAIL;
}

((USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId])->state = CUSTOM_HID_IDLE;

return (uint8_t)USBD_OK;
Expand All @@ -701,8 +722,13 @@ static uint8_t USBD_CUSTOM_HID_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 processing */

#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf);
#else
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf[0],
hhid->Report_buf[1]);
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */

return (uint8_t)USBD_OK;
}
Expand Down Expand Up @@ -755,8 +781,12 @@ static uint8_t USBD_CUSTOM_HID_EP0_RxReady(USBD_HandleTypeDef *pdev)

if (hhid->IsReportAvailable == 1U)
{
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf);
#else
((USBD_CUSTOM_HID_ItfTypeDef *)pdev->pUserData[pdev->classId])->OutEvent(hhid->Report_buf[0],
hhid->Report_buf[1]);
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */
hhid->IsReportAvailable = 0U;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ EndBSPDependencies */

static int8_t TEMPLATE_CUSTOM_HID_Init(void);
static int8_t TEMPLATE_CUSTOM_HID_DeInit(void);
#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t *report_buffer);
#else
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t event_idx, uint8_t state);
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */

#ifdef USBD_CUSTOMHID_CTRL_REQ_COMPLETE_CALLBACK_ENABLED
static int8_t TEMPLATE_CUSTOM_HID_CtrlReqComplete(uint8_t request, uint16_t wLength);
Expand All @@ -49,6 +53,9 @@ __ALIGN_BEGIN static uint8_t TEMPLATE_CUSTOM_HID_ReportDesc[USBD_CUSTOM_HID_REPO
USBD_CUSTOM_HID_ItfTypeDef USBD_CustomHID_template_fops =
{
TEMPLATE_CUSTOM_HID_ReportDesc,
#ifdef USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED
USBD_CUSTOM_HID_REPORT_DESC_SIZE,
#endif /* USBD_CUSTOMHID_REPORT_DESC_SIZE_ENABLED */
TEMPLATE_CUSTOM_HID_Init,
TEMPLATE_CUSTOM_HID_DeInit,
TEMPLATE_CUSTOM_HID_OutEvent,
Expand Down Expand Up @@ -95,10 +102,17 @@ static int8_t TEMPLATE_CUSTOM_HID_DeInit(void)
* @param state: event state
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
*/

#ifdef USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t *report_buffer)
{
UNUSED(report_buffer);
#else
static int8_t TEMPLATE_CUSTOM_HID_OutEvent(uint8_t event_idx, uint8_t state)
{
UNUSED(event_idx);
UNUSED(state);
#endif /* USBD_CUSTOMHID_REPORT_BUFFER_EVENT_ENABLED */

/* Start next USB packet transfer once data processing is completed */
if (USBD_CUSTOM_HID_ReceivePacket(&USBD_Device) != (uint8_t)USBD_OK)
Expand Down Expand Up @@ -151,7 +165,7 @@ static int8_t TEMPLATE_CUSTOM_HID_CtrlReqComplete(uint8_t request, uint16_t wLen
static uint8_t *TEMPLATE_CUSTOM_HID_GetReport(uint16_t *ReportLength)
{
UNUSED(ReportLength);
uint8_t *pbuff;
uint8_t *pbuff = NULL;

return (pbuff);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,12 @@ static void DFU_Download(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
if ((hdfu->dev_state == DFU_STATE_DNLOAD_IDLE) || (hdfu->dev_state == DFU_STATE_IDLE))
{
#if (USBD_DFU_VENDOR_CHECK_ENABLED == 1U)
/* Fill the buffer to be checked with the address stored in data buffer */
hdfu->buffer.d8[1] = (uint8_t)(hdfu->data_ptr & 0xFFU);
hdfu->buffer.d8[2] = (uint8_t)((hdfu->data_ptr & 0xFF00U) >> 8U);
hdfu->buffer.d8[3] = (uint8_t)((hdfu->data_ptr & 0xFF0000U) >> 16U);
hdfu->buffer.d8[4] = (uint8_t)((hdfu->data_ptr & 0xFF000000U) >> 24U);

if (DfuInterface->VendorCheck(hdfu->buffer.d8, IS_DFU_SETADDRESSPOINTER, &VendorStatus) != USBD_OK)
{
/* Update the state machine */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ USBD_ClassTypeDef USBD_HID =
USBD_HID_GetOtherSpeedCfgDesc,
USBD_HID_GetDeviceQualifierDesc,
#endif /* USE_USBD_COMPOSITE */
#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
NULL,
#endif /* USBD_SUPPORT_USER_STRING_DESC */
};

#ifndef USE_USBD_COMPOSITE
Expand Down Expand Up @@ -615,6 +618,11 @@ 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 */
if (pdev->pClassDataCmsit[pdev->classId] == NULL)
{
return (uint8_t)USBD_FAIL;
}

((USBD_HID_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId])->state = USBD_HID_IDLE;

return (uint8_t)USBD_OK;
Expand Down
Loading
Loading