Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
papilinou opened this issue May 22, 2018 · 3 comments
Open

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

papilinou opened this issue May 22, 2018 · 3 comments

Comments

@papilinou
Copy link

papilinou commented May 22, 2018

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

LowPowerLab added a commit that referenced this issue May 23, 2018
@LowPowerLab
Copy link
Owner

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 LowPowerLab changed the title using SPIFlash with arduino NANO SPIFlash.begin() location and JEDEC-ID May 23, 2018
@harissutanrafiq
Copy link

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

@LowPowerLab
Copy link
Owner

@harissutanrafiq You can write anything, in byte format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants