HAL_ChibiOS: fixed warning for USB

This commit is contained in:
Andrew Tridgell 2021-10-05 16:49:48 +11:00
parent 4daf4ad501
commit 8deaa1b46b
2 changed files with 9 additions and 4 deletions

View File

@ -244,8 +244,11 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp,
#if HAL_USE_SERIAL_USB
uint32_t get_usb_baud(uint16_t endpoint_id)
{
if(endpoint_id == 0)
return *((uint32_t*)linecoding.dwDTERate);
if (endpoint_id == 0) {
uint32_t rate;
memcpy(&rate, &linecoding.dwDTERate[0], sizeof(rate));
return rate;
}
return 0;
}
#endif

View File

@ -307,8 +307,10 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp,
uint32_t get_usb_baud(uint16_t endpoint_id)
{
for (uint8_t i = 0; i < ARRAY_SIZE(linecoding); i++) {
if(endpoint_id == ep_index[i])
return *((uint32_t*)linecoding[i].dwDTERate);
if (endpoint_id == ep_index[i]) {
uint32_t rate;
memcpy(&rate, &linecoding[i].dwDTERate[0], sizeof(rate));
}
}
return 0;
}