repair ack

This commit is contained in:
Kizarm 2024-10-12 14:02:13 +02:00
parent 9f238310f1
commit 7905132333

View file

@ -292,7 +292,7 @@ __always_inline void cdc_class::OutTokenHandler(const uint8_t intst) {
const char *ptr = reinterpret_cast<const char*> (USBFS_EP2_Buf);
USBFSD->UEP2_RX_CTRL = (USBFSD->UEP2_RX_CTRL & ~USBFS_UEP_R_RES_MASK) | USBFS_UEP_R_RES_NAK;
Up (ptr, rlen);
USBFSD->UEP2_RX_CTRL = (USBFSD->UEP2_RX_CTRL & ~USBFS_UEP_R_RES_MASK) | USBFS_UEP_R_RES_NAK;
USBFSD->UEP2_RX_CTRL = (USBFSD->UEP2_RX_CTRL & ~USBFS_UEP_R_RES_MASK) | USBFS_UEP_R_RES_ACK;
} break;
default:
@ -665,12 +665,10 @@ uint32_t cdc_class::Down (const char * data, const uint32_t len) {
uint32_t rem = len;
const uint32_t max = DEF_USBD_ENDP3_SIZE;
const uint8_t * ptr = reinterpret_cast<const uint8_t*> (data);
// zde se musí počkat, nevím proč, ale jinak to nechodí
delay_us(1'000); // 1ms stačí pro odchod paketu po USB
while (rem) {
const uint32_t chunk = rem > max ? max : rem;
if (USBFS_Endp_DataUp (DEF_UEP3, ptr, chunk, DEF_UEP_CPY_LOAD)) {
delay_us(1'000); // čekej dokud je USBFS_Endp_Busy
delay_us(10); // čekej dokud je USBFS_Endp_Busy
} else {
ptr += chunk;
rem -= chunk;