Skip to content

Commit 6fe0aa0

Browse files
committed
Fix LPC17XX and LPC40XX USB data throttling
Only clear the USB read buffer when endpointRead is called. This allows data to be read with endpointReadResult without also allowing USB to transfer more data. Instead additional data is transferred explicitly with a call to endpointRead.
1 parent eda332c commit 6fe0aa0

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

features/unsupported/USBDevice/targets/TARGET_NXP/USBHAL_LPC17.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,6 @@ uint32_t USBHAL::endpointReadcore(uint8_t endpoint, uint8_t *buffer) {
275275

276276
LPC_USB->USBCtrl = 0;
277277

278-
if ((endpoint >> 1) % 3 || (endpoint >> 1) == 0) {
279-
SIEselectEndpoint(endpoint);
280-
SIEclearBuffer();
281-
}
282-
283278
return size;
284279
}
285280

@@ -431,7 +426,7 @@ void USBHAL::EP0setup(uint8_t *buffer) {
431426
}
432427

433428
void USBHAL::EP0read(void) {
434-
// Not required
429+
endpointRead(EP0OUT, MAX_PACKET_SIZE_EP0);
435430
}
436431

437432
void USBHAL::EP0readStage(void) {
@@ -456,6 +451,11 @@ void USBHAL::EP0stall(void) {
456451
}
457452

458453
EP_STATUS USBHAL::endpointRead(uint8_t endpoint, uint32_t maximumSize) {
454+
// Don't clear isochronous endpoints
455+
if ((endpoint >> 1) % 3 || (endpoint >> 1) == 0) {
456+
SIEselectEndpoint(endpoint);
457+
SIEclearBuffer();
458+
}
459459
return EP_PENDING;
460460
}
461461

features/unsupported/USBDevice/targets/TARGET_NXP/USBHAL_LPC40.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,6 @@ uint32_t USBHAL::endpointReadcore(uint8_t endpoint, uint8_t *buffer) {
276276

277277
LPC_USB->Ctrl = 0;
278278

279-
if ((endpoint >> 1) % 3 || (endpoint >> 1) == 0) {
280-
SIEselectEndpoint(endpoint);
281-
SIEclearBuffer();
282-
}
283-
284279
return size;
285280
}
286281

@@ -436,7 +431,7 @@ void USBHAL::EP0setup(uint8_t *buffer) {
436431
}
437432

438433
void USBHAL::EP0read(void) {
439-
// Not required
434+
endpointRead(EP0OUT, MAX_PACKET_SIZE_EP0);
440435
}
441436

442437
void USBHAL::EP0readStage(void) {
@@ -461,6 +456,11 @@ void USBHAL::EP0stall(void) {
461456
}
462457

463458
EP_STATUS USBHAL::endpointRead(uint8_t endpoint, uint32_t maximumSize) {
459+
// Don't clear isochronous endpoints
460+
if ((endpoint >> 1) % 3 || (endpoint >> 1) == 0) {
461+
SIEselectEndpoint(endpoint);
462+
SIEclearBuffer();
463+
}
464464
return EP_PENDING;
465465
}
466466

0 commit comments

Comments
 (0)