aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/feature_bluetooth.md6
-rw-r--r--drivers/bluetooth/adafruit_ble.cpp44
-rw-r--r--keyboards/dtisaac/dosa40rgb/config.h5
-rw-r--r--keyboards/dtisaac/dosa40rgb/keymaps/default/keymap.c4
-rw-r--r--keyboards/handwired/dactyl_manuform/5x6_2_5/config.h3
-rw-r--r--keyboards/handwired/prkl30/feather/config.h3
-rw-r--r--keyboards/handwired/pterodactyl/config.h4
-rw-r--r--keyboards/spaceman/pancake/rev1/feather/config.h4
-rw-r--r--keyboards/tokyokeyboard/alix40/config.h3
9 files changed, 26 insertions, 50 deletions
diff --git a/docs/feature_bluetooth.md b/docs/feature_bluetooth.md
index 1b6a825e7..fdf19c107 100644
--- a/docs/feature_bluetooth.md
+++ b/docs/feature_bluetooth.md
@@ -17,9 +17,9 @@ Not Supported Yet but possible:
17 17
18### Adafruit BLE SPI Friend 18### Adafruit BLE SPI Friend
19Currently The only bluetooth chipset supported by QMK is the Adafruit Bluefruit SPI Friend. It's a Nordic nRF5182 based chip running Adafruit's custom firmware. Data is transmitted via Adafruit's SDEP over Hardware SPI. The [Feather 32u4 Bluefruit LE](https://www.adafruit.com/product/2829) is supported as it's an AVR mcu connected via SPI to the Nordic BLE chip with Adafruit firmware. If Building a custom board with the SPI friend it would be easiest to just use the pin selection that the 32u4 feather uses but you can change the pins in the config.h options with the following defines: 19Currently The only bluetooth chipset supported by QMK is the Adafruit Bluefruit SPI Friend. It's a Nordic nRF5182 based chip running Adafruit's custom firmware. Data is transmitted via Adafruit's SDEP over Hardware SPI. The [Feather 32u4 Bluefruit LE](https://www.adafruit.com/product/2829) is supported as it's an AVR mcu connected via SPI to the Nordic BLE chip with Adafruit firmware. If Building a custom board with the SPI friend it would be easiest to just use the pin selection that the 32u4 feather uses but you can change the pins in the config.h options with the following defines:
20* #define AdafruitBleResetPin D4 20* `#define ADAFRUIT_BLE_RST_PIN D4`
21* #define AdafruitBleCSPin B4 21* `#define ADAFRUIT_BLE_CS_PIN B4`
22* #define AdafruitBleIRQPin E6 22* `#define ADAFRUIT_BLE_IRQ_PIN E6`
23 23
24A Bluefruit UART friend can be converted to an SPI friend, however this [requires](https://github.com/qmk/qmk_firmware/issues/2274) some reflashing and soldering directly to the MDBT40 chip. 24A Bluefruit UART friend can be converted to an SPI friend, however this [requires](https://github.com/qmk/qmk_firmware/issues/2274) some reflashing and soldering directly to the MDBT40 chip.
25 25
diff --git a/drivers/bluetooth/adafruit_ble.cpp b/drivers/bluetooth/adafruit_ble.cpp
index 3f2cc3573..34a780e9a 100644
--- a/drivers/bluetooth/adafruit_ble.cpp
+++ b/drivers/bluetooth/adafruit_ble.cpp
@@ -16,24 +16,22 @@
16// These are the pin assignments for the 32u4 boards. 16// These are the pin assignments for the 32u4 boards.
17// You may define them to something else in your config.h 17// You may define them to something else in your config.h
18// if yours is wired up differently. 18// if yours is wired up differently.
19#ifndef AdafruitBleResetPin 19#ifndef ADAFRUIT_BLE_RST_PIN
20# define AdafruitBleResetPin D4 20# define ADAFRUIT_BLE_RST_PIN D4
21#endif 21#endif
22 22
23#ifndef AdafruitBleCSPin 23#ifndef ADAFRUIT_BLE_CS_PIN
24# define AdafruitBleCSPin B4 24# define ADAFRUIT_BLE_CS_PIN B4
25#endif 25#endif
26 26
27#ifndef AdafruitBleIRQPin 27#ifndef ADAFRUIT_BLE_IRQ_PIN
28# define AdafruitBleIRQPin E6 28# define ADAFRUIT_BLE_IRQ_PIN E6
29#endif 29#endif
30 30
31#ifndef AdafruitBleSpiClockSpeed 31#ifndef ADAFRUIT_BLE_SCK_DIVISOR
32# define AdafruitBleSpiClockSpeed 4000000UL // SCK frequency 32# define ADAFRUIT_BLE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE
33#endif 33#endif
34 34
35#define SCK_DIVISOR (F_CPU / AdafruitBleSpiClockSpeed)
36
37#define SAMPLE_BATTERY 35#define SAMPLE_BATTERY
38#define ConnectionUpdateInterval 1000 /* milliseconds */ 36#define ConnectionUpdateInterval 1000 /* milliseconds */
39 37
@@ -145,7 +143,7 @@ static bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool ver
145 143
146// Send a single SDEP packet 144// Send a single SDEP packet
147static bool sdep_send_pkt(const struct sdep_msg *msg, uint16_t timeout) { 145static bool sdep_send_pkt(const struct sdep_msg *msg, uint16_t timeout) {
148 spi_start(AdafruitBleCSPin, false, 0, SCK_DIVISOR); 146 spi_start(ADAFRUIT_BLE_CS_PIN, false, 0, ADAFRUIT_BLE_SCK_DIVISOR);
149 uint16_t timerStart = timer_read(); 147 uint16_t timerStart = timer_read();
150 bool success = false; 148 bool success = false;
151 bool ready = false; 149 bool ready = false;
@@ -159,7 +157,7 @@ static bool sdep_send_pkt(const struct sdep_msg *msg, uint16_t timeout) {
159 // Release it and let it initialize 157 // Release it and let it initialize
160 spi_stop(); 158 spi_stop();
161 wait_us(SdepBackOff); 159 wait_us(SdepBackOff);
162 spi_start(AdafruitBleCSPin, false, 0, SCK_DIVISOR); 160 spi_start(ADAFRUIT_BLE_CS_PIN, false, 0, ADAFRUIT_BLE_SCK_DIVISOR);
163 } while (timer_elapsed(timerStart) < timeout); 161 } while (timer_elapsed(timerStart) < timeout);
164 162
165 if (ready) { 163 if (ready) {
@@ -192,7 +190,7 @@ static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) {
192 bool ready = false; 190 bool ready = false;
193 191
194 do { 192 do {
195 ready = readPin(AdafruitBleIRQPin); 193 ready = readPin(ADAFRUIT_BLE_IRQ_PIN);
196 if (ready) { 194 if (ready) {
197 break; 195 break;
198 } 196 }
@@ -200,7 +198,7 @@ static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) {
200 } while (timer_elapsed(timerStart) < timeout); 198 } while (timer_elapsed(timerStart) < timeout);
201 199
202 if (ready) { 200 if (ready) {
203 spi_start(AdafruitBleCSPin, false, 0, SCK_DIVISOR); 201 spi_start(ADAFRUIT_BLE_CS_PIN, false, 0, ADAFRUIT_BLE_SCK_DIVISOR);
204 202
205 do { 203 do {
206 // Read the command type, waiting for the data to be ready 204 // Read the command type, waiting for the data to be ready
@@ -209,7 +207,7 @@ static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) {
209 // Release it and let it initialize 207 // Release it and let it initialize
210 spi_stop(); 208 spi_stop();
211 wait_us(SdepBackOff); 209 wait_us(SdepBackOff);
212 spi_start(AdafruitBleCSPin, false, 0, SCK_DIVISOR); 210 spi_start(ADAFRUIT_BLE_CS_PIN, false, 0, ADAFRUIT_BLE_SCK_DIVISOR);
213 continue; 211 continue;
214 } 212 }
215 213
@@ -235,7 +233,7 @@ static void resp_buf_read_one(bool greedy) {
235 return; 233 return;
236 } 234 }
237 235
238 if (readPin(AdafruitBleIRQPin)) { 236 if (readPin(ADAFRUIT_BLE_IRQ_PIN)) {
239 struct sdep_msg msg; 237 struct sdep_msg msg;
240 238
241 again: 239 again:
@@ -246,7 +244,7 @@ static void resp_buf_read_one(bool greedy) {
246 dprintf("recv latency %dms\n", TIMER_DIFF_16(timer_read(), last_send)); 244 dprintf("recv latency %dms\n", TIMER_DIFF_16(timer_read(), last_send));
247 } 245 }
248 246
249 if (greedy && resp_buf.peek(last_send) && readPin(AdafruitBleIRQPin)) { 247 if (greedy && resp_buf.peek(last_send) && readPin(ADAFRUIT_BLE_IRQ_PIN)) {
250 goto again; 248 goto again;
251 } 249 }
252 } 250 }
@@ -297,16 +295,16 @@ static bool ble_init(void) {
297 state.configured = false; 295 state.configured = false;
298 state.is_connected = false; 296 state.is_connected = false;
299 297
300 setPinInput(AdafruitBleIRQPin); 298 setPinInput(ADAFRUIT_BLE_IRQ_PIN);
301 299
302 spi_init(); 300 spi_init();
303 301
304 // Perform a hardware reset 302 // Perform a hardware reset
305 setPinOutput(AdafruitBleResetPin); 303 setPinOutput(ADAFRUIT_BLE_RST_PIN);
306 writePinHigh(AdafruitBleResetPin); 304 writePinHigh(ADAFRUIT_BLE_RST_PIN);
307 writePinLow(AdafruitBleResetPin); 305 writePinLow(ADAFRUIT_BLE_RST_PIN);
308 wait_ms(10); 306 wait_ms(10);
309 writePinHigh(AdafruitBleResetPin); 307 writePinHigh(ADAFRUIT_BLE_RST_PIN);
310 308
311 wait_ms(1000); // Give it a second to initialize 309 wait_ms(1000); // Give it a second to initialize
312 310
@@ -509,7 +507,7 @@ void adafruit_ble_task(void) {
509 resp_buf_read_one(true); 507 resp_buf_read_one(true);
510 send_buf_send_one(SdepShortTimeout); 508 send_buf_send_one(SdepShortTimeout);
511 509
512 if (resp_buf.empty() && (state.event_flags & UsingEvents) && readPin(AdafruitBleIRQPin)) { 510 if (resp_buf.empty() && (state.event_flags & UsingEvents) && readPin(ADAFRUIT_BLE_IRQ_PIN)) {
513 // Must be an event update 511 // Must be an event update
514 if (at_command_P(PSTR("AT+EVENTSTATUS"), resbuf, sizeof(resbuf))) { 512 if (at_command_P(PSTR("AT+EVENTSTATUS"), resbuf, sizeof(resbuf))) {
515 uint32_t mask = strtoul(resbuf, NULL, 16); 513 uint32_t mask = strtoul(resbuf, NULL, 16);
diff --git a/keyboards/dtisaac/dosa40rgb/config.h b/keyboards/dtisaac/dosa40rgb/config.h
index 52891c4aa..0ed29bf94 100644
--- a/keyboards/dtisaac/dosa40rgb/config.h
+++ b/keyboards/dtisaac/dosa40rgb/config.h
@@ -30,11 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
30#define MATRIX_ROWS 4 30#define MATRIX_ROWS 4
31#define MATRIX_COLS 11 31#define MATRIX_COLS 11
32 32
33/* AdafruitBle Pin */
34#define AdafruitBleResetPin D4
35#define AdafruitBleCSPin B4
36#define AdafruitBleIRQPin E6
37
38/* 33/*
39 * Keyboard Matrix Assignments 34 * Keyboard Matrix Assignments
40 * 35 *
diff --git a/keyboards/dtisaac/dosa40rgb/keymaps/default/keymap.c b/keyboards/dtisaac/dosa40rgb/keymaps/default/keymap.c
index c9bde4bb8..e25bd5970 100644
--- a/keyboards/dtisaac/dosa40rgb/keymaps/default/keymap.c
+++ b/keyboards/dtisaac/dosa40rgb/keymaps/default/keymap.c
@@ -77,7 +77,7 @@ void rgb_matrix_indicators_user(void)
77 77
78void sdep_send(const uint8_t *cmd, uint8_t len) { 78void sdep_send(const uint8_t *cmd, uint8_t len) {
79 79
80 spi_start(AdafruitBleCSPin, false, 0, 2); 80 spi_start(ADAFRUIT_BLE_CS_PIN, false, 0, 2);
81 uint8_t cnt = 200; 81 uint8_t cnt = 200;
82 bool ready = false; 82 bool ready = false;
83 83
@@ -88,7 +88,7 @@ void sdep_send(const uint8_t *cmd, uint8_t len) {
88 } 88 }
89 spi_stop(); 89 spi_stop();
90 wait_us(25); 90 wait_us(25);
91 spi_start(AdafruitBleCSPin, false, 0, 2); 91 spi_start(ADAFRUIT_BLE_CS_PIN, false, 0, 2);
92 } while (cnt--); 92 } while (cnt--);
93 93
94 if (ready) { 94 if (ready) {
diff --git a/keyboards/handwired/dactyl_manuform/5x6_2_5/config.h b/keyboards/handwired/dactyl_manuform/5x6_2_5/config.h
index 79ea625d9..cb147654b 100644
--- a/keyboards/handwired/dactyl_manuform/5x6_2_5/config.h
+++ b/keyboards/handwired/dactyl_manuform/5x6_2_5/config.h
@@ -34,9 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
34// // right half adafruit feather 34// // right half adafruit feather
35// #define MATRIX_COL_PINS { F1, F0, B1, B2, B3, D2 } 35// #define MATRIX_COL_PINS { F1, F0, B1, B2, B3, D2 }
36// #define MATRIX_ROW_PINS { D6, B7, B6, B5, D7, C6 } 36// #define MATRIX_ROW_PINS { D6, B7, B6, B5, D7, C6 }
37// #define AdafruitBleResetPin D4
38// #define AdafruitBleCSPin B4
39// #define AdafruitBleIRQPin E6
40 37
41#define DIODE_DIRECTION COL2ROW 38#define DIODE_DIRECTION COL2ROW
42 39
diff --git a/keyboards/handwired/prkl30/feather/config.h b/keyboards/handwired/prkl30/feather/config.h
index 6a9bce38c..875b3d740 100644
--- a/keyboards/handwired/prkl30/feather/config.h
+++ b/keyboards/handwired/prkl30/feather/config.h
@@ -35,9 +35,6 @@
35#define ENCODERS_PAD_A { F7 } 35#define ENCODERS_PAD_A { F7 }
36#define ENCODERS_PAD_B { F6 } 36#define ENCODERS_PAD_B { F6 }
37#define ENCODER_RESOLUTION 4 37#define ENCODER_RESOLUTION 4
38#define AdafruitBleResetPin D4
39#define AdafruitBleCSPin B4
40#define AdafruitBleIRQPin E6
41#define UNUSED_PINS 38#define UNUSED_PINS
42 39
43/* RGB Light Configuration */ 40/* RGB Light Configuration */
diff --git a/keyboards/handwired/pterodactyl/config.h b/keyboards/handwired/pterodactyl/config.h
index 9f5f1412b..044fa12f7 100644
--- a/keyboards/handwired/pterodactyl/config.h
+++ b/keyboards/handwired/pterodactyl/config.h
@@ -60,7 +60,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
60 60
61/* Set 0 if debouncing isn't needed */ 61/* Set 0 if debouncing isn't needed */
62#define DEBOUNCE 0 62#define DEBOUNCE 0
63
64#define AdafruitBleResetPin D4
65#define AdafruitBleCSPin B4
66#define AdafruitBleIRQPin E6
diff --git a/keyboards/spaceman/pancake/rev1/feather/config.h b/keyboards/spaceman/pancake/rev1/feather/config.h
index e72b25f3d..cb80721e4 100644
--- a/keyboards/spaceman/pancake/rev1/feather/config.h
+++ b/keyboards/spaceman/pancake/rev1/feather/config.h
@@ -21,8 +21,4 @@
21#define MATRIX_COL_PINS { C7, D6, B7, B6, F0, D2, D3, F1, F4, F5, F6, F7 } 21#define MATRIX_COL_PINS { C7, D6, B7, B6, F0, D2, D3, F1, F4, F5, F6, F7 }
22#define UNUSED_PINS 22#define UNUSED_PINS
23 23
24#define AdafruitBleResetPin D4
25#define AdafruitBleCSPin B4
26#define AdafruitBleIRQPin E6
27
28#define VIA_HAS_BROKEN_KEYCODES 24#define VIA_HAS_BROKEN_KEYCODES
diff --git a/keyboards/tokyokeyboard/alix40/config.h b/keyboards/tokyokeyboard/alix40/config.h
index 113412e95..f4b4e6e5a 100644
--- a/keyboards/tokyokeyboard/alix40/config.h
+++ b/keyboards/tokyokeyboard/alix40/config.h
@@ -65,9 +65,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
65#define QMK_ESC_INPUT D7 // usually ROW 65#define QMK_ESC_INPUT D7 // usually ROW
66 66
67/* Bluetooth */ 67/* Bluetooth */
68#define AdafruitBleResetPin D4
69#define AdafruitBleCSPin B4
70#define AdafruitBleIRQPin E6
71#define BATTERY_LEVEL_PIN B6 68#define BATTERY_LEVEL_PIN B6
72 69
73#define VIA_HAS_BROKEN_KEYCODES 70#define VIA_HAS_BROKEN_KEYCODES