Main Menu

Spi sharing

Started by SadE54, April 01, 2016, 06:17:59 PM

SadE54

Hi,

I'm now to Moteino but looking at the source code, SPi transfer is occuring in interrupt mode to get data from the RFM module.
For my project , I need to share the SPI between RFM , an RTC and an accelerometer.
Is there a way to properly manage spi to avoid data corrruption ?

Thanks in advance !

snorp

Quote from: SadE54 on April 01, 2016, 06:17:59 PM
Hi,

I'm now to Moteino but looking at the source code, SPi transfer is occuring in interrupt mode to get data from the RFM module.
For my project , I need to share the SPI between RFM , an RTC and an accelerometer.
Is there a way to properly manage spi to avoid data corrruption ?

Thanks in advance !

Disable interrupts with noInterrupts() while you are using the SPI with one of the other components, and re-enable with interrupts() when done. Of course, you will not receive any messages sent to you during that time.

SadE54

I saw on Github the SPI transaction use was added then removed , why ?  :o

Felix

See this branch for SPI_transaction support: https://github.com/LowPowerLab/RFM69/tree/SPI_TRANSACTION-attempt
Experimental at this point, the master version does its own management of the SPI bus, the same idea as in transactions - and what snorp mentioned above.