Skip to content

Commit

Permalink
GD32F205: Fix occassional problems with USB serial port
Browse files Browse the repository at this point in the history
Return proper error on unknown requests.
Don't hang on received data.
  • Loading branch information
PetteriAimonen committed Dec 2, 2024
1 parent f68e827 commit b905521
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ZuluSCSI_platform_GD32F205/gd32_cdc_acm_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ static uint8_t cdc_acm_req (usb_dev *udev, usb_req *req)
break;

default:
break;
return REQ_NOTSUPP;
}

return USBD_OK;
Expand Down
9 changes: 9 additions & 0 deletions lib/ZuluSCSI_platform_GD32F205/usb_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ bool usb_serial_ready(void)
// check that (our) serial is the currently active class
if ((USBD_CONFIGURED == cdc_acm.dev.cur_status) && (cdc_acm.dev.desc == &gd32_cdc_desc))
{
gd32_usb_cdc_handler *cdc = (gd32_usb_cdc_handler *)cdc_acm.dev.class_data[CDC_COM_INTERFACE];
if (cdc->packet_receive)
{
// Discard any received data.
// Otherwise it queues up on the host side and can cause the port to hang.
cdc->packet_receive = 0;
gd32_cdc_acm_data_receive(&cdc_acm);
}

if (1U == gd32_cdc_acm_check_ready(&cdc_acm))
{
return true;
Expand Down

0 comments on commit b905521

Please sign in to comment.