Select the flash chip
| 52 | |
| 53 | /// Select the flash chip |
| 54 | void SPIFlash::select() { |
| 55 | //save current SPI settings |
| 56 | #ifndef SPI_HAS_TRANSACTION |
| 57 | noInterrupts(); |
| 58 | #endif |
| 59 | #if defined (SPCR) && defined (SPSR) |
| 60 | _SPCR = SPCR; |
| 61 | _SPSR = SPSR; |
| 62 | #endif |
| 63 | |
| 64 | #ifdef SPI_HAS_TRANSACTION |
| 65 | SPI.beginTransaction(_settings); |
| 66 | #else |
| 67 | // set FLASH SPI settings |
| 68 | SPI.setDataMode(SPI_MODE0); |
| 69 | SPI.setBitOrder(MSBFIRST); |
| 70 | SPI.setClockDivider(SPI_CLOCK_DIV4); //decided to slow down from DIV2 after SPI stalling in some instances, especially visible on mega1284p when RFM69 and FLASH chip both present |
| 71 | #endif |
| 72 | digitalWrite(_slaveSelectPin, LOW); |
| 73 | } |
| 74 | |
| 75 | /// UNselect the flash chip |
| 76 | void SPIFlash::unselect() { |
nothing calls this directly
no outgoing calls
no test coverage detected