Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions bricks/_common/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ $(error failed)
endif
endif
endif
ifeq ($(PB_LIB_BTSTACK),1)
ifneq ($(strip $(PB_LIB_BTSTACK)),)
ifeq ("$(wildcard $(PBTOP)/lib/btstack/README.md)","")
$(info GIT cloning btstack submodule)
$(info $(shell cd $(PBTOP) && git submodule update --checkout --init lib/btstack))
Expand Down Expand Up @@ -121,7 +121,7 @@ endif
ifeq ($(PB_LIB_BLE5STACK),1)
INC += -I$(PBTOP)/lib/ble5stack/central
endif
ifeq ($(PB_LIB_BTSTACK),1)
ifneq ($(strip $(PB_LIB_BTSTACK)),)
INC += -I$(PBTOP)/lib/btstack/chipset/cc256x
INC += -I$(PBTOP)/lib/btstack/src
endif
Expand Down Expand Up @@ -379,7 +379,7 @@ BTSTACK_SRC_C = $(addprefix lib/btstack/src/,\
l2cap.c \
)

BTSTACK_SRC_C += $(addprefix lib/btstack/src/ble/,\
BTSTACK_BLE_SRC_C += $(addprefix lib/btstack/src/ble/,\
att_db_util.c \
att_db.c \
att_dispatch.c \
Expand Down Expand Up @@ -528,10 +528,15 @@ ifeq ($(PB_LIB_BLE5STACK),1)
OBJ += $(addprefix $(BUILD)/, $(BLE5STACK_SRC_C:.c=.o))
endif

ifeq ($(PB_LIB_BTSTACK),1)
ifeq ($(PB_LIB_BTSTACK),classic)
OBJ += $(addprefix $(BUILD)/, $(BTSTACK_SRC_C:.c=.o))
endif

ifeq ($(PB_LIB_BTSTACK),lowenergy)
OBJ += $(addprefix $(BUILD)/, $(BTSTACK_SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(BTSTACK_BLE_SRC_C:.c=.o))
endif

ifeq ($(PB_LIB_STM32_HAL),1)
OBJ += $(addprefix $(BUILD)/, $(STM32_HAL_SRC_C:.c=.o))
$(BUILD)/lib/stm32lib/%.o: CFLAGS += -Wno-sign-compare
Expand Down Expand Up @@ -589,9 +594,9 @@ endif

all: $(TARGETS)

# handle BTStack .gatt files
# handle BTStack .gatt files (only for BLE / lowenergy)

ifeq ($(PB_LIB_BTSTACK),1)
ifeq ($(PB_LIB_BTSTACK),lowenergy)

GATT_FILES := $(addprefix lib/pbio/drv/bluetooth/,\
pybricks_service.gatt \
Expand Down
4 changes: 4 additions & 0 deletions bricks/_common/sources.mk
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,13 @@ PBIO_SRC_C = $(addprefix lib/pbio/,\
drv/block_device/block_device_test.c \
drv/block_device/block_device_w25qxx_stm32.c \
drv/bluetooth/bluetooth.c \
drv/bluetooth/bluetooth_btstack_control_ev3.c \
drv/bluetooth/bluetooth_btstack_control_gpio.c \
drv/bluetooth/bluetooth_btstack_uart_block_ev3.c \
drv/bluetooth/bluetooth_btstack_uart_block_stm32_hal.c \
drv/bluetooth/bluetooth_btstack.c \
drv/bluetooth/bluetooth_btstack_classic.c \
drv/bluetooth/bluetooth_init_cc2560x.c \
drv/bluetooth/bluetooth_init_cc2564C_1.4.c \
drv/bluetooth/bluetooth_simulation.c \
drv/bluetooth/bluetooth_stm32_bluenrg.c \
Expand Down
2 changes: 1 addition & 1 deletion bricks/essentialhub/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PB_MCU_EXT_OSC_HZ = 16000000
PB_LIB_STM32_HAL = 1
PB_LIB_LSM6DS3TR_C = 1
PB_LIB_BLUENRG = 0
PB_LIB_BTSTACK = 1
PB_LIB_BTSTACK = lowenergy
PB_LIB_STM32_USB_DEVICE = 1
TEXT0_ADDR = 0x8008000
DFU_VID = 0x0694
Expand Down
1 change: 1 addition & 0 deletions bricks/ev3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ PBIO_PLATFORM = ev3
PB_MCU_FAMILY = TIAM1808

PB_LIB_UMM_MALLOC = 1
PB_LIB_BTSTACK = classic

include ../_common/common.mk
33 changes: 33 additions & 0 deletions bricks/ev3/btstack_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2020 The Pybricks Authors

// BlueKitchen BTStack config

#ifndef _PLATFORM_EV3_BTSTACK_CONFIG_H_
#define _PLATFORM_EV3_BTSTACK_CONFIG_H_

// BTstack features that can be enabled
#define ENABLE_CLASSIC
// #define ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND
#define ENABLE_PRINTF_HEXDUMP

// Temporary, until I'm sure it's working.
#define ENABLE_LOG_DEBUG
#define ENABLE_LOG_ERROR
#define ENABLE_LOG_INFO

// BTstack configuration. buffers, sizes, ...
#define HCI_ACL_PAYLOAD_SIZE (1691 + 4)
#define MAX_ATT_DB_SIZE 512
#define MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 0
#define MAX_NR_HCI_CONNECTIONS 2 // CC2564C can have up to 10 connections
#define MAX_NR_HFP_CONNECTIONS 0
#define MAX_NR_L2CAP_CHANNELS 0
#define MAX_NR_L2CAP_SERVICES 0
#define MAX_NR_RFCOMM_CHANNELS 4
#define MAX_NR_RFCOMM_MULTIPLEXERS 0
#define MAX_NR_RFCOMM_SERVICES 0
#define MAX_NR_SERVICE_RECORD_ITEMS 0
#define MAX_NR_WHITELIST_ENTRIES 0

#endif // _PLATFORM_EV3_BTSTACK_CONFIG_H_
2 changes: 1 addition & 1 deletion bricks/primehub/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PB_MCU_EXT_OSC_HZ = 16000000
PB_LIB_STM32_HAL = 1
PB_LIB_LSM6DS3TR_C = 1
PB_LIB_BLUENRG = 0
PB_LIB_BTSTACK = 1
PB_LIB_BTSTACK = lowenergy
PB_LIB_STM32_USB_DEVICE = 1
TEXT0_ADDR = 0x8008000
DFU_VID = 0x0694
Expand Down
4 changes: 4 additions & 0 deletions lib/pbio/drv/bluetooth/bluetooth_btstack.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef _INTERNAL_PBDRV_BLUETOOTH_BTSTACK_H_
#define _INTERNAL_PBDRV_BLUETOOTH_BTSTACK_H_

#ifdef PBDRV_CONFIG_BLUETOOTH_BTSTACK

#include <btstack_chipset.h>
#include <btstack_control.h>
#include <btstack_uart_block.h>
Expand All @@ -23,4 +25,6 @@ typedef struct {
// defined in platform.c
extern const pbdrv_bluetooth_btstack_platform_data_t pbdrv_bluetooth_btstack_platform_data;

#endif // PBDRV_CONFIG_BLUETOOTH_BTSTACK

#endif // _INTERNAL_PBDRV_BLUETOOTH_BTSTACK_H_
Loading