2024-04-16 03:06 PM
When i moved to new version of CubeMX and regenerate code for my H7 USB project i got compiler warning about some variables. Here is difference between old and new generated usbd_desc.c file;
Old file:
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);
}
}
New file:
static void Get_SerialNum(void)
{
uint32_t deviceserial0;
uint32_t deviceserial1;
uint32_t deviceserial2;
deviceserial0 += deviceserial2;
if (deviceserial0 != 0)
{
IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8);
IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4);
}
}
As you can see deviceserial0, deviceserial1 and deviceserial2 variables defined but not assigned.
I fixed it myself, here is the solution in usbddesc_c.ftl file for M4 and M7 cores:
From: (at line 728 and 735)
[#if cpucore=="ARM_CORTEX_M4"]
[#elseif cpucore=="ARM_CORTEX_M7"]
To:
[#if cpucore=="ARM_CORTEX_M4" && (CLASS_FS=="CDC" | CLASS_HS=="CDC")]
[#elseif cpucore=="ARM_CORTEX_M7" | CLASS_FS!="CDC" | CLASS_HS!="CDC"]
Solved! Go to Solution.
2024-04-17 12:30 AM
2024-04-17 12:30 AM