Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: stm32wba: Add BLE controller implementation #187

Merged
merged 3 commits into from
Dec 18, 2023
Merged
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
49 changes: 48 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,51 @@ if(CONFIG_HAS_STM32LIB)
zephyr_sources(stm32wb/hci/tl_mbox.c)

endif()
endif()

if(CONFIG_BT_STM32WBA)

if(DEFINED CONFIG_BOARD_NUCLEO_WBA52CG)
message(FATAL_ERROR "BLE library is not compatible with nucleo_wba52cg")
endif()

zephyr_compile_definitions( -DBLE )

zephyr_include_directories(stm32wba/hci)
zephyr_include_directories(stm32wba/hci/ll)

zephyr_sources(stm32wba/hci/ll_sys_cs.c)
zephyr_sources(stm32wba/hci/ll_sys_intf.c)
zephyr_sources(stm32wba/hci/ll_sys_dp_slp.c)
zephyr_sources(stm32wba/hci/ll_sys_startup.c)
zephyr_sources(stm32wba/hci/RTDebug.c)
zephyr_sources(stm32wba/hci/hw_pka.c)
zephyr_sources(stm32wba/hci/pka_p256.c)
zephyr_sources(stm32wba/hci/bpka.c)
zephyr_sources(stm32wba/hci/power_table.c)
zephyr_sources(stm32wba/hci/scm.c)

set(STM32WBA_BLE_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../zephyr/blobs/stm32wba/lib)
set(STM32WBA_BLE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/stm32wba/hci)

add_library(stm32wba_ble_lib STATIC IMPORTED GLOBAL)
add_library(stm32wba_ll_lib STATIC IMPORTED GLOBAL)

add_dependencies(
stm32wba_ble_lib
stm32wba_ll_lib
)
set_target_properties(
stm32wba_ble_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_BLE_LIB_DIR}/stm32wba_ble_stack_llo.a
)
set_target_properties(
stm32wba_ll_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_BLE_LIB_DIR}/LinkLayer_BLE_Full_lib.a
)

set_target_properties(stm32wba_ble_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_BLE_INCLUDE_DIR})
set_target_properties(stm32wba_ll_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_BLE_INCLUDE_DIR})

target_link_libraries(app PUBLIC stm32wba_ble_lib)
target_link_libraries(app PUBLIC stm32wba_ll_lib)

endif()
endif()
27 changes: 27 additions & 0 deletions lib/stm32wba/hci/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2019-2021 STMicroelectronics.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
103 changes: 103 additions & 0 deletions lib/stm32wba/hci/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
STM32WBA BLE controller interfacing library
###########################################

Origin:
ST Microelectronics
https://github.com/STMicroelectronics/STM32CubeWBA

Status:
version v1.1.2

Purpose:
This library is used on STM32WBA series to port BLE controller library in
a hosting environment (Zephyr RTOS in current case).

Description:

This library is using the following files extracted the STM32CubeWBA package:
Middlewares/ST/STM32_WPAN/ble/stack/include/auto/ble_types.h
Middlewares/ST/STM32_WPAN/ble/stack/include/ble_bufsize.h
Middlewares/ST/STM32_WPAN/ble/stack/include/ble_const.h
Middlewares/ST/STM32_WPAN/ble/stack/include/ble_defs.h
Middlewares/ST/STM32_WPAN/ble/stack/include/ble_std.h
Middlewares/ST/STM32_WPAN/ble/stack/include/bleplat.h
Middlewares/ST/STM32_WPAN/ble/stack/include/blestack.h
Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/_40nm_reg_files/DWC_ble154combo.h
Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/bsp.h
Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/common_types.h
Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/event_manager.h
Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/evnt_schdlr_gnrc_if.h
Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/hci.h
Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ll_intf.h
Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/mem_intf.h
Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/os_wrapper.h
Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/power_table.h
Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/config/ble_full/ll_fw_config.h
Middlewares/ST/STM32_WPAN/link_layer/ll_sys/inc/linklayer_plat.h
Middlewares/ST/STM32_WPAN/link_layer/ll_sys/inc/ll_sys.h
Middlewares/ST/STM32_WPAN/link_layer/ll_sys/src/ll_sys_cs.c
Middlewares/ST/STM32_WPAN/link_layer/ll_sys/src/ll_sys_dp_slp.c
Middlewares/ST/STM32_WPAN/link_layer/ll_sys/src/ll_sys_intf.c
Middlewares/ST/STM32_WPAN/link_layer/ll_sys/src/ll_sys_startup.c
Middlewares/ST/STM32_WPAN/link_layer/ll_sys/inc/ll_sys_startup.h
Middlewares/ST/STM32_WPAN/stm32_wpan_common.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/Core/Inc/app_common.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/Core/Inc/app_conf.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/Core/Inc/app_entry.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/Core/Inc/utilities_conf.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/Core/Inc/main.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Modules/RTDebug/debug_signals.h
Projects/NUCLEO-WBA55CG/Applications/BLE/BLE_HeartRate/System/Modules/RTDebug/RTDebug.c
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Modules/RTDebug/RTDebug.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Modules/RTDebug/local_debug_tables.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Modules/scm.c
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Modules/scm.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Modules/utilities_common.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Interfaces/hw.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Interfaces/hw_aes.c
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Interfaces/hw_if.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Interfaces/hw_pka.c
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Interfaces/pka_p256.c
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Config/Log/log_module.c
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Config/Log/log_module.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Config/Debug_GPIO/app_debug.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/System/Config/Debug_GPIO/debug_config.h
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/STM32_WPAN/Target/power_table.c
Projects/NUCLEO-WBA52CG/Applications/BLE/BLE_HeartRate/STM32_WPAN/Target/bpka.c
Projects/NUCLEO-WBA55CG/Applications/BLE/BLE_HeartRate/STM32_WPAN/Target/bpka.h
Utilities/trace/adv_trace/stm32_adv_trace.h
Utilities/misc/stm32_mem.h
Utilities/tim_serv/stm32_timer.h
Utilities/misc/stm32_tiny_vsnprintf.h

Dependencies:
This library depends on STM32Cube HAL API.
It is available in stm32cube/stm32wbaxx/drivers

URL:
https://github.com/STMicroelectronics/STM32CubeWBA

commit:
v1.2.0

Maintained-by:
External

License:
BSD-3-Clause
MIT

License Link:
opensource.org/licenses/BSD-3-Clause
opensource.org/license/mit

Patch List:

* Disable Temperature based radio calibration:
Impacted file: app_conf.h

* Minimize dependency list
Impacted files: stm_list.h
main.h
app_conf.h
scm.c
80 changes: 80 additions & 0 deletions lib/stm32wba/hci/RTDebug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file RTDebug.c
* @author MCD Application Team
* @brief Real Time Debug module API definition
******************************************************************************
* @attention
*
* Copyright (c) 2022 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
#include "RTDebug.h"
#include "local_debug_tables.h"
#include "stm32wbaxx_hal.h"
#include <assert.h>

#if(CFG_RT_DEBUG_GPIO_MODULE == 1)
static_assert((sizeof(general_debug_table)/sizeof(st_gpio_debug_t)) == RT_DEBUG_SIGNALS_TOTAL_NUM,
"Debug signals number is different from debug signal table size."
);
#endif /* CFG_RT_DEBUG_GPIO_MODULE */

/***********************/
/** System debug APIs **/
/***********************/

void SYSTEM_DEBUG_SIGNAL_SET(system_debug_signal_t signal)
{
#if(CFG_RT_DEBUG_GPIO_MODULE == 1)
GENERIC_DEBUG_GPIO_SET(signal, system_debug_table);
#endif /* CFG_RT_DEBUG_GPIO_MODULE */
}

void SYSTEM_DEBUG_SIGNAL_RESET(system_debug_signal_t signal)
{
#if(CFG_RT_DEBUG_GPIO_MODULE == 1)
GENERIC_DEBUG_GPIO_RESET(signal, system_debug_table);
#endif /* CFG_RT_DEBUG_GPIO_MODULE */
}

void SYSTEM_DEBUG_SIGNAL_TOGGLE(system_debug_signal_t signal)
{
#if(CFG_RT_DEBUG_GPIO_MODULE == 1)
GENERIC_DEBUG_GPIO_TOGGLE(signal, system_debug_table);
#endif /* CFG_RT_DEBUG_GPIO_MODULE */
}

/***************************/
/** Link Layer debug APIs **/
/***************************/

/* Link Layer debug API definition */
void LINKLAYER_DEBUG_SIGNAL_SET(linklayer_debug_signal_t signal)
{
#if(CFG_RT_DEBUG_GPIO_MODULE == 1)
GENERIC_DEBUG_GPIO_SET(signal, linklayer_debug_table);
#endif /* CFG_RT_DEBUG_GPIO_MODULE */
}

void LINKLAYER_DEBUG_SIGNAL_RESET(linklayer_debug_signal_t signal)
{
#if(CFG_RT_DEBUG_GPIO_MODULE == 1)
GENERIC_DEBUG_GPIO_RESET(signal, linklayer_debug_table);
#endif /* CFG_RT_DEBUG_GPIO_MODULE */
}

void LINKLAYER_DEBUG_SIGNAL_TOGGLE(linklayer_debug_signal_t signal)
{
#if(CFG_RT_DEBUG_GPIO_MODULE == 1)
GENERIC_DEBUG_GPIO_TOGGLE(signal, linklayer_debug_table);
#endif /* CFG_RT_DEBUG_GPIO_MODULE */
}
88 changes: 88 additions & 0 deletions lib/stm32wba/hci/RTDebug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file RTDebug.h
* @author MCD Application Team
* @brief Real Time Debug module API declaration
******************************************************************************
* @attention
*
* Copyright (c) 2022 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
#ifndef SYSTEM_DEBUG_H
#define SYSTEM_DEBUG_H

#include "debug_config.h"

#if(CFG_RT_DEBUG_GPIO_MODULE == 1)

/**************************************************************/
/** Generic macros for local signal table index recuperation **/
/** and global signal table GPIO manipulation **/
/**************************************************************/

#define GENERIC_DEBUG_GPIO_SET(signal, table) do { \
uint32_t debug_table_idx = 0; \
if(signal >= sizeof(table)) \
{ \
return; \
} \
debug_table_idx = table[signal]; \
if(debug_table_idx != RT_DEBUG_SIGNAL_UNUSED) \
{ \
HAL_GPIO_WritePin(general_debug_table[debug_table_idx].GPIO_port, \
general_debug_table[debug_table_idx].GPIO_pin, \
GPIO_PIN_SET); \
} \
} while(0)

#define GENERIC_DEBUG_GPIO_RESET(signal, table) do { \
uint32_t debug_table_idx = 0; \
if(signal >= sizeof(table)) \
{ \
return; \
} \
debug_table_idx = table[signal]; \
if(debug_table_idx != RT_DEBUG_SIGNAL_UNUSED) \
{ \
HAL_GPIO_WritePin(general_debug_table[debug_table_idx].GPIO_port, \
general_debug_table[debug_table_idx].GPIO_pin, \
GPIO_PIN_RESET); \
} \
} while(0)

#define GENERIC_DEBUG_GPIO_TOGGLE(signal, table) do { \
uint32_t debug_table_idx = 0; \
if(signal >= sizeof(table)) \
{ \
return; \
} \
debug_table_idx = table[signal]; \
if(debug_table_idx != RT_DEBUG_SIGNAL_UNUSED) \
{ \
HAL_GPIO_TogglePin(general_debug_table[debug_table_idx].GPIO_port, \
general_debug_table[debug_table_idx].GPIO_pin); \
} \
} while(0)

#endif /* CFG_RT_DEBUG_GPIO_MODULE */

/* System debug API definition */
void SYSTEM_DEBUG_SIGNAL_SET(system_debug_signal_t signal);
void SYSTEM_DEBUG_SIGNAL_RESET(system_debug_signal_t signal);
void SYSTEM_DEBUG_SIGNAL_TOGGLE(system_debug_signal_t signal);

/* Link Layer debug API definition */
void LINKLAYER_DEBUG_SIGNAL_SET(linklayer_debug_signal_t signal);
void LINKLAYER_DEBUG_SIGNAL_RESET(linklayer_debug_signal_t signal);
void LINKLAYER_DEBUG_SIGNAL_TOGGLE(linklayer_debug_signal_t signal);

#endif /* SYSTEM_DEBUG_H */
Loading
Loading