You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if it were possible to detect the following:
If the SPI chip is wired and initialized correctly.
If SPIFlash::begin() was called and completed successfully.
I'm modifying a FAT library that uses this library as a backend and it would be useful to know whether the chip and class have been initialized appropriately before calling read/write operations.
The text was updated successfully, but these errors were encountered:
You should be able to do this with the current v2.4.0-w.i.p branch. Call the *****.error() function after any other function call and it will return an 8-bit error code generated by that function. (Ref: Wiki page on error codes)
To check if the chip is initialized correctly I'd recommend calling it after begin(). The begin() function runs a chip ID subroutine which can determine if the chip initialises correctly. The simplest way to check for that would be to do something along the lines of this:
#include<SPIFlash.h>
#include<SPI.h>voidsetup() {
flash.begin();
if (error()) {
Serial.print("Error generated: ");
Serial.println(error());
break;
}
/* The rest of your code goes here */
}
voidloop() {
/* The rest of your code goes here */
}
I was wondering if it were possible to detect the following:
SPIFlash::begin()
was called and completed successfully.I'm modifying a FAT library that uses this library as a backend and it would be useful to know whether the chip and class have been initialized appropriately before calling read/write operations.
The text was updated successfully, but these errors were encountered: