diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-10-01 02:51:45 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2010-10-01 02:51:45 +0000 |
commit | 9d30e36cbbdf3b9c5d8c05c4c7bea0e6b3c97f91 (patch) | |
tree | f63300e6600871316671d746b403120746b20ccf /nuttx/drivers | |
parent | d87a5740143d73f919f34c919286976a7783adce (diff) | |
download | px4-nuttx-9d30e36cbbdf3b9c5d8c05c4c7bea0e6b3c97f91.tar.gz px4-nuttx-9d30e36cbbdf3b9c5d8c05c4c7bea0e6b3c97f91.tar.bz2 px4-nuttx-9d30e36cbbdf3b9c5d8c05c4c7bea0e6b3c97f91.zip |
Use RECVBLOCK vs multiple SEND
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2957 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers')
-rw-r--r-- | nuttx/drivers/mtd/at45db.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/nuttx/drivers/mtd/at45db.c b/nuttx/drivers/mtd/at45db.c index ab8b39f0b..201fee0d6 100644 --- a/nuttx/drivers/mtd/at45db.c +++ b/nuttx/drivers/mtd/at45db.c @@ -330,10 +330,8 @@ static void at45db_resume(struct at45db_dev_s *priv) static inline int at45db_rdid(struct at45db_dev_s *priv) { - uint16_t manufacturer; - uint16_t devid1; - uint16_t devid2; - uint16_t capacity; + uint8_t capacity; + uint8_t devid[3]; fvdbg("priv: %p\n", priv); @@ -343,30 +341,28 @@ static inline int at45db_rdid(struct at45db_dev_s *priv) SPI_SELECT(priv->spi, SPIDEV_FLASH, true); - /* Send the " Manufacturer and Device ID Read" command and read the first three - * ID bytes + /* Send the " Manufacturer and Device ID Read" command and read the next three + * ID bytes from the FLASH. */ (void)SPI_SEND(priv->spi, AT45DB_RDDEVID); - manufacturer = SPI_SEND(priv->spi, 0xff); - devid1 = SPI_SEND(priv->spi, 0xff); - devid2 = SPI_SEND(priv->spi, 0xff); + SPI_RECVBLOCK(priv->spi, devid, 3); - /* Deselect the FLASH and unlock the bus */ + /* Deselect the FLASH */ SPI_SELECT(priv->spi, SPIDEV_FLASH, false); fvdbg("manufacturer: %02x devid1: %02x devid2: %02x\n", - manufacturer, devid1, devid2); + devid[0], devid[1], devid[2]); /* Check for a valid manufacturer and memory family */ - if (manufacturer == AT45DB_MANUFACTURER && - (devid1 & AT45DB_DEVID1_FAMMSK) == AT45DB_DEVID1_DFLASH) + if (devid[0] == AT45DB_MANUFACTURER && + (devid[1] & AT45DB_DEVID1_FAMMSK) == AT45DB_DEVID1_DFLASH) { /* Okay.. is it a FLASH capacity that we understand? */ - capacity = devid1 & AT45DB_DEVID1_CAPMSK; + capacity = devid[1] & AT45DB_DEVID1_CAPMSK; switch (capacity) { case AT45DB_DEVID1_1MBIT: |