Add busy() while() explanation

This commit is contained in:
LowPowerLab 2015-01-08 20:44:12 -05:00
parent 16e28cc666
commit a349130cc3
1 changed files with 6 additions and 1 deletions

View File

@ -139,7 +139,12 @@ void SPIFlash::command(byte cmd, boolean isWrite){
command(SPIFLASH_WRITEENABLE); // Write Enable
unselect();
}
while(busy()); //wait for any write/erase to complete
//wait for any write/erase to complete
// a time limit cannot really be added here without it being a very large safe limit
// that is because some chips can take several seconds to carry out a chip erase or other similar multi block or entire-chip operations
// a recommended alternative to such situations where chip can be or not be present is to add a 10k or similar weak pulldown on the
// open drain MISO input which can read noise/static and hence return a non 0 status byte, causing the while() to hang when a flash chip is not present
while(busy());
select();
SPI.transfer(cmd);
}