Adafruit Bluetooth LE and SPI sharing

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
j4zzcat
 
Posts: 9
Joined: Thu Oct 02, 2014 12:01 pm

Adafruit Bluetooth LE and SPI sharing

Post 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.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Adafruit Bluetooth LE and SPI sharing

Post 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.

User avatar
paulstoffregen
 
Posts: 444
Joined: Sun Oct 11, 2009 11:23 am

Re: Adafruit Bluetooth LE and SPI sharing

Post 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?

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”