This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new edf3cc55a58 drivers/mtd/w25: support custom SPI transfers delay
edf3cc55a58 is described below
commit edf3cc55a5829ded2744c3ef700cfcb4731023f3
Author: Michal Lenc <[email protected]>
AuthorDate: Thu Nov 27 10:42:15 2025 +0100
drivers/mtd/w25: support custom SPI transfers delay
This commit adds SPI_SETDELAY interface if CONFIG_SPI_DELAY_CONTROL
option is set. This allows to set custom delay between SPI transfers,
chip selects and so on.
Default values are set to 0. W25 SPI NOR flash works with them and
I haven't found any other values in the datasheet.
Signed-off-by: Michal Lenc <[email protected]>
---
drivers/mtd/Kconfig | 32 ++++++++++++++++++++++++++++++++
drivers/mtd/w25.c | 5 +++++
2 files changed, 37 insertions(+)
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 0104ae2177f..0a70ccbd313 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -1352,6 +1352,38 @@ config W25_SPIFREQUENCY
int "W25 SPI Frequency"
default 20000000
+config W25_START_DELAY
+ int "W25 SPI start delay"
+ depends on SPI_DELAY_CONTROL
+ range 0 1000000
+ default 0
+ ---help---
+ The delay between CS active and first CLK. In ns.
+
+config W25_STOP_DELAY
+ int "W25 SPI stop delay"
+ depends on SPI_DELAY_CONTROL
+ range 0 1000000
+ default 0
+ ---help---
+ The delay between last CLK and CS inactive. In ns.
+
+config W25_CS_DELAY
+ int "W25 SPI chip select delay"
+ depends on SPI_DELAY_CONTROL
+ range 0 1000000
+ default 0
+ ---help---
+ The delay between CS inactive and CS active again. In ns.
+
+config W25_IFDELAY
+ int "W25 SPI frames delay"
+ depends on SPI_DELAY_CONTROL
+ range 0 1000000
+ default 0
+ ---help---
+ The delay between consecutive frames. In ns.
+
config W25_READONLY
bool "W25 Read-Only FLASH"
default n
diff --git a/drivers/mtd/w25.c b/drivers/mtd/w25.c
index a5ef7b560cd..0a025183c7d 100644
--- a/drivers/mtd/w25.c
+++ b/drivers/mtd/w25.c
@@ -354,6 +354,11 @@ static void w25_lock(FAR struct spi_dev_s *spi)
SPI_SETBITS(spi, 8);
SPI_HWFEATURES(spi, 0);
SPI_SETFREQUENCY(spi, CONFIG_W25_SPIFREQUENCY);
+#ifdef CONFIG_SPI_DELAY_CONTROL
+ SPI_SETDELAY(spi, CONFIG_W25_START_DELAY,
+ CONFIG_W25_STOP_DELAY, CONFIG_W25_CS_DELAY,
+ CONFIG_W25_IFDELAY);
+#endif
}
/****************************************************************************