Browse Source

usb: Clean-up TinyUSB unnecessary code

Tomas Rezucha 3 năm trước cách đây
mục cha
commit
5d202aa401

+ 0 - 42
components/tinyusb/additions/include/tinyusb.h

@@ -18,48 +18,6 @@
 extern "C" {
 #endif
 
-
-/* tinyusb uses buffers with type of uint8_t[] but in our driver we are reading them as a 32-bit word */
-#if (CFG_TUD_ENDPOINT0_SIZE < 4)
-#   define CFG_TUD_ENDPOINT0_SIZE 4
-#   warning "CFG_TUD_ENDPOINT0_SIZE was too low and was set to 4"
-#endif
-
-#if TUSB_OPT_DEVICE_ENABLED
-
-#   if CFG_TUD_HID
-#      if (CFG_TUD_HID_BUFSIZE < 4)
-#         define CFG_TUD_HID_BUFSIZE 4
-#         warning "CFG_TUD_HID_BUFSIZE was too low and was set to 4"
-#      endif
-#   endif
-
-#   if CFG_TUD_CDC
-#      if (CFG_TUD_CDC_EP_BUFSIZE < 4)
-#         define CFG_TUD_CDC_EP_BUFSIZE 4
-#         warning "CFG_TUD_CDC_EP_BUFSIZE was too low and was set to 4"
-#      endif
-#   endif
-
-#   if CFG_TUD_MSC
-#      if (CFG_TUD_MSC_BUFSIZE < 4)
-#         define CFG_TUD_MSC_BUFSIZE 4
-#         warning "CFG_TUD_MSC_BUFSIZE was too low and was set to 4"
-#      endif
-#   endif
-
-#   if CFG_TUD_MIDI
-#       if (CFG_TUD_MIDI_EPSIZE < 4)
-#          define CFG_TUD_MIDI_EPSIZE 4
-#          warning "CFG_TUD_MIDI_EPSIZE was too low and was set to 4"
-#       endif
-#   endif
-
-#   if CFG_TUD_CUSTOM_CLASS
-#          warning "Please check that the buffer is more then 4 bytes"
-#   endif
-#endif
-
 /**
  * @brief Configuration structure of the tinyUSB core
  */

+ 2 - 1
components/tinyusb/additions/src/tusb_cdc_acm.c

@@ -17,6 +17,7 @@
 #include "sdkconfig.h"
 
 #define RX_UNREADBUF_SZ_DEFAULT 64 // buffer storing all unread RX data
+#define MIN(x, y) (((x) < (y)) ? (x) : (y))
 
 
 typedef struct {
@@ -283,7 +284,7 @@ size_t tinyusb_cdcacm_write_queue(tinyusb_cdcacm_itf_t itf, const uint8_t *in_bu
         return 0;
     }
     const uint32_t size_available = tud_cdc_n_write_available(itf);
-    return tud_cdc_n_write(itf, in_buf, (in_size < size_available) ? in_size : size_available);
+    return tud_cdc_n_write(itf, in_buf, MIN(in_size, size_available));
 }
 
 static uint32_t tud_cdc_n_write_occupied(tinyusb_cdcacm_itf_t itf)

+ 1 - 1
examples/peripherals/usb/device/tusb_serial_device/main/tusb_serial_device_main.c

@@ -44,7 +44,7 @@ void tinyusb_cdc_line_state_changed_callback(int itf, cdcacm_event_t *event)
 void app_main(void)
 {
     ESP_LOGI(TAG, "USB initialization");
-    tinyusb_config_t tusb_cfg = {}; // the configuration using default values
+    const tinyusb_config_t tusb_cfg = {}; // the configuration using default values
     ESP_ERROR_CHECK(tinyusb_driver_install(&tusb_cfg));
 
     tinyusb_config_cdcacm_t amc_cfg = {