Can someone explain SPI.beginTransaction(); to me?

When I google SPI.beginTransaction i get how to use it, what I really want to know is what its doing and how it works. I have a chunk of code that is hanging in there and I if I understood it better I could figure out where I'm doing wrong.

Anyone have a pointer to it? Or where I can find the source code of it?

Thanks!

-jim lee

Wait a sec, SPI.beginTransaction(settings); disable interrupts. Does that mean that it also stops the Serial.print("lost in code") stuff as well?

-jim lee

Not sure where the prints are in the code you're not showing us but yes, the serial uses interrupts so it doesn't work if they're turned off.

You have the source code for that already. It's in the SPI library with the rest of the core libraries where you installed Arduino.

Well, that actually answers my question. So thanks!

-jim lee

SPI.beginTransaction(settings); disable interrupts. Does that mean that it also stops the Serial.print("lost in code") stuff as well?

It disables interrupts VERY briefly. It shouldn't interfere with Serial output...

Mostly, beginTransaction loads up the SPI hardware registers with the settings for that particular SPI device.

It tells the SPI hardware to start an SPI transaction. What's so hard to comprehend? It provides a uniform software interface on several different microcontrollers with different SPI hardware, some of which requires to know when an SPI transaction starts and ends. There is a #define called SPI_HAS_TRANSACTION which is set to 1 if begin/endTransaction is supported for the current architecture.

I know this simply because I looked in the SPI library source which is in every distribution.