SPIFlash icon indicating copy to clipboard operation
SPIFlash copied to clipboard

SPIFlash.begin() location and JEDEC-ID

Open papilinou opened this issue 6 years ago • 3 comments

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; }

papilinou avatar May 22 '18 12:05 papilinou

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.

LowPowerLab avatar May 23 '18 16:05 LowPowerLab

its possible write and read float value ..? can you give me tutorial..?

harissutanrafiq avatar Sep 29 '18 22:09 harissutanrafiq

@harissutanrafiq You can write anything, in byte format.

LowPowerLab avatar Oct 01 '18 14:10 LowPowerLab