diff --git a/Class/BillBoard/Src/usbd_billboard.c b/Class/BillBoard/Src/usbd_billboard.c index b9e6d19..35b45a1 100644 --- a/Class/BillBoard/Src/usbd_billboard.c +++ b/Class/BillBoard/Src/usbd_billboard.c @@ -391,10 +391,10 @@ static uint8_t *USBD_BB_GetDeviceQualifierDesc(uint16_t *length) */ USBD_BB_DescHeader_t *USBD_BB_GetNextDesc(uint8_t *pbuf, uint16_t *ptr) { - USBD_BB_DescHeader_t *pnext = (USBD_BB_DescHeader_t *)pbuf; + USBD_BB_DescHeader_t *pnext = (USBD_BB_DescHeader_t *)(void *)pbuf; *ptr += pnext->bLength; - pnext = (USBD_BB_DescHeader_t *)(pbuf + pnext->bLength); + pnext = (USBD_BB_DescHeader_t *)(void *)(pbuf + pnext->bLength); return (pnext); } @@ -411,8 +411,8 @@ void *USBD_BB_GetCapDesc(USBD_HandleTypeDef *pdev, uint8_t *pBosDesc) { UNUSED(pdev); - USBD_BB_DescHeader_t *pdesc = (USBD_BB_DescHeader_t *)pBosDesc; - USBD_BosDescTypedef *desc = (USBD_BosDescTypedef *)pBosDesc; + USBD_BB_DescHeader_t *pdesc = (USBD_BB_DescHeader_t *)(void *)pBosDesc; + USBD_BosDescTypedef *desc = (USBD_BosDescTypedef *)(void *)pBosDesc; USBD_BosBBCapDescTypedef *pCapDesc = NULL; uint16_t ptr; @@ -426,7 +426,7 @@ void *USBD_BB_GetCapDesc(USBD_HandleTypeDef *pdev, uint8_t *pBosDesc) if (pdesc->bDevCapabilityType == USBD_BILLBOARD_CAPABILITY) { - pCapDesc = (USBD_BosBBCapDescTypedef *)pdesc; + pCapDesc = (USBD_BosBBCapDescTypedef *)(void *)pdesc; break; } } @@ -447,8 +447,8 @@ void *USBD_BB_GetAltModeDesc(USBD_HandleTypeDef *pdev, uint8_t *pBosDesc, uint8_ { UNUSED(pdev); - USBD_BB_DescHeader_t *pdesc = (USBD_BB_DescHeader_t *)pBosDesc; - USBD_BosDescTypedef *desc = (USBD_BosDescTypedef *)pBosDesc; + USBD_BB_DescHeader_t *pdesc = (USBD_BB_DescHeader_t *)(void *)pBosDesc; + USBD_BosDescTypedef *desc = (USBD_BosDescTypedef *)(void *)pBosDesc; USBD_BB_AltModeCapDescTypeDef *pAltModDesc = NULL; uint8_t cnt = 0U; uint16_t ptr; @@ -465,7 +465,7 @@ void *USBD_BB_GetAltModeDesc(USBD_HandleTypeDef *pdev, uint8_t *pBosDesc, uint8_ { if (cnt == idx) { - pAltModDesc = (USBD_BB_AltModeCapDescTypeDef *)pdesc; + pAltModDesc = (USBD_BB_AltModeCapDescTypeDef *)(void *)pdesc; break; } else diff --git a/Class/CDC/Src/usbd_cdc.c b/Class/CDC/Src/usbd_cdc.c index 017e4cd..ae1f9a4 100644 --- a/Class/CDC/Src/usbd_cdc.c +++ b/Class/CDC/Src/usbd_cdc.c @@ -474,16 +474,16 @@ static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) (void)USBD_LL_OpenEP(pdev, CDC_IN_EP, USBD_EP_TYPE_BULK, CDC_DATA_HS_IN_PACKET_SIZE); - pdev->ep_in[CDC_IN_EP & 0xFU].is_used = 1U; + pdev->ep_in[CDC_IN_EP & 0xFU].is_used = 1U; - /* Open EP OUT */ - (void)USBD_LL_OpenEP(pdev, CDC_OUT_EP, USBD_EP_TYPE_BULK, - CDC_DATA_HS_OUT_PACKET_SIZE); + /* Open EP OUT */ + (void)USBD_LL_OpenEP(pdev, CDC_OUT_EP, USBD_EP_TYPE_BULK, + CDC_DATA_HS_OUT_PACKET_SIZE); - pdev->ep_out[CDC_OUT_EP & 0xFU].is_used = 1U; + pdev->ep_out[CDC_OUT_EP & 0xFU].is_used = 1U; - /* Set bInterval for CDC CMD Endpoint */ - pdev->ep_in[CDC_CMD_EP & 0xFU].bInterval = CDC_HS_BINTERVAL; + /* Set bInterval for CDC CMD Endpoint */ + pdev->ep_in[CDC_CMD_EP & 0xFU].bInterval = CDC_HS_BINTERVAL; } else { @@ -491,16 +491,16 @@ static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) (void)USBD_LL_OpenEP(pdev, CDC_IN_EP, USBD_EP_TYPE_BULK, CDC_DATA_FS_IN_PACKET_SIZE); - pdev->ep_in[CDC_IN_EP & 0xFU].is_used = 1U; + pdev->ep_in[CDC_IN_EP & 0xFU].is_used = 1U; - /* Open EP OUT */ - (void)USBD_LL_OpenEP(pdev, CDC_OUT_EP, USBD_EP_TYPE_BULK, - CDC_DATA_FS_OUT_PACKET_SIZE); + /* Open EP OUT */ + (void)USBD_LL_OpenEP(pdev, CDC_OUT_EP, USBD_EP_TYPE_BULK, + CDC_DATA_FS_OUT_PACKET_SIZE); - pdev->ep_out[CDC_OUT_EP & 0xFU].is_used = 1U; + pdev->ep_out[CDC_OUT_EP & 0xFU].is_used = 1U; - /* Set bInterval for CMD Endpoint */ - pdev->ep_in[CDC_CMD_EP & 0xFU].bInterval = CDC_FS_BINTERVAL; + /* Set bInterval for CMD Endpoint */ + pdev->ep_in[CDC_CMD_EP & 0xFU].bInterval = CDC_FS_BINTERVAL; } /* Open Command IN EP */ @@ -540,7 +540,6 @@ static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx) { UNUSED(cfgidx); - uint8_t ret = 0U; /* Close EP IN */ (void)USBD_LL_CloseEP(pdev, CDC_IN_EP); @@ -563,7 +562,7 @@ static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx) pdev->pClassData = NULL; } - return ret; + return (uint8_t)USBD_OK; } /** @@ -583,81 +582,81 @@ static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev, switch (req->bmRequest & USB_REQ_TYPE_MASK) { - case USB_REQ_TYPE_CLASS: - if (req->wLength != 0U) - { - if ((req->bmRequest & 0x80U) != 0U) + case USB_REQ_TYPE_CLASS: + if (req->wLength != 0U) { - ((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest, - (uint8_t *)hcdc->data, - req->wLength); + if ((req->bmRequest & 0x80U) != 0U) + { + ((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest, + (uint8_t *)hcdc->data, + req->wLength); (void)USBD_CtlSendData(pdev, (uint8_t *)hcdc->data, req->wLength); + } + else + { + hcdc->CmdOpCode = req->bRequest; + hcdc->CmdLength = (uint8_t)req->wLength; + + (void)USBD_CtlPrepareRx(pdev, (uint8_t *)hcdc->data, req->wLength); + } } else { - hcdc->CmdOpCode = req->bRequest; - hcdc->CmdLength = (uint8_t)req->wLength; - - (void)USBD_CtlPrepareRx(pdev, (uint8_t *)hcdc->data, req->wLength); - } - } - else - { - ((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest, - (uint8_t *)req, 0U); - } - break; - - case USB_REQ_TYPE_STANDARD: - switch (req->bRequest) - { - case USB_REQ_GET_STATUS: - if (pdev->dev_state == USBD_STATE_CONFIGURED) - { - (void)USBD_CtlSendData(pdev, (uint8_t *)&status_info, 2U); - } - else - { - USBD_CtlError(pdev, req); - ret = USBD_FAIL; + ((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest, + (uint8_t *)req, 0U); } break; - case USB_REQ_GET_INTERFACE: - if (pdev->dev_state == USBD_STATE_CONFIGURED) + case USB_REQ_TYPE_STANDARD: + switch (req->bRequest) { - (void)USBD_CtlSendData(pdev, &ifalt, 1U); - } - else - { - USBD_CtlError(pdev, req); - ret = USBD_FAIL; - } - break; + case USB_REQ_GET_STATUS: + if (pdev->dev_state == USBD_STATE_CONFIGURED) + { + (void)USBD_CtlSendData(pdev, (uint8_t *)&status_info, 2U); + } + else + { + USBD_CtlError(pdev, req); + ret = USBD_FAIL; + } + break; - case USB_REQ_SET_INTERFACE: - if (pdev->dev_state != USBD_STATE_CONFIGURED) - { - USBD_CtlError(pdev, req); - ret = USBD_FAIL; - } - break; + case USB_REQ_GET_INTERFACE: + if (pdev->dev_state == USBD_STATE_CONFIGURED) + { + (void)USBD_CtlSendData(pdev, &ifalt, 1U); + } + else + { + USBD_CtlError(pdev, req); + ret = USBD_FAIL; + } + break; - case USB_REQ_CLEAR_FEATURE: + case USB_REQ_SET_INTERFACE: + if (pdev->dev_state != USBD_STATE_CONFIGURED) + { + USBD_CtlError(pdev, req); + ret = USBD_FAIL; + } + break; + + case USB_REQ_CLEAR_FEATURE: + break; + + default: + USBD_CtlError(pdev, req); + ret = USBD_FAIL; + break; + } break; default: USBD_CtlError(pdev, req); ret = USBD_FAIL; break; - } - break; - - default: - USBD_CtlError(pdev, req); - ret = USBD_FAIL; - break; } return (uint8_t)ret; @@ -694,7 +693,11 @@ 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); + + if (((USBD_CDC_ItfTypeDef *)pdev->pUserData)->TransmitCplt != NULL) + { + ((USBD_CDC_ItfTypeDef *)pdev->pUserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum); + } } return (uint8_t)USBD_OK; @@ -743,7 +746,6 @@ static uint8_t USBD_CDC_EP0_RxReady(USBD_HandleTypeDef *pdev) (uint8_t *)hcdc->data, (uint16_t)hcdc->CmdLength); hcdc->CmdOpCode = 0xFFU; - } return (uint8_t)USBD_OK; @@ -778,7 +780,7 @@ static uint8_t *USBD_CDC_GetHSCfgDesc(uint16_t *length) } /** - * @brief USBD_CDC_GetCfgDesc + * @brief USBD_CDC_GetOtherSpeedCfgDesc * Return configuration descriptor * @param speed : current device speed * @param length : pointer data length @@ -792,11 +794,11 @@ static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc(uint16_t *length) } /** -* @brief DeviceQualifierDescriptor -* return Device Qualifier descriptor -* @param length : pointer data length -* @retval pointer to descriptor buffer -*/ + * @brief USBD_CDC_GetDeviceQualifierDescriptor + * return Device Qualifier descriptor + * @param length : pointer data length + * @retval pointer to descriptor buffer + */ uint8_t *USBD_CDC_GetDeviceQualifierDescriptor(uint16_t *length) { *length = (uint16_t)sizeof(USBD_CDC_DeviceQualifierDesc); @@ -805,7 +807,7 @@ uint8_t *USBD_CDC_GetDeviceQualifierDescriptor(uint16_t *length) } /** -* @brief USBD_CDC_RegisterInterface + * @brief USBD_CDC_RegisterInterface * @param pdev: device instance * @param fops: CD Interface callback * @retval status @@ -840,7 +842,6 @@ uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, return (uint8_t)USBD_OK; } - /** * @brief USBD_CDC_SetRxBuffer * @param pdev: device instance @@ -889,7 +890,6 @@ uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev) return (uint8_t)ret; } - /** * @brief USBD_CDC_ReceivePacket * prepare OUT Endpoint for reception diff --git a/Class/CDC_ECM/Src/usbd_cdc_ecm.c b/Class/CDC_ECM/Src/usbd_cdc_ecm.c index edc5d22..731c4a6 100644 --- a/Class/CDC_ECM/Src/usbd_cdc_ecm.c +++ b/Class/CDC_ECM/Src/usbd_cdc_ecm.c @@ -716,7 +716,10 @@ static uint8_t USBD_CDC_ECM_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum) else { hcdc->TxState = 0U; - ((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum); + if (((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData)->TransmitCplt != NULL) + { + ((USBD_CDC_ECM_ItfTypeDef *)pdev->pUserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum); + } } } else if (epnum == (CDC_ECM_CMD_EP & 0x7FU)) @@ -1020,7 +1023,7 @@ uint8_t USBD_CDC_ECM_SendNotification(USBD_HandleTypeDef *pdev, (hcdc->Req).bmRequest = CDC_ECM_BMREQUEST_TYPE_ECM; (hcdc->Req).bRequest = (uint8_t)Notif; - switch (Notif) + switch ((hcdc->Req).bRequest) { case NETWORK_CONNECTION: (hcdc->Req).wValue = bVal; diff --git a/Class/CDC_RNDIS/Src/usbd_cdc_rndis.c b/Class/CDC_RNDIS/Src/usbd_cdc_rndis.c index 946ed50..6109b63 100644 --- a/Class/CDC_RNDIS/Src/usbd_cdc_rndis.c +++ b/Class/CDC_RNDIS/Src/usbd_cdc_rndis.c @@ -657,7 +657,7 @@ static uint8_t USBD_CDC_RNDIS_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req) { USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData; - USBD_CDC_RNDIS_CtrlMsgTypeDef *Msg = (USBD_CDC_RNDIS_CtrlMsgTypeDef *)hcdc->data; + USBD_CDC_RNDIS_CtrlMsgTypeDef *Msg = (USBD_CDC_RNDIS_CtrlMsgTypeDef *)(void *)hcdc->data; uint8_t ifalt = 0U; uint16_t status_info = 0U; USBD_StatusTypeDef ret = USBD_OK; @@ -810,7 +810,11 @@ static uint8_t USBD_CDC_RNDIS_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum) else { hcdc->TxState = 0U; - ((USBD_CDC_RNDIS_ItfTypeDef *)pdev->pUserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum); + + if (((USBD_CDC_RNDIS_ItfTypeDef *)pdev->pUserData)->TransmitCplt != NULL) + { + ((USBD_CDC_RNDIS_ItfTypeDef *)pdev->pUserData)->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum); + } } } else if (epnum == (CDC_RNDIS_CMD_EP & 0x7FU)) @@ -866,7 +870,7 @@ static uint8_t USBD_CDC_RNDIS_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum) NACKed till the end of the application Xfer */ /* Call data packet message parsing and processing function */ - (void)USBD_CDC_RNDIS_ProcessPacketMsg(pdev, (USBD_CDC_RNDIS_PacketMsgTypeDef *)hcdc->RxBuffer); + (void)USBD_CDC_RNDIS_ProcessPacketMsg(pdev, (USBD_CDC_RNDIS_PacketMsgTypeDef *)(void *)hcdc->RxBuffer); } else { @@ -1071,7 +1075,7 @@ uint8_t USBD_CDC_RNDIS_TransmitPacket(USBD_HandleTypeDef *pdev) } hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData; - PacketMsg = (USBD_CDC_RNDIS_PacketMsgTypeDef *)hcdc->TxBuffer; + PacketMsg = (USBD_CDC_RNDIS_PacketMsgTypeDef *)(void *)hcdc->TxBuffer; if (hcdc->TxState == 0U) { @@ -1192,7 +1196,7 @@ uint8_t USBD_CDC_RNDIS_SendNotification(USBD_HandleTypeDef *pdev, */ static uint8_t USBD_CDC_RNDIS_MsgParsing(USBD_HandleTypeDef *pdev, uint8_t *RxBuff) { - USBD_CDC_RNDIS_CtrlMsgTypeDef *Msg = (USBD_CDC_RNDIS_CtrlMsgTypeDef *)RxBuff; + USBD_CDC_RNDIS_CtrlMsgTypeDef *Msg = (USBD_CDC_RNDIS_CtrlMsgTypeDef *)(void *)RxBuff; static uint8_t ret = (uint8_t)USBD_OK; /* Check message type */ @@ -1200,37 +1204,37 @@ static uint8_t USBD_CDC_RNDIS_MsgParsing(USBD_HandleTypeDef *pdev, uint8_t *RxBu { /* CDC_RNDIS Initialize message */ case CDC_RNDIS_INITIALIZE_MSG_ID: - ret = USBD_CDC_RNDIS_ProcessInitMsg(pdev, (USBD_CDC_RNDIS_InitMsgTypeDef *)Msg); + ret = USBD_CDC_RNDIS_ProcessInitMsg(pdev, (USBD_CDC_RNDIS_InitMsgTypeDef *)(void *)Msg); break; /* CDC_RNDIS Halt message */ case CDC_RNDIS_HALT_MSG_ID: - ret = USBD_CDC_RNDIS_ProcessHaltMsg(pdev, (USBD_CDC_RNDIS_HaltMsgTypeDef *)Msg); + ret = USBD_CDC_RNDIS_ProcessHaltMsg(pdev, (USBD_CDC_RNDIS_HaltMsgTypeDef *)(void *)Msg); break; /* CDC_RNDIS Query message */ case CDC_RNDIS_QUERY_MSG_ID: - ret = USBD_CDC_RNDIS_ProcessQueryMsg(pdev, (USBD_CDC_RNDIS_QueryMsgTypeDef *)Msg); + ret = USBD_CDC_RNDIS_ProcessQueryMsg(pdev, (USBD_CDC_RNDIS_QueryMsgTypeDef *)(void *)Msg); break; /* CDC_RNDIS Set message */ case CDC_RNDIS_SET_MSG_ID: - ret = USBD_CDC_RNDIS_ProcessSetMsg(pdev, (USBD_CDC_RNDIS_SetMsgTypeDef *)Msg); + ret = USBD_CDC_RNDIS_ProcessSetMsg(pdev, (USBD_CDC_RNDIS_SetMsgTypeDef *)(void *)Msg); break; /* CDC_RNDIS Reset message */ case CDC_RNDIS_RESET_MSG_ID: - ret = USBD_CDC_RNDIS_ProcessResetMsg(pdev, (USBD_CDC_RNDIS_ResetMsgTypeDef *)Msg); + ret = USBD_CDC_RNDIS_ProcessResetMsg(pdev, (USBD_CDC_RNDIS_ResetMsgTypeDef *)(void *)Msg); break; /* CDC_RNDIS Keep-Alive message */ case CDC_RNDIS_KEEPALIVE_MSG_ID: - ret = USBD_CDC_RNDIS_ProcessKeepAliveMsg(pdev, (USBD_CDC_RNDIS_KpAliveMsgTypeDef *)Msg); + ret = USBD_CDC_RNDIS_ProcessKeepAliveMsg(pdev, (USBD_CDC_RNDIS_KpAliveMsgTypeDef *)(void *)Msg); break; /* CDC_RNDIS unsupported message */ default: - ret = USBD_CDC_RNDIS_ProcessUnsupportedMsg(pdev, (USBD_CDC_RNDIS_CtrlMsgTypeDef *)Msg); + ret = USBD_CDC_RNDIS_ProcessUnsupportedMsg(pdev, (USBD_CDC_RNDIS_CtrlMsgTypeDef *)(void *)Msg); break; } @@ -1255,7 +1259,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessInitMsg(USBD_HandleTypeDef *pdev, USBD_CDC_RNDIS_InitMsgTypeDef *InitMessage = (USBD_CDC_RNDIS_InitMsgTypeDef *)Msg; /* Use same Msg input buffer as response buffer */ - USBD_CDC_RNDIS_InitCpltMsgTypeDef *InitResponse = (USBD_CDC_RNDIS_InitCpltMsgTypeDef *)Msg; + USBD_CDC_RNDIS_InitCpltMsgTypeDef *InitResponse = (USBD_CDC_RNDIS_InitCpltMsgTypeDef *)(void *)Msg; /* Store the Message Request ID */ uint32_t ReqId = InitMessage->ReqId; @@ -1336,7 +1340,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessKeepAliveMsg(USBD_HandleTypeDef *pdev, USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData; /* Use same Msg input buffer as response buffer */ - USBD_CDC_RNDIS_KpAliveCpltMsgTypeDef *InitResponse = (USBD_CDC_RNDIS_KpAliveCpltMsgTypeDef *)Msg; + USBD_CDC_RNDIS_KpAliveCpltMsgTypeDef *InitResponse = (USBD_CDC_RNDIS_KpAliveCpltMsgTypeDef *)(void *)Msg; /* Store the Message Request ID */ uint32_t ReqId = Msg->ReqId; @@ -1381,7 +1385,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessQueryMsg(USBD_HandleTypeDef *pdev, USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData; /* Use same Msg input buffer as response buffer */ - USBD_CDC_RNDIS_QueryCpltMsgTypeDef *QueryResponse = (USBD_CDC_RNDIS_QueryCpltMsgTypeDef *)Msg; + USBD_CDC_RNDIS_QueryCpltMsgTypeDef *QueryResponse = (USBD_CDC_RNDIS_QueryCpltMsgTypeDef *)(void *)Msg; /* Store the Message Request ID */ uint32_t ReqId = Msg->RequestId; @@ -1524,7 +1528,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessSetMsg(USBD_HandleTypeDef *pdev, USBD_CDC_RNDIS_SetMsgTypeDef *SetMessage = (USBD_CDC_RNDIS_SetMsgTypeDef *)Msg; /* Use same Msg input buffer as response buffer */ - USBD_CDC_RNDIS_SetCpltMsgTypeDef *SetResponse = (USBD_CDC_RNDIS_SetCpltMsgTypeDef *)Msg; + USBD_CDC_RNDIS_SetCpltMsgTypeDef *SetResponse = (USBD_CDC_RNDIS_SetCpltMsgTypeDef *)(void *)Msg; /* Store the Message Request ID */ uint32_t ReqId = SetMessage->ReqId; @@ -1578,7 +1582,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessResetMsg(USBD_HandleTypeDef *pdev, /* Get the CDC_RNDIS handle pointer */ USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData; /* Use same Msg input buffer as response buffer */ - USBD_CDC_RNDIS_ResetCpltMsgTypeDef *ResetResponse = (USBD_CDC_RNDIS_ResetCpltMsgTypeDef *)Msg; + USBD_CDC_RNDIS_ResetCpltMsgTypeDef *ResetResponse = (USBD_CDC_RNDIS_ResetCpltMsgTypeDef *)(void *)Msg; if ((ResetMessage->MsgLength != sizeof(USBD_CDC_RNDIS_ResetMsgTypeDef)) || \ (ResetMessage->Reserved != 0U)) @@ -1662,7 +1666,7 @@ static uint8_t USBD_CDC_RNDIS_ProcessUnsupportedMsg(USBD_HandleTypeDef *pdev, USBD_CDC_RNDIS_HandleTypeDef *hcdc = (USBD_CDC_RNDIS_HandleTypeDef *)pdev->pClassData; /* Use same Msg input buffer as response buffer */ - USBD_CDC_RNDIS_StsChangeMsgTypeDef *Response = (USBD_CDC_RNDIS_StsChangeMsgTypeDef *)Msg; + USBD_CDC_RNDIS_StsChangeMsgTypeDef *Response = (USBD_CDC_RNDIS_StsChangeMsgTypeDef *)(void *)Msg; /* Setup the response buffer content */ Response->MsgType = CDC_RNDIS_INDICATE_STATUS_MSG_ID; diff --git a/Core/Src/usbd_core.c b/Core/Src/usbd_core.c index 3faed35..67b2a67 100644 --- a/Core/Src/usbd_core.c +++ b/Core/Src/usbd_core.c @@ -100,16 +100,10 @@ USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, return USBD_FAIL; } - /* Unlink previous class */ - if (pdev->pClass != NULL) - { - pdev->pClass = NULL; - } - - if (pdev->pConfDesc != NULL) - { - pdev->pConfDesc = NULL; - } + /* Unlink previous class resources */ + pdev->pClass = NULL; + pdev->pUserData = NULL; + pdev->pConfDesc = NULL; /* Assign USBD Descriptors */ if (pdesc != NULL) @@ -137,6 +131,9 @@ USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev) { USBD_StatusTypeDef ret; + /* Disconnect the USB Device */ + (void)USBD_LL_Stop(pdev); + /* Set Default State */ pdev->dev_state = USBD_STATE_DEFAULT; @@ -144,22 +141,15 @@ USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev) if (pdev->pClass != NULL) { pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config); + pdev->pClass = NULL; + pdev->pUserData = NULL; } - if (pdev->pConfDesc != NULL) - { - pdev->pConfDesc = NULL; - } + /* Free Device descriptors resources */ + pdev->pDesc = NULL; + pdev->pConfDesc = NULL; - /* Stop the low level driver */ - ret = USBD_LL_Stop(pdev); - - if (ret != USBD_OK) - { - return ret; - } - - /* Initialize low level driver */ + /* DeInitialize low level driver */ ret = USBD_LL_DeInit(pdev); return ret; @@ -188,13 +178,18 @@ USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDe pdev->pClass = pclass; /* Get Device Configuration Descriptor */ -#ifdef USE_USB_FS - pdev->pConfDesc = (void *)pdev->pClass->GetFSConfigDescriptor(&len); -#else /* USE_USB_HS */ - pdev->pConfDesc = (void *)pdev->pClass->GetHSConfigDescriptor(&len); +#ifdef USE_USB_HS + if (pdev->pClass->GetHSConfigDescriptor != NULL) + { + pdev->pConfDesc = (void *)pdev->pClass->GetHSConfigDescriptor(&len); + } +#else /* Default USE_USB_FS */ + if (pdev->pClass->GetFSConfigDescriptor != NULL) + { + pdev->pConfDesc = (void *)pdev->pClass->GetFSConfigDescriptor(&len); + } #endif /* USE_USB_FS */ - return USBD_OK; } @@ -218,23 +213,16 @@ USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev) */ USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev) { - USBD_StatusTypeDef ret; + /* Disconnect USB Device */ + (void)USBD_LL_Stop(pdev); /* Free Class Resources */ if (pdev->pClass != NULL) { - pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config); + (void)pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config); } - if (pdev->pConfDesc != NULL) - { - pdev->pConfDesc = NULL; - } - - /* Stop the low level driver */ - ret = USBD_LL_Stop(pdev); - - return ret; + return USBD_OK; } /** diff --git a/Core/Src/usbd_ctlreq.c b/Core/Src/usbd_ctlreq.c index c31d40e..cadaf12 100644 --- a/Core/Src/usbd_ctlreq.c +++ b/Core/Src/usbd_ctlreq.c @@ -285,7 +285,7 @@ USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef (void)USBD_LL_ClearStallEP(pdev, ep_addr); } (void)USBD_CtlSendStatus(pdev); - (USBD_StatusTypeDef)pdev->pClass->Setup(pdev, req); + ret = (USBD_StatusTypeDef)pdev->pClass->Setup(pdev, req); } break; diff --git a/README.md b/README.md index e279717..ba20ce7 100644 --- a/README.md +++ b/README.md @@ -29,21 +29,6 @@ This software component is licensed by ST under Ultimate Liberty license SLA004 Details about the content of this release are available in the release note [here](https://htmlpreview.github.io/?https://github.com/STMicroelectronics/stm32_mw_usb_device/blob/master/Release_Notes.html). -## Compatibility information - -This table shows the correspondence between the USB Device MW version and the corresponding HAL version of the targeted series. It is **crucial** that you use a consistent set of versions for the MW - HAL, as mentioned in this table. - -Note that: -* in case a series does not support a particular tag, it is not mentioned in front of it. -* in case a series supports a recent tag, it is not mentioned in front of older ones. - -USB Device | HAL | ----------- | ---------- | -Tag v2.5.1 | Tag v1.10.2 ([stm32l0xx_hal_driver](https://github.com/STMicroelectronics/stm32l0xx_hal_driver)) -Tag v2.5.2 | Tag v1.4.0 ([stm32l1xx_hal_driver](https://github.com/STMicroelectronics/stm32l1xx_hal_driver)) -Tag v2.5.3 | Tag v1.7.3 ([stm32f0xx_hal_driver](https://github.com/STMicroelectronics/stm32f0xx_hal_driver))
Tag v1.1.4 ([stm32f1xx_hal_driver](https://github.com/STMicroelectronics/stm32f1xx_hal_driver))
Tag v1.2.4 ([stm32f2xx_hal_driver](https://github.com/STMicroelectronics/stm32f2xx_hal_driver))
Tag v1.5.3 ([stm32f3xx_hal_driver](https://github.com/STMicroelectronics/stm32f3xx_hal_driver)) -Tag v2.6.0 | Tag v1.7.8 ([stm32f4xx_hal_driver](https://github.com/STMicroelectronics/stm32f4xx_hal_driver))
Tag v1.2.8 ([stm32f7xx_hal_driver](https://github.com/STMicroelectronics/stm32f7xx_hal_driver))
Tag v1.9.0 ([stm32h7xx_hal_driver](https://github.com/STMicroelectronics/stm32h7xx_hal_driver))
Tag v1.12.0 ([stm32l4xx_hal_driver](https://github.com/STMicroelectronics/stm32l4xx_hal_driver))
Tag v1.6.0 ([stm32wbxx_hal_driver](https://github.com/STMicroelectronics/stm32wbxx_hal_driver)) - ## 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). diff --git a/Release_Notes.html b/Release_Notes.html index c1432a6..fa16ae7 100644 --- a/Release_Notes.html +++ b/Release_Notes.html @@ -14,6 +14,7 @@ + - +
@@ -920,10 +920,60 @@ ul

 

- +
-

Update History

-

V2.6.0 / 27-December-2019

Main +

Update History

+

V2.6.1 / 05-June-2020

+ + + +

Main +Changes

+ + + + + + + + + + + + + + + + + + + + + + + +
    +
  • USB Core:
  • +
      +
    • minor rework on USBD_Init() USBD_DeInit()
    • +
    • Fix warning issue with Keil due to missing return value of setup API
      +
    • +
    +
  • USB CDC Class:
  • +
      +
    • Fix file indentation
    • +
    • Avoid accessing to NULL pointer in case +TransmitCplt() user fops is not defined to allow application +compatibility with device library version below v2.6.0
      +
    • +
    +
+
+
    +
  • Fix minor misra-c 2012 violations
  • +
+

V2.6.0 / 27-December-2019

+

Main Changes

@@ -946,7 +996,7 @@ Changes
  • Integration of three new USB device Class drivers:
    • USB CDC ECM Class driver
    • USB CDC RNDIS Microsoft Class driver
    • USB Billboard Class driver
  • Fix mondatory misra-c 2012 violations
  • update user core and class template files
  • USB Core:
    • Fix unexpected EP0 stall during enumeration phase 
    • Improve APIs error management and prevent accessing NULL pointers
  • USB MSC Class:
    • Fix USBCV specific class tests
    • Fix mutliple error with SCSI commands handling
    • Protect medium access when host ask for medium ejection
  • USB CDC Class:
    • Add new function to inform user that current IN transfer is completed
    • update transmit and receive APIs to transfer up to 64KB
    • USB AUDIO Class:
      • Fix audio sync start buffer size
      • update user callback periodicTC args by adding pointer to user buffer and size
    • USB CustomHID Class:
      • Rework the OUT transfer complete and prevent automaticly re-enabling the OUT EP 
      • Add new user API to restart the OUT transfer: USBD_CUSTOM_HID_ReceivePacket()

    V2.5.3 / 30-April-2019

    Main +

    • Integration of three new USB device Class drivers:
      • USB CDC ECM Class driver
      • USB CDC RNDIS Microsoft Class driver
      • USB Billboard Class driver
    • Fix mondatory misra-c 2012 violations
    • update user core and class template files
    • USB Core:
      • Fix unexpected EP0 stall during enumeration phase 
      • Improve APIs error management and prevent accessing NULL pointers
    • USB MSC Class:
      • Fix USBCV specific class tests
      • Fix multiple error with SCSI commands handling
      • Protect medium access when host ask for medium ejection
    • USB CDC Class:
      • Add new function to inform user that current IN transfer is completed
      • update transmit and receive APIs to transfer up to 64KB
    • USB AUDIO Class:
      • Fix audio sync start buffer size
      • update user callback periodicTC args by adding pointer to user buffer and size
    • USB CustomHID Class:
      • Rework the OUT transfer complete and prevent automatically re-enabling the OUT EP 
      • Add new user API to restart the OUT transfer: USBD_CUSTOM_HID_ReceivePacket()

    V2.5.3 / 30-April-2019

    Main Changes

    @@ -969,7 +1019,7 @@ Changes
  • Fix misra-c 2012 high severity violations
  • Core driver:
    • protect shared macros __ALIGN_BEGIN, __ALIGN_END with C directive #ifndef
    • update Core driver and DFU Class driver to use USBD_SUPPORT_USER_STRING_DESC insead of  USBD_SUPPORT_USER_STRING
    •  prevent accessing to NULL pointer if the get descriptor functions are not defined
    • Update on USBD_LL_Resume(),  restore the device state only if the current state is USBD_STATE_SUSPENDED

    V2.5.2 / 27-Mars-2019

    Main +

    • Fix misra-c 2012 high severity violations
    • Core driver:
      • protect shared macros __ALIGN_BEGIN, __ALIGN_END with C directive #ifndef
      • update Core driver and DFU Class driver to use USBD_SUPPORT_USER_STRING_DESC insead of  USBD_SUPPORT_USER_STRING
      •  prevent accessing to NULL pointer if the get descriptor functions are not defined
      • Update on USBD_LL_Resume(),  restore the device state only if the current state is USBD_STATE_SUSPENDED

    V2.5.2 / 27-Mars-2019

    Main Changes

    @@ -993,7 +1043,7 @@ Changes
  • DFU Class:
    • fix compilation warning due to unreachable - instruction code introduced with CMSIS V5.4.0 NVIC_SystemReset() prototype change

    V2.5.1 / 03-August-2018
    +
    instruction code introduced with CMSIS V5.4.0 NVIC_SystemReset() prototype change

    V2.5.1 / 03-August-2018

    @@ -1035,7 +1085,7 @@ Changes
  • Update license section by adding path to get copy of ST Ultimate Liberty license
  • Core: Fix unexpected stall during status OUT phase
  • DFU Class:
    • rework hdfu struct to prevent unaligned addresses
  • MSC Class:
    • fix lba address overflow during large file transfers > 4Go
  • Template Class:
    • add missing Switch case Break on USBD_Template_Setup API

    V2.5.0 / 15-December-2017
    +
    • Update license section by adding path to get copy of ST Ultimate Liberty license
    • Core: Fix unexpected stall during status OUT phase
    • DFU Class:
      • rework hdfu struct to prevent unaligned addresses
    • MSC Class:
      • fix lba address overflow during large file transfers > 4Go
    • Template Class:
      • add missing Switch case Break on USBD_Template_Setup API

    V2.5.0 / 15-December-2017

    @@ -1077,7 +1127,7 @@ Changes
  • Update license section
  • Update some functions to be MISRAC 2004 compliant
  • Add HS and OtherSpeed configuration descriptor for HID and CustomHID classes
  • Correct error handling in all class setup function
  • Add usbd_desc_template.c/ usbd_desc_template.h templates files
  • Add support of class and vendor request
  • CDC Class: fix zero-length packet issue in bulk IN transfer
  • Fix compilation warning with unused arguments for some functions
  • Improve USB Core enumeration state machine
  • V2.4.2 / 11-December-2015
    +
    • Update license section
    • Update some functions to be MISRAC 2004 compliant
    • Add HS and OtherSpeed configuration descriptor for HID and CustomHID classes
    • Correct error handling in all class setup function
    • Add usbd_desc_template.c/ usbd_desc_template.h templates files
    • Add support of class and vendor request
    • CDC Class: fix zero-length packet issue in bulk IN transfer
    • Fix compilation warning with unused arguments for some functions
    • Improve USB Core enumeration state machine

    V2.4.2 / 11-December-2015

    @@ -1124,7 +1174,7 @@ Changes
    V2.4.1 / 19-June-2015
    +

    V2.4.1 / 19-June-2015

    @@ -1183,7 +1233,7 @@ Changes
    V2.4.0 / 28-February-2015
    +

    V2.4.0 / 28-February-2015

    @@ -1233,7 +1283,7 @@ USBD_CDC_Setup() function to allow correct user implementation of CDC_SET_CONTROL_LINE_STATE and similar no-data setup requests.
    -

    V2.3.0 / 04-November-2014
    +

    V2.3.0 / 04-November-2014

    @@ -1276,7 +1326,7 @@ Changes
    Miscellaneous source code comments update -

    V2.2.0 / 13-June-2014

    +

    V2.2.0 / 13-June-2014

    @@ -1322,7 +1372,7 @@ Changes
    ex. for the HID, the USBD_HID_CLASS macro is defined this way #define USBD_HID_CLASS  &USBD_HID
      and the application code can use the previous definition: &USBD_HID ex. USBD_RegisterClass(&USBD_Device, &USBD_HID) or the new USBD_HID_CLASS ex. USBD_RegisterClass(&USBD_Device, USBD_HID_CLASS) -

    V2.1.0 / 22-April-2014

    +

    V2.1.0 / 22-April-2014

    @@ -1360,7 +1410,7 @@ Changes
    V2.0.0 / 18-February-2014

    +

    V2.0.0 / 18-February-2014

    @@ -1385,14 +1435,14 @@ modified vs. V1.1.0, and thus the 2 versions are not compatible.
    -

    V1.1.0 / 19-March-2012

    +

    V1.1.0 / 19-March-2012

    Main Changes

    -
    • Official support of STM32F4xx devices
    • All source files: license disclaimer text update and add link to the License file on ST Internet.
    • Handle test mode in the set feature request
    • Handle dynamically the USB SELF POWERED feature
    • Handle correctly the USBD_CtlError process to take into account error during Control OUT stage
    • Miscellaneous bug fix

    V1.0.0 / 22-July-2011

    Main +

    • Official support of STM32F4xx devices
    • All source files: license disclaimer text update and add link to the License file on ST Internet.
    • Handle test mode in the set feature request
    • Handle dynamically the USB SELF POWERED feature
    • Handle correctly the USBD_CtlError process to take into account error during Control OUT stage
    • Miscellaneous bug fix

    V1.0.0 / 22-July-2011

    Main Changes

    • First official version for STM32F105/7xx and STM32F2xx devices

    -

    License

    This +

    License

    This software component is licensed by ST under Ultimate Liberty license SLA0044, the "License"; You may not use this component except in compliance with the License. You may obtain a copy of the License at:

    http://www.st.com/SLA0044