From 47f534680215a68391a46cd45decde9b6f0a6573 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 18 Jun 2026 15:35:55 +0700 Subject: dcd/stm32_fsdev: tidy CH32 EP0 setup parsing and whitespace Parse the setup packet via tusb_control_request_t instead of hand-rolled byte indexing; drop a stray blank line and fix indentation. No functional change. Co-Authored-By: Claude Fable 5 --- src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c index 9c3431c20..8dd790404 100644 --- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c +++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c @@ -291,7 +291,7 @@ static void handle_ctr_tx(uint32_t ep_id) { #if defined(TUP_USBIP_FSDEV_CH32) // Control read: block unsolicited EP0 OUT ACK. if ((ep_num == 0u) && ep0_ctrl_dir_in && ep0_ctrl_has_data) { - ep0_set_type(U_EP_BULK, false); + ep0_set_type(U_EP_BULK, false); } #endif dcd_event_xfer_complete(0, ep_num | TUSB_DIR_IN_MASK, xfer->queued_len, XFER_RESULT_SUCCESS, true); @@ -311,9 +311,9 @@ static void handle_ctr_setup(uint32_t ep_id) { // Setup packet should always be 8 bytes. If not, we probably missed the packet if (rx_count == 8) { #if defined(TUP_USBIP_FSDEV_CH32) - uint16_t const setup_w_length = (uint16_t) setup_packet[6] | ((uint16_t) setup_packet[7] << 8); - ep0_ctrl_dir_in = (setup_packet[0] & TUSB_DIR_IN_MASK) != 0u; - ep0_ctrl_has_data = (setup_w_length != 0u); + tusb_control_request_t const *request = (tusb_control_request_t const *) (void *) setup_packet; + ep0_ctrl_dir_in = (request->bmRequestType_bit.direction == TUSB_DIR_IN); + ep0_ctrl_has_data = (request->wLength != 0u); // For control write, block unsolicited EP0 OUT ACK until transfer is armed in edpt_xfer(). if (!ep0_ctrl_dir_in && ep0_ctrl_has_data) { @@ -366,7 +366,6 @@ static void handle_ctr_rx(uint32_t ep_id) { } xfer->queued_len += rx_count; - if ((rx_count < xfer->max_packet_size) || (xfer->queued_len >= xfer->total_len)) { // all bytes received or short packet -- cgit v1.3.1