Merge branch 'fix/usb/buffer_sizes_backport_v4.4' into 'release/v4.4'

usb: TinyUSB buffer sizes (backport v4.4)

See merge request espressif/esp-idf!18502
This commit is contained in:
Jiang Jiang Jian 2022-06-15 10:51:27 +08:00
commit aa95c6545b
2 changed files with 5 additions and 8 deletions

View File

@ -125,6 +125,7 @@ menu "TinyUSB Stack"
depends on TINYUSB_MSC_ENABLED
int "MSC FIFO size"
default 512
range 64 10000
help
MSC FIFO size, in bytes.
endmenu # "Massive Storage Class"
@ -140,6 +141,7 @@ menu "TinyUSB Stack"
depends on TINYUSB_CDC_ENABLED
int "CDC FIFO size of RX channel"
default 64
range 64 10000
help
CDC FIFO size of RX channel.

View File

@ -24,7 +24,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 {
bool initialized;
@ -86,7 +86,6 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
}
}
/* Invoked when CDC interface received data from host */
void tud_cdc_rx_cb(uint8_t itf)
{
@ -164,8 +163,6 @@ void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char)
}
}
esp_err_t tinyusb_cdcacm_register_callback(tinyusb_cdcacm_itf_t itf,
cdcacm_event_type_t event_type,
tusb_cdcacm_callback_t callback)
@ -195,7 +192,6 @@ esp_err_t tinyusb_cdcacm_register_callback(tinyusb_cdcacm_itf_t itf,
}
}
esp_err_t tinyusb_cdcacm_unregister_callback(tinyusb_cdcacm_itf_t itf,
cdcacm_event_type_t event_type)
{
@ -280,7 +276,6 @@ esp_err_t tinyusb_cdcacm_read(tinyusb_cdcacm_itf_t itf, uint8_t *out_buf, size_t
return ESP_OK;
}
size_t tinyusb_cdcacm_write_queue_char(tinyusb_cdcacm_itf_t itf, char ch)
{
if (!get_acm(itf)) { // non-initialized
@ -289,13 +284,13 @@ size_t tinyusb_cdcacm_write_queue_char(tinyusb_cdcacm_itf_t itf, char ch)
return tud_cdc_n_write_char(itf, ch);
}
size_t tinyusb_cdcacm_write_queue(tinyusb_cdcacm_itf_t itf, const uint8_t *in_buf, size_t in_size)
{
if (!get_acm(itf)) { // non-initialized
return 0;
}
return tud_cdc_n_write(itf, in_buf, in_size);
const uint32_t size_available = tud_cdc_n_write_available(itf);
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)