From 0efea19ac298d0c63abd87bd5516eb5b81215351 Mon Sep 17 00:00:00 2001 From: Felix Rusu Date: Fri, 2 Aug 2013 00:02:46 -0400 Subject: [PATCH] fix infinite loop bug when HIGH-Z MISO stays high When FLASH chip is not present and MISO is in high impedance, other SPI devices might pull MISO high and the while(busy) loop might never return because of a false positive busy (actually MISO would return 0XFF for status register including the BUSY bit) --- SPIFlash.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SPIFlash.cpp b/SPIFlash.cpp index 28536bf..bf35b62 100644 --- a/SPIFlash.cpp +++ b/SPIFlash.cpp @@ -62,7 +62,9 @@ boolean SPIFlash::initialize() /// Get the manufacturer and device ID bytes (as a short word) word SPIFlash::readDeviceId() { - command(SPIFLASH_IDREAD); // Read JEDEC ID + //command(SPIFLASH_IDREAD); // Read JEDEC ID + select(); + SPI.transfer(SPIFLASH_IDREAD); word jedecid = SPI.transfer(0) << 8; jedecid |= SPI.transfer(0); unselect();