LowPowerLab Forum

Hardware support => General topics => Topic started by: SadE54 on April 01, 2016, 06:17:59 PM

Title: Spi sharing
Post by: 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 !
Title: Re: Spi sharing
Post by: snorp on April 02, 2016, 01:22:32 PM
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.
Title: Re: Spi sharing
Post by: SadE54 on April 14, 2016, 02:52:43 AM
I saw on Github the SPI transaction use was added then removed , why ?  :o
Title: Re: Spi sharing
Post by: Felix on April 14, 2016, 07:29:28 AM
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.