diff --git a/examples/SPIFlash_Detect/SPIFlash_Detect.ino b/examples/SPIFlash_Detect/SPIFlash_Detect.ino index 14dcdfc..666b9bc 100644 --- a/examples/SPIFlash_Detect/SPIFlash_Detect.ino +++ b/examples/SPIFlash_Detect/SPIFlash_Detect.ino @@ -3,7 +3,7 @@ #include //https://github.com/lowpowerlab/spiflash #include -#define SERIAL_ENABLE +#define SERIAL_BAUD 115200 #define BLINK_FAST_DELAY 50 #define BLINK_SLOW_DELAY 1000 @@ -12,15 +12,14 @@ int LEDTIME = 500; // the setup routine runs once when you press reset: void setup() { -#ifdef SERIAL_ENABLE - Serial.begin(115200); - delay(2000); //wait a bit until SerialMonitor can be opened +#ifdef SERIAL_BAUD + Serial.begin(SERIAL_BAUD); + while (!Serial) delay(100); //wait until Serial/monitor is opened #endif pinMode(LED_BUILTIN, OUTPUT); //ensure the radio module CS pin is pulled HIGH or it might interfere! - pinMode(SS, OUTPUT); - digitalWrite(SS, HIGH); + pinMode(SS, OUTPUT); digitalWrite(SS, HIGH); //ensure FLASH chip is not sleep mode (unresponsive) flash.wakeup(); diff --git a/examples/SPIFlash_ReadWrite/SPIFlash_ReadWrite.ino b/examples/SPIFlash_ReadWrite/SPIFlash_ReadWrite.ino index d4a4747..ab36b30 100644 --- a/examples/SPIFlash_ReadWrite/SPIFlash_ReadWrite.ino +++ b/examples/SPIFlash_ReadWrite/SPIFlash_ReadWrite.ino @@ -53,9 +53,17 @@ uint16_t expectedDeviceID=0xEF30; SPIFlash flash(SS_FLASHMEM, expectedDeviceID); void setup(){ +#ifdef SERIAL_BAUD Serial.begin(SERIAL_BAUD); + while (!Serial) delay(100); //wait until Serial/monitor is opened +#endif + pinMode(LED_BUILTIN, OUTPUT); + Serial.print("Start..."); + //ensure the radio module CS pin is pulled HIGH or it might interfere! + pinMode(SS, OUTPUT); digitalWrite(SS, HIGH); + if (flash.initialize()) { Serial.println("Init OK!"); @@ -134,14 +142,12 @@ void loop(){ if ((int)(millis()/500) > lastPeriod) { lastPeriod++; - pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, lastPeriod%2); } } void Blink(int DELAY_MS, byte loops) { - pinMode(LED_BUILTIN, OUTPUT); while (loops--) { digitalWrite(LED_BUILTIN,HIGH);