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

Method select

SPIFlash.cpp:54–73  ·  view source on GitHub ↗

Select the flash chip

Source from the content-addressed store, hash-verified

52
53/// Select the flash chip
54void 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
76void SPIFlash::unselect() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected