Skip to content

SPIFlash.begin() location and JEDEC-ID #20

Description

@papilinou

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions