From 8deaa1b46b27607957ed0eade06243748f520829 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 5 Oct 2021 16:49:48 +1100 Subject: [PATCH] HAL_ChibiOS: fixed warning for USB --- libraries/AP_HAL_ChibiOS/hwdef/common/usbcfg.c | 7 +++++-- libraries/AP_HAL_ChibiOS/hwdef/common/usbcfg_dualcdc.c | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/usbcfg.c b/libraries/AP_HAL_ChibiOS/hwdef/common/usbcfg.c index 3a2bcf8b12..b6afa71b27 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/usbcfg.c +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/usbcfg.c @@ -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 diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/usbcfg_dualcdc.c b/libraries/AP_HAL_ChibiOS/hwdef/common/usbcfg_dualcdc.c index 5a407d748d..091cabf33d 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/usbcfg_dualcdc.c +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/usbcfg_dualcdc.c @@ -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; }