net: remove CFG_TUD_NET_ENDPOINT_SIZE, manage ZLP based on real speed in drivers

Co-authored-by: HiFiPhile <4375114+HiFiPhile@users.noreply.github.com>
Agent-Logs-Url: https://github.com/hathach/tinyusb/sessions/5d355974-2223-4071-8d14-b6d4ac1fd030
This commit is contained in:
copilot-swe-agent[bot]
2026-03-22 19:54:27 +00:00
parent cec6ea2223
commit ebeb495bd0
11 changed files with 11 additions and 6 deletions

Submodule hw/mcu/st/cmsis_device_f4 added at 3c77349ce0

Submodule hw/mcu/st/stm32f4xx_hal_driver added at b6f0ed3829

1
lib/CMSIS_5 Submodule

Submodule lib/CMSIS_5 added at 2b7495b853

1
lib/FreeRTOS-Kernel Submodule

Submodule lib/FreeRTOS-Kernel added at cc0e0707c0

1
lib/lwip Submodule

Submodule lib/lwip added at 159e31b689

1
lib/threadx Submodule

Submodule lib/threadx added at 4b6e8100d9

View File

@ -356,8 +356,8 @@ bool netd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
/* data transmission finished */
if (ep_addr == _netd_itf.ep_in) {
/* TinyUSB requires the class driver to implement ZLP (since ZLP usage is class-specific) */
if (xferred_bytes && (0 == (xferred_bytes % CFG_TUD_NET_ENDPOINT_SIZE))) {
uint16_t const ep_size = (tud_speed_get() == TUSB_SPEED_HIGH) ? 512 : 64;
if (xferred_bytes && (0 == (xferred_bytes % ep_size))) {
do_in_xfer(NULL, 0); /* a ZLP is needed */
} else {
/* we're finally finished */

View File

@ -340,7 +340,7 @@ static xmit_ntb_t *xmit_get_next_ready_ntb(void) {
static bool xmit_insert_required_zlp(uint8_t rhport, uint32_t xferred_bytes) {
TU_LOG_DRV("xmit_insert_required_zlp(%d,%ld)\n", rhport, xferred_bytes);
if (xferred_bytes == 0 || xferred_bytes % CFG_TUD_NET_ENDPOINT_SIZE != 0) {
if (xferred_bytes == 0 || xferred_bytes % (tud_speed_get() == TUSB_SPEED_HIGH ? 512 : 64) != 0) {
return false;
}

View File

@ -35,9 +35,6 @@
#error "Cannot enable both ECM_RNDIS and NCM network drivers"
#endif
/* declared here, NOT in usb_descriptors.c, so that the driver can intelligently ZLP as needed */
#define CFG_TUD_NET_ENDPOINT_SIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
/* Maximum Transmission Unit (in bytes) of the network, including Ethernet header */
#ifndef CFG_TUD_NET_MTU
#define CFG_TUD_NET_MTU 1514

1
tools/linkermap Submodule

Submodule tools/linkermap added at 8e1f440fa1

1
tools/uf2 Submodule

Submodule tools/uf2 added at c594542b2f