diff --git a/SPIFlash.cpp b/SPIFlash.cpp index e250c17..9d043b8 100644 --- a/SPIFlash.cpp +++ b/SPIFlash.cpp @@ -50,6 +50,15 @@ SPIFlash::SPIFlash(uint8_t slaveSelectPin, uint16_t jedecID) { _jedecID = jedecID; } +/// Empty constructor to permit late pin and JedecID assignment. +SPIFlash::SPIFlash() {} + +/// Set the pin and JedecID. (Only needed if the empty constructor was used.) +void SPIFlash::begin(uint8_t slaveSelectPin, uint16_t jedecID) { + _slaveSelectPin = slaveSelectPin; + _jedecID = jedecID; +} + /// Select the flash chip void SPIFlash::select() { //save current SPI settings @@ -290,4 +299,4 @@ void SPIFlash::wakeup() { /// cleanup void SPIFlash::end() { SPI.end(); -} \ No newline at end of file +} diff --git a/SPIFlash.h b/SPIFlash.h index 7364a8f..0052ae0 100644 --- a/SPIFlash.h +++ b/SPIFlash.h @@ -91,6 +91,8 @@ class SPIFlash { public: static uint8_t UNIQUEID[8]; SPIFlash(uint8_t slaveSelectPin, uint16_t jedecID=0); + SPIFlash(); + void begin(uint8_t slaveSelectPin, uint16_t jedecID=0); boolean initialize(); void command(uint8_t cmd, boolean isWrite=false); uint8_t readStatus(); @@ -120,4 +122,4 @@ class SPIFlash { #endif }; -#endif \ No newline at end of file +#endif diff --git a/keywords.txt b/keywords.txt index 652da98..124bca6 100644 --- a/keywords.txt +++ b/keywords.txt @@ -1,5 +1,6 @@ SPIFlash KEYWORD1 initialize KEYWORD2 +begin KEYWORD2 command KEYWORD2 readStatus KEYWORD2 readByte KEYWORD2 @@ -15,4 +16,4 @@ readUniqueId KEYWORD2 UNIQUEID KEYWORD2 sleep KEYWORD2 wakeup KEYWORD2 -end KEYWORD2 \ No newline at end of file +end KEYWORD2