diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2011-12-20 23:44:21 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2011-12-20 23:44:21 +0000 |
commit | 67609317a56867512eee5eb477d2331d8c3fd491 (patch) | |
tree | 6b8e2d48d86c56db9540d5a7d88e07fbe670fbba /nuttx/drivers/mtd | |
parent | 468bf27b12a7725bbeea610d240176b7356cd50b (diff) | |
download | px4-firmware-67609317a56867512eee5eb477d2331d8c3fd491.tar.gz px4-firmware-67609317a56867512eee5eb477d2331d8c3fd491.tar.bz2 px4-firmware-67609317a56867512eee5eb477d2331d8c3fd491.zip |
STM32 ADC driver update
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4208 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/drivers/mtd')
-rw-r--r-- | nuttx/drivers/mtd/m25px.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/nuttx/drivers/mtd/m25px.c b/nuttx/drivers/mtd/m25px.c index cfdb1ea97..6fc613d7c 100644 --- a/nuttx/drivers/mtd/m25px.c +++ b/nuttx/drivers/mtd/m25px.c @@ -67,7 +67,10 @@ # define CONFIG_MP25P_SPIMODE SPIDEV_MODE0 #endif -/* Various manufacturers may have produced the parts */ +/* Various manufacturers may have produced the parts. 0x20 is the manufacturer ID + * for the STMicro MP25x serial FLASH. If, for example, you are using the a Macronix + * International MX25 serial FLASH, the correct manufacturer ID would be 0xc2. + */ #ifndef CONFIG_MP25P_MANUFACTURER # define CONFIG_MP25P_MANUFACTURER 0x20 @@ -317,6 +320,34 @@ static void m25p_waitwritecomplete(struct m25p_dev_s *priv) { uint8_t status; + /* Are we the only device on the bus? */ + +#ifdef CONFIG_SPI_OWNBUS + + /* Select this FLASH part */ + + SPI_SELECT(priv->dev, SPIDEV_FLASH, true); + + /* Send "Read Status Register (RDSR)" command */ + + (void)SPI_SEND(priv->dev, M25P_RDSR); + + /* Loop as long as the memory is busy with a write cycle */ + + do + { + /* Send a dummy byte to generate the clock needed to shift out the status */ + + status = SPI_SEND(priv->dev, M25P_DUMMY); + } + while ((status & M25P_SR_WIP) != 0); + + /* Deselect the FLASH */ + + SPI_SELECT(priv->dev, SPIDEV_FLASH, false); + +#else + /* Loop as long as the memory is busy with a write cycle */ do @@ -337,6 +368,11 @@ static void m25p_waitwritecomplete(struct m25p_dev_s *priv) SPI_SELECT(priv->dev, SPIDEV_FLASH, false); + /* 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. + */ + if ((status & M25P_SR_WIP) != 0) { m25p_unlock(priv->dev); @@ -345,6 +381,7 @@ static void m25p_waitwritecomplete(struct m25p_dev_s *priv) } } while ((status & M25P_SR_WIP) != 0); +#endif fvdbg("Complete\n"); } |