setup SPI, read device ID etc...
| 89 | |
| 90 | /// setup SPI, read device ID etc... |
| 91 | boolean 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) |
| 116 | uint16_t SPIFlash::readDeviceId() |
nothing calls this directly
no outgoing calls
no test coverage detected