summaryrefslogtreecommitdiff
path: root/nuttx/drivers
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-20 23:44:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-12-20 23:44:21 +0000
commit3f6973a6104b7ea2f4daf52cf2d06b694a7711e7 (patch)
tree6b8e2d48d86c56db9540d5a7d88e07fbe670fbba /nuttx/drivers
parentaec8ecfdad3e58bdec86a767047b9a9fc445d188 (diff)
downloadpx4-nuttx-3f6973a6104b7ea2f4daf52cf2d06b694a7711e7.tar.gz
px4-nuttx-3f6973a6104b7ea2f4daf52cf2d06b694a7711e7.tar.bz2
px4-nuttx-3f6973a6104b7ea2f4daf52cf2d06b694a7711e7.zip
STM32 ADC driver update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4208 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers')
-rw-r--r--nuttx/drivers/mtd/m25px.c39
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");
}