summaryrefslogtreecommitdiff
path: root/stm32cubemx/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'stm32cubemx/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c')
-rw-r--r--stm32cubemx/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c224
1 files changed, 112 insertions, 112 deletions
diff --git a/stm32cubemx/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c b/stm32cubemx/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c
index 0158829..ff3ed44 100644
--- a/stm32cubemx/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c
+++ b/stm32cubemx/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c
@@ -16,14 +16,14 @@
*
* http://www.st.com/software_license_agreement_liberty_v2
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
- */
+ */
/* Includes ------------------------------------------------------------------*/
#include "usbd_core.h"
@@ -33,57 +33,57 @@
*/
-/** @defgroup USBD_CORE
+/** @defgroup USBD_CORE
* @brief usbd core module
* @{
-*/
+*/
/** @defgroup USBD_CORE_Private_TypesDefinitions
* @{
-*/
+*/
/**
* @}
-*/
+*/
/** @defgroup USBD_CORE_Private_Defines
* @{
-*/
+*/
/**
* @}
-*/
+*/
/** @defgroup USBD_CORE_Private_Macros
* @{
-*/
+*/
/**
* @}
-*/
+*/
/** @defgroup USBD_CORE_Private_FunctionPrototypes
* @{
-*/
+*/
/**
* @}
-*/
+*/
/** @defgroup USBD_CORE_Private_Variables
* @{
-*/
+*/
/**
* @}
-*/
+*/
/** @defgroup USBD_CORE_Private_Functions
* @{
-*/
+*/
/**
* @brief USBD_Init
@@ -99,32 +99,32 @@ USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *
if(pdev == NULL)
{
USBD_ErrLog("Invalid Device handle");
- return USBD_FAIL;
+ return USBD_FAIL;
}
-
+
/* Unlink previous class*/
if(pdev->pClass != NULL)
{
pdev->pClass = NULL;
}
-
+
/* Assign USBD Descriptors */
if(pdesc != NULL)
{
pdev->pDesc = pdesc;
}
-
+
/* Set Device initial State */
pdev->dev_state = USBD_STATE_DEFAULT;
pdev->id = id;
/* Initialize low level driver */
USBD_LL_Init(pdev);
-
- return USBD_OK;
+
+ return USBD_OK;
}
/**
-* @brief USBD_DeInit
+* @brief USBD_DeInit
* Re-Initialize th device library
* @param pdev: device instance
* @retval status: status
@@ -133,22 +133,22 @@ USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev)
{
/* Set Default State */
pdev->dev_state = USBD_STATE_DEFAULT;
-
+
/* Free Class Resources */
- pdev->pClass->DeInit(pdev, pdev->dev_config);
-
+ pdev->pClass->DeInit(pdev, pdev->dev_config);
+
/* Stop the low level driver */
- USBD_LL_Stop(pdev);
-
+ USBD_LL_Stop(pdev);
+
/* Initialize low level driver */
USBD_LL_DeInit(pdev);
-
+
return USBD_OK;
}
/**
- * @brief USBD_RegisterClass
+ * @brief USBD_RegisterClass
* Link class driver to Device Core.
* @param pDevice : Device Handle
* @param pclass: Class handle
@@ -166,29 +166,29 @@ USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeD
else
{
USBD_ErrLog("Invalid Class handle");
- status = USBD_FAIL;
+ status = USBD_FAIL;
}
-
+
return status;
}
/**
- * @brief USBD_Start
+ * @brief USBD_Start
* Start the USB Device Core.
* @param pdev: Device Handle
* @retval USBD Status
*/
USBD_StatusTypeDef USBD_Start (USBD_HandleTypeDef *pdev)
{
-
+
/* Start the low level driver */
- USBD_LL_Start(pdev);
-
- return USBD_OK;
+ USBD_LL_Start(pdev);
+
+ return USBD_OK;
}
/**
- * @brief USBD_Stop
+ * @brief USBD_Stop
* Stop the USB Device Core.
* @param pdev: Device Handle
* @retval USBD Status
@@ -196,28 +196,28 @@ USBD_StatusTypeDef USBD_Start (USBD_HandleTypeDef *pdev)
USBD_StatusTypeDef USBD_Stop (USBD_HandleTypeDef *pdev)
{
/* Free Class Resources */
- pdev->pClass->DeInit(pdev, pdev->dev_config);
+ pdev->pClass->DeInit(pdev, pdev->dev_config);
/* Stop the low level driver */
- USBD_LL_Stop(pdev);
-
- return USBD_OK;
+ USBD_LL_Stop(pdev);
+
+ return USBD_OK;
}
/**
-* @brief USBD_RunTestMode
+* @brief USBD_RunTestMode
* Launch test mode process
* @param pdev: device instance
* @retval status
*/
-USBD_StatusTypeDef USBD_RunTestMode (USBD_HandleTypeDef *pdev)
+USBD_StatusTypeDef USBD_RunTestMode (USBD_HandleTypeDef *pdev)
{
return USBD_OK;
}
/**
-* @brief USBD_SetClassConfig
+* @brief USBD_SetClassConfig
* Configure device and start the interface
* @param pdev: device instance
* @param cfgidx: configuration index
@@ -227,7 +227,7 @@ USBD_StatusTypeDef USBD_RunTestMode (USBD_HandleTypeDef *pdev)
USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
USBD_StatusTypeDef ret = USBD_FAIL;
-
+
if(pdev->pClass != NULL)
{
/* Set configuration and Start the Class*/
@@ -236,11 +236,11 @@ USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx
ret = USBD_OK;
}
}
- return ret;
+ return ret;
}
/**
-* @brief USBD_ClrClassConfig
+* @brief USBD_ClrClassConfig
* Clear current configuration
* @param pdev: device instance
* @param cfgidx: configuration index
@@ -249,13 +249,13 @@ USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx
USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
/* Clear configuration and De-initialize the Class process*/
- pdev->pClass->DeInit(pdev, cfgidx);
+ pdev->pClass->DeInit(pdev, cfgidx);
return USBD_OK;
}
/**
-* @brief USBD_SetupStage
+* @brief USBD_SetupStage
* Handle the setup stage
* @param pdev: device instance
* @retval status
@@ -264,33 +264,33 @@ USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup)
{
USBD_ParseSetupRequest(&pdev->request, psetup);
-
+
pdev->ep0_state = USBD_EP0_SETUP;
pdev->ep0_data_len = pdev->request.wLength;
-
- switch (pdev->request.bmRequest & 0x1F)
+
+ switch (pdev->request.bmRequest & 0x1F)
{
- case USB_REQ_RECIPIENT_DEVICE:
+ case USB_REQ_RECIPIENT_DEVICE:
USBD_StdDevReq (pdev, &pdev->request);
break;
-
- case USB_REQ_RECIPIENT_INTERFACE:
+
+ case USB_REQ_RECIPIENT_INTERFACE:
USBD_StdItfReq(pdev, &pdev->request);
break;
-
- case USB_REQ_RECIPIENT_ENDPOINT:
- USBD_StdEPReq(pdev, &pdev->request);
+
+ case USB_REQ_RECIPIENT_ENDPOINT:
+ USBD_StdEPReq(pdev, &pdev->request);
break;
-
- default:
+
+ default:
USBD_LL_StallEP(pdev , pdev->request.bmRequest & 0x80);
break;
- }
- return USBD_OK;
+ }
+ return USBD_OK;
}
/**
-* @brief USBD_DataOutStage
+* @brief USBD_DataOutStage
* Handle data OUT stage
* @param pdev: device instance
* @param epnum: endpoint index
@@ -299,18 +299,18 @@ USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup)
USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata)
{
USBD_EndpointTypeDef *pep;
-
- if(epnum == 0)
+
+ if(epnum == 0)
{
pep = &pdev->ep_out[0];
-
+
if ( pdev->ep0_state == USBD_EP0_DATA_OUT)
{
if(pep->rem_length > pep->maxpacket)
{
pep->rem_length -= pep->maxpacket;
-
- USBD_CtlContinueRx (pdev,
+
+ USBD_CtlContinueRx (pdev,
pdata,
MIN(pep->rem_length ,pep->maxpacket));
}
@@ -319,7 +319,7 @@ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum
if((pdev->pClass->EP0_RxReady != NULL)&&
(pdev->dev_state == USBD_STATE_CONFIGURED))
{
- pdev->pClass->EP0_RxReady(pdev);
+ pdev->pClass->EP0_RxReady(pdev);
}
USBD_CtlSendStatus(pdev);
}
@@ -328,13 +328,13 @@ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum
else if((pdev->pClass->DataOut != NULL)&&
(pdev->dev_state == USBD_STATE_CONFIGURED))
{
- pdev->pClass->DataOut(pdev, epnum);
- }
+ pdev->pClass->DataOut(pdev, epnum);
+ }
return USBD_OK;
}
/**
-* @brief USBD_DataInStage
+* @brief USBD_DataInStage
* Handle data in stage
* @param pdev: device instance
* @param epnum: endpoint index
@@ -343,26 +343,26 @@ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum
USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev ,uint8_t epnum, uint8_t *pdata)
{
USBD_EndpointTypeDef *pep;
-
- if(epnum == 0)
+
+ if(epnum == 0)
{
pep = &pdev->ep_in[0];
-
+
if ( pdev->ep0_state == USBD_EP0_DATA_IN)
{
if(pep->rem_length > pep->maxpacket)
{
pep->rem_length -= pep->maxpacket;
-
- USBD_CtlContinueSendData (pdev,
- pdata,
+
+ USBD_CtlContinueSendData (pdev,
+ pdata,
pep->rem_length);
-
+
/* Prepare endpoint for premature end of transfer */
USBD_LL_PrepareReceive (pdev,
0,
NULL,
- 0);
+ 0);
}
else
{ /* last packet is MPS multiple, so send ZLP packet */
@@ -370,10 +370,10 @@ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev ,uint8_t epnum,
(pep->total_length >= pep->maxpacket) &&
(pep->total_length < pdev->ep0_data_len ))
{
-
+
USBD_CtlContinueSendData(pdev , NULL, 0);
pdev->ep0_data_len = 0;
-
+
/* Prepare endpoint for premature end of transfer */
USBD_LL_PrepareReceive (pdev,
0,
@@ -385,28 +385,28 @@ USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev ,uint8_t epnum,
if((pdev->pClass->EP0_TxSent != NULL)&&
(pdev->dev_state == USBD_STATE_CONFIGURED))
{
- pdev->pClass->EP0_TxSent(pdev);
- }
+ pdev->pClass->EP0_TxSent(pdev);
+ }
USBD_CtlReceiveStatus(pdev);
}
}
}
if (pdev->dev_test_mode == 1)
{
- USBD_RunTestMode(pdev);
+ USBD_RunTestMode(pdev);
pdev->dev_test_mode = 0;
}
}
- else if((pdev->pClass->DataIn != NULL)&&
+ else if((pdev->pClass->DataIn != NULL)&&
(pdev->dev_state == USBD_STATE_CONFIGURED))
{
- pdev->pClass->DataIn(pdev, epnum);
- }
+ pdev->pClass->DataIn(pdev, epnum);
+ }
return USBD_OK;
}
/**
-* @brief USBD_LL_Reset
+* @brief USBD_LL_Reset
* Handle Reset event
* @param pdev: device instance
* @retval status
@@ -419,23 +419,23 @@ USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
0x00,
USBD_EP_TYPE_CTRL,
USB_MAX_EP0_SIZE);
-
+
pdev->ep_out[0].maxpacket = USB_MAX_EP0_SIZE;
-
+
/* Open EP0 IN */
USBD_LL_OpenEP(pdev,
0x80,
USBD_EP_TYPE_CTRL,
USB_MAX_EP0_SIZE);
-
+
pdev->ep_in[0].maxpacket = USB_MAX_EP0_SIZE;
/* Upon Reset call user call back */
pdev->dev_state = USBD_STATE_DEFAULT;
-
- if (pdev->pClassData)
- pdev->pClass->DeInit(pdev, pdev->dev_config);
-
-
+
+ if (pdev->pClassData)
+ pdev->pClass->DeInit(pdev, pdev->dev_config);
+
+
return USBD_OK;
}
@@ -443,7 +443,7 @@ USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
/**
-* @brief USBD_LL_Reset
+* @brief USBD_LL_Reset
* Handle Reset event
* @param pdev: device instance
* @retval status
@@ -455,7 +455,7 @@ USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef
}
/**
-* @brief USBD_Suspend
+* @brief USBD_Suspend
* Handle Suspend event
* @param pdev: device instance
* @retval status
@@ -469,7 +469,7 @@ USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev)
}
/**
-* @brief USBD_Resume
+* @brief USBD_Resume
* Handle Resume event
* @param pdev: device instance
* @retval status
@@ -477,12 +477,12 @@ USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev)
USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev)
{
- pdev->dev_state = pdev->dev_old_state;
+ pdev->dev_state = pdev->dev_old_state;
return USBD_OK;
}
/**
-* @brief USBD_SOF
+* @brief USBD_SOF
* Handle SOF event
* @param pdev: device instance
* @retval status
@@ -501,7 +501,7 @@ USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
}
/**
-* @brief USBD_IsoINIncomplete
+* @brief USBD_IsoINIncomplete
* Handle iso in incomplete event
* @param pdev: device instance
* @retval status
@@ -512,7 +512,7 @@ USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t ep
}
/**
-* @brief USBD_IsoOUTIncomplete
+* @brief USBD_IsoOUTIncomplete
* Handle iso out incomplete event
* @param pdev: device instance
* @retval status
@@ -523,7 +523,7 @@ USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t e
}
/**
-* @brief USBD_DevConnected
+* @brief USBD_DevConnected
* Handle device connection event
* @param pdev: device instance
* @retval status
@@ -534,7 +534,7 @@ USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev)
}
/**
-* @brief USBD_DevDisconnected
+* @brief USBD_DevDisconnected
* Handle device disconnection event
* @param pdev: device instance
* @retval status
@@ -543,23 +543,23 @@ USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev)
{
/* Free Class Resources */
pdev->dev_state = USBD_STATE_DEFAULT;
- pdev->pClass->DeInit(pdev, pdev->dev_config);
-
+ pdev->pClass->DeInit(pdev, pdev->dev_config);
+
return USBD_OK;
}
/**
* @}
-*/
+*/
/**
* @}
-*/
+*/
/**
* @}
-*/
+*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/