Fix some wrong synchronization waits in usb_write()

To make the full use of the ping-pong endpoint
Transfer speed before this fix:
616448,618496,618496,615424,615424->616857.6 bytes/s
Transfer speed after this fix:
707584,709632,707584,709632,710656->709017.6 bytes/s (+14.9%)
Tested by running hw status
This commit is contained in:
wh201906 2023-10-24 00:46:28 +08:00
parent e20742dd04
commit 72da0c9623
No known key found for this signature in database

View file

@ -797,7 +797,7 @@ int usb_write(const uint8_t *data, const size_t len) {
while (pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP) {}; while (pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP) {};
UDP_SET_EP_FLAGS(AT91C_EP_IN, AT91C_UDP_TXPKTRDY); UDP_SET_EP_FLAGS(AT91C_EP_IN, AT91C_UDP_TXPKTRDY);
while (pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXPKTRDY) {}; while (!(pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXPKTRDY)) {};
} }
// Wait for the end of transfer // Wait for the end of transfer
@ -812,7 +812,7 @@ int usb_write(const uint8_t *data, const size_t len) {
if (len % AT91C_EP_IN_SIZE == 0) { if (len % AT91C_EP_IN_SIZE == 0) {
UDP_SET_EP_FLAGS(AT91C_EP_IN, AT91C_UDP_TXPKTRDY); UDP_SET_EP_FLAGS(AT91C_EP_IN, AT91C_UDP_TXPKTRDY);
while (!(pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP)) {}; while (!(pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXPKTRDY)) {};
UDP_CLEAR_EP_FLAGS(AT91C_EP_IN, AT91C_UDP_TXCOMP); UDP_CLEAR_EP_FLAGS(AT91C_EP_IN, AT91C_UDP_TXCOMP);
while (pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP) {}; while (pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP) {};