summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-07-22 17:45:24 +0700
committerhathach <[email protected]>2021-07-22 17:49:39 +0700
commit8cd23489d518e96594850207c91dfeefb6d6fb05 (patch)
tree4378340cd62deab0cf52951d1a8e18531778902b /src/device
parentc4da1abb1eaa7aff432535878ada519d02382419 (diff)
update endian
Diffstat (limited to 'src/device')
-rw-r--r--src/device/usbd.c10
-rw-r--r--src/device/usbd_control.c1
2 files changed, 4 insertions, 7 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 5a7d0ab0f..a30eab217 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -953,11 +953,10 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
tusb_desc_bos_t const* desc_bos = (tusb_desc_bos_t const*) tud_descriptor_bos_cb();
- uint16_t total_len;
// Use offsetof to avoid pointer to the odd/misaligned address
- memcpy(&total_len, (uint8_t*) desc_bos + offsetof(tusb_desc_bos_t, wTotalLength), 2);
+ uint16_t const total_len = tu_le16toh( tu_unaligned_read16((uint8_t*) desc_bos + offsetof(tusb_desc_bos_t, wTotalLength)) );
- return tud_control_xfer(rhport, p_request, (void*) desc_bos, tu_le16toh(total_len));
+ return tud_control_xfer(rhport, p_request, (void*) desc_bos, total_len);
}
break;
@@ -968,11 +967,10 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
tusb_desc_configuration_t const* desc_config = (tusb_desc_configuration_t const*) tud_descriptor_configuration_cb(desc_index);
TU_ASSERT(desc_config);
- uint16_t total_len;
// Use offsetof to avoid pointer to the odd/misaligned address
- memcpy(&total_len, (uint8_t*) desc_config + offsetof(tusb_desc_configuration_t, wTotalLength), 2);
+ uint16_t const total_len = tu_le16toh( tu_unaligned_read16((uint8_t*) desc_config + offsetof(tusb_desc_configuration_t, wTotalLength)) );
- return tud_control_xfer(rhport, p_request, (void*) desc_config, tu_le16toh(total_len));
+ return tud_control_xfer(rhport, p_request, (void*) desc_config, total_len);
}
break;
diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c
index 124f711a7..7a8244699 100644
--- a/src/device/usbd_control.c
+++ b/src/device/usbd_control.c
@@ -58,7 +58,6 @@ static usbd_control_xfer_t _ctrl_xfer;
CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN
static uint8_t _usbd_ctrl_buf[CFG_TUD_ENDPOINT0_SIZE];
-
//--------------------------------------------------------------------+
// Application API
//--------------------------------------------------------------------+