feat: H7 support (#5738)
Co-authored-by: Richard Li <richard.li@ces.hk> Co-authored-by: philmoz <phil.a.mitchell@gmail.com> Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
This commit is contained in:
co-authored by
Richard Li
philmoz
raphaelcoeffic
parent
5a15ffb017
commit
3d25c2a0f8
@@ -69,7 +69,11 @@
|
||||
|
||||
#define USBD_LANGID_STRING 0x409
|
||||
#define USBD_MANUFACTURER_STRING "OpenTX"
|
||||
#if defined(FIRMWARE_QSPI)
|
||||
#define USB_SIZ_STRING_SERIAL 0x1A
|
||||
#else
|
||||
#define USBD_SERIALNUMBER_FS_STRING "00000000001B"
|
||||
#endif
|
||||
|
||||
#if defined(BOOT)
|
||||
#define USBD_MSC_PRODUCT_FS_STRING USB_NAME " Bootloader"
|
||||
@@ -94,6 +98,14 @@
|
||||
#define USBD_CDC_CONFIGURATION_FS_STRING "VSP Config"
|
||||
#define USBD_CDC_INTERFACE_FS_STRING "VSP Interface"
|
||||
|
||||
#if defined(FIRMWARE_QSPI)
|
||||
#define USBD_DFU_VID USBD_VID_STM
|
||||
#define USBD_DFU_PID 0xDF11
|
||||
#define USBD_DFU_PRODUCT_STRING USB_NAME " DFU"
|
||||
#define USBD_DFU_CONFIGURATION_STRING "DFU Config"
|
||||
#define USBD_DFU_INTERFACE_STRING "DFU Interface"
|
||||
#endif
|
||||
|
||||
/* USER CODE BEGIN PRIVATE_DEFINES */
|
||||
|
||||
/* USER CODE END PRIVATE_DEFINES */
|
||||
@@ -123,10 +135,10 @@
|
||||
* @brief Private functions declaration.
|
||||
* @{
|
||||
*/
|
||||
|
||||
//static void Get_SerialNum(void);
|
||||
//static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len);
|
||||
|
||||
#if defined(FIRMWARE_QSPI)
|
||||
static void Get_SerialNum(void);
|
||||
static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len);
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -254,6 +266,16 @@ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END =
|
||||
/* Internal string descriptor. */
|
||||
__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END;
|
||||
|
||||
#if defined(FIRMWARE_QSPI)
|
||||
#if defined ( __ICCARM__ ) /* !< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = {
|
||||
USB_SIZ_STRING_SERIAL,
|
||||
USB_DESC_TYPE_STRING,
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -290,7 +312,12 @@ uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
||||
vid = USBD_MSC_VID;
|
||||
pid = USBD_MSC_PID;
|
||||
break;
|
||||
|
||||
#if defined(FIRMWARE_QSPI)
|
||||
case USB_DFU_MODE:
|
||||
vid = USBD_DFU_VID;
|
||||
pid = USBD_DFU_PID;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
vid = 0;
|
||||
pid = 0;
|
||||
@@ -360,6 +387,11 @@ uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length
|
||||
case USB_MASS_STORAGE_MODE:
|
||||
USBD_GetString ((uint8_t*)USBD_MSC_PRODUCT_FS_STRING, USBD_StrDesc, length);
|
||||
break;
|
||||
#if defined(FIRMWARE_QSPI)
|
||||
case USB_DFU_MODE:
|
||||
USBD_GetString ((uint8_t*)USBD_DFU_PRODUCT_STRING, USBD_StrDesc, length);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
return USBD_StrDesc;
|
||||
}
|
||||
@@ -385,9 +417,18 @@ uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *l
|
||||
*/
|
||||
uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
||||
{
|
||||
#if defined(FIRMWARE_QSPI)
|
||||
*length = USB_SIZ_STRING_SERIAL;
|
||||
|
||||
/* Update the serial number string descriptor with the data from the unique
|
||||
* ID */
|
||||
Get_SerialNum();
|
||||
|
||||
return (uint8_t *)USBD_StringSerial;
|
||||
#else
|
||||
USBD_GetString ((uint8_t*)USBD_SERIALNUMBER_FS_STRING, USBD_StrDesc, length);
|
||||
return USBD_StrDesc;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -408,6 +449,11 @@ uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
||||
case USB_MASS_STORAGE_MODE:
|
||||
USBD_GetString ((uint8_t*)USBD_MSC_CONFIGURATION_FS_STRING, USBD_StrDesc, length);
|
||||
break;
|
||||
#if defined(FIRMWARE_QSPI)
|
||||
case USB_DFU_MODE:
|
||||
USBD_GetString ((uint8_t*)USBD_DFU_CONFIGURATION_STRING, USBD_StrDesc, length);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
return USBD_StrDesc;
|
||||
}
|
||||
@@ -430,6 +476,11 @@ uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *leng
|
||||
case USB_MASS_STORAGE_MODE:
|
||||
USBD_GetString ((uint8_t*)USBD_MSC_INTERFACE_FS_STRING, USBD_StrDesc, length);
|
||||
break;
|
||||
#if defined(FIRMWARE_QSPI)
|
||||
case USB_DFU_MODE:
|
||||
USBD_GetString ((uint8_t*)USBD_DFU_INTERFACE_STRING, USBD_StrDesc, length);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
return USBD_StrDesc;
|
||||
}
|
||||
@@ -449,29 +500,30 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
||||
}
|
||||
#endif /* (USBD_LPM_ENABLED == 1) */
|
||||
|
||||
#if defined(FIRMWARE_QSPI)
|
||||
/**
|
||||
* @brief Create the serial number string descriptor
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
//static void Get_SerialNum(void)
|
||||
//{
|
||||
// uint32_t deviceserial0;
|
||||
// uint32_t deviceserial1;
|
||||
// uint32_t deviceserial2;
|
||||
//
|
||||
// deviceserial0 = *(uint32_t *) DEVICE_ID1;
|
||||
// deviceserial1 = *(uint32_t *) DEVICE_ID2;
|
||||
// deviceserial2 = *(uint32_t *) DEVICE_ID3;
|
||||
//
|
||||
// deviceserial0 += deviceserial2;
|
||||
//
|
||||
// if (deviceserial0 != 0)
|
||||
// {
|
||||
// IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8);
|
||||
// IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4);
|
||||
// }
|
||||
//}
|
||||
static void Get_SerialNum(void)
|
||||
{
|
||||
uint32_t deviceserial0;
|
||||
uint32_t deviceserial1;
|
||||
uint32_t deviceserial2;
|
||||
|
||||
deviceserial0 = *(uint32_t *) DEVICE_ID1;
|
||||
deviceserial1 = *(uint32_t *) DEVICE_ID2;
|
||||
deviceserial2 = *(uint32_t *) DEVICE_ID3;
|
||||
|
||||
deviceserial0 += deviceserial2;
|
||||
|
||||
if (deviceserial0 != 0)
|
||||
{
|
||||
IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8);
|
||||
IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert Hex 32Bits value into char
|
||||
@@ -480,26 +532,27 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
||||
* @param len: buffer length
|
||||
* @retval None
|
||||
*/
|
||||
//static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len)
|
||||
//{
|
||||
// uint8_t idx = 0;
|
||||
//
|
||||
// for (idx = 0; idx < len; idx++)
|
||||
// {
|
||||
// if (((value >> 28)) < 0xA)
|
||||
// {
|
||||
// pbuf[2 * idx] = (value >> 28) + '0';
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// pbuf[2 * idx] = (value >> 28) + 'A' - 10;
|
||||
// }
|
||||
//
|
||||
// value = value << 4;
|
||||
//
|
||||
// pbuf[2 * idx + 1] = 0;
|
||||
// }
|
||||
//}
|
||||
static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len)
|
||||
{
|
||||
uint8_t idx = 0;
|
||||
|
||||
for (idx = 0; idx < len; idx++)
|
||||
{
|
||||
if (((value >> 28)) < 0xA)
|
||||
{
|
||||
pbuf[2 * idx] = (value >> 28) + '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
pbuf[2 * idx] = (value >> 28) + 'A' - 10;
|
||||
}
|
||||
|
||||
value = value << 4;
|
||||
|
||||
pbuf[2 * idx + 1] = 0;
|
||||
}
|
||||
}
|
||||
#endif // FIRMWARE_QSPI
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user