Skip to content

Commit 983abfd

Browse files
authored
Merge pull request hathach#1279 from kasjer/kasjer/nrf5x-int-race
nrf5x: Fix EP OUT race conditions
2 parents 84f2ca7 + da44fe3 commit 983abfd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/portable/nordic/nrf5x/dcd_nrf5x.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,11 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
457457

458458
xfer_td_t* xfer = get_td(epnum, dir);
459459

460+
dcd_int_disable(rhport);
460461
xfer->buffer = buffer;
461462
xfer->total_len = total_bytes;
462463
xfer->actual_len = 0;
464+
dcd_int_enable(rhport);
463465

464466
// Control endpoint with zero-length packet and opposite direction to 1st request byte --> status stage
465467
bool const control_status = (epnum == 0 && total_bytes == 0 && dir != tu_edpt_dir(NRF_USBD->BMREQUESTTYPE));
@@ -480,7 +482,7 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
480482
edpt_dma_start(&NRF_USBD->TASKS_EP0RCVOUT);
481483
}else
482484
{
483-
if ( xfer->data_received )
485+
if ( xfer->data_received && xfer->total_len > xfer->actual_len)
484486
{
485487
// Data is already received previously
486488
// start DMA to copy to SRAM

0 commit comments

Comments
 (0)