From 6e02a69ecaaf4e124e899e5b1c406d6389bcad42 Mon Sep 17 00:00:00 2001
From: iabdalkader <i.abdalkader@gmail.com>
Date: Sat, 31 Aug 2024 09:51:47 +0200
Subject: [PATCH] shared/TinyUSB: Allow boards to override CDC buffer sizes.

---
 shared/tinyusb/tusb_config.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/shared/tinyusb/tusb_config.h b/shared/tinyusb/tusb_config.h
index 9347042246d8..0cc5ef03985e 100644
--- a/shared/tinyusb/tusb_config.h
+++ b/shared/tinyusb/tusb_config.h
@@ -77,8 +77,12 @@
 
 // CDC Configuration
 #if CFG_TUD_CDC
-#define CFG_TUD_CDC_RX_BUFSIZE  (CFG_TUD_CDC_EP_BUFSIZE)
-#define CFG_TUD_CDC_TX_BUFSIZE  (CFG_TUD_CDC_EP_BUFSIZE)
+#ifndef CFG_TUD_CDC_RX_BUFSIZE
+#define CFG_TUD_CDC_RX_BUFSIZE  ((CFG_TUD_MAX_SPEED == OPT_MODE_HIGH_SPEED) ? 512 : 256)
+#endif
+#ifndef CFG_TUD_CDC_TX_BUFSIZE
+#define CFG_TUD_CDC_TX_BUFSIZE  ((CFG_TUD_MAX_SPEED == OPT_MODE_HIGH_SPEED) ? 512 : 256)
+#endif
 #endif
 
 // MSC Configuration