Skip to content

Commit c5d448f

Browse files
committed
examples/natmod: Add stm32wb55_transparent_vcp.
1 parent b24754c commit c5d448f

File tree

4 files changed

+754
-0
lines changed

4 files changed

+754
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This module is intended for use on stm32wb55 microcontrollers
2+
# and shows how a native module can be used to extend hardware
3+
# functionality.
4+
5+
# Note: `pip install pyelftools` is required to build native modules.
6+
7+
# Location of top-level MicroPython directory
8+
MPY_DIR = ../../..
9+
10+
# Name of module
11+
MOD = transparent_vcp
12+
13+
# Source files (.c or .py)
14+
SRC = \
15+
_stm32wb55_transparent.c \
16+
stm32wb55_transparent_vcp.py \
17+
18+
19+
# $(MPY_DIR)/ports/stm32/rfcore.c
20+
21+
# Architecture to build for (x86, x64, armv7m, xtensa, xtensawin)
22+
ARCH = armv7m
23+
24+
MCU_SERIES = wb
25+
CMSIS_MCU = STM32WB55xx
26+
include $(MPY_DIR)/ports/stm32/stm32.mk
27+
28+
CFLAGS += -D$(CMSIS_MCU) -DUSE_FULL_LL_DRIVER $(CFLAGS_MCU_$(MCU_SERIES))
29+
# CFLAGS += -DSTM32_HAL_H='<stm32$(MCU_SERIES)xx_hal.h>'
30+
CFLAGS += -DSTM32_HAL_H='<stm32$(MCU_SERIES)xx_hal.h>'
31+
CFLAGS += -DMICROPY_PIN_DEFS_PORT_H='<rfcore_settings.h>'
32+
CFLAGS += -Dpin_gpio_t=uint32_t
33+
# CFLAGS += -Dmp_obj_new_int_from_uint=
34+
CFLAGS += -DMICROPY_PY_BLUETOOTH=0
35+
CFLAGS += -DMICROPY_BLUETOOTH_NIMBLE=0
36+
CFLAGS += -DMICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS=1
37+
38+
CFLAGS += -I$(MPY_DIR)/ports/stm32
39+
CFLAGS += -I$(MPY_DIR)/ports/stm32/boards/NUCLEO_WB55
40+
CFLAGS += -I$(MPY_DIR)/lib/cmsis/inc
41+
CFLAGS += -I$(MPY_DIR)/lib/stm32lib/STM32WBxx_HAL_Driver/Inc
42+
CFLAGS += -I$(MPY_DIR)/lib/stm32lib/CMSIS/STM32WBxx/Include
43+
CFLAGS += -I$(MPY_DIR)/lib/mynewt-nimble/nimble/include
44+
CFLAGS += -I$(MPY_DIR)/extmod/nimble
45+
46+
include $(MPY_DIR)/py/dynruntime.mk
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# STM32WB55 BLE HCI Transparent Mode
2+
3+
This module allows the usage of a stm32wb55 board (eg. nucleo or dongle) as a USB/UART Bluetooth HCI Dongle.
4+
5+
This allows it to be used to provide bluetooth functionality with the unix micropython port.
6+
7+
It also has full support for use with STM32CubeMonitor-Rf app.
8+
9+
The native module can be compiled and deployed with:
10+
11+
```
12+
cd examples/natmod/stm32wb55_transparent_vcp
13+
make
14+
mpremote cp transparent_vcp.mpy :
15+
```
16+
17+
Minimal usage:
18+
19+
```
20+
import transparent_vcp
21+
transparent_vcp.start()
22+
```
23+
24+
By default stdio (repl) will be used / taken over by this
25+
transparent mode.
26+
27+
Example `main.py`
28+
29+
```
30+
import os
31+
from pyb import Pin, LED
32+
33+
sw = Pin("SW3", Pin.IN, Pin.PULL_UP)
34+
35+
def activity(status):
36+
if status:
37+
LED(3).on()
38+
else:
39+
LED(3).off()
40+
41+
if sw.value():
42+
LED(2).on()
43+
import transparent_vcp
44+
45+
# Disconnect USB VCP from repl to use here
46+
usb = os.dupterm(None, 1) # startup default is usb (repl) on slot 1
47+
48+
transparent_vcp.start(usb, activity)
49+
50+
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy