Page 1 of 1

Adafruit Bluetooth LE and SPI sharing

Posted: Sat Oct 11, 2014 1:54 pm
by j4zzcat
Hi All,

I'm designing a solution that needs to store data that comes over BLE on a flash chip.

I'm thinking of using the Adafruit BLE and the W25Q80BV (flash chip).
These two products provide a SPI interface, and I'm thinking of doing something like this -- is it enough?

Code: Select all

while there's data to read from the BLE {
  read a chunk of data into a buffer 
  set the chip select pin of the BLE to HIGH
  set the chip select pin of the W25Q80BV to LOW
  write the data to the W25Q80BV
  set the chip select pin of the W25Q80BV to HIGH
  set the chip select pin of the BLE to LOW
}
Thanks.

Re: Adafruit Bluetooth LE and SPI sharing

Posted: Sun Oct 12, 2014 9:28 am
by adafruit_support_rick
There's a problem. The BLE library is interrupt-driven, and it does SPI operations at interrupt level. That means it doesn't play well with other SPI devices, which may be in the middle of a SPI operation when a BLE interrupt occurs.

If you want to do this, you'll need to establish two different SPI buses. The BLE is hardcoded to use hardware SPI, so you would have to do software SPI on a different set of pins for your flash chip.

Re: Adafruit Bluetooth LE and SPI sharing

Posted: Sat Nov 15, 2014 10:05 pm
by paulstoffregen
I am working on this problem. If anyone is still watching this thread, here's the latest attempt to use SPI transactions to make this library play nicely with SPI-based libs. This is a work-in-progress, and I could really use your feedback if you're willing to help test it.

https://github.com/PaulStoffregen/Adafruit_nRF8001

This requires SPI transactions. To try this code, you need either Arduino 1.5.8 or Arduino 1.0.6 with Teensyduino 1.20.

If you try this with a nRF8001 and SD card or other SPI device, please let me know if it works for you?