You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/07/12 20:00:23 UTC

[GitHub] [incubator-nuttx] acassis commented on a diff in pull request #6604: esp32s3: Add DMA support

acassis commented on code in PR #6604:
URL: https://github.com/apache/incubator-nuttx/pull/6604#discussion_r919373487


##########
arch/xtensa/src/esp32s3/esp32s3_spi.c:
##########
@@ -723,6 +808,126 @@ static int esp32s3_spi_hwfeatures(struct spi_dev_s *dev,
 }
 #endif
 
+/****************************************************************************
+ * Name: esp32s3_spi_dma_exchange
+ *
+ * Description:
+ *   Exchange a block of data from SPI by DMA.
+ *
+ * Input Parameters:
+ *   priv     - SPI private state data
+ *   txbuffer - A pointer to the buffer of data to be sent
+ *   rxbuffer - A pointer to the buffer in which to receive data
+ *   nwords   - the length of data that to be exchanged in units of words.
+ *              The wordsize is determined by the number of bits-per-word
+ *              selected for the SPI interface.  If nbits <= 8, the data is
+ *              packed into uint8_t's; if nbits >8, the data is packed into
+ *              uint16_t's
+ *
+ * Returned Value:
+ *   None.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ESP32S3_SPI2_DMA
+static void esp32s3_spi_dma_exchange(struct esp32s3_spi_priv_s *priv,
+                                     const void *txbuffer,
+                                     void *rxbuffer,
+                                     uint32_t nwords)
+{
+  const uint32_t total = nwords * (priv->nbits / 8);
+  const int32_t channel = priv->dma_channel;
+  uint32_t bytes = total;
+  uint32_t n;
+  uint8_t *tp;
+  uint8_t *rp;
+
+  DEBUGASSERT((txbuffer != NULL) || (rxbuffer != NULL));
+
+  spiinfo("nwords=%" PRIu32 "\n", nwords);
+
+  tp = (uint8_t *)txbuffer;
+  rp = (uint8_t *)rxbuffer;
+
+  if (tp == NULL)
+    {
+      tp = rp;
+    }
+
+  esp32s3_spi_set_regbits(SPI_DMA_INT_CLR_REG(priv->config->id),
+                          SPI_TRANS_DONE_INT_RAW_M);

Review Comment:
   True, I only considered the bit shift, but of course the name is wrong!



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org