mirror of
https://github.com/apache/nuttx.git
synced 2026-03-27 10:39:28 +08:00
drivers/mtd/w25.c: Enable short delay after sector/chip erase
This commit is contained in:
committed by
Gregory Nutt
parent
369b72f65a
commit
7af5cbb833
@@ -224,6 +224,7 @@ struct w25_dev_s
|
||||
struct mtd_dev_s mtd; /* MTD interface */
|
||||
FAR struct spi_dev_s *spi; /* Saved SPI interface instance */
|
||||
uint16_t nsectors; /* Number of erase sectors */
|
||||
uint8_t prev_instr; /* Previous instruction given to W25 device */
|
||||
|
||||
#if defined(CONFIG_W25_SECTOR512) && !defined(CONFIG_W25_READONLY)
|
||||
uint8_t flags; /* Buffered sector flags */
|
||||
@@ -495,17 +496,17 @@ static uint8_t w25_waitwritecomplete(struct w25_dev_s *priv)
|
||||
|
||||
/* Given that writing could take up to few tens of milliseconds, and erasing
|
||||
* could take more. The following short delay in the "busy" case will allow
|
||||
* other peripherals to access the SPI bus.
|
||||
* other peripherals to access the SPI bus. Delay would slow down writing
|
||||
* too much, so go to sleep only if previous operation was not a page program
|
||||
* operation.
|
||||
*/
|
||||
|
||||
#if 0 /* Makes writes too slow */
|
||||
if ((status & W25_SR_BUSY) != 0)
|
||||
if (priv->prev_instr != W25_PP && (status & W25_SR_BUSY) != 0)
|
||||
{
|
||||
w25_unlock(priv->spi);
|
||||
usleep(1000);
|
||||
w25_lock(priv->spi);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
while ((status & W25_SR_BUSY) != 0);
|
||||
|
||||
@@ -633,6 +634,7 @@ static void w25_sectorerase(struct w25_dev_s *priv, off_t sector)
|
||||
/* Send the "Sector Erase (SE)" instruction */
|
||||
|
||||
(void)SPI_SEND(priv->spi, W25_SE);
|
||||
priv->prev_instr = W25_SE;
|
||||
|
||||
/* Send the sector address high byte first. Only the most significant bits (those
|
||||
* corresponding to the sector) have any meaning.
|
||||
@@ -670,6 +672,7 @@ static inline int w25_chiperase(struct w25_dev_s *priv)
|
||||
/* Send the "Chip Erase (CE)" instruction */
|
||||
|
||||
(void)SPI_SEND(priv->spi, W25_CE);
|
||||
priv->prev_instr = W25_CE;
|
||||
|
||||
/* Deselect the FLASH */
|
||||
|
||||
@@ -706,8 +709,10 @@ static void w25_byteread(FAR struct w25_dev_s *priv, FAR uint8_t *buffer,
|
||||
|
||||
#ifdef CONFIG_W25_SLOWREAD
|
||||
(void)SPI_SEND(priv->spi, W25_RDDATA);
|
||||
priv->prev_instr = W25_RDDATA;
|
||||
#else
|
||||
(void)SPI_SEND(priv->spi, W25_FRD);
|
||||
priv->prev_instr = W25_FRD;
|
||||
#endif
|
||||
|
||||
/* Send the address high byte first. */
|
||||
@@ -763,6 +768,7 @@ static void w25_pagewrite(struct w25_dev_s *priv, FAR const uint8_t *buffer,
|
||||
/* Send the "Page Program (W25_PP)" Command */
|
||||
|
||||
SPI_SEND(priv->spi, W25_PP);
|
||||
priv->prev_instr = W25_PP;
|
||||
|
||||
/* Send the address high byte first. */
|
||||
|
||||
@@ -819,6 +825,7 @@ static inline void w25_bytewrite(struct w25_dev_s *priv, FAR const uint8_t *buff
|
||||
/* Send "Page Program (PP)" command */
|
||||
|
||||
(void)SPI_SEND(priv->spi, W25_PP);
|
||||
priv->prev_instr = W25_PP;
|
||||
|
||||
/* Send the page offset high byte first. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user