From 65091a90f3a15557e7adb78be9f2909818cbc245 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Fri, 5 Jul 2024 15:53:04 +0200 Subject: [PATCH 01/17] chore: update STM32_WPAN from Cube version v1.20.0 Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/README.md | 4 +- src/utility/STM32_WPAN/app_conf_default.h | 105 +++++----------------- src/utility/STM32_WPAN/ble_bufsize.h | 4 +- src/utility/STM32_WPAN/hw.h | 13 +-- src/utility/STM32_WPAN/hw_ipcc.c | 4 +- src/utility/STM32_WPAN/shci.c | 2 - src/utility/STM32_WPAN/shci.h | 5 +- src/utility/STM32_WPAN/shci_tl.c | 27 +----- src/utility/STM32_WPAN/stm_list.c | 6 +- src/utility/STM32_WPAN/tl.h | 2 +- src/utility/STM32_WPAN/tl_mbox.c | 6 -- 11 files changed, 37 insertions(+), 141 deletions(-) diff --git a/src/utility/STM32_WPAN/README.md b/src/utility/STM32_WPAN/README.md index b8b7d7ed..f50589ee 100644 --- a/src/utility/STM32_WPAN/README.md +++ b/src/utility/STM32_WPAN/README.md @@ -1,6 +1,6 @@ ## Source -[STMicroelectronics/STM32CubeWB Release v1.19.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.19.0) -- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.19.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) +[STMicroelectronics/STM32CubeWB Release v1.20.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.20.0) +- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.20.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h index 9509a0f5..846be3c9 100644 --- a/src/utility/STM32_WPAN/app_conf_default.h +++ b/src/utility/STM32_WPAN/app_conf_default.h @@ -1,9 +1,9 @@ /* USER CODE BEGIN Header */ /** ****************************************************************************** - * @file app_conf_default.h + * @file app_conf.h * @author MCD Application Team - * @brief Default application configuration file for STM32WPAN Middleware. + * @brief Application configuration file for STM32WPAN Middleware. ****************************************************************************** * @attention * @@ -19,42 +19,18 @@ /* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef APP_CONF_DEFAULT_H -#define APP_CONF_DEFAULT_H +#ifndef APP_CONF_H +#define APP_CONF_H -#if 0 #include "hw.h" #include "hw_conf.h" #include "hw_if.h" #include "ble_bufsize.h" -#endif /****************************************************************************** * Application Config ******************************************************************************/ -/**< generic parameters ******************************************************/ -/* HCI related defines */ - -#define ACI_HAL_SET_TX_POWER_LEVEL 0xFC0F -#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C -#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D -#define MAX_HCI_ACL_PACKET_SIZE (sizeof(TL_PacketHeader_t) + 5 + 251) -#define HCI_RESET 0x0C03 - -#ifndef BLE_SHARED_MEM_BYTE_ORDER - #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST -#endif -#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 - -/** - * Define Tx Power - */ -#ifndef CFG_TX_POWER - #define CFG_TX_POWER (0x18) /* -0.15dBm */ -#endif - -#if 0 /** * Define Secure Connections Support */ @@ -128,7 +104,6 @@ #define CFG_FW_SUBVERSION (1) #define CFG_FW_BRANCH (0) #define CFG_FW_BUILD (0) -#endif /****************************************************************************** * BLE Stack @@ -137,25 +112,13 @@ * Maximum number of simultaneous connections that the device will support. * Valid values are from 1 to 8 */ -#ifndef CFG_BLE_NUM_LINK -#ifdef STM32WB15xx - #define CFG_BLE_NUM_LINK 3 -#else - #define CFG_BLE_NUM_LINK 8 -#endif -#endif +#define CFG_BLE_NUM_LINK 8 /** * Maximum number of Services that can be stored in the GATT database. * Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user services */ -#ifndef CFG_BLE_NUM_GATT_SERVICES -#ifdef STM32WB15xx - #define CFG_BLE_NUM_GATT_SERVICES 4 -#else - #define CFG_BLE_NUM_GATT_SERVICES 8 -#endif -#endif +#define CFG_BLE_NUM_GATT_SERVICES 8 /** * Maximum number of Attributes @@ -164,13 +127,7 @@ * Note that certain characteristics and relative descriptors are added automatically during device initialization * so this parameters should be 9 plus the number of user Attributes */ -#ifndef CFG_BLE_NUM_GATT_ATTRIBUTES -#ifdef STM32WB15xx - #define CFG_BLE_NUM_GATT_ATTRIBUTES 30 -#else - #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 -#endif -#endif +#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 /** * Maximum supported ATT_MTU size @@ -206,16 +163,12 @@ /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. */ -#ifndef CFG_BLE_DATA_LENGTH_EXTENSION - #define CFG_BLE_DATA_LENGTH_EXTENSION 1 -#endif +#define CFG_BLE_DATA_LENGTH_EXTENSION 1 /** * Sleep clock accuracy in Peripheral mode (ppm value) */ -#ifndef CFG_BLE_PERIPHERAL_SCA - #define CFG_BLE_PERIPHERAL_SCA 500 -#endif +#define CFG_BLE_PERIPHERAL_SCA 500 /** * Sleep clock accuracy in Central mode @@ -228,9 +181,7 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#ifndef CFG_BLE_CENTRAL_SCA - #define CFG_BLE_CENTRAL_SCA 0 -#endif +#define CFG_BLE_CENTRAL_SCA 0 /** * LsSource @@ -239,27 +190,21 @@ * - bit 1: 1: STM32WB5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module * - bit 2: 1: HSE/1024 Clock config 0: LSE Clock config */ -#ifndef CFG_BLE_LS_SOURCE - #if defined(STM32WB5Mxx) - #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) - #else - #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) - #endif +#if defined(STM32WB5Mxx) + #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) +#else + #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) #endif /** * Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us) */ -#ifndef CFG_BLE_HSE_STARTUP_TIME - #define CFG_BLE_HSE_STARTUP_TIME 0x148 -#endif +#define CFG_BLE_HSE_STARTUP_TIME 0x148 /** * Maximum duration of the connection event when the device is in Peripheral mode in units of 625/256 us (~2.44 us) */ -#ifndef CFG_BLE_MAX_CONN_EVENT_LENGTH - #define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) -#endif +#define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) /** * Viterbi Mode @@ -305,7 +250,7 @@ * 0: LE Power Class 2-3 * other bits: complete with Options_extension flag */ -#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) +#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_HOST | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) /** * BLE stack Options_extension flags to be configured with: @@ -347,11 +292,7 @@ * This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set */ -#if defined(STM32WB15xx) - #define CFG_BLE_MAX_ADV_SET_NBR (3) -#else - #define CFG_BLE_MAX_ADV_SET_NBR (8) -#endif +#define CFG_BLE_MAX_ADV_SET_NBR (8) /* Maximum advertising data length (in bytes) * Range: 31 .. 1650 with limitation: @@ -360,11 +301,7 @@ * This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set */ -#if defined(STM32WB15xx) - #define CFG_BLE_MAX_ADV_DATA_LEN (414) -#else - #define CFG_BLE_MAX_ADV_DATA_LEN (207) -#endif +#define CFG_BLE_MAX_ADV_DATA_LEN (207) /* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. * Range: -1280 .. 1280 @@ -387,7 +324,6 @@ #define CFG_BLE_CORE_VERSION (SHCI_C2_BLE_INIT_BLE_CORE_5_4) -#if 0 /****************************************************************************** * Transport Layer ******************************************************************************/ @@ -723,5 +659,4 @@ typedef enum #define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR -#endif -#endif /*APP_CONF_DEFAULT_H */ +#endif /*APP_CONF_H */ diff --git a/src/utility/STM32_WPAN/ble_bufsize.h b/src/utility/STM32_WPAN/ble_bufsize.h index 66cc2a5a..c5018420 100644 --- a/src/utility/STM32_WPAN/ble_bufsize.h +++ b/src/utility/STM32_WPAN/ble_bufsize.h @@ -1,6 +1,6 @@ /***************************************************************************** * @file ble_bufsize.h - * @author MDG + * * @brief Definition of BLE stack buffers size ***************************************************************************** * @attention @@ -49,7 +49,7 @@ */ #define BLE_MEM_BLOCK_SIZE 32 -#if (SLAVE_ONLY != 0) ||(BASIC_FEATURES != 0) +#if (SLAVE_ONLY != 0) || (BASIC_FEATURES != 0) #define BLE_MEM_BLOCK_X_PTX(n_link) 0 #else #define BLE_MEM_BLOCK_X_PTX(n_link) (n_link) diff --git a/src/utility/STM32_WPAN/hw.h b/src/utility/STM32_WPAN/hw.h index 1472a5e8..651e1f17 100644 --- a/src/utility/STM32_WPAN/hw.h +++ b/src/utility/STM32_WPAN/hw.h @@ -26,23 +26,14 @@ extern "C" { #endif /* Includes ------------------------------------------------------------------*/ -#include "stm32_def.h" -#include "stm32wbxx_ll_bus.h" -#include "stm32wbxx_ll_exti.h" -#include "stm32wbxx_ll_system.h" -#include "stm32wbxx_ll_rcc.h" -#include "stm32wbxx_ll_ipcc.h" -#include "stm32wbxx_ll_cortex.h" -#include "stm32wbxx_ll_utils.h" -#include "stm32wbxx_ll_pwr.h" /****************************************************************************** * HW IPCC ******************************************************************************/ void HW_IPCC_Enable( void ); void HW_IPCC_Init( void ); -#define HW_IPCC_Rx_Handler IPCC_C1_RX_IRQHandler -#define HW_IPCC_Tx_Handler IPCC_C1_TX_IRQHandler + void HW_IPCC_Rx_Handler( void ); + void HW_IPCC_Tx_Handler( void ); void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); diff --git a/src/utility/STM32_WPAN/hw_ipcc.c b/src/utility/STM32_WPAN/hw_ipcc.c index 3461cbed..fd620b85 100644 --- a/src/utility/STM32_WPAN/hw_ipcc.c +++ b/src/utility/STM32_WPAN/hw_ipcc.c @@ -18,9 +18,8 @@ */ /* USER CODE END Header */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ -#include "hw.h" +#include "app_common.h" #include "mbox_def.h" /* Global variables ---------------------------------------------------------*/ @@ -668,4 +667,3 @@ static void HW_IPCC_TRACES_EvtHandler( void ) } __weak void HW_IPCC_TRACES_EvtNot( void ){}; -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/shci.c b/src/utility/STM32_WPAN/shci.c index 40110f42..5c32555e 100644 --- a/src/utility/STM32_WPAN/shci.c +++ b/src/utility/STM32_WPAN/shci.c @@ -17,7 +17,6 @@ */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -760,4 +759,3 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/shci.h b/src/utility/STM32_WPAN/shci.h index 30ae10cb..59c6fd46 100644 --- a/src/utility/STM32_WPAN/shci.h +++ b/src/utility/STM32_WPAN/shci.h @@ -882,6 +882,7 @@ extern "C" { #define SHCI_C2_CONFIG_CONFIG1_BIT0_BLE_NVM_DATA_TO_SRAM (1<<0) #define SHCI_C2_CONFIG_CONFIG1_BIT1_THREAD_NVM_DATA_TO_INTERNAL_FLASH (0<<1) #define SHCI_C2_CONFIG_CONFIG1_BIT1_THREAD_NVM_DATA_TO_SRAM (1<<1) +#define SHCI_C2_CONFIG_CONFIG1_BIT2_SET_EUI64_FORMAT (1<<2) /** * EvtMask1 @@ -1340,7 +1341,9 @@ typedef struct { * 1 - BLE NVM Data are written in SRAM cache pointed by BleNvmRamAddress * - bit1 : 0 - THREAD NVM Data data are flushed in internal secure flash * 1 - THREAD NVM Data are written in SRAM cache pointed by ThreadNvmRamAddress - * - bit2 to bit7 : Unused, shall be set to 0 + * - bit2 : 0 - Thread EUI64 is set to new (and current) format + * 1 - Thread EUI64 is set to old format + * - bit3 to bit7 : Unused, shall be set to 0 * uint8_t EvtMask1 : * When a bit is set to 0, the event is not reported * bit0 : Asynchronous Event with Sub Evt Code 0x9201 (= SHCI_SUB_EVT_ERROR_NOTIF) diff --git a/src/utility/STM32_WPAN/shci_tl.c b/src/utility/STM32_WPAN/shci_tl.c index 25e1a214..0f604300 100644 --- a/src/utility/STM32_WPAN/shci_tl.c +++ b/src/utility/STM32_WPAN/shci_tl.c @@ -17,14 +17,11 @@ */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "stm_list.h" #include "shci_tl.h" -#include "stm32_def.h" -#include "wiring_time.h" /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -171,20 +168,6 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl return; } -void shci_notify_asynch_evt(void *pdata) -{ - UNUSED(pdata); - /* Need to parse data in future version */ - shci_user_evt_proc(); -} - -void shci_register_io_bus(tSHciIO *fops) -{ - /* Register IO bus services */ - fops->Init = TL_SYS_Init; - fops->Send = TL_SYS_SendCmd; -} - /* Private functions ---------------------------------------------------------*/ static void TlInit( TL_CmdPacket_t * p_cmdbuffer ) { @@ -252,11 +235,10 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { - for (unsigned long start = millis(); (millis() - start) < timeout;) { - if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { - break; - } - } + (void)timeout; + + while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); + return; } @@ -268,4 +250,3 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/stm_list.c b/src/utility/STM32_WPAN/stm_list.c index df6c2155..4c928647 100644 --- a/src/utility/STM32_WPAN/stm_list.c +++ b/src/utility/STM32_WPAN/stm_list.c @@ -17,13 +17,10 @@ */ -#if defined(STM32WBxx) /****************************************************************************** * Include Files ******************************************************************************/ -#include "stdint.h" -#include "cmsis_gcc.h" -#include "stm32_wpan_common.h" +#include "utilities_common.h" #include "stm_list.h" @@ -207,4 +204,3 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/tl.h b/src/utility/STM32_WPAN/tl.h index 74520878..8e8c6cbc 100644 --- a/src/utility/STM32_WPAN/tl.h +++ b/src/utility/STM32_WPAN/tl.h @@ -108,7 +108,7 @@ typedef PACKED_STRUCT { uint8_t evtcode; uint8_t plen; - uint8_t payload[4]; + uint8_t payload[2]; } TL_Evt_t; typedef PACKED_STRUCT diff --git a/src/utility/STM32_WPAN/tl_mbox.c b/src/utility/STM32_WPAN/tl_mbox.c index 40c96793..27a998a3 100644 --- a/src/utility/STM32_WPAN/tl_mbox.c +++ b/src/utility/STM32_WPAN/tl_mbox.c @@ -16,7 +16,6 @@ ****************************************************************************** */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -52,10 +51,8 @@ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleLldTable_t TL_BleLldTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_SysTable_t TL_SysTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_MemManagerTable_t TL_MemManagerTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_TracesTable_t TL_TracesTable; -#if 0 PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_Mac_802_15_4_t TL_Mac_802_15_4_Table; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ZigbeeTable_t TL_Zigbee_Table; -#endif /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; @@ -100,10 +97,8 @@ void TL_Init( void ) TL_RefTable.p_sys_table = &TL_SysTable; TL_RefTable.p_mem_manager_table = &TL_MemManagerTable; TL_RefTable.p_traces_table = &TL_TracesTable; -#if 0 TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; -#endif HW_IPCC_Init(); return; @@ -851,4 +846,3 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } -#endif /* STM32WBxx */ From 8ceb243a658457a9c26e1c23a6f9e2546b0fe6dd Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 10 Jan 2024 18:16:01 +0100 Subject: [PATCH 02/17] chore: adapt STM32_WPAN sources Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/app_conf_default.h | 49 +++++++++++++++++++---- src/utility/STM32_WPAN/hw.h | 13 +++++- src/utility/STM32_WPAN/hw_ipcc.c | 4 +- src/utility/STM32_WPAN/shci.c | 2 + src/utility/STM32_WPAN/shci_tl.c | 17 ++++++++ src/utility/STM32_WPAN/stm_list.c | 6 ++- src/utility/STM32_WPAN/tl_mbox.c | 6 +++ 7 files changed, 85 insertions(+), 12 deletions(-) diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h index 846be3c9..6c9beb3b 100644 --- a/src/utility/STM32_WPAN/app_conf_default.h +++ b/src/utility/STM32_WPAN/app_conf_default.h @@ -1,9 +1,9 @@ /* USER CODE BEGIN Header */ /** ****************************************************************************** - * @file app_conf.h + * @file app_conf_default.h * @author MCD Application Team - * @brief Application configuration file for STM32WPAN Middleware. + * @brief Default application configuration file for STM32WPAN Middleware. ****************************************************************************** * @attention * @@ -19,18 +19,40 @@ /* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef APP_CONF_H -#define APP_CONF_H +#ifndef APP_CONF_DEFAULT_H +#define APP_CONF_DEFAULT_H +#if 0 #include "hw.h" #include "hw_conf.h" #include "hw_if.h" #include "ble_bufsize.h" +#endif /****************************************************************************** * Application Config ******************************************************************************/ +/**< generic parameters ******************************************************/ +/* HCI related defines */ + +#define ACI_HAL_SET_TX_POWER_LEVEL 0xFC0F +#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C +#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D +#define MAX_HCI_ACL_PACKET_SIZE (sizeof(TL_PacketHeader_t) + 5 + 251) +#define HCI_RESET 0x0C03 + +#ifndef BLE_SHARED_MEM_BYTE_ORDER + #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST +#endif +#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 + +/** + * Define Tx Power + */ +#define CFG_TX_POWER (0x18) /* -0.15dBm */ + +#if 0 /** * Define Secure Connections Support */ @@ -104,6 +126,7 @@ #define CFG_FW_SUBVERSION (1) #define CFG_FW_BRANCH (0) #define CFG_FW_BUILD (0) +#endif /****************************************************************************** * BLE Stack @@ -250,7 +273,7 @@ * 0: LE Power Class 2-3 * other bits: complete with Options_extension flag */ -#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_HOST | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) +#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) /** * BLE stack Options_extension flags to be configured with: @@ -292,7 +315,11 @@ * This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set */ -#define CFG_BLE_MAX_ADV_SET_NBR (8) +#if defined(STM32WB15xx) + #define CFG_BLE_MAX_ADV_SET_NBR (3) +#else + #define CFG_BLE_MAX_ADV_SET_NBR (8) +#endif /* Maximum advertising data length (in bytes) * Range: 31 .. 1650 with limitation: @@ -301,7 +328,11 @@ * This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set */ -#define CFG_BLE_MAX_ADV_DATA_LEN (207) +#if defined(STM32WB15xx) + #define CFG_BLE_MAX_ADV_DATA_LEN (414) +#else + #define CFG_BLE_MAX_ADV_DATA_LEN (207) +#endif /* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. * Range: -1280 .. 1280 @@ -324,6 +355,7 @@ #define CFG_BLE_CORE_VERSION (SHCI_C2_BLE_INIT_BLE_CORE_5_4) +#if 0 /****************************************************************************** * Transport Layer ******************************************************************************/ @@ -659,4 +691,5 @@ typedef enum #define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR -#endif /*APP_CONF_H */ +#endif +#endif /*APP_CONF_DEFAULT_H */ diff --git a/src/utility/STM32_WPAN/hw.h b/src/utility/STM32_WPAN/hw.h index 651e1f17..1472a5e8 100644 --- a/src/utility/STM32_WPAN/hw.h +++ b/src/utility/STM32_WPAN/hw.h @@ -26,14 +26,23 @@ extern "C" { #endif /* Includes ------------------------------------------------------------------*/ +#include "stm32_def.h" +#include "stm32wbxx_ll_bus.h" +#include "stm32wbxx_ll_exti.h" +#include "stm32wbxx_ll_system.h" +#include "stm32wbxx_ll_rcc.h" +#include "stm32wbxx_ll_ipcc.h" +#include "stm32wbxx_ll_cortex.h" +#include "stm32wbxx_ll_utils.h" +#include "stm32wbxx_ll_pwr.h" /****************************************************************************** * HW IPCC ******************************************************************************/ void HW_IPCC_Enable( void ); void HW_IPCC_Init( void ); - void HW_IPCC_Rx_Handler( void ); - void HW_IPCC_Tx_Handler( void ); +#define HW_IPCC_Rx_Handler IPCC_C1_RX_IRQHandler +#define HW_IPCC_Tx_Handler IPCC_C1_TX_IRQHandler void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); diff --git a/src/utility/STM32_WPAN/hw_ipcc.c b/src/utility/STM32_WPAN/hw_ipcc.c index fd620b85..3461cbed 100644 --- a/src/utility/STM32_WPAN/hw_ipcc.c +++ b/src/utility/STM32_WPAN/hw_ipcc.c @@ -18,8 +18,9 @@ */ /* USER CODE END Header */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ -#include "app_common.h" +#include "hw.h" #include "mbox_def.h" /* Global variables ---------------------------------------------------------*/ @@ -667,3 +668,4 @@ static void HW_IPCC_TRACES_EvtHandler( void ) } __weak void HW_IPCC_TRACES_EvtNot( void ){}; +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/shci.c b/src/utility/STM32_WPAN/shci.c index 5c32555e..40110f42 100644 --- a/src/utility/STM32_WPAN/shci.c +++ b/src/utility/STM32_WPAN/shci.c @@ -17,6 +17,7 @@ */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -759,3 +760,4 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/shci_tl.c b/src/utility/STM32_WPAN/shci_tl.c index 0f604300..daa988c1 100644 --- a/src/utility/STM32_WPAN/shci_tl.c +++ b/src/utility/STM32_WPAN/shci_tl.c @@ -17,11 +17,13 @@ */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "stm_list.h" #include "shci_tl.h" +#include "stm32_def.h" /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -168,6 +170,20 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl return; } +void shci_notify_asynch_evt(void *pdata) +{ + UNUSED(pdata); + /* Need to parse data in future version */ + shci_user_evt_proc(); +} + +void shci_register_io_bus(tSHciIO *fops) +{ + /* Register IO bus services */ + fops->Init = TL_SYS_Init; + fops->Send = TL_SYS_SendCmd; +} + /* Private functions ---------------------------------------------------------*/ static void TlInit( TL_CmdPacket_t * p_cmdbuffer ) { @@ -250,3 +266,4 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/stm_list.c b/src/utility/STM32_WPAN/stm_list.c index 4c928647..df6c2155 100644 --- a/src/utility/STM32_WPAN/stm_list.c +++ b/src/utility/STM32_WPAN/stm_list.c @@ -17,10 +17,13 @@ */ +#if defined(STM32WBxx) /****************************************************************************** * Include Files ******************************************************************************/ -#include "utilities_common.h" +#include "stdint.h" +#include "cmsis_gcc.h" +#include "stm32_wpan_common.h" #include "stm_list.h" @@ -204,3 +207,4 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/tl_mbox.c b/src/utility/STM32_WPAN/tl_mbox.c index 27a998a3..40c96793 100644 --- a/src/utility/STM32_WPAN/tl_mbox.c +++ b/src/utility/STM32_WPAN/tl_mbox.c @@ -16,6 +16,7 @@ ****************************************************************************** */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -51,8 +52,10 @@ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleLldTable_t TL_BleLldTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_SysTable_t TL_SysTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_MemManagerTable_t TL_MemManagerTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_TracesTable_t TL_TracesTable; +#if 0 PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_Mac_802_15_4_t TL_Mac_802_15_4_Table; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ZigbeeTable_t TL_Zigbee_Table; +#endif /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; @@ -97,8 +100,10 @@ void TL_Init( void ) TL_RefTable.p_sys_table = &TL_SysTable; TL_RefTable.p_mem_manager_table = &TL_MemManagerTable; TL_RefTable.p_traces_table = &TL_TracesTable; +#if 0 TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; +#endif HW_IPCC_Init(); return; @@ -846,3 +851,4 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } +#endif /* STM32WBxx */ From 7450369e948219792a971133bbf13d93daa2b955 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 13 Jul 2023 17:16:40 +0200 Subject: [PATCH 03/17] fix: include a timeout when waiting for the cmd_resp Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/shci_tl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utility/STM32_WPAN/shci_tl.c b/src/utility/STM32_WPAN/shci_tl.c index daa988c1..25e1a214 100644 --- a/src/utility/STM32_WPAN/shci_tl.c +++ b/src/utility/STM32_WPAN/shci_tl.c @@ -24,6 +24,7 @@ #include "stm_list.h" #include "shci_tl.h" #include "stm32_def.h" +#include "wiring_time.h" /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -251,10 +252,11 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { - (void)timeout; - - while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); - + for (unsigned long start = millis(); (millis() - start) < timeout;) { + if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { + break; + } + } return; } From dac6208ecb4c6fb885a599a68998bcea846c7e5f Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 10 Jan 2024 18:45:17 +0100 Subject: [PATCH 04/17] chore: add support for customize app_conf_default.h Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/app_conf_default.h | 58 ++++++++++++++++++----- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h index 6c9beb3b..9509a0f5 100644 --- a/src/utility/STM32_WPAN/app_conf_default.h +++ b/src/utility/STM32_WPAN/app_conf_default.h @@ -50,7 +50,9 @@ /** * Define Tx Power */ -#define CFG_TX_POWER (0x18) /* -0.15dBm */ +#ifndef CFG_TX_POWER + #define CFG_TX_POWER (0x18) /* -0.15dBm */ +#endif #if 0 /** @@ -135,13 +137,25 @@ * Maximum number of simultaneous connections that the device will support. * Valid values are from 1 to 8 */ -#define CFG_BLE_NUM_LINK 8 +#ifndef CFG_BLE_NUM_LINK +#ifdef STM32WB15xx + #define CFG_BLE_NUM_LINK 3 +#else + #define CFG_BLE_NUM_LINK 8 +#endif +#endif /** * Maximum number of Services that can be stored in the GATT database. * Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user services */ -#define CFG_BLE_NUM_GATT_SERVICES 8 +#ifndef CFG_BLE_NUM_GATT_SERVICES +#ifdef STM32WB15xx + #define CFG_BLE_NUM_GATT_SERVICES 4 +#else + #define CFG_BLE_NUM_GATT_SERVICES 8 +#endif +#endif /** * Maximum number of Attributes @@ -150,7 +164,13 @@ * Note that certain characteristics and relative descriptors are added automatically during device initialization * so this parameters should be 9 plus the number of user Attributes */ -#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#ifndef CFG_BLE_NUM_GATT_ATTRIBUTES +#ifdef STM32WB15xx + #define CFG_BLE_NUM_GATT_ATTRIBUTES 30 +#else + #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#endif +#endif /** * Maximum supported ATT_MTU size @@ -186,12 +206,16 @@ /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. */ -#define CFG_BLE_DATA_LENGTH_EXTENSION 1 +#ifndef CFG_BLE_DATA_LENGTH_EXTENSION + #define CFG_BLE_DATA_LENGTH_EXTENSION 1 +#endif /** * Sleep clock accuracy in Peripheral mode (ppm value) */ -#define CFG_BLE_PERIPHERAL_SCA 500 +#ifndef CFG_BLE_PERIPHERAL_SCA + #define CFG_BLE_PERIPHERAL_SCA 500 +#endif /** * Sleep clock accuracy in Central mode @@ -204,7 +228,9 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#define CFG_BLE_CENTRAL_SCA 0 +#ifndef CFG_BLE_CENTRAL_SCA + #define CFG_BLE_CENTRAL_SCA 0 +#endif /** * LsSource @@ -213,21 +239,27 @@ * - bit 1: 1: STM32WB5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module * - bit 2: 1: HSE/1024 Clock config 0: LSE Clock config */ -#if defined(STM32WB5Mxx) - #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) -#else - #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) +#ifndef CFG_BLE_LS_SOURCE + #if defined(STM32WB5Mxx) + #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) + #else + #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) + #endif #endif /** * Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us) */ -#define CFG_BLE_HSE_STARTUP_TIME 0x148 +#ifndef CFG_BLE_HSE_STARTUP_TIME + #define CFG_BLE_HSE_STARTUP_TIME 0x148 +#endif /** * Maximum duration of the connection event when the device is in Peripheral mode in units of 625/256 us (~2.44 us) */ -#define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) +#ifndef CFG_BLE_MAX_CONN_EVENT_LENGTH + #define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) +#endif /** * Viterbi Mode From c4c7874909259ad37eb7f7c2527ab3021a53f161 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 24 Jul 2023 10:55:20 +0200 Subject: [PATCH 05/17] fix: TL_Evt_t payload size for reset Within STM32CubeWB v1.17.0 update TL_Evt_t payload size was reduced. This produce a warning -Warray-bounds due to the reset management which require 4 bytes. Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/tl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/STM32_WPAN/tl.h b/src/utility/STM32_WPAN/tl.h index 8e8c6cbc..74520878 100644 --- a/src/utility/STM32_WPAN/tl.h +++ b/src/utility/STM32_WPAN/tl.h @@ -108,7 +108,7 @@ typedef PACKED_STRUCT { uint8_t evtcode; uint8_t plen; - uint8_t payload[2]; + uint8_t payload[4]; } TL_Evt_t; typedef PACKED_STRUCT From 5853f23b0fe0e41c7f234e39627b8e21ce1876da Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 9 Jan 2025 14:27:24 +0100 Subject: [PATCH 06/17] chore: update STM32_WPAN from Cube version v1.21.0 Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/LICENSE.md | 28 ++++++ src/utility/STM32_WPAN/README.md | 4 +- src/utility/STM32_WPAN/app_conf_default.h | 106 +++++----------------- src/utility/STM32_WPAN/hw.h | 13 +-- src/utility/STM32_WPAN/hw_ipcc.c | 4 +- src/utility/STM32_WPAN/shci.c | 2 - src/utility/STM32_WPAN/shci_tl.c | 27 +----- src/utility/STM32_WPAN/stm_list.c | 6 +- src/utility/STM32_WPAN/tl.h | 2 +- src/utility/STM32_WPAN/tl_mbox.c | 25 ++--- 10 files changed, 70 insertions(+), 147 deletions(-) diff --git a/src/utility/STM32_WPAN/LICENSE.md b/src/utility/STM32_WPAN/LICENSE.md index 1af52330..4e70ee7c 100644 --- a/src/utility/STM32_WPAN/LICENSE.md +++ b/src/utility/STM32_WPAN/LICENSE.md @@ -1,3 +1,31 @@ +## Overview + + +This Software Bill Of Material (SBOM) lists the software components of this +software package, including the copyright owner and license terms for each +component. + +__SOFTWARE BILL OF MATERIALS__ + +Component | Copyright | License +--------- | ----------------------------------------------------------------- | ------- +Bluetooth Low Energy | STMicroelectronics | SLA +Bluetooth Low Energy LLD | STMicroelectronics | SLA +Interface | STMicroelectronics | SLA +MAC 802.15.4 | STMicroelectronics | SLA +PHY | STMicroelectronics | SLA +OpenThread | The OpenThread Authors | BSD-3-Clause +Utilities | STMicroelectronics, Amazon.com Inc. | SLA, MIT +Zigbee | Exegin Technologies Limited, STMicroelectronics, Dr Brian Gladman | SLA + + +__Notes:__ If the license is an open source license, then you can access the +terms at [www.opensource.org](https://opensource.org/). Otherwise, the full +license terms are below. If a component is not listed in the SBOM, then the SLA +shall apply unless other terms are clearly stated in the package. + + + SLA0044 Rev5/February 2018 ## Software license agreement diff --git a/src/utility/STM32_WPAN/README.md b/src/utility/STM32_WPAN/README.md index f50589ee..a9b3969a 100644 --- a/src/utility/STM32_WPAN/README.md +++ b/src/utility/STM32_WPAN/README.md @@ -1,6 +1,6 @@ ## Source -[STMicroelectronics/STM32CubeWB Release v1.20.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.20.0) -- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.20.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) +[STMicroelectronics/STM32CubeWB Release v1.21.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.21.0) +- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.21.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h index 9509a0f5..71fc107b 100644 --- a/src/utility/STM32_WPAN/app_conf_default.h +++ b/src/utility/STM32_WPAN/app_conf_default.h @@ -1,9 +1,9 @@ /* USER CODE BEGIN Header */ /** ****************************************************************************** - * @file app_conf_default.h + * @file app_conf.h * @author MCD Application Team - * @brief Default application configuration file for STM32WPAN Middleware. + * @brief Application configuration file for STM32WPAN Middleware. ****************************************************************************** * @attention * @@ -19,42 +19,18 @@ /* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef APP_CONF_DEFAULT_H -#define APP_CONF_DEFAULT_H +#ifndef APP_CONF_H +#define APP_CONF_H -#if 0 #include "hw.h" #include "hw_conf.h" #include "hw_if.h" #include "ble_bufsize.h" -#endif /****************************************************************************** * Application Config ******************************************************************************/ -/**< generic parameters ******************************************************/ -/* HCI related defines */ - -#define ACI_HAL_SET_TX_POWER_LEVEL 0xFC0F -#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C -#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D -#define MAX_HCI_ACL_PACKET_SIZE (sizeof(TL_PacketHeader_t) + 5 + 251) -#define HCI_RESET 0x0C03 - -#ifndef BLE_SHARED_MEM_BYTE_ORDER - #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST -#endif -#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 - -/** - * Define Tx Power - */ -#ifndef CFG_TX_POWER - #define CFG_TX_POWER (0x18) /* -0.15dBm */ -#endif - -#if 0 /** * Define Secure Connections Support */ @@ -128,7 +104,6 @@ #define CFG_FW_SUBVERSION (1) #define CFG_FW_BRANCH (0) #define CFG_FW_BUILD (0) -#endif /****************************************************************************** * BLE Stack @@ -137,25 +112,13 @@ * Maximum number of simultaneous connections that the device will support. * Valid values are from 1 to 8 */ -#ifndef CFG_BLE_NUM_LINK -#ifdef STM32WB15xx - #define CFG_BLE_NUM_LINK 3 -#else - #define CFG_BLE_NUM_LINK 8 -#endif -#endif +#define CFG_BLE_NUM_LINK 8 /** * Maximum number of Services that can be stored in the GATT database. * Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user services */ -#ifndef CFG_BLE_NUM_GATT_SERVICES -#ifdef STM32WB15xx - #define CFG_BLE_NUM_GATT_SERVICES 4 -#else - #define CFG_BLE_NUM_GATT_SERVICES 8 -#endif -#endif +#define CFG_BLE_NUM_GATT_SERVICES 8 /** * Maximum number of Attributes @@ -164,13 +127,7 @@ * Note that certain characteristics and relative descriptors are added automatically during device initialization * so this parameters should be 9 plus the number of user Attributes */ -#ifndef CFG_BLE_NUM_GATT_ATTRIBUTES -#ifdef STM32WB15xx - #define CFG_BLE_NUM_GATT_ATTRIBUTES 30 -#else - #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 -#endif -#endif +#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 /** * Maximum supported ATT_MTU size @@ -206,16 +163,12 @@ /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. */ -#ifndef CFG_BLE_DATA_LENGTH_EXTENSION - #define CFG_BLE_DATA_LENGTH_EXTENSION 1 -#endif +#define CFG_BLE_DATA_LENGTH_EXTENSION 1 /** * Sleep clock accuracy in Peripheral mode (ppm value) */ -#ifndef CFG_BLE_PERIPHERAL_SCA - #define CFG_BLE_PERIPHERAL_SCA 500 -#endif +#define CFG_BLE_PERIPHERAL_SCA 500 /** * Sleep clock accuracy in Central mode @@ -228,9 +181,7 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#ifndef CFG_BLE_CENTRAL_SCA - #define CFG_BLE_CENTRAL_SCA 0 -#endif +#define CFG_BLE_CENTRAL_SCA 0 /** * LsSource @@ -239,27 +190,21 @@ * - bit 1: 1: STM32WB5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module * - bit 2: 1: HSE/1024 Clock config 0: LSE Clock config */ -#ifndef CFG_BLE_LS_SOURCE - #if defined(STM32WB5Mxx) - #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) - #else - #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) - #endif +#if defined(STM32WB5Mxx) + #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) +#else + #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) #endif /** * Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us) */ -#ifndef CFG_BLE_HSE_STARTUP_TIME - #define CFG_BLE_HSE_STARTUP_TIME 0x148 -#endif +#define CFG_BLE_HSE_STARTUP_TIME 0x148 /** * Maximum duration of the connection event when the device is in Peripheral mode in units of 625/256 us (~2.44 us) */ -#ifndef CFG_BLE_MAX_CONN_EVENT_LENGTH - #define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) -#endif +#define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) /** * Viterbi Mode @@ -305,7 +250,7 @@ * 0: LE Power Class 2-3 * other bits: complete with Options_extension flag */ -#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) +#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_HOST | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) /** * BLE stack Options_extension flags to be configured with: @@ -347,11 +292,7 @@ * This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set */ -#if defined(STM32WB15xx) - #define CFG_BLE_MAX_ADV_SET_NBR (3) -#else - #define CFG_BLE_MAX_ADV_SET_NBR (8) -#endif +#define CFG_BLE_MAX_ADV_SET_NBR (8) /* Maximum advertising data length (in bytes) * Range: 31 .. 1650 with limitation: @@ -360,11 +301,7 @@ * This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set */ -#if defined(STM32WB15xx) - #define CFG_BLE_MAX_ADV_DATA_LEN (414) -#else - #define CFG_BLE_MAX_ADV_DATA_LEN (207) -#endif +#define CFG_BLE_MAX_ADV_DATA_LEN (207) /* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. * Range: -1280 .. 1280 @@ -387,7 +324,6 @@ #define CFG_BLE_CORE_VERSION (SHCI_C2_BLE_INIT_BLE_CORE_5_4) -#if 0 /****************************************************************************** * Transport Layer ******************************************************************************/ @@ -687,6 +623,7 @@ typedef enum /* USER CODE BEGIN CFG_SCH_Prio_Id_t */ /* USER CODE END CFG_SCH_Prio_Id_t */ + CFG_SCH_PRIO_NBR } CFG_SCH_Prio_Id_t; /** @@ -723,5 +660,4 @@ typedef enum #define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR -#endif -#endif /*APP_CONF_DEFAULT_H */ +#endif /*APP_CONF_H */ diff --git a/src/utility/STM32_WPAN/hw.h b/src/utility/STM32_WPAN/hw.h index 1472a5e8..651e1f17 100644 --- a/src/utility/STM32_WPAN/hw.h +++ b/src/utility/STM32_WPAN/hw.h @@ -26,23 +26,14 @@ extern "C" { #endif /* Includes ------------------------------------------------------------------*/ -#include "stm32_def.h" -#include "stm32wbxx_ll_bus.h" -#include "stm32wbxx_ll_exti.h" -#include "stm32wbxx_ll_system.h" -#include "stm32wbxx_ll_rcc.h" -#include "stm32wbxx_ll_ipcc.h" -#include "stm32wbxx_ll_cortex.h" -#include "stm32wbxx_ll_utils.h" -#include "stm32wbxx_ll_pwr.h" /****************************************************************************** * HW IPCC ******************************************************************************/ void HW_IPCC_Enable( void ); void HW_IPCC_Init( void ); -#define HW_IPCC_Rx_Handler IPCC_C1_RX_IRQHandler -#define HW_IPCC_Tx_Handler IPCC_C1_TX_IRQHandler + void HW_IPCC_Rx_Handler( void ); + void HW_IPCC_Tx_Handler( void ); void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); diff --git a/src/utility/STM32_WPAN/hw_ipcc.c b/src/utility/STM32_WPAN/hw_ipcc.c index 3461cbed..fd620b85 100644 --- a/src/utility/STM32_WPAN/hw_ipcc.c +++ b/src/utility/STM32_WPAN/hw_ipcc.c @@ -18,9 +18,8 @@ */ /* USER CODE END Header */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ -#include "hw.h" +#include "app_common.h" #include "mbox_def.h" /* Global variables ---------------------------------------------------------*/ @@ -668,4 +667,3 @@ static void HW_IPCC_TRACES_EvtHandler( void ) } __weak void HW_IPCC_TRACES_EvtNot( void ){}; -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/shci.c b/src/utility/STM32_WPAN/shci.c index 40110f42..5c32555e 100644 --- a/src/utility/STM32_WPAN/shci.c +++ b/src/utility/STM32_WPAN/shci.c @@ -17,7 +17,6 @@ */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -760,4 +759,3 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/shci_tl.c b/src/utility/STM32_WPAN/shci_tl.c index 25e1a214..0f604300 100644 --- a/src/utility/STM32_WPAN/shci_tl.c +++ b/src/utility/STM32_WPAN/shci_tl.c @@ -17,14 +17,11 @@ */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "stm_list.h" #include "shci_tl.h" -#include "stm32_def.h" -#include "wiring_time.h" /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -171,20 +168,6 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl return; } -void shci_notify_asynch_evt(void *pdata) -{ - UNUSED(pdata); - /* Need to parse data in future version */ - shci_user_evt_proc(); -} - -void shci_register_io_bus(tSHciIO *fops) -{ - /* Register IO bus services */ - fops->Init = TL_SYS_Init; - fops->Send = TL_SYS_SendCmd; -} - /* Private functions ---------------------------------------------------------*/ static void TlInit( TL_CmdPacket_t * p_cmdbuffer ) { @@ -252,11 +235,10 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { - for (unsigned long start = millis(); (millis() - start) < timeout;) { - if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { - break; - } - } + (void)timeout; + + while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); + return; } @@ -268,4 +250,3 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/stm_list.c b/src/utility/STM32_WPAN/stm_list.c index df6c2155..4c928647 100644 --- a/src/utility/STM32_WPAN/stm_list.c +++ b/src/utility/STM32_WPAN/stm_list.c @@ -17,13 +17,10 @@ */ -#if defined(STM32WBxx) /****************************************************************************** * Include Files ******************************************************************************/ -#include "stdint.h" -#include "cmsis_gcc.h" -#include "stm32_wpan_common.h" +#include "utilities_common.h" #include "stm_list.h" @@ -207,4 +204,3 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/tl.h b/src/utility/STM32_WPAN/tl.h index 74520878..8e8c6cbc 100644 --- a/src/utility/STM32_WPAN/tl.h +++ b/src/utility/STM32_WPAN/tl.h @@ -108,7 +108,7 @@ typedef PACKED_STRUCT { uint8_t evtcode; uint8_t plen; - uint8_t payload[4]; + uint8_t payload[2]; } TL_Evt_t; typedef PACKED_STRUCT diff --git a/src/utility/STM32_WPAN/tl_mbox.c b/src/utility/STM32_WPAN/tl_mbox.c index 40c96793..df07a197 100644 --- a/src/utility/STM32_WPAN/tl_mbox.c +++ b/src/utility/STM32_WPAN/tl_mbox.c @@ -16,7 +16,6 @@ ****************************************************************************** */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -52,10 +51,8 @@ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleLldTable_t TL_BleLldTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_SysTable_t TL_SysTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_MemManagerTable_t TL_MemManagerTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_TracesTable_t TL_TracesTable; -#if 0 PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_Mac_802_15_4_t TL_Mac_802_15_4_Table; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ZigbeeTable_t TL_Zigbee_Table; -#endif /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; @@ -100,10 +97,8 @@ void TL_Init( void ) TL_RefTable.p_sys_table = &TL_SysTable; TL_RefTable.p_mem_manager_table = &TL_MemManagerTable; TL_RefTable.p_traces_table = &TL_TracesTable; -#if 0 TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; -#endif HW_IPCC_Init(); return; @@ -676,6 +671,7 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) { TL_EvtPacket_t *p_evt_packet; TL_CmdPacket_t *p_cmd_packet; + TL_EvtSerial_t *p_cmd_rsp_packet; switch(packet_type) { @@ -799,28 +795,28 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) break; case TL_MB_SYS_CMD_RSP: - p_evt_packet = (TL_EvtPacket_t*)buffer; - switch(p_evt_packet->evtserial.evt.evtcode) + p_cmd_rsp_packet = (TL_EvtSerial_t*)buffer; + switch(p_cmd_rsp_packet->evt.evtcode) { case TL_BLEEVT_CC_OPCODE: - TL_SHCI_CMD_DBG_MSG("sys rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode); - TL_SHCI_CMD_DBG_MSG(" cmd opcode: 0x%02X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); - TL_SHCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[0]); - if((p_evt_packet->evtserial.evt.plen-4) != 0) + TL_SHCI_CMD_DBG_MSG("sys rsp: 0x%02X", p_cmd_rsp_packet->evt.evtcode); + TL_SHCI_CMD_DBG_MSG(" cmd opcode: 0x%02X", ((TL_CcEvt_t*)(p_cmd_rsp_packet->evt.payload))->cmdcode); + TL_SHCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CcEvt_t*)(p_cmd_rsp_packet->evt.payload))->payload[0]); + if((p_cmd_rsp_packet->evt.plen-4) != 0) { TL_SHCI_CMD_DBG_MSG(" payload:"); - TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[1], p_evt_packet->evtserial.evt.plen-4, ""); + TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_cmd_rsp_packet->evt.payload))->payload[1], p_cmd_rsp_packet->evt.plen-4, ""); } break; default: - TL_SHCI_CMD_DBG_MSG("unknown sys rsp received: %02X", p_evt_packet->evtserial.evt.evtcode); + TL_SHCI_CMD_DBG_MSG("unknown sys rsp received: %02X", p_cmd_rsp_packet->evt.evtcode); break; } TL_SHCI_CMD_DBG_MSG("\r\n"); - TL_SHCI_CMD_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); + TL_SHCI_CMD_DBG_RAW(&p_cmd_rsp_packet->evt, p_cmd_rsp_packet->evt.plen+TL_EVT_HDR_SIZE); break; case TL_MB_SYS_ASYNCH_EVT: @@ -851,4 +847,3 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } -#endif /* STM32WBxx */ From a5d59623a4510744b4ac4b8cab463800f5f5e742 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 10 Jan 2024 18:16:01 +0100 Subject: [PATCH 07/17] chore: adapt STM32_WPAN sources Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/app_conf_default.h | 49 +++++++++++++++++++---- src/utility/STM32_WPAN/hw.h | 13 +++++- src/utility/STM32_WPAN/hw_ipcc.c | 4 +- src/utility/STM32_WPAN/shci.c | 2 + src/utility/STM32_WPAN/shci_tl.c | 17 ++++++++ src/utility/STM32_WPAN/stm_list.c | 6 ++- src/utility/STM32_WPAN/tl_mbox.c | 6 +++ 7 files changed, 85 insertions(+), 12 deletions(-) diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h index 71fc107b..bf2274a5 100644 --- a/src/utility/STM32_WPAN/app_conf_default.h +++ b/src/utility/STM32_WPAN/app_conf_default.h @@ -1,9 +1,9 @@ /* USER CODE BEGIN Header */ /** ****************************************************************************** - * @file app_conf.h + * @file app_conf_default.h * @author MCD Application Team - * @brief Application configuration file for STM32WPAN Middleware. + * @brief Default application configuration file for STM32WPAN Middleware. ****************************************************************************** * @attention * @@ -19,18 +19,40 @@ /* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef APP_CONF_H -#define APP_CONF_H +#ifndef APP_CONF_DEFAULT_H +#define APP_CONF_DEFAULT_H +#if 0 #include "hw.h" #include "hw_conf.h" #include "hw_if.h" #include "ble_bufsize.h" +#endif /****************************************************************************** * Application Config ******************************************************************************/ +/**< generic parameters ******************************************************/ +/* HCI related defines */ + +#define ACI_HAL_SET_TX_POWER_LEVEL 0xFC0F +#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C +#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D +#define MAX_HCI_ACL_PACKET_SIZE (sizeof(TL_PacketHeader_t) + 5 + 251) +#define HCI_RESET 0x0C03 + +#ifndef BLE_SHARED_MEM_BYTE_ORDER + #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST +#endif +#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 + +/** + * Define Tx Power + */ +#define CFG_TX_POWER (0x18) /* -0.15dBm */ + +#if 0 /** * Define Secure Connections Support */ @@ -104,6 +126,7 @@ #define CFG_FW_SUBVERSION (1) #define CFG_FW_BRANCH (0) #define CFG_FW_BUILD (0) +#endif /****************************************************************************** * BLE Stack @@ -250,7 +273,7 @@ * 0: LE Power Class 2-3 * other bits: complete with Options_extension flag */ -#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_HOST | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) +#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) /** * BLE stack Options_extension flags to be configured with: @@ -292,7 +315,11 @@ * This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set */ -#define CFG_BLE_MAX_ADV_SET_NBR (8) +#if defined(STM32WB15xx) + #define CFG_BLE_MAX_ADV_SET_NBR (3) +#else + #define CFG_BLE_MAX_ADV_SET_NBR (8) +#endif /* Maximum advertising data length (in bytes) * Range: 31 .. 1650 with limitation: @@ -301,7 +328,11 @@ * This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set */ -#define CFG_BLE_MAX_ADV_DATA_LEN (207) +#if defined(STM32WB15xx) + #define CFG_BLE_MAX_ADV_DATA_LEN (414) +#else + #define CFG_BLE_MAX_ADV_DATA_LEN (207) +#endif /* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. * Range: -1280 .. 1280 @@ -324,6 +355,7 @@ #define CFG_BLE_CORE_VERSION (SHCI_C2_BLE_INIT_BLE_CORE_5_4) +#if 0 /****************************************************************************** * Transport Layer ******************************************************************************/ @@ -660,4 +692,5 @@ typedef enum #define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR -#endif /*APP_CONF_H */ +#endif +#endif /*APP_CONF_DEFAULT_H */ diff --git a/src/utility/STM32_WPAN/hw.h b/src/utility/STM32_WPAN/hw.h index 651e1f17..1472a5e8 100644 --- a/src/utility/STM32_WPAN/hw.h +++ b/src/utility/STM32_WPAN/hw.h @@ -26,14 +26,23 @@ extern "C" { #endif /* Includes ------------------------------------------------------------------*/ +#include "stm32_def.h" +#include "stm32wbxx_ll_bus.h" +#include "stm32wbxx_ll_exti.h" +#include "stm32wbxx_ll_system.h" +#include "stm32wbxx_ll_rcc.h" +#include "stm32wbxx_ll_ipcc.h" +#include "stm32wbxx_ll_cortex.h" +#include "stm32wbxx_ll_utils.h" +#include "stm32wbxx_ll_pwr.h" /****************************************************************************** * HW IPCC ******************************************************************************/ void HW_IPCC_Enable( void ); void HW_IPCC_Init( void ); - void HW_IPCC_Rx_Handler( void ); - void HW_IPCC_Tx_Handler( void ); +#define HW_IPCC_Rx_Handler IPCC_C1_RX_IRQHandler +#define HW_IPCC_Tx_Handler IPCC_C1_TX_IRQHandler void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); diff --git a/src/utility/STM32_WPAN/hw_ipcc.c b/src/utility/STM32_WPAN/hw_ipcc.c index fd620b85..3461cbed 100644 --- a/src/utility/STM32_WPAN/hw_ipcc.c +++ b/src/utility/STM32_WPAN/hw_ipcc.c @@ -18,8 +18,9 @@ */ /* USER CODE END Header */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ -#include "app_common.h" +#include "hw.h" #include "mbox_def.h" /* Global variables ---------------------------------------------------------*/ @@ -667,3 +668,4 @@ static void HW_IPCC_TRACES_EvtHandler( void ) } __weak void HW_IPCC_TRACES_EvtNot( void ){}; +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/shci.c b/src/utility/STM32_WPAN/shci.c index 5c32555e..40110f42 100644 --- a/src/utility/STM32_WPAN/shci.c +++ b/src/utility/STM32_WPAN/shci.c @@ -17,6 +17,7 @@ */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -759,3 +760,4 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/shci_tl.c b/src/utility/STM32_WPAN/shci_tl.c index 0f604300..daa988c1 100644 --- a/src/utility/STM32_WPAN/shci_tl.c +++ b/src/utility/STM32_WPAN/shci_tl.c @@ -17,11 +17,13 @@ */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "stm_list.h" #include "shci_tl.h" +#include "stm32_def.h" /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -168,6 +170,20 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl return; } +void shci_notify_asynch_evt(void *pdata) +{ + UNUSED(pdata); + /* Need to parse data in future version */ + shci_user_evt_proc(); +} + +void shci_register_io_bus(tSHciIO *fops) +{ + /* Register IO bus services */ + fops->Init = TL_SYS_Init; + fops->Send = TL_SYS_SendCmd; +} + /* Private functions ---------------------------------------------------------*/ static void TlInit( TL_CmdPacket_t * p_cmdbuffer ) { @@ -250,3 +266,4 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/stm_list.c b/src/utility/STM32_WPAN/stm_list.c index 4c928647..df6c2155 100644 --- a/src/utility/STM32_WPAN/stm_list.c +++ b/src/utility/STM32_WPAN/stm_list.c @@ -17,10 +17,13 @@ */ +#if defined(STM32WBxx) /****************************************************************************** * Include Files ******************************************************************************/ -#include "utilities_common.h" +#include "stdint.h" +#include "cmsis_gcc.h" +#include "stm32_wpan_common.h" #include "stm_list.h" @@ -204,3 +207,4 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/tl_mbox.c b/src/utility/STM32_WPAN/tl_mbox.c index df07a197..9a2a2973 100644 --- a/src/utility/STM32_WPAN/tl_mbox.c +++ b/src/utility/STM32_WPAN/tl_mbox.c @@ -16,6 +16,7 @@ ****************************************************************************** */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -51,8 +52,10 @@ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleLldTable_t TL_BleLldTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_SysTable_t TL_SysTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_MemManagerTable_t TL_MemManagerTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_TracesTable_t TL_TracesTable; +#if 0 PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_Mac_802_15_4_t TL_Mac_802_15_4_Table; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ZigbeeTable_t TL_Zigbee_Table; +#endif /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; @@ -97,8 +100,10 @@ void TL_Init( void ) TL_RefTable.p_sys_table = &TL_SysTable; TL_RefTable.p_mem_manager_table = &TL_MemManagerTable; TL_RefTable.p_traces_table = &TL_TracesTable; +#if 0 TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; +#endif HW_IPCC_Init(); return; @@ -847,3 +852,4 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } +#endif /* STM32WBxx */ From faf4e9048be7c450278c6cb227f74d407bb4c480 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 13 Jul 2023 17:16:40 +0200 Subject: [PATCH 08/17] fix: include a timeout when waiting for the cmd_resp Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/shci_tl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utility/STM32_WPAN/shci_tl.c b/src/utility/STM32_WPAN/shci_tl.c index daa988c1..25e1a214 100644 --- a/src/utility/STM32_WPAN/shci_tl.c +++ b/src/utility/STM32_WPAN/shci_tl.c @@ -24,6 +24,7 @@ #include "stm_list.h" #include "shci_tl.h" #include "stm32_def.h" +#include "wiring_time.h" /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -251,10 +252,11 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { - (void)timeout; - - while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); - + for (unsigned long start = millis(); (millis() - start) < timeout;) { + if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { + break; + } + } return; } From bae86c445bd4ff3ddbabd21f0ead27a05b0c83d3 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 10 Jan 2024 18:45:17 +0100 Subject: [PATCH 09/17] chore: add support for customize app_conf_default.h Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/app_conf_default.h | 58 ++++++++++++++++++----- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h index bf2274a5..ff2dc017 100644 --- a/src/utility/STM32_WPAN/app_conf_default.h +++ b/src/utility/STM32_WPAN/app_conf_default.h @@ -50,7 +50,9 @@ /** * Define Tx Power */ -#define CFG_TX_POWER (0x18) /* -0.15dBm */ +#ifndef CFG_TX_POWER + #define CFG_TX_POWER (0x18) /* -0.15dBm */ +#endif #if 0 /** @@ -135,13 +137,25 @@ * Maximum number of simultaneous connections that the device will support. * Valid values are from 1 to 8 */ -#define CFG_BLE_NUM_LINK 8 +#ifndef CFG_BLE_NUM_LINK +#ifdef STM32WB15xx + #define CFG_BLE_NUM_LINK 3 +#else + #define CFG_BLE_NUM_LINK 8 +#endif +#endif /** * Maximum number of Services that can be stored in the GATT database. * Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user services */ -#define CFG_BLE_NUM_GATT_SERVICES 8 +#ifndef CFG_BLE_NUM_GATT_SERVICES +#ifdef STM32WB15xx + #define CFG_BLE_NUM_GATT_SERVICES 4 +#else + #define CFG_BLE_NUM_GATT_SERVICES 8 +#endif +#endif /** * Maximum number of Attributes @@ -150,7 +164,13 @@ * Note that certain characteristics and relative descriptors are added automatically during device initialization * so this parameters should be 9 plus the number of user Attributes */ -#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#ifndef CFG_BLE_NUM_GATT_ATTRIBUTES +#ifdef STM32WB15xx + #define CFG_BLE_NUM_GATT_ATTRIBUTES 30 +#else + #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#endif +#endif /** * Maximum supported ATT_MTU size @@ -186,12 +206,16 @@ /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. */ -#define CFG_BLE_DATA_LENGTH_EXTENSION 1 +#ifndef CFG_BLE_DATA_LENGTH_EXTENSION + #define CFG_BLE_DATA_LENGTH_EXTENSION 1 +#endif /** * Sleep clock accuracy in Peripheral mode (ppm value) */ -#define CFG_BLE_PERIPHERAL_SCA 500 +#ifndef CFG_BLE_PERIPHERAL_SCA + #define CFG_BLE_PERIPHERAL_SCA 500 +#endif /** * Sleep clock accuracy in Central mode @@ -204,7 +228,9 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#define CFG_BLE_CENTRAL_SCA 0 +#ifndef CFG_BLE_CENTRAL_SCA + #define CFG_BLE_CENTRAL_SCA 0 +#endif /** * LsSource @@ -213,21 +239,27 @@ * - bit 1: 1: STM32WB5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module * - bit 2: 1: HSE/1024 Clock config 0: LSE Clock config */ -#if defined(STM32WB5Mxx) - #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) -#else - #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) +#ifndef CFG_BLE_LS_SOURCE + #if defined(STM32WB5Mxx) + #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) + #else + #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) + #endif #endif /** * Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us) */ -#define CFG_BLE_HSE_STARTUP_TIME 0x148 +#ifndef CFG_BLE_HSE_STARTUP_TIME + #define CFG_BLE_HSE_STARTUP_TIME 0x148 +#endif /** * Maximum duration of the connection event when the device is in Peripheral mode in units of 625/256 us (~2.44 us) */ -#define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) +#ifndef CFG_BLE_MAX_CONN_EVENT_LENGTH + #define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) +#endif /** * Viterbi Mode From bf11bf0a0a22919c8b79c48f0300878fad7e5d81 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 24 Jul 2023 10:55:20 +0200 Subject: [PATCH 10/17] fix: TL_Evt_t payload size for reset Within STM32CubeWB v1.17.0 update TL_Evt_t payload size was reduced. This produce a warning -Warray-bounds due to the reset management which require 4 bytes. Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/tl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/STM32_WPAN/tl.h b/src/utility/STM32_WPAN/tl.h index 8e8c6cbc..74520878 100644 --- a/src/utility/STM32_WPAN/tl.h +++ b/src/utility/STM32_WPAN/tl.h @@ -108,7 +108,7 @@ typedef PACKED_STRUCT { uint8_t evtcode; uint8_t plen; - uint8_t payload[2]; + uint8_t payload[4]; } TL_Evt_t; typedef PACKED_STRUCT From 433999896e26efed35bfded74699e8f20573be2a Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 10 Jan 2024 18:16:01 +0100 Subject: [PATCH 11/17] chore: regenerate STM32_WPAN patches Signed-off-by: Frederic Pillon --- .../0001-chore-adapt-STM32_WPAN-sources.patch | 16 ++++++++-------- ...a-timeout-when-waiting-for-the-cmd_resp.patch | 2 +- ...upport-for-customize-app_conf_default.h.patch | 4 ++-- ...004-fix-TL_Evt_t-payload-size-for-reset.patch | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/extras/STM32_WPAN/0001-chore-adapt-STM32_WPAN-sources.patch b/extras/STM32_WPAN/0001-chore-adapt-STM32_WPAN-sources.patch index 90daace9..a3f62011 100644 --- a/extras/STM32_WPAN/0001-chore-adapt-STM32_WPAN-sources.patch +++ b/extras/STM32_WPAN/0001-chore-adapt-STM32_WPAN-sources.patch @@ -1,4 +1,4 @@ -From 5587ff466e0276de186103d21e6a4e498820e49f Mon Sep 17 00:00:00 2001 +From 7f99c89e8a6f834daf4a76bf98307e9ebcd01c91 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 10 Jan 2024 18:16:01 +0100 Subject: [PATCH 1/4] chore: adapt STM32_WPAN sources @@ -15,7 +15,7 @@ Signed-off-by: Frederic Pillon 7 files changed, 85 insertions(+), 12 deletions(-) diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h -index 846be3c..6c9beb3 100644 +index 71fc107..bf2274a 100644 --- a/src/utility/STM32_WPAN/app_conf_default.h +++ b/src/utility/STM32_WPAN/app_conf_default.h @@ -1,9 +1,9 @@ @@ -124,7 +124,7 @@ index 846be3c..6c9beb3 100644 /****************************************************************************** * Transport Layer ******************************************************************************/ -@@ -659,4 +691,5 @@ typedef enum +@@ -660,4 +692,5 @@ typedef enum #define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR @@ -162,7 +162,7 @@ index 651e1f1..1472a5e 100644 void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); diff --git a/src/utility/STM32_WPAN/hw_ipcc.c b/src/utility/STM32_WPAN/hw_ipcc.c -index fd620b8..3461cbe 100644 +index 6a311b1..ad3c9d4 100644 --- a/src/utility/STM32_WPAN/hw_ipcc.c +++ b/src/utility/STM32_WPAN/hw_ipcc.c @@ -18,8 +18,9 @@ @@ -174,9 +174,9 @@ index fd620b8..3461cbe 100644 -#include "app_common.h" +#include "hw.h" #include "mbox_def.h" + #include "utilities_conf.h" - /* Global variables ---------------------------------------------------------*/ -@@ -667,3 +668,4 @@ static void HW_IPCC_TRACES_EvtHandler( void ) +@@ -745,3 +746,4 @@ static void HW_IPCC_TRACES_EvtHandler( void ) } __weak void HW_IPCC_TRACES_EvtNot( void ){}; @@ -267,7 +267,7 @@ index 4c92864..df6c215 100644 } +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/tl_mbox.c b/src/utility/STM32_WPAN/tl_mbox.c -index 27a998a..40c9679 100644 +index df07a19..9a2a297 100644 --- a/src/utility/STM32_WPAN/tl_mbox.c +++ b/src/utility/STM32_WPAN/tl_mbox.c @@ -16,6 +16,7 @@ @@ -300,7 +300,7 @@ index 27a998a..40c9679 100644 HW_IPCC_Init(); return; -@@ -846,3 +851,4 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) +@@ -847,3 +852,4 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } diff --git a/extras/STM32_WPAN/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch b/extras/STM32_WPAN/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch index e234d198..bd6f66a2 100644 --- a/extras/STM32_WPAN/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch +++ b/extras/STM32_WPAN/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch @@ -1,4 +1,4 @@ -From 2867f96057d7bd5b34cfc3395d78653856f9cc7c Mon Sep 17 00:00:00 2001 +From a33328182e334e1ddedd368a047d75cf1662e330 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 13 Jul 2023 17:16:40 +0200 Subject: [PATCH 2/4] fix: include a timeout when waiting for the cmd_resp diff --git a/extras/STM32_WPAN/0003-chore-add-support-for-customize-app_conf_default.h.patch b/extras/STM32_WPAN/0003-chore-add-support-for-customize-app_conf_default.h.patch index bd66679d..3c5e66ae 100644 --- a/extras/STM32_WPAN/0003-chore-add-support-for-customize-app_conf_default.h.patch +++ b/extras/STM32_WPAN/0003-chore-add-support-for-customize-app_conf_default.h.patch @@ -1,4 +1,4 @@ -From ba3df1bd28eb49eab28a99fa88481f45fe565cbf Mon Sep 17 00:00:00 2001 +From a973b405bf34a93b0c300c8bbc4aa5d59fa182e5 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 10 Jan 2024 18:45:17 +0100 Subject: [PATCH 3/4] chore: add support for customize app_conf_default.h @@ -9,7 +9,7 @@ Signed-off-by: Frederic Pillon 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h -index 6c9beb3..9509a0f 100644 +index bf2274a..ff2dc01 100644 --- a/src/utility/STM32_WPAN/app_conf_default.h +++ b/src/utility/STM32_WPAN/app_conf_default.h @@ -50,7 +50,9 @@ diff --git a/extras/STM32_WPAN/0004-fix-TL_Evt_t-payload-size-for-reset.patch b/extras/STM32_WPAN/0004-fix-TL_Evt_t-payload-size-for-reset.patch index 035d4b99..110a8410 100644 --- a/extras/STM32_WPAN/0004-fix-TL_Evt_t-payload-size-for-reset.patch +++ b/extras/STM32_WPAN/0004-fix-TL_Evt_t-payload-size-for-reset.patch @@ -1,4 +1,4 @@ -From a6ae9acf134d326f74ff04818b4e2c643c826b35 Mon Sep 17 00:00:00 2001 +From 324eef795bfd0a754aae4d5f9b528d4c8ad706c8 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 24 Jul 2023 10:55:20 +0200 Subject: [PATCH 4/4] fix: TL_Evt_t payload size for reset From f7ca0a26ed091f3f253d00bcc7fbbf1642d5515f Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 5 Mar 2025 09:30:56 +0100 Subject: [PATCH 12/17] chore: update STM32_WPAN from Cube version v1.22.0 Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/README.md | 4 +- src/utility/STM32_WPAN/app_conf_default.h | 105 +++++----------------- src/utility/STM32_WPAN/ble_bufsize.h | 6 +- src/utility/STM32_WPAN/hw.h | 13 +-- src/utility/STM32_WPAN/hw_ipcc.c | 82 ++++++++++++++++- src/utility/STM32_WPAN/shci.c | 2 - src/utility/STM32_WPAN/shci_tl.c | 27 +----- src/utility/STM32_WPAN/stm_list.c | 6 +- src/utility/STM32_WPAN/tl.h | 2 +- src/utility/STM32_WPAN/tl_mbox.c | 6 -- src/utility/STM32_WPAN/utilities_conf.h | 66 ++++++++++++++ 11 files changed, 178 insertions(+), 141 deletions(-) create mode 100644 src/utility/STM32_WPAN/utilities_conf.h diff --git a/src/utility/STM32_WPAN/README.md b/src/utility/STM32_WPAN/README.md index a9b3969a..90f96452 100644 --- a/src/utility/STM32_WPAN/README.md +++ b/src/utility/STM32_WPAN/README.md @@ -1,6 +1,6 @@ ## Source -[STMicroelectronics/STM32CubeWB Release v1.21.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.21.0) -- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.21.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) +[STMicroelectronics/STM32CubeWB Release v1.22.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.22.0) +- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.22.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h index ff2dc017..71fc107b 100644 --- a/src/utility/STM32_WPAN/app_conf_default.h +++ b/src/utility/STM32_WPAN/app_conf_default.h @@ -1,9 +1,9 @@ /* USER CODE BEGIN Header */ /** ****************************************************************************** - * @file app_conf_default.h + * @file app_conf.h * @author MCD Application Team - * @brief Default application configuration file for STM32WPAN Middleware. + * @brief Application configuration file for STM32WPAN Middleware. ****************************************************************************** * @attention * @@ -19,42 +19,18 @@ /* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef APP_CONF_DEFAULT_H -#define APP_CONF_DEFAULT_H +#ifndef APP_CONF_H +#define APP_CONF_H -#if 0 #include "hw.h" #include "hw_conf.h" #include "hw_if.h" #include "ble_bufsize.h" -#endif /****************************************************************************** * Application Config ******************************************************************************/ -/**< generic parameters ******************************************************/ -/* HCI related defines */ - -#define ACI_HAL_SET_TX_POWER_LEVEL 0xFC0F -#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C -#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D -#define MAX_HCI_ACL_PACKET_SIZE (sizeof(TL_PacketHeader_t) + 5 + 251) -#define HCI_RESET 0x0C03 - -#ifndef BLE_SHARED_MEM_BYTE_ORDER - #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST -#endif -#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 - -/** - * Define Tx Power - */ -#ifndef CFG_TX_POWER - #define CFG_TX_POWER (0x18) /* -0.15dBm */ -#endif - -#if 0 /** * Define Secure Connections Support */ @@ -128,7 +104,6 @@ #define CFG_FW_SUBVERSION (1) #define CFG_FW_BRANCH (0) #define CFG_FW_BUILD (0) -#endif /****************************************************************************** * BLE Stack @@ -137,25 +112,13 @@ * Maximum number of simultaneous connections that the device will support. * Valid values are from 1 to 8 */ -#ifndef CFG_BLE_NUM_LINK -#ifdef STM32WB15xx - #define CFG_BLE_NUM_LINK 3 -#else - #define CFG_BLE_NUM_LINK 8 -#endif -#endif +#define CFG_BLE_NUM_LINK 8 /** * Maximum number of Services that can be stored in the GATT database. * Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user services */ -#ifndef CFG_BLE_NUM_GATT_SERVICES -#ifdef STM32WB15xx - #define CFG_BLE_NUM_GATT_SERVICES 4 -#else - #define CFG_BLE_NUM_GATT_SERVICES 8 -#endif -#endif +#define CFG_BLE_NUM_GATT_SERVICES 8 /** * Maximum number of Attributes @@ -164,13 +127,7 @@ * Note that certain characteristics and relative descriptors are added automatically during device initialization * so this parameters should be 9 plus the number of user Attributes */ -#ifndef CFG_BLE_NUM_GATT_ATTRIBUTES -#ifdef STM32WB15xx - #define CFG_BLE_NUM_GATT_ATTRIBUTES 30 -#else - #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 -#endif -#endif +#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 /** * Maximum supported ATT_MTU size @@ -206,16 +163,12 @@ /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. */ -#ifndef CFG_BLE_DATA_LENGTH_EXTENSION - #define CFG_BLE_DATA_LENGTH_EXTENSION 1 -#endif +#define CFG_BLE_DATA_LENGTH_EXTENSION 1 /** * Sleep clock accuracy in Peripheral mode (ppm value) */ -#ifndef CFG_BLE_PERIPHERAL_SCA - #define CFG_BLE_PERIPHERAL_SCA 500 -#endif +#define CFG_BLE_PERIPHERAL_SCA 500 /** * Sleep clock accuracy in Central mode @@ -228,9 +181,7 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#ifndef CFG_BLE_CENTRAL_SCA - #define CFG_BLE_CENTRAL_SCA 0 -#endif +#define CFG_BLE_CENTRAL_SCA 0 /** * LsSource @@ -239,27 +190,21 @@ * - bit 1: 1: STM32WB5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module * - bit 2: 1: HSE/1024 Clock config 0: LSE Clock config */ -#ifndef CFG_BLE_LS_SOURCE - #if defined(STM32WB5Mxx) - #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) - #else - #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) - #endif +#if defined(STM32WB5Mxx) + #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) +#else + #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) #endif /** * Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us) */ -#ifndef CFG_BLE_HSE_STARTUP_TIME - #define CFG_BLE_HSE_STARTUP_TIME 0x148 -#endif +#define CFG_BLE_HSE_STARTUP_TIME 0x148 /** * Maximum duration of the connection event when the device is in Peripheral mode in units of 625/256 us (~2.44 us) */ -#ifndef CFG_BLE_MAX_CONN_EVENT_LENGTH - #define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) -#endif +#define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) /** * Viterbi Mode @@ -305,7 +250,7 @@ * 0: LE Power Class 2-3 * other bits: complete with Options_extension flag */ -#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) +#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_HOST | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) /** * BLE stack Options_extension flags to be configured with: @@ -347,11 +292,7 @@ * This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set */ -#if defined(STM32WB15xx) - #define CFG_BLE_MAX_ADV_SET_NBR (3) -#else - #define CFG_BLE_MAX_ADV_SET_NBR (8) -#endif +#define CFG_BLE_MAX_ADV_SET_NBR (8) /* Maximum advertising data length (in bytes) * Range: 31 .. 1650 with limitation: @@ -360,11 +301,7 @@ * This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set */ -#if defined(STM32WB15xx) - #define CFG_BLE_MAX_ADV_DATA_LEN (414) -#else - #define CFG_BLE_MAX_ADV_DATA_LEN (207) -#endif +#define CFG_BLE_MAX_ADV_DATA_LEN (207) /* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. * Range: -1280 .. 1280 @@ -387,7 +324,6 @@ #define CFG_BLE_CORE_VERSION (SHCI_C2_BLE_INIT_BLE_CORE_5_4) -#if 0 /****************************************************************************** * Transport Layer ******************************************************************************/ @@ -724,5 +660,4 @@ typedef enum #define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR -#endif -#endif /*APP_CONF_DEFAULT_H */ +#endif /*APP_CONF_H */ diff --git a/src/utility/STM32_WPAN/ble_bufsize.h b/src/utility/STM32_WPAN/ble_bufsize.h index c5018420..26551c09 100644 --- a/src/utility/STM32_WPAN/ble_bufsize.h +++ b/src/utility/STM32_WPAN/ble_bufsize.h @@ -5,7 +5,7 @@ ***************************************************************************** * @attention * - * Copyright (c) 2018-2024 STMicroelectronics. + * Copyright (c) 2018-2025 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file @@ -97,7 +97,7 @@ * mentioned parameters. */ #if (BEACON_ONLY != 0) -#define BLE_FIXED_BUFFER_SIZE_BYTES 4100 /* Beacon only */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 4200 /* Beacon only */ #elif (LL_ONLY_BASIC != 0) #define BLE_FIXED_BUFFER_SIZE_BYTES 6040 /* LL only Basic*/ #elif (LL_ONLY != 0) @@ -114,7 +114,7 @@ * BLE_PER_LINK_SIZE_BYTES: additional memory size used per link */ #if (BEACON_ONLY != 0) -#define BLE_PER_LINK_SIZE_BYTES 108 /* Beacon only */ +#define BLE_PER_LINK_SIZE_BYTES 76 /* Beacon only */ #elif (LL_ONLY_BASIC != 0) #define BLE_PER_LINK_SIZE_BYTES 244 /* LL only Basic */ #elif (LL_ONLY != 0) diff --git a/src/utility/STM32_WPAN/hw.h b/src/utility/STM32_WPAN/hw.h index 1472a5e8..651e1f17 100644 --- a/src/utility/STM32_WPAN/hw.h +++ b/src/utility/STM32_WPAN/hw.h @@ -26,23 +26,14 @@ extern "C" { #endif /* Includes ------------------------------------------------------------------*/ -#include "stm32_def.h" -#include "stm32wbxx_ll_bus.h" -#include "stm32wbxx_ll_exti.h" -#include "stm32wbxx_ll_system.h" -#include "stm32wbxx_ll_rcc.h" -#include "stm32wbxx_ll_ipcc.h" -#include "stm32wbxx_ll_cortex.h" -#include "stm32wbxx_ll_utils.h" -#include "stm32wbxx_ll_pwr.h" /****************************************************************************** * HW IPCC ******************************************************************************/ void HW_IPCC_Enable( void ); void HW_IPCC_Init( void ); -#define HW_IPCC_Rx_Handler IPCC_C1_RX_IRQHandler -#define HW_IPCC_Tx_Handler IPCC_C1_TX_IRQHandler + void HW_IPCC_Rx_Handler( void ); + void HW_IPCC_Tx_Handler( void ); void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); diff --git a/src/utility/STM32_WPAN/hw_ipcc.c b/src/utility/STM32_WPAN/hw_ipcc.c index 3461cbed..6a311b14 100644 --- a/src/utility/STM32_WPAN/hw_ipcc.c +++ b/src/utility/STM32_WPAN/hw_ipcc.c @@ -18,10 +18,10 @@ */ /* USER CODE END Header */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ -#include "hw.h" +#include "app_common.h" #include "mbox_def.h" +#include "utilities_conf.h" /* Global variables ---------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/ @@ -227,7 +227,9 @@ void HW_IPCC_Init( void ) ******************************************************************************/ void HW_IPCC_BLE_Init( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_BLE_EVENT_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -251,14 +253,18 @@ static void HW_IPCC_BLE_EvtHandler( void ) void HW_IPCC_BLE_SendAclData( void ) { LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } static void HW_IPCC_BLE_AclDataEvtHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_BLE_AclDataAckNot(); @@ -273,7 +279,9 @@ __weak void HW_IPCC_BLE_RxEvtNot( void ){}; ******************************************************************************/ void HW_IPCC_SYS_Init( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -281,14 +289,18 @@ void HW_IPCC_SYS_Init( void ) void HW_IPCC_SYS_SendCmd( void ) { LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } static void HW_IPCC_SYS_CmdEvtHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_SYS_CmdEvtNot(); @@ -313,7 +325,9 @@ __weak void HW_IPCC_SYS_EvtNot( void ){}; #ifdef MAC_802_15_4_WB void HW_IPCC_MAC_802_15_4_Init( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -321,7 +335,9 @@ void HW_IPCC_MAC_802_15_4_Init( void ) void HW_IPCC_MAC_802_15_4_SendCmd( void ) { LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -329,14 +345,18 @@ void HW_IPCC_MAC_802_15_4_SendCmd( void ) void HW_IPCC_MAC_802_15_4_SendAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_MAC_802_15_4_CmdEvtNot(); @@ -345,7 +365,9 @@ static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ) static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_MAC_802_15_4_EvtNot(); @@ -361,8 +383,10 @@ __weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){}; #ifdef THREAD_WB void HW_IPCC_THREAD_Init( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -370,7 +394,9 @@ void HW_IPCC_THREAD_Init( void ) void HW_IPCC_OT_SendCmd( void ) { LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -385,7 +411,9 @@ void HW_IPCC_CLI_SendCmd( void ) void HW_IPCC_THREAD_SendAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -393,14 +421,18 @@ void HW_IPCC_THREAD_SendAck( void ) void HW_IPCC_THREAD_CliSendAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } static void HW_IPCC_OT_CmdEvtHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_OT_CmdEvtNot(); @@ -409,7 +441,9 @@ static void HW_IPCC_OT_CmdEvtHandler( void ) static void HW_IPCC_THREAD_NotEvtHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_THREAD_EvtNot(); @@ -418,7 +452,9 @@ static void HW_IPCC_THREAD_NotEvtHandler( void ) static void HW_IPCC_THREAD_CliNotEvtHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_THREAD_CliEvtNot(); @@ -437,8 +473,10 @@ __weak void HW_IPCC_THREAD_EvtNot( void ){}; #ifdef LLD_TESTS_WB void HW_IPCC_LLDTESTS_Init( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -450,7 +488,10 @@ void HW_IPCC_LLDTESTS_SendCliCmd( void ) static void HW_IPCC_LLDTESTS_ReceiveCliRspHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); + HW_IPCC_LLDTESTS_ReceiveCliRsp(); return; } @@ -458,13 +499,17 @@ static void HW_IPCC_LLDTESTS_ReceiveCliRspHandler( void ) void HW_IPCC_LLDTESTS_SendCliRspAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } static void HW_IPCC_LLDTESTS_ReceiveM0CmdHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_LLDTESTS_ReceiveM0Cmd(); return; } @@ -472,7 +517,9 @@ static void HW_IPCC_LLDTESTS_ReceiveM0CmdHandler( void ) void HW_IPCC_LLDTESTS_SendM0CmdAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } __weak void HW_IPCC_LLDTESTS_ReceiveCliRsp( void ){}; @@ -485,8 +532,10 @@ __weak void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void ){}; #ifdef LLD_BLE_WB void HW_IPCC_LLD_BLE_Init( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -498,7 +547,9 @@ void HW_IPCC_LLD_BLE_SendCliCmd( void ) /*static void HW_IPCC_LLD_BLE_ReceiveCliRspHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_LLD_BLE_ReceiveCliRsp(); return; }*/ @@ -506,7 +557,9 @@ void HW_IPCC_LLD_BLE_SendCliCmd( void ) void HW_IPCC_LLD_BLE_SendCliRspAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -535,7 +588,9 @@ void HW_IPCC_LLD_BLE_SendCmd( void ) static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_LLD_BLE_ReceiveRsp(); return; } @@ -543,7 +598,9 @@ static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ) void HW_IPCC_LLD_BLE_SendRspAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -555,8 +612,10 @@ void HW_IPCC_LLD_BLE_SendRspAck( void ) #ifdef ZIGBEE_WB void HW_IPCC_ZIGBEE_Init( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -564,7 +623,9 @@ void HW_IPCC_ZIGBEE_Init( void ) void HW_IPCC_ZIGBEE_SendM4RequestToM0( void ) { LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -572,14 +633,18 @@ void HW_IPCC_ZIGBEE_SendM4RequestToM0( void ) void HW_IPCC_ZIGBEE_SendM4AckToM0Notify( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_ZIGBEE_RecvAppliAckFromM0(); @@ -588,7 +653,9 @@ static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ) static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_ZIGBEE_RecvM0NotifyToM4(); @@ -597,7 +664,9 @@ static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ) static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); HW_IPCC_ZIGBEE_RecvM0RequestToM4(); @@ -607,7 +676,9 @@ static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ) void HW_IPCC_ZIGBEE_SendM4AckToM0Request( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -625,7 +696,9 @@ void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) ) if ( LL_C1_IPCC_IsActiveFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ) ) { FreeBufCb = cb; + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); } else { @@ -639,7 +712,9 @@ void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) ) static void HW_IPCC_MM_FreeBufHandler( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); FreeBufCb(); @@ -653,7 +728,9 @@ static void HW_IPCC_MM_FreeBufHandler( void ) ******************************************************************************/ void HW_IPCC_TRACES_Init( void ) { + UTILS_ENTER_CRITICAL_SECTION(); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_TRACES_CHANNEL ); + UTILS_EXIT_CRITICAL_SECTION(); return; } @@ -668,4 +745,3 @@ static void HW_IPCC_TRACES_EvtHandler( void ) } __weak void HW_IPCC_TRACES_EvtNot( void ){}; -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/shci.c b/src/utility/STM32_WPAN/shci.c index 40110f42..5c32555e 100644 --- a/src/utility/STM32_WPAN/shci.c +++ b/src/utility/STM32_WPAN/shci.c @@ -17,7 +17,6 @@ */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -760,4 +759,3 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/shci_tl.c b/src/utility/STM32_WPAN/shci_tl.c index 25e1a214..0f604300 100644 --- a/src/utility/STM32_WPAN/shci_tl.c +++ b/src/utility/STM32_WPAN/shci_tl.c @@ -17,14 +17,11 @@ */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "stm_list.h" #include "shci_tl.h" -#include "stm32_def.h" -#include "wiring_time.h" /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -171,20 +168,6 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl return; } -void shci_notify_asynch_evt(void *pdata) -{ - UNUSED(pdata); - /* Need to parse data in future version */ - shci_user_evt_proc(); -} - -void shci_register_io_bus(tSHciIO *fops) -{ - /* Register IO bus services */ - fops->Init = TL_SYS_Init; - fops->Send = TL_SYS_SendCmd; -} - /* Private functions ---------------------------------------------------------*/ static void TlInit( TL_CmdPacket_t * p_cmdbuffer ) { @@ -252,11 +235,10 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { - for (unsigned long start = millis(); (millis() - start) < timeout;) { - if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { - break; - } - } + (void)timeout; + + while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); + return; } @@ -268,4 +250,3 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/stm_list.c b/src/utility/STM32_WPAN/stm_list.c index df6c2155..4c928647 100644 --- a/src/utility/STM32_WPAN/stm_list.c +++ b/src/utility/STM32_WPAN/stm_list.c @@ -17,13 +17,10 @@ */ -#if defined(STM32WBxx) /****************************************************************************** * Include Files ******************************************************************************/ -#include "stdint.h" -#include "cmsis_gcc.h" -#include "stm32_wpan_common.h" +#include "utilities_common.h" #include "stm_list.h" @@ -207,4 +204,3 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/tl.h b/src/utility/STM32_WPAN/tl.h index 74520878..8e8c6cbc 100644 --- a/src/utility/STM32_WPAN/tl.h +++ b/src/utility/STM32_WPAN/tl.h @@ -108,7 +108,7 @@ typedef PACKED_STRUCT { uint8_t evtcode; uint8_t plen; - uint8_t payload[4]; + uint8_t payload[2]; } TL_Evt_t; typedef PACKED_STRUCT diff --git a/src/utility/STM32_WPAN/tl_mbox.c b/src/utility/STM32_WPAN/tl_mbox.c index 9a2a2973..df07a197 100644 --- a/src/utility/STM32_WPAN/tl_mbox.c +++ b/src/utility/STM32_WPAN/tl_mbox.c @@ -16,7 +16,6 @@ ****************************************************************************** */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -52,10 +51,8 @@ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleLldTable_t TL_BleLldTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_SysTable_t TL_SysTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_MemManagerTable_t TL_MemManagerTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_TracesTable_t TL_TracesTable; -#if 0 PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_Mac_802_15_4_t TL_Mac_802_15_4_Table; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ZigbeeTable_t TL_Zigbee_Table; -#endif /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; @@ -100,10 +97,8 @@ void TL_Init( void ) TL_RefTable.p_sys_table = &TL_SysTable; TL_RefTable.p_mem_manager_table = &TL_MemManagerTable; TL_RefTable.p_traces_table = &TL_TracesTable; -#if 0 TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; -#endif HW_IPCC_Init(); return; @@ -852,4 +847,3 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/utilities_conf.h b/src/utility/STM32_WPAN/utilities_conf.h new file mode 100644 index 00000000..d6221a73 --- /dev/null +++ b/src/utility/STM32_WPAN/utilities_conf.h @@ -0,0 +1,66 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file utilities_conf.h + * @author MCD Application Team + * @brief Configuration file for STM32 Utilities. + ****************************************************************************** + * @attention + * + * Copyright (c) 2019-2021 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 */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef UTILITIES_CONF_H +#define UTILITIES_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "cmsis_compiler.h" +#include "string.h" +#include "app_conf.h" + +/****************************************************************************** + * common + ******************************************************************************/ +#define UTILS_ENTER_CRITICAL_SECTION( ) uint32_t primask_bit = __get_PRIMASK( );\ + __disable_irq( ) + +#define UTILS_EXIT_CRITICAL_SECTION( ) __set_PRIMASK( primask_bit ) + +#define UTILS_MEMSET8( dest, value, size ) memset( dest, value, size); + +/****************************************************************************** + * tiny low power manager + * (any macro that does not need to be modified can be removed) + ******************************************************************************/ +#define UTIL_LPM_INIT_CRITICAL_SECTION( ) +#define UTIL_LPM_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION( ) +#define UTIL_LPM_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION( ) + +/****************************************************************************** + * sequencer + * (any macro that does not need to be modified can be removed) + ******************************************************************************/ +#define UTIL_SEQ_INIT_CRITICAL_SECTION( ) +#define UTIL_SEQ_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION( ) +#define UTIL_SEQ_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION( ) +#define UTIL_SEQ_CONF_TASK_NBR (32) +#define UTIL_SEQ_CONF_PRIO_NBR CFG_SCH_PRIO_NBR +#define UTIL_SEQ_MEMSET8( dest, value, size ) UTILS_MEMSET8( dest, value, size ) + +#ifdef __cplusplus +} +#endif + +#endif /*UTILITIES_CONF_H */ From 20b8a4c663e3dde6eb896d60ae2d25c167a03856 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 10 Jan 2024 18:16:01 +0100 Subject: [PATCH 13/17] chore: adapt STM32_WPAN sources Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/app_conf_default.h | 49 +++++++++++++++++++---- src/utility/STM32_WPAN/hw.h | 13 +++++- src/utility/STM32_WPAN/hw_ipcc.c | 4 +- src/utility/STM32_WPAN/shci.c | 2 + src/utility/STM32_WPAN/shci_tl.c | 17 ++++++++ src/utility/STM32_WPAN/stm_list.c | 6 ++- src/utility/STM32_WPAN/tl_mbox.c | 6 +++ 7 files changed, 85 insertions(+), 12 deletions(-) diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h index 71fc107b..bf2274a5 100644 --- a/src/utility/STM32_WPAN/app_conf_default.h +++ b/src/utility/STM32_WPAN/app_conf_default.h @@ -1,9 +1,9 @@ /* USER CODE BEGIN Header */ /** ****************************************************************************** - * @file app_conf.h + * @file app_conf_default.h * @author MCD Application Team - * @brief Application configuration file for STM32WPAN Middleware. + * @brief Default application configuration file for STM32WPAN Middleware. ****************************************************************************** * @attention * @@ -19,18 +19,40 @@ /* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef APP_CONF_H -#define APP_CONF_H +#ifndef APP_CONF_DEFAULT_H +#define APP_CONF_DEFAULT_H +#if 0 #include "hw.h" #include "hw_conf.h" #include "hw_if.h" #include "ble_bufsize.h" +#endif /****************************************************************************** * Application Config ******************************************************************************/ +/**< generic parameters ******************************************************/ +/* HCI related defines */ + +#define ACI_HAL_SET_TX_POWER_LEVEL 0xFC0F +#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C +#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D +#define MAX_HCI_ACL_PACKET_SIZE (sizeof(TL_PacketHeader_t) + 5 + 251) +#define HCI_RESET 0x0C03 + +#ifndef BLE_SHARED_MEM_BYTE_ORDER + #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST +#endif +#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 + +/** + * Define Tx Power + */ +#define CFG_TX_POWER (0x18) /* -0.15dBm */ + +#if 0 /** * Define Secure Connections Support */ @@ -104,6 +126,7 @@ #define CFG_FW_SUBVERSION (1) #define CFG_FW_BRANCH (0) #define CFG_FW_BUILD (0) +#endif /****************************************************************************** * BLE Stack @@ -250,7 +273,7 @@ * 0: LE Power Class 2-3 * other bits: complete with Options_extension flag */ -#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_HOST | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) +#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) /** * BLE stack Options_extension flags to be configured with: @@ -292,7 +315,11 @@ * This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set */ -#define CFG_BLE_MAX_ADV_SET_NBR (8) +#if defined(STM32WB15xx) + #define CFG_BLE_MAX_ADV_SET_NBR (3) +#else + #define CFG_BLE_MAX_ADV_SET_NBR (8) +#endif /* Maximum advertising data length (in bytes) * Range: 31 .. 1650 with limitation: @@ -301,7 +328,11 @@ * This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set */ -#define CFG_BLE_MAX_ADV_DATA_LEN (207) +#if defined(STM32WB15xx) + #define CFG_BLE_MAX_ADV_DATA_LEN (414) +#else + #define CFG_BLE_MAX_ADV_DATA_LEN (207) +#endif /* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. * Range: -1280 .. 1280 @@ -324,6 +355,7 @@ #define CFG_BLE_CORE_VERSION (SHCI_C2_BLE_INIT_BLE_CORE_5_4) +#if 0 /****************************************************************************** * Transport Layer ******************************************************************************/ @@ -660,4 +692,5 @@ typedef enum #define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR -#endif /*APP_CONF_H */ +#endif +#endif /*APP_CONF_DEFAULT_H */ diff --git a/src/utility/STM32_WPAN/hw.h b/src/utility/STM32_WPAN/hw.h index 651e1f17..1472a5e8 100644 --- a/src/utility/STM32_WPAN/hw.h +++ b/src/utility/STM32_WPAN/hw.h @@ -26,14 +26,23 @@ extern "C" { #endif /* Includes ------------------------------------------------------------------*/ +#include "stm32_def.h" +#include "stm32wbxx_ll_bus.h" +#include "stm32wbxx_ll_exti.h" +#include "stm32wbxx_ll_system.h" +#include "stm32wbxx_ll_rcc.h" +#include "stm32wbxx_ll_ipcc.h" +#include "stm32wbxx_ll_cortex.h" +#include "stm32wbxx_ll_utils.h" +#include "stm32wbxx_ll_pwr.h" /****************************************************************************** * HW IPCC ******************************************************************************/ void HW_IPCC_Enable( void ); void HW_IPCC_Init( void ); - void HW_IPCC_Rx_Handler( void ); - void HW_IPCC_Tx_Handler( void ); +#define HW_IPCC_Rx_Handler IPCC_C1_RX_IRQHandler +#define HW_IPCC_Tx_Handler IPCC_C1_TX_IRQHandler void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); diff --git a/src/utility/STM32_WPAN/hw_ipcc.c b/src/utility/STM32_WPAN/hw_ipcc.c index 6a311b14..ad3c9d4c 100644 --- a/src/utility/STM32_WPAN/hw_ipcc.c +++ b/src/utility/STM32_WPAN/hw_ipcc.c @@ -18,8 +18,9 @@ */ /* USER CODE END Header */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ -#include "app_common.h" +#include "hw.h" #include "mbox_def.h" #include "utilities_conf.h" @@ -745,3 +746,4 @@ static void HW_IPCC_TRACES_EvtHandler( void ) } __weak void HW_IPCC_TRACES_EvtNot( void ){}; +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/shci.c b/src/utility/STM32_WPAN/shci.c index 5c32555e..40110f42 100644 --- a/src/utility/STM32_WPAN/shci.c +++ b/src/utility/STM32_WPAN/shci.c @@ -17,6 +17,7 @@ */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -759,3 +760,4 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/shci_tl.c b/src/utility/STM32_WPAN/shci_tl.c index 0f604300..daa988c1 100644 --- a/src/utility/STM32_WPAN/shci_tl.c +++ b/src/utility/STM32_WPAN/shci_tl.c @@ -17,11 +17,13 @@ */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "stm_list.h" #include "shci_tl.h" +#include "stm32_def.h" /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -168,6 +170,20 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl return; } +void shci_notify_asynch_evt(void *pdata) +{ + UNUSED(pdata); + /* Need to parse data in future version */ + shci_user_evt_proc(); +} + +void shci_register_io_bus(tSHciIO *fops) +{ + /* Register IO bus services */ + fops->Init = TL_SYS_Init; + fops->Send = TL_SYS_SendCmd; +} + /* Private functions ---------------------------------------------------------*/ static void TlInit( TL_CmdPacket_t * p_cmdbuffer ) { @@ -250,3 +266,4 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/stm_list.c b/src/utility/STM32_WPAN/stm_list.c index 4c928647..df6c2155 100644 --- a/src/utility/STM32_WPAN/stm_list.c +++ b/src/utility/STM32_WPAN/stm_list.c @@ -17,10 +17,13 @@ */ +#if defined(STM32WBxx) /****************************************************************************** * Include Files ******************************************************************************/ -#include "utilities_common.h" +#include "stdint.h" +#include "cmsis_gcc.h" +#include "stm32_wpan_common.h" #include "stm_list.h" @@ -204,3 +207,4 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } +#endif /* STM32WBxx */ diff --git a/src/utility/STM32_WPAN/tl_mbox.c b/src/utility/STM32_WPAN/tl_mbox.c index df07a197..9a2a2973 100644 --- a/src/utility/STM32_WPAN/tl_mbox.c +++ b/src/utility/STM32_WPAN/tl_mbox.c @@ -16,6 +16,7 @@ ****************************************************************************** */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -51,8 +52,10 @@ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleLldTable_t TL_BleLldTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_SysTable_t TL_SysTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_MemManagerTable_t TL_MemManagerTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_TracesTable_t TL_TracesTable; +#if 0 PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_Mac_802_15_4_t TL_Mac_802_15_4_Table; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ZigbeeTable_t TL_Zigbee_Table; +#endif /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; @@ -97,8 +100,10 @@ void TL_Init( void ) TL_RefTable.p_sys_table = &TL_SysTable; TL_RefTable.p_mem_manager_table = &TL_MemManagerTable; TL_RefTable.p_traces_table = &TL_TracesTable; +#if 0 TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; +#endif HW_IPCC_Init(); return; @@ -847,3 +852,4 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } +#endif /* STM32WBxx */ From 974ce4cf8389edac59c1f416e7d99e56db2d7ccb Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 13 Jul 2023 17:16:40 +0200 Subject: [PATCH 14/17] fix: include a timeout when waiting for the cmd_resp Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/shci_tl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utility/STM32_WPAN/shci_tl.c b/src/utility/STM32_WPAN/shci_tl.c index daa988c1..25e1a214 100644 --- a/src/utility/STM32_WPAN/shci_tl.c +++ b/src/utility/STM32_WPAN/shci_tl.c @@ -24,6 +24,7 @@ #include "stm_list.h" #include "shci_tl.h" #include "stm32_def.h" +#include "wiring_time.h" /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -251,10 +252,11 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { - (void)timeout; - - while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); - + for (unsigned long start = millis(); (millis() - start) < timeout;) { + if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { + break; + } + } return; } From 5a5dc8e921c7b0f7e7854f6ab257abb3be30b18a Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 10 Jan 2024 18:45:17 +0100 Subject: [PATCH 15/17] chore: add support for customize app_conf_default.h Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/app_conf_default.h | 58 ++++++++++++++++++----- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/src/utility/STM32_WPAN/app_conf_default.h b/src/utility/STM32_WPAN/app_conf_default.h index bf2274a5..ff2dc017 100644 --- a/src/utility/STM32_WPAN/app_conf_default.h +++ b/src/utility/STM32_WPAN/app_conf_default.h @@ -50,7 +50,9 @@ /** * Define Tx Power */ -#define CFG_TX_POWER (0x18) /* -0.15dBm */ +#ifndef CFG_TX_POWER + #define CFG_TX_POWER (0x18) /* -0.15dBm */ +#endif #if 0 /** @@ -135,13 +137,25 @@ * Maximum number of simultaneous connections that the device will support. * Valid values are from 1 to 8 */ -#define CFG_BLE_NUM_LINK 8 +#ifndef CFG_BLE_NUM_LINK +#ifdef STM32WB15xx + #define CFG_BLE_NUM_LINK 3 +#else + #define CFG_BLE_NUM_LINK 8 +#endif +#endif /** * Maximum number of Services that can be stored in the GATT database. * Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user services */ -#define CFG_BLE_NUM_GATT_SERVICES 8 +#ifndef CFG_BLE_NUM_GATT_SERVICES +#ifdef STM32WB15xx + #define CFG_BLE_NUM_GATT_SERVICES 4 +#else + #define CFG_BLE_NUM_GATT_SERVICES 8 +#endif +#endif /** * Maximum number of Attributes @@ -150,7 +164,13 @@ * Note that certain characteristics and relative descriptors are added automatically during device initialization * so this parameters should be 9 plus the number of user Attributes */ -#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#ifndef CFG_BLE_NUM_GATT_ATTRIBUTES +#ifdef STM32WB15xx + #define CFG_BLE_NUM_GATT_ATTRIBUTES 30 +#else + #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#endif +#endif /** * Maximum supported ATT_MTU size @@ -186,12 +206,16 @@ /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. */ -#define CFG_BLE_DATA_LENGTH_EXTENSION 1 +#ifndef CFG_BLE_DATA_LENGTH_EXTENSION + #define CFG_BLE_DATA_LENGTH_EXTENSION 1 +#endif /** * Sleep clock accuracy in Peripheral mode (ppm value) */ -#define CFG_BLE_PERIPHERAL_SCA 500 +#ifndef CFG_BLE_PERIPHERAL_SCA + #define CFG_BLE_PERIPHERAL_SCA 500 +#endif /** * Sleep clock accuracy in Central mode @@ -204,7 +228,9 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#define CFG_BLE_CENTRAL_SCA 0 +#ifndef CFG_BLE_CENTRAL_SCA + #define CFG_BLE_CENTRAL_SCA 0 +#endif /** * LsSource @@ -213,21 +239,27 @@ * - bit 1: 1: STM32WB5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module * - bit 2: 1: HSE/1024 Clock config 0: LSE Clock config */ -#if defined(STM32WB5Mxx) - #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) -#else - #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) +#ifndef CFG_BLE_LS_SOURCE + #if defined(STM32WB5Mxx) + #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) + #else + #define CFG_BLE_LS_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV | SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE) + #endif #endif /** * Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us) */ -#define CFG_BLE_HSE_STARTUP_TIME 0x148 +#ifndef CFG_BLE_HSE_STARTUP_TIME + #define CFG_BLE_HSE_STARTUP_TIME 0x148 +#endif /** * Maximum duration of the connection event when the device is in Peripheral mode in units of 625/256 us (~2.44 us) */ -#define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) +#ifndef CFG_BLE_MAX_CONN_EVENT_LENGTH + #define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) +#endif /** * Viterbi Mode From 6f7c381684aaa14b3241280beedd106732dcd0ab Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 24 Jul 2023 10:55:20 +0200 Subject: [PATCH 16/17] fix: TL_Evt_t payload size for reset Within STM32CubeWB v1.17.0 update TL_Evt_t payload size was reduced. This produce a warning -Warray-bounds due to the reset management which require 4 bytes. Signed-off-by: Frederic Pillon --- src/utility/STM32_WPAN/tl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/STM32_WPAN/tl.h b/src/utility/STM32_WPAN/tl.h index 8e8c6cbc..74520878 100644 --- a/src/utility/STM32_WPAN/tl.h +++ b/src/utility/STM32_WPAN/tl.h @@ -108,7 +108,7 @@ typedef PACKED_STRUCT { uint8_t evtcode; uint8_t plen; - uint8_t payload[2]; + uint8_t payload[4]; } TL_Evt_t; typedef PACKED_STRUCT From 13b3a1a7de1a7b694b02084e450b5fe18a2f12d2 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 5 Mar 2025 10:12:19 +0100 Subject: [PATCH 17/17] chore: update library.properties Signed-off-by: Frederic Pillon --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 6f0833c7..630fdc92 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=STM32duinoBLE -version=1.2.8 +version=1.2.9 author=Arduino, SRA maintainer=stm32duino sentence=Fork of ArduinoBLE library to add the support of STM32WB, SPBTLE-RF, SPBTLE-1S, BLUENRG-M2SP and BLUENRG-M0 BLE modules.