diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/AUDIO/Inc/usbh_audio.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/AUDIO/Inc/usbh_audio.h
index 80d286f84e..1fb53ac196 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/AUDIO/Inc/usbh_audio.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/AUDIO/Inc/usbh_audio.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -190,7 +189,7 @@ typedef struct
uint8_t Pipe;
uint8_t Poll;
- uint32_t timer ;
+ uint32_t timer;
uint8_t asociated_as;
uint8_t asociated_mixer;
@@ -222,7 +221,7 @@ typedef struct
uint8_t Pipe;
uint8_t Poll;
- uint32_t timer ;
+ uint32_t timer;
}
AUDIO_InterfaceControlPropTypeDef;
@@ -582,5 +581,4 @@ void USBH_AUDIO_BufferEmptyCallback(USBH_HandleTypeDef *phost);
/**
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/AUDIO/Src/usbh_audio.c b/system/Middlewares/ST/STM32_USB_Host_Library/Class/AUDIO/Src/usbh_audio.c
index 4cdfe9da6b..48358466ae 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/AUDIO/Src/usbh_audio.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/AUDIO/Src/usbh_audio.c
@@ -4,6 +4,17 @@
* @author MCD Application Team
* @brief This file is the AC Layer Handlers for USB Host AC class.
*
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
* @verbatim
*
* ===================================================================
@@ -15,17 +26,6 @@
* @endverbatim
*
******************************************************************************
- * @attention
- *
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
- *
- ******************************************************************************
*/
/* BSPDependencies
@@ -63,7 +63,6 @@ EndBSPDependencies */
* @}
*/
-
/** @defgroup USBH_AUDIO_CORE_Private_Defines
* @{
*/
@@ -72,7 +71,6 @@ EndBSPDependencies */
* @}
*/
-
/** @defgroup USBH_AUDIO_CORE_Private_Macros
* @{
*/
@@ -80,7 +78,6 @@ EndBSPDependencies */
* @}
*/
-
/** @defgroup USBH_AUDIO_CORE_Private_Variables
* @{
*/
@@ -89,7 +86,6 @@ EndBSPDependencies */
* @}
*/
-
/** @defgroup USBH_AUDIO_CORE_Private_FunctionPrototypes
* @{
*/
@@ -218,7 +214,7 @@ static USBH_StatusTypeDef USBH_AUDIO_InterfaceInit(USBH_HandleTypeDef *phost)
}
/* Initialize audio handler */
- USBH_memset(AUDIO_Handle, 0, sizeof(AUDIO_HandleTypeDef));
+ (void)USBH_memset(AUDIO_Handle, 0, sizeof(AUDIO_HandleTypeDef));
/* 1st Step: Find Audio Interfaces */
out_status = USBH_AUDIO_FindAudioStreamingIN(phost);
@@ -269,43 +265,43 @@ static USBH_StatusTypeDef USBH_AUDIO_InterfaceInit(USBH_HandleTypeDef *phost)
}
/* 3rd Step: Find and Parse Audio interfaces */
- USBH_AUDIO_ParseCSDescriptors(phost);
+ (void)USBH_AUDIO_ParseCSDescriptors(phost);
/* 4th Step: Open the Audio streaming pipes*/
if (AUDIO_Handle->headphone.supported == 1U)
{
- USBH_AUDIO_BuildHeadphonePath(phost);
+ (void)USBH_AUDIO_BuildHeadphonePath(phost);
AUDIO_Handle->headphone.Pipe = USBH_AllocPipe(phost, AUDIO_Handle->headphone.Ep);
/* Open pipe for IN endpoint */
- USBH_OpenPipe(phost,
- AUDIO_Handle->headphone.Pipe,
- AUDIO_Handle->headphone.Ep,
- phost->device.address,
- phost->device.speed,
- USB_EP_TYPE_ISOC,
- AUDIO_Handle->headphone.EpSize);
-
- USBH_LL_SetToggle(phost, AUDIO_Handle->headphone.Pipe, 0U);
+ (void)USBH_OpenPipe(phost,
+ AUDIO_Handle->headphone.Pipe,
+ AUDIO_Handle->headphone.Ep,
+ phost->device.address,
+ phost->device.speed,
+ USB_EP_TYPE_ISOC,
+ AUDIO_Handle->headphone.EpSize);
+
+ (void)USBH_LL_SetToggle(phost, AUDIO_Handle->headphone.Pipe, 0U);
}
if (AUDIO_Handle->microphone.supported == 1U)
{
- USBH_AUDIO_BuildMicrophonePath(phost);
+ (void)USBH_AUDIO_BuildMicrophonePath(phost);
AUDIO_Handle->microphone.Pipe = USBH_AllocPipe(phost, AUDIO_Handle->microphone.Ep);
/* Open pipe for IN endpoint */
- USBH_OpenPipe(phost,
- AUDIO_Handle->microphone.Pipe,
- AUDIO_Handle->microphone.Ep,
- phost->device.address,
- phost->device.speed,
- USB_EP_TYPE_ISOC,
- AUDIO_Handle->microphone.EpSize);
-
- USBH_LL_SetToggle(phost, AUDIO_Handle->microphone.Pipe, 0U);
+ (void)USBH_OpenPipe(phost,
+ AUDIO_Handle->microphone.Pipe,
+ AUDIO_Handle->microphone.Ep,
+ phost->device.address,
+ phost->device.speed,
+ USB_EP_TYPE_ISOC,
+ AUDIO_Handle->microphone.EpSize);
+
+ (void)USBH_LL_SetToggle(phost, AUDIO_Handle->microphone.Pipe, 0U);
}
if (AUDIO_Handle->control.supported == 1U)
@@ -313,15 +309,15 @@ static USBH_StatusTypeDef USBH_AUDIO_InterfaceInit(USBH_HandleTypeDef *phost)
AUDIO_Handle->control.Pipe = USBH_AllocPipe(phost, AUDIO_Handle->control.Ep);
/* Open pipe for IN endpoint */
- USBH_OpenPipe(phost,
- AUDIO_Handle->control.Pipe,
- AUDIO_Handle->control.Ep,
- phost->device.address,
- phost->device.speed,
- USB_EP_TYPE_INTR,
- AUDIO_Handle->control.EpSize);
+ (void)USBH_OpenPipe(phost,
+ AUDIO_Handle->control.Pipe,
+ AUDIO_Handle->control.Ep,
+ phost->device.address,
+ phost->device.speed,
+ USB_EP_TYPE_INTR,
+ AUDIO_Handle->control.EpSize);
- USBH_LL_SetToggle(phost, AUDIO_Handle->control.Pipe, 0U);
+ (void)USBH_LL_SetToggle(phost, AUDIO_Handle->control.Pipe, 0U);
}
@@ -344,31 +340,31 @@ static USBH_StatusTypeDef USBH_AUDIO_InterfaceDeInit(USBH_HandleTypeDef *phost)
if (AUDIO_Handle->microphone.Pipe != 0x00U)
{
- USBH_ClosePipe(phost, AUDIO_Handle->microphone.Pipe);
- USBH_FreePipe(phost, AUDIO_Handle->microphone.Pipe);
+ (void)USBH_ClosePipe(phost, AUDIO_Handle->microphone.Pipe);
+ (void)USBH_FreePipe(phost, AUDIO_Handle->microphone.Pipe);
AUDIO_Handle->microphone.Pipe = 0U; /* Reset the pipe as Free */
}
if (AUDIO_Handle->headphone.Pipe != 0x00U)
{
- USBH_ClosePipe(phost, AUDIO_Handle->headphone.Pipe);
- USBH_FreePipe(phost, AUDIO_Handle->headphone.Pipe);
+ (void)USBH_ClosePipe(phost, AUDIO_Handle->headphone.Pipe);
+ (void)USBH_FreePipe(phost, AUDIO_Handle->headphone.Pipe);
AUDIO_Handle->headphone.Pipe = 0U; /* Reset the pipe as Free */
}
if (AUDIO_Handle->control.Pipe != 0x00U)
{
- USBH_ClosePipe(phost, AUDIO_Handle->control.Pipe);
- USBH_FreePipe(phost, AUDIO_Handle->control.Pipe);
+ (void)USBH_ClosePipe(phost, AUDIO_Handle->control.Pipe);
+ (void)USBH_FreePipe(phost, AUDIO_Handle->control.Pipe);
AUDIO_Handle->control.Pipe = 0U; /* Reset the pipe as Free */
}
- if (phost->pActiveClass->pData)
+ if ((phost->pActiveClass->pData) != 0U)
{
USBH_free(phost->pActiveClass->pData);
phost->pActiveClass->pData = 0U;
}
- return USBH_OK ;
+ return USBH_OK;
}
@@ -388,178 +384,153 @@ static USBH_StatusTypeDef USBH_AUDIO_ClassRequest(USBH_HandleTypeDef *phost)
/* Switch AUDIO REQ state machine */
switch (AUDIO_Handle->req_state)
{
- case AUDIO_REQ_INIT:
- case AUDIO_REQ_SET_DEFAULT_IN_INTERFACE:
- if (AUDIO_Handle->microphone.supported == 1U)
- {
- req_status = USBH_SetInterface(phost,
- AUDIO_Handle->microphone.interface,
- 0U);
-
- if (req_status == USBH_OK)
- {
- AUDIO_Handle->req_state = AUDIO_REQ_SET_DEFAULT_OUT_INTERFACE;
- }
- else if (req_status == USBH_NOT_SUPPORTED)
+ case AUDIO_REQ_INIT:
+ case AUDIO_REQ_SET_DEFAULT_IN_INTERFACE:
+ if (AUDIO_Handle->microphone.supported == 1U)
{
- USBH_ErrLog("Control error: AUDIO: Device Set interface request failed");
- status = USBH_FAIL;
+ req_status = USBH_SetInterface(phost,
+ AUDIO_Handle->microphone.interface,
+ 0U);
+
+ if (req_status == USBH_OK)
+ {
+ AUDIO_Handle->req_state = AUDIO_REQ_SET_DEFAULT_OUT_INTERFACE;
+ }
+ else if (req_status == USBH_NOT_SUPPORTED)
+ {
+ USBH_ErrLog("Control error: AUDIO: Device Set interface request failed");
+ status = USBH_FAIL;
+ }
+ else
+ {
+ /* .. */
+ }
}
else
{
- /* .. */
- }
- }
- else
- {
- AUDIO_Handle->req_state = AUDIO_REQ_SET_DEFAULT_OUT_INTERFACE;
+ AUDIO_Handle->req_state = AUDIO_REQ_SET_DEFAULT_OUT_INTERFACE;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
- }
- break;
-
- case AUDIO_REQ_SET_DEFAULT_OUT_INTERFACE:
- if (AUDIO_Handle->headphone.supported == 1U)
- {
- req_status = USBH_SetInterface(phost,
- AUDIO_Handle->headphone.interface,
- 0U);
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ }
+ break;
- if (req_status == USBH_OK)
+ case AUDIO_REQ_SET_DEFAULT_OUT_INTERFACE:
+ if (AUDIO_Handle->headphone.supported == 1U)
{
- AUDIO_Handle->req_state = AUDIO_REQ_CS_REQUESTS;
- AUDIO_Handle->cs_req_state = AUDIO_REQ_GET_VOLUME;
+ req_status = USBH_SetInterface(phost,
+ AUDIO_Handle->headphone.interface,
+ 0U);
- AUDIO_Handle->temp_feature = AUDIO_Handle->headphone.asociated_feature;
- AUDIO_Handle->temp_channels = AUDIO_Handle->headphone.asociated_channels;
- }
- else if (req_status == USBH_NOT_SUPPORTED)
- {
- USBH_ErrLog("Control error: AUDIO: Device Set interface request failed");
- status = USBH_FAIL;
+ if (req_status == USBH_OK)
+ {
+ AUDIO_Handle->req_state = AUDIO_REQ_CS_REQUESTS;
+ AUDIO_Handle->cs_req_state = AUDIO_REQ_GET_VOLUME;
+
+ AUDIO_Handle->temp_feature = AUDIO_Handle->headphone.asociated_feature;
+ AUDIO_Handle->temp_channels = AUDIO_Handle->headphone.asociated_channels;
+ }
+ else if (req_status == USBH_NOT_SUPPORTED)
+ {
+ USBH_ErrLog("Control error: AUDIO: Device Set interface request failed");
+ status = USBH_FAIL;
+ }
+ else
+ {
+ /* .. */
+ }
}
else
{
- /* .. */
- }
- }
- else
- {
- AUDIO_Handle->req_state = AUDIO_REQ_CS_REQUESTS;
- AUDIO_Handle->cs_req_state = AUDIO_REQ_GET_VOLUME;
+ AUDIO_Handle->req_state = AUDIO_REQ_CS_REQUESTS;
+ AUDIO_Handle->cs_req_state = AUDIO_REQ_GET_VOLUME;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
- }
- break;
-
- case AUDIO_REQ_CS_REQUESTS:
- if (USBH_AUDIO_HandleCSRequest(phost) == USBH_OK)
- {
- AUDIO_Handle->req_state = AUDIO_REQ_SET_IN_INTERFACE;
- }
- break;
-
- case AUDIO_REQ_SET_IN_INTERFACE:
- if (AUDIO_Handle->microphone.supported == 1U)
- {
- req_status = USBH_SetInterface(phost,
- AUDIO_Handle->microphone.interface,
- AUDIO_Handle->microphone.AltSettings);
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ }
+ break;
- if (req_status == USBH_OK)
+ case AUDIO_REQ_CS_REQUESTS:
+ if (USBH_AUDIO_HandleCSRequest(phost) == USBH_OK)
{
- AUDIO_Handle->req_state = AUDIO_REQ_SET_OUT_INTERFACE;
+ AUDIO_Handle->req_state = AUDIO_REQ_SET_IN_INTERFACE;
}
- else if (req_status == USBH_NOT_SUPPORTED)
+ break;
+
+ case AUDIO_REQ_SET_IN_INTERFACE:
+ if (AUDIO_Handle->microphone.supported == 1U)
{
- USBH_ErrLog("Control error: AUDIO: Device Set interface request failed");
- status = USBH_FAIL;
+ req_status = USBH_SetInterface(phost,
+ AUDIO_Handle->microphone.interface,
+ AUDIO_Handle->microphone.AltSettings);
+
+ if (req_status == USBH_OK)
+ {
+ AUDIO_Handle->req_state = AUDIO_REQ_SET_OUT_INTERFACE;
+ }
+ else if (req_status == USBH_NOT_SUPPORTED)
+ {
+ USBH_ErrLog("Control error: AUDIO: Device Set interface request failed");
+ status = USBH_FAIL;
+ }
+ else
+ {
+ /* .. */
+ }
}
else
{
- /* .. */
- }
- }
- else
- {
- AUDIO_Handle->req_state = AUDIO_REQ_SET_OUT_INTERFACE;
+ AUDIO_Handle->req_state = AUDIO_REQ_SET_OUT_INTERFACE;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
- }
- break;
- case AUDIO_REQ_SET_OUT_INTERFACE:
- if (AUDIO_Handle->headphone.supported == 1U)
- {
- req_status = USBH_SetInterface(phost,
- AUDIO_Handle->headphone.interface,
- AUDIO_Handle->headphone.AltSettings);
-
- if (req_status == USBH_OK)
- {
- AUDIO_Handle->req_state = AUDIO_REQ_IDLE;
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
- else if (req_status == USBH_NOT_SUPPORTED)
+ break;
+ case AUDIO_REQ_SET_OUT_INTERFACE:
+ if (AUDIO_Handle->headphone.supported == 1U)
{
- USBH_ErrLog("Control error: AUDIO: Device Set interface request failed");
- status = USBH_FAIL;
+ req_status = USBH_SetInterface(phost,
+ AUDIO_Handle->headphone.interface,
+ AUDIO_Handle->headphone.AltSettings);
+
+ if (req_status == USBH_OK)
+ {
+ AUDIO_Handle->req_state = AUDIO_REQ_IDLE;
+ }
+ else if (req_status == USBH_NOT_SUPPORTED)
+ {
+ USBH_ErrLog("Control error: AUDIO: Device Set interface request failed");
+ status = USBH_FAIL;
+ }
+ else
+ {
+ /* .. */
+ }
}
else
{
- /* .. */
- }
- }
- else
- {
- AUDIO_Handle->req_state = AUDIO_REQ_IDLE;
+ AUDIO_Handle->req_state = AUDIO_REQ_IDLE;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
- }
- break;
- case AUDIO_REQ_IDLE:
- AUDIO_Handle->play_state = AUDIO_PLAYBACK_INIT;
- phost->pUser(phost, HOST_USER_CLASS_ACTIVE);
- status = USBH_OK;
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ }
+ break;
+ case AUDIO_REQ_IDLE:
+ AUDIO_Handle->play_state = AUDIO_PLAYBACK_INIT;
+ phost->pUser(phost, HOST_USER_CLASS_ACTIVE);
+ status = USBH_OK;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
- break;
-
- default:
- break;
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ break;
+
+ default:
+ break;
}
return status;
}
@@ -692,13 +663,8 @@ static USBH_StatusTypeDef USBH_AUDIO_HandleCSRequest(USBH_HandleTypeDef *phost)
AUDIO_Handle->cs_req_state = AUDIO_REQ_GET_VOLUME;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
return status;
@@ -717,12 +683,12 @@ static USBH_StatusTypeDef USBH_AUDIO_Process(USBH_HandleTypeDef *phost)
if (AUDIO_Handle->headphone.supported == 1U)
{
- USBH_AUDIO_OutputStream(phost);
+ (void)USBH_AUDIO_OutputStream(phost);
}
if (AUDIO_Handle->microphone.supported == 1U)
{
- USBH_AUDIO_InputStream(phost);
+ (void)USBH_AUDIO_InputStream(phost);
}
return status;
@@ -749,7 +715,7 @@ static USBH_StatusTypeDef USBH_AUDIO_SOFProcess(USBH_HandleTypeDef *phost)
static USBH_StatusTypeDef USBH_AUDIO_FindAudioStreamingIN(USBH_HandleTypeDef *phost)
{
uint8_t interface, alt_settings;
- USBH_StatusTypeDef status = USBH_FAIL ;
+ USBH_StatusTypeDef status = USBH_FAIL;
AUDIO_HandleTypeDef *AUDIO_Handle;
AUDIO_Handle = (AUDIO_HandleTypeDef *) phost->pActiveClass->pData;
@@ -761,7 +727,7 @@ static USBH_StatusTypeDef USBH_AUDIO_FindAudioStreamingIN(USBH_HandleTypeDef *ph
if ((phost->device.CfgDesc.Itf_Desc[interface].bInterfaceClass == AC_CLASS) &&
(phost->device.CfgDesc.Itf_Desc[interface].bInterfaceSubClass == USB_SUBCLASS_AUDIOSTREAMING))
{
- if ((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress & 0x80U) &&
+ if (((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress & 0x80U) != 0U) &&
(phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].wMaxPacketSize > 0U))
{
AUDIO_Handle->stream_in[alt_settings].Ep = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress;
@@ -791,7 +757,7 @@ static USBH_StatusTypeDef USBH_AUDIO_FindAudioStreamingIN(USBH_HandleTypeDef *ph
static USBH_StatusTypeDef USBH_AUDIO_FindAudioStreamingOUT(USBH_HandleTypeDef *phost)
{
uint8_t interface, alt_settings;
- USBH_StatusTypeDef status = USBH_FAIL ;
+ USBH_StatusTypeDef status = USBH_FAIL;
AUDIO_HandleTypeDef *AUDIO_Handle;
AUDIO_Handle = (AUDIO_HandleTypeDef *) phost->pActiveClass->pData;
@@ -914,9 +880,9 @@ static USBH_StatusTypeDef USBH_AUDIO_ParseCSDescriptors(USBH_HandleTypeDef *phos
else
{
- ParseCSDescriptors(&AUDIO_Handle->class_desc,
- phost->device.CfgDesc.Itf_Desc[itf_index].bInterfaceSubClass,
- (uint8_t *)pdesc);
+ (void)ParseCSDescriptors(&AUDIO_Handle->class_desc,
+ phost->device.CfgDesc.Itf_Desc[itf_index].bInterfaceSubClass,
+ (uint8_t *)pdesc);
}
}
break;
@@ -995,7 +961,7 @@ static USBH_StatusTypeDef ParseCSDescriptors(AUDIO_ClassSpecificDescTypedef *cla
/**
* @brief Link a Unit to next associated one
* @param phost: Host handle
- * @param UnitID: Unit identifer
+ * @param UnitID: Unit identifier
* @retval UnitID, Index and Type of the associated Unit
*/
static uint32_t USBH_AUDIO_FindLinkedUnit(USBH_HandleTypeDef *phost, uint8_t UnitID)
@@ -1024,7 +990,7 @@ static uint32_t USBH_AUDIO_FindLinkedUnit(USBH_HandleTypeDef *phost, uint8_t Uni
{
UnitID = AUDIO_Handle->class_desc.cs_desc.MixerUnitDesc[Index]->bUnitID;
- return ((UnitID << 16U) | (UAC_MIXER_UNIT << 8U) | Index);
+ return (uint32_t)((UnitID << 16U) | (UAC_MIXER_UNIT << 8U) | Index);
}
}
@@ -1035,18 +1001,18 @@ static uint32_t USBH_AUDIO_FindLinkedUnit(USBH_HandleTypeDef *phost, uint8_t Uni
{
UnitID = AUDIO_Handle->class_desc.cs_desc.SelectorUnitDesc[Index]->bUnitID;
- return ((UnitID << 16U) | (UAC_SELECTOR_UNIT << 8U) | Index);
+ return (uint32_t)((UnitID << 16U) | (UAC_SELECTOR_UNIT << 8U) | Index);
}
}
- /* Find OT Unit */
+ /* Find Output Terminal Unit */
for (Index = 0U; Index < AUDIO_Handle->class_desc.OutputTerminalNum; Index ++)
{
if (AUDIO_Handle->class_desc.cs_desc.OutputTerminalDesc[Index]->bSourceID == UnitID)
{
UnitID = AUDIO_Handle->class_desc.cs_desc.OutputTerminalDesc[Index]->bTerminalID;
- return ((UnitID << 16U) | (UAC_OUTPUT_TERMINAL << 8U) | Index);
+ return (uint32_t)((UnitID << 16U) | (UAC_OUTPUT_TERMINAL << 8U) | Index);
}
}
@@ -1072,7 +1038,7 @@ static USBH_StatusTypeDef USBH_AUDIO_BuildMicrophonePath(USBH_HandleTypeDef *pho
/*Find microphone IT*/
for (terminalIndex = 0U; terminalIndex < AUDIO_Handle->class_desc.InputTerminalNum; terminalIndex++)
{
- if (LE16(AUDIO_Handle->class_desc.cs_desc.InputTerminalDesc[terminalIndex]->wTerminalType) == 0x201)
+ if (LE16(AUDIO_Handle->class_desc.cs_desc.InputTerminalDesc[terminalIndex]->wTerminalType) == 0x201U)
{
UnitID = AUDIO_Handle->class_desc.cs_desc.InputTerminalDesc[terminalIndex]->bTerminalID;
AUDIO_Handle->microphone.asociated_channels = AUDIO_Handle->class_desc.cs_desc.InputTerminalDesc[terminalIndex]->bNrChannels;
@@ -1084,7 +1050,7 @@ static USBH_StatusTypeDef USBH_AUDIO_BuildMicrophonePath(USBH_HandleTypeDef *pho
{
value = USBH_AUDIO_FindLinkedUnit(phost, UnitID);
- if (!value)
+ if (value == 0U)
{
return USBH_FAIL;
}
@@ -1115,8 +1081,7 @@ static USBH_StatusTypeDef USBH_AUDIO_BuildMicrophonePath(USBH_HandleTypeDef *pho
ret = USBH_FAIL;
break;
}
- }
- while ((Type != UAC_OUTPUT_TERMINAL) && (value > 0U));
+ } while ((Type != UAC_OUTPUT_TERMINAL) && (value > 0U));
return ret;
}
@@ -1139,7 +1104,7 @@ static USBH_StatusTypeDef USBH_AUDIO_BuildHeadphonePath(USBH_HandleTypeDef *phos
/* Find association between audio streaming and microphone */
for (terminalIndex = 0U; terminalIndex < AUDIO_Handle->class_desc.InputTerminalNum; terminalIndex++)
{
- if (LE16(AUDIO_Handle->class_desc.cs_desc.InputTerminalDesc[terminalIndex]->wTerminalType) == 0x101)
+ if (LE16(AUDIO_Handle->class_desc.cs_desc.InputTerminalDesc[terminalIndex]->wTerminalType) == 0x101U)
{
UnitID = AUDIO_Handle->class_desc.cs_desc.InputTerminalDesc[terminalIndex]->bTerminalID;
AUDIO_Handle->headphone.asociated_channels = AUDIO_Handle->class_desc.cs_desc.InputTerminalDesc[terminalIndex]->bNrChannels;
@@ -1160,7 +1125,7 @@ static USBH_StatusTypeDef USBH_AUDIO_BuildHeadphonePath(USBH_HandleTypeDef *phos
{
value = USBH_AUDIO_FindLinkedUnit(phost, UnitID);
- if (!value)
+ if (value == 0U)
{
return USBH_FAIL;
}
@@ -1187,7 +1152,7 @@ static USBH_StatusTypeDef USBH_AUDIO_BuildHeadphonePath(USBH_HandleTypeDef *phos
AUDIO_Handle->headphone.asociated_terminal = Index;
if (Index < AUDIO_MAX_NUM_OUT_TERMINAL)
{
- if (LE16(AUDIO_Handle->class_desc.cs_desc.OutputTerminalDesc[Index]->wTerminalType) != 0x103)
+ if (LE16(AUDIO_Handle->class_desc.cs_desc.OutputTerminalDesc[Index]->wTerminalType) != 0x103U)
{
return USBH_OK;
}
@@ -1202,8 +1167,7 @@ static USBH_StatusTypeDef USBH_AUDIO_BuildHeadphonePath(USBH_HandleTypeDef *phos
ret = USBH_FAIL;
break;
}
- }
- while ((Type != UAC_OUTPUT_TERMINAL) && (value > 0U));
+ } while ((Type != UAC_OUTPUT_TERMINAL) && (value > 0U));
return ret;
}
@@ -1246,7 +1210,7 @@ static USBH_StatusTypeDef USBH_AC_SetCur(USBH_HandleTypeDef *phost,
case UAC_FEATURE_UNIT:
UnitID = AUDIO_Handle->class_desc.cs_desc.FeatureUnitDesc[feature]->bUnitID;
InterfaceNum = 0U; /*Always zero Control Interface */
- wIndex = (uint16_t)((uint32_t)UnitID << 8U) | (uint16_t)InterfaceNum ;
+ wIndex = (uint16_t)((uint32_t)UnitID << 8U) | (uint16_t)InterfaceNum;
/*holds the CS(control selector ) and CN (channel number)*/
wValue = (uint16_t)((uint32_t)controlSelector << 8U) | (uint16_t)channel;
wLength = length;
@@ -1383,7 +1347,7 @@ static USBH_StatusTypeDef USBH_AC_GetMax(USBH_HandleTypeDef *phost,
case UAC_FEATURE_UNIT:
UnitID = AUDIO_Handle->class_desc.cs_desc.FeatureUnitDesc[feature]->bUnitID;
InterfaceNum = 0U; /*Always zero Control Interface */
- wIndex = (uint16_t)((uint32_t)UnitID << 8U) | (uint16_t)InterfaceNum ;
+ wIndex = (uint16_t)((uint32_t)UnitID << 8U) | (uint16_t)InterfaceNum;
/*holds the CS(control selector ) and CN (channel number)*/
wValue = (uint16_t)((uint32_t)controlSelector << 8U) | (uint16_t)channel;
wLength = length;
@@ -1392,8 +1356,8 @@ static USBH_StatusTypeDef USBH_AC_GetMax(USBH_HandleTypeDef *phost,
case UAC_OUTPUT_TERMINAL:
UnitID = AUDIO_Handle->class_desc.cs_desc.OutputTerminalDesc[0]->bTerminalID;
InterfaceNum = 0U; /*Always zero Control Interface */
- wIndex = (uint16_t)((uint32_t)UnitID << 8U) | (uint16_t)InterfaceNum ;
- wValue = (COPY_PROTECT_CONTROL << 8U) ;
+ wIndex = (uint16_t)((uint32_t)UnitID << 8U) | (uint16_t)InterfaceNum;
+ wValue = (COPY_PROTECT_CONTROL << 8U);
wLength = 1U;
break;
@@ -1448,7 +1412,7 @@ static USBH_StatusTypeDef USBH_AC_GetRes(USBH_HandleTypeDef *phost,
UnitID = AUDIO_Handle->class_desc.cs_desc.InputTerminalDesc[0]->bTerminalID;
InterfaceNum = 0U; /*Always zero Control Interface */
wIndex = (uint16_t)((uint32_t)UnitID << 8U) | (uint16_t)InterfaceNum;
- wValue = (COPY_PROTECT_CONTROL << 8U) ;
+ wValue = (COPY_PROTECT_CONTROL << 8U);
AUDIO_Handle->mem[0] = 0x00U;
wLength = 1U;
@@ -1466,7 +1430,7 @@ static USBH_StatusTypeDef USBH_AC_GetRes(USBH_HandleTypeDef *phost,
UnitID = AUDIO_Handle->class_desc.cs_desc.OutputTerminalDesc[0]->bTerminalID;
InterfaceNum = 0U; /*Always zero Control Interface */
wIndex = (uint16_t)((uint32_t)UnitID << 8U) | (uint16_t)InterfaceNum;
- wValue = (COPY_PROTECT_CONTROL << 8U) ;
+ wValue = (COPY_PROTECT_CONTROL << 8U);
wLength = 1U;
break;
@@ -1580,7 +1544,7 @@ static USBH_StatusTypeDef USBH_AUDIO_SetEndpointControls(USBH_HandleTypeDef *pho
wValue = SAMPLING_FREQ_CONTROL << 8U;
wIndex = Ep;
- wLength = 3U; /*length of the frequency parameter*/
+ wLength = 3U; /* length of the frequency parameter */
phost->Control.setup.b.bmRequestType = USB_H2D | USB_REQ_RECIPIENT_ENDPOINT | \
USB_REQ_TYPE_CLASS;
@@ -1591,7 +1555,6 @@ static USBH_StatusTypeDef USBH_AUDIO_SetEndpointControls(USBH_HandleTypeDef *pho
phost->Control.setup.b.wLength.w = wLength;
return (USBH_CtlReq(phost, (uint8_t *)buff, wLength));
-
}
/**
@@ -1616,7 +1579,7 @@ static USBH_StatusTypeDef USBH_AUDIO_InputStream(USBH_HandleTypeDef *phost)
*/
static USBH_StatusTypeDef USBH_AUDIO_Control(USBH_HandleTypeDef *phost)
{
- USBH_StatusTypeDef status = USBH_BUSY ;
+ USBH_StatusTypeDef status = USBH_BUSY;
AUDIO_HandleTypeDef *AUDIO_Handle = (AUDIO_HandleTypeDef *) phost->pActiveClass->pData;
uint16_t attribute = 0U;
@@ -1626,15 +1589,15 @@ static USBH_StatusTypeDef USBH_AUDIO_Control(USBH_HandleTypeDef *phost)
if ((phost->Timer & 1U) == 0U)
{
AUDIO_Handle->control.timer = phost->Timer;
- USBH_InterruptReceiveData(phost,
- (uint8_t *)(void *)(AUDIO_Handle->mem),
- (uint8_t)AUDIO_Handle->control.EpSize,
- AUDIO_Handle->control.Pipe);
+ (void)USBH_InterruptReceiveData(phost,
+ (uint8_t *)(void *)(AUDIO_Handle->mem),
+ (uint8_t)AUDIO_Handle->control.EpSize,
+ AUDIO_Handle->control.Pipe);
AUDIO_Handle->temp_feature = AUDIO_Handle->headphone.asociated_feature;
AUDIO_Handle->temp_channels = AUDIO_Handle->headphone.asociated_channels;
- AUDIO_Handle->control_state = AUDIO_CONTROL_CHANGE ;
+ AUDIO_Handle->control_state = AUDIO_CONTROL_CHANGE;
}
break;
@@ -1652,10 +1615,10 @@ static USBH_StatusTypeDef USBH_AUDIO_Control(USBH_HandleTypeDef *phost)
{
AUDIO_Handle->control.timer = phost->Timer;
- USBH_InterruptReceiveData(phost,
- (uint8_t *)(void *)(AUDIO_Handle->mem),
- (uint8_t)AUDIO_Handle->control.EpSize,
- AUDIO_Handle->control.Pipe);
+ (void)USBH_InterruptReceiveData(phost,
+ (uint8_t *)(void *)(AUDIO_Handle->mem),
+ (uint8_t)AUDIO_Handle->control.EpSize,
+ AUDIO_Handle->control.Pipe);
}
break;
@@ -1691,7 +1654,7 @@ static USBH_StatusTypeDef USBH_AUDIO_Control(USBH_HandleTypeDef *phost)
*/
static USBH_StatusTypeDef USBH_AUDIO_OutputStream(USBH_HandleTypeDef *phost)
{
- USBH_StatusTypeDef status = USBH_BUSY ;
+ USBH_StatusTypeDef status = USBH_BUSY;
AUDIO_HandleTypeDef *AUDIO_Handle = (AUDIO_HandleTypeDef *) phost->pActiveClass->pData;
uint8_t *buff;
@@ -1710,13 +1673,8 @@ static USBH_StatusTypeDef USBH_AUDIO_OutputStream(USBH_HandleTypeDef *phost)
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case AUDIO_PLAYBACK_SET_EP_FREQ:
@@ -1744,17 +1702,12 @@ static USBH_StatusTypeDef USBH_AUDIO_OutputStream(USBH_HandleTypeDef *phost)
status = USBH_OK;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case AUDIO_PLAYBACK_PLAY:
- USBH_AUDIO_Transmit(phost);
+ (void)USBH_AUDIO_Transmit(phost);
status = USBH_OK;
break;
@@ -1772,7 +1725,7 @@ static USBH_StatusTypeDef USBH_AUDIO_OutputStream(USBH_HandleTypeDef *phost)
*/
static USBH_StatusTypeDef USBH_AUDIO_Transmit(USBH_HandleTypeDef *phost)
{
- USBH_StatusTypeDef status = USBH_BUSY ;
+ USBH_StatusTypeDef status = USBH_BUSY;
AUDIO_HandleTypeDef *AUDIO_Handle = (AUDIO_HandleTypeDef *) phost->pActiveClass->pData;
switch (AUDIO_Handle->processing_state)
@@ -1783,10 +1736,10 @@ static USBH_StatusTypeDef USBH_AUDIO_Transmit(USBH_HandleTypeDef *phost)
{
AUDIO_Handle->headphone.timer = phost->Timer;
AUDIO_Handle->processing_state = AUDIO_DATA_OUT;
- USBH_IsocSendData(phost,
- AUDIO_Handle->headphone.buf,
- (uint32_t)AUDIO_Handle->headphone.frame_length,
- AUDIO_Handle->headphone.Pipe);
+ (void)USBH_IsocSendData(phost,
+ AUDIO_Handle->headphone.buf,
+ (uint32_t)AUDIO_Handle->headphone.frame_length,
+ AUDIO_Handle->headphone.Pipe);
AUDIO_Handle->headphone.partial_ptr = AUDIO_Handle->headphone.frame_length;
AUDIO_Handle->headphone.global_ptr = AUDIO_Handle->headphone.frame_length;
@@ -1794,17 +1747,10 @@ static USBH_StatusTypeDef USBH_AUDIO_Transmit(USBH_HandleTypeDef *phost)
}
else
{
-
#if (USBH_USE_OS == 1U)
osDelay(1);
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
break;
@@ -1816,15 +1762,15 @@ static USBH_StatusTypeDef USBH_AUDIO_Transmit(USBH_HandleTypeDef *phost)
if (AUDIO_Handle->control.supported == 1U)
{
- USBH_AUDIO_Control(phost);
+ (void)USBH_AUDIO_Control(phost);
}
if (AUDIO_Handle->headphone.global_ptr <= AUDIO_Handle->headphone.total_length)
{
- USBH_IsocSendData(phost,
- AUDIO_Handle->headphone.cbuf,
- (uint32_t)AUDIO_Handle->headphone.frame_length,
- AUDIO_Handle->headphone.Pipe);
+ (void)USBH_IsocSendData(phost,
+ AUDIO_Handle->headphone.cbuf,
+ (uint32_t)AUDIO_Handle->headphone.frame_length,
+ AUDIO_Handle->headphone.Pipe);
AUDIO_Handle->headphone.cbuf += AUDIO_Handle->headphone.frame_length;
AUDIO_Handle->headphone.partial_ptr += AUDIO_Handle->headphone.frame_length;
@@ -1870,9 +1816,9 @@ USBH_StatusTypeDef USBH_AUDIO_SetFrequency(USBH_HandleTypeDef *phost,
if (phost->gState == HOST_CLASS)
{
AUDIO_Handle = (AUDIO_HandleTypeDef *) phost->pActiveClass->pData;
+
if (AUDIO_Handle->play_state == AUDIO_PLAYBACK_IDLE)
{
-
if (AUDIO_Handle->class_desc.as_desc[AUDIO_Handle->headphone.asociated_as].FormatTypeDesc->bSamFreqType == 0U)
{
freq_min = LE24(AUDIO_Handle->class_desc.as_desc[AUDIO_Handle->headphone.asociated_as].FormatTypeDesc->tSamFreq[0]);
@@ -1885,13 +1831,12 @@ USBH_StatusTypeDef USBH_AUDIO_SetFrequency(USBH_HandleTypeDef *phost,
}
else
{
-
num_supported_freq = (AUDIO_Handle->class_desc.as_desc[AUDIO_Handle->headphone.asociated_as].FormatTypeDesc->bLength - 8U) / 3U;
-
for (index = 0U; index < num_supported_freq; index++)
{
- if (SampleRate == LE24(AUDIO_Handle->class_desc.as_desc[AUDIO_Handle->headphone.asociated_as].FormatTypeDesc->tSamFreq[index]))
+ if (SampleRate == LE24(
+ AUDIO_Handle->class_desc.as_desc[AUDIO_Handle->headphone.asociated_as].FormatTypeDesc->tSamFreq[index]))
{
change_freq = TRUE;
break;
@@ -1905,7 +1850,10 @@ USBH_StatusTypeDef USBH_AUDIO_SetFrequency(USBH_HandleTypeDef *phost,
AUDIO_Handle->headphone.frame_length = (SampleRate * BitPerSample * NbrChannels) / 8000U;
AUDIO_Handle->play_state = AUDIO_PLAYBACK_SET_EP;
Status = USBH_OK;
-
+ }
+ else
+ {
+ USBH_ErrLog("Sample Rate not supported by the Audio Device");
}
}
}
@@ -1928,6 +1876,7 @@ USBH_StatusTypeDef USBH_AUDIO_Play(USBH_HandleTypeDef *phost, uint8_t *buf, uint
if (phost->gState == HOST_CLASS)
{
AUDIO_Handle = (AUDIO_HandleTypeDef *) phost->pActiveClass->pData;
+
if (AUDIO_Handle->play_state == AUDIO_PLAYBACK_IDLE)
{
AUDIO_Handle->headphone.buf = buf;
@@ -1938,13 +1887,8 @@ USBH_StatusTypeDef USBH_AUDIO_Play(USBH_HandleTypeDef *phost, uint8_t *buf, uint
Status = USBH_OK;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
}
return Status;
@@ -1977,6 +1921,7 @@ USBH_StatusTypeDef USBH_AUDIO_Suspend(USBH_HandleTypeDef *phost)
if (phost->gState == HOST_CLASS)
{
AUDIO_Handle = (AUDIO_HandleTypeDef *) phost->pActiveClass->pData;
+
if (AUDIO_Handle->play_state == AUDIO_PLAYBACK_PLAY)
{
AUDIO_Handle->control_state = AUDIO_CONTROL_IDLE;
@@ -2000,6 +1945,7 @@ USBH_StatusTypeDef USBH_AUDIO_Resume(USBH_HandleTypeDef *phost)
if (phost->gState == HOST_CLASS)
{
AUDIO_Handle = (AUDIO_HandleTypeDef *) phost->pActiveClass->pData;
+
if (AUDIO_Handle->play_state == AUDIO_PLAYBACK_IDLE)
{
AUDIO_Handle->control_state = AUDIO_CONTROL_INIT;
@@ -2021,6 +1967,7 @@ int32_t USBH_AUDIO_GetOutOffset(USBH_HandleTypeDef *phost)
if (phost->gState == HOST_CLASS)
{
AUDIO_Handle = (AUDIO_HandleTypeDef *) phost->pActiveClass->pData;
+
if (AUDIO_Handle->play_state == AUDIO_PLAYBACK_PLAY)
{
return (int32_t)AUDIO_Handle->headphone.partial_ptr;
@@ -2044,11 +1991,13 @@ USBH_StatusTypeDef USBH_AUDIO_ChangeOutBuffer(USBH_HandleTypeDef *phost, uint8_t
if (phost->gState == HOST_CLASS)
{
AUDIO_Handle = (AUDIO_HandleTypeDef *) phost->pActiveClass->pData;
+
if (AUDIO_Handle->play_state == AUDIO_PLAYBACK_PLAY)
{
if (AUDIO_Handle->headphone.buf <= buf)
{
AUDIO_Handle->headphone.cbuf = buf;
+
if (AUDIO_Handle->headphone.buf == buf)
{
AUDIO_Handle->headphone.partial_ptr = 0U;
@@ -2161,7 +2110,7 @@ USBH_StatusTypeDef USBH_AUDIO_SetVolume(USBH_HandleTypeDef *phost, AUDIO_VolumeC
*/
static USBH_StatusTypeDef AUDIO_SetVolume(USBH_HandleTypeDef *phost, uint8_t feature, uint8_t channel, uint16_t volume)
{
- USBH_StatusTypeDef status = USBH_BUSY ;
+ USBH_StatusTypeDef status = USBH_BUSY;
AUDIO_HandleTypeDef *AUDIO_Handle;
@@ -2191,31 +2140,30 @@ __weak void USBH_AUDIO_FrequencySet(USBH_HandleTypeDef *phost)
* @param phost: Selected device
* @retval None
*/
-__weak void USBH_AUDIO_BufferEmptyCallback(USBH_HandleTypeDef *phost)
+__weak void USBH_AUDIO_BufferEmptyCallback(USBH_HandleTypeDef *phost)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
}
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
-/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/CDC/Inc/usbh_cdc.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/CDC/Inc/usbh_cdc.h
index a23ea6ae63..3d47816948 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/CDC/Inc/usbh_cdc.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/CDC/Inc/usbh_cdc.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -30,21 +29,21 @@ extern "C" {
/** @addtogroup USBH_LIB
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_CLASS
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_CDC_CLASS
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_CDC_CORE
-* @brief This file is the Header file for usbh_core.c
-* @{
-*/
+ * @brief This file is the Header file for usbh_core.c
+ * @{
+ */
@@ -131,8 +130,8 @@ extern "C" {
*/
/** @defgroup USBH_CDC_CORE_Exported_Types
-* @{
-*/
+ * @{
+ */
/* States for CDC State Machine */
typedef enum
@@ -196,7 +195,7 @@ Offset| field | Size | Value | Description
| | | | release number in binary-coded
| | | | decimal
------|---------------------|-------|------------|------------------------------
-*/
+ */
typedef struct _FunctionalDescriptorHeader
{
uint8_t bLength; /*Size of this descriptor.*/
@@ -237,7 +236,7 @@ Offset| field | Size | Value | Description
4 | bDataInterface | 1 | Number | Interface number of Data Class interface
| | | | optionally used for call management.
------|---------------------|-------|------------|------------------------------
-*/
+ */
typedef struct _CallMgmtFunctionalDescriptor
{
uint8_t bLength; /*Size of this functional descriptor, in bytes.*/
@@ -275,7 +274,7 @@ Offset| field | Size | Value | Description
| | | | a Communication Class interface with the
| | | | SubClass code of Abstract Control Model.
------|---------------------|-------|------------|------------------------------
-*/
+ */
typedef struct _AbstractCntrlMgmtFunctionalDescriptor
{
uint8_t bLength; /*Size of this functional descriptor, in bytes.*/
@@ -298,7 +297,7 @@ Offset| field | Size | Value | Description
4 | bSlaveInterface0 | 1 | Number | nterface number of first slave or associated
| | | | interface in the union.
------|---------------------|-------|------------|------------------------------
-*/
+ */
typedef struct _UnionFunctionalDescriptor
{
uint8_t bLength; /*Size of this functional descriptor, in bytes*/
@@ -328,7 +327,7 @@ typedef struct
uint8_t buff[8];
uint16_t NotifEpSize;
}
-CDC_CommItfTypedef ;
+CDC_CommItfTypedef;
typedef struct
{
@@ -340,7 +339,7 @@ typedef struct
uint16_t OutEpSize;
uint16_t InEpSize;
}
-CDC_DataItfTypedef ;
+CDC_DataItfTypedef;
/* Structure for CDC process */
typedef struct _CDC_Process
@@ -362,37 +361,37 @@ typedef struct _CDC_Process
CDC_HandleTypeDef;
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CDC_CORE_Exported_Defines
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CDC_CORE_Exported_Macros
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CDC_CORE_Exported_Variables
-* @{
-*/
+ * @{
+ */
extern USBH_ClassTypeDef CDC_Class;
#define USBH_CDC_CLASS &CDC_Class
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CDC_CORE_Exported_FunctionsPrototype
-* @{
-*/
+ * @{
+ */
USBH_StatusTypeDef USBH_CDC_SetLineCoding(USBH_HandleTypeDef *phost,
CDC_LineCodingTypeDef *linecoding);
@@ -420,8 +419,8 @@ void USBH_CDC_TransmitCallback(USBH_HandleTypeDef *phost);
void USBH_CDC_ReceiveCallback(USBH_HandleTypeDef *phost);
/**
-* @}
-*/
+ * @}
+ */
#ifdef __cplusplus
}
@@ -430,19 +429,18 @@ void USBH_CDC_ReceiveCallback(USBH_HandleTypeDef *phost);
#endif /* __USBH_CDC_H */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/CDC/Src/usbh_cdc.c b/system/Middlewares/ST/STM32_USB_Host_Library/Class/CDC/Src/usbh_cdc.c
index e32d00de56..357381b5d5 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/CDC/Src/usbh_cdc.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/CDC/Src/usbh_cdc.c
@@ -4,6 +4,17 @@
* @author MCD Application Team
* @brief This file is the CDC Layer Handlers for USB Host CDC class.
*
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
* @verbatim
*
* ===================================================================
@@ -24,17 +35,6 @@
* @endverbatim
*
******************************************************************************
- * @attention
- *
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
- *
- ******************************************************************************
*/
/* BSPDependencies
@@ -49,58 +49,58 @@ EndBSPDependencies */
#include "usbh_cdc.h"
/** @addtogroup USBH_LIB
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_CLASS
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_CDC_CLASS
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_CDC_CORE
-* @brief This file includes CDC Layer Handlers for USB Host CDC class.
-* @{
-*/
+ * @brief This file includes CDC Layer Handlers for USB Host CDC class.
+ * @{
+ */
/** @defgroup USBH_CDC_CORE_Private_TypesDefinitions
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CDC_CORE_Private_Defines
-* @{
-*/
+ * @{
+ */
#define USBH_CDC_BUFFER_SIZE 1024
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CDC_CORE_Private_Macros
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CDC_CORE_Private_Variables
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CDC_CORE_Private_FunctionPrototypes
-* @{
-*/
+ * @{
+ */
static USBH_StatusTypeDef USBH_CDC_InterfaceInit(USBH_HandleTypeDef *phost);
@@ -134,13 +134,13 @@ USBH_ClassTypeDef CDC_Class =
NULL,
};
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CDC_CORE_Private_Functions
-* @{
-*/
+ * @{
+ */
/**
* @brief USBH_CDC_InterfaceInit
@@ -156,7 +156,7 @@ static USBH_StatusTypeDef USBH_CDC_InterfaceInit(USBH_HandleTypeDef *phost)
CDC_HandleTypeDef *CDC_Handle;
interface = USBH_FindInterface(phost, COMMUNICATION_INTERFACE_CLASS_CODE,
- ABSTRACT_CONTROL_MODEL, COMMON_AT_COMMAND);
+ ABSTRACT_CONTROL_MODEL, COMMON_AT_COMMAND);
if ((interface == 0xFFU) || (interface >= USBH_MAX_NUM_INTERFACES)) /* No Valid Interface */
{
@@ -181,10 +181,10 @@ static USBH_StatusTypeDef USBH_CDC_InterfaceInit(USBH_HandleTypeDef *phost)
}
/* Initialize cdc handler */
- USBH_memset(CDC_Handle, 0, sizeof(CDC_HandleTypeDef));
+ (void)USBH_memset(CDC_Handle, 0, sizeof(CDC_HandleTypeDef));
/*Collect the notification endpoint address and length*/
- if (phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress & 0x80U)
+ if ((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress & 0x80U) != 0U)
{
CDC_Handle->CommItf.NotifEp = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress;
CDC_Handle->CommItf.NotifEpSize = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].wMaxPacketSize;
@@ -194,14 +194,14 @@ static USBH_StatusTypeDef USBH_CDC_InterfaceInit(USBH_HandleTypeDef *phost)
CDC_Handle->CommItf.NotifPipe = USBH_AllocPipe(phost, CDC_Handle->CommItf.NotifEp);
/* Open pipe for Notification endpoint */
- USBH_OpenPipe(phost, CDC_Handle->CommItf.NotifPipe, CDC_Handle->CommItf.NotifEp,
- phost->device.address, phost->device.speed, USB_EP_TYPE_INTR,
- CDC_Handle->CommItf.NotifEpSize);
+ (void)USBH_OpenPipe(phost, CDC_Handle->CommItf.NotifPipe, CDC_Handle->CommItf.NotifEp,
+ phost->device.address, phost->device.speed, USB_EP_TYPE_INTR,
+ CDC_Handle->CommItf.NotifEpSize);
- USBH_LL_SetToggle(phost, CDC_Handle->CommItf.NotifPipe, 0U);
+ (void)USBH_LL_SetToggle(phost, CDC_Handle->CommItf.NotifPipe, 0U);
interface = USBH_FindInterface(phost, DATA_INTERFACE_CLASS_CODE,
- RESERVED, NO_CLASS_SPECIFIC_PROTOCOL_CODE);
+ RESERVED, NO_CLASS_SPECIFIC_PROTOCOL_CODE);
if ((interface == 0xFFU) || (interface >= USBH_MAX_NUM_INTERFACES)) /* No Valid Interface */
{
@@ -210,7 +210,7 @@ static USBH_StatusTypeDef USBH_CDC_InterfaceInit(USBH_HandleTypeDef *phost)
}
/*Collect the class specific endpoint address and length*/
- if (phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress & 0x80U)
+ if ((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress & 0x80U) != 0U)
{
CDC_Handle->DataItf.InEp = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress;
CDC_Handle->DataItf.InEpSize = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].wMaxPacketSize;
@@ -221,7 +221,7 @@ static USBH_StatusTypeDef USBH_CDC_InterfaceInit(USBH_HandleTypeDef *phost)
CDC_Handle->DataItf.OutEpSize = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].wMaxPacketSize;
}
- if (phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[1].bEndpointAddress & 0x80U)
+ if ((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[1].bEndpointAddress & 0x80U) != 0U)
{
CDC_Handle->DataItf.InEp = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[1].bEndpointAddress;
CDC_Handle->DataItf.InEpSize = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[1].wMaxPacketSize;
@@ -239,19 +239,19 @@ static USBH_StatusTypeDef USBH_CDC_InterfaceInit(USBH_HandleTypeDef *phost)
CDC_Handle->DataItf.InPipe = USBH_AllocPipe(phost, CDC_Handle->DataItf.InEp);
/* Open channel for OUT endpoint */
- USBH_OpenPipe(phost, CDC_Handle->DataItf.OutPipe, CDC_Handle->DataItf.OutEp,
- phost->device.address, phost->device.speed, USB_EP_TYPE_BULK,
- CDC_Handle->DataItf.OutEpSize);
+ (void)USBH_OpenPipe(phost, CDC_Handle->DataItf.OutPipe, CDC_Handle->DataItf.OutEp,
+ phost->device.address, phost->device.speed, USB_EP_TYPE_BULK,
+ CDC_Handle->DataItf.OutEpSize);
/* Open channel for IN endpoint */
- USBH_OpenPipe(phost, CDC_Handle->DataItf.InPipe, CDC_Handle->DataItf.InEp,
- phost->device.address, phost->device.speed, USB_EP_TYPE_BULK,
- CDC_Handle->DataItf.InEpSize);
+ (void)USBH_OpenPipe(phost, CDC_Handle->DataItf.InPipe, CDC_Handle->DataItf.InEp,
+ phost->device.address, phost->device.speed, USB_EP_TYPE_BULK,
+ CDC_Handle->DataItf.InEpSize);
CDC_Handle->state = CDC_IDLE_STATE;
- USBH_LL_SetToggle(phost, CDC_Handle->DataItf.OutPipe, 0U);
- USBH_LL_SetToggle(phost, CDC_Handle->DataItf.InPipe, 0U);
+ (void)USBH_LL_SetToggle(phost, CDC_Handle->DataItf.OutPipe, 0U);
+ (void)USBH_LL_SetToggle(phost, CDC_Handle->DataItf.InPipe, 0U);
return USBH_OK;
}
@@ -268,28 +268,28 @@ static USBH_StatusTypeDef USBH_CDC_InterfaceDeInit(USBH_HandleTypeDef *phost)
{
CDC_HandleTypeDef *CDC_Handle = (CDC_HandleTypeDef *) phost->pActiveClass->pData;
- if (CDC_Handle->CommItf.NotifPipe)
+ if ((CDC_Handle->CommItf.NotifPipe) != 0U)
{
- USBH_ClosePipe(phost, CDC_Handle->CommItf.NotifPipe);
- USBH_FreePipe(phost, CDC_Handle->CommItf.NotifPipe);
+ (void)USBH_ClosePipe(phost, CDC_Handle->CommItf.NotifPipe);
+ (void)USBH_FreePipe(phost, CDC_Handle->CommItf.NotifPipe);
CDC_Handle->CommItf.NotifPipe = 0U; /* Reset the Channel as Free */
}
- if (CDC_Handle->DataItf.InPipe)
+ if ((CDC_Handle->DataItf.InPipe) != 0U)
{
- USBH_ClosePipe(phost, CDC_Handle->DataItf.InPipe);
- USBH_FreePipe(phost, CDC_Handle->DataItf.InPipe);
+ (void)USBH_ClosePipe(phost, CDC_Handle->DataItf.InPipe);
+ (void)USBH_FreePipe(phost, CDC_Handle->DataItf.InPipe);
CDC_Handle->DataItf.InPipe = 0U; /* Reset the Channel as Free */
}
- if (CDC_Handle->DataItf.OutPipe)
+ if ((CDC_Handle->DataItf.OutPipe) != 0U)
{
- USBH_ClosePipe(phost, CDC_Handle->DataItf.OutPipe);
- USBH_FreePipe(phost, CDC_Handle->DataItf.OutPipe);
+ (void)USBH_ClosePipe(phost, CDC_Handle->DataItf.OutPipe);
+ (void)USBH_FreePipe(phost, CDC_Handle->DataItf.OutPipe);
CDC_Handle->DataItf.OutPipe = 0U; /* Reset the Channel as Free */
}
- if (phost->pActiveClass->pData)
+ if ((phost->pActiveClass->pData) != NULL)
{
USBH_free(phost->pActiveClass->pData);
phost->pActiveClass->pData = 0U;
@@ -434,7 +434,7 @@ static USBH_StatusTypeDef USBH_CDC_SOFProcess(USBH_HandleTypeDef *phost)
* @param phost: Host handle
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_CDC_Stop(USBH_HandleTypeDef *phost)
+USBH_StatusTypeDef USBH_CDC_Stop(USBH_HandleTypeDef *phost)
{
CDC_HandleTypeDef *CDC_Handle = (CDC_HandleTypeDef *) phost->pActiveClass->pData;
@@ -442,9 +442,9 @@ USBH_StatusTypeDef USBH_CDC_Stop(USBH_HandleTypeDef *phost)
{
CDC_Handle->state = CDC_IDLE_STATE;
- USBH_ClosePipe(phost, CDC_Handle->CommItf.NotifPipe);
- USBH_ClosePipe(phost, CDC_Handle->DataItf.InPipe);
- USBH_ClosePipe(phost, CDC_Handle->DataItf.OutPipe);
+ (void)USBH_ClosePipe(phost, CDC_Handle->CommItf.NotifPipe);
+ (void)USBH_ClosePipe(phost, CDC_Handle->DataItf.InPipe);
+ (void)USBH_ClosePipe(phost, CDC_Handle->DataItf.OutPipe);
}
return USBH_OK;
}
@@ -494,10 +494,10 @@ static USBH_StatusTypeDef SetLineCoding(USBH_HandleTypeDef *phost,
}
/**
-* @brief This function prepares the state before issuing the class specific commands
-* @param None
-* @retval None
-*/
+ * @brief This function prepares the state before issuing the class specific commands
+ * @param None
+ * @retval None
+ */
USBH_StatusTypeDef USBH_CDC_SetLineCoding(USBH_HandleTypeDef *phost,
CDC_LineCodingTypeDef *linecoding)
{
@@ -509,25 +509,20 @@ USBH_StatusTypeDef USBH_CDC_SetLineCoding(USBH_HandleTypeDef *phost,
CDC_Handle->pUserLineCoding = linecoding;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
return USBH_OK;
}
/**
-* @brief This function prepares the state before issuing the class specific commands
-* @param None
-* @retval None
-*/
-USBH_StatusTypeDef USBH_CDC_GetLineCoding(USBH_HandleTypeDef *phost,
- CDC_LineCodingTypeDef *linecoding)
+ * @brief This function prepares the state before issuing the class specific commands
+ * @param None
+ * @retval None
+ */
+USBH_StatusTypeDef USBH_CDC_GetLineCoding(USBH_HandleTypeDef *phost,
+ CDC_LineCodingTypeDef *linecoding)
{
CDC_HandleTypeDef *CDC_Handle = (CDC_HandleTypeDef *) phost->pActiveClass->pData;
@@ -569,7 +564,7 @@ uint16_t USBH_CDC_GetLastReceivedDataSize(USBH_HandleTypeDef *phost)
* @param None
* @retval None
*/
-USBH_StatusTypeDef USBH_CDC_Transmit(USBH_HandleTypeDef *phost, uint8_t *pbuff, uint32_t length)
+USBH_StatusTypeDef USBH_CDC_Transmit(USBH_HandleTypeDef *phost, uint8_t *pbuff, uint32_t length)
{
USBH_StatusTypeDef Status = USBH_BUSY;
CDC_HandleTypeDef *CDC_Handle = (CDC_HandleTypeDef *) phost->pActiveClass->pData;
@@ -583,24 +578,20 @@ USBH_StatusTypeDef USBH_CDC_Transmit(USBH_HandleTypeDef *phost, uint8_t *pbuff,
Status = USBH_OK;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
+
return Status;
}
/**
-* @brief This function prepares the state before issuing the class specific commands
-* @param None
-* @retval None
-*/
-USBH_StatusTypeDef USBH_CDC_Receive(USBH_HandleTypeDef *phost, uint8_t *pbuff, uint32_t length)
+ * @brief This function prepares the state before issuing the class specific commands
+ * @param None
+ * @retval None
+ */
+USBH_StatusTypeDef USBH_CDC_Receive(USBH_HandleTypeDef *phost, uint8_t *pbuff, uint32_t length)
{
USBH_StatusTypeDef Status = USBH_BUSY;
CDC_HandleTypeDef *CDC_Handle = (CDC_HandleTypeDef *) phost->pActiveClass->pData;
@@ -614,22 +605,17 @@ USBH_StatusTypeDef USBH_CDC_Receive(USBH_HandleTypeDef *phost, uint8_t *pbuff,
Status = USBH_OK;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
return Status;
}
/**
-* @brief The function is responsible for sending data to the device
-* @param pdev: Selected device
-* @retval None
-*/
+ * @brief The function is responsible for sending data to the device
+ * @param pdev: Selected device
+ * @retval None
+ */
static void CDC_ProcessTransmission(USBH_HandleTypeDef *phost)
{
CDC_HandleTypeDef *CDC_Handle = (CDC_HandleTypeDef *) phost->pActiveClass->pData;
@@ -640,19 +626,19 @@ static void CDC_ProcessTransmission(USBH_HandleTypeDef *phost)
case CDC_SEND_DATA:
if (CDC_Handle->TxDataLength > CDC_Handle->DataItf.OutEpSize)
{
- USBH_BulkSendData(phost,
- CDC_Handle->pTxData,
- CDC_Handle->DataItf.OutEpSize,
- CDC_Handle->DataItf.OutPipe,
- 1U);
+ (void)USBH_BulkSendData(phost,
+ CDC_Handle->pTxData,
+ CDC_Handle->DataItf.OutEpSize,
+ CDC_Handle->DataItf.OutPipe,
+ 1U);
}
else
{
- USBH_BulkSendData(phost,
- CDC_Handle->pTxData,
- (uint16_t)CDC_Handle->TxDataLength,
- CDC_Handle->DataItf.OutPipe,
- 1U);
+ (void)USBH_BulkSendData(phost,
+ CDC_Handle->pTxData,
+ (uint16_t)CDC_Handle->TxDataLength,
+ CDC_Handle->DataItf.OutPipe,
+ 1U);
}
CDC_Handle->data_tx_state = CDC_SEND_DATA_WAIT;
@@ -686,13 +672,8 @@ static void CDC_ProcessTransmission(USBH_HandleTypeDef *phost)
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -701,13 +682,8 @@ static void CDC_ProcessTransmission(USBH_HandleTypeDef *phost)
CDC_Handle->data_tx_state = CDC_SEND_DATA;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
}
break;
@@ -717,10 +693,10 @@ static void CDC_ProcessTransmission(USBH_HandleTypeDef *phost)
}
}
/**
-* @brief This function responsible for reception of data from the device
-* @param pdev: Selected device
-* @retval None
-*/
+ * @brief This function responsible for reception of data from the device
+ * @param pdev: Selected device
+ * @retval None
+ */
static void CDC_ProcessReception(USBH_HandleTypeDef *phost)
{
@@ -733,10 +709,14 @@ static void CDC_ProcessReception(USBH_HandleTypeDef *phost)
case CDC_RECEIVE_DATA:
- USBH_BulkReceiveData(phost,
- CDC_Handle->pRxData,
- CDC_Handle->DataItf.InEpSize,
- CDC_Handle->DataItf.InPipe);
+ (void)USBH_BulkReceiveData(phost,
+ CDC_Handle->pRxData,
+ CDC_Handle->DataItf.InEpSize,
+ CDC_Handle->DataItf.InPipe);
+
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ phost->NakTimer = phost->Timer;
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
CDC_Handle->data_rx_state = CDC_RECEIVE_DATA_WAIT;
@@ -751,9 +731,9 @@ static void CDC_ProcessReception(USBH_HandleTypeDef *phost)
{
length = USBH_LL_GetLastXferSize(phost, CDC_Handle->DataItf.InPipe);
- if (((CDC_Handle->RxDataLength - length) > 0U) && (length > CDC_Handle->DataItf.InEpSize))
+ if (((CDC_Handle->RxDataLength - length) > 0U) && (length == CDC_Handle->DataItf.InEpSize))
{
- CDC_Handle->RxDataLength -= length ;
+ CDC_Handle->RxDataLength -= length;
CDC_Handle->pRxData += length;
CDC_Handle->data_rx_state = CDC_RECEIVE_DATA;
}
@@ -764,13 +744,28 @@ static void CDC_ProcessReception(USBH_HandleTypeDef *phost)
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ }
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ else if (URB_Status == USBH_URB_NAK_WAIT)
+ {
+ CDC_Handle->data_rx_state = CDC_RECEIVE_DATA_WAIT;
+
+ if ((phost->Timer - phost->NakTimer) > phost->NakTimeout)
+ {
+ phost->NakTimer = phost->Timer;
+ USBH_ActivatePipe(phost, CDC_Handle->DataItf.InPipe);
+ }
+
+#if (USBH_USE_OS == 1U)
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ }
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
+ else
+ {
+ /* .. */
}
break;
@@ -780,10 +775,10 @@ static void CDC_ProcessReception(USBH_HandleTypeDef *phost)
}
/**
-* @brief The function informs user that data have been received
-* @param pdev: Selected device
-* @retval None
-*/
+ * @brief The function informs user that data have been received
+ * @param pdev: Selected device
+ * @retval None
+ */
__weak void USBH_CDC_TransmitCallback(USBH_HandleTypeDef *phost)
{
/* Prevent unused argument(s) compilation warning */
@@ -791,10 +786,10 @@ __weak void USBH_CDC_TransmitCallback(USBH_HandleTypeDef *phost)
}
/**
-* @brief The function informs user that data have been sent
-* @param pdev: Selected device
-* @retval None
-*/
+ * @brief The function informs user that data have been sent
+ * @param pdev: Selected device
+ * @retval None
+ */
__weak void USBH_CDC_ReceiveCallback(USBH_HandleTypeDef *phost)
{
/* Prevent unused argument(s) compilation warning */
@@ -802,10 +797,10 @@ __weak void USBH_CDC_ReceiveCallback(USBH_HandleTypeDef *phost)
}
/**
-* @brief The function informs user that Settings have been changed
-* @param pdev: Selected device
-* @retval None
-*/
+ * @brief The function informs user that Settings have been changed
+ * @param pdev: Selected device
+ * @retval None
+ */
__weak void USBH_CDC_LineCodingChanged(USBH_HandleTypeDef *phost)
{
/* Prevent unused argument(s) compilation warning */
@@ -813,25 +808,24 @@ __weak void USBH_CDC_LineCodingChanged(USBH_HandleTypeDef *phost)
}
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid.h
index 26b597ca34..be7996128d 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -102,26 +101,26 @@ extern "C" {
/* States for HID State Machine */
typedef enum
{
- HID_INIT = 0,
- HID_IDLE,
- HID_SEND_DATA,
- HID_BUSY,
- HID_GET_DATA,
- HID_SYNC,
- HID_POLL,
- HID_ERROR,
+ USBH_HID_INIT = 0,
+ USBH_HID_IDLE,
+ USBH_HID_SEND_DATA,
+ USBH_HID_BUSY,
+ USBH_HID_GET_DATA,
+ USBH_HID_SYNC,
+ USBH_HID_POLL,
+ USBH_HID_ERROR,
}
-HID_StateTypeDef;
+USBH_HID_StateTypeDef;
typedef enum
{
- HID_REQ_INIT = 0,
- HID_REQ_IDLE,
- HID_REQ_GET_REPORT_DESC,
- HID_REQ_GET_HID_DESC,
- HID_REQ_SET_IDLE,
- HID_REQ_SET_PROTOCOL,
- HID_REQ_SET_REPORT,
+ USBH_HID_REQ_INIT = 0,
+ USBH_HID_REQ_IDLE,
+ USBH_HID_REQ_GET_REPORT_DESC,
+ USBH_HID_REQ_GET_HID_DESC,
+ USBH_HID_REQ_SET_IDLE,
+ USBH_HID_REQ_SET_PROTOCOL,
+ USBH_HID_REQ_SET_REPORT,
}
HID_CtlStateTypeDef;
@@ -211,7 +210,7 @@ typedef struct _HID_Process
{
uint8_t OutPipe;
uint8_t InPipe;
- HID_StateTypeDef state;
+ USBH_HID_StateTypeDef state;
uint8_t OutEp;
uint8_t InEp;
HID_CtlStateTypeDef ctl_state;
@@ -340,5 +339,4 @@ uint16_t USBH_HID_FifoWrite(FIFO_TypeDef *f, void *buf, uint16_t nbytes);
/**
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_keybd.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_keybd.h
index 04726d7874..dc09fb6094 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_keybd.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_keybd.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -50,6 +49,10 @@ extern "C" {
/** @defgroup USBH_HID_KEYBD_Exported_Types
* @{
*/
+#ifndef USBH_HID_KEYBD_REPORT_SIZE
+#define USBH_HID_KEYBD_REPORT_SIZE 0x8U
+#endif /* USBH_HID_KEYBD_REPORT_SIZE */
+
#define KEY_NONE 0x00
#define KEY_ERRORROLLOVER 0x01
#define KEY_POSTFAIL 0x02
@@ -103,11 +106,11 @@ extern "C" {
#define KEY_NONUS_NUMBER_SIGN_TILDE 0x32
#define KEY_SEMICOLON_COLON 0x33
#define KEY_SINGLE_AND_DOUBLE_QUOTE 0x34
-#define KEY_GRAVE ACCENT AND TILDE 0x35
+#define KEY_GRAVE_ACCENT_AND_TILDE 0x35
#define KEY_COMMA_AND_LESS 0x36
#define KEY_DOT_GREATER 0x37
#define KEY_SLASH_QUESTION 0x38
-#define KEY_CAPS LOCK 0x39
+#define KEY_CAPS_LOCK 0x39
#define KEY_F1 0x3A
#define KEY_F2 0x3B
#define KEY_F3 0x3C
@@ -121,7 +124,7 @@ extern "C" {
#define KEY_F11 0x44
#define KEY_F12 0x45
#define KEY_PRINTSCREEN 0x46
-#define KEY_SCROLL LOCK 0x47
+#define KEY_SCROLL_LOCK 0x47
#define KEY_PAUSE 0x48
#define KEY_INSERT 0x49
#define KEY_HOME 0x4A
@@ -314,5 +317,4 @@ uint8_t USBH_HID_GetASCIICode(HID_KEYBD_Info_TypeDef *info);
/**
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_mouse.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_mouse.h
index d954f21957..87af136f22 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_mouse.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_mouse.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -52,9 +51,9 @@ extern "C" {
typedef struct _HID_MOUSE_Info
{
- uint8_t x;
- uint8_t y;
- uint8_t buttons[3];
+ uint8_t x;
+ uint8_t y;
+ uint8_t buttons[3];
}
HID_MOUSE_Info_TypeDef;
@@ -65,6 +64,9 @@ HID_MOUSE_Info_TypeDef;
/** @defgroup USBH_HID_MOUSE_Exported_Defines
* @{
*/
+#ifndef USBH_HID_MOUSE_REPORT_SIZE
+#define USBH_HID_MOUSE_REPORT_SIZE 0x8U
+#endif /* USBH_HID_MOUSE_REPORT_SIZE */
/**
* @}
*/
@@ -114,4 +116,4 @@ HID_MOUSE_Info_TypeDef *USBH_HID_GetMouseInfo(USBH_HandleTypeDef *phost);
/**
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_parser.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_parser.h
index 98bd335c0f..eae51c715c 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_parser.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_parser.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -95,4 +94,3 @@ uint32_t HID_WriteItem(HID_Report_ItemTypedef *ri, uint32_t value, uint8_t ndx);
/**
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_usage.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_usage.h
index 40cf670b7c..0905c610a5 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_usage.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Inc/usbh_hid_usage.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -190,4 +189,3 @@ extern "C" {
/**
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c
index c8aba02a3d..55de9ddcc9 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid.c
@@ -4,6 +4,17 @@
* @author MCD Application Team
* @brief This file is the HID Layer Handlers for USB Host HID class.
*
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
* @verbatim
*
* ===================================================================
@@ -18,17 +29,6 @@
* @endverbatim
*
******************************************************************************
- * @attention
- *
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
- *
- ******************************************************************************
*/
/* BSPDependencies
@@ -44,65 +44,65 @@ EndBSPDependencies */
/** @addtogroup USBH_LIB
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_CLASS
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_HID_CLASS
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_HID_CORE
-* @brief This file includes HID Layer Handlers for USB Host HID class.
-* @{
-*/
+ * @brief This file includes HID Layer Handlers for USB Host HID class.
+ * @{
+ */
/** @defgroup USBH_HID_CORE_Private_TypesDefinitions
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_HID_CORE_Private_Defines
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_HID_CORE_Private_Macros
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_HID_CORE_Private_Variables
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_HID_CORE_Private_FunctionPrototypes
-* @{
-*/
+ * @{
+ */
static USBH_StatusTypeDef USBH_HID_InterfaceInit(USBH_HandleTypeDef *phost);
static USBH_StatusTypeDef USBH_HID_InterfaceDeInit(USBH_HandleTypeDef *phost);
static USBH_StatusTypeDef USBH_HID_ClassRequest(USBH_HandleTypeDef *phost);
static USBH_StatusTypeDef USBH_HID_Process(USBH_HandleTypeDef *phost);
static USBH_StatusTypeDef USBH_HID_SOFProcess(USBH_HandleTypeDef *phost);
-static void USBH_HID_ParseHIDDesc(HID_DescTypeDef *desc, uint8_t *buf);
+static void USBH_HID_ParseHIDDesc(HID_DescTypeDef *desc, uint8_t *buf);
extern USBH_StatusTypeDef USBH_HID_MouseInit(USBH_HandleTypeDef *phost);
extern USBH_StatusTypeDef USBH_HID_KeybdInit(USBH_HandleTypeDef *phost);
@@ -119,13 +119,13 @@ USBH_ClassTypeDef HID_Class =
NULL,
};
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_HID_CORE_Private_Functions
-* @{
-*/
+ * @{
+ */
/**
@@ -138,6 +138,7 @@ static USBH_StatusTypeDef USBH_HID_InterfaceInit(USBH_HandleTypeDef *phost)
{
USBH_StatusTypeDef status;
HID_HandleTypeDef *HID_Handle;
+ uint16_t ep_mps;
uint8_t max_ep;
uint8_t num = 0U;
uint8_t interface;
@@ -167,9 +168,9 @@ static USBH_StatusTypeDef USBH_HID_InterfaceInit(USBH_HandleTypeDef *phost)
}
/* Initialize hid handler */
- USBH_memset(HID_Handle, 0, sizeof(HID_HandleTypeDef));
+ (void)USBH_memset(HID_Handle, 0, sizeof(HID_HandleTypeDef));
- HID_Handle->state = HID_ERROR;
+ HID_Handle->state = USBH_HID_ERROR;
/*Decode Bootclass Protocol: Mouse or Keyboard*/
if (phost->device.CfgDesc.Itf_Desc[interface].bInterfaceProtocol == HID_KEYBRD_BOOT_CODE)
@@ -188,48 +189,50 @@ static USBH_StatusTypeDef USBH_HID_InterfaceInit(USBH_HandleTypeDef *phost)
return USBH_FAIL;
}
- HID_Handle->state = HID_INIT;
- HID_Handle->ctl_state = HID_REQ_INIT;
+ HID_Handle->state = USBH_HID_INIT;
+ HID_Handle->ctl_state = USBH_HID_REQ_INIT;
HID_Handle->ep_addr = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress;
HID_Handle->length = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].wMaxPacketSize;
HID_Handle->poll = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bInterval;
- if (HID_Handle->poll < HID_MIN_POLL)
+ if (HID_Handle->poll < HID_MIN_POLL)
{
HID_Handle->poll = HID_MIN_POLL;
}
- /* Check fo available number of endpoints */
+ /* Check of available number of endpoints */
/* Find the number of EPs in the Interface Descriptor */
/* Choose the lower number in order not to overrun the buffer allocated */
max_ep = ((phost->device.CfgDesc.Itf_Desc[interface].bNumEndpoints <= USBH_MAX_NUM_ENDPOINTS) ?
- phost->device.CfgDesc.Itf_Desc[interface].bNumEndpoints : USBH_MAX_NUM_ENDPOINTS);
+ phost->device.CfgDesc.Itf_Desc[interface].bNumEndpoints : USBH_MAX_NUM_ENDPOINTS);
/* Decode endpoint IN and OUT address from interface descriptor */
for (num = 0U; num < max_ep; num++)
{
- if (phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[num].bEndpointAddress & 0x80U)
+ if ((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[num].bEndpointAddress & 0x80U) != 0U)
{
HID_Handle->InEp = (phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[num].bEndpointAddress);
HID_Handle->InPipe = USBH_AllocPipe(phost, HID_Handle->InEp);
+ ep_mps = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[num].wMaxPacketSize;
/* Open pipe for IN endpoint */
- USBH_OpenPipe(phost, HID_Handle->InPipe, HID_Handle->InEp, phost->device.address,
- phost->device.speed, USB_EP_TYPE_INTR, HID_Handle->length);
+ (void)USBH_OpenPipe(phost, HID_Handle->InPipe, HID_Handle->InEp, phost->device.address,
+ phost->device.speed, USB_EP_TYPE_INTR, ep_mps);
- USBH_LL_SetToggle(phost, HID_Handle->InPipe, 0U);
+ (void)USBH_LL_SetToggle(phost, HID_Handle->InPipe, 0U);
}
else
{
HID_Handle->OutEp = (phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[num].bEndpointAddress);
- HID_Handle->OutPipe = USBH_AllocPipe(phost, HID_Handle->OutEp);
+ HID_Handle->OutPipe = USBH_AllocPipe(phost, HID_Handle->OutEp);
+ ep_mps = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[num].wMaxPacketSize;
/* Open pipe for OUT endpoint */
- USBH_OpenPipe(phost, HID_Handle->OutPipe, HID_Handle->OutEp, phost->device.address,
- phost->device.speed, USB_EP_TYPE_INTR, HID_Handle->length);
+ (void)USBH_OpenPipe(phost, HID_Handle->OutPipe, HID_Handle->OutEp, phost->device.address,
+ phost->device.speed, USB_EP_TYPE_INTR, ep_mps);
- USBH_LL_SetToggle(phost, HID_Handle->OutPipe, 0U);
+ (void)USBH_LL_SetToggle(phost, HID_Handle->OutPipe, 0U);
}
}
@@ -248,19 +251,19 @@ static USBH_StatusTypeDef USBH_HID_InterfaceDeInit(USBH_HandleTypeDef *phost)
if (HID_Handle->InPipe != 0x00U)
{
- USBH_ClosePipe(phost, HID_Handle->InPipe);
- USBH_FreePipe(phost, HID_Handle->InPipe);
+ (void)USBH_ClosePipe(phost, HID_Handle->InPipe);
+ (void)USBH_FreePipe(phost, HID_Handle->InPipe);
HID_Handle->InPipe = 0U; /* Reset the pipe as Free */
}
if (HID_Handle->OutPipe != 0x00U)
{
- USBH_ClosePipe(phost, HID_Handle->OutPipe);
- USBH_FreePipe(phost, HID_Handle->OutPipe);
+ (void)USBH_ClosePipe(phost, HID_Handle->OutPipe);
+ (void)USBH_FreePipe(phost, HID_Handle->OutPipe);
HID_Handle->OutPipe = 0U; /* Reset the pipe as Free */
}
- if (phost->pActiveClass->pData)
+ if ((phost->pActiveClass->pData) != NULL)
{
USBH_free(phost->pActiveClass->pData);
phost->pActiveClass->pData = 0U;
@@ -286,78 +289,78 @@ static USBH_StatusTypeDef USBH_HID_ClassRequest(USBH_HandleTypeDef *phost)
/* Switch HID state machine */
switch (HID_Handle->ctl_state)
{
- case HID_REQ_INIT:
- case HID_REQ_GET_HID_DESC:
+ case USBH_HID_REQ_INIT:
+ case USBH_HID_REQ_GET_HID_DESC:
- USBH_HID_ParseHIDDesc(&HID_Handle->HID_Desc, phost->device.CfgDesc_Raw);
+ USBH_HID_ParseHIDDesc(&HID_Handle->HID_Desc, phost->device.CfgDesc_Raw);
- HID_Handle->ctl_state = HID_REQ_GET_REPORT_DESC;
+ HID_Handle->ctl_state = USBH_HID_REQ_GET_REPORT_DESC;
- break;
- case HID_REQ_GET_REPORT_DESC:
+ break;
+ case USBH_HID_REQ_GET_REPORT_DESC:
- /* Get Report Desc */
- classReqStatus = USBH_HID_GetHIDReportDescriptor(phost, HID_Handle->HID_Desc.wItemLength);
- if (classReqStatus == USBH_OK)
- {
- /* The descriptor is available in phost->device.Data */
- HID_Handle->ctl_state = HID_REQ_SET_IDLE;
- }
- else if (classReqStatus == USBH_NOT_SUPPORTED)
- {
- USBH_ErrLog("Control error: HID: Device Get Report Descriptor request failed");
- status = USBH_FAIL;
- }
- else
- {
- /* .. */
- }
+ /* Get Report Desc */
+ classReqStatus = USBH_HID_GetHIDReportDescriptor(phost, HID_Handle->HID_Desc.wItemLength);
+ if (classReqStatus == USBH_OK)
+ {
+ /* The descriptor is available in phost->device.Data */
+ HID_Handle->ctl_state = USBH_HID_REQ_SET_IDLE;
+ }
+ else if (classReqStatus == USBH_NOT_SUPPORTED)
+ {
+ USBH_ErrLog("Control error: HID: Device Get Report Descriptor request failed");
+ status = USBH_FAIL;
+ }
+ else
+ {
+ /* .. */
+ }
- break;
+ break;
- case HID_REQ_SET_IDLE:
+ case USBH_HID_REQ_SET_IDLE:
- classReqStatus = USBH_HID_SetIdle(phost, 0U, 0U);
+ classReqStatus = USBH_HID_SetIdle(phost, 0U, 0U);
- /* set Idle */
- if (classReqStatus == USBH_OK)
- {
- HID_Handle->ctl_state = HID_REQ_SET_PROTOCOL;
- }
- else
- {
- if (classReqStatus == USBH_NOT_SUPPORTED)
+ /* set Idle */
+ if (classReqStatus == USBH_OK)
{
- HID_Handle->ctl_state = HID_REQ_SET_PROTOCOL;
+ HID_Handle->ctl_state = USBH_HID_REQ_SET_PROTOCOL;
}
- }
- break;
+ else
+ {
+ if (classReqStatus == USBH_NOT_SUPPORTED)
+ {
+ HID_Handle->ctl_state = USBH_HID_REQ_SET_PROTOCOL;
+ }
+ }
+ break;
- case HID_REQ_SET_PROTOCOL:
- /* set protocol */
- classReqStatus = USBH_HID_SetProtocol(phost, 0U);
- if (classReqStatus == USBH_OK)
- {
- HID_Handle->ctl_state = HID_REQ_IDLE;
+ case USBH_HID_REQ_SET_PROTOCOL:
+ /* set protocol */
+ classReqStatus = USBH_HID_SetProtocol(phost, 0U);
+ if (classReqStatus == USBH_OK)
+ {
+ HID_Handle->ctl_state = USBH_HID_REQ_IDLE;
- /* all requests performed*/
- phost->pUser(phost, HOST_USER_CLASS_ACTIVE);
- status = USBH_OK;
- }
- else if (classReqStatus == USBH_NOT_SUPPORTED)
- {
- USBH_ErrLog("Control error: HID: Device Set protocol request failed");
- status = USBH_FAIL;
- }
- else
- {
- /* .. */
- }
- break;
+ /* all requests performed */
+ phost->pUser(phost, HOST_USER_CLASS_ACTIVE);
+ status = USBH_OK;
+ }
+ else if (classReqStatus == USBH_NOT_SUPPORTED)
+ {
+ USBH_ErrLog("Control error: HID: Device Set protocol request failed");
+ status = USBH_FAIL;
+ }
+ else
+ {
+ /* .. */
+ }
+ break;
- case HID_REQ_IDLE:
- default:
- break;
+ case USBH_HID_REQ_IDLE:
+ default:
+ break;
}
return status;
@@ -377,98 +380,89 @@ static USBH_StatusTypeDef USBH_HID_Process(USBH_HandleTypeDef *phost)
switch (HID_Handle->state)
{
- case HID_INIT:
- HID_Handle->Init(phost);
- HID_Handle->state = HID_IDLE;
+ case USBH_HID_INIT:
+ status = HID_Handle->Init(phost);
+
+ if (status == USBH_OK)
+ {
+ HID_Handle->state = USBH_HID_IDLE;
+ }
+ else
+ {
+ USBH_ErrLog("HID Class Init failed");
+ HID_Handle->state = USBH_HID_ERROR;
+ status = USBH_FAIL;
+ }
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
- case HID_IDLE:
+ case USBH_HID_IDLE:
status = USBH_HID_GetReport(phost, 0x01U, 0U, HID_Handle->pData, (uint8_t)HID_Handle->length);
+
if (status == USBH_OK)
{
- HID_Handle->state = HID_SYNC;
+ HID_Handle->state = USBH_HID_SYNC;
}
else if (status == USBH_BUSY)
{
- HID_Handle->state = HID_IDLE;
+ HID_Handle->state = USBH_HID_IDLE;
status = USBH_OK;
}
else if (status == USBH_NOT_SUPPORTED)
{
- HID_Handle->state = HID_SYNC;
+ HID_Handle->state = USBH_HID_SYNC;
status = USBH_OK;
}
else
{
- HID_Handle->state = HID_ERROR;
+ HID_Handle->state = USBH_HID_ERROR;
status = USBH_FAIL;
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
- case HID_SYNC:
+ case USBH_HID_SYNC:
/* Sync with start of Even Frame */
- if (phost->Timer & 1U)
+ if ((phost->Timer & 1U) != 0U)
{
- HID_Handle->state = HID_GET_DATA;
+ HID_Handle->state = USBH_HID_GET_DATA;
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
- case HID_GET_DATA:
- USBH_InterruptReceiveData(phost, HID_Handle->pData,
- (uint8_t)HID_Handle->length,
- HID_Handle->InPipe);
+ case USBH_HID_GET_DATA:
+ (void)USBH_InterruptReceiveData(phost, HID_Handle->pData,
+ (uint8_t)HID_Handle->length,
+ HID_Handle->InPipe);
- HID_Handle->state = HID_POLL;
+ HID_Handle->state = USBH_HID_POLL;
HID_Handle->timer = phost->Timer;
HID_Handle->DataReady = 0U;
break;
- case HID_POLL:
+ case USBH_HID_POLL:
if (USBH_LL_GetURBState(phost, HID_Handle->InPipe) == USBH_URB_DONE)
{
XferSize = USBH_LL_GetLastXferSize(phost, HID_Handle->InPipe);
- if ((HID_Handle->DataReady == 0U) && (XferSize != 0U))
+ if ((HID_Handle->DataReady == 0U) && (XferSize != 0U) && (HID_Handle->fifo.buf != NULL))
{
- USBH_HID_FifoWrite(&HID_Handle->fifo, HID_Handle->pData, HID_Handle->length);
+ (void)USBH_HID_FifoWrite(&HID_Handle->fifo, HID_Handle->pData, HID_Handle->length);
HID_Handle->DataReady = 1U;
USBH_HID_EventCallback(phost);
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
}
else
@@ -480,7 +474,7 @@ static USBH_StatusTypeDef USBH_HID_Process(USBH_HandleTypeDef *phost)
if (USBH_ClrFeature(phost, HID_Handle->ep_addr) == USBH_OK)
{
/* Change state to issue next IN token */
- HID_Handle->state = HID_GET_DATA;
+ HID_Handle->state = USBH_HID_GET_DATA;
}
}
}
@@ -503,27 +497,22 @@ static USBH_StatusTypeDef USBH_HID_SOFProcess(USBH_HandleTypeDef *phost)
{
HID_HandleTypeDef *HID_Handle = (HID_HandleTypeDef *) phost->pActiveClass->pData;
- if (HID_Handle->state == HID_POLL)
+ if (HID_Handle->state == USBH_HID_POLL)
{
if ((phost->Timer - HID_Handle->timer) >= HID_Handle->poll)
{
- HID_Handle->state = HID_GET_DATA;
+ HID_Handle->state = USBH_HID_GET_DATA;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
}
return USBH_OK;
}
/**
-* @brief USBH_Get_HID_ReportDescriptor
+ * @brief USBH_Get_HID_ReportDescriptor
* Issue report Descriptor command to the device. Once the response
* received, parse the report descriptor and update the status.
* @param phost: Host handle
@@ -536,6 +525,12 @@ USBH_StatusTypeDef USBH_HID_GetHIDReportDescriptor(USBH_HandleTypeDef *phost,
USBH_StatusTypeDef status;
+ if (length > sizeof(phost->device.Data))
+ {
+ USBH_ErrLog("Control error: Get HID Report Descriptor failed, data buffer size issue");
+ return USBH_NOT_SUPPORTED;
+ }
+
status = USBH_GetDescriptor(phost,
USB_REQ_RECIPIENT_INTERFACE | USB_REQ_TYPE_STANDARD,
USB_DESC_HID_REPORT,
@@ -565,6 +560,12 @@ USBH_StatusTypeDef USBH_HID_GetHIDDescriptor(USBH_HandleTypeDef *phost,
{
USBH_StatusTypeDef status;
+ if (length > sizeof(phost->device.Data))
+ {
+ USBH_ErrLog("Control error: Get HID Descriptor failed, data buffer size issue");
+ return USBH_NOT_SUPPORTED;
+ }
+
status = USBH_GetDescriptor(phost,
USB_REQ_RECIPIENT_INTERFACE | USB_REQ_TYPE_STANDARD,
USB_DESC_HID,
@@ -597,7 +598,7 @@ USBH_StatusTypeDef USBH_HID_SetIdle(USBH_HandleTypeDef *phost,
phost->Control.setup.b.wIndex.w = 0U;
phost->Control.setup.b.wLength.w = 0U;
- return USBH_CtlReq(phost, 0U, 0U);
+ return USBH_CtlReq(phost, NULL, 0U);
}
@@ -634,7 +635,7 @@ USBH_StatusTypeDef USBH_HID_SetReport(USBH_HandleTypeDef *phost,
/**
* @brief USBH_HID_GetReport
- * retreive Set Report
+ * retrieve Set Report
* @param phost: Host handle
* @param reportType : Report type to be sent
* @param reportId : Targeted report ID for Set Report request
@@ -676,7 +677,7 @@ USBH_StatusTypeDef USBH_HID_SetProtocol(USBH_HandleTypeDef *phost,
| USB_REQ_TYPE_CLASS;
phost->Control.setup.b.bRequest = USB_HID_SET_PROTOCOL;
- if (protocol)
+ if (protocol != 0U)
{
phost->Control.setup.b.wValue.w = 0U;
}
@@ -688,7 +689,7 @@ USBH_StatusTypeDef USBH_HID_SetProtocol(USBH_HandleTypeDef *phost,
phost->Control.setup.b.wIndex.w = 0U;
phost->Control.setup.b.wLength.w = 0U;
- return USBH_CtlReq(phost, 0U, 0U);
+ return USBH_CtlReq(phost, NULL, 0U);
}
@@ -699,7 +700,7 @@ USBH_StatusTypeDef USBH_HID_SetProtocol(USBH_HandleTypeDef *phost,
* @param buf: Buffer where the source descriptor is available
* @retval None
*/
-static void USBH_HID_ParseHIDDesc(HID_DescTypeDef *desc, uint8_t *buf)
+static void USBH_HID_ParseHIDDesc(HID_DescTypeDef *desc, uint8_t *buf)
{
USBH_DescHeader_t *pdesc = (USBH_DescHeader_t *)buf;
uint16_t CfgDescLen;
@@ -865,8 +866,8 @@ uint16_t USBH_HID_FifoWrite(FIFO_TypeDef *f, void *buf, uint16_t nbytes)
for (i = 0U; i < nbytes; i++)
{
- if ((f->head + 1U == f->tail) ||
- ((f->head + 1U == f->size) && (f->tail == 0U)))
+ if (((f->head + 1U) == f->tail) ||
+ (((f->head + 1U) == f->size) && (f->tail == 0U)))
{
f->lock = 0U;
return i;
@@ -890,35 +891,34 @@ uint16_t USBH_HID_FifoWrite(FIFO_TypeDef *f, void *buf, uint16_t nbytes)
}
/**
-* @brief The function is a callback about HID Data events
-* @param phost: Selected device
-* @retval None
-*/
+ * @brief The function is a callback about HID Data events
+ * @param phost: Selected device
+ * @retval None
+ */
__weak void USBH_HID_EventCallback(USBH_HandleTypeDef *phost)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
}
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_keybd.c b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_keybd.c
index f18b268267..731bdd846b 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_keybd.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_keybd.c
@@ -8,13 +8,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -31,36 +30,36 @@ EndBSPDependencies */
#include "usbh_hid_parser.h"
/** @addtogroup USBH_LIB
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_CLASS
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_HID_CLASS
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_HID_KEYBD
-* @brief This file includes HID Layer Handlers for USB Host HID class.
-* @{
-*/
+ * @brief This file includes HID Layer Handlers for USB Host HID class.
+ * @{
+ */
/** @defgroup USBH_HID_KEYBD_Private_TypesDefinitions
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_HID_KEYBD_Private_Defines
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
#ifndef AZERTY_KEYBOARD
#define QWERTY_KEYBOARD
#endif
@@ -75,31 +74,31 @@ EndBSPDependencies */
#define KBR_MAX_NBR_PRESSED 6
/** @defgroup USBH_HID_KEYBD_Private_Macros
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_HID_KEYBD_Private_FunctionPrototypes
-* @{
-*/
+ * @{
+ */
static USBH_StatusTypeDef USBH_HID_KeybdDecode(USBH_HandleTypeDef *phost);
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_HID_KEYBD_Private_Variables
-* @{
-*/
+ * @{
+ */
-HID_KEYBD_Info_TypeDef keybd_info;
-uint32_t keybd_rx_report_buf[2];
-uint32_t keybd_report_data[2];
+HID_KEYBD_Info_TypeDef keybd_info;
+uint8_t keybd_rx_report_buf[USBH_HID_KEYBD_REPORT_SIZE];
+uint8_t keybd_report_data[USBH_HID_KEYBD_REPORT_SIZE];
static const HID_Report_ItemTypedef imp_0_lctrl =
{
- (uint8_t *)(void *)keybd_report_data + 0, /*data*/
+ keybd_report_data, /*data*/
1, /*size*/
0, /*shift*/
0, /*count (only for array items)*/
@@ -112,7 +111,7 @@ static const HID_Report_ItemTypedef imp_0_lctrl =
};
static const HID_Report_ItemTypedef imp_0_lshift =
{
- (uint8_t *)(void *)keybd_report_data + 0, /*data*/
+ keybd_report_data, /*data*/
1, /*size*/
1, /*shift*/
0, /*count (only for array items)*/
@@ -125,7 +124,7 @@ static const HID_Report_ItemTypedef imp_0_lshift =
};
static const HID_Report_ItemTypedef imp_0_lalt =
{
- (uint8_t *)(void *)keybd_report_data + 0, /*data*/
+ keybd_report_data, /*data*/
1, /*size*/
2, /*shift*/
0, /*count (only for array items)*/
@@ -138,7 +137,7 @@ static const HID_Report_ItemTypedef imp_0_lalt =
};
static const HID_Report_ItemTypedef imp_0_lgui =
{
- (uint8_t *)(void *)keybd_report_data + 0, /*data*/
+ keybd_report_data, /*data*/
1, /*size*/
3, /*shift*/
0, /*count (only for array items)*/
@@ -151,7 +150,7 @@ static const HID_Report_ItemTypedef imp_0_lgui =
};
static const HID_Report_ItemTypedef imp_0_rctrl =
{
- (uint8_t *)(void *)keybd_report_data + 0, /*data*/
+ keybd_report_data, /*data*/
1, /*size*/
4, /*shift*/
0, /*count (only for array items)*/
@@ -164,7 +163,7 @@ static const HID_Report_ItemTypedef imp_0_rctrl =
};
static const HID_Report_ItemTypedef imp_0_rshift =
{
- (uint8_t *)(void *)keybd_report_data + 0, /*data*/
+ keybd_report_data, /*data*/
1, /*size*/
5, /*shift*/
0, /*count (only for array items)*/
@@ -177,7 +176,7 @@ static const HID_Report_ItemTypedef imp_0_rshift =
};
static const HID_Report_ItemTypedef imp_0_ralt =
{
- (uint8_t *)(void *)keybd_report_data + 0, /*data*/
+ keybd_report_data, /*data*/
1, /*size*/
6, /*shift*/
0, /*count (only for array items)*/
@@ -190,7 +189,7 @@ static const HID_Report_ItemTypedef imp_0_ralt =
};
static const HID_Report_ItemTypedef imp_0_rgui =
{
- (uint8_t *)(void *)keybd_report_data + 0, /*data*/
+ keybd_report_data, /*data*/
1, /*size*/
7, /*shift*/
0, /*count (only for array items)*/
@@ -204,7 +203,7 @@ static const HID_Report_ItemTypedef imp_0_rgui =
static const HID_Report_ItemTypedef imp_0_key_array =
{
- (uint8_t *)(void *)keybd_report_data + 2, /*data*/
+ keybd_report_data + 2U, /*data*/
8, /*size*/
0, /*shift*/
6, /*count (only for array items)*/
@@ -217,72 +216,154 @@ static const HID_Report_ItemTypedef imp_0_key_array =
};
#ifdef QWERTY_KEYBOARD
-static const uint8_t HID_KEYBRD_Key[] =
+static const uint8_t HID_KEYBRD_Key[] =
{
- '\0', '`', '1', '2', '3', '4', '5', '6',
- '7', '8', '9', '0', '-', '=', '\0', '\r',
- '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u',
- 'i', 'o', 'p', '[', ']', '\\',
- '\0', 'a', 's', 'd', 'f', 'g', 'h', 'j',
- 'k', 'l', ';', '\'', '\0', '\n',
- '\0', '\0', 'z', 'x', 'c', 'v', 'b', 'n',
- 'm', ',', '.', '/', '\0', '\0',
- '\0', '\0', '\0', ' ', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\r', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '7', '4', '1',
- '\0', '/', '8', '5', '2',
- '0', '*', '9', '6', '3',
- '.', '-', '+', '\0', '\n', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0'
+ /* 0 */ '\0', /* 1 */ '`', /* 2 */ '1', /* 3 */ '2',
+ /* 4 */ '3', /* 5 */ '4', /* 6 */ '5', /* 7 */ '6',
+ /* 8 */ '7', /* 9 */ '8', /* 10 */ '9', /* 11 */ '0',
+ /* 12 */ '-', /* 13 */ '=', /* 14 */ '\0', /* 15 */ '\b',
+ /* 16 */ '\t', /* 17 */ 'q', /* 18 */ 'w', /* 19 */ 'e',
+ /* 20 */ 'r', /* 21 */ 't', /* 22 */ 'y', /* 23 */ 'u',
+ /* 24 */ 'i', /* 25 */ 'o', /* 26 */ 'p', /* 27 */ '[',
+ /* 28 */ ']', /* 29 */ '\\', /* 30 */ '\0', /* 31 */ 'a',
+ /* 32 */ 's', /* 33 */ 'd', /* 34 */ 'f', /* 35 */ 'g',
+ /* 36 */ 'h', /* 37 */ 'j', /* 38 */ 'k', /* 39 */ 'l',
+ /* 40 */ ';', /* 41 */ '\'', /* 42 */ '\0', /* 43 */ '\n',
+ /* 44 */ '\0', /* 45 */ '\0', /* 46 */ 'z', /* 47 */ 'x',
+ /* 48 */ 'c', /* 49 */ 'v', /* 50 */ 'b', /* 51 */ 'n',
+ /* 52 */ 'm', /* 53 */ ',', /* 54 */ '.', /* 55 */ '/',
+ /* 56 */ '\0', /* 57 */ '\0', /* 58 */ '\0', /* 59 */ '\0',
+ /* 60 */ '\0', /* 61 */ ' ', /* 62 */ '\0', /* 63 */ '\0',
+ /* 64 */ '\0', /* 65 */ '\0', /* 66 */ '\0', /* 67 */ '\0',
+ /* 68 */ '\0', /* 69 */ '\0', /* 70 */ '\0', /* 71 */ '\0',
+ /* 72 */ '\0', /* 73 */ '\0', /* 74 */ '\0', /* 75 */ '\0',
+ /* 76 */ '\0', /* 77 */ '\0', /* 78 */ '\0', /* 79 */ '\0',
+ /* 80 */ '\r', /* 81 */ '\0', /* 82 */ '\0', /* 83 */ '\0',
+ /* 84 */ '\0', /* 85 */ '\0', /* 86 */ '\0', /* 87 */ '\0',
+ /* 88 */ '\0', /* 89 */ '\0', /* 90 */ '\0', /* 91 */ '7',
+ /* 92 */ '4', /* 93 */ '1', /* 94 */ '\0', /* 95 */ '/',
+ /* 96 */ '8', /* 97 */ '5', /* 98 */ '2', /* 99 */ '0',
+ /*100 */ '*', /*101 */ '9', /*102 */ '6', /*103 */ '3',
+ /*104 */ '.', /*105 */ '-', /*106 */ '+', /*107 */ '\0',
+ /*108 */ '\n', /*109 */ '\0', /*110 */ 0x1B, /*111 */ '\0',
+ /*112 */ '\0', /*113 */ '\0', /*114 */ '\0', /*115 */ '\0',
+ /*116 */ '\0', /*117 */ '\0', /*118 */ '\0', /*119 */ '\0',
+ /*120 */ '\0', /*121 */ '\0', /*122 */ '\0', /*123 */ '\0',
+ /*124 */ '\0', /*125 */ '\0', /*126 */ '\0', /*127 */ '\0',
+ /*128 */ '\0', /*129 */ '\0', /*130 */ '\0', /*131 */ '\0'
};
-static const uint8_t HID_KEYBRD_ShiftKey[] =
+static const uint8_t HID_KEYBRD_ShiftKey[] =
{
- '\0', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
- '_', '+', '\0', '\0', '\0', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U',
- 'I', 'O', 'P', '{', '}', '|', '\0', 'A', 'S', 'D', 'F', 'G',
- 'H', 'J', 'K', 'L', ':', '"', '\0', '\n', '\0', '\0', 'Z', 'X',
- 'C', 'V', 'B', 'N', 'M', '<', '>', '?', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'
+ /* 0 */ '\0', /* 1 */ '~', /* 2 */ '!', /* 3 */ '@',
+ /* 4 */ '#', /* 5 */ '$', /* 6 */ '%', /* 7 */ '^',
+ /* 8 */ '&', /* 9 */ '*', /* 10 */ '(', /* 11 */ ')',
+ /* 12 */ '_', /* 13 */ '+', /* 14 */ '\0', /* 15 */ '\b',
+ /* 16 */ '\0', /* 17 */ 'Q', /* 18 */ 'W', /* 19 */ 'E',
+ /* 20 */ 'R', /* 21 */ 'T', /* 22 */ 'Y', /* 23 */ 'U',
+ /* 24 */ 'I', /* 25 */ 'O', /* 26 */ 'P', /* 27 */ '{',
+ /* 28 */ '}', /* 29 */ '|', /* 30 */ '\0', /* 31 */ 'A',
+ /* 32 */ 'S', /* 33 */ 'D', /* 34 */ 'F', /* 35 */ 'G',
+ /* 36 */ 'H', /* 37 */ 'J', /* 38 */ 'K', /* 39 */ 'L',
+ /* 40 */ ':', /* 41 */ '"', /* 42 */ '\0', /* 43 */ '\n',
+ /* 44 */ '\0', /* 45 */ '\0', /* 46 */ 'Z', /* 47 */ 'X',
+ /* 48 */ 'C', /* 49 */ 'V', /* 50 */ 'B', /* 51 */ 'N',
+ /* 52 */ 'M', /* 53 */ '<', /* 54 */ '>', /* 55 */ '?',
+ /* 56 */ '\0', /* 57 */ '\0', /* 58 */ '\0', /* 59 */ '\0',
+ /* 60 */ '\0', /* 61 */ ' ', /* 62 */ '\0', /* 63 */ '\0',
+ /* 64 */ '\0', /* 65 */ '\0', /* 66 */ '\0', /* 67 */ '\0',
+ /* 68 */ '\0', /* 69 */ '\0', /* 70 */ '\0', /* 71 */ '\0',
+ /* 72 */ '\0', /* 73 */ '\0', /* 74 */ '\0', /* 75 */ '\0',
+ /* 76 */ '\0', /* 77 */ '\0', /* 78 */ '\0', /* 79 */ '\0',
+ /* 80 */ '\0', /* 81 */ '\0', /* 82 */ '\0', /* 83 */ '\0',
+ /* 84 */ '\0', /* 85 */ '\0', /* 86 */ '\0', /* 87 */ '\0',
+ /* 88 */ '\0', /* 89 */ '\0', /* 90 */ '\0', /* 91 */ '\0',
+ /* 92 */ '\0', /* 93 */ '\0', /* 94 */ '\0', /* 95 */ '/',
+ /* 96 */ '\0', /* 97 */ '\0', /* 98 */ '\0', /* 99 */ '\0',
+ /*100 */ '*', /*101 */ '\0', /*102 */ '\0', /*103 */ '\0',
+ /*104 */ '\0', /*105 */ '-', /*106 */ '+', /*107 */ '\0',
+ /*108 */ '\n', /*109 */ '\0', /*110 */ 0x1B, /*111 */ '\0',
+ /*112 */ '\0', /*113 */ '\0', /*114 */ '\0', /*115 */ '\0',
+ /*116 */ '\0', /*117 */ '\0', /*118 */ '\0', /*119 */ '\0',
+ /*120 */ '\0', /*121 */ '\0', /*122 */ '\0', /*123 */ '\0',
+ /*124 */ '\0', /*125 */ '\0', /*126 */ '\0', /*127 */ '\0',
+ /*128 */ '\0', /*129 */ '\0', /*130 */ '\0', /*131 */ '\0'
};
-#else
+#else /* AZERTY Keyboard defined */
-static const uint8_t HID_KEYBRD_Key[] =
+static const uint8_t HID_KEYBRD_Key[] =
{
- '\0', '`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
- '-', '=', '\0', '\r', '\t', 'a', 'z', 'e', 'r', 't', 'y', 'u',
- 'i', 'o', 'p', '[', ']', '\\', '\0', 'q', 's', 'd', 'f', 'g',
- 'h', 'j', 'k', 'l', 'm', '\0', '\0', '\n', '\0', '\0', 'w', 'x',
- 'c', 'v', 'b', 'n', ',', ';', ':', '!', '\0', '\0', '\0', '\0',
- '\0', ' ', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\r', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '7', '4', '1', '\0', '/',
- '8', '5', '2', '0', '*', '9', '6', '3', '.', '-', '+', '\0',
- '\n', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'
+ /* 0 */ '\0', /* 1 */ '�', /* 2 */ '&', /* 3 */ '�',
+ /* 4 */ '"', /* 5 */ '\'', /* 6 */ '(', /* 7 */ '-',
+ /* 8 */ '�', /* 9 */ '_', /* 10 */ '�', /* 11 */ '�',
+ /* 12 */ ')', /* 13 */ '=', /* 14 */ '\0', /* 15 */ '\b',
+ /* 16 */ '\t', /* 17 */ 'a', /* 18 */ 'z', /* 19 */ 'e',
+ /* 20 */ 'r', /* 21 */ 't', /* 22 */ 'y', /* 23 */ 'u',
+ /* 24 */ 'i', /* 25 */ 'o', /* 26 */ 'p', /* 27 */ '^',
+ /* 28 */ '$', /* 29 */ '\\', /* 30 */ '\0', /* 31 */ 'q',
+ /* 32 */ 's', /* 33 */ 'd', /* 34 */ 'f', /* 35 */ 'g',
+ /* 36 */ 'h', /* 37 */ 'j', /* 38 */ 'k', /* 39 */ 'l',
+ /* 40 */ 'm', /* 41 */ '�', /* 42 */ '*', /* 43 */ '\n',
+ /* 44 */ '\0', /* 45 */ '<', /* 46 */ 'w', /* 47 */ 'x',
+ /* 48 */ 'c', /* 49 */ 'v', /* 50 */ 'b', /* 51 */ 'n',
+ /* 52 */ ',', /* 53 */ ';', /* 54 */ ':', /* 55 */ '!',
+ /* 56 */ '\0', /* 57 */ '\0', /* 58 */ '\0', /* 59 */ '\0',
+ /* 60 */ '\0', /* 61 */ ' ', /* 62 */ '\0', /* 63 */ '\0',
+ /* 64 */ '\0', /* 65 */ '\0', /* 66 */ '\0', /* 67 */ '\0',
+ /* 68 */ '\0', /* 69 */ '\0', /* 70 */ '\0', /* 71 */ '\0',
+ /* 72 */ '\0', /* 73 */ '\0', /* 74 */ '\0', /* 75 */ '\0',
+ /* 76 */ '\0', /* 77 */ '\0', /* 78 */ '\0', /* 79 */ '\0',
+ /* 80 */ '\0', /* 81 */ '\0', /* 82 */ '\0', /* 83 */ '\0',
+ /* 84 */ '\0', /* 85 */ '\0', /* 86 */ '\0', /* 87 */ '\0',
+ /* 88 */ '\0', /* 89 */ '\0', /* 90 */ '\0', /* 91 */ '7',
+ /* 92 */ '4', /* 93 */ '1', /* 94 */ '\0', /* 95 */ '/',
+ /* 96 */ '8', /* 97 */ '5', /* 98 */ '2', /* 99 */ '0',
+ /*100 */ '*', /*101 */ '9', /*102 */ '6', /*103 */ '3',
+ /*104 */ '.', /*105 */ '-', /*106 */ '+', /*107 */ '\0',
+ /*108 */ '\n', /*109 */ '\0', /*110 */ 0x1B, /*111 */ '\0',
+ /*112 */ '\0', /*113 */ '\0', /*114 */ '\0', /*115 */ '\0',
+ /*116 */ '\0', /*117 */ '\0', /*118 */ '\0', /*119 */ '\0',
+ /*120 */ '\0', /*121 */ '\0', /*122 */ '\0', /*123 */ '\0',
+ /*124 */ '\0', /*125 */ '\0', /*126 */ '\0', /*127 */ '\0',
+ /*128 */ '\0', /*129 */ '\0', /*130 */ '\0', /*131 */ '\0'
};
-static const uint8_t HID_KEYBRD_ShiftKey[] =
+static const uint8_t HID_KEYBRD_ShiftKey[] =
{
- '\0', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_',
- '+', '\0', '\0', '\0', 'A', 'Z', 'E', 'R', 'T', 'Y', 'U', 'I', 'O',
- 'P', '{', '}', '*', '\0', 'Q', 'S', 'D', 'F', 'G', 'H', 'J', 'K',
- 'L', 'M', '%', '\0', '\n', '\0', '\0', 'W', 'X', 'C', 'V', 'B', 'N',
- '?', '.', '/', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'
+ /* 0 */ '\0', /* 1 */ '\0', /* 2 */ '1', /* 3 */ '2',
+ /* 4 */ '3', /* 5 */ '4', /* 6 */ '5', /* 7 */ '6',
+ /* 8 */ '7', /* 9 */ '8', /* 10 */ '9', /* 11 */ '0',
+ /* 12 */ '�', /* 13 */ '+', /* 14 */ '\0', /* 15 */ '\b',
+ /* 16 */ '\t', /* 17 */ 'A', /* 18 */ 'Z', /* 19 */ 'E',
+ /* 20 */ 'R', /* 21 */ 'T', /* 22 */ 'Y', /* 23 */ 'U',
+ /* 24 */ 'I', /* 25 */ 'O', /* 26 */ 'P', /* 27 */ '�',
+ /* 28 */ '�', /* 29 */ '�', /* 30 */ '\0', /* 31 */ 'Q',
+ /* 32 */ 'S', /* 33 */ 'D', /* 34 */ 'F', /* 35 */ 'G',
+ /* 36 */ 'H', /* 37 */ 'J', /* 38 */ 'K', /* 39 */ 'L',
+ /* 40 */ 'M', /* 41 */ '%', /* 42 */ '�', /* 43 */ '\n',
+ /* 44 */ '\0', /* 45 */ '>', /* 46 */ 'W', /* 47 */ 'X',
+ /* 48 */ 'C', /* 49 */ 'V', /* 50 */ 'B', /* 51 */ 'N',
+ /* 52 */ '?', /* 53 */ '.', /* 54 */ '/', /* 55 */ '�',
+ /* 56 */ '\0', /* 57 */ '\0', /* 58 */ '\0', /* 59 */ '\0',
+ /* 60 */ '\0', /* 61 */ ' ', /* 62 */ '\0', /* 63 */ '\0',
+ /* 64 */ '\0', /* 65 */ '\0', /* 66 */ '\0', /* 67 */ '\0',
+ /* 68 */ '\0', /* 69 */ '\0', /* 70 */ '\0', /* 71 */ '\0',
+ /* 72 */ '\0', /* 73 */ '\0', /* 74 */ '\0', /* 75 */ '\0',
+ /* 76 */ '\0', /* 77 */ '\0', /* 78 */ '\0', /* 79 */ '\0',
+ /* 80 */ '\0', /* 81 */ '\0', /* 82 */ '\0', /* 83 */ '\0',
+ /* 84 */ '\0', /* 85 */ '\0', /* 86 */ '\0', /* 87 */ '\0',
+ /* 88 */ '\0', /* 89 */ '\0', /* 90 */ '\0', /* 91 */ '7',
+ /* 92 */ '\0', /* 93 */ '\0', /* 94 */ '\0', /* 95 */ '/',
+ /* 96 */ '\0', /* 97 */ '\0', /* 98 */ '\0', /* 99 */ '\0',
+ /*100 */ '*', /*101 */ '\0', /*102 */ '\0', /*103 */ '\0',
+ /*104 */ '\0', /*105 */ '-', /*106 */ '+', /*107 */ '\0',
+ /*108 */ '\n', /*109 */ '\0', /*110 */ 0x1B, /*111 */ '\0',
+ /*112 */ '\0', /*113 */ '\0', /*114 */ '\0', /*115 */ '\0',
+ /*116 */ '\0', /*117 */ '\0', /*118 */ '\0', /*119 */ '\0',
+ /*120 */ '\0', /*121 */ '\0', /*122 */ '\0', /*123 */ '\0',
+ /*124 */ '\0', /*125 */ '\0', /*126 */ '\0', /*127 */ '\0',
+ /*128 */ '\0', /*129 */ '\0', /*130 */ '\0', /*131 */ '\0'
};
#endif
@@ -290,32 +371,32 @@ static const uint8_t HID_KEYBRD_Codes[] =
{
0, 0, 0, 0, 31, 50, 48, 33,
19, 34, 35, 36, 24, 37, 38, 39, /* 0x00 - 0x0F */
- 52, 51, 25, 26, 17, 20, 32, 21,
+ 52, 51, 25, 26, 17, 20, 32, 21,
23, 49, 18, 47, 22, 46, 2, 3, /* 0x10 - 0x1F */
- 4, 5, 6, 7, 8, 9, 10, 11,
+ 4, 5, 6, 7, 8, 9, 10, 11,
43, 110, 15, 16, 61, 12, 13, 27, /* 0x20 - 0x2F */
28, 29, 42, 40, 41, 1, 53, 54,
55, 30, 112, 113, 114, 115, 116, 117, /* 0x30 - 0x3F */
- 118, 119, 120, 121, 122, 123, 124, 125,
- 126, 75, 80, 85, 76, 81, 86, 89, /* 0x40 - 0x4F */
+ 118, 119, 120, 121, 122, 123, 124, 125,
+ 126, 75, 80, 85, 76, 81, 86, 89, /* 0x40 - 0x4F */
79, 84, 83, 90, 95, 100, 105, 106,
- 108, 93, 98, 103, 92, 97, 102, 91, /* 0x50 - 0x5F */
+ 108, 93, 98, 103, 92, 97, 102, 91, /* 0x50 - 0x5F */
96, 101, 99, 104, 45, 129, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x6F */
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x7F */
- 0, 0, 0, 0, 0, 107, 0, 56,
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8F */
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9F */
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0xA0 - 0xAF */
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0xB0 - 0xBF */
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0xC0 - 0xCF */
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0xD0 - 0xDF */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x6F */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x7F */
+ 0, 0, 0, 0, 0, 107, 0, 56,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8F */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9F */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xA0 - 0xAF */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xB0 - 0xBF */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xC0 - 0xCF */
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xD0 - 0xDF */
58, 44, 60, 127, 64, 57, 62, 128 /* 0xE0 - 0xE7 */
};
@@ -330,13 +411,16 @@ USBH_StatusTypeDef USBH_HID_KeybdInit(USBH_HandleTypeDef *phost)
uint32_t x;
HID_HandleTypeDef *HID_Handle = (HID_HandleTypeDef *) phost->pActiveClass->pData;
- keybd_info.lctrl = keybd_info.lshift = 0U;
- keybd_info.lalt = keybd_info.lgui = 0U;
- keybd_info.rctrl = keybd_info.rshift = 0U;
- keybd_info.ralt = keybd_info.rgui = 0U;
+ keybd_info.lctrl = 0U;
+ keybd_info.lshift = 0U;
+ keybd_info.lalt = 0U;
+ keybd_info.lgui = 0U;
+ keybd_info.rctrl = 0U;
+ keybd_info.rshift = 0U;
+ keybd_info.ralt = 0U;
+ keybd_info.rgui = 0U;
-
- for (x = 0U; x < (sizeof(keybd_report_data) / sizeof(uint32_t)); x++)
+ for (x = 0U; x < sizeof(keybd_report_data); x++)
{
keybd_report_data[x] = 0U;
keybd_rx_report_buf[x] = 0U;
@@ -344,10 +428,19 @@ USBH_StatusTypeDef USBH_HID_KeybdInit(USBH_HandleTypeDef *phost)
if (HID_Handle->length > (sizeof(keybd_report_data)))
{
- HID_Handle->length = (sizeof(keybd_report_data));
+ HID_Handle->length = (uint16_t)(sizeof(keybd_report_data));
+ }
+
+ HID_Handle->pData = keybd_rx_report_buf;
+
+ if ((HID_QUEUE_SIZE * sizeof(keybd_report_data)) > sizeof(phost->device.Data))
+ {
+ return USBH_FAIL;
+ }
+ else
+ {
+ USBH_HID_FifoInit(&HID_Handle->fifo, phost->device.Data, (uint16_t)(HID_QUEUE_SIZE * sizeof(keybd_report_data)));
}
- HID_Handle->pData = (uint8_t *)(void *)keybd_rx_report_buf;
- USBH_HID_FifoInit(&HID_Handle->fifo, phost->device.Data, HID_QUEUE_SIZE * sizeof(keybd_report_data));
return USBH_OK;
}
@@ -381,10 +474,12 @@ static USBH_StatusTypeDef USBH_HID_KeybdDecode(USBH_HandleTypeDef *phost)
uint8_t x;
HID_HandleTypeDef *HID_Handle = (HID_HandleTypeDef *) phost->pActiveClass->pData;
- if (HID_Handle->length == 0U)
+
+ if ((HID_Handle->length == 0U) || (HID_Handle->fifo.buf == NULL))
{
return USBH_FAIL;
}
+
/*Fill report */
if (USBH_HID_FifoRead(&HID_Handle->fifo, &keybd_report_data, HID_Handle->length) == HID_Handle->length)
{
@@ -416,16 +511,16 @@ static USBH_StatusTypeDef USBH_HID_KeybdDecode(USBH_HandleTypeDef *phost)
*/
uint8_t USBH_HID_GetASCIICode(HID_KEYBD_Info_TypeDef *info)
{
- uint8_t output;
- if ((info->lshift == 1U) || (info->rshift))
+ uint8_t output;
+
+ if ((info->lshift != 0U) || (info->rshift != 0U))
{
- output = HID_KEYBRD_ShiftKey[HID_KEYBRD_Codes[info->keys[0]]];
+ output = HID_KEYBRD_ShiftKey[HID_KEYBRD_Codes[info->keys[0]]];
}
else
{
- output = HID_KEYBRD_Key[HID_KEYBRD_Codes[info->keys[0]]];
+ output = HID_KEYBRD_Key[HID_KEYBRD_Codes[info->keys[0]]];
}
return output;
}
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_mouse.c b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_mouse.c
index 0d375df662..4c4d290466 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_mouse.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_mouse.c
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -82,15 +81,15 @@ static USBH_StatusTypeDef USBH_HID_MouseDecode(USBH_HandleTypeDef *phost);
/** @defgroup USBH_HID_MOUSE_Private_Variables
* @{
*/
-HID_MOUSE_Info_TypeDef mouse_info;
-uint32_t mouse_report_data[2];
-uint32_t mouse_rx_report_buf[2];
+HID_MOUSE_Info_TypeDef mouse_info;
+uint8_t mouse_report_data[USBH_HID_MOUSE_REPORT_SIZE];
+uint8_t mouse_rx_report_buf[USBH_HID_MOUSE_REPORT_SIZE];
/* Structures defining how to access items in a HID mouse report */
/* Access button 1 state. */
static const HID_Report_ItemTypedef prop_b1 =
{
- (uint8_t *)(void *)mouse_report_data + 0, /*data*/
+ mouse_report_data, /*data*/
1, /*size*/
0, /*shift*/
0, /*count (only for array items)*/
@@ -105,7 +104,7 @@ static const HID_Report_ItemTypedef prop_b1 =
/* Access button 2 state. */
static const HID_Report_ItemTypedef prop_b2 =
{
- (uint8_t *)(void *)mouse_report_data + 0, /*data*/
+ mouse_report_data, /*data*/
1, /*size*/
1, /*shift*/
0, /*count (only for array items)*/
@@ -120,7 +119,7 @@ static const HID_Report_ItemTypedef prop_b2 =
/* Access button 3 state. */
static const HID_Report_ItemTypedef prop_b3 =
{
- (uint8_t *)(void *)mouse_report_data + 0, /*data*/
+ mouse_report_data, /*data*/
1, /*size*/
2, /*shift*/
0, /*count (only for array items)*/
@@ -135,7 +134,7 @@ static const HID_Report_ItemTypedef prop_b3 =
/* Access x coordinate change. */
static const HID_Report_ItemTypedef prop_x =
{
- (uint8_t *)(void *)mouse_report_data + 1, /*data*/
+ mouse_report_data + 1U, /*data*/
8, /*size*/
0, /*shift*/
0, /*count (only for array items)*/
@@ -150,7 +149,7 @@ static const HID_Report_ItemTypedef prop_x =
/* Access y coordinate change. */
static const HID_Report_ItemTypedef prop_y =
{
- (uint8_t *)(void *)mouse_report_data + 2, /*data*/
+ mouse_report_data + 2U, /*data*/
8, /*size*/
0, /*shift*/
0, /*count (only for array items)*/
@@ -189,7 +188,7 @@ USBH_StatusTypeDef USBH_HID_MouseInit(USBH_HandleTypeDef *phost)
mouse_info.buttons[1] = 0U;
mouse_info.buttons[2] = 0U;
- for (i = 0U; i < (sizeof(mouse_report_data) / sizeof(uint32_t)); i++)
+ for (i = 0U; i < sizeof(mouse_report_data); i++)
{
mouse_report_data[i] = 0U;
mouse_rx_report_buf[i] = 0U;
@@ -197,10 +196,18 @@ USBH_StatusTypeDef USBH_HID_MouseInit(USBH_HandleTypeDef *phost)
if (HID_Handle->length > sizeof(mouse_report_data))
{
- HID_Handle->length = sizeof(mouse_report_data);
+ HID_Handle->length = (uint16_t)sizeof(mouse_report_data);
+ }
+ HID_Handle->pData = mouse_rx_report_buf;
+
+ if ((HID_QUEUE_SIZE * sizeof(mouse_report_data)) > sizeof(phost->device.Data))
+ {
+ return USBH_FAIL;
+ }
+ else
+ {
+ USBH_HID_FifoInit(&HID_Handle->fifo, phost->device.Data, (uint16_t)(HID_QUEUE_SIZE * sizeof(mouse_report_data)));
}
- HID_Handle->pData = (uint8_t *)(void *)mouse_rx_report_buf;
- USBH_HID_FifoInit(&HID_Handle->fifo, phost->device.Data, HID_QUEUE_SIZE * sizeof(mouse_report_data));
return USBH_OK;
}
@@ -233,12 +240,12 @@ static USBH_StatusTypeDef USBH_HID_MouseDecode(USBH_HandleTypeDef *phost)
{
HID_HandleTypeDef *HID_Handle = (HID_HandleTypeDef *) phost->pActiveClass->pData;
- if (HID_Handle->length == 0U)
+ if ((HID_Handle->length == 0U) || (HID_Handle->fifo.buf == NULL))
{
return USBH_FAIL;
}
/*Fill report */
- if (USBH_HID_FifoRead(&HID_Handle->fifo, &mouse_report_data, HID_Handle->length) == HID_Handle->length)
+ if (USBH_HID_FifoRead(&HID_Handle->fifo, &mouse_report_data, HID_Handle->length) == HID_Handle->length)
{
/*Decode report */
mouse_info.x = (uint8_t)HID_ReadItem((HID_Report_ItemTypedef *) &prop_x, 0U);
@@ -273,4 +280,3 @@ static USBH_StatusTypeDef USBH_HID_MouseDecode(USBH_HandleTypeDef *phost)
/**
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_parser.c b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_parser.c
index d6d497e16d..8a829e99f2 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_parser.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/HID/Src/usbh_hid_parser.c
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -95,7 +94,7 @@ EndBSPDependencies */
* The function read a report item.
* @param ri: report item
* @param ndx: report index
-* @retval status (0 : fail / otherwise: item value)
+ * @retval status (0 : fail / otherwise: item value)
*/
uint32_t HID_ReadItem(HID_Report_ItemTypedef *ri, uint8_t ndx)
{
@@ -107,7 +106,7 @@ uint32_t HID_ReadItem(HID_Report_ItemTypedef *ri, uint8_t ndx)
/* get the logical value of the item */
- /* if this is an array, wee may need to offset ri->data.*/
+ /* if this is an array, we may need to offset ri->data.*/
if (ri->count > 0U)
{
/* If app tries to read outside of the array. */
@@ -124,20 +123,20 @@ uint32_t HID_ReadItem(HID_Report_ItemTypedef *ri, uint8_t ndx)
shift = (uint8_t)(bofs % 8U);
}
/* read data bytes in little endian order */
- for (x = 0U; x < ((ri->size & 0x7U) ? (ri->size / 8U) + 1U : (ri->size / 8U)); x++)
+ for (x = 0U; x < (((ri->size & 0x7U) != 0U) ? ((ri->size / 8U) + 1U) : (ri->size / 8U)); x++)
{
val = (uint32_t)((uint32_t)(*data) << (x * 8U));
}
- val = (val >> shift) & ((1U << ri->size) - 1U);
+ val = (val >> shift) & (((uint32_t)1U << ri->size) - 1U);
- if (val < ri->logical_min || val > ri->logical_max)
+ if ((val < ri->logical_min) || (val > ri->logical_max))
{
return (0U);
}
/* convert logical value to physical value */
/* See if the number is negative or not. */
- if ((ri->sign) && (val & (1U << (ri->size - 1U))))
+ if ((ri->sign != 0U) && ((val & ((uint32_t)1U << (ri->size - 1U))) != 0U))
{
/* yes, so sign extend value to 32 bits. */
uint32_t vs = (uint32_t)((0xffffffffU & ~((1U << (ri->size)) - 1U)) | val);
@@ -173,12 +172,12 @@ uint32_t HID_WriteItem(HID_Report_ItemTypedef *ri, uint32_t value, uint8_t ndx)
uint8_t *data = ri->data;
uint8_t shift = ri->shift;
- if (value < ri->physical_min || value > ri->physical_max)
+ if ((value < ri->physical_min) || (value > ri->physical_max))
{
return (1U);
}
- /* if this is an array, wee may need to offset ri->data.*/
+ /* if this is an array, we may need to offset ri->data.*/
if (ri->count > 0U)
{
/* If app tries to read outside of the array. */
@@ -202,10 +201,10 @@ uint32_t HID_WriteItem(HID_Report_ItemTypedef *ri, uint32_t value, uint8_t ndx)
}
/* Write logical value to report in little endian order. */
- mask = (1U << ri->size) - 1U;
+ mask = ((uint32_t)1U << ri->size) - 1U;
value = (value & mask) << shift;
- for (x = 0U; x < ((ri->size & 0x7U) ? (ri->size / 8U) + 1U : (ri->size / 8U)); x++)
+ for (x = 0U; x < (((ri->size & 0x7U) != 0U) ? ((ri->size / 8U) + 1U) : (ri->size / 8U)); x++)
{
*(ri->data + x) = (uint8_t)((*(ri->data + x) & ~(mask >> (x * 8U))) |
((value >> (x * 8U)) & (mask >> (x * 8U))));
@@ -234,4 +233,4 @@ uint32_t HID_WriteItem(HID_Report_ItemTypedef *ri, uint32_t value, uint8_t ndx)
/**
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc.h
index d452582369..f7e98be812 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -64,6 +63,7 @@ typedef enum
MSC_WRITE,
MSC_UNRECOVERED_ERROR,
MSC_PERIODIC_CHECK,
+ MSC_USER_NOTIFY
}
MSC_StateTypeDef;
@@ -122,6 +122,7 @@ typedef struct _MSC_Process
BOT_HandleTypeDef hbot;
MSC_LUNTypeDef unit[MAX_SUPPORTED_LUN];
uint16_t current_lun;
+ uint16_t lun;
uint16_t rw_lun;
uint32_t timer;
}
@@ -210,7 +211,6 @@ USBH_StatusTypeDef USBH_MSC_Write(USBH_HandleTypeDef *phost, uint8_t lun,
/**
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc_bot.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc_bot.h
index 2de31f65dc..7a71bedae9 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc_bot.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc_bot.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -228,5 +227,4 @@ USBH_StatusTypeDef USBH_MSC_BOT_Error(USBH_HandleTypeDef *phost, uint8_t lun);
/**
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc_scsi.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc_scsi.h
index 7f839444d2..ed523da5a9 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc_scsi.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc/usbh_msc_scsi.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -214,5 +213,3 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Read(USBH_HandleTypeDef *phost,
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc.c b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc.c
index 929132e7f2..8ee72e346f 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc.c
@@ -3,6 +3,20 @@
* @file usbh_msc.c
* @author MCD Application Team
* @brief This file implements the MSC class driver functions
+ *
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ * @verbatim
+ *
* ===================================================================
* MSC Class Description
* ===================================================================
@@ -16,17 +30,6 @@
* @endverbatim
*
******************************************************************************
- * @attention
- *
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
- *
- ******************************************************************************
*/
/* BSPDependencies
@@ -59,7 +62,6 @@ EndBSPDependencies */
* @{
*/
-
/** @defgroup USBH_MSC_CORE_Private_TypesDefinitions
* @{
*/
@@ -81,7 +83,6 @@ EndBSPDependencies */
* @}
*/
-
/** @defgroup USBH_MSC_CORE_Private_Variables
* @{
*/
@@ -89,21 +90,15 @@ EndBSPDependencies */
* @}
*/
-
/** @defgroup USBH_MSC_CORE_Private_FunctionPrototypes
* @{
*/
static USBH_StatusTypeDef USBH_MSC_InterfaceInit(USBH_HandleTypeDef *phost);
-
static USBH_StatusTypeDef USBH_MSC_InterfaceDeInit(USBH_HandleTypeDef *phost);
-
static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost);
-
static USBH_StatusTypeDef USBH_MSC_ClassRequest(USBH_HandleTypeDef *phost);
-
static USBH_StatusTypeDef USBH_MSC_SOFProcess(USBH_HandleTypeDef *phost);
-
static USBH_StatusTypeDef USBH_MSC_RdWrProcess(USBH_HandleTypeDef *phost, uint8_t lun);
USBH_ClassTypeDef USBH_msc =
@@ -118,26 +113,21 @@ USBH_ClassTypeDef USBH_msc =
NULL,
};
-
/**
* @}
*/
-
/** @defgroup USBH_MSC_CORE_Exported_Variables
* @{
*/
-
/**
* @}
*/
-
/** @defgroup USBH_MSC_CORE_Private_Functions
* @{
*/
-
/**
* @brief USBH_MSC_InterfaceInit
* The function init the MSC class.
@@ -175,9 +165,9 @@ static USBH_StatusTypeDef USBH_MSC_InterfaceInit(USBH_HandleTypeDef *phost)
}
/* Initialize msc handler */
- USBH_memset(MSC_Handle, 0, sizeof(MSC_HandleTypeDef));
+ (void)USBH_memset(MSC_Handle, 0, sizeof(MSC_HandleTypeDef));
- if (phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress & 0x80U)
+ if ((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress & 0x80U) != 0U)
{
MSC_Handle->InEp = (phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].bEndpointAddress);
MSC_Handle->InEpSize = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].wMaxPacketSize;
@@ -188,7 +178,7 @@ static USBH_StatusTypeDef USBH_MSC_InterfaceInit(USBH_HandleTypeDef *phost)
MSC_Handle->OutEpSize = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[0].wMaxPacketSize;
}
- if (phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[1].bEndpointAddress & 0x80U)
+ if ((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[1].bEndpointAddress & 0x80U) != 0U)
{
MSC_Handle->InEp = (phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[1].bEndpointAddress);
MSC_Handle->InEpSize = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[1].wMaxPacketSize;
@@ -205,19 +195,33 @@ static USBH_StatusTypeDef USBH_MSC_InterfaceInit(USBH_HandleTypeDef *phost)
MSC_Handle->OutPipe = USBH_AllocPipe(phost, MSC_Handle->OutEp);
MSC_Handle->InPipe = USBH_AllocPipe(phost, MSC_Handle->InEp);
- USBH_MSC_BOT_Init(phost);
+ (void)USBH_MSC_BOT_Init(phost);
/* Open the new channels */
- USBH_OpenPipe(phost, MSC_Handle->OutPipe, MSC_Handle->OutEp,
- phost->device.address, phost->device.speed,
- USB_EP_TYPE_BULK, MSC_Handle->OutEpSize);
+ if ((MSC_Handle->OutEp != 0U) && (MSC_Handle->OutEpSize != 0U))
+ {
+ (void)USBH_OpenPipe(phost, MSC_Handle->OutPipe, MSC_Handle->OutEp,
+ phost->device.address, phost->device.speed,
+ USB_EP_TYPE_BULK, MSC_Handle->OutEpSize);
+ }
+ else
+ {
+ return USBH_NOT_SUPPORTED;
+ }
- USBH_OpenPipe(phost, MSC_Handle->InPipe, MSC_Handle->InEp,
- phost->device.address, phost->device.speed, USB_EP_TYPE_BULK,
- MSC_Handle->InEpSize);
+ if ((MSC_Handle->InEp != 0U) && (MSC_Handle->InEpSize != 0U))
+ {
+ (void)USBH_OpenPipe(phost, MSC_Handle->InPipe, MSC_Handle->InEp,
+ phost->device.address, phost->device.speed, USB_EP_TYPE_BULK,
+ MSC_Handle->InEpSize);
+ }
+ else
+ {
+ return USBH_NOT_SUPPORTED;
+ }
- USBH_LL_SetToggle(phost, MSC_Handle->InPipe, 0U);
- USBH_LL_SetToggle(phost, MSC_Handle->OutPipe, 0U);
+ (void)USBH_LL_SetToggle(phost, MSC_Handle->InPipe, 0U);
+ (void)USBH_LL_SetToggle(phost, MSC_Handle->OutPipe, 0U);
return USBH_OK;
}
@@ -232,21 +236,21 @@ static USBH_StatusTypeDef USBH_MSC_InterfaceDeInit(USBH_HandleTypeDef *phost)
{
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
- if (MSC_Handle->OutPipe)
+ if ((MSC_Handle->OutPipe) != 0U)
{
- USBH_ClosePipe(phost, MSC_Handle->OutPipe);
- USBH_FreePipe(phost, MSC_Handle->OutPipe);
+ (void)USBH_ClosePipe(phost, MSC_Handle->OutPipe);
+ (void)USBH_FreePipe(phost, MSC_Handle->OutPipe);
MSC_Handle->OutPipe = 0U; /* Reset the Channel as Free */
}
- if (MSC_Handle->InPipe)
+ if ((MSC_Handle->InPipe != 0U))
{
- USBH_ClosePipe(phost, MSC_Handle->InPipe);
- USBH_FreePipe(phost, MSC_Handle->InPipe);
+ (void)USBH_ClosePipe(phost, MSC_Handle->InPipe);
+ (void)USBH_FreePipe(phost, MSC_Handle->InPipe);
MSC_Handle->InPipe = 0U; /* Reset the Channel as Free */
}
- if (phost->pActiveClass->pData)
+ if ((phost->pActiveClass->pData) != NULL)
{
USBH_free(phost->pActiveClass->pData);
phost->pActiveClass->pData = 0U;
@@ -266,18 +270,19 @@ static USBH_StatusTypeDef USBH_MSC_ClassRequest(USBH_HandleTypeDef *phost)
{
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
USBH_StatusTypeDef status = USBH_BUSY;
- uint8_t i;
+ uint8_t lun_idx;
/* Switch MSC REQ state machine */
switch (MSC_Handle->req_state)
{
case MSC_REQ_IDLE:
case MSC_REQ_GET_MAX_LUN:
+
/* Issue GetMaxLUN request */
status = USBH_MSC_BOT_REQ_GetMaxLUN(phost, &MSC_Handle->max_lun);
/* When devices do not support the GetMaxLun request, this should
- be considred as only one logical unit is supported */
+ be considered as only one logical unit is supported */
if (status == USBH_NOT_SUPPORTED)
{
MSC_Handle->max_lun = 0U;
@@ -289,10 +294,10 @@ static USBH_StatusTypeDef USBH_MSC_ClassRequest(USBH_HandleTypeDef *phost)
MSC_Handle->max_lun = (MSC_Handle->max_lun > MAX_SUPPORTED_LUN) ? MAX_SUPPORTED_LUN : (MSC_Handle->max_lun + 1U);
USBH_UsrLog("Number of supported LUN: %d", MSC_Handle->max_lun);
- for (i = 0U; i < MSC_Handle->max_lun; i++)
+ for (lun_idx = 0U; lun_idx < MSC_Handle->max_lun; lun_idx++)
{
- MSC_Handle->unit[i].prev_ready_state = USBH_FAIL;
- MSC_Handle->unit[i].state_changed = 0U;
+ MSC_Handle->unit[lun_idx].prev_ready_state = USBH_FAIL;
+ MSC_Handle->unit[lun_idx].state_changed = 0U;
}
}
break;
@@ -331,8 +336,8 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
if (MSC_Handle->current_lun < MSC_Handle->max_lun)
{
-
MSC_Handle->unit[MSC_Handle->current_lun].error = MSC_NOT_READY;
+
/* Switch MSC REQ state machine */
switch (MSC_Handle->unit[MSC_Handle->current_lun].state)
{
@@ -352,7 +357,7 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
USBH_UsrLog("Inquiry Version : %s", MSC_Handle->unit[MSC_Handle->current_lun].inquiry.revision_id);
MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_TEST_UNIT_READY;
}
- if (scsi_status == USBH_FAIL)
+ else if (scsi_status == USBH_FAIL)
{
MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_REQUEST_SENSE;
}
@@ -360,7 +365,7 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
{
if (scsi_status == USBH_UNRECOVERED_ERROR)
{
- MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_IDLE;
+ MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_UNRECOVERED_ERROR;
MSC_Handle->unit[MSC_Handle->current_lun].error = MSC_ERROR;
}
}
@@ -384,7 +389,7 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
MSC_Handle->unit[MSC_Handle->current_lun].error = MSC_OK;
MSC_Handle->unit[MSC_Handle->current_lun].prev_ready_state = USBH_OK;
}
- if (ready_status == USBH_FAIL)
+ else if (ready_status == USBH_FAIL)
{
/* Media not ready, so try to check again during 10s */
if (MSC_Handle->unit[MSC_Handle->current_lun].prev_ready_state != USBH_FAIL)
@@ -404,23 +409,24 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
{
if (ready_status == USBH_UNRECOVERED_ERROR)
{
- MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_IDLE;
+ MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_UNRECOVERED_ERROR;
MSC_Handle->unit[MSC_Handle->current_lun].error = MSC_ERROR;
}
}
break;
case MSC_READ_CAPACITY10:
- scsi_status = USBH_MSC_SCSI_ReadCapacity(phost, (uint8_t)MSC_Handle->current_lun, &MSC_Handle->unit[MSC_Handle->current_lun].capacity) ;
+ scsi_status = USBH_MSC_SCSI_ReadCapacity(phost, (uint8_t)MSC_Handle->current_lun, &MSC_Handle->unit[MSC_Handle->current_lun].capacity);
if (scsi_status == USBH_OK)
{
if (MSC_Handle->unit[MSC_Handle->current_lun].state_changed == 1U)
{
- USBH_UsrLog("MSC Device capacity : %lu Bytes", \
- (int32_t)(MSC_Handle->unit[MSC_Handle->current_lun].capacity.block_nbr * MSC_Handle->unit[MSC_Handle->current_lun].capacity.block_size));
- USBH_UsrLog("Block number : %lu", (int32_t)(MSC_Handle->unit[MSC_Handle->current_lun].capacity.block_nbr));
- USBH_UsrLog("Block Size : %lu", (int32_t)(MSC_Handle->unit[MSC_Handle->current_lun].capacity.block_size));
+ USBH_UsrLog("MSC Device capacity : %u Bytes", \
+ (unsigned int)(MSC_Handle->unit[MSC_Handle->current_lun].capacity.block_nbr *
+ MSC_Handle->unit[MSC_Handle->current_lun].capacity.block_size));
+ USBH_UsrLog("Block number : %u", (unsigned int)(MSC_Handle->unit[MSC_Handle->current_lun].capacity.block_nbr));
+ USBH_UsrLog("Block Size : %u", (unsigned int)(MSC_Handle->unit[MSC_Handle->current_lun].capacity.block_size));
}
MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_IDLE;
MSC_Handle->unit[MSC_Handle->current_lun].error = MSC_OK;
@@ -434,7 +440,7 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
{
if (scsi_status == USBH_UNRECOVERED_ERROR)
{
- MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_IDLE;
+ MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_UNRECOVERED_ERROR;
MSC_Handle->unit[MSC_Handle->current_lun].error = MSC_ERROR;
}
}
@@ -462,16 +468,17 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_IDLE;
MSC_Handle->current_lun++;
}
- if (scsi_status == USBH_FAIL)
+ else if (scsi_status == USBH_FAIL)
{
USBH_UsrLog("MSC Device NOT ready");
MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_UNRECOVERED_ERROR;
+ MSC_Handle->unit[MSC_Handle->current_lun].error = MSC_ERROR;
}
else
{
if (scsi_status == USBH_UNRECOVERED_ERROR)
{
- MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_IDLE;
+ MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_UNRECOVERED_ERROR;
MSC_Handle->unit[MSC_Handle->current_lun].error = MSC_ERROR;
}
}
@@ -486,31 +493,46 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
MSC_Handle->current_lun = 0U;
- MSC_Handle->state = MSC_IDLE;
+ MSC_Handle->state = MSC_USER_NOTIFY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
- phost->pUser(phost, HOST_USER_CLASS_ACTIVE);
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
break;
+ case MSC_USER_NOTIFY:
+ if (MSC_Handle->lun < MSC_Handle->max_lun)
+ {
+ MSC_Handle->current_lun = MSC_Handle->lun;
+ if (MSC_Handle->unit[MSC_Handle->current_lun].error == MSC_OK)
+ {
+ phost->pUser(phost, HOST_USER_CLASS_ACTIVE);
+ }
+ else
+ {
+ phost->pUser(phost, HOST_USER_UNRECOVERED_ERROR);
+ }
+
+ MSC_Handle->lun++;
+ }
+ else
+ {
+ MSC_Handle->lun = 0U;
+ MSC_Handle->state = MSC_IDLE;
+ }
+
+#if (USBH_USE_OS == 1U)
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ break;
+
case MSC_IDLE:
error = USBH_OK;
break;
@@ -545,13 +567,12 @@ static USBH_StatusTypeDef USBH_MSC_SOFProcess(USBH_HandleTypeDef *phost)
static USBH_StatusTypeDef USBH_MSC_RdWrProcess(USBH_HandleTypeDef *phost, uint8_t lun)
{
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
- USBH_StatusTypeDef error = USBH_BUSY ;
- USBH_StatusTypeDef scsi_status = USBH_BUSY ;
+ USBH_StatusTypeDef error = USBH_BUSY;
+ USBH_StatusTypeDef scsi_status = USBH_BUSY;
/* Switch MSC REQ state machine */
switch (MSC_Handle->unit[lun].state)
{
-
case MSC_READ:
scsi_status = USBH_MSC_SCSI_Read(phost, lun, 0U, NULL, 0U);
@@ -574,13 +595,8 @@ static USBH_StatusTypeDef USBH_MSC_RdWrProcess(USBH_HandleTypeDef *phost, uint8_
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case MSC_WRITE:
@@ -605,13 +621,8 @@ static USBH_StatusTypeDef USBH_MSC_RdWrProcess(USBH_HandleTypeDef *phost, uint8_
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case MSC_REQUEST_SENSE:
@@ -627,7 +638,7 @@ static USBH_StatusTypeDef USBH_MSC_RdWrProcess(USBH_HandleTypeDef *phost, uint8_
error = USBH_FAIL;
}
- if (scsi_status == USBH_FAIL)
+ else if (scsi_status == USBH_FAIL)
{
USBH_UsrLog("MSC Device NOT ready");
}
@@ -641,13 +652,8 @@ static USBH_StatusTypeDef USBH_MSC_RdWrProcess(USBH_HandleTypeDef *phost, uint8_
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CLASS_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CLASS_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
default:
@@ -663,7 +669,7 @@ static USBH_StatusTypeDef USBH_MSC_RdWrProcess(USBH_HandleTypeDef *phost, uint8_
* @param phost: Host handle
* @retval USBH Status
*/
-uint8_t USBH_MSC_IsReady(USBH_HandleTypeDef *phost)
+uint8_t USBH_MSC_IsReady(USBH_HandleTypeDef *phost)
{
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
uint8_t res;
@@ -686,7 +692,7 @@ uint8_t USBH_MSC_IsReady(USBH_HandleTypeDef *phost)
* @param phost: Host handle
* @retval logical Unit Number supported
*/
-uint8_t USBH_MSC_GetMaxLUN(USBH_HandleTypeDef *phost)
+uint8_t USBH_MSC_GetMaxLUN(USBH_HandleTypeDef *phost)
{
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
@@ -705,11 +711,14 @@ uint8_t USBH_MSC_GetMaxLUN(USBH_HandleTypeDef *phost)
* @param lun: logical Unit Number
* @retval Lun status (0: not ready / 1: ready)
*/
-uint8_t USBH_MSC_UnitIsReady(USBH_HandleTypeDef *phost, uint8_t lun)
+uint8_t USBH_MSC_UnitIsReady(USBH_HandleTypeDef *phost, uint8_t lun)
{
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
uint8_t res;
+ /* Store the current lun */
+ MSC_Handle->current_lun = lun;
+
if ((phost->gState == HOST_CLASS) && (MSC_Handle->unit[lun].error == MSC_OK))
{
res = 1U;
@@ -732,9 +741,13 @@ uint8_t USBH_MSC_UnitIsReady(USBH_HandleTypeDef *phost, uint8_t lun)
USBH_StatusTypeDef USBH_MSC_GetLUNInfo(USBH_HandleTypeDef *phost, uint8_t lun, MSC_LUNTypeDef *info)
{
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
+
+ /* Store the current lun */
+ MSC_Handle->current_lun = lun;
+
if (phost->gState == HOST_CLASS)
{
- USBH_memcpy(info, &MSC_Handle->unit[lun], sizeof(MSC_LUNTypeDef));
+ (void)USBH_memcpy(info, &MSC_Handle->unit[lun], sizeof(MSC_LUNTypeDef));
return USBH_OK;
}
else
@@ -762,30 +775,29 @@ USBH_StatusTypeDef USBH_MSC_Read(USBH_HandleTypeDef *phost,
uint32_t timeout;
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
- if ((phost->device.is_connected == 0U) ||
+ /* Store the current lun */
+ MSC_Handle->current_lun = lun;
+
+ if ((phost->device.PortEnabled == 0U) ||
(phost->gState != HOST_CLASS) ||
(MSC_Handle->unit[lun].state != MSC_IDLE))
{
return USBH_FAIL;
}
- MSC_Handle->state = MSC_READ;
MSC_Handle->unit[lun].state = MSC_READ;
- MSC_Handle->rw_lun = lun;
- USBH_MSC_SCSI_Read(phost, lun, address, pbuf, length);
+ (void)USBH_MSC_SCSI_Read(phost, lun, address, pbuf, length);
timeout = phost->Timer;
while (USBH_MSC_RdWrProcess(phost, lun) == USBH_BUSY)
{
- if (((phost->Timer - timeout) > (10000U * length)) || (phost->device.is_connected == 0U))
+ if (((phost->Timer - timeout) > (10000U * length)) || (phost->device.PortEnabled == 0U))
{
- MSC_Handle->state = MSC_IDLE;
return USBH_FAIL;
}
}
- MSC_Handle->state = MSC_IDLE;
return USBH_OK;
}
@@ -809,29 +821,29 @@ USBH_StatusTypeDef USBH_MSC_Write(USBH_HandleTypeDef *phost,
uint32_t timeout;
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
- if ((phost->device.is_connected == 0U) ||
+ /* Store the current lun */
+ MSC_Handle->current_lun = lun;
+
+ if ((phost->device.PortEnabled == 0U) ||
(phost->gState != HOST_CLASS) ||
(MSC_Handle->unit[lun].state != MSC_IDLE))
{
return USBH_FAIL;
}
- MSC_Handle->state = MSC_WRITE;
MSC_Handle->unit[lun].state = MSC_WRITE;
- MSC_Handle->rw_lun = lun;
- USBH_MSC_SCSI_Write(phost, lun, address, pbuf, length);
+ (void)USBH_MSC_SCSI_Write(phost, lun, address, pbuf, length);
timeout = phost->Timer;
while (USBH_MSC_RdWrProcess(phost, lun) == USBH_BUSY)
{
- if (((phost->Timer - timeout) > (10000U * length)) || (phost->device.is_connected == 0U))
+ if (((phost->Timer - timeout) > (10000U * length)) || (phost->device.PortEnabled == 0U))
{
- MSC_Handle->state = MSC_IDLE;
return USBH_FAIL;
}
}
- MSC_Handle->state = MSC_IDLE;
+
return USBH_OK;
}
@@ -855,4 +867,3 @@ USBH_StatusTypeDef USBH_MSC_Write(USBH_HandleTypeDef *phost,
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_bot.c b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_bot.c
index 7f2026d175..ec2f740ea4 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_bot.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_bot.c
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -29,75 +28,75 @@ EndBSPDependencies */
#include "usbh_msc.h"
/** @addtogroup USBH_LIB
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_CLASS
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_MSC_CLASS
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_MSC_BOT
-* @brief This file includes the mass storage related functions
-* @{
-*/
+ * @brief This file includes the mass storage related functions
+ * @{
+ */
/** @defgroup USBH_MSC_BOT_Private_TypesDefinitions
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MSC_BOT_Private_Defines
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MSC_BOT_Private_Macros
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MSC_BOT_Private_Variables
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MSC_BOT_Private_FunctionPrototypes
-* @{
-*/
+ * @{
+ */
static USBH_StatusTypeDef USBH_MSC_BOT_Abort(USBH_HandleTypeDef *phost, uint8_t lun, uint8_t dir);
static BOT_CSWStatusTypeDef USBH_MSC_DecodeCSW(USBH_HandleTypeDef *phost);
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MSC_BOT_Exported_Variables
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MSC_BOT_Private_Functions
-* @{
-*/
+ * @{
+ */
/**
* @brief USBH_MSC_BOT_REQ_Reset
@@ -116,7 +115,7 @@ USBH_StatusTypeDef USBH_MSC_BOT_REQ_Reset(USBH_HandleTypeDef *phost)
phost->Control.setup.b.wIndex.w = 0U;
phost->Control.setup.b.wLength.w = 0U;
- return USBH_CtlReq(phost, 0U, 0U);
+ return USBH_CtlReq(phost, NULL, 0U);
}
/**
@@ -183,8 +182,8 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
case BOT_SEND_CBW:
MSC_Handle->hbot.cbw.field.LUN = lun;
MSC_Handle->hbot.state = BOT_SEND_CBW_WAIT;
- USBH_BulkSendData(phost, MSC_Handle->hbot.cbw.data,
- BOT_CBW_LENGTH, MSC_Handle->OutPipe, 1U);
+ (void)USBH_BulkSendData(phost, MSC_Handle->hbot.cbw.data,
+ BOT_CBW_LENGTH, MSC_Handle->OutPipe, 1U);
break;
@@ -208,7 +207,6 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
MSC_Handle->hbot.state = BOT_DATA_OUT;
}
}
-
else
{
/* If there is NO Data Transfer Stage */
@@ -216,13 +214,8 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else if (URB_Status == USBH_URB_NOTREADY)
{
@@ -230,36 +223,31 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
MSC_Handle->hbot.state = BOT_SEND_CBW;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
if (URB_Status == USBH_URB_STALL)
{
- MSC_Handle->hbot.state = BOT_ERROR_OUT;
+ MSC_Handle->hbot.state = BOT_ERROR_OUT;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
}
break;
case BOT_DATA_IN:
+
/* Send first packet */
- USBH_BulkReceiveData(phost, MSC_Handle->hbot.pbuf,
- MSC_Handle->InEpSize, MSC_Handle->InPipe);
+ (void)USBH_BulkReceiveData(phost, MSC_Handle->hbot.pbuf,
+ MSC_Handle->InEpSize, MSC_Handle->InPipe);
+
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ phost->NakTimer = phost->Timer;
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
MSC_Handle->hbot.state = BOT_DATA_IN_WAIT;
@@ -286,24 +274,39 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
if (MSC_Handle->hbot.cbw.field.DataTransferLength > 0U)
{
/* Send next packet */
- USBH_BulkReceiveData(phost, MSC_Handle->hbot.pbuf,
- MSC_Handle->InEpSize, MSC_Handle->InPipe);
+ (void)USBH_BulkReceiveData(phost, MSC_Handle->hbot.pbuf,
+ MSC_Handle->InEpSize, MSC_Handle->InPipe);
+
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ phost->NakTimer = phost->Timer;
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
}
else
{
/* If value was 0, and successful transfer, then change the state */
- MSC_Handle->hbot.state = BOT_RECEIVE_CSW;
+ MSC_Handle->hbot.state = BOT_RECEIVE_CSW;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ }
+ }
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ else if (URB_Status == USBH_URB_NAK_WAIT)
+ {
+ MSC_Handle->hbot.state = BOT_DATA_IN_WAIT;
+
+ if ((phost->Timer - phost->NakTimer) > phost->NakTimeout)
+ {
+ phost->NakTimer = phost->Timer;
+ USBH_ActivatePipe(phost, MSC_Handle->InPipe);
}
+
+#if (USBH_USE_OS == 1U)
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
else if (URB_Status == USBH_URB_STALL)
{
/* This is Data IN Stage STALL Condition */
@@ -317,13 +320,8 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
4. The host shall attempt to receive a CSW.*/
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -332,8 +330,8 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
case BOT_DATA_OUT:
- USBH_BulkSendData(phost, MSC_Handle->hbot.pbuf,
- MSC_Handle->OutEpSize, MSC_Handle->OutPipe, 1U);
+ (void)USBH_BulkSendData(phost, MSC_Handle->hbot.pbuf,
+ MSC_Handle->OutEpSize, MSC_Handle->OutPipe, 1U);
MSC_Handle->hbot.state = BOT_DATA_OUT_WAIT;
break;
@@ -357,43 +355,33 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
/* More Data To be Sent */
if (MSC_Handle->hbot.cbw.field.DataTransferLength > 0U)
{
- USBH_BulkSendData(phost, MSC_Handle->hbot.pbuf,
- MSC_Handle->OutEpSize, MSC_Handle->OutPipe, 1U);
+ (void)USBH_BulkSendData(phost, MSC_Handle->hbot.pbuf,
+ MSC_Handle->OutEpSize, MSC_Handle->OutPipe, 1U);
}
else
{
/* If value was 0, and successful transfer, then change the state */
- MSC_Handle->hbot.state = BOT_RECEIVE_CSW;
+ MSC_Handle->hbot.state = BOT_RECEIVE_CSW;
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else if (URB_Status == USBH_URB_NOTREADY)
{
/* Resend same data */
- MSC_Handle->hbot.state = BOT_DATA_OUT;
+ MSC_Handle->hbot.state = BOT_DATA_OUT;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else if (URB_Status == USBH_URB_STALL)
{
- MSC_Handle->hbot.state = BOT_ERROR_OUT;
+ MSC_Handle->hbot.state = BOT_ERROR_OUT;
/* Refer to USB Mass-Storage Class : BOT (www.usb.org)
6.7.3 Ho - Host expects to send data to the device
@@ -403,13 +391,8 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
*/
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -418,10 +401,14 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
case BOT_RECEIVE_CSW:
- USBH_BulkReceiveData(phost, MSC_Handle->hbot.csw.data,
- BOT_CSW_LENGTH, MSC_Handle->InPipe);
+ (void)USBH_BulkReceiveData(phost, MSC_Handle->hbot.csw.data,
+ BOT_CSW_LENGTH, MSC_Handle->InPipe);
+
+ MSC_Handle->hbot.state = BOT_RECEIVE_CSW_WAIT;
- MSC_Handle->hbot.state = BOT_RECEIVE_CSW_WAIT;
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ phost->NakTimer = phost->Timer;
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
break;
case BOT_RECEIVE_CSW_WAIT:
@@ -445,26 +432,32 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ }
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ else if (URB_Status == USBH_URB_NAK_WAIT)
+ {
+ MSC_Handle->hbot.state = BOT_RECEIVE_CSW_WAIT;
+
+ if ((phost->Timer - phost->NakTimer) > phost->NakTimeout)
+ {
+ phost->NakTimer = phost->Timer;
+ USBH_ActivatePipe(phost, MSC_Handle->InPipe);
+ }
+
+#if (USBH_USE_OS == 1U)
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
else if (URB_Status == USBH_URB_STALL)
{
- MSC_Handle->hbot.state = BOT_ERROR_IN;
+ MSC_Handle->hbot.state = BOT_ERROR_IN;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -493,10 +486,9 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
if (error == USBH_OK)
{
-
toggle = USBH_LL_GetToggle(phost, MSC_Handle->OutPipe);
- USBH_LL_SetToggle(phost, MSC_Handle->OutPipe, 1U - toggle);
- USBH_LL_SetToggle(phost, MSC_Handle->InPipe, 0U);
+ (void)USBH_LL_SetToggle(phost, MSC_Handle->OutPipe, 1U - toggle);
+ (void)USBH_LL_SetToggle(phost, MSC_Handle->InPipe, 0U);
MSC_Handle->hbot.state = BOT_ERROR_IN;
}
else
@@ -590,7 +582,6 @@ static BOT_CSWStatusTypeDef USBH_MSC_DecodeCSW(USBH_HandleTypeDef *phost)
(11) Ho > Do (Host expects to send data to the device,
Device intends to receive data from the host)*/
-
status = BOT_CSW_PHASE_ERROR;
}
else
@@ -626,7 +617,6 @@ static BOT_CSWStatusTypeDef USBH_MSC_DecodeCSW(USBH_HandleTypeDef *phost)
Device intends to send data to the host)
(12) Ho = Do (Host expects to send data to the device,
Device intends to receive data from the host)
-
*/
status = BOT_CSW_CMD_PASSED;
@@ -635,7 +625,6 @@ static BOT_CSWStatusTypeDef USBH_MSC_DecodeCSW(USBH_HandleTypeDef *phost)
{
status = BOT_CSW_CMD_FAILED;
}
-
else if (MSC_Handle->hbot.csw.field.Status == 2U)
{
/* Refer to USB Mass-Storage Class : BOT (www.usb.org)
@@ -675,26 +664,24 @@ static BOT_CSWStatusTypeDef USBH_MSC_DecodeCSW(USBH_HandleTypeDef *phost)
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_scsi.c b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_scsi.c
index 20612f69f2..11ee79714a 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_scsi.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_scsi.c
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -103,20 +102,20 @@ EndBSPDependencies */
USBH_StatusTypeDef USBH_MSC_SCSI_TestUnitReady(USBH_HandleTypeDef *phost,
uint8_t lun)
{
- USBH_StatusTypeDef error = USBH_FAIL ;
+ USBH_StatusTypeDef error = USBH_FAIL;
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
switch (MSC_Handle->hbot.cmd_state)
{
case BOT_CMD_SEND:
- /*Prepare the CBW and relevent field*/
+ /* Prepare the CBW and relevant field */
MSC_Handle->hbot.cbw.field.DataTransferLength = DATA_LEN_MODE_TEST_UNIT_READY;
MSC_Handle->hbot.cbw.field.Flags = USB_EP_DIR_OUT;
MSC_Handle->hbot.cbw.field.CBLength = CBW_LENGTH;
- USBH_memset(MSC_Handle->hbot.cbw.field.CB, 0, CBW_CB_LENGTH);
- MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_TEST_UNIT_READY;
+ (void)USBH_memset(MSC_Handle->hbot.cbw.field.CB, 0, CBW_CB_LENGTH);
+ MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_TEST_UNIT_READY;
MSC_Handle->hbot.state = BOT_SEND_CBW;
MSC_Handle->hbot.cmd_state = BOT_CMD_WAIT;
@@ -146,19 +145,19 @@ USBH_StatusTypeDef USBH_MSC_SCSI_ReadCapacity(USBH_HandleTypeDef *phost,
uint8_t lun,
SCSI_CapacityTypeDef *capacity)
{
- USBH_StatusTypeDef error = USBH_BUSY ;
+ USBH_StatusTypeDef error = USBH_BUSY;
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
switch (MSC_Handle->hbot.cmd_state)
{
case BOT_CMD_SEND:
- /*Prepare the CBW and relevent field*/
+ /* Prepare the CBW and relevant field */
MSC_Handle->hbot.cbw.field.DataTransferLength = DATA_LEN_READ_CAPACITY10;
MSC_Handle->hbot.cbw.field.Flags = USB_EP_DIR_IN;
MSC_Handle->hbot.cbw.field.CBLength = CBW_LENGTH;
- USBH_memset(MSC_Handle->hbot.cbw.field.CB, 0, CBW_CB_LENGTH);
+ (void)USBH_memset(MSC_Handle->hbot.cbw.field.CB, 0, CBW_CB_LENGTH);
MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_READ_CAPACITY10;
MSC_Handle->hbot.state = BOT_SEND_CBW;
@@ -174,11 +173,11 @@ USBH_StatusTypeDef USBH_MSC_SCSI_ReadCapacity(USBH_HandleTypeDef *phost,
if (error == USBH_OK)
{
- /*assign the capacity*/
+ /* Assign the capacity */
capacity->block_nbr = MSC_Handle->hbot.pbuf[3] | ((uint32_t)MSC_Handle->hbot.pbuf[2] << 8U) | \
((uint32_t)MSC_Handle->hbot.pbuf[1] << 16U) | ((uint32_t)MSC_Handle->hbot.pbuf[0] << 24U);
- /*assign the page length*/
+ /* Assign the page length */
capacity->block_size = (uint16_t)(MSC_Handle->hbot.pbuf[7] | ((uint32_t)MSC_Handle->hbot.pbuf[6] << 8U));
}
break;
@@ -208,18 +207,18 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Inquiry(USBH_HandleTypeDef *phost, uint8_t lun,
{
case BOT_CMD_SEND:
- /*Prepare the CBW and relevent field*/
+ /* Prepare the CBW and relevant field */
MSC_Handle->hbot.cbw.field.DataTransferLength = DATA_LEN_INQUIRY;
MSC_Handle->hbot.cbw.field.Flags = USB_EP_DIR_IN;
MSC_Handle->hbot.cbw.field.CBLength = CBW_LENGTH;
- USBH_memset(MSC_Handle->hbot.cbw.field.CB, 0, CBW_LENGTH);
- MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_INQUIRY;
- MSC_Handle->hbot.cbw.field.CB[1] = (lun << 5);
- MSC_Handle->hbot.cbw.field.CB[2] = 0U;
- MSC_Handle->hbot.cbw.field.CB[3] = 0U;
- MSC_Handle->hbot.cbw.field.CB[4] = 0x24U;
- MSC_Handle->hbot.cbw.field.CB[5] = 0U;
+ (void)USBH_memset(MSC_Handle->hbot.cbw.field.CB, 0, CBW_LENGTH);
+ MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_INQUIRY;
+ MSC_Handle->hbot.cbw.field.CB[1] = (lun << 5);
+ MSC_Handle->hbot.cbw.field.CB[2] = 0U;
+ MSC_Handle->hbot.cbw.field.CB[3] = 0U;
+ MSC_Handle->hbot.cbw.field.CB[4] = 0x24U;
+ MSC_Handle->hbot.cbw.field.CB[5] = 0U;
MSC_Handle->hbot.state = BOT_SEND_CBW;
@@ -234,8 +233,8 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Inquiry(USBH_HandleTypeDef *phost, uint8_t lun,
if (error == USBH_OK)
{
- USBH_memset(inquiry, 0, sizeof(SCSI_StdInquiryDataTypeDef));
- /*assign Inquiry Data */
+ (void)USBH_memset(inquiry, 0, sizeof(SCSI_StdInquiryDataTypeDef));
+ /* Assign Inquiry Data */
inquiry->DeviceType = MSC_Handle->hbot.pbuf[0] & 0x1FU;
inquiry->PeripheralQualifier = MSC_Handle->hbot.pbuf[0] >> 5U;
@@ -248,9 +247,9 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Inquiry(USBH_HandleTypeDef *phost, uint8_t lun,
inquiry->RemovableMedia = 0U;
}
- USBH_memcpy(inquiry->vendor_id, &MSC_Handle->hbot.pbuf[8], 8U);
- USBH_memcpy(inquiry->product_id, &MSC_Handle->hbot.pbuf[16], 16U);
- USBH_memcpy(inquiry->revision_id, &MSC_Handle->hbot.pbuf[32], 4U);
+ (void)USBH_memcpy(inquiry->vendor_id, &MSC_Handle->hbot.pbuf[8], 8U);
+ (void)USBH_memcpy(inquiry->product_id, &MSC_Handle->hbot.pbuf[16], 16U);
+ (void)USBH_memcpy(inquiry->revision_id, &MSC_Handle->hbot.pbuf[32], 4U);
}
break;
@@ -273,25 +272,25 @@ USBH_StatusTypeDef USBH_MSC_SCSI_RequestSense(USBH_HandleTypeDef *phost,
uint8_t lun,
SCSI_SenseTypeDef *sense_data)
{
- USBH_StatusTypeDef error = USBH_FAIL ;
+ USBH_StatusTypeDef error = USBH_FAIL;
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
switch (MSC_Handle->hbot.cmd_state)
{
case BOT_CMD_SEND:
- /*Prepare the CBW and relevent field*/
+ /* Prepare the CBW and relevant field */
MSC_Handle->hbot.cbw.field.DataTransferLength = DATA_LEN_REQUEST_SENSE;
MSC_Handle->hbot.cbw.field.Flags = USB_EP_DIR_IN;
MSC_Handle->hbot.cbw.field.CBLength = CBW_LENGTH;
- USBH_memset(MSC_Handle->hbot.cbw.field.CB, 0, CBW_CB_LENGTH);
- MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_REQUEST_SENSE;
- MSC_Handle->hbot.cbw.field.CB[1] = (lun << 5);
- MSC_Handle->hbot.cbw.field.CB[2] = 0U;
- MSC_Handle->hbot.cbw.field.CB[3] = 0U;
- MSC_Handle->hbot.cbw.field.CB[4] = DATA_LEN_REQUEST_SENSE;
- MSC_Handle->hbot.cbw.field.CB[5] = 0U;
+ (void)USBH_memset(MSC_Handle->hbot.cbw.field.CB, 0, CBW_CB_LENGTH);
+ MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_REQUEST_SENSE;
+ MSC_Handle->hbot.cbw.field.CB[1] = (lun << 5);
+ MSC_Handle->hbot.cbw.field.CB[2] = 0U;
+ MSC_Handle->hbot.cbw.field.CB[3] = 0U;
+ MSC_Handle->hbot.cbw.field.CB[4] = DATA_LEN_REQUEST_SENSE;
+ MSC_Handle->hbot.cbw.field.CB[5] = 0U;
MSC_Handle->hbot.state = BOT_SEND_CBW;
MSC_Handle->hbot.cmd_state = BOT_CMD_WAIT;
@@ -308,6 +307,12 @@ USBH_StatusTypeDef USBH_MSC_SCSI_RequestSense(USBH_HandleTypeDef *phost,
sense_data->key = MSC_Handle->hbot.pbuf[2] & 0x0FU;
sense_data->asc = MSC_Handle->hbot.pbuf[12];
sense_data->ascq = MSC_Handle->hbot.pbuf[13];
+
+ if (sense_data->asc == SCSI_ASC_MEDIUM_NOT_PRESENT)
+ {
+ USBH_UsrLog("MSC Device MEDIUM not present");
+ error = USBH_UNRECOVERED_ERROR;
+ }
}
break;
@@ -334,7 +339,7 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Write(USBH_HandleTypeDef *phost,
uint8_t *pbuf,
uint32_t length)
{
- USBH_StatusTypeDef error = USBH_FAIL ;
+ USBH_StatusTypeDef error = USBH_FAIL;
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
@@ -342,24 +347,24 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Write(USBH_HandleTypeDef *phost,
{
case BOT_CMD_SEND:
- /*Prepare the CBW and relevent field*/
- MSC_Handle->hbot.cbw.field.DataTransferLength = length * MSC_Handle->unit[0].capacity.block_size;
+ /* Prepare the CBW and relevant field */
+ MSC_Handle->hbot.cbw.field.DataTransferLength = length * MSC_Handle->unit[lun].capacity.block_size;
MSC_Handle->hbot.cbw.field.Flags = USB_EP_DIR_OUT;
MSC_Handle->hbot.cbw.field.CBLength = CBW_LENGTH;
- USBH_memset(MSC_Handle->hbot.cbw.field.CB, 0, CBW_CB_LENGTH);
- MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_WRITE10;
+ (void)USBH_memset(MSC_Handle->hbot.cbw.field.CB, 0, CBW_CB_LENGTH);
+ MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_WRITE10;
- /*logical block address*/
- MSC_Handle->hbot.cbw.field.CB[2] = (((uint8_t *)(void *)&address)[3]);
- MSC_Handle->hbot.cbw.field.CB[3] = (((uint8_t *)(void *)&address)[2]);
- MSC_Handle->hbot.cbw.field.CB[4] = (((uint8_t *)(void *)&address)[1]);
- MSC_Handle->hbot.cbw.field.CB[5] = (((uint8_t *)(void *)&address)[0]);
+ /* Logical block address */
+ MSC_Handle->hbot.cbw.field.CB[2] = (((uint8_t *)(void *)&address)[3]);
+ MSC_Handle->hbot.cbw.field.CB[3] = (((uint8_t *)(void *)&address)[2]);
+ MSC_Handle->hbot.cbw.field.CB[4] = (((uint8_t *)(void *)&address)[1]);
+ MSC_Handle->hbot.cbw.field.CB[5] = (((uint8_t *)(void *)&address)[0]);
/*Transfer length */
- MSC_Handle->hbot.cbw.field.CB[7] = (((uint8_t *)(void *)&length)[1]) ;
- MSC_Handle->hbot.cbw.field.CB[8] = (((uint8_t *)(void *)&length)[0]) ;
+ MSC_Handle->hbot.cbw.field.CB[7] = (((uint8_t *)(void *)&length)[1]);
+ MSC_Handle->hbot.cbw.field.CB[8] = (((uint8_t *)(void *)&length)[0]);
MSC_Handle->hbot.state = BOT_SEND_CBW;
@@ -395,31 +400,31 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Read(USBH_HandleTypeDef *phost,
uint8_t *pbuf,
uint32_t length)
{
- USBH_StatusTypeDef error = USBH_FAIL ;
+ USBH_StatusTypeDef error = USBH_FAIL;
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
switch (MSC_Handle->hbot.cmd_state)
{
case BOT_CMD_SEND:
- /*Prepare the CBW and relevent field*/
- MSC_Handle->hbot.cbw.field.DataTransferLength = length * MSC_Handle->unit[0].capacity.block_size;
+ /* Prepare the CBW and relevant field */
+ MSC_Handle->hbot.cbw.field.DataTransferLength = length * MSC_Handle->unit[lun].capacity.block_size;
MSC_Handle->hbot.cbw.field.Flags = USB_EP_DIR_IN;
MSC_Handle->hbot.cbw.field.CBLength = CBW_LENGTH;
- USBH_memset(MSC_Handle->hbot.cbw.field.CB, 0, CBW_CB_LENGTH);
- MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_READ10;
+ (void)USBH_memset(MSC_Handle->hbot.cbw.field.CB, 0, CBW_CB_LENGTH);
+ MSC_Handle->hbot.cbw.field.CB[0] = OPCODE_READ10;
- /*logical block address*/
- MSC_Handle->hbot.cbw.field.CB[2] = (((uint8_t *)(void *)&address)[3]);
- MSC_Handle->hbot.cbw.field.CB[3] = (((uint8_t *)(void *)&address)[2]);
- MSC_Handle->hbot.cbw.field.CB[4] = (((uint8_t *)(void *)&address)[1]);
- MSC_Handle->hbot.cbw.field.CB[5] = (((uint8_t *)(void *)&address)[0]);
+ /* Logical block address */
+ MSC_Handle->hbot.cbw.field.CB[2] = (((uint8_t *)(void *)&address)[3]);
+ MSC_Handle->hbot.cbw.field.CB[3] = (((uint8_t *)(void *)&address)[2]);
+ MSC_Handle->hbot.cbw.field.CB[4] = (((uint8_t *)(void *)&address)[1]);
+ MSC_Handle->hbot.cbw.field.CB[5] = (((uint8_t *)(void *)&address)[0]);
- /*Transfer length */
- MSC_Handle->hbot.cbw.field.CB[7] = (((uint8_t *)(void *)&length)[1]) ;
- MSC_Handle->hbot.cbw.field.CB[8] = (((uint8_t *)(void *)&length)[0]) ;
+ /* Transfer length */
+ MSC_Handle->hbot.cbw.field.CB[7] = (((uint8_t *)(void *)&length)[1]);
+ MSC_Handle->hbot.cbw.field.CB[8] = (((uint8_t *)(void *)&length)[0]);
MSC_Handle->hbot.state = BOT_SEND_CBW;
@@ -460,7 +465,5 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Read(USBH_HandleTypeDef *phost,
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
-
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Inc/usbh_mtp.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Inc/usbh_mtp.h
index b33301660d..b31e309489 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Inc/usbh_mtp.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Inc/usbh_mtp.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -31,21 +30,21 @@ extern "C" {
/** @addtogroup USBH_LIB
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_CLASS
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_MTP_CLASS
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_MTP_CORE
-* @brief This file is the Header file for usbh_mtp.c
-* @{
-*/
+ * @brief This file is the Header file for usbh_mtp.c
+ * @{
+ */
@@ -59,8 +58,8 @@ extern "C" {
*/
/** @defgroup USBH_MTP_CORE_Exported_Types
-* @{
-*/
+ * @{
+ */
typedef enum
{
MTP_IDLE = 0,
@@ -140,37 +139,37 @@ MTP_HandleTypeDef;
#define MTP_ObjectHandlesTypedef PTP_ObjectHandlesTypedef
#define MTP_ObjectInfoTypedef PTP_ObjectInfoTypedef
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_CORE_Exported_Defines
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_CORE_Exported_Macros
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_CORE_Exported_Variables
-* @{
-*/
+ * @{
+ */
extern USBH_ClassTypeDef MTP_Class;
#define USBH_MTP_CLASS &MTP_Class
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_CORE_Exported_FunctionsPrototype
-* @{
-*/
+ * @{
+ */
uint8_t USBH_MTP_IsReady(USBH_HandleTypeDef *phost);
USBH_StatusTypeDef USBH_MTP_SelectStorage(USBH_HandleTypeDef *phost, uint8_t storage_idx);
USBH_StatusTypeDef USBH_MTP_GetNumStorage(USBH_HandleTypeDef *phost, uint8_t *storage_num);
@@ -234,8 +233,8 @@ USBH_StatusTypeDef USBH_MTP_GetDevicePropDesc(USBH_HandleTypeDef *phost,
void USBH_MTP_EventsCallback(USBH_HandleTypeDef *phost, uint32_t event, uint32_t param);
/**
-* @}
-*/
+ * @}
+ */
#ifdef __cplusplus
}
@@ -244,19 +243,18 @@ void USBH_MTP_EventsCallback(USBH_HandleTypeDef *phost, uint32_t event, uint32_t
#endif /* __USBH_MTP_H */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Inc/usbh_mtp_ptp.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Inc/usbh_mtp_ptp.h
index cc9f3b1508..32d72a108f 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Inc/usbh_mtp_ptp.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Inc/usbh_mtp_ptp.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -224,10 +223,10 @@ PTP_ContainerTypedef;
#define PTP_USB_BULK_HS_MAX_PACKET_LEN_WRITE 1024U
#define PTP_USB_BULK_HS_MAX_PACKET_LEN_READ 1024U
-#define PTP_USB_BULK_HDR_LEN (2U * sizeof(uint32_t) + 2U * sizeof(uint16_t))
+#define PTP_USB_BULK_HDR_LEN ((2U * sizeof(uint32_t)) + (2U * sizeof(uint16_t)))
#define PTP_USB_BULK_PAYLOAD_LEN_WRITE (PTP_USB_BULK_HS_MAX_PACKET_LEN_WRITE-PTP_USB_BULK_HDR_LEN)
#define PTP_USB_BULK_PAYLOAD_LEN_READ (PTP_USB_BULK_HS_MAX_PACKET_LEN_READ - PTP_USB_BULK_HDR_LEN)
-#define PTP_USB_BULK_REQ_LEN (PTP_USB_BULK_HDR_LEN + 5U * sizeof(uint32_t))
+#define PTP_USB_BULK_REQ_LEN (PTP_USB_BULK_HDR_LEN + (5U * sizeof(uint32_t)))
#define PTP_USB_BULK_REQ_RESP_MAX_LEN 63U
typedef struct
@@ -1038,5 +1037,4 @@ USBH_StatusTypeDef USBH_PTP_GetDevicePropDesc(USBH_HandleTypeDef *phost,
/**
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Src/usbh_mtp.c b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Src/usbh_mtp.c
index 488405172f..a733d97c90 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Src/usbh_mtp.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Src/usbh_mtp.c
@@ -4,30 +4,30 @@
* @author MCD Application Team
* @brief This file is the MTP Layer Handlers for USB Host MTP class.
*
- * @verbatim
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ * @verbatim
*
* ===================================================================
* MTP Class Description
* ===================================================================
* This module manages the MTP class following the
* "Media Transfer Protocol (MTP) specification Version 1.11 April 6th, 2011".
- * the implmentation is compatible with the PTP model as an extension
+ * the implementation is compatible with the PTP model as an extension
* of the existing Picture Transfer Protocol defined by the ISO 15740 specification
*
* @endverbatim
*
******************************************************************************
- * @attention
- *
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
- *
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
- *
- ******************************************************************************
*/
/* BSPDependencies
@@ -43,57 +43,57 @@ EndBSPDependencies */
#include "usbh_mtp.h"
/** @addtogroup USBH_LIB
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_CLASS
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_MTP_CLASS
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_MTP_CORE
-* @brief This file includes MTP Layer Handlers for USB Host MTP class.
-* @{
-*/
+ * @brief This file includes MTP Layer Handlers for USB Host MTP class.
+ * @{
+ */
/** @defgroup USBH_MTP_CORE_Private_TypesDefinitions
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_CORE_Private_Defines
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_CORE_Private_Macros
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_CORE_Private_Variables
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_CORE_Private_FunctionPrototypes
-* @{
-*/
+ * @{
+ */
static USBH_StatusTypeDef USBH_MTP_InterfaceInit(USBH_HandleTypeDef *phost);
static USBH_StatusTypeDef USBH_MTP_InterfaceDeInit(USBH_HandleTypeDef *phost);
@@ -121,13 +121,13 @@ USBH_ClassTypeDef MTP_Class =
NULL,
};
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_CORE_Private_Functions
-* @{
-*/
+ * @{
+ */
/**
* @brief USBH_MTP_InterfaceInit
@@ -148,7 +148,7 @@ static USBH_StatusTypeDef USBH_MTP_InterfaceInit(USBH_HandleTypeDef *phost)
return USBH_FAIL;
}
- USBH_SelectInterface(phost, interface);
+ (void)USBH_SelectInterface(phost, interface);
status = USBH_SelectInterface(phost, interface);
@@ -174,7 +174,7 @@ static USBH_StatusTypeDef USBH_MTP_InterfaceInit(USBH_HandleTypeDef *phost)
}
/* Initialize mtp handler */
- USBH_memset(MTP_Handle, 0, sizeof(MTP_HandleTypeDef));
+ (void)USBH_memset(MTP_Handle, 0, sizeof(MTP_HandleTypeDef));
/*Collect the control endpoint address and length*/
MTP_Handle->NotificationEp = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bEndpointAddress;
@@ -183,11 +183,11 @@ static USBH_StatusTypeDef USBH_MTP_InterfaceInit(USBH_HandleTypeDef *phost)
MTP_Handle->events.poll = phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bInterval;
/* Open pipe for Notification endpoint */
- USBH_OpenPipe(phost, MTP_Handle->NotificationPipe,MTP_Handle->NotificationEp,
- phost->device.address, phost->device.speed, USB_EP_TYPE_INTR,
- MTP_Handle->NotificationEpSize);
+ (void)USBH_OpenPipe(phost, MTP_Handle->NotificationPipe, MTP_Handle->NotificationEp,
+ phost->device.address, phost->device.speed, USB_EP_TYPE_INTR,
+ MTP_Handle->NotificationEpSize);
- USBH_LL_SetToggle(phost, MTP_Handle->NotificationPipe, 0U);
+ (void)USBH_LL_SetToggle(phost, MTP_Handle->NotificationPipe, 0U);
endpoint = MTP_FindDataInEndpoint(phost);
if ((endpoint == 0xFFU) || (endpoint >= USBH_MAX_NUM_ENDPOINTS))
@@ -202,11 +202,11 @@ static USBH_StatusTypeDef USBH_MTP_InterfaceInit(USBH_HandleTypeDef *phost)
MTP_Handle->DataInPipe = USBH_AllocPipe(phost, MTP_Handle->DataInEp);
/* Open pipe for DATA IN endpoint */
- USBH_OpenPipe(phost, MTP_Handle->DataInPipe, MTP_Handle->DataInEp,
- phost->device.address, phost->device.speed, USB_EP_TYPE_BULK,
- MTP_Handle->DataInEpSize);
+ (void)USBH_OpenPipe(phost, MTP_Handle->DataInPipe, MTP_Handle->DataInEp,
+ phost->device.address, phost->device.speed, USB_EP_TYPE_BULK,
+ MTP_Handle->DataInEpSize);
- USBH_LL_SetToggle(phost, MTP_Handle->DataInPipe, 0U);
+ (void)USBH_LL_SetToggle(phost, MTP_Handle->DataInPipe, 0U);
endpoint = MTP_FindDataOutEndpoint(phost);
if ((endpoint == 0xFFU) || (endpoint >= USBH_MAX_NUM_ENDPOINTS))
@@ -221,11 +221,11 @@ static USBH_StatusTypeDef USBH_MTP_InterfaceInit(USBH_HandleTypeDef *phost)
MTP_Handle->DataOutPipe = USBH_AllocPipe(phost, MTP_Handle->DataOutEp);
/* Open pipe for DATA OUT endpoint */
- USBH_OpenPipe(phost, MTP_Handle->DataOutPipe, MTP_Handle->DataOutEp,
- phost->device.address, phost->device.speed, USB_EP_TYPE_BULK,
- MTP_Handle->DataOutEpSize);
+ (void)USBH_OpenPipe(phost, MTP_Handle->DataOutPipe, MTP_Handle->DataOutEp,
+ phost->device.address, phost->device.speed, USB_EP_TYPE_BULK,
+ MTP_Handle->DataOutEpSize);
- USBH_LL_SetToggle(phost, MTP_Handle->DataOutPipe, 0U);
+ (void)USBH_LL_SetToggle(phost, MTP_Handle->DataOutPipe, 0U);
MTP_Handle->state = MTP_OPENSESSION;
MTP_Handle->is_ready = 0U;
@@ -243,13 +243,13 @@ static uint8_t MTP_FindCtlEndpoint(USBH_HandleTypeDef *phost)
{
uint8_t interface, endpoint;
- for (interface = 0U; interface < USBH_MAX_NUM_INTERFACES ; interface ++)
+ for (interface = 0U; interface < USBH_MAX_NUM_INTERFACES; interface ++)
{
if (phost->device.CfgDesc.Itf_Desc[interface].bInterfaceClass == USB_MTP_CLASS)
{
- for (endpoint = 0U; endpoint < USBH_MAX_NUM_ENDPOINTS ; endpoint ++)
+ for (endpoint = 0U; endpoint < USBH_MAX_NUM_ENDPOINTS; endpoint ++)
{
- if ((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bEndpointAddress & 0x80U) &&
+ if (((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bEndpointAddress & 0x80U) != 0U) &&
(phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].wMaxPacketSize > 0U) &&
((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bmAttributes & USBH_EP_INTERRUPT) == USBH_EP_INTERRUPT))
{
@@ -262,7 +262,6 @@ static uint8_t MTP_FindCtlEndpoint(USBH_HandleTypeDef *phost)
return 0xFFU; /* Invalid Endpoint */
}
-
/**
* @brief Find MTP DATA OUT interface
* @param phost: Host handle
@@ -272,11 +271,11 @@ static uint8_t MTP_FindDataOutEndpoint(USBH_HandleTypeDef *phost)
{
uint8_t interface, endpoint;
- for (interface = 0U; interface < USBH_MAX_NUM_INTERFACES ; interface ++)
+ for (interface = 0U; interface < USBH_MAX_NUM_INTERFACES; interface ++)
{
if (phost->device.CfgDesc.Itf_Desc[interface].bInterfaceClass == USB_MTP_CLASS)
{
- for (endpoint = 0U; endpoint < USBH_MAX_NUM_ENDPOINTS ; endpoint ++)
+ for (endpoint = 0U; endpoint < USBH_MAX_NUM_ENDPOINTS; endpoint ++)
{
if (((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bEndpointAddress & 0x80U) == 0U) &&
@@ -301,14 +300,14 @@ static uint8_t MTP_FindDataInEndpoint(USBH_HandleTypeDef *phost)
{
uint8_t interface, endpoint;
- for (interface = 0U; interface < USBH_MAX_NUM_INTERFACES; interface ++)
+ for (interface = 0U; interface < USBH_MAX_NUM_INTERFACES; interface ++)
{
if (phost->device.CfgDesc.Itf_Desc[interface].bInterfaceClass == USB_MTP_CLASS)
{
- for (endpoint = 0U; endpoint < USBH_MAX_NUM_ENDPOINTS; endpoint ++)
+ for (endpoint = 0U; endpoint < USBH_MAX_NUM_ENDPOINTS; endpoint ++)
{
- if ((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bEndpointAddress & 0x80U) &&
+ if (((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bEndpointAddress & 0x80U) != 0U) &&
(phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].wMaxPacketSize > 0U) &&
((phost->device.CfgDesc.Itf_Desc[interface].Ep_Desc[endpoint].bmAttributes & USBH_EP_BULK) == USBH_EP_BULK))
{
@@ -321,7 +320,6 @@ static uint8_t MTP_FindDataInEndpoint(USBH_HandleTypeDef *phost)
return 0xFFU; /* Invalid Endpoint */
}
-
/**
* @brief USBH_MTP_InterfaceDeInit
* The function DeInit the Pipes used for the MTP class.
@@ -334,22 +332,22 @@ static USBH_StatusTypeDef USBH_MTP_InterfaceDeInit(USBH_HandleTypeDef *phost)
if (MTP_Handle->DataOutPipe != 0U)
{
- USBH_ClosePipe(phost, MTP_Handle->DataOutPipe);
- USBH_FreePipe(phost, MTP_Handle->DataOutPipe);
+ (void)USBH_ClosePipe(phost, MTP_Handle->DataOutPipe);
+ (void)USBH_FreePipe(phost, MTP_Handle->DataOutPipe);
MTP_Handle->DataOutPipe = 0U; /* Reset the Channel as Free */
}
if (MTP_Handle->DataInPipe != 0U)
{
- USBH_ClosePipe(phost, MTP_Handle->DataInPipe);
- USBH_FreePipe(phost, MTP_Handle->DataInPipe);
+ (void)USBH_ClosePipe(phost, MTP_Handle->DataInPipe);
+ (void)USBH_FreePipe(phost, MTP_Handle->DataInPipe);
MTP_Handle->DataInPipe = 0U; /* Reset the Channel as Free */
}
if (MTP_Handle->NotificationPipe != 0U)
{
- USBH_ClosePipe(phost, MTP_Handle->NotificationPipe);
- USBH_FreePipe(phost, MTP_Handle->NotificationPipe);
+ (void)USBH_ClosePipe(phost, MTP_Handle->NotificationPipe);
+ (void)USBH_FreePipe(phost, MTP_Handle->NotificationPipe);
MTP_Handle->NotificationPipe = 0U; /* Reset the Channel as Free */
}
@@ -372,21 +370,14 @@ static USBH_StatusTypeDef USBH_MTP_InterfaceDeInit(USBH_HandleTypeDef *phost)
static USBH_StatusTypeDef USBH_MTP_ClassRequest(USBH_HandleTypeDef *phost)
{
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
#else
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
-#endif
-
+#endif /* (USBH_USE_OS == 1U) */
return USBH_OK;
}
-
/**
* @brief USBH_MTP_Process
* The function is for managing state machine for MTP data transfers
@@ -410,13 +401,8 @@ static USBH_StatusTypeDef USBH_MTP_Process(USBH_HandleTypeDef *phost)
MTP_Handle->state = MTP_GETDEVICEINFO;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
break;
@@ -440,13 +426,8 @@ static USBH_StatusTypeDef USBH_MTP_Process(USBH_HandleTypeDef *phost)
MTP_Handle->state = MTP_GETSTORAGEIDS;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
break;
@@ -456,7 +437,7 @@ static USBH_StatusTypeDef USBH_MTP_Process(USBH_HandleTypeDef *phost)
if (status == USBH_OK)
{
USBH_DbgLog("Number of storage ID items : %d", MTP_Handle->info.storids.n);
- for (idx = 0U; idx < MTP_Handle->info.storids.n; idx ++)
+ for (idx = 0U; idx < MTP_Handle->info.storids.n; idx ++)
{
USBH_DbgLog("storage#%d ID : %x", idx, MTP_Handle->info.storids.Storage[idx]);
}
@@ -465,13 +446,8 @@ static USBH_StatusTypeDef USBH_MTP_Process(USBH_HandleTypeDef *phost)
MTP_Handle->state = MTP_GETSTORAGEINFO;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
break;
@@ -498,28 +474,18 @@ static USBH_StatusTypeDef USBH_MTP_Process(USBH_HandleTypeDef *phost)
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
break;
case MTP_IDLE:
- USBH_MTP_Events(phost);
+ (void)USBH_MTP_Events(phost);
#if (USBH_USE_OS == 1U)
osDelay(10U);
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
status = USBH_OK;
break;
@@ -589,7 +555,7 @@ USBH_StatusTypeDef USBH_MTP_SelectStorage(USBH_HandleTypeDef *phost, uint8_t sto
USBH_StatusTypeDef status = USBH_FAIL;
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
- if ((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready))
+ if ((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready == 1U))
{
MTP_Handle->params.CurrentStorageId = MTP_Handle->info.storids.Storage[storage_idx];
status = USBH_OK;
@@ -609,7 +575,7 @@ USBH_StatusTypeDef USBH_MTP_GetStorageInfo(USBH_HandleTypeDef *phost, uint8_t st
USBH_StatusTypeDef status = USBH_FAIL;
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
- if ((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready))
+ if ((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready == 1U))
{
*info = MTP_Handle->info.storinfo[storage_idx];
status = USBH_OK;
@@ -632,7 +598,7 @@ USBH_StatusTypeDef USBH_MTP_GetNumObjects(USBH_HandleTypeDef *phost,
USBH_StatusTypeDef status = USBH_FAIL;
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
uint32_t timeout = phost->Timer;
- if ((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready))
+ if ((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready == 1U))
{
while ((status = USBH_PTP_GetNumObjects(phost,
MTP_Handle->info.storids.Storage[storage_idx],
@@ -640,7 +606,7 @@ USBH_StatusTypeDef USBH_MTP_GetNumObjects(USBH_HandleTypeDef *phost,
associationOH,
numobs)) == USBH_BUSY)
{
- if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
+ if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
{
return USBH_FAIL;
}
@@ -666,7 +632,7 @@ USBH_StatusTypeDef USBH_MTP_GetObjectHandles(USBH_HandleTypeDef *phost,
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
uint32_t timeout = phost->Timer;
- if ((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready))
+ if ((storage_idx < MTP_Handle->info.storids.n) && (MTP_Handle->is_ready == 1U))
{
while ((status = USBH_PTP_GetObjectHandles(phost,
MTP_Handle->info.storids.Storage[storage_idx],
@@ -674,7 +640,7 @@ USBH_StatusTypeDef USBH_MTP_GetObjectHandles(USBH_HandleTypeDef *phost,
associationOH,
objecthandles)) == USBH_BUSY)
{
- if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
+ if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
{
return USBH_FAIL;
}
@@ -698,7 +664,7 @@ USBH_StatusTypeDef USBH_MTP_GetObjectInfo(USBH_HandleTypeDef *phost,
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
uint32_t timeout = phost->Timer;
- if (MTP_Handle->is_ready)
+ if ((MTP_Handle->is_ready) != 0U)
{
while ((status = USBH_PTP_GetObjectInfo(phost, handle, objectinfo)) == USBH_BUSY)
{
@@ -726,7 +692,7 @@ USBH_StatusTypeDef USBH_MTP_DeleteObject(USBH_HandleTypeDef *phost,
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
uint32_t timeout = phost->Timer;
- if (MTP_Handle->is_ready)
+ if ((MTP_Handle->is_ready) != 0U)
{
while ((status = USBH_PTP_DeleteObject(phost, handle, objectformatcode)) == USBH_BUSY)
{
@@ -755,7 +721,7 @@ USBH_StatusTypeDef USBH_MTP_GetObject(USBH_HandleTypeDef *phost,
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
uint32_t timeout = phost->Timer;
- if (MTP_Handle->is_ready)
+ if ((MTP_Handle->is_ready) != 0U)
{
while ((status = USBH_PTP_GetObject(phost, handle, object)) == USBH_BUSY)
{
@@ -786,12 +752,12 @@ USBH_StatusTypeDef USBH_MTP_GetPartialObject(USBH_HandleTypeDef *phost,
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
uint32_t timeout = phost->Timer;
- if (MTP_Handle->is_ready)
+ if ((MTP_Handle->is_ready) != 0U)
{
while ((status = USBH_PTP_GetPartialObject(phost, handle, offset, maxbytes,
object, len)) == USBH_BUSY)
{
- if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
+ if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
{
return USBH_FAIL;
}
@@ -817,12 +783,12 @@ USBH_StatusTypeDef USBH_MTP_GetObjectPropsSupported(USBH_HandleTypeDef *phost,
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
uint32_t timeout = phost->Timer;
- if (MTP_Handle->is_ready)
+ if ((MTP_Handle->is_ready) != 0U)
{
while ((status = USBH_PTP_GetObjectPropsSupported(phost, ofc, propnum,
props)) == USBH_BUSY)
{
- if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
+ if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
{
return USBH_FAIL;
}
@@ -847,11 +813,11 @@ USBH_StatusTypeDef USBH_MTP_GetObjectPropDesc(USBH_HandleTypeDef *phost,
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
uint32_t timeout = phost->Timer;
- if (MTP_Handle->is_ready)
+ if ((MTP_Handle->is_ready) != 0U)
{
while ((status = USBH_PTP_GetObjectPropDesc(phost, opc, ofc, opd)) == USBH_BUSY)
{
- if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
+ if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
{
return USBH_FAIL;
}
@@ -876,12 +842,12 @@ USBH_StatusTypeDef USBH_MTP_GetObjectPropList(USBH_HandleTypeDef *phost,
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
uint32_t timeout = phost->Timer;
- if (MTP_Handle->is_ready)
+ if ((MTP_Handle->is_ready) != 0U)
{
while ((status = USBH_PTP_GetObjectPropList(phost, handle, pprops,
nrofprops)) == USBH_BUSY)
{
- if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
+ if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
{
return USBH_FAIL;
}
@@ -906,11 +872,11 @@ USBH_StatusTypeDef USBH_MTP_SendObject(USBH_HandleTypeDef *phost,
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
uint32_t timeout = phost->Timer;
- if (MTP_Handle->is_ready)
+ if ((MTP_Handle->is_ready) != 0U)
{
while ((status = USBH_PTP_SendObject(phost, handle, object, size)) == USBH_BUSY)
{
- if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
+ if (((phost->Timer - timeout) > 5000U) || (phost->device.is_connected == 0U))
{
return USBH_FAIL;
}
@@ -920,10 +886,10 @@ USBH_StatusTypeDef USBH_MTP_SendObject(USBH_HandleTypeDef *phost,
}
/**
- * @brief Handle HID Control process
- * @param phost: Host handle
- * @retval USBH Status
- */
+ * @brief Handle HID Control process
+ * @param phost: Host handle
+ * @retval USBH Status
+ */
static USBH_StatusTypeDef USBH_MTP_Events(USBH_HandleTypeDef *phost)
{
USBH_StatusTypeDef status = USBH_BUSY;
@@ -935,10 +901,10 @@ static USBH_StatusTypeDef USBH_MTP_Events(USBH_HandleTypeDef *phost)
if ((phost->Timer & 1U) == 0U)
{
MTP_Handle->events.timer = phost->Timer;
- USBH_InterruptReceiveData(phost,
- (uint8_t *)(void *) & (MTP_Handle->events.container),
- (uint8_t)MTP_Handle->NotificationEpSize,
- MTP_Handle->NotificationPipe);
+ (void)USBH_InterruptReceiveData(phost,
+ (uint8_t *)(void *) & (MTP_Handle->events.container),
+ (uint8_t)MTP_Handle->NotificationEpSize,
+ MTP_Handle->NotificationPipe);
MTP_Handle->events.state = MTP_EVENTS_GETDATA;
@@ -954,11 +920,10 @@ static USBH_StatusTypeDef USBH_MTP_Events(USBH_HandleTypeDef *phost)
{
MTP_Handle->events.timer = phost->Timer;
- USBH_InterruptReceiveData(phost,
- (uint8_t *)(void *) & (MTP_Handle->events.container),
- (uint8_t)MTP_Handle->NotificationEpSize,
- MTP_Handle->NotificationPipe);
-
+ (void)USBH_InterruptReceiveData(phost,
+ (uint8_t *)(void *) & (MTP_Handle->events.container),
+ (uint8_t)MTP_Handle->NotificationEpSize,
+ MTP_Handle->NotificationPipe);
}
break;
@@ -1072,7 +1037,7 @@ USBH_StatusTypeDef USBH_MTP_GetDevicePropDesc(USBH_HandleTypeDef *phost,
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
uint32_t timeout = phost->Timer;
- if (MTP_Handle->is_ready)
+ if ((MTP_Handle->is_ready) != 0U)
{
while ((status = USBH_PTP_GetDevicePropDesc(phost, propcode, devicepropertydesc)) == USBH_BUSY)
{
@@ -1084,6 +1049,7 @@ USBH_StatusTypeDef USBH_MTP_GetDevicePropDesc(USBH_HandleTypeDef *phost,
}
return status;
}
+
/**
* @brief The function informs that host has received an event
* @param pdev: Selected device
@@ -1097,25 +1063,23 @@ __weak void USBH_MTP_EventsCallback(USBH_HandleTypeDef *phost, uint32_t event, u
UNUSED(param);
}
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Src/usbh_mtp_ptp.c b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Src/usbh_mtp_ptp.c
index 41479ca58f..8fe4fcab2d 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Src/usbh_mtp_ptp.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/MTP/Src/usbh_mtp_ptp.c
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -31,57 +30,57 @@ EndBSPDependencies */
#include "usbh_mtp.h"
/** @addtogroup USBH_LIB
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_CLASS
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_MTP_CLASS
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_MTP_PTP
-* @brief This file includes the mass storage related functions
-* @{
-*/
+ * @brief This file includes the mass storage related functions
+ * @{
+ */
/** @defgroup USBH_MTP_PTP_Private_TypesDefinitions
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_PTP_Private_Defines
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_PTP_Private_Macros
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_PTP_Private_Variables
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_PTP_Private_FunctionPrototypes
-* @{
-*/
+ * @{
+ */
static void PTP_DecodeDeviceInfo(USBH_HandleTypeDef *phost, PTP_DeviceInfoTypedef *dev_info);
static void PTP_GetStorageIDs(USBH_HandleTypeDef *phost, PTP_StorageIDsTypedef *stor_ids);
static void PTP_GetStorageInfo(USBH_HandleTypeDef *phost, uint32_t storage_id, PTP_StorageInfoTypedef *stor_info);
@@ -101,21 +100,21 @@ static void PTP_GetString(uint8_t *str, uint8_t *data, uint16_t *len);
static uint32_t PTP_GetArray16(uint16_t *array, uint8_t *data, uint32_t offset);
static uint32_t PTP_GetArray32(uint32_t *array, uint8_t *data, uint32_t offset);
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_PTP_Exported_Variables
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_MTP_PTP_Private_Functions
-* @{
-*/
+ * @{
+ */
/**
* @brief USBH_PTP_Init
* The function Initializes the BOT protocol.
@@ -155,11 +154,11 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
break;
case PTP_OP_REQUEST_STATE:
- USBH_BulkSendData(phost,
- (uint8_t *)(void *) & (MTP_Handle->ptp.op_container),
- (uint16_t)MTP_Handle->ptp.op_container.length,
- MTP_Handle->DataOutPipe,
- 1U);
+ (void)USBH_BulkSendData(phost,
+ (uint8_t *)(void *) & (MTP_Handle->ptp.op_container),
+ (uint16_t)MTP_Handle->ptp.op_container.length,
+ MTP_Handle->DataOutPipe,
+ 1U);
MTP_Handle->ptp.state = PTP_OP_REQUEST_WAIT_STATE;
break;
@@ -182,16 +181,12 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
}
else
{
+ /* .. */
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else if (URB_Status == USBH_URB_NOTREADY)
{
@@ -199,26 +194,16 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else if (URB_Status == USBH_URB_STALL)
{
MTP_Handle->ptp.state = PTP_ERROR;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -227,14 +212,13 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
case PTP_DATA_OUT_PHASE_STATE:
- USBH_BulkSendData(phost,
- MTP_Handle->ptp.data_ptr,
- MTP_Handle->DataOutEpSize,
- MTP_Handle->DataOutPipe,
- 1U);
+ (void)USBH_BulkSendData(phost,
+ MTP_Handle->ptp.data_ptr,
+ MTP_Handle->DataOutEpSize,
+ MTP_Handle->DataOutPipe,
+ 1U);
-
- MTP_Handle->ptp.state = PTP_DATA_OUT_PHASE_WAIT_STATE;
+ MTP_Handle->ptp.state = PTP_DATA_OUT_PHASE_WAIT_STATE;
break;
case PTP_DATA_OUT_PHASE_WAIT_STATE:
@@ -264,11 +248,11 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
/* More Data To be Sent */
if (MTP_Handle->ptp.data_length > 0U)
{
- USBH_BulkSendData(phost,
- MTP_Handle->ptp.data_ptr,
- MTP_Handle->DataOutEpSize,
- MTP_Handle->DataOutPipe,
- 1U);
+ (void)USBH_BulkSendData(phost,
+ MTP_Handle->ptp.data_ptr,
+ MTP_Handle->DataOutEpSize,
+ MTP_Handle->DataOutPipe,
+ 1U);
}
else
{
@@ -277,13 +261,8 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else if (URB_Status == USBH_URB_NOTREADY)
{
@@ -291,26 +270,16 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
MTP_Handle->ptp.state = PTP_DATA_OUT_PHASE_STATE;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else if (URB_Status == USBH_URB_STALL)
{
MTP_Handle->ptp.state = PTP_ERROR;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -320,10 +289,14 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
case PTP_DATA_IN_PHASE_STATE:
/* Send first packet */
- USBH_BulkReceiveData(phost,
- MTP_Handle->ptp.data_ptr,
- MTP_Handle->DataInEpSize,
- MTP_Handle->DataInPipe);
+ (void)USBH_BulkReceiveData(phost,
+ MTP_Handle->ptp.data_ptr,
+ MTP_Handle->DataInEpSize,
+ MTP_Handle->DataInPipe);
+
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ phost->NakTimer = phost->Timer;
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
MTP_Handle->ptp.state = PTP_DATA_IN_PHASE_WAIT_STATE;
break;
@@ -355,11 +328,15 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
MTP_Handle->ptp.iteration++;
}
- /* Continue receiving data*/
- USBH_BulkReceiveData(phost,
- MTP_Handle->ptp.data_ptr,
- MTP_Handle->DataInEpSize,
- MTP_Handle->DataInPipe);
+ /* Continue receiving data */
+ (void)USBH_BulkReceiveData(phost,
+ MTP_Handle->ptp.data_ptr,
+ MTP_Handle->DataInEpSize,
+ MTP_Handle->DataInPipe);
+
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ phost->NakTimer = phost->Timer;
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
}
else
{
@@ -367,27 +344,33 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
MTP_Handle->ptp.state = PTP_RESPONSE_STATE;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
}
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ else if (URB_Status == USBH_URB_NAK_WAIT)
+ {
+ MTP_Handle->ptp.state = PTP_DATA_IN_PHASE_WAIT_STATE;
+
+ if ((phost->Timer - phost->NakTimer) > phost->NakTimeout)
+ {
+ phost->NakTimer = phost->Timer;
+ USBH_ActivatePipe(phost, MTP_Handle->DataInPipe);
+ }
+
+#if (USBH_USE_OS == 1U)
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ }
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
else if (URB_Status == USBH_URB_STALL)
{
MTP_Handle->ptp.state = PTP_ERROR;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -396,12 +379,16 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
break;
case PTP_RESPONSE_STATE:
- USBH_BulkReceiveData(phost,
- (uint8_t *)(void *) & (MTP_Handle->ptp.resp_container),
- PTP_USB_BULK_REQ_RESP_MAX_LEN,
- MTP_Handle->DataInPipe);
+ (void)USBH_BulkReceiveData(phost,
+ (uint8_t *)(void *) & (MTP_Handle->ptp.resp_container),
+ PTP_USB_BULK_REQ_RESP_MAX_LEN,
+ MTP_Handle->DataInPipe);
+
+ MTP_Handle->ptp.state = PTP_RESPONSE_WAIT_STATE;
- MTP_Handle->ptp.state = PTP_RESPONSE_WAIT_STATE;
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ phost->NakTimer = phost->Timer;
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
break;
case PTP_RESPONSE_WAIT_STATE:
@@ -409,7 +396,7 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
if (URB_Status == USBH_URB_DONE)
{
- USBH_PTP_GetResponse(phost, &ptp_container);
+ (void)USBH_PTP_GetResponse(phost, &ptp_container);
if (ptp_container.Code == PTP_RC_OK)
{
@@ -421,18 +408,29 @@ USBH_StatusTypeDef USBH_PTP_Process(USBH_HandleTypeDef *phost)
}
MTP_Handle->ptp.req_state = PTP_REQ_SEND;
}
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ else if (URB_Status == USBH_URB_NAK_WAIT)
+ {
+ MTP_Handle->ptp.state = PTP_RESPONSE_WAIT_STATE;
+
+ if ((phost->Timer - phost->NakTimer) > phost->NakTimeout)
+ {
+ phost->NakTimer = phost->Timer;
+ USBH_ActivatePipe(phost, MTP_Handle->DataInPipe);
+ }
+
+#if (USBH_USE_OS == 1U)
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ }
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
else if (URB_Status == USBH_URB_STALL)
{
MTP_Handle->ptp.state = PTP_ERROR;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_URB_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_URB_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -462,10 +460,10 @@ USBH_StatusTypeDef USBH_PTP_SendRequest(USBH_HandleTypeDef *phost, PTP_Container
MTP_HandleTypeDef *MTP_Handle = (MTP_HandleTypeDef *)phost->pActiveClass->pData;
/* Clear PTP Data container*/
- USBH_memset(&(MTP_Handle->ptp.op_container), 0, sizeof(PTP_OpContainerTypedef));
+ (void)USBH_memset(&(MTP_Handle->ptp.op_container), 0, sizeof(PTP_OpContainerTypedef));
/* build appropriate USB container */
- MTP_Handle->ptp.op_container.length = PTP_USB_BULK_REQ_LEN - (sizeof(uint32_t) * (5U - req->Nparam));
+ MTP_Handle->ptp.op_container.length = PTP_USB_BULK_REQ_LEN - ((sizeof(uint32_t) * (5U - (uint32_t)req->Nparam)));
MTP_Handle->ptp.op_container.type = PTP_USB_CONTAINER_COMMAND;
MTP_Handle->ptp.op_container.code = req->Code;
MTP_Handle->ptp.op_container.trans_id = req->Transaction_ID;
@@ -524,7 +522,8 @@ static void PTP_BufferFullCallback(USBH_HandleTypeDef *phost)
if (MTP_Handle->ptp.iteration == 0U)
{
/* copy it to object */
- USBH_memcpy(MTP_Handle->ptp.object_ptr, MTP_Handle->ptp.data_container.payload.data, PTP_USB_BULK_PAYLOAD_LEN_READ);
+ (void)USBH_memcpy(MTP_Handle->ptp.object_ptr, MTP_Handle->ptp.data_container.payload.data,
+ PTP_USB_BULK_PAYLOAD_LEN_READ);
/* next packet should be directly copied to object */
MTP_Handle->ptp.data_ptr = (MTP_Handle->ptp.object_ptr + PTP_USB_BULK_PAYLOAD_LEN_READ);
@@ -572,38 +571,38 @@ static void PTP_DecodeDeviceInfo(USBH_HandleTypeDef *phost, PTP_DeviceInfoTypede
dev_info->VendorExtensionVersion = LE16(&data[PTP_di_VendorExtensionVersion]);
PTP_GetString(dev_info->VendorExtensionDesc, &data[PTP_di_VendorExtensionDesc], &len);
- totallen = len * 2U + 1U;
+ totallen = (uint32_t)(len * 2U) + 1U;
dev_info->FunctionalMode = LE16(&data[PTP_di_FunctionalMode + totallen]);
dev_info->OperationsSupported_len = PTP_GetArray16((uint16_t *)(void *)&dev_info->OperationsSupported,
data, PTP_di_OperationsSupported + totallen);
- totallen = totallen + dev_info->OperationsSupported_len * sizeof(uint16_t) + sizeof(uint32_t);
+ totallen = totallen + (dev_info->OperationsSupported_len * sizeof(uint16_t)) + sizeof(uint32_t);
dev_info->EventsSupported_len = PTP_GetArray16((uint16_t *)(void *)&dev_info->EventsSupported,
data, PTP_di_OperationsSupported + totallen);
- totallen = totallen + dev_info->EventsSupported_len * sizeof(uint16_t) + sizeof(uint32_t);
+ totallen = totallen + (dev_info->EventsSupported_len * sizeof(uint16_t)) + sizeof(uint32_t);
dev_info->DevicePropertiesSupported_len = PTP_GetArray16((uint16_t *)(void *)&dev_info->DevicePropertiesSupported,
data, PTP_di_OperationsSupported + totallen);
- totallen = totallen + dev_info->DevicePropertiesSupported_len * sizeof(uint16_t) + sizeof(uint32_t);
+ totallen = totallen + (dev_info->DevicePropertiesSupported_len * sizeof(uint16_t)) + sizeof(uint32_t);
dev_info->CaptureFormats_len = PTP_GetArray16((uint16_t *)(void *)&dev_info->CaptureFormats,
data, PTP_di_OperationsSupported + totallen);
- totallen = totallen + dev_info->CaptureFormats_len * sizeof(uint16_t) + sizeof(uint32_t);
+ totallen = totallen + (dev_info->CaptureFormats_len * sizeof(uint16_t)) + sizeof(uint32_t);
dev_info->ImageFormats_len = PTP_GetArray16((uint16_t *)(void *)&dev_info->ImageFormats,
data, PTP_di_OperationsSupported + totallen);
- totallen = totallen + dev_info->ImageFormats_len * sizeof(uint16_t) + sizeof(uint32_t);
+ totallen = totallen + (dev_info->ImageFormats_len * sizeof(uint16_t)) + sizeof(uint32_t);
PTP_GetString(dev_info->Manufacturer, &data[PTP_di_OperationsSupported + totallen], &len);
- totallen += len * 2U + 1U;
+ totallen += (uint32_t)(len * 2U) + 1U;
PTP_GetString(dev_info->Model, &data[PTP_di_OperationsSupported + totallen], &len);
- totallen += len * 2U + 1U;
+ totallen += (uint32_t)(len * 2U) + 1U;
PTP_GetString(dev_info->DeviceVersion, &data[PTP_di_OperationsSupported + totallen], &len);
- totallen += len * 2U + 1U;
+ totallen += (uint32_t)(len * 2U) + 1U;
PTP_GetString(dev_info->SerialNumber, &data[PTP_di_OperationsSupported + totallen], &len);
}
}
@@ -648,7 +647,7 @@ static void PTP_GetStorageInfo(USBH_HandleTypeDef *phost, uint32_t storage_id, P
stor_info->FreeSpaceInImages = LE32(&data[PTP_si_FreeSpaceInImages]);
PTP_GetString(stor_info->StorageDescription, &data[PTP_si_StorageDescription], &len);
- PTP_GetString(stor_info->VolumeLabel, &data[PTP_si_StorageDescription + len * 2U + 1U], &len);
+ PTP_GetString(stor_info->VolumeLabel, &data[PTP_si_StorageDescription + (len * 2U) + 1U], &len);
}
/**
@@ -728,7 +727,7 @@ static void PTP_GetObjectPropDesc(USBH_HandleTypeDef *phost, PTP_ObjectPropDescT
opd->FORM.Enum.NumberOfValues = LE16(&data[offset]);
offset += sizeof(uint16_t);
- for (i = 0U; i < opd->FORM.Enum.NumberOfValues ; i++)
+ for (i = 0U; i < opd->FORM.Enum.NumberOfValues; i++)
{
PTP_GetDevicePropValue(phost, &offset, opdlen, &opd->FORM.Enum.SupportedValue[i], opd->DataType);
}
@@ -760,15 +759,15 @@ static void PTP_GetDevicePropValue(USBH_HandleTypeDef *phost,
switch (datatype)
{
case PTP_DTC_INT8:
- value->i8 = *(int8_t *)(void *) &(data[*offset]);
+ value->i8 = *(int8_t *)(void *) & (data[*offset]);
*offset += 1U;
break;
case PTP_DTC_UINT8:
- value->u8 = *(uint8_t *) &(data[*offset]);
+ value->u8 = *(uint8_t *) & (data[*offset]);
*offset += 1U;
break;
case PTP_DTC_INT16:
- value->i16 = *(int16_t *)(void *) &(data[*offset]);
+ value->i16 = *(int16_t *)(void *) & (data[*offset]);
*offset += 2U;
break;
case PTP_DTC_UINT16:
@@ -802,7 +801,7 @@ static void PTP_GetDevicePropValue(USBH_HandleTypeDef *phost,
case PTP_DTC_STR:
PTP_GetString((uint8_t *)(void *)value->str, (uint8_t *) & (data[*offset]), &len);
- *offset += len * 2U + 1U;
+ *offset += (uint32_t)(len * 2U) + 1U;
break;
default:
break;
@@ -937,7 +936,7 @@ static uint32_t PTP_GetArray32(uint32_t *array, uint8_t *data, uint32_t offset)
PTP Requests
-*******************************************************************************/
+ *******************************************************************************/
/**
* @brief USBH_PTP_OpenSession
* Open a new session
@@ -967,7 +966,7 @@ USBH_StatusTypeDef USBH_PTP_OpenSession(USBH_HandleTypeDef *phost, uint32_t sess
ptp_container.Nparam = 1U;
/* convert request packet inti USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -975,13 +974,8 @@ USBH_StatusTypeDef USBH_PTP_OpenSession(USBH_HandleTypeDef *phost, uint32_t sess
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1028,7 +1022,7 @@ USBH_StatusTypeDef USBH_PTP_GetDevicePropDesc(USBH_HandleTypeDef *phost,
ptp_container.Nparam = 1U;
/* convert request packet into USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1036,13 +1030,8 @@ USBH_StatusTypeDef USBH_PTP_GetDevicePropDesc(USBH_HandleTypeDef *phost,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1080,7 +1069,7 @@ USBH_StatusTypeDef USBH_PTP_GetDeviceInfo(USBH_HandleTypeDef *phost, PTP_DeviceI
case PTP_REQ_SEND:
/* Set operation request type */
MTP_Handle->ptp.flags = PTP_DP_GETDATA;
- MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) &(MTP_Handle->ptp.data_container);
+ MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) & (MTP_Handle->ptp.data_container);
MTP_Handle->ptp.data_length = 0U;
MTP_Handle->ptp.data_packet_counter = 0U;
MTP_Handle->ptp.data_packet = 0U;
@@ -1092,7 +1081,7 @@ USBH_StatusTypeDef USBH_PTP_GetDeviceInfo(USBH_HandleTypeDef *phost, PTP_DeviceI
ptp_container.Nparam = 0U;
/* convert request packet inti USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1100,13 +1089,8 @@ USBH_StatusTypeDef USBH_PTP_GetDeviceInfo(USBH_HandleTypeDef *phost, PTP_DeviceI
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1142,7 +1126,7 @@ USBH_StatusTypeDef USBH_PTP_GetStorageIds(USBH_HandleTypeDef *phost, PTP_Storage
case PTP_REQ_SEND:
/* Set operation request type */
MTP_Handle->ptp.flags = PTP_DP_GETDATA;
- MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) &(MTP_Handle->ptp.data_container);
+ MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) & (MTP_Handle->ptp.data_container);
MTP_Handle->ptp.data_length = 0U;
MTP_Handle->ptp.data_packet_counter = 0U;
MTP_Handle->ptp.data_packet = 0U;
@@ -1154,7 +1138,7 @@ USBH_StatusTypeDef USBH_PTP_GetStorageIds(USBH_HandleTypeDef *phost, PTP_Storage
ptp_container.Nparam = 0U;
/* convert request packet inti USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1162,13 +1146,8 @@ USBH_StatusTypeDef USBH_PTP_GetStorageIds(USBH_HandleTypeDef *phost, PTP_Storage
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1206,7 +1185,7 @@ USBH_StatusTypeDef USBH_PTP_GetStorageInfo(USBH_HandleTypeDef *phost,
case PTP_REQ_SEND:
/* Set operation request type */
MTP_Handle->ptp.flags = PTP_DP_GETDATA;
- MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) &(MTP_Handle->ptp.data_container);
+ MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) & (MTP_Handle->ptp.data_container);
MTP_Handle->ptp.data_length = 0U;
MTP_Handle->ptp.data_packet_counter = 0U;
MTP_Handle->ptp.data_packet = 0U;
@@ -1219,7 +1198,7 @@ USBH_StatusTypeDef USBH_PTP_GetStorageInfo(USBH_HandleTypeDef *phost,
ptp_container.Nparam = 1U;
/* convert request packet inti USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1227,13 +1206,8 @@ USBH_StatusTypeDef USBH_PTP_GetStorageInfo(USBH_HandleTypeDef *phost,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1284,7 +1258,7 @@ USBH_StatusTypeDef USBH_PTP_GetNumObjects(USBH_HandleTypeDef *phost,
ptp_container.Nparam = 3U;
/* convert request packet into USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1292,13 +1266,8 @@ USBH_StatusTypeDef USBH_PTP_GetNumObjects(USBH_HandleTypeDef *phost,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1338,7 +1307,7 @@ USBH_StatusTypeDef USBH_PTP_GetObjectHandles(USBH_HandleTypeDef *phost,
case PTP_REQ_SEND:
/* Set operation request type */
MTP_Handle->ptp.flags = PTP_DP_GETDATA;
- MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) &(MTP_Handle->ptp.data_container);
+ MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) & (MTP_Handle->ptp.data_container);
MTP_Handle->ptp.data_length = 0U;
MTP_Handle->ptp.data_packet_counter = 0U;
MTP_Handle->ptp.data_packet = 0U;
@@ -1353,7 +1322,7 @@ USBH_StatusTypeDef USBH_PTP_GetObjectHandles(USBH_HandleTypeDef *phost,
ptp_container.Nparam = 3U;
/* convert request packet into USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1361,13 +1330,8 @@ USBH_StatusTypeDef USBH_PTP_GetObjectHandles(USBH_HandleTypeDef *phost,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1407,7 +1371,7 @@ USBH_StatusTypeDef USBH_PTP_GetObjectInfo(USBH_HandleTypeDef *phost,
case PTP_REQ_SEND:
/* Set operation request type */
MTP_Handle->ptp.flags = PTP_DP_GETDATA;
- MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) &(MTP_Handle->ptp.data_container);
+ MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) & (MTP_Handle->ptp.data_container);
MTP_Handle->ptp.data_length = 0U;
MTP_Handle->ptp.data_packet_counter = 0U;
MTP_Handle->ptp.data_packet = 0U;
@@ -1420,7 +1384,7 @@ USBH_StatusTypeDef USBH_PTP_GetObjectInfo(USBH_HandleTypeDef *phost,
ptp_container.Nparam = 1U;
/* convert request packet into USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1428,13 +1392,8 @@ USBH_StatusTypeDef USBH_PTP_GetObjectInfo(USBH_HandleTypeDef *phost,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1482,7 +1441,7 @@ USBH_StatusTypeDef USBH_PTP_DeleteObject(USBH_HandleTypeDef *phost,
ptp_container.Nparam = 2U;
/* convert request packet into USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1490,13 +1449,8 @@ USBH_StatusTypeDef USBH_PTP_DeleteObject(USBH_HandleTypeDef *phost,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1530,7 +1484,7 @@ USBH_StatusTypeDef USBH_PTP_GetObject(USBH_HandleTypeDef *phost,
/* Set operation request type */
MTP_Handle->ptp.flags = PTP_DP_GETDATA;
- MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) &(MTP_Handle->ptp.data_container);
+ MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) & (MTP_Handle->ptp.data_container);
MTP_Handle->ptp.data_length = 0U;
MTP_Handle->ptp.data_packet_counter = 0U;
MTP_Handle->ptp.data_packet = 0U;
@@ -1547,7 +1501,7 @@ USBH_StatusTypeDef USBH_PTP_GetObject(USBH_HandleTypeDef *phost,
/* convert request packet into USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1555,13 +1509,8 @@ USBH_StatusTypeDef USBH_PTP_GetObject(USBH_HandleTypeDef *phost,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1573,9 +1522,9 @@ USBH_StatusTypeDef USBH_PTP_GetObject(USBH_HandleTypeDef *phost,
if (MTP_Handle->ptp.iteration == 0U)
{
/* copy it to object */
- USBH_memcpy(MTP_Handle->ptp.object_ptr,
- MTP_Handle->ptp.data_container.payload.data,
- PTP_USB_BULK_PAYLOAD_LEN_READ);
+ (void)USBH_memcpy(MTP_Handle->ptp.object_ptr,
+ MTP_Handle->ptp.data_container.payload.data,
+ PTP_USB_BULK_PAYLOAD_LEN_READ);
}
}
break;
@@ -1609,7 +1558,7 @@ USBH_StatusTypeDef USBH_PTP_GetPartialObject(USBH_HandleTypeDef *phost,
case PTP_REQ_SEND:
/* Set operation request type */
MTP_Handle->ptp.flags = PTP_DP_GETDATA;
- MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) &(MTP_Handle->ptp.data_container);
+ MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) & (MTP_Handle->ptp.data_container);
MTP_Handle->ptp.data_length = 0U;
MTP_Handle->ptp.data_packet_counter = 0U;
MTP_Handle->ptp.data_packet = 0U;
@@ -1627,7 +1576,7 @@ USBH_StatusTypeDef USBH_PTP_GetPartialObject(USBH_HandleTypeDef *phost,
ptp_container.Nparam = 3U;
/* convert request packet into USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1635,13 +1584,8 @@ USBH_StatusTypeDef USBH_PTP_GetPartialObject(USBH_HandleTypeDef *phost,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1654,8 +1598,8 @@ USBH_StatusTypeDef USBH_PTP_GetPartialObject(USBH_HandleTypeDef *phost,
if (MTP_Handle->ptp.iteration == 0U)
{
/* copy it to object */
- USBH_memcpy(MTP_Handle->ptp.object_ptr,
- MTP_Handle->ptp.data_container.payload.data, *len);
+ (void)USBH_memcpy(MTP_Handle->ptp.object_ptr,
+ MTP_Handle->ptp.data_container.payload.data, *len);
}
}
break;
@@ -1687,7 +1631,7 @@ USBH_StatusTypeDef USBH_PTP_GetObjectPropsSupported(USBH_HandleTypeDef *phost,
case PTP_REQ_SEND:
/* Set operation request type */
MTP_Handle->ptp.flags = PTP_DP_GETDATA;
- MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) &(MTP_Handle->ptp.data_container);
+ MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) & (MTP_Handle->ptp.data_container);
MTP_Handle->ptp.data_length = 0U;
MTP_Handle->ptp.data_packet_counter = 0U;
MTP_Handle->ptp.data_packet = 0U;
@@ -1700,7 +1644,7 @@ USBH_StatusTypeDef USBH_PTP_GetObjectPropsSupported(USBH_HandleTypeDef *phost,
ptp_container.Nparam = 1U;
/* convert request packet into USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1708,13 +1652,8 @@ USBH_StatusTypeDef USBH_PTP_GetObjectPropsSupported(USBH_HandleTypeDef *phost,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1754,7 +1693,7 @@ USBH_StatusTypeDef USBH_PTP_GetObjectPropDesc(USBH_HandleTypeDef *phost,
/* Set operation request type */
MTP_Handle->ptp.flags = PTP_DP_GETDATA;
- MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) &(MTP_Handle->ptp.data_container);
+ MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) & (MTP_Handle->ptp.data_container);
MTP_Handle->ptp.data_length = 0U;
MTP_Handle->ptp.data_packet_counter = 0U;
MTP_Handle->ptp.data_packet = 0U;
@@ -1768,7 +1707,7 @@ USBH_StatusTypeDef USBH_PTP_GetObjectPropDesc(USBH_HandleTypeDef *phost,
ptp_container.Nparam = 2U;
/* convert request packet into USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1776,13 +1715,8 @@ USBH_StatusTypeDef USBH_PTP_GetObjectPropDesc(USBH_HandleTypeDef *phost,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1825,14 +1759,14 @@ USBH_StatusTypeDef USBH_PTP_GetObjectPropList(USBH_HandleTypeDef *phost,
/* Set operation request type */
MTP_Handle->ptp.flags = PTP_DP_GETDATA;
- MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) &(MTP_Handle->ptp.data_container);
+ MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) & (MTP_Handle->ptp.data_container);
MTP_Handle->ptp.data_length = 0U;
MTP_Handle->ptp.data_packet_counter = 0U;
MTP_Handle->ptp.data_packet = 0U;
/* copy first packet of the object into data container */
- USBH_memcpy(MTP_Handle->ptp.data_container.payload.data,
- MTP_Handle->ptp.object_ptr, PTP_USB_BULK_PAYLOAD_LEN_READ);
+ (void)USBH_memcpy(MTP_Handle->ptp.data_container.payload.data,
+ MTP_Handle->ptp.object_ptr, PTP_USB_BULK_PAYLOAD_LEN_READ);
/* Fill operation request params */
ptp_container.Code = PTP_OC_GetObjPropList;
@@ -1846,7 +1780,7 @@ USBH_StatusTypeDef USBH_PTP_GetObjectPropList(USBH_HandleTypeDef *phost,
ptp_container.Nparam = 5U;
/* convert request packet into USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1854,13 +1788,8 @@ USBH_StatusTypeDef USBH_PTP_GetObjectPropList(USBH_HandleTypeDef *phost,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1868,7 +1797,7 @@ USBH_StatusTypeDef USBH_PTP_GetObjectPropList(USBH_HandleTypeDef *phost,
if (status == USBH_OK)
{
- PTP_GetObjectPropList(phost, pprops, MTP_Handle->ptp.data_length);
+ (void)PTP_GetObjectPropList(phost, pprops, MTP_Handle->ptp.data_length);
}
break;
@@ -1902,7 +1831,7 @@ USBH_StatusTypeDef USBH_PTP_SendObject(USBH_HandleTypeDef *phost,
case PTP_REQ_SEND:
/* Set operation request type */
MTP_Handle->ptp.flags = PTP_DP_SENDDATA;
- MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) &(MTP_Handle->ptp.data_container);
+ MTP_Handle->ptp.data_ptr = (uint8_t *)(void *) & (MTP_Handle->ptp.data_container);
MTP_Handle->ptp.data_packet_counter = 0U;
MTP_Handle->ptp.data_packet = 0U;
MTP_Handle->ptp.iteration = 0U;
@@ -1918,7 +1847,7 @@ USBH_StatusTypeDef USBH_PTP_SendObject(USBH_HandleTypeDef *phost,
ptp_container.Nparam = 0U;
/* convert request packet into USB raw packet*/
- USBH_PTP_SendRequest(phost, &ptp_container);
+ (void)USBH_PTP_SendRequest(phost, &ptp_container);
/* Setup State machine and start transfer */
MTP_Handle->ptp.state = PTP_OP_REQUEST_STATE;
@@ -1926,13 +1855,8 @@ USBH_StatusTypeDef USBH_PTP_SendObject(USBH_HandleTypeDef *phost,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case PTP_REQ_WAIT:
@@ -1945,26 +1869,24 @@ USBH_StatusTypeDef USBH_PTP_SendObject(USBH_HandleTypeDef *phost,
return status;
}
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/Template/Inc/usbh_template.h b/system/Middlewares/ST/STM32_USB_Host_Library/Class/Template/Inc/usbh_template.h
index e6ba67d0fa..b7013b43e9 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/Template/Inc/usbh_template.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/Template/Inc/usbh_template.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -30,21 +29,21 @@ extern "C" {
/** @addtogroup USBH_LIB
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_CLASS
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_TEMPLATE_CLASS
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_TEMPLATE_CLASS
-* @brief This file is the Header file for usbh_template.c
-* @{
-*/
+ * @brief This file is the Header file for usbh_template.c
+ * @{
+ */
/**
@@ -52,49 +51,49 @@ extern "C" {
*/
/** @defgroup USBH_TEMPLATE_CLASS_Exported_Types
-* @{
-*/
+ * @{
+ */
/* States for TEMPLATE State Machine */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_TEMPLATE_CLASS_Exported_Defines
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_TEMPLATE_CLASS_Exported_Macros
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_TEMPLATE_CLASS_Exported_Variables
-* @{
-*/
+ * @{
+ */
extern USBH_ClassTypeDef TEMPLATE_Class;
#define USBH_TEMPLATE_CLASS &TEMPLATE_Class
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_TEMPLATE_CLASS_Exported_FunctionsPrototype
-* @{
-*/
+ * @{
+ */
USBH_StatusTypeDef USBH_TEMPLATE_IOProcess(USBH_HandleTypeDef *phost);
USBH_StatusTypeDef USBH_TEMPLATE_Init(USBH_HandleTypeDef *phost);
/**
-* @}
-*/
+ * @}
+ */
#ifdef __cplusplus
}
@@ -103,19 +102,18 @@ USBH_StatusTypeDef USBH_TEMPLATE_Init(USBH_HandleTypeDef *phost);
#endif /* __USBH_TEMPLATE_H */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Class/Template/Src/usbh_template.c b/system/Middlewares/ST/STM32_USB_Host_Library/Class/Template/Src/usbh_template.c
index 7d011223c5..f88c9d5d0e 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Class/Template/Src/usbh_template.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Class/Template/Src/usbh_template.c
@@ -8,13 +8,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -23,57 +22,57 @@
#include "usbh_template.h"
/** @addtogroup USBH_LIB
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_CLASS
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_TEMPLATE_CLASS
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_TEMPLATE_CORE
-* @brief This file includes TEMPLATE Layer Handlers for USB Host TEMPLATE class.
-* @{
-*/
+ * @brief This file includes TEMPLATE Layer Handlers for USB Host TEMPLATE class.
+ * @{
+ */
/** @defgroup USBH_TEMPLATE_CORE_Private_TypesDefinitions
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_TEMPLATE_CORE_Private_Defines
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_TEMPLATE_CORE_Private_Macros
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_TEMPLATE_CORE_Private_Variables
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_TEMPLATE_CORE_Private_FunctionPrototypes
-* @{
-*/
+ * @{
+ */
static USBH_StatusTypeDef USBH_TEMPLATE_InterfaceInit(USBH_HandleTypeDef *phost);
static USBH_StatusTypeDef USBH_TEMPLATE_InterfaceDeInit(USBH_HandleTypeDef *phost);
@@ -91,13 +90,13 @@ USBH_ClassTypeDef TEMPLATE_Class =
USBH_TEMPLATE_Process
};
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_TEMPLATE_CORE_Private_Functions
-* @{
-*/
+ * @{
+ */
/**
* @brief USBH_TEMPLATE_InterfaceInit
@@ -214,25 +213,24 @@ USBH_StatusTypeDef USBH_TEMPLATE_IOProcess(USBH_HandleTypeDef *phost)
}
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_conf_template.h b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_conf_template.h
index f345d3dde3..7ea43a4aaf 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_conf_template.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_conf_template.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -53,6 +52,7 @@ extern "C" {
#define USBH_MAX_DATA_BUFFER 0x200U
#define USBH_DEBUG_LEVEL 2U
#define USBH_USE_OS 1U
+#define USBH_IN_NAK_PROCESS 0
/** @defgroup USBH_Exported_Macros
* @{
@@ -67,9 +67,9 @@ extern "C" {
/* DEBUG macros */
#if (USBH_DEBUG_LEVEL > 0U)
#define USBH_UsrLog(...) do { \
- printf(__VA_ARGS__); \
- printf("\n"); \
-} while (0)
+ printf(__VA_ARGS__); \
+ printf("\n"); \
+ } while (0)
#else
#define USBH_UsrLog(...) do {} while (0)
#endif
@@ -77,20 +77,20 @@ extern "C" {
#if (USBH_DEBUG_LEVEL > 1U)
#define USBH_ErrLog(...) do { \
- printf("ERROR: ") ; \
- printf(__VA_ARGS__); \
- printf("\n"); \
-} while (0)
+ printf("ERROR: "); \
+ printf(__VA_ARGS__); \
+ printf("\n"); \
+ } while (0)
#else
#define USBH_ErrLog(...) do {} while (0)
#endif
#if (USBH_DEBUG_LEVEL > 2U)
#define USBH_DbgLog(...) do { \
- printf("DEBUG : ") ; \
- printf(__VA_ARGS__); \
- printf("\n"); \
-} while (0)
+ printf("DEBUG : "); \
+ printf(__VA_ARGS__); \
+ printf("\n"); \
+ } while (0)
#else
#define USBH_DbgLog(...) do {} while (0)
#endif
@@ -149,4 +149,3 @@ extern "C" {
/**
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_core.h b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_core.h
index 1be86e98c7..843d435a26 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_core.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_core.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -36,8 +35,8 @@ extern "C" {
*/
/** @addtogroup USBH_LIB_CORE
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_CORE
* @brief This file is the Header file for usbh_core.c
@@ -85,86 +84,75 @@ extern "C" {
/** @defgroup USBH_CORE_Exported_FunctionsPrototype
* @{
*/
-
-
-USBH_StatusTypeDef USBH_Init(USBH_HandleTypeDef *phost, void (*pUsrFunc)(USBH_HandleTypeDef *phost, uint8_t id), uint8_t id);
-USBH_StatusTypeDef USBH_DeInit(USBH_HandleTypeDef *phost);
-USBH_StatusTypeDef USBH_RegisterClass(USBH_HandleTypeDef *phost, USBH_ClassTypeDef *pclass);
-USBH_StatusTypeDef USBH_SelectInterface(USBH_HandleTypeDef *phost, uint8_t interface);
-uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost,
- uint8_t Class,
- uint8_t SubClass,
- uint8_t Protocol);
-uint8_t USBH_GetActiveClass(USBH_HandleTypeDef *phost);
-
-uint8_t USBH_FindInterfaceIndex(USBH_HandleTypeDef *phost,
- uint8_t interface_number,
- uint8_t alt_settings);
-
-uint8_t USBH_IsPortEnabled(USBH_HandleTypeDef *phost);
-
-USBH_StatusTypeDef USBH_Start(USBH_HandleTypeDef *phost);
-USBH_StatusTypeDef USBH_Stop(USBH_HandleTypeDef *phost);
-USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost);
-USBH_StatusTypeDef USBH_ReEnumerate(USBH_HandleTypeDef *phost);
+USBH_StatusTypeDef USBH_Init(USBH_HandleTypeDef *phost,
+ void (*pUsrFunc)(USBH_HandleTypeDef *phost, uint8_t id), uint8_t id);
+
+USBH_StatusTypeDef USBH_DeInit(USBH_HandleTypeDef *phost);
+USBH_StatusTypeDef USBH_Start(USBH_HandleTypeDef *phost);
+USBH_StatusTypeDef USBH_Stop(USBH_HandleTypeDef *phost);
+USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost);
+USBH_StatusTypeDef USBH_ReEnumerate(USBH_HandleTypeDef *phost);
+USBH_StatusTypeDef USBH_RegisterClass(USBH_HandleTypeDef *phost, USBH_ClassTypeDef *pclass);
+USBH_StatusTypeDef USBH_SelectInterface(USBH_HandleTypeDef *phost, uint8_t interface);
+
+uint8_t USBH_FindInterfaceIndex(USBH_HandleTypeDef *phost, uint8_t interface_number, uint8_t alt_settings);
+uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost, uint8_t Class, uint8_t SubClass, uint8_t Protocol);
+uint8_t USBH_GetActiveClass(USBH_HandleTypeDef *phost);
+uint8_t USBH_IsPortEnabled(USBH_HandleTypeDef *phost);
/* USBH Low Level Driver */
-USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost);
-USBH_StatusTypeDef USBH_LL_DeInit(USBH_HandleTypeDef *phost);
-USBH_StatusTypeDef USBH_LL_Start(USBH_HandleTypeDef *phost);
-USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost);
-
-USBH_StatusTypeDef USBH_LL_Connect(USBH_HandleTypeDef *phost);
-USBH_StatusTypeDef USBH_LL_Disconnect(USBH_HandleTypeDef *phost);
-USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost);
-USBH_StatusTypeDef USBH_LL_ResetPort(USBH_HandleTypeDef *phost);
-uint32_t USBH_LL_GetLastXferSize(USBH_HandleTypeDef *phost,
- uint8_t pipe);
-
-USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost,
- uint8_t state);
-
-USBH_StatusTypeDef USBH_LL_OpenPipe(USBH_HandleTypeDef *phost,
- uint8_t pipe,
- uint8_t epnum,
- uint8_t dev_address,
- uint8_t speed,
- uint8_t ep_type,
- uint16_t mps);
-
-USBH_StatusTypeDef USBH_LL_ClosePipe(USBH_HandleTypeDef *phost,
- uint8_t pipe);
-
-USBH_StatusTypeDef USBH_LL_SubmitURB(USBH_HandleTypeDef *phost,
- uint8_t pipe,
- uint8_t direction,
- uint8_t ep_type,
- uint8_t token,
- uint8_t *pbuff,
- uint16_t length,
- uint8_t do_ping);
-
-USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost,
- uint8_t pipe);
+USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost);
+USBH_StatusTypeDef USBH_LL_DeInit(USBH_HandleTypeDef *phost);
+USBH_StatusTypeDef USBH_LL_Start(USBH_HandleTypeDef *phost);
+USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost);
+
+USBH_StatusTypeDef USBH_LL_Connect(USBH_HandleTypeDef *phost);
+USBH_StatusTypeDef USBH_LL_Disconnect(USBH_HandleTypeDef *phost);
+USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost);
+USBH_StatusTypeDef USBH_LL_ResetPort(USBH_HandleTypeDef *phost);
+uint32_t USBH_LL_GetLastXferSize(USBH_HandleTypeDef *phost, uint8_t pipe);
+
+USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state);
+
+USBH_StatusTypeDef USBH_LL_OpenPipe(USBH_HandleTypeDef *phost,
+ uint8_t pipe,
+ uint8_t epnum,
+ uint8_t dev_address,
+ uint8_t speed,
+ uint8_t ep_type,
+ uint16_t mps);
+
+USBH_StatusTypeDef USBH_LL_ActivatePipe(USBH_HandleTypeDef *phost, uint8_t pipe);
+USBH_StatusTypeDef USBH_LL_ClosePipe(USBH_HandleTypeDef *phost, uint8_t pipe);
+
+USBH_StatusTypeDef USBH_LL_SubmitURB(USBH_HandleTypeDef *phost,
+ uint8_t pipe,
+ uint8_t direction,
+ uint8_t ep_type,
+ uint8_t token,
+ uint8_t *pbuff,
+ uint16_t length,
+ uint8_t do_ping);
+
+USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pipe);
#if (USBH_USE_OS == 1U)
-USBH_StatusTypeDef USBH_LL_NotifyURBChange(USBH_HandleTypeDef *phost);
-#endif
+USBH_StatusTypeDef USBH_LL_NotifyURBChange(USBH_HandleTypeDef *phost);
+void USBH_OS_PutMessage(USBH_HandleTypeDef *phost, USBH_OSEventTypeDef message, uint32_t timeout, uint32_t priority);
+#endif /*(USBH_USE_OS == 1U) */
-USBH_StatusTypeDef USBH_LL_SetToggle(USBH_HandleTypeDef *phost,
- uint8_t pipe, uint8_t toggle);
+USBH_StatusTypeDef USBH_LL_SetToggle(USBH_HandleTypeDef *phost, uint8_t pipe, uint8_t toggle);
uint8_t USBH_LL_GetToggle(USBH_HandleTypeDef *phost, uint8_t pipe);
-void USBH_LL_PortDisabled(USBH_HandleTypeDef *phost);
-void USBH_LL_PortEnabled(USBH_HandleTypeDef *phost);
+void USBH_LL_PortDisabled(USBH_HandleTypeDef *phost);
+void USBH_LL_PortEnabled(USBH_HandleTypeDef *phost);
/* USBH Time base */
void USBH_LL_SetTimer(USBH_HandleTypeDef *phost, uint32_t time);
void USBH_LL_IncTimer(USBH_HandleTypeDef *phost);
void USBH_Delay(uint32_t Delay);
-
/**
* @}
*/
@@ -183,10 +171,8 @@ void USBH_Delay(uint32_t Delay);
*/
/**
-* @}
-*/
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_ctlreq.h b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_ctlreq.h
index ca6ca6afb3..b12c1380ca 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_ctlreq.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_ctlreq.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -33,8 +32,8 @@ extern "C" {
*/
/** @addtogroup USBH_LIB_CORE
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_CTLREQ
* @brief This file is the
@@ -93,7 +92,7 @@ USBH_StatusTypeDef USBH_GetDescriptor(USBH_HandleTypeDef *phost,
uint8_t req_type, uint16_t value_idx,
uint8_t *buff, uint16_t length);
-USBH_StatusTypeDef USBH_Get_DevDesc(USBH_HandleTypeDef *phost, uint8_t length);
+USBH_StatusTypeDef USBH_Get_DevDesc(USBH_HandleTypeDef *phost, uint16_t length);
USBH_StatusTypeDef USBH_Get_StringDesc(USBH_HandleTypeDef *phost,
uint8_t string_index, uint8_t *buff,
@@ -133,9 +132,7 @@ USBH_DescHeader_t *USBH_GetNextDesc(uint8_t *pbuf, uint16_t *ptr);
*/
/**
-* @}
-*/
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_def.h b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_def.h
index 8ce334dc3c..431692a847 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_def.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_def.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -33,8 +32,8 @@ extern "C" {
*/
/** @addtogroup USBH_LIB_CORE
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_DEF
* @brief This file is includes USB descriptors
@@ -61,6 +60,14 @@ extern "C" {
#define SetBit(VAR,POS) (VAR |= (1 << POS))
#define ClrBit(VAR,POS) (VAR &= ((1 << POS)^255))
+#ifndef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
#define LE16(addr) (((uint16_t)(addr)[0]) | \
((uint16_t)(((uint32_t)(addr)[1]) << 8)))
@@ -87,7 +94,11 @@ extern "C" {
#define LE32S(addr) ((int32_t)(LE32((addr))))
#define LE64S(addr) ((int64_t)(LE64((addr))))
+#ifndef USBH_MAX_DATA_BUFFER
+#define USBH_MAX_DATA_BUFFER 0x400U
+#endif
+#define USBH_MAX_EP_PACKET_SIZE 0x400U
#define USB_LEN_DESC_HDR 0x02U
#define USB_LEN_DEV_DESC 0x12U
@@ -171,9 +182,13 @@ extern "C" {
#define USB_EP_DIR_MSK 0x80U
#ifndef USBH_MAX_PIPES_NBR
-#define USBH_MAX_PIPES_NBR 15U
+#define USBH_MAX_PIPES_NBR 16U
#endif /* USBH_MAX_PIPES_NBR */
+#ifndef USBH_NAK_SOF_COUNT
+#define USBH_NAK_SOF_COUNT 0x01U
+#endif /* USBH_NAK_SOF_COUNT */
+
#define USBH_DEVICE_ADDRESS_DEFAULT 0x00U
#define USBH_DEVICE_ADDRESS 0x01U
@@ -181,7 +196,7 @@ extern "C" {
#if (USBH_USE_OS == 1U)
#define MSGQUEUE_OBJECTS 0x10U
-#endif
+#endif /* (USBH_USE_OS == 1U) */
/**
@@ -190,12 +205,12 @@ extern "C" {
#define USBH_CONFIGURATION_DESCRIPTOR_SIZE (USB_CONFIGURATION_DESC_SIZE \
- + USB_INTERFACE_DESC_SIZE\
- + (USBH_MAX_NUM_ENDPOINTS * USB_ENDPOINT_DESC_SIZE))
+ + USB_INTERFACE_DESC_SIZE\
+ + (USBH_MAX_NUM_ENDPOINTS * USB_ENDPOINT_DESC_SIZE))
#define CONFIG_DESC_wTOTAL_LENGTH (ConfigurationDescriptorData.ConfigDescfield.\
- ConfigurationDescriptor.wTotalLength)
+ ConfigurationDescriptor.wTotalLength)
typedef union
@@ -245,9 +260,9 @@ typedef struct _DeviceDescriptor
code if equal to 0xFF, the class code is vendor specified.
Otherwise field is valid Class Code.*/
uint8_t bMaxPacketSize;
- uint16_t idVendor; /* Vendor ID (Assigned by USB Org) */
- uint16_t idProduct; /* Product ID (Assigned by Manufacturer) */
- uint16_t bcdDevice; /* Device Release Number */
+ uint16_t idVendor; /* Vendor ID (Assigned by USB Org) */
+ uint16_t idProduct; /* Product ID (Assigned by Manufacturer) */
+ uint16_t bcdDevice; /* Device Release Number */
uint8_t iManufacturer; /* Index of Manufacturer String Descriptor */
uint8_t iProduct; /* Index of Product String Descriptor */
uint8_t iSerialNumber; /* Index of Serial Number String Descriptor */
@@ -261,7 +276,7 @@ typedef struct _EndpointDescriptor
uint8_t bDescriptorType;
uint8_t bEndpointAddress; /* indicates what endpoint this descriptor is describing */
uint8_t bmAttributes; /* specifies the transfer type. */
- uint16_t wMaxPacketSize; /* Maximum Packet Size this endpoint is capable of sending or receiving */
+ uint16_t wMaxPacketSize; /* Maximum Packet Size this endpoint is capable of sending or receiving */
uint8_t bInterval; /* is used to specify the polling interval of certain transfers. */
}
USBH_EpDescTypeDef;
@@ -286,12 +301,12 @@ typedef struct _ConfigurationDescriptor
{
uint8_t bLength;
uint8_t bDescriptorType;
- uint16_t wTotalLength; /* Total Length of Data Returned */
+ uint16_t wTotalLength; /* Total Length of Data Returned */
uint8_t bNumInterfaces; /* Number of Interfaces */
uint8_t bConfigurationValue; /* Value to use as an argument to select this configuration*/
- uint8_t iConfiguration; /*Index of String Descriptor Describing this configuration */
+ uint8_t iConfiguration; /* Index of String Descriptor Describing this configuration */
uint8_t bmAttributes; /* D7 Bus Powered , D6 Self Powered, D5 Remote Wakeup , D4..0 Reserved (0)*/
- uint8_t bMaxPower; /*Maximum Power Consumption */
+ uint8_t bMaxPower; /* Maximum Power Consumption */
USBH_InterfaceDescTypeDef Itf_Desc[USBH_MAX_NUM_INTERFACES];
}
USBH_CfgDescTypeDef;
@@ -388,7 +403,8 @@ typedef enum
USBH_URB_NOTREADY,
USBH_URB_NYET,
USBH_URB_ERROR,
- USBH_URB_STALL
+ USBH_URB_STALL,
+ USBH_URB_NAK_WAIT
} USBH_URBStateTypeDef;
typedef enum
@@ -428,7 +444,7 @@ typedef struct
__IO uint8_t is_connected;
__IO uint8_t is_disconnected;
__IO uint8_t is_ReEnumerated;
- uint8_t PortEnabled;
+ __IO uint8_t PortEnabled;
uint8_t current_interface;
USBH_DevDescTypeDef DevDesc;
USBH_CfgDescTypeDef CfgDesc;
@@ -462,6 +478,10 @@ typedef struct _USBH_HandleTypeDef
uint32_t ClassNumber;
uint32_t Pipes[16];
__IO uint32_t Timer;
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ uint32_t NakTimer;
+ uint32_t NakTimeout;
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
uint32_t Timeout;
uint8_t id;
void *pData;
@@ -476,7 +496,7 @@ typedef struct _USBH_HandleTypeDef
osThreadId_t thread;
#endif
uint32_t os_msg;
-#endif
+#endif /* (USBH_USE_OS == 1U) */
} USBH_HandleTypeDef;
@@ -496,5 +516,4 @@ typedef struct _USBH_HandleTypeDef
#endif /* USBH_DEF_H */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_ioreq.h b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_ioreq.h
index 8c13a20c90..cf7c98396a 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_ioreq.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_ioreq.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -34,8 +33,8 @@ extern "C" {
*/
/** @addtogroup USBH_LIB_CORE
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_IOREQ
* @brief This file is the header file for usbh_ioreq.c
@@ -152,9 +151,7 @@ USBH_StatusTypeDef USBH_IsocSendData(USBH_HandleTypeDef *phost,
*/
/**
-* @}
-*/
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_pipes.h b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_pipes.h
index ed2247ea73..023eb3ac45 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_pipes.h
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Inc/usbh_pipes.h
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -33,8 +32,8 @@ extern "C" {
*/
/** @addtogroup USBH_LIB_CORE
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_PIPES
* @brief This file is the header file for usbh_pipes.c
@@ -91,8 +90,10 @@ uint8_t USBH_AllocPipe(USBH_HandleTypeDef *phost,
USBH_StatusTypeDef USBH_FreePipe(USBH_HandleTypeDef *phost,
uint8_t idx);
-
-
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+USBH_StatusTypeDef USBH_ActivatePipe(USBH_HandleTypeDef *phost,
+ uint8_t pipe_num);
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
/**
* @}
@@ -115,9 +116,7 @@ USBH_StatusTypeDef USBH_FreePipe(USBH_HandleTypeDef *phost,
*/
/**
-* @}
-*/
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_conf_template.c b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_conf_template.c
index aebb0bad07..07822e700f 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_conf_template.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_conf_template.c
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -26,7 +25,7 @@
* @param phost: Host handle
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost)
+USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
@@ -40,7 +39,7 @@ USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost)
* @param phost: Host handle
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_LL_DeInit(USBH_HandleTypeDef *phost)
+USBH_StatusTypeDef USBH_LL_DeInit(USBH_HandleTypeDef *phost)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
@@ -54,7 +53,7 @@ USBH_StatusTypeDef USBH_LL_DeInit(USBH_HandleTypeDef *phost)
* @param phost: Host handle
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_LL_Start(USBH_HandleTypeDef *phost)
+USBH_StatusTypeDef USBH_LL_Start(USBH_HandleTypeDef *phost)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
@@ -68,7 +67,7 @@ USBH_StatusTypeDef USBH_LL_Start(USBH_HandleTypeDef *phost)
* @param phost: Host handle
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost)
+USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
@@ -126,7 +125,7 @@ uint32_t USBH_LL_GetLastXferSize(USBH_HandleTypeDef *phost, uint8_t pipe)
* @brief USBH_LL_OpenPipe
* Open a pipe of the Low Level Driver.
* @param phost: Host handle
- * @param pipe_num: Pipe index
+ * @param pipe: Pipe index
* @param epnum: Endpoint Number
* @param dev_address: Device USB address
* @param speed: Device Speed
@@ -134,17 +133,17 @@ uint32_t USBH_LL_GetLastXferSize(USBH_HandleTypeDef *phost, uint8_t pipe)
* @param mps: Endpoint Max Packet Size
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_LL_OpenPipe(USBH_HandleTypeDef *phost,
- uint8_t pipe_num,
- uint8_t epnum,
- uint8_t dev_address,
- uint8_t speed,
- uint8_t ep_type,
- uint16_t mps)
+USBH_StatusTypeDef USBH_LL_OpenPipe(USBH_HandleTypeDef *phost,
+ uint8_t pipe,
+ uint8_t epnum,
+ uint8_t dev_address,
+ uint8_t speed,
+ uint8_t ep_type,
+ uint16_t mps)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
- UNUSED(pipe_num);
+ UNUSED(pipe);
UNUSED(epnum);
UNUSED(dev_address);
UNUSED(speed);
@@ -158,10 +157,26 @@ USBH_StatusTypeDef USBH_LL_OpenPipe(USBH_HandleTypeDef *phost,
* @brief USBH_LL_ClosePipe
* Close a pipe of the Low Level Driver.
* @param phost: Host handle
- * @param pipe_num: Pipe index
+ * @param pipe: Pipe index
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_LL_ClosePipe(USBH_HandleTypeDef *phost, uint8_t pipe)
+USBH_StatusTypeDef USBH_LL_ClosePipe(USBH_HandleTypeDef *phost, uint8_t pipe)
+{
+ /* Prevent unused argument(s) compilation warning */
+ UNUSED(phost);
+ UNUSED(pipe);
+
+ return USBH_OK;
+}
+
+/**
+ * @brief USBH_LL_ActivatePipe
+ * Activate a pipe of the Low Level Driver.
+ * @param phost: Host handle
+ * @param pipe: Pipe index
+ * @retval USBH Status
+ */
+USBH_StatusTypeDef USBH_LL_ActivatePipe(USBH_HandleTypeDef *phost, uint8_t pipe)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
@@ -198,15 +213,14 @@ USBH_StatusTypeDef USBH_LL_ClosePipe(USBH_HandleTypeDef *phost, uint8_t pipe)
* 1 : do ping active
* @retval Status
*/
-
-USBH_StatusTypeDef USBH_LL_SubmitURB(USBH_HandleTypeDef *phost,
- uint8_t pipe,
- uint8_t direction,
- uint8_t ep_type,
- uint8_t token,
- uint8_t *pbuff,
- uint16_t length,
- uint8_t do_ping)
+USBH_StatusTypeDef USBH_LL_SubmitURB(USBH_HandleTypeDef *phost,
+ uint8_t pipe,
+ uint8_t direction,
+ uint8_t ep_type,
+ uint8_t token,
+ uint8_t *pbuff,
+ uint16_t length,
+ uint8_t do_ping)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
@@ -236,7 +250,7 @@ USBH_StatusTypeDef USBH_LL_SubmitURB(USBH_HandleTypeDef *phost,
* @arg URB_ERROR
* @arg URB_STALL
*/
-USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pipe)
+USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pipe)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
@@ -251,12 +265,11 @@ USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t pip
* @param phost: Host handle
* @param state : VBUS state
* This parameter can be one of the these values:
- * 0 : VBUS Active
- * 1 : VBUS Inactive
+ * 0 : VBUS Inactive
+ * 1 : VBUS Active
* @retval Status
*/
-
-USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state)
+USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
@@ -274,7 +287,7 @@ USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t state)
* @param toggle: toggle (0/1)
* @retval Status
*/
-USBH_StatusTypeDef USBH_LL_SetToggle(USBH_HandleTypeDef *phost, uint8_t pipe, uint8_t toggle)
+USBH_StatusTypeDef USBH_LL_SetToggle(USBH_HandleTypeDef *phost, uint8_t pipe, uint8_t toggle)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
@@ -291,7 +304,7 @@ USBH_StatusTypeDef USBH_LL_SetToggle(USBH_HandleTypeDef *phost, uint8_t pipe,
* @param pipe: Pipe index
* @retval toggle (0/1)
*/
-uint8_t USBH_LL_GetToggle(USBH_HandleTypeDef *phost, uint8_t pipe)
+uint8_t USBH_LL_GetToggle(USBH_HandleTypeDef *phost, uint8_t pipe)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(phost);
@@ -301,15 +314,15 @@ uint8_t USBH_LL_GetToggle(USBH_HandleTypeDef *phost, uint8_t pipe)
return toggle;
}
+
/**
* @brief USBH_Delay
* Delay routine for the USB Host Library
* @param Delay: Delay in ms
* @retval None
*/
-void USBH_Delay(uint32_t Delay)
+void USBH_Delay(uint32_t Delay)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(Delay);
}
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c
index 76874c4f26..6e5bd61c7b 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c
@@ -7,13 +7,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -62,7 +61,7 @@
#if (osCMSIS >= 0x20000U)
osThreadAttr_t USBH_Thread_Atrr;
#endif
-#endif
+#endif /* (USBH_USE_OS == 1U) */
/**
@@ -82,8 +81,8 @@ static USBH_StatusTypeDef DeInitStateMachine(USBH_HandleTypeDef *phost);
static void USBH_Process_OS(void const *argument);
#else
static void USBH_Process_OS(void *argument);
-#endif
-#endif
+#endif /* (osCMSIS < 0x20000U) */
+#endif /* (USBH_USE_OS == 1U) */
/**
@@ -93,9 +92,9 @@ static void USBH_Process_OS(void *argument);
* @param pUsrFunc: User Callback
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_Init(USBH_HandleTypeDef *phost,
- void (*pUsrFunc)(USBH_HandleTypeDef *phost,
- uint8_t id), uint8_t id)
+USBH_StatusTypeDef USBH_Init(USBH_HandleTypeDef *phost,
+ void (*pUsrFunc)(USBH_HandleTypeDef *phost,
+ uint8_t id), uint8_t id)
{
/* Check whether the USB Host handle is valid */
if (phost == NULL)
@@ -112,7 +111,7 @@ USBH_StatusTypeDef USBH_Init(USBH_HandleTypeDef *phost,
phost->ClassNumber = 0U;
/* Restore default states and prepare EP0 */
- DeInitStateMachine(phost);
+ (void)DeInitStateMachine(phost);
/* Restore default Device connection states */
phost->device.PortEnabled = 0U;
@@ -163,7 +162,7 @@ USBH_StatusTypeDef USBH_Init(USBH_HandleTypeDef *phost,
#endif /* (USBH_USE_OS == 1U) */
/* Initialize low level driver */
- USBH_LL_Init(phost);
+ (void)USBH_LL_Init(phost);
return USBH_OK;
}
@@ -177,7 +176,7 @@ USBH_StatusTypeDef USBH_Init(USBH_HandleTypeDef *phost,
*/
USBH_StatusTypeDef USBH_DeInit(USBH_HandleTypeDef *phost)
{
- DeInitStateMachine(phost);
+ (void)DeInitStateMachine(phost);
/* Restore default Device connection states */
phost->device.PortEnabled = 0U;
@@ -189,9 +188,25 @@ USBH_StatusTypeDef USBH_DeInit(USBH_HandleTypeDef *phost)
if (phost->pData != NULL)
{
- USBH_LL_Stop(phost);
+ (void)USBH_LL_Stop(phost);
}
+#if (USBH_USE_OS == 1U)
+#if (osCMSIS < 0x20000U)
+
+ /* Free allocated resource for USBH process */
+ (void)osThreadTerminate(phost->thread);
+ (void)osMessageDelete(phost->os_event);
+
+#else
+
+ /* Free allocated resource for USBH process */
+ (void)osThreadTerminate(phost->thread);
+ (void)osMessageQueueDelete(phost->os_event);
+
+#endif /* (osCMSIS < 0x20000U) */
+#endif /* (USBH_USE_OS == 1U) */
+
return USBH_OK;
}
@@ -204,7 +219,7 @@ USBH_StatusTypeDef USBH_DeInit(USBH_HandleTypeDef *phost)
*/
static USBH_StatusTypeDef DeInitStateMachine(USBH_HandleTypeDef *phost)
{
- uint32_t i = 0U;
+ uint32_t i;
/* Clear Pipes flags*/
for (i = 0U; i < USBH_MAX_PIPES_NBR; i++)
@@ -227,10 +242,16 @@ static USBH_StatusTypeDef DeInitStateMachine(USBH_HandleTypeDef *phost)
phost->Control.errorcount = 0U;
phost->device.address = USBH_ADDRESS_DEFAULT;
- phost->device.speed = USBH_SPEED_FULL;
+ phost->device.speed = (uint8_t)USBH_SPEED_FULL;
phost->device.RstCnt = 0U;
phost->device.EnumCnt = 0U;
+ /* Reset the device struct */
+ USBH_memset(&phost->device.CfgDesc_Raw, 0, sizeof(phost->device.CfgDesc_Raw));
+ USBH_memset(&phost->device.Data, 0, sizeof(phost->device.Data));
+ USBH_memset(&phost->device.DevDesc, 0, sizeof(phost->device.DevDesc));
+ USBH_memset(&phost->device.CfgDesc, 0, sizeof(phost->device.CfgDesc));
+
return USBH_OK;
}
@@ -322,13 +343,13 @@ uint8_t USBH_GetActiveClass(USBH_HandleTypeDef *phost)
* @retval interface index in the configuration structure
* @note : (1)interface index 0xFF means interface index not found
*/
-uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost, uint8_t Class, uint8_t SubClass, uint8_t Protocol)
+uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost, uint8_t Class, uint8_t SubClass, uint8_t Protocol)
{
USBH_InterfaceDescTypeDef *pif;
USBH_CfgDescTypeDef *pcfg;
uint8_t if_ix = 0U;
- pif = (USBH_InterfaceDescTypeDef *)0;
+ pif = (USBH_InterfaceDescTypeDef *)NULL;
pcfg = &phost->device.CfgDesc;
while (if_ix < USBH_MAX_NUM_INTERFACES)
@@ -355,13 +376,13 @@ uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost, uint8_t Class, uint8_t Su
* @retval interface index in the configuration structure
* @note : (1)interface index 0xFF means interface index not found
*/
-uint8_t USBH_FindInterfaceIndex(USBH_HandleTypeDef *phost, uint8_t interface_number, uint8_t alt_settings)
+uint8_t USBH_FindInterfaceIndex(USBH_HandleTypeDef *phost, uint8_t interface_number, uint8_t alt_settings)
{
USBH_InterfaceDescTypeDef *pif;
USBH_CfgDescTypeDef *pcfg;
uint8_t if_ix = 0U;
- pif = (USBH_InterfaceDescTypeDef *)0;
+ pif = (USBH_InterfaceDescTypeDef *)NULL;
pcfg = &phost->device.CfgDesc;
while (if_ix < USBH_MAX_NUM_INTERFACES)
@@ -383,13 +404,13 @@ uint8_t USBH_FindInterfaceIndex(USBH_HandleTypeDef *phost, uint8_t interface_nu
* @param phost: Host Handle
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_Start(USBH_HandleTypeDef *phost)
+USBH_StatusTypeDef USBH_Start(USBH_HandleTypeDef *phost)
{
/* Start the low level driver */
- USBH_LL_Start(phost);
+ (void)USBH_LL_Start(phost);
/* Activate VBUS on the port */
- USBH_LL_DriverVBUS(phost, TRUE);
+ (void)USBH_LL_DriverVBUS(phost, TRUE);
return USBH_OK;
}
@@ -401,17 +422,17 @@ USBH_StatusTypeDef USBH_Start(USBH_HandleTypeDef *phost)
* @param phost: Host Handle
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_Stop(USBH_HandleTypeDef *phost)
+USBH_StatusTypeDef USBH_Stop(USBH_HandleTypeDef *phost)
{
/* DeActivate VBUS on the port */
- USBH_LL_DriverVBUS(phost, FALSE);
+ (void)USBH_LL_DriverVBUS(phost, FALSE);
/* Stop and cleanup the low level driver */
- USBH_LL_Stop(phost);
+ (void)USBH_LL_Stop(phost);
/* Free Control Pipes */
- USBH_FreePipe(phost, phost->Control.pipe_in);
- USBH_FreePipe(phost, phost->Control.pipe_out);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_in);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_out);
return USBH_OK;
}
@@ -425,24 +446,19 @@ USBH_StatusTypeDef USBH_Stop(USBH_HandleTypeDef *phost)
*/
USBH_StatusTypeDef USBH_ReEnumerate(USBH_HandleTypeDef *phost)
{
- if (USBH_IsPortEnabled(phost))
+ if (USBH_IsPortEnabled(phost) != 0U)
{
phost->device.is_ReEnumerated = 1U;
/* Stop Host */
- USBH_Stop(phost);
+ (void)USBH_Stop(phost);
phost->device.is_disconnected = 1U;
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_PORT_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_PORT_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
return USBH_OK;
}
@@ -454,7 +470,7 @@ USBH_StatusTypeDef USBH_ReEnumerate(USBH_HandleTypeDef *phost)
* @param phost: Host Handle
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
+USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
{
__IO USBH_StatusTypeDef status = USBH_FAIL;
uint8_t idx = 0U;
@@ -469,27 +485,22 @@ USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
{
case HOST_IDLE :
- if (phost->device.is_connected)
+ if ((phost->device.is_connected) != 0U)
{
USBH_UsrLog("USB Device Connected");
/* Wait for 200 ms after connection */
phost->gState = HOST_DEV_WAIT_FOR_ATTACHMENT;
USBH_Delay(200U);
- USBH_LL_ResetPort(phost);
+ (void)USBH_LL_ResetPort(phost);
/* Make sure to start with Default address */
phost->device.address = USBH_ADDRESS_DEFAULT;
phost->Timeout = 0U;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_PORT_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_PORT_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
break;
@@ -523,14 +534,10 @@ USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
USBH_Delay(10U);
}
}
+
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_PORT_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_PORT_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case HOST_DEV_ATTACHED :
@@ -543,7 +550,11 @@ USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
/* Wait for 100 ms after Reset */
USBH_Delay(100U);
- phost->device.speed = USBH_LL_GetSpeed(phost);
+ phost->device.speed = (uint8_t)USBH_LL_GetSpeed(phost);
+
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ phost->NakTimeout = USBH_NAK_SOF_COUNT;
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
phost->gState = HOST_ENUMERATION;
@@ -551,23 +562,18 @@ USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
phost->Control.pipe_in = USBH_AllocPipe(phost, 0x80U);
/* Open Control pipes */
- USBH_OpenPipe(phost, phost->Control.pipe_in, 0x80U,
- phost->device.address, phost->device.speed,
- USBH_EP_CONTROL, (uint16_t)phost->Control.pipe_size);
+ (void)USBH_OpenPipe(phost, phost->Control.pipe_in, 0x80U,
+ phost->device.address, phost->device.speed,
+ USBH_EP_CONTROL, (uint16_t)phost->Control.pipe_size);
/* Open Control pipes */
- USBH_OpenPipe(phost, phost->Control.pipe_out, 0x00U,
- phost->device.address, phost->device.speed,
- USBH_EP_CONTROL, (uint16_t)phost->Control.pipe_size);
+ (void)USBH_OpenPipe(phost, phost->Control.pipe_out, 0x00U,
+ phost->device.address, phost->device.speed,
+ USBH_EP_CONTROL, (uint16_t)phost->Control.pipe_size);
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_PORT_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_PORT_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case HOST_ENUMERATION:
@@ -589,14 +595,10 @@ USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
{
phost->gState = HOST_INPUT;
}
+
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
break;
@@ -609,13 +611,8 @@ USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
phost->gState = HOST_SET_CONFIGURATION;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
}
break;
@@ -629,24 +626,30 @@ USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_PORT_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_PORT_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case HOST_SET_WAKEUP_FEATURE:
- if ((phost->device.CfgDesc.bmAttributes) & (1U << 5))
+ if (((phost->device.CfgDesc.bmAttributes) & (1U << 5)) != 0U)
{
- if (USBH_SetFeature(phost, FEATURE_SELECTOR_REMOTEWAKEUP) == USBH_OK)
+ status = USBH_SetFeature(phost, FEATURE_SELECTOR_REMOTEWAKEUP);
+
+ if (status == USBH_OK)
{
USBH_UsrLog("Device remote wakeup enabled");
phost->gState = HOST_CHECK_CLASS;
}
+ else if (status == USBH_NOT_SUPPORTED)
+ {
+ USBH_UsrLog("Remote wakeup not supported by the device");
+ phost->gState = HOST_CHECK_CLASS;
+ }
+ else
+ {
+ /* .. */
+ }
}
else
{
@@ -654,13 +657,8 @@ USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_PORT_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_PORT_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case HOST_CHECK_CLASS:
@@ -706,13 +704,8 @@ USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case HOST_CLASS_REQUEST:
@@ -740,14 +733,10 @@ USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
phost->gState = HOST_ABORT_STATE;
USBH_ErrLog("Invalid Class Driver.");
}
+
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case HOST_CLASS:
@@ -761,7 +750,7 @@ USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
case HOST_DEV_DISCONNECTED :
phost->device.is_disconnected = 0U;
- DeInitStateMachine(phost);
+ (void)DeInitStateMachine(phost);
/* Re-Initilaize Host for new Enumeration */
if (phost->pActiveClass != NULL)
@@ -781,22 +770,17 @@ USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
phost->device.is_ReEnumerated = 0U;
/* Start the host and re-enable Vbus */
- USBH_Start(phost);
+ (void)USBH_Start(phost);
}
else
{
/* Device Disconnection Completed, start USB Driver */
- USBH_LL_Start(phost);
+ (void)USBH_LL_Start(phost);
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_PORT_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_PORT_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case HOST_ABORT_STATE:
@@ -830,14 +814,14 @@ static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
phost->EnumState = ENUM_GET_FULL_DEV_DESC;
/* modify control channels configuration for MaxPacket size */
- USBH_OpenPipe(phost, phost->Control.pipe_in, 0x80U, phost->device.address,
- phost->device.speed, USBH_EP_CONTROL,
- (uint16_t)phost->Control.pipe_size);
+ (void)USBH_OpenPipe(phost, phost->Control.pipe_in, 0x80U, phost->device.address,
+ phost->device.speed, USBH_EP_CONTROL,
+ (uint16_t)phost->Control.pipe_size);
/* Open Control pipes */
- USBH_OpenPipe(phost, phost->Control.pipe_out, 0x00U, phost->device.address,
- phost->device.speed, USBH_EP_CONTROL,
- (uint16_t)phost->Control.pipe_size);
+ (void)USBH_OpenPipe(phost, phost->Control.pipe_out, 0x00U, phost->device.address,
+ phost->device.speed, USBH_EP_CONTROL,
+ (uint16_t)phost->Control.pipe_size);
}
else if (ReqStatus == USBH_NOT_SUPPORTED)
{
@@ -852,8 +836,8 @@ static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
else
{
/* free control pipes */
- USBH_FreePipe(phost, phost->Control.pipe_out);
- USBH_FreePipe(phost, phost->Control.pipe_in);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_out);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_in);
/* Reset the USB Device */
phost->gState = HOST_IDLE;
@@ -888,8 +872,8 @@ static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
else
{
/* Free control pipes */
- USBH_FreePipe(phost, phost->Control.pipe_out);
- USBH_FreePipe(phost, phost->Control.pipe_in);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_out);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_in);
/* Reset the USB Device */
phost->EnumState = ENUM_IDLE;
@@ -915,14 +899,14 @@ static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
phost->EnumState = ENUM_GET_CFG_DESC;
/* modify control channels to update device address */
- USBH_OpenPipe(phost, phost->Control.pipe_in, 0x80U, phost->device.address,
- phost->device.speed, USBH_EP_CONTROL,
- (uint16_t)phost->Control.pipe_size);
+ (void)USBH_OpenPipe(phost, phost->Control.pipe_in, 0x80U, phost->device.address,
+ phost->device.speed, USBH_EP_CONTROL,
+ (uint16_t)phost->Control.pipe_size);
/* Open Control pipes */
- USBH_OpenPipe(phost, phost->Control.pipe_out, 0x00U, phost->device.address,
- phost->device.speed, USBH_EP_CONTROL,
- (uint16_t)phost->Control.pipe_size);
+ (void)USBH_OpenPipe(phost, phost->Control.pipe_out, 0x00U, phost->device.address,
+ phost->device.speed, USBH_EP_CONTROL,
+ (uint16_t)phost->Control.pipe_size);
}
else if (ReqStatus == USBH_NOT_SUPPORTED)
{
@@ -959,8 +943,8 @@ static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
else
{
/* Free control pipes */
- USBH_FreePipe(phost, phost->Control.pipe_out);
- USBH_FreePipe(phost, phost->Control.pipe_in);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_out);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_in);
/* Reset the USB Device */
phost->EnumState = ENUM_IDLE;
@@ -993,8 +977,8 @@ static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
else
{
/* Free control pipes */
- USBH_FreePipe(phost, phost->Control.pipe_out);
- USBH_FreePipe(phost, phost->Control.pipe_in);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_out);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_in);
/* Reset the USB Device */
phost->EnumState = ENUM_IDLE;
@@ -1020,13 +1004,8 @@ static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
phost->EnumState = ENUM_GET_PRODUCT_STRING_DESC;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else if (ReqStatus == USBH_NOT_SUPPORTED)
{
@@ -1034,13 +1013,8 @@ static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
phost->EnumState = ENUM_GET_PRODUCT_STRING_DESC;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -1053,13 +1027,8 @@ static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
phost->EnumState = ENUM_GET_PRODUCT_STRING_DESC;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
break;
@@ -1081,13 +1050,8 @@ static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
phost->EnumState = ENUM_GET_SERIALNUM_STRING_DESC;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -1100,13 +1064,8 @@ static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
phost->EnumState = ENUM_GET_SERIALNUM_STRING_DESC;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_STATE_CHANGED_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_STATE_CHANGED_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
break;
@@ -1152,7 +1111,7 @@ static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
* @param phost: Host Handle
* @retval None
*/
-void USBH_LL_SetTimer(USBH_HandleTypeDef *phost, uint32_t time)
+void USBH_LL_SetTimer(USBH_HandleTypeDef *phost, uint32_t time)
{
phost->Timer = time;
}
@@ -1164,7 +1123,7 @@ void USBH_LL_SetTimer(USBH_HandleTypeDef *phost, uint32_t time)
* @param phost: Host Handle
* @retval None
*/
-void USBH_LL_IncTimer(USBH_HandleTypeDef *phost)
+void USBH_LL_IncTimer(USBH_HandleTypeDef *phost)
{
phost->Timer++;
USBH_HandleSof(phost);
@@ -1177,7 +1136,7 @@ void USBH_LL_IncTimer(USBH_HandleTypeDef *phost)
* @param phost: Host Handle
* @retval None
*/
-static void USBH_HandleSof(USBH_HandleTypeDef *phost)
+static void USBH_HandleSof(USBH_HandleTypeDef *phost)
{
if ((phost->gState == HOST_CLASS) && (phost->pActiveClass != NULL))
{
@@ -1197,13 +1156,8 @@ void USBH_LL_PortEnabled(USBH_HandleTypeDef *phost)
phost->device.PortEnabled = 1U;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_PORT_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_PORT_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
return;
}
@@ -1218,6 +1172,7 @@ void USBH_LL_PortEnabled(USBH_HandleTypeDef *phost)
void USBH_LL_PortDisabled(USBH_HandleTypeDef *phost)
{
phost->device.PortEnabled = 0U;
+ phost->device.is_disconnected = 1U;
return;
}
@@ -1237,25 +1192,19 @@ uint8_t USBH_IsPortEnabled(USBH_HandleTypeDef *phost)
/**
* @brief USBH_LL_Connect
- * Handle USB Host connexion event
+ * Handle USB Host connection event
* @param phost: Host Handle
* @retval USBH_Status
*/
-USBH_StatusTypeDef USBH_LL_Connect(USBH_HandleTypeDef *phost)
+USBH_StatusTypeDef USBH_LL_Connect(USBH_HandleTypeDef *phost)
{
phost->device.is_connected = 1U;
phost->device.is_disconnected = 0U;
phost->device.is_ReEnumerated = 0U;
-
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_PORT_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_PORT_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
return USBH_OK;
}
@@ -1267,7 +1216,7 @@ USBH_StatusTypeDef USBH_LL_Connect(USBH_HandleTypeDef *phost)
* @param phost: Host Handle
* @retval USBH_Status
*/
-USBH_StatusTypeDef USBH_LL_Disconnect(USBH_HandleTypeDef *phost)
+USBH_StatusTypeDef USBH_LL_Disconnect(USBH_HandleTypeDef *phost)
{
/* update device connection states */
phost->device.is_disconnected = 1U;
@@ -1275,31 +1224,56 @@ USBH_StatusTypeDef USBH_LL_Disconnect(USBH_HandleTypeDef *phost)
phost->device.PortEnabled = 0U;
/* Stop Host */
- USBH_LL_Stop(phost);
+ (void)USBH_LL_Stop(phost);
/* FRee Control Pipes */
- USBH_FreePipe(phost, phost->Control.pipe_in);
- USBH_FreePipe(phost, phost->Control.pipe_out);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_in);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_out);
+
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_PORT_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_PORT_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
return USBH_OK;
}
-
#if (USBH_USE_OS == 1U)
+/**
+ * @brief USBH_OS_PutMessage
+ * USB Host put message event to OS message queue
+ * @param phost Host Handle
+ * @param message message event
+ * @param timeout message event timeout
+ * @param priority message event priority
+ * @retval None
+ */
+void USBH_OS_PutMessage(USBH_HandleTypeDef *phost, USBH_OSEventTypeDef message, uint32_t timeout, uint32_t priority)
+{
+ phost->os_msg = (uint32_t)message;
+
+#if (osCMSIS < 0x20000U)
+ UNUSED(priority);
+
+ /* Calculate the number of available spaces */
+ uint32_t available_spaces = MSGQUEUE_OBJECTS - osMessageWaiting(phost->os_event);
+
+ if (available_spaces != 0U)
+ {
+ (void)osMessagePut(phost->os_event, phost->os_msg, timeout);
+ }
+#else
+ if (osMessageQueueGetSpace(phost->os_event) != 0U)
+ {
+ (void)osMessageQueuePut(phost->os_event, &phost->os_msg, priority, timeout);
+ }
+#endif /* (osCMSIS < 0x20000U) */
+}
+
/**
* @brief USB Host Thread task
* @param pvParameters not used
* @retval None
*/
-
#if (osCMSIS < 0x20000U)
static void USBH_Process_OS(void const *argument)
{
@@ -1331,26 +1305,21 @@ static void USBH_Process_OS(void *argument)
}
#endif /* (osCMSIS < 0x20000U) */
-
/**
-* @brief USBH_LL_NotifyURBChange
-* Notify URB state Change
-* @param phost: Host handle
-* @retval USBH Status
-*/
-USBH_StatusTypeDef USBH_LL_NotifyURBChange(USBH_HandleTypeDef *phost)
+ * @brief USBH_LL_NotifyURBChange
+ * Notify URB state Change
+ * @param phost: Host handle
+ * @retval USBH Status
+ */
+USBH_StatusTypeDef USBH_LL_NotifyURBChange(USBH_HandleTypeDef *phost)
{
- phost->os_msg = (uint32_t)USBH_PORT_EVENT;
-
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
+#if (USBH_USE_OS == 1U)
+ USBH_OS_PutMessage(phost, USBH_PORT_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
return USBH_OK;
}
-#endif
+#endif /* (USBH_USE_OS == 1U) */
/**
* @}
*/
@@ -1367,4 +1336,3 @@ USBH_StatusTypeDef USBH_LL_NotifyURBChange(USBH_HandleTypeDef *phost)
* @}
*/
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c
index 13e777e301..d8dfbd9ad6 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -21,75 +20,69 @@
#include "usbh_ctlreq.h"
/** @addtogroup USBH_LIB
-* @{
-*/
+ * @{
+ */
/** @addtogroup USBH_LIB_CORE
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_CTLREQ
-* @brief This file implements the standard requests for device enumeration
-* @{
-*/
+ * @brief This file implements the standard requests for device enumeration
+ * @{
+ */
/** @defgroup USBH_CTLREQ_Private_Defines
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CTLREQ_Private_TypesDefinitions
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CTLREQ_Private_Macros
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CTLREQ_Private_Variables
-* @{
-*/
+ * @{
+ */
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CTLREQ_Private_FunctionPrototypes
-* @{
-*/
+ * @{
+ */
static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost);
+static USBH_StatusTypeDef USBH_ParseDevDesc(USBH_HandleTypeDef *phost, uint8_t *buf, uint16_t length);
+static USBH_StatusTypeDef USBH_ParseCfgDesc(USBH_HandleTypeDef *phost, uint8_t *buf, uint16_t length);
+static USBH_StatusTypeDef USBH_ParseEPDesc(USBH_HandleTypeDef *phost, USBH_EpDescTypeDef *ep_descriptor, uint8_t *buf);
-static void USBH_ParseDevDesc(USBH_DevDescTypeDef *dev_desc,
- uint8_t *buf, uint16_t length);
-
-static void USBH_ParseCfgDesc(USBH_CfgDescTypeDef *cfg_desc,
- uint8_t *buf, uint16_t length);
-
-static void USBH_ParseEPDesc(USBH_EpDescTypeDef *ep_descriptor, uint8_t *buf);
static void USBH_ParseStringDesc(uint8_t *psrc, uint8_t *pdest, uint16_t length);
static void USBH_ParseInterfaceDesc(USBH_InterfaceDescTypeDef *if_descriptor, uint8_t *buf);
-
-
/**
-* @}
-*/
+ * @}
+ */
/** @defgroup USBH_CTLREQ_Private_Functions
-* @{
-*/
+ * @{
+ */
/**
@@ -100,18 +93,24 @@ static void USBH_ParseInterfaceDesc(USBH_InterfaceDescTypeDef *if_descriptor, u
* @param length: Length of the descriptor
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_Get_DevDesc(USBH_HandleTypeDef *phost, uint8_t length)
+USBH_StatusTypeDef USBH_Get_DevDesc(USBH_HandleTypeDef *phost, uint16_t length)
{
USBH_StatusTypeDef status;
- if ((status = USBH_GetDescriptor(phost,
- USB_REQ_RECIPIENT_DEVICE | USB_REQ_TYPE_STANDARD,
- USB_DESC_DEVICE, phost->device.Data,
- (uint16_t)length)) == USBH_OK)
+ if (length > sizeof(phost->device.Data))
+ {
+ USBH_ErrLog("Control error: Get Device Descriptor failed, data buffer size issue");
+ return USBH_NOT_SUPPORTED;
+ }
+
+ status = USBH_GetDescriptor(phost,
+ USB_REQ_RECIPIENT_DEVICE | USB_REQ_TYPE_STANDARD,
+ USB_DESC_DEVICE, phost->device.Data, length);
+
+ if (status == USBH_OK)
{
/* Commands successfully sent and Response Received */
- USBH_ParseDevDesc(&phost->device.DevDesc, phost->device.Data,
- (uint16_t)length);
+ status = USBH_ParseDevDesc(phost, phost->device.Data, length);
}
return status;
@@ -127,18 +126,24 @@ USBH_StatusTypeDef USBH_Get_DevDesc(USBH_HandleTypeDef *phost, uint8_t length)
* @param length: Length of the descriptor
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_Get_CfgDesc(USBH_HandleTypeDef *phost,
- uint16_t length)
-
+USBH_StatusTypeDef USBH_Get_CfgDesc(USBH_HandleTypeDef *phost, uint16_t length)
{
USBH_StatusTypeDef status;
- uint8_t *pData = phost->device.CfgDesc_Raw;;
+ uint8_t *pData = phost->device.CfgDesc_Raw;
+
+ if (length > sizeof(phost->device.CfgDesc_Raw))
+ {
+ USBH_ErrLog("Control error: Get configuration Descriptor failed, data buffer size issue");
+ return USBH_NOT_SUPPORTED;
+ }
+
+ status = USBH_GetDescriptor(phost, (USB_REQ_RECIPIENT_DEVICE | USB_REQ_TYPE_STANDARD),
+ USB_DESC_CONFIGURATION, pData, length);
- if ((status = USBH_GetDescriptor(phost, (USB_REQ_RECIPIENT_DEVICE | USB_REQ_TYPE_STANDARD),
- USB_DESC_CONFIGURATION, pData, length)) == USBH_OK)
+ if (status == USBH_OK)
{
/* Commands successfully sent and Response Received */
- USBH_ParseCfgDesc(&phost->device.CfgDesc, pData, length);
+ status = USBH_ParseCfgDesc(phost, pData, length);
}
return status;
@@ -155,18 +160,24 @@ USBH_StatusTypeDef USBH_Get_CfgDesc(USBH_HandleTypeDef *phost,
* @param length: Length of the descriptor
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_Get_StringDesc(USBH_HandleTypeDef *phost,
- uint8_t string_index, uint8_t *buff,
- uint16_t length)
+USBH_StatusTypeDef USBH_Get_StringDesc(USBH_HandleTypeDef *phost, uint8_t string_index, uint8_t *buff, uint16_t length)
{
USBH_StatusTypeDef status;
- if ((status = USBH_GetDescriptor(phost,
- USB_REQ_RECIPIENT_DEVICE | USB_REQ_TYPE_STANDARD,
- USB_DESC_STRING | string_index,
- phost->device.Data, length)) == USBH_OK)
+ if ((length > sizeof(phost->device.Data)) || (buff == NULL))
{
- /* Commands successfully sent and Response Received */
+ USBH_ErrLog("Control error: Get String Descriptor failed, data buffer size issue");
+ return USBH_NOT_SUPPORTED;
+ }
+
+ status = USBH_GetDescriptor(phost,
+ USB_REQ_RECIPIENT_DEVICE | USB_REQ_TYPE_STANDARD,
+ USB_DESC_STRING | string_index,
+ phost->device.Data, length);
+
+ if (status == USBH_OK)
+ {
+ /* Commands successfully sent and Response Received */
USBH_ParseStringDesc(phost->device.Data, buff, length);
}
@@ -185,11 +196,8 @@ USBH_StatusTypeDef USBH_Get_StringDesc(USBH_HandleTypeDef *phost,
* @param length: Length of the descriptor
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_GetDescriptor(USBH_HandleTypeDef *phost,
- uint8_t req_type,
- uint16_t value_idx,
- uint8_t *buff,
- uint16_t length)
+USBH_StatusTypeDef USBH_GetDescriptor(USBH_HandleTypeDef *phost, uint8_t req_type, uint16_t value_idx,
+ uint8_t *buff, uint16_t length)
{
if (phost->RequestState == CMD_SEND)
{
@@ -234,7 +242,7 @@ USBH_StatusTypeDef USBH_SetAddress(USBH_HandleTypeDef *phost,
phost->Control.setup.b.wLength.w = 0U;
}
- return USBH_CtlReq(phost, 0U, 0U);
+ return USBH_CtlReq(phost, NULL, 0U);
}
@@ -258,7 +266,7 @@ USBH_StatusTypeDef USBH_SetCfg(USBH_HandleTypeDef *phost, uint16_t cfg_idx)
phost->Control.setup.b.wLength.w = 0U;
}
- return USBH_CtlReq(phost, 0U, 0U);
+ return USBH_CtlReq(phost, NULL, 0U);
}
@@ -269,8 +277,7 @@ USBH_StatusTypeDef USBH_SetCfg(USBH_HandleTypeDef *phost, uint16_t cfg_idx)
* @param altSetting: Interface value
* @retval USBH Status
*/
-USBH_StatusTypeDef USBH_SetInterface(USBH_HandleTypeDef *phost, uint8_t ep_num,
- uint8_t altSetting)
+USBH_StatusTypeDef USBH_SetInterface(USBH_HandleTypeDef *phost, uint8_t ep_num, uint8_t altSetting)
{
if (phost->RequestState == CMD_SEND)
{
@@ -283,7 +290,7 @@ USBH_StatusTypeDef USBH_SetInterface(USBH_HandleTypeDef *phost, uint8_t ep_num,
phost->Control.setup.b.wLength.w = 0U;
}
- return USBH_CtlReq(phost, 0U, 0U);
+ return USBH_CtlReq(phost, NULL, 0U);
}
@@ -293,7 +300,7 @@ USBH_StatusTypeDef USBH_SetInterface(USBH_HandleTypeDef *phost, uint8_t ep_num,
* @param pdev: Selected device
* @param itf_idx
* @retval Status
-*/
+ */
USBH_StatusTypeDef USBH_SetFeature(USBH_HandleTypeDef *phost, uint8_t wValue)
{
if (phost->RequestState == CMD_SEND)
@@ -307,7 +314,7 @@ USBH_StatusTypeDef USBH_SetFeature(USBH_HandleTypeDef *phost, uint8_t wValue)
phost->Control.setup.b.wLength.w = 0U;
}
- return USBH_CtlReq(phost, 0U, 0U);
+ return USBH_CtlReq(phost, NULL, 0U);
}
@@ -331,103 +338,199 @@ USBH_StatusTypeDef USBH_ClrFeature(USBH_HandleTypeDef *phost, uint8_t ep_num)
phost->Control.setup.b.wIndex.w = ep_num;
phost->Control.setup.b.wLength.w = 0U;
}
- return USBH_CtlReq(phost, 0U, 0U);
+
+ return USBH_CtlReq(phost, NULL, 0U);
}
/**
* @brief USBH_ParseDevDesc
* This function Parses the device descriptor
+ * @param phost: Host Handle
* @param dev_desc: device_descriptor destination address
* @param buf: Buffer where the source descriptor is available
* @param length: Length of the descriptor
- * @retval None
+ * @retval USBH status
*/
-static void USBH_ParseDevDesc(USBH_DevDescTypeDef *dev_desc, uint8_t *buf,
- uint16_t length)
+static USBH_StatusTypeDef USBH_ParseDevDesc(USBH_HandleTypeDef *phost, uint8_t *buf, uint16_t length)
{
- dev_desc->bLength = *(uint8_t *)(buf + 0);
- dev_desc->bDescriptorType = *(uint8_t *)(buf + 1);
- dev_desc->bcdUSB = LE16(buf + 2);
- dev_desc->bDeviceClass = *(uint8_t *)(buf + 4);
- dev_desc->bDeviceSubClass = *(uint8_t *)(buf + 5);
- dev_desc->bDeviceProtocol = *(uint8_t *)(buf + 6);
- dev_desc->bMaxPacketSize = *(uint8_t *)(buf + 7);
+ USBH_DevDescTypeDef *dev_desc = &phost->device.DevDesc;
+ USBH_StatusTypeDef status = USBH_OK;
+
+ if (buf == NULL)
+ {
+ return USBH_FAIL;
+ }
+
+ dev_desc->bLength = *(uint8_t *)(buf + 0U);
+ dev_desc->bDescriptorType = *(uint8_t *)(buf + 1U);
+ dev_desc->bcdUSB = LE16(buf + 2U);
+ dev_desc->bDeviceClass = *(uint8_t *)(buf + 4U);
+ dev_desc->bDeviceSubClass = *(uint8_t *)(buf + 5U);
+ dev_desc->bDeviceProtocol = *(uint8_t *)(buf + 6U);
+ dev_desc->bMaxPacketSize = *(uint8_t *)(buf + 7U);
+
+ if ((phost->device.speed == (uint8_t)USBH_SPEED_HIGH) ||
+ (phost->device.speed == (uint8_t)USBH_SPEED_FULL))
+ {
+ /* Make sure that the max packet size is either 8, 16, 32, 64 or force it to minimum allowed value */
+ switch (dev_desc->bMaxPacketSize)
+ {
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+ break;
+
+ default:
+ /* set the size to min allowed value in case the device has answered with incorrect size */
+ dev_desc->bMaxPacketSize = 8U;
+ break;
+ }
+ }
+ else if (phost->device.speed == (uint8_t)USBH_SPEED_LOW)
+ {
+ if (dev_desc->bMaxPacketSize != 8U)
+ {
+ /* set the size to 8 in case the device has answered with incorrect size */
+ dev_desc->bMaxPacketSize = 8U;
+ }
+ }
+ else
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
if (length > 8U)
{
/* For 1st time after device connection, Host may issue only 8 bytes for
Device Descriptor Length */
- dev_desc->idVendor = LE16(buf + 8);
- dev_desc->idProduct = LE16(buf + 10);
- dev_desc->bcdDevice = LE16(buf + 12);
- dev_desc->iManufacturer = *(uint8_t *)(buf + 14);
- dev_desc->iProduct = *(uint8_t *)(buf + 15);
- dev_desc->iSerialNumber = *(uint8_t *)(buf + 16);
- dev_desc->bNumConfigurations = *(uint8_t *)(buf + 17);
+ dev_desc->idVendor = LE16(buf + 8U);
+ dev_desc->idProduct = LE16(buf + 10U);
+ dev_desc->bcdDevice = LE16(buf + 12U);
+ dev_desc->iManufacturer = *(uint8_t *)(buf + 14U);
+ dev_desc->iProduct = *(uint8_t *)(buf + 15U);
+ dev_desc->iSerialNumber = *(uint8_t *)(buf + 16U);
+ dev_desc->bNumConfigurations = *(uint8_t *)(buf + 17U);
}
+
+ return status;
}
/**
* @brief USBH_ParseCfgDesc
* This function Parses the configuration descriptor
- * @param cfg_desc: Configuration Descriptor address
+ * @param phost: USB Host handler
* @param buf: Buffer where the source descriptor is available
* @param length: Length of the descriptor
- * @retval None
+ * @retval USBH status
*/
-static void USBH_ParseCfgDesc(USBH_CfgDescTypeDef *cfg_desc, uint8_t *buf,
- uint16_t length)
+static USBH_StatusTypeDef USBH_ParseCfgDesc(USBH_HandleTypeDef *phost, uint8_t *buf, uint16_t length)
{
- USBH_InterfaceDescTypeDef *pif ;
+ USBH_CfgDescTypeDef *cfg_desc = &phost->device.CfgDesc;
+ USBH_StatusTypeDef status = USBH_OK;
+ USBH_InterfaceDescTypeDef *pif;
USBH_EpDescTypeDef *pep;
- USBH_DescHeader_t *pdesc = (USBH_DescHeader_t *)(void *)buf;
+ USBH_DescHeader_t *pdesc;
uint16_t ptr;
uint8_t if_ix = 0U;
uint8_t ep_ix = 0U;
- pdesc = (USBH_DescHeader_t *)(void *)buf;
+ if (buf == NULL)
+ {
+ return USBH_FAIL;
+ }
+
+ pdesc = (USBH_DescHeader_t *)(void *)buf;
+
+ /* Make sure that the Configuration descriptor's bLength is equal to USB_CONFIGURATION_DESC_SIZE */
+ if (pdesc->bLength != USB_CONFIGURATION_DESC_SIZE)
+ {
+ pdesc->bLength = USB_CONFIGURATION_DESC_SIZE;
+ }
/* Parse configuration descriptor */
- cfg_desc->bLength = *(uint8_t *)(buf + 0);
- cfg_desc->bDescriptorType = *(uint8_t *)(buf + 1);
- cfg_desc->wTotalLength = LE16(buf + 2);
- cfg_desc->bNumInterfaces = *(uint8_t *)(buf + 4);
- cfg_desc->bConfigurationValue = *(uint8_t *)(buf + 5);
- cfg_desc->iConfiguration = *(uint8_t *)(buf + 6);
- cfg_desc->bmAttributes = *(uint8_t *)(buf + 7);
- cfg_desc->bMaxPower = *(uint8_t *)(buf + 8);
+ cfg_desc->bLength = *(uint8_t *)(buf + 0U);
+ cfg_desc->bDescriptorType = *(uint8_t *)(buf + 1U);
+ cfg_desc->wTotalLength = MIN(((uint16_t) LE16(buf + 2U)), ((uint16_t)USBH_MAX_SIZE_CONFIGURATION));
+ cfg_desc->bNumInterfaces = *(uint8_t *)(buf + 4U);
+ cfg_desc->bConfigurationValue = *(uint8_t *)(buf + 5U);
+ cfg_desc->iConfiguration = *(uint8_t *)(buf + 6U);
+ cfg_desc->bmAttributes = *(uint8_t *)(buf + 7U);
+ cfg_desc->bMaxPower = *(uint8_t *)(buf + 8U);
if (length > USB_CONFIGURATION_DESC_SIZE)
{
ptr = USB_LEN_CFG_DESC;
- pif = (USBH_InterfaceDescTypeDef *)0;
+ pif = (USBH_InterfaceDescTypeDef *)NULL;
while ((if_ix < USBH_MAX_NUM_INTERFACES) && (ptr < cfg_desc->wTotalLength))
{
pdesc = USBH_GetNextDesc((uint8_t *)(void *)pdesc, &ptr);
- if (pdesc->bDescriptorType == USB_DESC_TYPE_INTERFACE)
+ if (pdesc->bDescriptorType == USB_DESC_TYPE_INTERFACE)
{
+ /* Make sure that the interface descriptor's bLength is equal to USB_INTERFACE_DESC_SIZE */
+ if (pdesc->bLength != USB_INTERFACE_DESC_SIZE)
+ {
+ pdesc->bLength = USB_INTERFACE_DESC_SIZE;
+ }
+
pif = &cfg_desc->Itf_Desc[if_ix];
USBH_ParseInterfaceDesc(pif, (uint8_t *)(void *)pdesc);
ep_ix = 0U;
- pep = (USBH_EpDescTypeDef *)0;
- while ((ep_ix < pif->bNumEndpoints) && (ptr < cfg_desc->wTotalLength))
+ pep = (USBH_EpDescTypeDef *)NULL;
+
+ while ((ep_ix < USBH_MAX_NUM_ENDPOINTS) && (ep_ix < pif->bNumEndpoints) && (ptr < cfg_desc->wTotalLength))
{
pdesc = USBH_GetNextDesc((uint8_t *)(void *)pdesc, &ptr);
- if (pdesc->bDescriptorType == USB_DESC_TYPE_ENDPOINT)
+
+ if (pdesc->bDescriptorType == USB_DESC_TYPE_ENDPOINT)
{
+ /* Check if the endpoint is appartening to an audio streaming interface */
+ if ((pif->bInterfaceClass == 0x01U) &&
+ ((pif->bInterfaceSubClass == 0x02U) || (pif->bInterfaceSubClass == 0x03U)))
+ {
+ /* Check if it is supporting the USB AUDIO 01 class specification */
+ if ((pif->bInterfaceProtocol == 0x00U) && (pdesc->bLength != 0x09U))
+ {
+ pdesc->bLength = 0x09U;
+ }
+ }
+ /* Make sure that the endpoint descriptor's bLength is equal to
+ USB_ENDPOINT_DESC_SIZE for all other endpoints types */
+ else
+ {
+ pdesc->bLength = USB_ENDPOINT_DESC_SIZE;
+ }
+
pep = &cfg_desc->Itf_Desc[if_ix].Ep_Desc[ep_ix];
- USBH_ParseEPDesc(pep, (uint8_t *)(void *)pdesc);
+
+ status = USBH_ParseEPDesc(phost, pep, (uint8_t *)(void *)pdesc);
+
ep_ix++;
}
}
+
+ /* Check if the required endpoint(s) data are parsed */
+ if (ep_ix < pif->bNumEndpoints)
+ {
+ return USBH_NOT_SUPPORTED;
+ }
+
if_ix++;
}
}
+
+ /* Check if the required interface(s) data are parsed */
+ if (if_ix < MIN(cfg_desc->bNumInterfaces, (uint8_t)USBH_MAX_NUM_INTERFACES))
+ {
+ return USBH_NOT_SUPPORTED;
+ }
}
+
+ return status;
}
@@ -438,37 +541,138 @@ static void USBH_ParseCfgDesc(USBH_CfgDescTypeDef *cfg_desc, uint8_t *buf,
* @param buf: Buffer where the descriptor data is available
* @retval None
*/
-static void USBH_ParseInterfaceDesc(USBH_InterfaceDescTypeDef *if_descriptor,
- uint8_t *buf)
+static void USBH_ParseInterfaceDesc(USBH_InterfaceDescTypeDef *if_descriptor, uint8_t *buf)
{
- if_descriptor->bLength = *(uint8_t *)(buf + 0);
- if_descriptor->bDescriptorType = *(uint8_t *)(buf + 1);
- if_descriptor->bInterfaceNumber = *(uint8_t *)(buf + 2);
- if_descriptor->bAlternateSetting = *(uint8_t *)(buf + 3);
- if_descriptor->bNumEndpoints = *(uint8_t *)(buf + 4);
- if_descriptor->bInterfaceClass = *(uint8_t *)(buf + 5);
- if_descriptor->bInterfaceSubClass = *(uint8_t *)(buf + 6);
- if_descriptor->bInterfaceProtocol = *(uint8_t *)(buf + 7);
- if_descriptor->iInterface = *(uint8_t *)(buf + 8);
+ if_descriptor->bLength = *(uint8_t *)(buf + 0U);
+ if_descriptor->bDescriptorType = *(uint8_t *)(buf + 1U);
+ if_descriptor->bInterfaceNumber = *(uint8_t *)(buf + 2U);
+ if_descriptor->bAlternateSetting = *(uint8_t *)(buf + 3U);
+ if_descriptor->bNumEndpoints = *(uint8_t *)(buf + 4U);
+ if_descriptor->bInterfaceClass = *(uint8_t *)(buf + 5U);
+ if_descriptor->bInterfaceSubClass = *(uint8_t *)(buf + 6U);
+ if_descriptor->bInterfaceProtocol = *(uint8_t *)(buf + 7U);
+ if_descriptor->iInterface = *(uint8_t *)(buf + 8U);
}
/**
* @brief USBH_ParseEPDesc
* This function Parses the endpoint descriptor
+ * @param phost: USB Host handler
* @param ep_descriptor: Endpoint descriptor destination address
* @param buf: Buffer where the parsed descriptor stored
- * @retval None
+ * @retval USBH Status
*/
-static void USBH_ParseEPDesc(USBH_EpDescTypeDef *ep_descriptor,
- uint8_t *buf)
+static USBH_StatusTypeDef USBH_ParseEPDesc(USBH_HandleTypeDef *phost, USBH_EpDescTypeDef *ep_descriptor, uint8_t *buf)
{
- ep_descriptor->bLength = *(uint8_t *)(buf + 0);
- ep_descriptor->bDescriptorType = *(uint8_t *)(buf + 1);
- ep_descriptor->bEndpointAddress = *(uint8_t *)(buf + 2);
- ep_descriptor->bmAttributes = *(uint8_t *)(buf + 3);
- ep_descriptor->wMaxPacketSize = LE16(buf + 4);
- ep_descriptor->bInterval = *(uint8_t *)(buf + 6);
+ USBH_StatusTypeDef status = USBH_OK;
+
+ ep_descriptor->bLength = *(uint8_t *)(buf + 0U);
+ ep_descriptor->bDescriptorType = *(uint8_t *)(buf + 1U);
+ ep_descriptor->bEndpointAddress = *(uint8_t *)(buf + 2U);
+ ep_descriptor->bmAttributes = *(uint8_t *)(buf + 3U);
+ ep_descriptor->wMaxPacketSize = LE16(buf + 4U);
+ ep_descriptor->bInterval = *(uint8_t *)(buf + 6U);
+
+ /* Make sure that wMaxPacketSize is different from 0 */
+ if ((ep_descriptor->wMaxPacketSize == 0x00U) ||
+ (ep_descriptor->wMaxPacketSize > USBH_MAX_EP_PACKET_SIZE) ||
+ (ep_descriptor->wMaxPacketSize > USBH_MAX_DATA_BUFFER))
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+
+ if (phost->device.speed == (uint8_t)USBH_SPEED_HIGH)
+ {
+ if ((ep_descriptor->bmAttributes & EP_TYPE_MSK) == EP_TYPE_BULK)
+ {
+ if (ep_descriptor->wMaxPacketSize > 512U)
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+ }
+ else if ((ep_descriptor->bmAttributes & EP_TYPE_MSK) == EP_TYPE_CTRL)
+ {
+ if (ep_descriptor->wMaxPacketSize > 64U)
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+ }
+ /* For high-speed interrupt/isochronous endpoints, bInterval can vary from 1 to 16 */
+ else if (((ep_descriptor->bmAttributes & EP_TYPE_MSK) == EP_TYPE_ISOC) ||
+ ((ep_descriptor->bmAttributes & EP_TYPE_MSK) == EP_TYPE_INTR))
+ {
+ if ((ep_descriptor->bInterval == 0U) || (ep_descriptor->bInterval > 0x10U))
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+ }
+ else
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+ }
+ else if (phost->device.speed == (uint8_t)USBH_SPEED_FULL)
+ {
+ if (((ep_descriptor->bmAttributes & EP_TYPE_MSK) == EP_TYPE_BULK) ||
+ ((ep_descriptor->bmAttributes & EP_TYPE_MSK) == EP_TYPE_CTRL))
+ {
+ if (ep_descriptor->wMaxPacketSize > 64U)
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+ }
+ /* For full-speed isochronous endpoints, the value of bInterval must be in the range from 1 to 16.*/
+ else if ((ep_descriptor->bmAttributes & EP_TYPE_MSK) == EP_TYPE_ISOC)
+ {
+ if ((ep_descriptor->bInterval == 0U) ||
+ (ep_descriptor->bInterval > 0x10U) ||
+ (ep_descriptor->wMaxPacketSize > 64U))
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+ }
+ /* For full-speed interrupt endpoints, the value of bInterval may be from 1 to 255.*/
+ else if ((ep_descriptor->bmAttributes & EP_TYPE_MSK) == EP_TYPE_INTR)
+ {
+ if ((ep_descriptor->bInterval == 0U) || (ep_descriptor->wMaxPacketSize > 1023U))
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+ }
+ else
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+ }
+ else if (phost->device.speed == (uint8_t)USBH_SPEED_LOW)
+ {
+ if ((ep_descriptor->bmAttributes & EP_TYPE_MSK) == EP_TYPE_CTRL)
+ {
+ if (ep_descriptor->wMaxPacketSize != 8U)
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+ }
+ /* For low-speed interrupt endpoints, the value of bInterval may be from 1 to 255.*/
+ else if ((ep_descriptor->bmAttributes & EP_TYPE_MSK) == EP_TYPE_INTR)
+ {
+ if ((ep_descriptor->bInterval == 0U) || (ep_descriptor->wMaxPacketSize > 8U))
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+ }
+ else
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+ }
+ else
+ {
+ status = USBH_NOT_SUPPORTED;
+ }
+
+ return status;
}
@@ -486,7 +690,7 @@ static void USBH_ParseStringDesc(uint8_t *psrc, uint8_t *pdest, uint16_t length)
uint16_t idx;
/* The UNICODE string descriptor is not NULL-terminated. The string length is
- computed by substracting two from the value of the first byte of the descriptor.
+ computed by subtracting two from the value of the first byte of the descriptor.
*/
/* Check which is lower size, the Size of string or the length of bytes read
@@ -520,9 +724,9 @@ static void USBH_ParseStringDesc(uint8_t *psrc, uint8_t *pdest, uint16_t length)
* @param ptr: data pointer inside the cfg descriptor
* @retval next header
*/
-USBH_DescHeader_t *USBH_GetNextDesc(uint8_t *pbuf, uint16_t *ptr)
+USBH_DescHeader_t *USBH_GetNextDesc(uint8_t *pbuf, uint16_t *ptr)
{
- USBH_DescHeader_t *pnext;
+ USBH_DescHeader_t *pnext;
*ptr += ((USBH_DescHeader_t *)(void *)pbuf)->bLength;
pnext = (USBH_DescHeader_t *)(void *)((uint8_t *)(void *)pbuf + \
@@ -559,13 +763,8 @@ USBH_StatusTypeDef USBH_CtlReq(USBH_HandleTypeDef *phost, uint8_t *buff,
status = USBH_BUSY;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
case CMD_WAIT:
@@ -585,14 +784,10 @@ USBH_StatusTypeDef USBH_CtlReq(USBH_HandleTypeDef *phost, uint8_t *buff,
{
/* .. */
}
+
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
break;
default:
@@ -618,8 +813,8 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
{
case CTRL_SETUP:
/* send a SETUP packet */
- USBH_CtlSendSetup(phost, (uint8_t *)(void *)phost->Control.setup.d8,
- phost->Control.pipe_out);
+ (void)USBH_CtlSendSetup(phost, (uint8_t *)(void *)phost->Control.setup.d8,
+ phost->Control.pipe_out);
phost->Control.state = CTRL_SETUP_WAIT;
break;
@@ -663,13 +858,8 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
}
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -678,13 +868,8 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
phost->Control.state = CTRL_ERROR;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
}
break;
@@ -692,8 +877,13 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
case CTRL_DATA_IN:
/* Issue an IN token */
phost->Control.timer = (uint16_t)phost->Timer;
- USBH_CtlReceiveData(phost, phost->Control.buff, phost->Control.length,
- phost->Control.pipe_in);
+
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ phost->NakTimer = phost->Timer;
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
+
+ (void)USBH_CtlReceiveData(phost, phost->Control.buff,
+ phost->Control.length, phost->Control.pipe_in);
phost->Control.state = CTRL_DATA_IN_WAIT;
break;
@@ -708,29 +898,34 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
phost->Control.state = CTRL_STATUS_OUT;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ else if (URB_Status == USBH_URB_NAK_WAIT)
+ {
+ phost->Control.state = CTRL_DATA_IN_WAIT;
- /* manage error cases*/
- if (URB_Status == USBH_URB_STALL)
+ if ((phost->Timer - phost->NakTimer) > phost->NakTimeout)
+ {
+ phost->NakTimer = phost->Timer;
+ USBH_ActivatePipe(phost, phost->Control.pipe_in);
+ }
+
+#if (USBH_USE_OS == 1U)
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ }
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
+ /* manage error cases */
+ else if (URB_Status == USBH_URB_STALL)
{
/* In stall case, return to previous machine state*/
status = USBH_NOT_SUPPORTED;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -740,21 +935,16 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
phost->Control.state = CTRL_ERROR;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
}
break;
case CTRL_DATA_OUT:
- USBH_CtlSendData(phost, phost->Control.buff, phost->Control.length,
- phost->Control.pipe_out, 1U);
+ (void)USBH_CtlSendData(phost, phost->Control.buff, phost->Control.length,
+ phost->Control.pipe_out, 1U);
phost->Control.timer = (uint16_t)phost->Timer;
phost->Control.state = CTRL_DATA_OUT_WAIT;
@@ -770,13 +960,8 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
phost->Control.state = CTRL_STATUS_IN;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
/* handle error cases */
@@ -787,13 +972,8 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
status = USBH_NOT_SUPPORTED;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else if (URB_Status == USBH_URB_NOTREADY)
{
@@ -801,13 +981,8 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
phost->Control.state = CTRL_DATA_OUT;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -818,20 +993,19 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
status = USBH_FAIL;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
}
break;
case CTRL_STATUS_IN:
/* Send 0 bytes out packet */
- USBH_CtlReceiveData(phost, 0U, 0U, phost->Control.pipe_in);
+ (void)USBH_CtlReceiveData(phost, NULL, 0U, phost->Control.pipe_in);
+
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ phost->NakTimer = phost->Timer;
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
phost->Control.timer = (uint16_t)phost->Timer;
phost->Control.state = CTRL_STATUS_IN_WAIT;
@@ -849,26 +1023,32 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
status = USBH_OK;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
+ }
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+ else if (URB_Status == USBH_URB_NAK_WAIT)
+ {
+ phost->Control.state = CTRL_STATUS_IN_WAIT;
+
+ if ((phost->Timer - phost->NakTimer) > phost->NakTimeout)
+ {
+ phost->NakTimer = phost->Timer;
+ USBH_ActivatePipe(phost, phost->Control.pipe_in);
+ }
+
+#if (USBH_USE_OS == 1U)
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
else if (URB_Status == USBH_URB_ERROR)
{
phost->Control.state = CTRL_ERROR;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -878,19 +1058,14 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
status = USBH_NOT_SUPPORTED;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
}
break;
case CTRL_STATUS_OUT:
- USBH_CtlSendData(phost, 0U, 0U, phost->Control.pipe_out, 1U);
+ (void)USBH_CtlSendData(phost, NULL, 0U, phost->Control.pipe_out, 1U);
phost->Control.timer = (uint16_t)phost->Timer;
phost->Control.state = CTRL_STATUS_OUT_WAIT;
@@ -904,26 +1079,16 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
phost->Control.state = CTRL_COMPLETE;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else if (URB_Status == USBH_URB_NOTREADY)
{
phost->Control.state = CTRL_STATUS_OUT;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
else
{
@@ -932,13 +1097,8 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
phost->Control.state = CTRL_ERROR;
#if (USBH_USE_OS == 1U)
- phost->os_msg = (uint32_t)USBH_CONTROL_EVENT;
-#if (osCMSIS < 0x20000U)
- (void)osMessagePut(phost->os_event, phost->os_msg, 0U);
-#else
- (void)osMessageQueuePut(phost->os_event, &phost->os_msg, 0U, NULL);
-#endif
-#endif
+ USBH_OS_PutMessage(phost, USBH_CONTROL_EVENT, 0U, 0U);
+#endif /* (USBH_USE_OS == 1U) */
}
}
break;
@@ -965,8 +1125,8 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
USBH_ErrLog("Control error: Device not responding");
/* Free control pipes */
- USBH_FreePipe(phost, phost->Control.pipe_out);
- USBH_FreePipe(phost, phost->Control.pipe_in);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_out);
+ (void)USBH_FreePipe(phost, phost->Control.pipe_in);
phost->gState = HOST_IDLE;
status = USBH_FAIL;
@@ -981,22 +1141,20 @@ static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
}
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c
index 46e973454c..68afa1d87b 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -25,8 +24,8 @@
*/
/** @addtogroup USBH_LIB_CORE
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_IOREQ
* @brief This file handles the standard protocol processing (USB v2.0)
@@ -94,14 +93,14 @@ USBH_StatusTypeDef USBH_CtlSendSetup(USBH_HandleTypeDef *phost,
uint8_t pipe_num)
{
- USBH_LL_SubmitURB(phost, /* Driver handle */
- pipe_num, /* Pipe index */
- 0U, /* Direction : OUT */
- USBH_EP_CONTROL, /* EP type */
- USBH_PID_SETUP, /* Type setup */
- buff, /* data buffer */
- USBH_SETUP_PKT_SIZE, /* data length */
- 0U);
+ (void)USBH_LL_SubmitURB(phost, /* Driver handle */
+ pipe_num, /* Pipe index */
+ 0U, /* Direction : OUT */
+ USBH_EP_CONTROL, /* EP type */
+ USBH_PID_SETUP, /* Type setup */
+ buff, /* data buffer */
+ USBH_SETUP_PKT_SIZE, /* data length */
+ 0U);
return USBH_OK;
}
@@ -126,14 +125,14 @@ USBH_StatusTypeDef USBH_CtlSendData(USBH_HandleTypeDef *phost,
do_ping = 0U;
}
- USBH_LL_SubmitURB(phost, /* Driver handle */
- pipe_num, /* Pipe index */
- 0U, /* Direction : OUT */
- USBH_EP_CONTROL, /* EP type */
- USBH_PID_DATA, /* Type Data */
- buff, /* data buffer */
- length, /* data length */
- do_ping); /* do ping (HS Only)*/
+ (void)USBH_LL_SubmitURB(phost, /* Driver handle */
+ pipe_num, /* Pipe index */
+ 0U, /* Direction : OUT */
+ USBH_EP_CONTROL, /* EP type */
+ USBH_PID_DATA, /* Type Data */
+ buff, /* data buffer */
+ length, /* data length */
+ do_ping); /* do ping (HS Only)*/
return USBH_OK;
}
@@ -153,14 +152,14 @@ USBH_StatusTypeDef USBH_CtlReceiveData(USBH_HandleTypeDef *phost,
uint16_t length,
uint8_t pipe_num)
{
- USBH_LL_SubmitURB(phost, /* Driver handle */
- pipe_num, /* Pipe index */
- 1U, /* Direction : IN */
- USBH_EP_CONTROL, /* EP type */
- USBH_PID_DATA, /* Type Data */
- buff, /* data buffer */
- length, /* data length */
- 0U);
+ (void)USBH_LL_SubmitURB(phost, /* Driver handle */
+ pipe_num, /* Pipe index */
+ 1U, /* Direction : IN */
+ USBH_EP_CONTROL, /* EP type */
+ USBH_PID_DATA, /* Type Data */
+ buff, /* data buffer */
+ length, /* data length */
+ 0U);
return USBH_OK;
}
@@ -186,14 +185,14 @@ USBH_StatusTypeDef USBH_BulkSendData(USBH_HandleTypeDef *phost,
do_ping = 0U;
}
- USBH_LL_SubmitURB(phost, /* Driver handle */
- pipe_num, /* Pipe index */
- 0U, /* Direction : IN */
- USBH_EP_BULK, /* EP type */
- USBH_PID_DATA, /* Type Data */
- buff, /* data buffer */
- length, /* data length */
- do_ping); /* do ping (HS Only)*/
+ (void)USBH_LL_SubmitURB(phost, /* Driver handle */
+ pipe_num, /* Pipe index */
+ 0U, /* Direction : IN */
+ USBH_EP_BULK, /* EP type */
+ USBH_PID_DATA, /* Type Data */
+ buff, /* data buffer */
+ length, /* data length */
+ do_ping); /* do ping (HS Only)*/
return USBH_OK;
}
@@ -212,14 +211,14 @@ USBH_StatusTypeDef USBH_BulkReceiveData(USBH_HandleTypeDef *phost,
uint16_t length,
uint8_t pipe_num)
{
- USBH_LL_SubmitURB(phost, /* Driver handle */
- pipe_num, /* Pipe index */
- 1U, /* Direction : IN */
- USBH_EP_BULK, /* EP type */
- USBH_PID_DATA, /* Type Data */
- buff, /* data buffer */
- length, /* data length */
- 0U);
+ (void)USBH_LL_SubmitURB(phost, /* Driver handle */
+ pipe_num, /* Pipe index */
+ 1U, /* Direction : IN */
+ USBH_EP_BULK, /* EP type */
+ USBH_PID_DATA, /* Type Data */
+ buff, /* data buffer */
+ length, /* data length */
+ 0U);
return USBH_OK;
}
@@ -238,14 +237,14 @@ USBH_StatusTypeDef USBH_InterruptReceiveData(USBH_HandleTypeDef *phost,
uint8_t length,
uint8_t pipe_num)
{
- USBH_LL_SubmitURB(phost, /* Driver handle */
- pipe_num, /* Pipe index */
- 1U, /* Direction : IN */
- USBH_EP_INTERRUPT, /* EP type */
- USBH_PID_DATA, /* Type Data */
- buff, /* data buffer */
- (uint16_t)length, /* data length */
- 0U);
+ (void)USBH_LL_SubmitURB(phost, /* Driver handle */
+ pipe_num, /* Pipe index */
+ 1U, /* Direction : IN */
+ USBH_EP_INTERRUPT, /* EP type */
+ USBH_PID_DATA, /* Type Data */
+ buff, /* data buffer */
+ (uint16_t)length, /* data length */
+ 0U);
return USBH_OK;
}
@@ -264,14 +263,14 @@ USBH_StatusTypeDef USBH_InterruptSendData(USBH_HandleTypeDef *phost,
uint8_t length,
uint8_t pipe_num)
{
- USBH_LL_SubmitURB(phost, /* Driver handle */
- pipe_num, /* Pipe index */
- 0U, /* Direction : OUT */
- USBH_EP_INTERRUPT, /* EP type */
- USBH_PID_DATA, /* Type Data */
- buff, /* data buffer */
- (uint16_t)length, /* data length */
- 0U);
+ (void)USBH_LL_SubmitURB(phost, /* Driver handle */
+ pipe_num, /* Pipe index */
+ 0U, /* Direction : OUT */
+ USBH_EP_INTERRUPT, /* EP type */
+ USBH_PID_DATA, /* Type Data */
+ buff, /* data buffer */
+ (uint16_t)length, /* data length */
+ 0U);
return USBH_OK;
}
@@ -290,14 +289,14 @@ USBH_StatusTypeDef USBH_IsocReceiveData(USBH_HandleTypeDef *phost,
uint32_t length,
uint8_t pipe_num)
{
- USBH_LL_SubmitURB(phost, /* Driver handle */
- pipe_num, /* Pipe index */
- 1U, /* Direction : IN */
- USBH_EP_ISO, /* EP type */
- USBH_PID_DATA, /* Type Data */
- buff, /* data buffer */
- (uint16_t)length, /* data length */
- 0U);
+ (void)USBH_LL_SubmitURB(phost, /* Driver handle */
+ pipe_num, /* Pipe index */
+ 1U, /* Direction : IN */
+ USBH_EP_ISO, /* EP type */
+ USBH_PID_DATA, /* Type Data */
+ buff, /* data buffer */
+ (uint16_t)length, /* data length */
+ 0U);
return USBH_OK;
@@ -317,34 +316,32 @@ USBH_StatusTypeDef USBH_IsocSendData(USBH_HandleTypeDef *phost,
uint32_t length,
uint8_t pipe_num)
{
- USBH_LL_SubmitURB(phost, /* Driver handle */
- pipe_num, /* Pipe index */
- 0U, /* Direction : OUT */
- USBH_EP_ISO, /* EP type */
- USBH_PID_DATA, /* Type Data */
- buff, /* data buffer */
- (uint16_t)length, /* data length */
- 0U);
+ (void)USBH_LL_SubmitURB(phost, /* Driver handle */
+ pipe_num, /* Pipe index */
+ 0U, /* Direction : OUT */
+ USBH_EP_ISO, /* EP type */
+ USBH_PID_DATA, /* Type Data */
+ buff, /* data buffer */
+ (uint16_t)length, /* data length */
+ 0U);
return USBH_OK;
}
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c
index 60fe08b907..c38dece22f 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c
@@ -6,13 +6,12 @@
******************************************************************************
* @attention
*
- *
© Copyright (c) 2015 STMicroelectronics.
- * All rights reserved.
+ * Copyright (c) 2015 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
@@ -25,8 +24,8 @@
*/
/** @addtogroup USBH_LIB_CORE
-* @{
-*/
+ * @{
+ */
/** @defgroup USBH_PIPES
* @brief This file includes opening and closing Pipes
@@ -86,11 +85,26 @@ USBH_StatusTypeDef USBH_OpenPipe(USBH_HandleTypeDef *phost, uint8_t pipe_num,
uint8_t epnum, uint8_t dev_address,
uint8_t speed, uint8_t ep_type, uint16_t mps)
{
- USBH_LL_OpenPipe(phost, pipe_num, epnum, dev_address, speed, ep_type, mps);
+ (void)USBH_LL_OpenPipe(phost, pipe_num, epnum, dev_address, speed, ep_type, mps);
return USBH_OK;
}
+#if defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U)
+/**
+ * @brief USBH_ActivatePipe
+ * Activate a pipe
+ * @param phost: Host Handle
+ * @param pipe_num: Pipe Number
+ * @retval USBH Status
+ */
+USBH_StatusTypeDef USBH_ActivatePipe(USBH_HandleTypeDef *phost, uint8_t pipe_num)
+{
+ USBH_LL_ActivatePipe(phost, pipe_num);
+
+ return USBH_OK;
+}
+#endif /* defined (USBH_IN_NAK_PROCESS) && (USBH_IN_NAK_PROCESS == 1U) */
/**
* @brief USBH_ClosePipe
@@ -101,7 +115,7 @@ USBH_StatusTypeDef USBH_OpenPipe(USBH_HandleTypeDef *phost, uint8_t pipe_num,
*/
USBH_StatusTypeDef USBH_ClosePipe(USBH_HandleTypeDef *phost, uint8_t pipe_num)
{
- USBH_LL_ClosePipe(phost, pipe_num);
+ (void)USBH_LL_ClosePipe(phost, pipe_num);
return USBH_OK;
}
@@ -122,7 +136,7 @@ uint8_t USBH_AllocPipe(USBH_HandleTypeDef *phost, uint8_t ep_addr)
if (pipe != 0xFFFFU)
{
- phost->Pipes[pipe & 0xFU] = 0x8000U | ep_addr;
+ phost->Pipes[pipe & 0xFU] = (uint32_t)(0x8000U | ep_addr);
}
return (uint8_t)pipe;
@@ -138,7 +152,7 @@ uint8_t USBH_AllocPipe(USBH_HandleTypeDef *phost, uint8_t ep_addr)
*/
USBH_StatusTypeDef USBH_FreePipe(USBH_HandleTypeDef *phost, uint8_t idx)
{
- if (idx < 11U)
+ if (idx < USBH_MAX_PIPES_NBR)
{
phost->Pipes[idx] &= 0x7FFFU;
}
@@ -157,7 +171,7 @@ static uint16_t USBH_GetFreePipe(USBH_HandleTypeDef *phost)
{
uint8_t idx = 0U;
- for (idx = 0U ; idx < 11U ; idx++)
+ for (idx = 0U; idx < USBH_MAX_PIPES_NBR; idx++)
{
if ((phost->Pipes[idx] & 0x8000U) == 0U)
{
@@ -168,21 +182,19 @@ static uint16_t USBH_GetFreePipe(USBH_HandleTypeDef *phost)
return 0xFFFFU;
}
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
+ * @}
+ */
/**
-* @}
-*/
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+ * @}
+ */
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/LICENSE.md b/system/Middlewares/ST/STM32_USB_Host_Library/LICENSE.md
new file mode 100644
index 0000000000..1af5233078
--- /dev/null
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/LICENSE.md
@@ -0,0 +1,80 @@
+SLA0044 Rev5/February 2018
+
+## Software license agreement
+
+### __ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT__
+
+BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE
+OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS
+INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES
+(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON
+BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES
+TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT.
+
+Under STMicroelectronics’ intellectual property rights, the redistribution,
+reproduction and use in source and binary forms of the software or any part
+thereof, with or without modification, are permitted provided that the following
+conditions are met:
+
+1. Redistribution of source code (modified or not) must retain any copyright
+notice, this list of conditions and the disclaimer set forth below as items 10
+and 11.
+
+2. Redistributions in binary form, except as embedded into microcontroller or
+microprocessor device manufactured by or for STMicroelectronics or a software
+update for such device, must reproduce any copyright notice provided with the
+binary code, this list of conditions, and the disclaimer set forth below as
+items 10 and 11, in documentation and/or other materials provided with the
+distribution.
+
+3. Neither the name of STMicroelectronics nor the names of other contributors to
+this software may be used to endorse or promote products derived from this
+software or part thereof without specific written permission.
+
+4. This software or any part thereof, including modifications and/or derivative
+works of this software, must be used and execute solely and exclusively on or in
+combination with a microcontroller or microprocessor device manufactured by or
+for STMicroelectronics.
+
+5. No use, reproduction or redistribution of this software partially or totally
+may be done in any manner that would subject this software to any Open Source
+Terms. “Open Source Terms” shall mean any open source license which requires as
+part of distribution of software that the source code of such software is
+distributed therewith or otherwise made available, or open source license that
+substantially complies with the Open Source definition specified at
+www.opensource.org and any other comparable open source license such as for
+example GNU General Public License (GPL), Eclipse Public License (EPL), Apache
+Software License, BSD license or MIT license.
+
+6. STMicroelectronics has no obligation to provide any maintenance, support or
+updates for the software.
+
+7. The software is and will remain the exclusive property of STMicroelectronics
+and its licensors. The recipient will not take any action that jeopardizes
+STMicroelectronics and its licensors' proprietary rights or acquire any rights
+in the software, except the limited rights specified hereunder.
+
+8. The recipient shall comply with all applicable laws and regulations affecting
+the use of the software or any part thereof including any applicable export
+control law or regulation.
+
+9. Redistribution and use of this software or any part thereof other than as
+permitted under this license is void and will automatically terminate your
+rights under this license.
+
+10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE
+DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL
+STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER
+EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY
+RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.
diff --git a/system/Middlewares/ST/STM32_USB_Host_Library/Release_Notes.html b/system/Middlewares/ST/STM32_USB_Host_Library/Release_Notes.html
index beaf939523..cc788ed345 100644
--- a/system/Middlewares/ST/STM32_USB_Host_Library/Release_Notes.html
+++ b/system/Middlewares/ST/STM32_USB_Host_Library/Release_Notes.html
@@ -1,1235 +1,809 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Release Notes for STM32 USB Host Library
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Back to Release page
- |
-
-
-
- Release Notes for STM32 USB Host Library
- Copyright
- 2015 STMicroelectronics
- 
- |
-
-
-
-
-
-
- Update HistoryV3.3.4 / 08-January-2020Main Changes - Core driver:
- Improve enumeration phase and avoid silent responses.
- Add device reset trial mechanism during enumeration phase.
- MSC Class
- usbh_msc.c
- update max_lun field to be uint8_t instead of uint32_t.
- HID Class
- Get
-HID descriptor by parsing the device descriptor in order to improve
-interoperability with buggy devices that Stall host Get HID descriptor
-request.
V3.3.3 / 29-April-2019Main Changes - Fix misra-C 2012 high severity violations
- Core driver:
- usbh_core.c: Rework USB host Core process in order to improve Device connection / disconnection robustness
- MSC Class
- usbh_msc.c
- Update USBH_MSC_GetMaxLUN() to prevent corruption of supported LUNs
- HID Class
- prevent
-race between USB buffer and Application fifo buffer, this was ensured
-by allocating a dedicated buffer for received report
- Prevent overflow on USB buffer for devices that could have report size greater than 4bytes
V3.3.2 / 24-January-2019 Main Changes - Core driver:
- usbh_core.c:
-fix on USBH_Deinit() API, prevent freeing pActiveClass->pData
-pointer during host Deinit, this is manged by the Class drivers.
V3.3.1 / 09-July-2018 Main Changes - Fix interoperability issue with HP mouse
- Add compatibility with FreeRTOS CMSIS V2 API changes
- Update License section and add link to get copy of ST Ultimate Liberty license SLA0044
V3.3.0 / 23-january-2018
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Main Changes - Update license section to Ultimate Liberty
- Update some functions to be MISRA-C 2004 compliant
- Improve USB Core enumeration state machine
- Fix Device fast plug/unplug issue
- Improve interoperability with non compliant USB devices
- Add support of Host set remote wakeup enable feature
- Fix USB Host MSC set correct sector size
- MSC: Set correct LUN number if returned LUN number exceeds max supported value
V3.2.2 / 07-July-2015
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Main
-Changes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - MSC Class
- usbh_msc.c
- Fix MSC Get Ready Delay issue
V3.2.1 / 26-June-2015
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Main
-Changes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-- Core driver
-
- - usbh_def.h:
-update USBH_MAX_PIPES_NBR literal definition to be conditioned by
-#ifndef directive, to allow application code to change its value (i.e.
-in the compiler preprocessor)
-
-
- - MSC Class
-
- - usbh_msc.c
-
- - Update USBH_MSC_GetMaxLUN() to return the correct number of supported LUNs (was returning 0xFF)
- - Fix timeout calculation issue
-
-
-
-
- - usbh_msc.h:
-update MAX_SUPPORTED_LUN literal definition to be conditioned by
-#ifndef directive, to allow application code to change its value
-(i.e.in the compiler preprocessor)
-
- - HID Class
-
- - usbh_hid.h: fix HID's handle �timer� type to uint32_t instead of uint16_t
- - MTP Class
-
- - usbh_mtp.c : Fix timeout calculation issue
-
-
-
-
-
-
- V3.2.0 / 04-November-2014
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Main
-Changes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-- Update all drivers to be C++ compliant
-
- - Core driver
-
- - usbh_core.c: remove HOST_IDLE state in USBH_LL_Connect() function
-
-
- - MSC class
-
- - Update to manage correctly older USB Keys that do not support GetMaxLun request
-
-- Miscellaneous source code comments update
-
-
- V3.1.0 / 19-June-2014
-
-
-
-
-
- Main
-Changes
-
-
-
-
-
-
-
-
-
-
- - Core driver
-
- - Add a new define USBH_PROCESS_STACK_SIZE in the usbh_conf.h
-file to change the default internal USB host process stack. Note that
-by omitting this define, the default stack size (2KB) is used
-
- - Add a user callback to handle unrecoverable error case in the application
-
-
- - Remove the wrong check on the interface descriptor index in the USBH_FindInterface() function
-
-
- - All classes
-
-- Update class description in files comment by adding reference to the used USB class specification revision
-
- - Audio, CDC and MTP classes
-
-
- - Add full RTOS support by handling state transitions through OS messages
-
-
- - HID class
-
- - Add new API USBH_HID_GetPollInterval() to allow user to retrieve the needed poll time (interval between two USBD_HID_SendReport())
-
- - Audio class
-
- - Add a new weak callback USBH_AUDIO_BufferEmptyCallback() to indicate the end of audio data processing on the user buffer
-
- - MSC class
-
-- Return mass storage device capacity in Bytes in the user log message instead of MBytes
-
-
-
-
-
- V3.0.0 / 18-February-2014
-
-
-
- Main
-Changes
-
-
-
-
-
-
-
-
- - Major update
-based on STM32Cube specification: Library Core, Classes architecture and APIs
-modified vs. V2.1.0, and thus the 2 versions are not compatible.
-
- - This version has to be used only with STM32Cube based development
+
+
+
+
+
+
+ Release Notes for STM32Cube USB Host Library
+
+
+
+
+
+
+
+
+
+Release Notes for
+STM32Cube USB Host Library
+Copyright © 2015 STMicroelectronics
+
+
+
+ Purpose
+ The USB host library comes on top of the STM32Cube™ USB host HAL
+driver and offers all the APIs required to develop an USB host
+application.
+ The main USB host library features are:
+
+- Support of multi packet transfer features allowing the reception of
+big amount of data without splitting it into max packet size
+transfers.
+- Support of most common USB Class drivers (HID, CDC, MSC, MTP,
+AUDIO1.0)
+- Configuration files to interface with Cube HAL and change the
+library configuration without changing the library code (Read
+Only).
+- 32-bits aligned data structures to handle DMA based transfer in High
+speed modes.
+
+ Here is the list of references to user documents:
+
+- UM1720
+: STM32Cube USB host library User Manual
+- Wiki
+Page : STM32Cube USB Wiki Page
- V2.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
- Add ISR structure to link the low level driver to the Host library
- Change length parameter in the I/O operations to handle large amount of data
- Enhance the configuration descriptor parsing method to take into account multi interface devices
- HID class
- Remove blocking even frame synchronization loop
- MSC class
- Handle correctly the BOT transfer with length < max length
- Handle multi sector length data in the FAT FS interface
- Miscellaneous bug fix
V2.0.0 / 22-July-2011 Main
-Changes
- - Second official version supporting STM32F105/7 and STM32F2xx devices
- Add support for STM32F2xx devices
- Add multi interface feature
- Add dynamic configuration parsing
- Add
-USBH_DeAllocate_AllChannel function in the Host channel management
-layer to clean up channels allocation table when de-initializing the
-library
- Change the core layer to stop correctly the host core and free all allocated channels
- Add usbh_conf.h file in the application layer to customize some user parameters
V1.0.0 - 11/29/2010
- LicenseThis
-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
-
-
-
- For
- complete documentation on STM32
- Microcontrollers visit www.st.com/STM32
- |
-
-
-
- |
-
-
-
-
-
-
+
+Update History
+
+
+
+
Main Changes
+
+
+
+
+
+
+Core |
+
+
+Improve usage of CMSIS RTOS message queue |
+
+
+Add new API to allow activating USB host pipe from STM32 HAL |
+
+
+HID Class |
+
+
+ Fix keyboard layout mapping for AZERTY keyboards |
+
+
+ Add escape to Keyboard layouts mapping |
+
+
+MSC/CDC/MTP Classes |
+
+
+Allow re-activating host IN channel based on SOF timer to reduce NAK IT with some USB peripherals |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Core |
+
+
+Avoid infinite loop in case device descriptor length was wrongly set to zero |
+
+
+MSC Class |
+
+
+Add support of multi-LUN storage devices |
+
+
+Report error for non-ready media |
+
+
+Audio Class |
+
+
+Report error for unsupported audio sample rate |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Core |
+
+
+Ensure the number of endpoints parsed does not exceed defined USBH_MAX_NUM_ENDPOINTS |
+
+
+Use correct endpoint length for audio midi subclass devices |
+
+
+HID Class |
+
+
+Prevent buffer overflow during HID get descriptors |
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Core |
+
+
+Fix potential corruption of Endpoints MaxPacketSize |
+
+
+HID Class |
+
+
+Fix potential buffer overflow |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Update the way to declare licenses |
+
+
+Fix code spelling and improve code
+style |
+
+
+HID Class |
+
+
+Modify some variables names to avoid
+duplication versus device for HID class |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Core driver: |
+
+
+Fixes added to free RTOS resource during
+USB host DeInit |
+
+
+CodeSpell and mcuAstlye fixes |
+
+
+Multiple MisraC 2012 fixes |
+
+
+All Classes: |
+
+
+CodeSpell and mcuAstlye fixes |
+
+
+Multiple MisraC 2012 fixes |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Core driver: |
+
+
+Improve enumeration phase by adding some
+specifications requirements checks. |
+
+
+Add error signaling for some out of
+specification device’s descriptors fields. |
+
+
+MSC Class: |
+
+
+usbh_msc.c: add checking on both IN and
+OUT pipes construction. |
+
+
+HID Class: |
+
+
+Fix wrong keyboard key defines. |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Core driver: |
+
+
+Improve enumeration phase and avoid silent
+responses. |
+
+
+Add device reset trial mechanism during
+enumeration phase. |
+
+
+MSC Class: |
+
+
+usbh_msc.c: update max_lun field to be
+uint8_t instead of uint32_t. |
+
+
+HID Class: |
+
+
+Get HID descriptor by parsing the device
+descriptor in order to improve interoperability with buggy devices that
+Stall host Get HID descriptor request. |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Fix misra-C 2012 high severity
+violations |
+
+
+Core driver: |
+
+
+usbh_core.c: Rework USB host Core process
+in order to improve Device connection / disconnection robustness |
+
+
+MSC Class: |
+
+
+usbh_msc.c: Update USBH_MSC_GetMaxLUN() to
+prevent corruption of supported LUNs |
+
+
+HID Class: |
+
+
+Prevent race between USB buffer and
+Application fifo buffer, this was ensured by allocating a dedicated
+buffer for received report |
+
+
+Prevent overflow on USB buffer for devices
+that could have report size greater than 4bytes |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Core driver: |
+
+
+usbh_core.c: fix on USBH_Deinit() API,
+prevent freeing pActiveClass->pData pointer during host Deinit, this
+is manged by the Class drivers. |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Fix interoperability issue with HP
+mouse |
+
+
+Add compatibility with FreeRTOS CMSIS V2
+API changes |
+
+
+Update License section and add link to get
+copy of ST Ultimate Liberty license SLA0044 |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Update license section to Ultimate
+Liberty |
+
+
+Update some functions to be MISRA-C 2004
+compliant |
+
+
+Improve USB Core enumeration state
+machine |
+
+
+Fix Device fast plug/unplug issue |
+
+
+Improve interoperability with non
+compliant USB devices |
+
+
+Add support of Host set remote wakeup
+enable feature |
+
+
+Fix USB Host MSC set correct sector
+size |
+
+
+MSC: Set correct LUN number if returned
+LUN number exceeds max supported value |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+MSC Class: |
+
+
+usbh_msc.c: Fix MSC Get Ready Delay
+issue |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Core driver: |
+
+
+usbh_def.h: update USBH_MAX_PIPES_NBR
+literal definition to be conditioned by #ifndef directive, to allow
+application code to change its value (i.e. in the compiler
+preprocessor) |
+
+
+MSC Class: |
+
+
+usbh_msc.c: |
+
+
+Update USBH_MSC_GetMaxLUN() to return the
+correct number of supported LUNs (was returning 0xFF) |
+
+
+Fix timeout calculation issue |
+
+
+usbh_msc.h: |
+
+
+update MAX_SUPPORTED_LUN literal
+definition to be conditioned by #ifndef directive, to allow application
+code to change its value (i.e.in the compiler preprocessor) |
+
+
+HID Class: |
+
+
+usbh_hid.h: fix HID’s handle “Timer” type
+to uint32_t instead of uint16_t |
+
+
+MTP Class: |
+
+
+usbh_mtp.c : Fix timeout calculation
+issue |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Update all drivers to be C++
+compliant |
+
+
+Miscellaneous source code comments
+update |
+
+
+Core driver |
+
+
+usbh_core.c: remove HOST_IDLE state in
+USBH_LL_Connect() function |
+
+
+MSC class |
+
+
+Update to manage correctly older USB Keys
+that do not support GetMaxLun request |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Core driver |
+
+
+Add a new define USBH_PROCESS_STACK_SIZE
+in the usbh_conf.h file to change the default internal USB host process
+stack. Note that by omitting this define, the default stack size (2KB)
+is used |
+
+
+Add a user callback to handle
+unrecoverable error case in the application |
+
+
+Remove the wrong check on the interface
+descriptor index in the USBH_FindInterface() function |
+
+
+All classes |
+
+
+Update class description in files comment
+by adding reference to the used USB class specification revision |
+
+
+Audio, CDC and MTP
+classes |
+
+
+Add full RTOS support by handling state
+transitions through OS messages |
+
+
+HID class |
+
+
+Add new API USBH_HID_GetPollInterval() to
+allow user to retrieve the needed poll time (interval between two
+USBD_HID_SendReport()) |
+
+
+Audio class |
+
+
+Add a new weak callback
+USBH_AUDIO_BufferEmptyCallback() to indicate the end of audio data
+processing on the user buffer |
+
+
+MSC class |
+
+
+Return mass storage device capacity in
+Bytes in the user log message instead of MBytes |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Major update based on STM32Cube
+specification: Library Core, Classes architecture and APIs modified
+vs. V2.1.0, and thus the 2 versions are not compatible. |
+
+
+This version has to be used only
+with STM32Cube based development |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+Official support of STM32F4xx devices |
+
+
+All source files: license disclaimer text
+update and add link to the License file on ST Internet |
+
+
+Add ISR structure to link the low level
+driver to the Host library |
+
+
+Change length parameter in the I/O
+operations to handle large amount of data |
+
+
+Enhance the configuration descriptor
+parsing method to take into account multi interface devices |
+
+
+Miscellaneous bug fix |
+
+
+HID class |
+
+
+Remove blocking even frame synchronization
+loop |
+
+
+MSC class |
+
+
+Handle correctly the BOT transfer with
+length < max length |
+
+
+Handle multi sector length data in the FAT
+FS interface |
+
+
+
+
+
+
+
+
+
Main Changes
+
+
+
+
+
+
+econd official version supporting
+STM32F105/7 and STM32F2xx devices |
+
+
+dd support for STM32F2xx
+devices |
+
+
+dd multi interface feature |
+
+
+dd dynamic configuration parsing |
+
+
+dd USBH_DeAllocate_AllChannel function in
+the Host channel management layer to clean up channels allocation table
+when de-initializing the library |
+
+
+hange the core layer to stop correctly the
+host core and free all allocated channels |
+
+
+dd usbh_conf.h file in the application
+layer to customize some user parameters |
+
+
+
+
+
+
+
+
+
+
+
+
+
+