raiden00pl commented on a change in pull request #2270: URL: https://github.com/apache/incubator-nuttx/pull/2270#discussion_r520335981
########## File path: arch/arm/src/nrf52/nrf52_spi.c ########## @@ -983,51 +1089,86 @@ static void nrf52_spi_exchange(FAR struct spi_dev_s *dev, regval = (uint32_t)txbuffer; nrf52_spi_putreg(priv, NRF52_SPIM_TXDPTR_OFFSET, regval); - - /* Write number of bytes in TXD buffer */ - - regval = nwords; - nrf52_spi_putreg(priv, NRF52_SPIM_TXDMAXCNT_OFFSET, regval); } else { nrf52_spi_putreg(priv, NRF52_SPIM_TXDMAXCNT_OFFSET, 0); } - /* SPI start */ + /* If more than 255 bytes, enable list mode to send data + * in batches + */ + + if (nwords > 0xff) + { + if (rxbuffer != NULL) + { + nrf52_spi_putreg(priv, NRF52_SPIM_RXDLIST_OFFSET, 1); + } + + if (txbuffer != NULL) + { + nrf52_spi_putreg(priv, NRF52_SPIM_TXDLIST_OFFSET, 1); + } + } + + while (nwords_left > 0) + { + size_t transfer_size = (nwords_left > 255 ? 255 : nwords_left); - nrf52_spi_putreg(priv, NRF52_SPIM_TASK_START_OFFSET, SPIM_TASKS_START); + if (rxbuffer != NULL) + { + /* Write number of bytes in RXD buffer */ -#ifndef CONFIG_NRF52_SPI_MASTER_INTERRUPTS - /* Wait for RX done and TX done */ + nrf52_spi_putreg(priv, NRF52_SPIM_RXDMAXCNT_OFFSET, transfer_size); + } - while (nrf52_spi_getreg(priv, NRF52_SPIM_EVENTS_END_OFFSET) != 1); + if (txbuffer != NULL) + { + /* Write number of bytes in TXD buffer */ - /* Clear event */ + nrf52_spi_putreg(priv, NRF52_SPIM_TXDMAXCNT_OFFSET, transfer_size); + } - nrf52_spi_putreg(priv, NRF52_SPIM_EVENTS_END_OFFSET, 0); -#else - /* Wait for transfer complete */ + /* SPI start */ - nxsem_wait(&priv->sem_isr); -#endif + nrf52_spi_putreg(priv, NRF52_SPIM_TASK_START_OFFSET, SPIM_TASKS_START); - if (nrf52_spi_getreg(priv, NRF52_SPIM_TXDAMOUNT_OFFSET) != nwords) - { - spierr("Incomplete transfer wrote %d expected %d\n", regval, nwords); - } + #ifndef CONFIG_NRF52_SPI_MASTER_INTERRUPTS Review comment: ```suggestion #ifndef CONFIG_NRF52_SPI_MASTER_INTERRUPTS ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org