MCPcopy Create free account
hub / github.com/LowPowerLab/SPIFlash / initialize

Method initialize

SPIFlash.cpp:91–113  ·  view source on GitHub ↗

setup SPI, read device ID etc...

Source from the content-addressed store, hash-verified

89
90/// setup SPI, read device ID etc...
91boolean SPIFlash::initialize()
92{
93#if defined (SPCR) && defined (SPSR)
94 _SPCR = SPCR;
95 _SPSR = SPSR;
96#endif
97 pinMode(_slaveSelectPin, OUTPUT);
98 SPI.begin();
99#ifdef SPI_HAS_TRANSACTION
100 _settings = SPISettings(4000000, MSBFIRST, SPI_MODE0);
101#endif
102
103 unselect();
104 wakeup();
105
106 if (_jedecID == 0 || readDeviceId() == _jedecID) {
107 command(SPIFLASH_STATUSWRITE, true); // Write Status Register
108 SPI.transfer(0); // Global Unprotect
109 unselect();
110 return true;
111 }
112 return false;
113}
114
115/// Get the manufacturer and device ID bytes (as a short word)
116uint16_t SPIFlash::readDeviceId()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected