From 279282b51f298206edbc5a735aa1cb3fab37b9e5 Mon Sep 17 00:00:00 2001 From: Felix Rusu Date: Tue, 19 Jan 2021 12:48:53 -0500 Subject: [PATCH] Update examples --- examples/SPIFlash_Detect/SPIFlash_Detect.ino | 11 +++++------ examples/SPIFlash_ReadWrite/SPIFlash_ReadWrite.ino | 10 ++++++++-- 2 files changed, 13 insertions(+), 8 deletions(-) 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);