55 * need a unique ble local name (see below). If you are using another supported BLE board or shield,
66 * follow the instructions for the specific board or shield below.
77 *
8- * Make sure you have the Intel Curie Boards package v1 .0.6 or higher installed via the Arduino
8+ * Make sure you have the Intel Curie Boards package v2 .0.2 or higher installed via the Arduino
99 * Boards Manager.
1010 *
1111 * Supported boards and shields:
1212 * - Arduino 101 (recommended)
1313 * - RedBearLab BLE Shield (v2) ** to be verified **
1414 * - RedBearLab BLE Nano ** works with modifications **
15+ * - Adafruit Feather M0 Bluefruit LE
1516 *
1617 *================================================================================================*/
1718
1819// change this to a unique name per board if running StandardFirmataBLE on multiple boards
1920// within the same physical space
2021#define FIRMATA_BLE_LOCAL_NAME "FIRMATA"
2122
23+ /*
24+ * Arduino 101
25+ *
26+ * Make sure you have the Intel Curie Boards package v2.0.2 or higher installed via the Arduino
27+ * Boards Manager.
28+ *
29+ * Test script: https://gist.github.com/soundanalogous/927360b797574ed50e27
30+ */
31+ #ifdef _VARIANT_ARDUINO_101_X_
32+ // After conversion to units of 1.25ms, both values must be between
33+ // 0x0006 (7.5ms) and 0x0c80 (4s)
34+ #define FIRMATA_BLE_MIN_INTERVAL 8 // ( 8 * 1000) / 1250 == 0x06 -> 7.5ms
35+ #define FIRMATA_BLE_MAX_INTERVAL 30 // (30 * 1000) / 1250 == 0x18 -> 30ms
36+ #endif
37+
38+
2239/*
2340 * RedBearLab BLE Shield
2441 *
3653//#define REDBEAR_BLE_SHIELD
3754
3855#ifdef REDBEAR_BLE_SHIELD
39- #include <SPI.h>
40- #include <BLEPeripheral.h>
41- #include "utility/BLEStream.h"
42-
4356#define BLE_REQ 9
4457#define BLE_RDY 8
4558#define BLE_RST 4 // 4 or 7 via jumper on shield
59+ #endif
4660
47- BLEStream stream (BLE_REQ , BLE_RDY , BLE_RST );
61+
62+ /*
63+ * Adafruit Feather M0 Bluefruit LE
64+ *
65+ * If you are using an Adafruit Feather M0 Bluefruit LE, uncomment the define below.
66+ * This configuration should also work with other Bluefruit LE boards/modules that communicate
67+ * with the nRF51822 via SPI (e.g. Bluefruit LE SPI Friend, Bluefruit LE Shield), although
68+ * you may need to change the values of BLE_SPI_CS, BLE_SPI_IRQ, and/or BLE_SPI_RST below.
69+ *
70+ * You will need to install a lightly-modified version of the Adafruit BluefruitLE nRF51
71+ * package, available at:
72+ * https://github.com/cstawarz/Adafruit_BluefruitLE_nRF51/archive/firmata_fixes.zip
73+ */
74+ //#define BLUEFRUIT_LE_SPI
75+
76+ #ifdef BLUEFRUIT_LE_SPI
77+ // Both values must be between 10ms and 4s
78+ #define FIRMATA_BLE_MIN_INTERVAL 10 // 10ms
79+ #define FIRMATA_BLE_MAX_INTERVAL 20 // 20ms
80+
81+ #define BLE_SPI_CS 8
82+ #define BLE_SPI_IRQ 7
83+ #define BLE_SPI_RST 4
84+ #endif
85+
86+
87+ /*
88+ * Generic settings
89+ */
90+ #if !defined(FIRMATA_BLE_MIN_INTERVAL ) && !defined(FIRMATA_BLE_MAX_INTERVAL )
91+ // These values apply to all devices using the Arduino BLEPeripheral library
92+ // with a Nordic nRF8001 or nRF51822. Both values must be between
93+ // 0x0006 (7.5ms) and 0x0c80 (4s).
94+ #define FIRMATA_BLE_MIN_INTERVAL 0x0006 // 7.5ms (7.5 / 1.25)
95+ #define FIRMATA_BLE_MAX_INTERVAL 0x0018 // 30ms (30 / 1.25)
96+ #endif
97+
98+ #if !defined(FIRMATA_BLE_TXBUFFER_FLUSH_INTERVAL )
99+ #define FIRMATA_BLE_TXBUFFER_FLUSH_INTERVAL 30 // 30ms
48100#endif
49101
50102
51103/*==================================================================================================
52104 * END BLE CONFIGURATION - you should not need to change anything below this line
53105 *================================================================================================*/
54106
55- /*
56- * Arduino 101
57- *
58- * Make sure you have the Intel Curie Boards package v1.0.6 or higher installed via the Arduino
59- * Boards Manager.
60- *
61- * Test script: https://gist.github.com/soundanalogous/927360b797574ed50e27
62- */
63107#ifdef _VARIANT_ARDUINO_101_X_
64- #include <CurieBLE.h>
65108#include "utility/BLEStream.h"
66109BLEStream stream ;
67110#endif
68111
69112
113+ #ifdef REDBEAR_BLE_SHIELD
114+ #include <SPI.h>
115+ #include "utility/BLEStream.h"
116+ BLEStream stream (BLE_REQ , BLE_RDY , BLE_RST );
117+ #endif
118+
119+
120+ #ifdef BLUEFRUIT_LE_SPI
121+ #include "utility/BluefruitLE_SPI_Stream.h"
122+ BluefruitLE_SPI_Stream stream (BLE_SPI_CS , BLE_SPI_IRQ , BLE_SPI_RST );
123+ #endif
124+
125+
70126/*
71127 * RedBearLab BLE Nano (with default switch settings)
72128 *
@@ -81,7 +137,6 @@ BLEStream stream;
81137 * the pins are currently mapped in Firmata only for the default (factory) jumper settings.
82138 */
83139// #ifdef BLE_NANO
84- // #include <BLEPeripheral.h>
85140// #include "utility/BLEStream.h"
86141// BLEStream stream;
87142// #endif
@@ -96,7 +151,6 @@ BLEStream stream;
96151 */
97152// #if defined(BLEND_MICRO) || defined(BLEND)
98153// #include <SPI.h>
99- // #include <BLEPeripheral.h>
100154// #include "utility/BLEStream.h"
101155
102156// #define BLE_REQ 6
@@ -109,4 +163,6 @@ BLEStream stream;
109163
110164#if defined(BLE_REQ ) && defined(BLE_RDY ) && defined(BLE_RST )
111165#define IS_IGNORE_BLE_PINS (p ) ((p) == BLE_REQ || (p) == BLE_RDY || (p) == BLE_RST)
166+ #elif defined(BLE_SPI_CS ) && defined(BLE_SPI_IRQ ) && defined(BLE_SPI_RST )
167+ #define IS_IGNORE_BLE_PINS (p ) ((p) == BLE_SPI_CS || (p) == BLE_SPI_IRQ || (p) == BLE_SPI_RST)
112168#endif
0 commit comments