STM32 Cube WBGetting Started
STM32 Cube WBGetting Started
STM32 Cube WBGetting Started
User manual
Getting started with STM32CubeWB for STM32WB Series
Introduction
STM32Cube is an STMicroelectronics original initiative to make developers’ lives easier by
reducing development effort, time and cost. STM32Cube covers the whole STM32 portfolio.
STM32Cube includes:
• STM32CubeMX, a graphical software configuration tool that allows the generation of C
initialization code using graphical wizards.
• A comprehensive embedded software platform, delivered per Series (such as
STM32CubeWB for STM32WB Series):
– The STM32Cube HAL, STM32 abstraction layer embedded software ensuring
maximized portability across STM32 portfolio. The HAL is available for all
peripherals
– Low-layer APIs (LL) offering a fast light-weight expert-oriented layer which is
closer to the hardware than the HAL. LL APIs are available only for a set of
peripherals.
– A consistent set of middleware components such as USB Device, STMTouch
(STM32 touch sensing library), STM32_WPAN (Bluetooth® Low Energy 5.0,
OpenThread, 802-15-4 MAC, ZigBee), FatFS and FreeRTOS.
– All embedded software utilities coming with a full set of examples.
This user manual describes how to get started with the STM32CubeWB MCU Package.
Section 1 describes the main features of the STM32CubeWB MCU Package.
Section 2 and Section 3 provide an overview of the STM32CubeWB architecture and MCU
Package structure.
Contents
6 FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.1 What is the license scheme for the STM32CubeWB firmware? . . . . . . . . 26
6.2 What boards are supported by the STM32CubeWB firmware package? . 26
6.3 Are any examples provided with the ready-to-use toolset projects? . . . . 26
6.4 Is there any link with Standard Peripheral Libraries? . . . . . . . . . . . . . . . . 26
6.5 Does the HAL layer take benefit from interrupts or DMA?
How can this be controlled? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
7 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
List of tables
List of figures
The STM32CubeWB MCU Package runs on STM32 32-bit microcontrollers based on the
Arm®(a) Cortex®-M processor.
STM32CubeWB gathers, in a single package, all the generic embedded software
components required to develop an application on STM32WB microcontrollers. In line with
the STM32Cube initiative, this set of components is highly portable, not only within
STM32WB Series but also to other STM32 Series.
STM32CubeWB is fully compatible with STM32CubeMX code generator that allows
generating initialization code. The package includes low-layer (LL) and hardware
abstraction layer (HAL) APIs that cover the microcontroller hardware, together with an
extensive set of examples running on STMicroelectronics boards. The HAL and LL APIs are
available in open-source BSD license for user convenience.
STM32CubeWB MCU Package also contains a set of middleware components with the
corresponding examples. They come in free user-friendly license terms:
• CMSIS-RTOS implementation with FreeRTOS™ open source solution
• Full USB Device stack supporting many classes: Audio, HID, MSC, CDC and DFU
• STMTouch, touch sensing library solution
• STM32_WPAN, wireless personal area network middleware developed within the
STM32WB framework to support Bluetooth® Low Energy (BLE) 5.0, 802.15.4
OpenThread certified stacks, 802-15-4 MAC layer and ZigBee.
• FAT file system based on open source FatFS solution
Several applications and demonstrations implementing all these middleware components
are also provided in the STM32CubeWB MCU Package.
a. Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and or elsewhere.
STM32_WPAN
Touch (Bluetooth,
USB RTOS CMSIS
library Thread and 802-
15-4 MAC layer)
Board support package (BSP) Low-layer APIs (LL) Hardware abstraction layer APIs (HAL)
(1) The set of middleware components depends on the product Series. MSv46868V1
The STM32CubeWB firmware solution is built around three independent levels that easily
interact as described in Figure 2.
Applications
Level 1
Library and protocol based components
(for example FatFS, USB, STMTouch, FreeRTOS™ or
STM32_WPAN)
Examples
HAL
MSv61375V1
2.1 Level 0
This level is divided into three sub-layers:
• Board support package (BSP)
• Hardware abstraction layer (HAL)
– HAL peripheral drivers
– Low-layer drivers
• Basic peripheral usage examples
2.2 Level 1
This level is divided into two sub-layers:
• Middleware components
• Examples based on the middleware components.
2.3 Level 2
This level is composed of a single layer which consist in a global real-time and graphical
demonstration based on the middleware service layer, the low-level abstraction layer and
the basic peripheral usage applications for board based features.
STM32WB30xx STM32WB30CEU5
STM32WB35CEU6, STM32WB35CEY6, STM32WB35CCU6,
STM32WB35xx
STM32WB35CCY6
STM32WB50xx STM32WB50CGU5
STM32WB55CGU6, STM32WB55CEU6, STM32WB55CCU6,
STM32WB55RGV6, STM32WB55REV6, STM32WB55RCV6,
STM32WB55xx
STM32WB55VGY6, STM32WB55VEY6, STM32WB55VCY6,
STM32WB55VGQ6, STM32WB55VEQ6, STM32WB55VCQ6
STM32WB5Mxx STM32WB5MMGH6
STM32CubeWB features a rich set of examples and applications at all levels making it easy
to understand and use any HAL driver and/or middleware components. These examples run
on the STMicroelectronics boards listed in Table 2.
P-NUCLEO-WB55.Nucleo: STM32WB55RG
P-NUCLEO-WB55
P-NUCLEO-WB55.USBDongle: STM32WB55CG
NA NUCLEO-WB35CE: STM32WB35CE
The Arduino® shield drivers are provided within the BSP component. Their usage is
illustrated by a demonstration firmware.
The STM32CubeWB firmware is able to run on any compatible hardware. The user simply
updates the BSP drivers to port the provided examples on his own board, if this latter has
the same hardware features (LED, LCD display, buttons...).
BSP driver
Drivers of external
components
Wireless personal
area network
middleware
Wirelss firmware
binaries
MS53625V1
1. The components files must not be modified by the user. Only the \Projects sources are eligible to changes
by the user.
For each board, a set of examples are provided with pre-configured projects for EWARM,
MDK-ARM, and SW4STM32 tool-chains.
Figure 4 shows the project structure for the P-NUCLEO-WB55.Nucleo board.
The examples are classified depending on the STM32Cube level they apply to, and are
named as explained below:
• Level 0 examples are called Examples, Examples_LL and Examples_MIX. They use
respectively HAL drivers, LL drivers and a mix of HAL and LL drivers without any
middleware component.
• Level 1 examples are called Applications. They provide typical use cases of each
middleware component.
The BLE folder contains typical BLE 5.0 use cases.
The Thread folder contains typical thread use cases.
The BLE_Thread folder contains an application illustrating the switching from BLE to
Thread and viceversa.
The BLE_ZigBee folder contains an application illustrating the switching from BLE to
Zigbee and viceversa.
The CKS folder contains an application which demonstrate how to use customer key
storage feature to store AES cryptographic keys in secure area.
The Mac_802_15_4 folder contains applications which demonstrate how to use MAC
802.15.4 Association and Data exchange.
The ZigBee folder contains applications to demonstrate the usage of clusters in
distributed or centralized ZigBee network.
Templates projects available in the Templates and Templates_LL directories allow to quickly
build any firmware application on a given board.
All examples have the same structure:
• \Inc folder that contains all header files.
• \Src folder for the sources code.
• \EWARM, \MDK-ARM, and \SW4STM32 folders contain the pre-configured project for
each toolchain.
• readme.txt describing the example behavior and needed environment to make it
working
• *.ioc file that allows users to open most of firmware examples within STM32CubeMX
(starting from STM32CubeMX 5.1)
information to know the impact of each configuration option. More detailed information
is available in the documentation provided for each component.
4. Start the HAL Library
After jumping to the main program, the application code must call HAL_Init() API to
initialize the HAL Library, which do the following tasks:
a) Configuration of the Flash prefetch and SysTick interrupt priority (through macros
defined in stm32wbxx_hal_conf.h).
b) Configuration of the SysTick to generate an interrupt every millisecond at the
SysTick interrupt priority TICK_INT_PRIO defined in stm32wbxx_hal_conf.h.
c) Setting of NVIC Group Priority to 0.
d) Call of HAL_MspInit() callback function defined in stm32wbxx_hal_msp.c user
file to perform global low-level hardware initializations.
5. Configure the system clock
The system clock configuration is done by calling the two APIs described below:
a) HAL_RCC_OscConfig(): this API configures the internal and/or external
oscillators, as well as the PLL source and factors. The user chooses to configure
one oscillator or all oscillators. The PLL configuration can be skipped if there is no
need to run the system at high frequency.
b) HAL_RCC_ClockConfig(): this API configures the system clock source, the
Flash memory latency and AHB and APB prescalers.
6. Initialize the peripheral
a) First write the peripheral HAL_PPP_MspInit function. Proceed as follows:
- Enable the peripheral clock.
- Configure the peripheral GPIOs.
- Configure the DMA channel and enable DMA interrupt (if needed).
- Enable peripheral interrupt (if needed).
b) Edit the stm32xxx_it.c to call the required interrupt handlers (peripheral and DMA),
if needed.
c) Write process complete callback functions if you plan to use peripheral interrupt or
DMA.
d) In your main.c file, initialize the peripheral handle structure then call the function
HAL_PPP_Init() to initialize your peripheral.
7. Develop your application
At this stage, your system is ready and you start developing your application code.
– The HAL provides intuitive and ready-to-use APIs to configure the peripheral. It
supports polling, interrupts and DMA programming model, to accommodate any
application requirements. For more details on how to use each peripheral, refer to
the rich examples set provided in the STM32CubeWB MCU package.
– If your application has some real-time constraints, you find a large set of examples
showing how to use FreeRTOS™ and integrate it with all middleware stacks
provided within STM32CubeWB. This is a good starting point to develop your
application.
Caution: In the default HAL implementation, SysTick timer is used as timebase: it generates
interrupts at regular time intervals. If HAL_Delay() is called from peripheral ISR process,
make sure that the SysTick interrupt has higher priority (numerically lower) than the
peripheral interrupt. Otherwise, the caller ISR process will be blocked. Functions affecting
timebase configurations are declared as __weak to make override possible in case of other
implementations in user file (using a general purpose timer for example or other time
source). For more details, refer to HAL_TimeBase example.
4.2.3 LL application
This section describes the steps needed to create your own LL application using
STM32CubeWB.
1. Create your project
To create a new project you either start from the Templates_LL project provided for
each board under \Projects\<STM32xxx_yyy>\Templates_LL or from any available
project under \Projects\<STM32xxy_yyy>\Examples_LL (<STM32xxx_yyy> refers to
the board name, such as P-NUCLEO-WB55.Nucleo).
The Template project provides an empty main loop function, however it is a good
starting point to get familiar with project settings for STM32CubeWB.
Template main characteristics are the following:
– It contains the source codes of the LL and CMSIS drivers which are the minimal
components needed to develop code on a given board.
– It contains the include paths for all the required firmware components.
– It selects the supported STM32WB device and allows to configure the CMSIS and
LL drivers accordingly.
– It provides ready-to-use user files, that are pre-configured as follows:
main.h: LED & USER_BUTTON definition abstraction layer.
main.c: System clock configuration for maximum frequency.
2. Port an existing project to another board
To port an existing project to another target board, start from the Templates_LL project
provided for each board and available under
\Projects\<STM32xxx_yyy>\Templates_LL:
a) Select a LL example
To find the board on which LL examples are deployed, refer to the list of LL
examples STM32CubeProjectsList.html or to application note “STM32Cube
firmware examples for STM32WB Series” (AN5155).
b) Port the LL example
– Copy/paste the Templates_LL folder - to keep the initial source - or directly update
existing Templates_LL project.
– Then porting consists principally in replacing Templates_LL files by the
Examples_LL targeted project.
– Keep all board specific parts. For reasons of clarity, board specific parts have been
flagged with specific tags:
/* ============== BOARD SPECIFIC CONFIGURATION CODE BEGIN ============== */
/* ============== BOARD SPECIFIC CONFIGURATION CODE END ============== */
Thus the main porting steps are the following:
– Replace the stm32wbxx_it.h file
– Replace the stm32wbxx_it.c file
– Replace the main.h file and update it: keep the LED and user button definition of
the LL template under ‘BOARD SPECIFIC CONFIGURATION’ tags.
The STM32CubeWB firmware package contains several wireless stack binaries located
under Projects\STM32WB_Copro_Wireless_Binaries.
STM32WB5x (Projects\STM32WB_Copro_Wireless_Binaries\STM32WB5x)
The supported binaries are the following:
• stm32wb5x_BLE_Stack_full_fw.bin
– Full BLE stack, certified 5.0: link layer, HCI, L2CAP, ATT, SM, GAP and GATT
database
– BT SIG certification listing: declaration ID D042164
• stm32wb5x_BLE_Stack_light_fw.bin
– Erase/Write Flash memory of wireless stack non volatile memory while BLE link is
active (min interval 28 ms)
– Fix IFS (inter frame spacing) sometimes longer than 152 μs
– Wireless BLE stack light configuration (slave only): GAP peripheral / LL slave,
GATT server, Data length extension, Double LL slave
• stm32wb5x_BLE_HCILayer_fw.bin
– HCI layer, only mode 5.0 certified: link layer and HCI
– BT SIG certification listing: declaration ID D042213
• stm32wb5x_Thread_FTD_fw.bin
– Full Thread Device, certified v1.1
Usage: Leader, Router and End Device Thread roles (full featured except for Border
Router)
• stm32wb5x_Thread_MTD_fw.bin
– Minimal Thread Device, certified v1.1.
Usage: End Device and Sleepy End Device Thread roles
• stm32wb5x_BLE_Thread_fw.bin
– Static Concurrent Mode BLE Thread, supporting full BLE stack certified 5.0 and
Full Thread Device certified v1.1
• stm32wb5x_Mac_802_15_4_fw.bin
– MAC API based on the latest official IEEE Std 802.15.4-2011
Usage: MAC FFD and RFD devices
• stm32wb5x_rfmonitor_phy802_15_4_fw.bin
– Dedicated firmware binary to be used with STM32CubeMonitor-RF application.
Refer to STM32CubeMonitor-RF software tool for wireless performance
measurements (UM2288) user manual to get application details.
• stm32wb5x_Zigbee_FFD_Full_fw.bin
– Zigbee Compliant Platform certified.
Supports: full function device (FFD)
• stm32wb5x_BLE_Zigbee_FFD_static_fw.bin
– Static Concurrent Mode BLE Zigbee
Supports: full BLE Stack 5.0 certified and Zigbee FFD compliant platform certified
• stm32wb5x_FUS_fw_1_0_2.bin
– Firmware Upgrade Services (FUS)
This binary is the utility to flash the Wireless Coprocessor Binaries.
FUS version v1.0.2
• stm32wb5x_FUS_fw.bin
– FUS (firmware upgrade Ssrvices)
This binary is the utility to flash the wireless coprocessor binaries.
Latest version of the FUS
STM32WB3x (Projects\STM32WB_Copro_Wireless_Binaries\STM32WB3x)
The supported binaries are the following:
• stm32wb3x_BLE_Stack_full_fw.bin
– Full BLE Stack 5.0 certified: Link Layer, HCI, L2CAP, ATT, SM, GAP and GATT
database
– BT SIG Certification listing: Declaration ID D042164
• stm32wb3x_BLE_Stack_light_fw.bin
– Wireless BLE stack light configuration (slave only): GAP peripheral / LL slave,
GATT server, Data length extension
• slavestm32wb3x_BLE_HCILayer_fw.bin
– HCI Layer only mode 5.0 certified: Link Layer, HCI
– BT SIG Certification listing: Declaration ID D042213
• stm32wb3x_Mac_802_15_4_fw.bin
– MAC API is based on latest official IEEE Std 802.15.4-2011
Usage: MAC FFD and RFD devices
• stm32wb3x_Thread_FTD_fw.bin
– Full Thread Device certified v1.1
Usage: Leader / Router / End Device Thread role (full features excepting Border
Router)
• stm32wb3x_Thread_MTD_fw.bin
– Minimal Thread Device certified v1.1
Usage: End Device and Sleepy End Device Thread role
Follow the steps below to flash the wireless coprocessor binary into the device memory
(inside the below procedure, the references to binaries name and installation address are
provided in the section Main Changes of the release note under
Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x/Release_Notes.html or
Projects/STM32WB_Copro_Wireless_Binaries/STM32WB3x/Release_Notes.html. Those
values depends on the versions of your binaries, their name and your device):
1. Use STM32CubeProgrammer version 2.0 or higher (refer to ST firmware upgrade
services for STM32WB Series (AN5185)
The STM32CubeProgrammer software is available as command line interface (CLI).
It gives access to the firmware upgrade service (FUS) through the bootloader.
2. Access to bootloader USB interface (system Flash memory)
This is achieved by connecting BOOT0 pin to VDD.
For P-NUCLEO-WB55.Nucleo:
6 FAQ
6.5 Does the HAL layer take benefit from interrupts or DMA?
How can this be controlled?
Yes. The HAL layer supports three API programming models: polling, interrupt and DMA
(with or without interrupt generation).
6.10 Can I use HAL and LL drivers together? If yes, what are the
constraints?
It is possible to use both HAL and LL drivers. One handles the IP initialization phase with
HAL and then manages the I/O operations with LL drivers.
The major difference between HAL and LL is that HAL drivers require to create and use
handles for operation management while LL drivers operates directly on peripheral
registers. Mixing HAL and LL is illustrated in Examples_MIX example.
6.11 Are there any LL APIs which are not available with HAL?
Yes, there are.
A few Cortex® APIs have been added in stm32wbxx_ll_cortex.h , for instance for accessing
SCB or SysTick registers.
7 Revision history
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and
improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on
ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order
acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or
the design of Purchasers’ products.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. For additional information about ST trademarks, please refer to www.st.com/trademarks. All other
product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.