mirror of
https://github.com/STMicroelectronics/stm32-mw-usb-device.git
synced 2026-02-08 20:18:07 -05:00
Release v2.9.0
This commit is contained in:
@@ -6,13 +6,12 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
* Copyright (c) 2020 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -413,7 +412,6 @@ typedef struct
|
||||
int8_t (* DeInit)(void);
|
||||
int8_t (* Control)(uint8_t, uint8_t *, uint16_t);
|
||||
int8_t (* Data)(uint8_t **, uint16_t *, uint16_t *);
|
||||
uint8_t *pStrDesc;
|
||||
} USBD_VIDEO_ItfTypeDef;
|
||||
|
||||
/* UVC uses only 26 first bytes */
|
||||
|
||||
@@ -6,13 +6,12 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
* Copyright (c) 2020 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
@@ -114,6 +113,25 @@ void TransferComplete_CallBack_FS(void);
|
||||
*/
|
||||
void HalfTransfer_CallBack_FS(void);
|
||||
|
||||
|
||||
|
||||
#define IMG_NBR 1U
|
||||
#define IMAGE_SIZE 0x1U
|
||||
|
||||
const uint8_t image[] = {0x00};
|
||||
const uint8_t *tImagesList[] = {image};
|
||||
uint16_t tImagesSizes[] = {IMAGE_SIZE};
|
||||
|
||||
/* Time laps between video frames in ms.
|
||||
Please adjust this value depending on required speed.
|
||||
Please note that this define uses the system HAL_Delay() which uses the systick.
|
||||
In case of changes on HAL_Delay, please ensure the values in ms correspond. */
|
||||
#ifdef USE_USB_HS
|
||||
#define USBD_VIDEO_IMAGE_LAPS 160U
|
||||
#else
|
||||
#define USBD_VIDEO_IMAGE_LAPS 80U
|
||||
#endif /* USE_USB_HS */
|
||||
|
||||
/* USER CODE BEGIN EXPORTED_FUNCTIONS */
|
||||
|
||||
/* USER CODE END EXPORTED_FUNCTIONS */
|
||||
@@ -136,7 +154,3 @@ void HalfTransfer_CallBack_FS(void);
|
||||
|
||||
#endif /* USBD_VIDEO_IF_H_ */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,17 @@
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides the Video core functions.
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2020 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
|
||||
*
|
||||
* ===================================================================
|
||||
@@ -35,17 +46,6 @@
|
||||
* @endverbatim
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* 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
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
@@ -757,7 +757,7 @@ static void VIDEO_REQ_GetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
|
||||
|
||||
/* Probe Request */
|
||||
(void)USBD_CtlSendData(pdev, (uint8_t *)&video_Probe_Control,
|
||||
MIN(req->wLength, sizeof(USBD_VideoControlTypeDef)));
|
||||
MIN(req->wLength, sizeof(USBD_VideoControlTypeDef)));
|
||||
}
|
||||
else if (LOBYTE(req->wValue) == (uint8_t)VS_COMMIT_CONTROL)
|
||||
{
|
||||
@@ -774,7 +774,7 @@ static void VIDEO_REQ_GetCurrent(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef
|
||||
|
||||
/* Commit Request */
|
||||
(void)USBD_CtlSendData(pdev, (uint8_t *)&video_Commit_Control,
|
||||
MIN(req->wLength, sizeof(USBD_VideoControlTypeDef)));
|
||||
MIN(req->wLength, sizeof(USBD_VideoControlTypeDef)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -957,7 +957,7 @@ static void *USBD_VIDEO_GetVSFrameDesc(uint8_t *pConfDesc)
|
||||
pdesc = USBD_VIDEO_GetNextDesc((uint8_t *)pdesc, &ptr);
|
||||
|
||||
if (((pdesc->bDescriptorSubType == VS_FRAME_MJPEG) ||
|
||||
(pdesc->bDescriptorSubType == VS_FRAME_UNCOMPRESSED)) &&
|
||||
(pdesc->bDescriptorSubType == VS_FRAME_UNCOMPRESSED)) &&
|
||||
(pdesc->bLength == VS_FRAME_DESC_SIZE))
|
||||
{
|
||||
pVSFrameDesc = (USBD_VIDEO_VSFrameDescTypeDef *)(void *)pdesc;
|
||||
@@ -1045,7 +1045,3 @@ uint8_t USBD_VIDEO_RegisterInterface(USBD_HandleTypeDef *pdev, USBD_VIDEO_ItfT
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
||||
|
||||
|
||||
@@ -6,19 +6,18 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
* Copyright (c) 2020 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_video_if.h"
|
||||
#include "usbd_video_if_template.h"
|
||||
|
||||
/* Include you image binary file here
|
||||
Binary image template shall provide:
|
||||
@@ -41,7 +40,7 @@
|
||||
|
||||
/* USER CODE BEGIN PV */
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
uint8_t img_count;
|
||||
/* USER CODE END PV */
|
||||
|
||||
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
|
||||
@@ -189,6 +188,9 @@ static int8_t VIDEO_Itf_DeInit(void)
|
||||
*/
|
||||
static int8_t VIDEO_Itf_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length)
|
||||
{
|
||||
UNUSED(cmd);
|
||||
UNUSED(pbuf);
|
||||
UNUSED(length);
|
||||
|
||||
return (0);
|
||||
}
|
||||
@@ -221,9 +223,9 @@ static int8_t VIDEO_Itf_Data(uint8_t **pbuf, uint16_t *psize, uint16_t *pcktidx)
|
||||
|
||||
*/
|
||||
const uint8_t *(*ImagePtr) = tImagesList;
|
||||
uint32_t packet_count = (tImagesSizes[img_count]) / ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U)));
|
||||
uint32_t packet_remainder = (tImagesSizes[img_count]) % ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U)));
|
||||
static uint8_t packet_index = 0;
|
||||
uint32_t packet_count = (tImagesSizes[img_count]) / ((UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U)));
|
||||
uint32_t packet_remainder = (tImagesSizes[img_count]) % ((UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U)));
|
||||
static uint8_t packet_index = 0U;
|
||||
|
||||
/* Check if end of current image has been reached */
|
||||
if (packet_index < packet_count)
|
||||
@@ -232,17 +234,17 @@ static int8_t VIDEO_Itf_Data(uint8_t **pbuf, uint16_t *psize, uint16_t *pcktidx)
|
||||
*psize = (uint16_t)UVC_PACKET_SIZE;
|
||||
|
||||
/* Get the pointer to the next packet to be transmitted */
|
||||
*pbuf = (uint8_t *)(*(ImagePtr + img_count) + packet_index * ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U))));
|
||||
*pbuf = (uint8_t *)(*(ImagePtr + img_count) + (packet_index * ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U)))));
|
||||
}
|
||||
else if ((packet_index == packet_count))
|
||||
{
|
||||
if (packet_remainder != 0U)
|
||||
{
|
||||
/* Get the pointer to the next packet to be transmitted */
|
||||
*pbuf = (uint8_t *)(*(ImagePtr + img_count) + packet_index * ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U))));
|
||||
*pbuf = (uint8_t *)(*(ImagePtr + img_count) + (packet_index * ((uint16_t)(UVC_PACKET_SIZE - (UVC_HEADER_PACKET_CNT * 2U)))));
|
||||
|
||||
/* Set the current packet size */
|
||||
*psize = packet_remainder + (UVC_HEADER_PACKET_CNT * 2U);
|
||||
*psize = (uint16_t)(packet_remainder + (UVC_HEADER_PACKET_CNT * 2U));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -262,7 +264,7 @@ static int8_t VIDEO_Itf_Data(uint8_t **pbuf, uint16_t *psize, uint16_t *pcktidx)
|
||||
*pcktidx = packet_index;
|
||||
|
||||
/* Increment the packet count and check if it reached the end of current image buffer */
|
||||
if (packet_index++ >= (packet_count + 1))
|
||||
if (packet_index++ >= (packet_count + 1U))
|
||||
{
|
||||
/* Reset the packet count to zero */
|
||||
packet_index = 0U;
|
||||
@@ -270,7 +272,7 @@ static int8_t VIDEO_Itf_Data(uint8_t **pbuf, uint16_t *psize, uint16_t *pcktidx)
|
||||
/* Move to the next image in the images table */
|
||||
|
||||
img_count++;
|
||||
HAL_Delay(USBD_VIDEO_IMAGE_LAPS);
|
||||
USBD_Delay(USBD_VIDEO_IMAGE_LAPS);
|
||||
/* Check if images count has been reached, then reset to zero (go back to first image in circular loop) */
|
||||
if (img_count == IMG_NBR)
|
||||
{
|
||||
@@ -292,5 +294,3 @@ static int8_t VIDEO_Itf_Data(uint8_t **pbuf, uint16_t *psize, uint16_t *pcktidx)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
||||
Reference in New Issue
Block a user