mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 17:48:54 +08:00
Use RECVBLOCK vs multiple SEND
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2957 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+10
-14
@@ -330,10 +330,8 @@ static void at45db_resume(struct at45db_dev_s *priv)
|
|||||||
|
|
||||||
static inline int at45db_rdid(struct at45db_dev_s *priv)
|
static inline int at45db_rdid(struct at45db_dev_s *priv)
|
||||||
{
|
{
|
||||||
uint16_t manufacturer;
|
uint8_t capacity;
|
||||||
uint16_t devid1;
|
uint8_t devid[3];
|
||||||
uint16_t devid2;
|
|
||||||
uint16_t capacity;
|
|
||||||
|
|
||||||
fvdbg("priv: %p\n", priv);
|
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);
|
SPI_SELECT(priv->spi, SPIDEV_FLASH, true);
|
||||||
|
|
||||||
/* Send the " Manufacturer and Device ID Read" command and read the first three
|
/* Send the " Manufacturer and Device ID Read" command and read the next three
|
||||||
* ID bytes
|
* ID bytes from the FLASH.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(void)SPI_SEND(priv->spi, AT45DB_RDDEVID);
|
(void)SPI_SEND(priv->spi, AT45DB_RDDEVID);
|
||||||
manufacturer = SPI_SEND(priv->spi, 0xff);
|
SPI_RECVBLOCK(priv->spi, devid, 3);
|
||||||
devid1 = SPI_SEND(priv->spi, 0xff);
|
|
||||||
devid2 = SPI_SEND(priv->spi, 0xff);
|
|
||||||
|
|
||||||
/* Deselect the FLASH and unlock the bus */
|
/* Deselect the FLASH */
|
||||||
|
|
||||||
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
|
SPI_SELECT(priv->spi, SPIDEV_FLASH, false);
|
||||||
|
|
||||||
fvdbg("manufacturer: %02x devid1: %02x devid2: %02x\n",
|
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 */
|
/* Check for a valid manufacturer and memory family */
|
||||||
|
|
||||||
if (manufacturer == AT45DB_MANUFACTURER &&
|
if (devid[0] == AT45DB_MANUFACTURER &&
|
||||||
(devid1 & AT45DB_DEVID1_FAMMSK) == AT45DB_DEVID1_DFLASH)
|
(devid[1] & AT45DB_DEVID1_FAMMSK) == AT45DB_DEVID1_DFLASH)
|
||||||
{
|
{
|
||||||
/* Okay.. is it a FLASH capacity that we understand? */
|
/* Okay.. is it a FLASH capacity that we understand? */
|
||||||
|
|
||||||
capacity = devid1 & AT45DB_DEVID1_CAPMSK;
|
capacity = devid[1] & AT45DB_DEVID1_CAPMSK;
|
||||||
switch (capacity)
|
switch (capacity)
|
||||||
{
|
{
|
||||||
case AT45DB_DEVID1_1MBIT:
|
case AT45DB_DEVID1_1MBIT:
|
||||||
|
|||||||
Reference in New Issue
Block a user