SPIFlash
SPIFlash copied to clipboard
SPIFlash.begin() location and JEDEC-ID
SPI.begin must be call even in the SPI library with " transaction" included in the Arduino IDE 1.8.5. See that example : https://www.arduino.cc/en/Tutorial/SPITransaction. A good place to include it could be in SPIFlash initialize around line 94 and delete around line 70 /// setup SPI, read device ID etc... boolean SPIFlash::initialize() { _SPCR = SPCR; _SPSR = SPSR; pinMode(_slaveSelectPin, OUTPUT); SPI.begin(); #ifdef SPI_HAS_TRANSACTION _settings = SPISettings(4000000, MSBFIRST, SPI_MODE0); #endif
also to get the complete jedecID (3 bytes): in SPIFlash.h 👍 line 106: uint32_t readDeviceId();
in SPIFlash.cpp: uint32_t SPIFlash::readDeviceId() { #if defined(AVR_ATmega32U4) // Arduino Leonardo, MoteinoLeo command(SPIFLASH_IDREAD); // Read JEDEC ID #else select(); SPI.transfer(SPIFLASH_IDREAD); #endif
uint32_t jedecid = SPI.transfer(0) ; jedecid = jedecid << 16 & 0x00ffffff ; jedecid |= SPI.transfer(0) << 8 ; jedecid |= SPI.transfer(0); unselect(); return jedecid; }
Thank you for the suggestion!
I moved SPI.begin() in this commit.
For the JEDEC ID, maybe this can come later. I will leave this issue OPEN for this reason.
its possible write and read float value ..? can you give me tutorial..?
@harissutanrafiq You can write anything, in byte format.