Skip to content

Commit ba9ebb7

Browse files
committed
ports/stm32: Add Zephyr BLE build variant for PYBD_SF6.
Add Zephyr BLE variant configuration for PYBD_SF6 board, with HCI UART readpacket support for bulk reading from the BT coprocessor. Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
1 parent d7d2e19 commit ba9ebb7

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Zephyr BLE variant for PYBD_SF6
2+
# Swaps NimBLE host stack for Zephyr BLE host, using same CYW43 UART HCI transport.
3+
4+
# Enable Bluetooth with Zephyr stack (disable NimBLE default)
5+
MICROPY_PY_BLUETOOTH = 1
6+
MICROPY_BLUETOOTH_NIMBLE = 0
7+
MICROPY_BLUETOOTH_ZEPHYR = 1
8+
9+
# Use bump allocator for GATT structures (STM32 port uses -nostdlib, no libc malloc)
10+
CFLAGS += -DMICROPY_BLUETOOTH_ZEPHYR_GATT_POOL=1
11+
12+
# Force linker to keep HCI device symbols (prevent --gc-sections from removing them)
13+
LDFLAGS += -Wl,--undefined=__device_dts_ord_0 -Wl,--undefined=mp_bluetooth_zephyr_hci_dev

ports/stm32/mpbthciport.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,18 @@ int mp_bluetooth_hci_uart_readchar(void) {
251251
}
252252
}
253253

254+
int mp_bluetooth_hci_uart_readpacket(mp_bluetooth_hci_uart_readchar_t handler) {
255+
// Read all available bytes from UART and feed to the H:4 parser callback.
256+
// Returns total bytes read, or -1 if no data available.
257+
int total = 0;
258+
while (uart_rx_any(&mp_bluetooth_hci_uart_obj)) {
259+
uint8_t chr = uart_rx_char(&mp_bluetooth_hci_uart_obj);
260+
handler(chr);
261+
total++;
262+
}
263+
return (total > 0) ? total : -1;
264+
}
265+
254266
#endif // defined(STM32WB)
255267

256268
// Default (weak) implementation of the HCI controller interface.

0 commit comments

Comments
 (0)