acassis commented on code in PR #17389:
URL: https://github.com/apache/nuttx/pull/17389#discussion_r2568205587
##########
arch/arm/src/samv7/sam_qspi_spi.c:
##########
@@ -398,6 +406,109 @@ static uint32_t qspi_spi_setfrequency(struct spi_dev_s
*dev,
return actual;
}
+/****************************************************************************
+ * Name: qspi_spi_setdelay
+ *
+ * Description:
+ * Set the QSPI Delays in nanoseconds. Optional.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * startdelay - The delay between CS active and first CLK
+ * stopdelay - The delay between last CLK and CS inactive
+ * csdelay - The delay between CS inactive and CS active again
+ * ifdelay - The delay between frames
+ *
+ * Returned Value:
+ * Returns 0 if ok
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SPI_DELAY_CONTROL
+static int qspi_spi_setdelay(struct spi_dev_s *dev, uint32_t startdelay,
+ uint32_t stopdelay, uint32_t csdelay,
+ uint32_t ifdelay)
+{
+ struct sam_spidev_s *spi = &g_spidev;
+ uint64_t dlybs;
+ uint64_t dlybct;
+ uint64_t dlybcs;
+ uint32_t regval;
+
+ spiinfo("startdelay=%" PRIu32 "\n", startdelay);
+ spiinfo("stopdelay=%" PRIu32 "\n", stopdelay);
+ spiinfo("csdelay=%" PRIu32 "\n", csdelay);
+ spiinfo("ifdelay=%" PRIu32 "\n", ifdelay);
+
+ /* startdelay = DLYBS: Delay Before SPCK.
+ * This field defines the delay from NPCS valid to the first valid SPCK
+ * transition. When DLYBS equals zero, the NPCS valid to SPCK transition is
+ * 1/2 the SPCK clock period.
+ * Otherwise, the following equations determine the delay:
+ *
+ * Delay Before SPCK = DLYBS / SPI_CLK
+ *
+ * For a 2uS delay
+ *
+ * DLYBS = SPI_CLK * 0.000002 = SPI_CLK / 500000
+ *
+ * TODO: Check for boundaries!
+ */
+
+ dlybs = SAM_QSPI_CLOCK;
+ dlybs *= startdelay;
+ dlybs /= 1000000000;
Review Comment:
I'm ok these three lines, but why not just use:
dlybs = (SAM_QSPI_CLOCK * startdelay) / 1000000000;
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]