summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2023-05-24 16:39:36 +0800
committersakumisu <[email protected]>2023-05-24 16:40:13 +0800
commit77c3f17b7d5162ccf4b02710aaa5dddc6cf5a7c1 (patch)
tree91cffb2f4437d1f46f7a1cbc4ee13858cad11388
parent01c6d6007673d32a736c17425e2415405d4133a4 (diff)
check with last to reduce set line coding repeatly
-rw-r--r--class/cdc/usbd_cdc.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/class/cdc/usbd_cdc.c b/class/cdc/usbd_cdc.c
index 1820037e..e3e310f3 100644
--- a/class/cdc/usbd_cdc.c
+++ b/class/cdc/usbd_cdc.c
@@ -16,6 +16,7 @@ static int cdc_acm_class_interface_request_handler(struct usb_setup_packet *setu
setup->bRequest);
struct cdc_line_coding line_coding;
+ struct cdc_line_coding line_coding_last;
bool dtr, rts;
uint8_t intf_num = LO_BYTE(setup->wIndex);
@@ -46,7 +47,13 @@ static int cdc_acm_class_interface_request_handler(struct usb_setup_packet *setu
line_coding.bDataBits,
parity_name[line_coding.bParityType],
stop_name[line_coding.bCharFormat]);
- usbd_cdc_acm_set_line_coding(intf_num, &line_coding);
+
+ /* check if current line coding is the same with last, if they are the same, do not set line coding */
+ usbd_cdc_acm_get_line_coding(intf_num, &line_coding_last);
+ if (memcmp(&line_coding_last, &line_coding, sizeof(struct cdc_line_coding))) {
+ usbd_cdc_acm_set_line_coding(intf_num, &line_coding);
+ }
+
break;
case CDC_REQUEST_SET_CONTROL_LINE_STATE: {