diff options
| author | Ha Thach <[email protected]> | 2021-11-26 13:31:25 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-11-26 13:31:25 +0700 |
| commit | 79de83183fa7cd5ca0002bb79da99e6c034aa777 (patch) | |
| tree | e38c882d40fea8455a2759848d7b83c3ab02dc16 /src/class/cdc | |
| parent | ae73873b5cba0eb11c89165f4559964940430d44 (diff) | |
| parent | c9e9f4785f68c9f9e99c4832af8615847c5fae92 (diff) | |
Merge pull request #1208 from hathach/fix-nrf-easydma-race
fix nrf easy dma race condition
Diffstat (limited to 'src/class/cdc')
| -rw-r--r-- | src/class/cdc/cdc_device.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index 74c116192..08f2af253 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -80,7 +80,7 @@ typedef struct //--------------------------------------------------------------------+ CFG_TUSB_MEM_SECTION static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC]; -static void _prep_out_transaction (cdcd_interface_t* p_cdc) +static bool _prep_out_transaction (cdcd_interface_t* p_cdc) { uint8_t const rhport = TUD_OPT_RHPORT; uint16_t available = tu_fifo_remaining(&p_cdc->rx_ff); @@ -89,21 +89,23 @@ static void _prep_out_transaction (cdcd_interface_t* p_cdc) // TODO Actually we can still carry out the transfer, keeping count of received bytes // and slowly move it to the FIFO when read(). // This pre-check reduces endpoint claiming - TU_VERIFY(available >= sizeof(p_cdc->epout_buf), ); + TU_VERIFY(available >= sizeof(p_cdc->epout_buf)); // claim endpoint - TU_VERIFY(usbd_edpt_claim(rhport, p_cdc->ep_out), ); + TU_VERIFY(usbd_edpt_claim(rhport, p_cdc->ep_out)); // fifo can be changed before endpoint is claimed available = tu_fifo_remaining(&p_cdc->rx_ff); if ( available >= sizeof(p_cdc->epout_buf) ) { - usbd_edpt_xfer(rhport, p_cdc->ep_out, p_cdc->epout_buf, sizeof(p_cdc->epout_buf)); + return usbd_edpt_xfer(rhport, p_cdc->ep_out, p_cdc->epout_buf, sizeof(p_cdc->epout_buf)); }else { // Release endpoint since we don't make any transfer usbd_edpt_release(rhport, p_cdc->ep_out); + + return false; } } |
