Skip to content

Commit 6cc193a

Browse files
committed
examples/natmod: Add stm32wb55_transparent_vcp.
1 parent 31076bf commit 6cc193a

File tree

7 files changed

+842
-0
lines changed

7 files changed

+842
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
> Originally from https://github.com/STMicroelectronics/STM32CubeWB/blob/83aacadecbd5136ad3194f39e002ff50a5439ad9/Projects/P-NUCLEO-WB55.USBDongle/Applications/LICENSE.md
2+
> Applies only to stm32wb55_local_commands.c
3+
4+
SLA0044 Rev5/February 2018
5+
6+
## Software license agreement
7+
8+
### **ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT**
9+
10+
BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE
11+
OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS
12+
INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES
13+
(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON
14+
BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES
15+
TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT.
16+
17+
Under STMicroelectronics’ intellectual property rights, the redistribution,
18+
reproduction and use in source and binary forms of the software or any part
19+
thereof, with or without modification, are permitted provided that the following
20+
conditions are met:
21+
22+
1. Redistribution of source code (modified or not) must retain any copyright
23+
notice, this list of conditions and the disclaimer set forth below as items 10
24+
and 11.
25+
26+
2. Redistributions in binary form, except as embedded into microcontroller or
27+
microprocessor device manufactured by or for STMicroelectronics or a software
28+
update for such device, must reproduce any copyright notice provided with the
29+
binary code, this list of conditions, and the disclaimer set forth below as
30+
items 10 and 11, in documentation and/or other materials provided with the
31+
distribution.
32+
33+
3. Neither the name of STMicroelectronics nor the names of other contributors to
34+
this software may be used to endorse or promote products derived from this
35+
software or part thereof without specific written permission.
36+
37+
4. This software or any part thereof, including modifications and/or derivative
38+
works of this software, must be used and execute solely and exclusively on or in
39+
combination with a microcontroller or microprocessor device manufactured by or
40+
for STMicroelectronics.
41+
42+
5. No use, reproduction or redistribution of this software partially or totally
43+
may be done in any manner that would subject this software to any Open Source
44+
Terms. “Open Source Terms” shall mean any open source license which requires as
45+
part of distribution of software that the source code of such software is
46+
distributed therewith or otherwise made available, or open source license that
47+
substantially complies with the Open Source definition specified at
48+
www.opensource.org and any other comparable open source license such as for
49+
example GNU General Public License (GPL), Eclipse Public License (EPL), Apache
50+
Software License, BSD license or MIT license.
51+
52+
6. STMicroelectronics has no obligation to provide any maintenance, support or
53+
updates for the software.
54+
55+
7. The software is and will remain the exclusive property of STMicroelectronics
56+
and its licensors. The recipient will not take any action that jeopardizes
57+
STMicroelectronics and its licensors' proprietary rights or acquire any rights
58+
in the software, except the limited rights specified hereunder.
59+
60+
8. The recipient shall comply with all applicable laws and regulations affecting
61+
the use of the software or any part thereof including any applicable export
62+
control law or regulation.
63+
64+
9. Redistribution and use of this software or any part thereof other than as
65+
permitted under this license is void and will automatically terminate your
66+
rights under this license.
67+
68+
10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND
69+
ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
70+
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
71+
NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE
72+
DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL
73+
STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
74+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
75+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
76+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
77+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
78+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
79+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
80+
81+
11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER
82+
EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY
83+
RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 = rfcore_transparent
12+
13+
# Architecture to build for (x86, x64, armv7m, xtensa, xtensawin)
14+
ARCH = armv7m
15+
16+
# Source files (.c or .py)
17+
SRC = \
18+
stm32wb55_transparent.c \
19+
stm32wb55_local_commands.c \
20+
rfcore_transparent.py
21+
22+
MCU_SERIES = wb
23+
CMSIS_MCU = STM32WB55xx
24+
25+
CFLAGS += -Os
26+
CFLAGS += -D$(CMSIS_MCU) -DUSE_FULL_LL_DRIVER $(CFLAGS_MCU_$(MCU_SERIES))
27+
28+
CFLAGS += -I$(MPY_DIR)/ports/stm32
29+
CFLAGS += -I$(MPY_DIR)/ports/stm32/boards/NUCLEO_WB55
30+
CFLAGS += -I$(MPY_DIR)/lib/cmsis/inc
31+
CFLAGS += -I$(MPY_DIR)/lib/stm32lib/STM32WBxx_HAL_Driver/Inc
32+
CFLAGS += -I$(MPY_DIR)/lib/stm32lib/CMSIS/STM32WBxx/Include
33+
34+
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 rfcore_transparent.mpy :
15+
```
16+
17+
Minimal usage:
18+
19+
```
20+
import rfcore_transparent
21+
rfcore_transparent.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 rfcore_transparent
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+
rfcore_transparent.start(usb, activity)
49+
50+
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This will be built into the native mpy module.
2+
# Functions here will be available in the rfcore_transparent module along with
3+
# the native C functions.
4+
5+
6+
def start(stream=None, callback=None):
7+
import sys
8+
import micropython
9+
from bluetooth import BLE
10+
11+
# Ensure rfcore has been started at least once, then turn off bluetooth.
12+
BLE().active(1)
13+
BLE().active(0)
14+
15+
in_stream = out_stream = stream
16+
17+
if not in_stream:
18+
# Disable the ctrl-c interrupt when using repl stream.
19+
micropython.kbd_intr(-1)
20+
21+
in_stream = sys.stdin
22+
out_stream = sys.stdout
23+
24+
# Start transparant mode C function (never exits).
25+
_rfcore_transparent_start(in_stream, out_stream, callback)

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