Skip to content

Commit

Permalink
Rename AdafruitBLE to BluefruitLE (#16127)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored Jan 30, 2022
1 parent 9f4769f commit 7d68595
Show file tree
Hide file tree
Showing 35 changed files with 109 additions and 109 deletions.
10 changes: 5 additions & 5 deletions common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ ifeq ($(strip $(USBPD_ENABLE)), yes)
endif

BLUETOOTH_ENABLE ?= no
VALID_BLUETOOTH_DRIVER_TYPES := AdafruitBLE RN42 custom
VALID_BLUETOOTH_DRIVER_TYPES := BluefruitLE RN42 custom
ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
ifeq ($(filter $(strip $(BLUETOOTH_DRIVER)),$(VALID_BLUETOOTH_DRIVER_TYPES)),)
$(error "$(BLUETOOTH_DRIVER)" is not a valid Bluetooth driver type)
Expand All @@ -727,15 +727,15 @@ ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
COMMON_VPATH += $(DRIVER_PATH)/bluetooth
SRC += outputselect.c

ifeq ($(strip $(BLUETOOTH_DRIVER)), AdafruitBLE)
OPT_DEFS += -DMODULE_ADAFRUIT_BLE
ifeq ($(strip $(BLUETOOTH_DRIVER)), BluefruitLE)
OPT_DEFS += -DBLUETOOTH_BLUEFRUIT_LE
SRC += analog.c
SRC += $(DRIVER_PATH)/bluetooth/adafruit_ble.cpp
SRC += $(DRIVER_PATH)/bluetooth/bluefruit_le.cpp
QUANTUM_LIB_SRC += spi_master.c
endif

ifeq ($(strip $(BLUETOOTH_DRIVER)), RN42)
OPT_DEFS += -DMODULE_RN42
OPT_DEFS += -DBLUETOOTH_RN42
SRC += $(DRIVER_PATH)/bluetooth/rn42.c
QUANTUM_LIB_SRC += uart.c
endif
Expand Down
2 changes: 1 addition & 1 deletion data/schemas/keyboard.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"properties": {
"driver": {
"type": "string",
"enum": ["AdafruitBLE", "RN42"]
"enum": ["BluefruitLE", "RN42"]
},
"lto": {"type": "boolean"},
}
Expand Down
4 changes: 2 additions & 2 deletions docs/config_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ Use these to enable or disable building certain features. The more you have enab
* MIDI controls
* `UNICODE_ENABLE`
* Unicode
* `BLUETOOTH`
* Current options are AdafruitBLE, RN42
* `BLUETOOTH_ENABLE`
* Current options are BluefruitLE, RN42
* `SPLIT_KEYBOARD`
* Enables split keyboard support (dual MCU like the let's split and bakingpy's boards) and includes all necessary files located at quantum/split_common
* `CUSTOM_MATRIX`
Expand Down
10 changes: 5 additions & 5 deletions docs/feature_bluetooth.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Currently Bluetooth support is limited to AVR based chips. For Bluetooth 2.1, QM
|Board |Bluetooth Protocol |Connection Type|rules.mk |Bluetooth Chip|
|----------------------------------------------------------------|--------------------|---------------|--------------------------------|--------------|
|Roving Networks RN-42 (Sparkfun Bluesmirf) |Bluetooth Classic |UART |`BLUETOOTH_DRIVER = RN42` |RN-42 |
|[Bluefruit LE SPI Friend](https://www.adafruit.com/product/2633)|Bluetooth Low Energy|SPI |`BLUETOOTH_DRIVER = AdafruitBLE`|nRF51822 |
|[Bluefruit LE SPI Friend](https://www.adafruit.com/product/2633)|Bluetooth Low Energy|SPI |`BLUETOOTH_DRIVER = BluefruitLE`|nRF51822 |

Not Supported Yet but possible:
* [Bluefruit LE UART Friend](https://www.adafruit.com/product/2479). [Possible tmk implementation found in](https://github.com/tmk/tmk_keyboard/issues/514)
Expand All @@ -17,9 +17,9 @@ Not Supported Yet but possible:

### Adafruit BLE SPI Friend
Currently The only bluetooth chipset supported by QMK is the Adafruit Bluefruit SPI Friend. It's a Nordic nRF51822 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:
* `#define ADAFRUIT_BLE_RST_PIN D4`
* `#define ADAFRUIT_BLE_CS_PIN B4`
* `#define ADAFRUIT_BLE_IRQ_PIN E6`
* `#define BLUEFRUIT_LE_RST_PIN D4`
* `#define BLUEFRUIT_LE_CS_PIN B4`
* `#define BLUEFRUIT_LE_IRQ_PIN E6`

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

Expand All @@ -32,7 +32,7 @@ Add the following to your `rules.mk`:

```make
BLUETOOTH_ENABLE = yes
BLUETOOTH_DRIVER = AdafruitBLE # or RN42
BLUETOOTH_DRIVER = BluefruitLE # or RN42
```
## Bluetooth Keycodes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "adafruit_ble.h"
#include "bluefruit_le.h"

#include <stdio.h>
#include <stdlib.h>
Expand All @@ -16,20 +16,20 @@
// These are the pin assignments for the 32u4 boards.
// You may define them to something else in your config.h
// if yours is wired up differently.
#ifndef ADAFRUIT_BLE_RST_PIN
# define ADAFRUIT_BLE_RST_PIN D4
#ifndef BLUEFRUIT_LE_RST_PIN
# define BLUEFRUIT_LE_RST_PIN D4
#endif

#ifndef ADAFRUIT_BLE_CS_PIN
# define ADAFRUIT_BLE_CS_PIN B4
#ifndef BLUEFRUIT_LE_CS_PIN
# define BLUEFRUIT_LE_CS_PIN B4
#endif

#ifndef ADAFRUIT_BLE_IRQ_PIN
# define ADAFRUIT_BLE_IRQ_PIN E6
#ifndef BLUEFRUIT_LE_IRQ_PIN
# define BLUEFRUIT_LE_IRQ_PIN E6
#endif

#ifndef ADAFRUIT_BLE_SCK_DIVISOR
# define ADAFRUIT_BLE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE
#ifndef BLUEFRUIT_LE_SCK_DIVISOR
# define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE
#endif

#define SAMPLE_BATTERY
Expand Down Expand Up @@ -143,7 +143,7 @@ static bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool ver

// Send a single SDEP packet
static bool sdep_send_pkt(const struct sdep_msg *msg, uint16_t timeout) {
spi_start(ADAFRUIT_BLE_CS_PIN, false, 0, ADAFRUIT_BLE_SCK_DIVISOR);
spi_start(BLUEFRUIT_LE_CS_PIN, false, 0, BLUEFRUIT_LE_SCK_DIVISOR);
uint16_t timerStart = timer_read();
bool success = false;
bool ready = false;
Expand All @@ -157,7 +157,7 @@ static bool sdep_send_pkt(const struct sdep_msg *msg, uint16_t timeout) {
// Release it and let it initialize
spi_stop();
wait_us(SdepBackOff);
spi_start(ADAFRUIT_BLE_CS_PIN, false, 0, ADAFRUIT_BLE_SCK_DIVISOR);
spi_start(BLUEFRUIT_LE_CS_PIN, false, 0, BLUEFRUIT_LE_SCK_DIVISOR);
} while (timer_elapsed(timerStart) < timeout);

if (ready) {
Expand Down Expand Up @@ -190,15 +190,15 @@ static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) {
bool ready = false;

do {
ready = readPin(ADAFRUIT_BLE_IRQ_PIN);
ready = readPin(BLUEFRUIT_LE_IRQ_PIN);
if (ready) {
break;
}
wait_us(1);
} while (timer_elapsed(timerStart) < timeout);

if (ready) {
spi_start(ADAFRUIT_BLE_CS_PIN, false, 0, ADAFRUIT_BLE_SCK_DIVISOR);
spi_start(BLUEFRUIT_LE_CS_PIN, false, 0, BLUEFRUIT_LE_SCK_DIVISOR);

do {
// Read the command type, waiting for the data to be ready
Expand All @@ -207,7 +207,7 @@ static bool sdep_recv_pkt(struct sdep_msg *msg, uint16_t timeout) {
// Release it and let it initialize
spi_stop();
wait_us(SdepBackOff);
spi_start(ADAFRUIT_BLE_CS_PIN, false, 0, ADAFRUIT_BLE_SCK_DIVISOR);
spi_start(BLUEFRUIT_LE_CS_PIN, false, 0, BLUEFRUIT_LE_SCK_DIVISOR);
continue;
}

Expand All @@ -233,7 +233,7 @@ static void resp_buf_read_one(bool greedy) {
return;
}

if (readPin(ADAFRUIT_BLE_IRQ_PIN)) {
if (readPin(BLUEFRUIT_LE_IRQ_PIN)) {
struct sdep_msg msg;

again:
Expand All @@ -244,7 +244,7 @@ static void resp_buf_read_one(bool greedy) {
dprintf("recv latency %dms\n", TIMER_DIFF_16(timer_read(), last_send));
}

if (greedy && resp_buf.peek(last_send) && readPin(ADAFRUIT_BLE_IRQ_PIN)) {
if (greedy && resp_buf.peek(last_send) && readPin(BLUEFRUIT_LE_IRQ_PIN)) {
goto again;
}
}
Expand Down Expand Up @@ -295,16 +295,16 @@ static bool ble_init(void) {
state.configured = false;
state.is_connected = false;

setPinInput(ADAFRUIT_BLE_IRQ_PIN);
setPinInput(BLUEFRUIT_LE_IRQ_PIN);

spi_init();

// Perform a hardware reset
setPinOutput(ADAFRUIT_BLE_RST_PIN);
writePinHigh(ADAFRUIT_BLE_RST_PIN);
writePinLow(ADAFRUIT_BLE_RST_PIN);
setPinOutput(BLUEFRUIT_LE_RST_PIN);
writePinHigh(BLUEFRUIT_LE_RST_PIN);
writePinLow(BLUEFRUIT_LE_RST_PIN);
wait_ms(10);
writePinHigh(ADAFRUIT_BLE_RST_PIN);
writePinHigh(BLUEFRUIT_LE_RST_PIN);

wait_ms(1000); // Give it a second to initialize

Expand Down Expand Up @@ -424,9 +424,9 @@ bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool verbose) {
return at_command(cmdbuf, resp, resplen, verbose);
}

bool adafruit_ble_is_connected(void) { return state.is_connected; }
bool bluefruit_le_is_connected(void) { return state.is_connected; }

bool adafruit_ble_enable_keyboard(void) {
bool bluefruit_le_enable_keyboard(void) {
char resbuf[128];

if (!state.initialized && !ble_init()) {
Expand Down Expand Up @@ -498,16 +498,16 @@ static void set_connected(bool connected) {
}
}

void adafruit_ble_task(void) {
void bluefruit_le_task(void) {
char resbuf[48];

if (!state.configured && !adafruit_ble_enable_keyboard()) {
if (!state.configured && !bluefruit_le_enable_keyboard()) {
return;
}
resp_buf_read_one(true);
send_buf_send_one(SdepShortTimeout);

if (resp_buf.empty() && (state.event_flags & UsingEvents) && readPin(ADAFRUIT_BLE_IRQ_PIN)) {
if (resp_buf.empty() && (state.event_flags & UsingEvents) && readPin(BLUEFRUIT_LE_IRQ_PIN)) {
// Must be an event update
if (at_command_P(PSTR("AT+EVENTSTATUS"), resbuf, sizeof(resbuf))) {
uint32_t mask = strtoul(resbuf, NULL, 16);
Expand Down Expand Up @@ -609,7 +609,7 @@ static bool process_queue_item(struct queue_item *item, uint16_t timeout) {
}
}

void adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys) {
void bluefruit_le_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys) {
struct queue_item item;
bool didWait = false;

Expand Down Expand Up @@ -643,7 +643,7 @@ void adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nk
}
}

void adafruit_ble_send_consumer_key(uint16_t usage) {
void bluefruit_le_send_consumer_key(uint16_t usage) {
struct queue_item item;

item.queue_type = QTConsumer;
Expand All @@ -655,7 +655,7 @@ void adafruit_ble_send_consumer_key(uint16_t usage) {
}

#ifdef MOUSE_ENABLE
void adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons) {
void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons) {
struct queue_item item;

item.queue_type = QTMouseMove;
Expand All @@ -671,9 +671,9 @@ void adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan,
}
#endif

uint32_t adafruit_ble_read_battery_voltage(void) { return state.vbat; }
uint32_t bluefruit_le_read_battery_voltage(void) { return state.vbat; }

bool adafruit_ble_set_mode_leds(bool on) {
bool bluefruit_le_set_mode_leds(bool on) {
if (!state.configured) {
return false;
}
Expand All @@ -689,7 +689,7 @@ bool adafruit_ble_set_mode_leds(bool on) {
}

// https://learn.adafruit.com/adafruit-feather-32u4-bluefruit-le/ble-generic#at-plus-blepowerlevel
bool adafruit_ble_set_power_level(int8_t level) {
bool bluefruit_le_set_power_level(int8_t level) {
char cmd[46];
if (!state.configured) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,43 @@ extern "C" {
#endif

/* Instruct the module to enable HID keyboard support and reset */
extern bool adafruit_ble_enable_keyboard(void);
extern bool bluefruit_le_enable_keyboard(void);

/* Query to see if the BLE module is connected */
extern bool adafruit_ble_query_is_connected(void);
extern bool bluefruit_le_query_is_connected(void);

/* Returns true if we believe that the BLE module is connected.
* This uses our cached understanding that is maintained by
* calling ble_task() periodically. */
extern bool adafruit_ble_is_connected(void);
extern bool bluefruit_le_is_connected(void);

/* Call this periodically to process BLE-originated things */
extern void adafruit_ble_task(void);
extern void bluefruit_le_task(void);

/* Generates keypress events for a set of keys.
* The hid modifier mask specifies the state of the modifier keys for
* this set of keys.
* Also sends a key release indicator, so that the keys do not remain
* held down. */
extern void adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys);
extern void bluefruit_le_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys);

/* Send a consumer usage.
* (milliseconds) */
extern void adafruit_ble_send_consumer_key(uint16_t usage);
extern void bluefruit_le_send_consumer_key(uint16_t usage);

#ifdef MOUSE_ENABLE
/* Send a mouse/wheel movement report.
* The parameters are signed and indicate positive or negative direction
* change. */
extern void adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons);
extern void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons);
#endif

/* Compute battery voltage by reading an analog pin.
* Returns the integer number of millivolts */
extern uint32_t adafruit_ble_read_battery_voltage(void);
extern uint32_t bluefruit_le_read_battery_voltage(void);

extern bool adafruit_ble_set_mode_leds(bool on);
extern bool adafruit_ble_set_power_level(int8_t level);
extern bool bluefruit_le_set_mode_leds(bool on);
extern bool bluefruit_le_set_power_level(int8_t level);

#ifdef __cplusplus
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/bluetooth/outputselect.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "lufa.h"
#endif

#ifdef MODULE_ADAFRUIT_BLE
# include "adafruit_ble.h"
#ifdef BLUETOOTH_BLUEFRUIT_LE
# include "bluefruit_le.h"
#endif

uint8_t desired_output = OUTPUT_DEFAULT;
Expand Down Expand Up @@ -54,8 +54,8 @@ uint8_t auto_detect_output(void) {
return OUTPUT_USB;
}

#ifdef MODULE_ADAFRUIT_BLE
if (adafruit_ble_is_connected()) {
#ifdef BLUETOOTH_BLUEFRUIT_LE
if (bluefruit_le_is_connected()) {
return OUTPUT_BLUETOOTH;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion keyboards/10bleoledhub/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
AUDIO_ENABLE = no # Audio output
BLUETOOTH_ENABLE = yes
BLUETOOTH_DRIVER = AdafruitBLE
BLUETOOTH_DRIVER = BluefruitLE
OLED_ENABLE = yes
OLED_DRIVER = SSD1306
ENCODER_ENABLE = yes
2 changes: 1 addition & 1 deletion keyboards/40percentclub/mf68/keymaps/mf68_ble/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ F_CPU = 8000000
# change yes to no to disable
#
BLUETOOTH_ENABLE = yes
BLUETOOTH_DRIVER = AdafruitBLE
BLUETOOTH_DRIVER = BluefruitLE
BACKLIGHT_ENABLE = no
2 changes: 1 addition & 1 deletion keyboards/atreus/feather/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ BOOTLOADER = caterina
# change yes to no to disable
#
BLUETOOTH_ENABLE = yes
BLUETOOTH_DRIVER = AdafruitBLE
BLUETOOTH_DRIVER = BluefruitLE
CONSOLE_ENABLE = no
6 changes: 3 additions & 3 deletions keyboards/bioi/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ extern keymap_config_t keymap_config;
#endif

#ifdef BLUETOOTH_ENABLE
#ifdef MODULE_ADAFRUIT_BLE
#include "adafruit_ble.h"
#ifdef BLUETOOTH_BLUEFRUIT_LE
#include "bluefruit_le.h"
#else
#include "bluetooth.h"
#endif
Expand Down Expand Up @@ -319,7 +319,7 @@ int main(void)
setup_usb();
sei();

#if defined(MODULE_ADAFRUIT_EZKEY) || defined(MODULE_RN42)
#if defined(BLUETOOTH_RN42)
serial_init();
#endif

Expand Down
Loading

0 comments on commit 7d68595

Please sign in to comment.