From 1cf1da0d5fbd1b43626249c430c69c92b8de3be5 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 5 Oct 2021 16:04:46 +0200 Subject: [PATCH 01/58] ci: change to main branch Signed-off-by: Frederic Pillon --- .github/workflows/compile-examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 4efa2d9d..da41142d 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -22,5 +22,5 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} fqbn: ${{ matrix.fqbn }} platforms: | - - source-url: https://github.com/stm32duino/BoardManagerFiles/raw/master/package_stmicroelectronics_index.json + - source-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json name: STMicroelectronics:stm32 From 095fe1802f363865f631133e0f2c01fa3f9325a8 Mon Sep 17 00:00:00 2001 From: KMeldgaard <36625114+KMeldgaard@users.noreply.github.com> Date: Mon, 15 Nov 2021 14:54:07 +0100 Subject: [PATCH 02/58] Added support for custom app_conf.h (#35) --- README.md | 5 + src/utility/STM32Cube_FW/app_conf.h | 162 ++--------------- src/utility/STM32Cube_FW/app_conf_default.h | 185 ++++++++++++++++++++ 3 files changed, 202 insertions(+), 150 deletions(-) create mode 100644 src/utility/STM32Cube_FW/app_conf_default.h diff --git a/README.md b/README.md index 2fb6e425..b2d48b13 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,11 @@ https://github.com/stm32duino/wiki/wiki/STM32duinoBLE#stm32duinoble-with-x-nucle For more information about ArduinoBLE library please visit the official web page at: https://github.com/arduino-libraries/ArduinoBLE +# Configuration +STM32Cube_WPAN has several configuration options, which are set in the `app_conf.h`. +This package has a default configuration named `app_conf_default.h`. +The user can include the file `app_conf_custom.h` to customize the ble application. Options wrapped in `#ifndef, #endif` in `app_conf_default.h` can be overwritten. Additional options can be added. + ## License ``` diff --git a/src/utility/STM32Cube_FW/app_conf.h b/src/utility/STM32Cube_FW/app_conf.h index 667dbbd4..888c91a0 100644 --- a/src/utility/STM32Cube_FW/app_conf.h +++ b/src/utility/STM32Cube_FW/app_conf.h @@ -1,158 +1,20 @@ -/** - ****************************************************************************** - * File Name : app_conf.h - * Description : Application configuration file for STM32WPAN Middleware. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ +//----------------------------- +// @file app_conf.h +// @author Kasper Meldgaard +// @brief Wrapper for BLE app configuration based on comment by fpistm +// (https://github.com/stm32duino/STM32duinoBLE/issues/34). +// @date 15-11-2021 +// @copyright Copyright (c) 2021 -/* Define to prevent recursive inclusion -------------------------------------*/ #ifndef APP_CONF_H #define APP_CONF_H -#include "hw.h" #include "ble_bufsize.h" +#include "hw.h" - -/****************************************************************************** - * 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 +#if __has_include("app_conf_custom.h") +#include "app_conf_custom.h" #endif -#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 - -/** - * Define Tx Power - */ -#define CFG_TX_POWER (0x18) /* -0.15dBm */ - -/****************************************************************************** - * BLE Stack - ******************************************************************************/ -/** - * Maximum number of simultaneous connections that the device will support. - * Valid values are from 1 to 8 - */ -#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 - */ -#define CFG_BLE_NUM_GATT_SERVICES 8 - -/** - * Maximum number of Attributes - * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) - * that can be stored in the GATT database. - * 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 - -/** - * Maximum supported ATT_MTU size - */ -#define CFG_BLE_MAX_ATT_MTU (156) - -/** - * Size of the storage area for Attribute values - * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: - * - attribute value length - * - 5, if UUID is 16 bit; 19, if UUID is 128 bit - * - 2, if server configuration descriptor is used - * - 2*DTM_NUM_LINK, if client configuration descriptor is used - * - 2, if extended properties is used - * The total amount of memory needed is the sum of the above quantities for each attribute. - */ -#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) - -/** - * Prepare Write List size in terms of number of packet - */ -//#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) - -/** - * Number of allocated memory blocks - */ -//#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) -#define CFG_BLE_MBLOCK_COUNT (0x79) -/** - * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. - */ -#define CFG_BLE_DATA_LENGTH_EXTENSION 1 - -/** - * Sleep clock accuracy in Slave mode (ppm value) - */ -#define CFG_BLE_SLAVE_SCA 500 - -/** - * Sleep clock accuracy in Master mode - * 0 : 251 ppm to 500 ppm - * 1 : 151 ppm to 250 ppm - * 2 : 101 ppm to 150 ppm - * 3 : 76 ppm to 100 ppm - * 4 : 51 ppm to 75 ppm - * 5 : 31 ppm to 50 ppm - * 6 : 21 ppm to 30 ppm - * 7 : 0 ppm to 20 ppm - */ -#define CFG_BLE_MASTER_SCA 0 - -/** - * Source for the 32 kHz slow speed clock - * 1 : internal RO - * 0 : external crystal ( no calibration ) - */ -#define CFG_BLE_LSE_SOURCE 0 - -/** - * 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 - -/** - * Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us) - */ -#define CFG_BLE_MAX_CONN_EVENT_LENGTH ( 0xFFFFFFFF ) - -/** - * Viterbi Mode - * 1 : enabled - * 0 : disabled - */ -#define CFG_BLE_VITERBI_MODE 1 - -/** - * LL Only Mode - * 1 : LL Only - * 0 : LL + Host - */ -#define CFG_BLE_LL_ONLY 1 - -#endif /* APP_CONF_H */ +#include "app_conf_default.h" -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +#endif /* APP_CONF_H */ \ No newline at end of file diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h new file mode 100644 index 00000000..58c9f5bb --- /dev/null +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -0,0 +1,185 @@ +/** + ****************************************************************************** + * File Name : app_conf_default.h + * Description : Default application configuration file for STM32WPAN Middleware. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef APP_CONF_DEFAULT_H +#define APP_CONF_DEFAULT_H + +/****************************************************************************** + * 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 + +/****************************************************************************** + * BLE Stack + ******************************************************************************/ +/** + * Maximum number of simultaneous connections that the device will support. + * Valid values are from 1 to 8 + */ +#ifndef CFG_BLE_NUM_LINK +#define CFG_BLE_NUM_LINK 8 +#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 + */ +#ifndef CFG_BLE_NUM_GATT_SERVICES +#define CFG_BLE_NUM_GATT_SERVICES 8 +#endif + +/** + * Maximum number of Attributes + * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the + * services) that can be stored in the GATT database. 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 +#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#endif + +/** + * Maximum supported ATT_MTU size + */ +#ifndef CFG_BLE_MAX_ATT_MTU +#define CFG_BLE_MAX_ATT_MTU (156) +#endif + +/** + * Size of the storage area for Attribute values + * This value depends on the number of attributes used by application. In particular the sum of the following + * quantities (in octets) should be made for each attribute: + * - attribute value length + * - 5, if UUID is 16 bit; 19, if UUID is 128 bit + * - 2, if server configuration descriptor is used + * - 2*DTM_NUM_LINK, if client configuration descriptor is used + * - 2, if extended properties is used + * The total amount of memory needed is the sum of the above quantities for each attribute. + */ +#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE +#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) +#endif + +/** + * Prepare Write List size in terms of number of packet + */ +//#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE +#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) +#endif + +/** + * Number of allocated memory blocks + */ +//#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, +// CFG_BLE_NUM_LINK)) +#ifndef CFG_BLE_MBLOCK_COUNT +#define CFG_BLE_MBLOCK_COUNT (0x79) +#endif + +/** + * 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 + +/** + * Sleep clock accuracy in Slave mode (ppm value) + */ +#ifndef CFG_BLE_SLAVE_SCA +#define CFG_BLE_SLAVE_SCA 500 +#endif + +/** + * Sleep clock accuracy in Master mode + * 0 : 251 ppm to 500 ppm + * 1 : 151 ppm to 250 ppm + * 2 : 101 ppm to 150 ppm + * 3 : 76 ppm to 100 ppm + * 4 : 51 ppm to 75 ppm + * 5 : 31 ppm to 50 ppm + * 6 : 21 ppm to 30 ppm + * 7 : 0 ppm to 20 ppm + */ +#ifndef CFG_BLE_MASTER_SCA +#define CFG_BLE_MASTER_SCA 0 +#endif + +/** + * Source for the 32 kHz slow speed clock + * 1 : internal RO + * 0 : external crystal ( no calibration ) + */ +#ifndef CFG_BLE_LSE_SOURCE +#define CFG_BLE_LSE_SOURCE 0 +#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 + +/** + * Maximum duration of the connection event when the device is in Slave 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 + +/** + * Viterbi Mode + * 1 : enabled + * 0 : disabled + */ +#define CFG_BLE_VITERBI_MODE 1 + +/** + * LL Only Mode + * 1 : LL Only + * 0 : LL + Host + */ +#define CFG_BLE_LL_ONLY 1 + +#endif /* APP_CONF_DEFAULT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From 6a6c5505cfe72d11d42979324ff4f98aef4c6af0 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 1 Dec 2021 10:21:53 +0100 Subject: [PATCH 03/58] Revert "Added support for custom app_conf.h (#35)" This reverts commit 095fe1802f363865f631133e0f2c01fa3f9325a8. --- README.md | 5 - src/utility/STM32Cube_FW/app_conf.h | 162 +++++++++++++++-- src/utility/STM32Cube_FW/app_conf_default.h | 185 -------------------- 3 files changed, 150 insertions(+), 202 deletions(-) delete mode 100644 src/utility/STM32Cube_FW/app_conf_default.h diff --git a/README.md b/README.md index b2d48b13..2fb6e425 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,6 @@ https://github.com/stm32duino/wiki/wiki/STM32duinoBLE#stm32duinoble-with-x-nucle For more information about ArduinoBLE library please visit the official web page at: https://github.com/arduino-libraries/ArduinoBLE -# Configuration -STM32Cube_WPAN has several configuration options, which are set in the `app_conf.h`. -This package has a default configuration named `app_conf_default.h`. -The user can include the file `app_conf_custom.h` to customize the ble application. Options wrapped in `#ifndef, #endif` in `app_conf_default.h` can be overwritten. Additional options can be added. - ## License ``` diff --git a/src/utility/STM32Cube_FW/app_conf.h b/src/utility/STM32Cube_FW/app_conf.h index 888c91a0..667dbbd4 100644 --- a/src/utility/STM32Cube_FW/app_conf.h +++ b/src/utility/STM32Cube_FW/app_conf.h @@ -1,20 +1,158 @@ -//----------------------------- -// @file app_conf.h -// @author Kasper Meldgaard -// @brief Wrapper for BLE app configuration based on comment by fpistm -// (https://github.com/stm32duino/STM32duinoBLE/issues/34). -// @date 15-11-2021 -// @copyright Copyright (c) 2021 +/** + ****************************************************************************** + * File Name : app_conf.h + * Description : Application configuration file for STM32WPAN Middleware. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* Define to prevent recursive inclusion -------------------------------------*/ #ifndef APP_CONF_H #define APP_CONF_H -#include "ble_bufsize.h" #include "hw.h" +#include "ble_bufsize.h" + + +/****************************************************************************** + * 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 -#if __has_include("app_conf_custom.h") -#include "app_conf_custom.h" +#ifndef BLE_SHARED_MEM_BYTE_ORDER + #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST #endif -#include "app_conf_default.h" +#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 + +/** + * Define Tx Power + */ +#define CFG_TX_POWER (0x18) /* -0.15dBm */ + +/****************************************************************************** + * BLE Stack + ******************************************************************************/ +/** + * Maximum number of simultaneous connections that the device will support. + * Valid values are from 1 to 8 + */ +#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 + */ +#define CFG_BLE_NUM_GATT_SERVICES 8 + +/** + * Maximum number of Attributes + * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) + * that can be stored in the GATT database. + * 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 + +/** + * Maximum supported ATT_MTU size + */ +#define CFG_BLE_MAX_ATT_MTU (156) + +/** + * Size of the storage area for Attribute values + * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: + * - attribute value length + * - 5, if UUID is 16 bit; 19, if UUID is 128 bit + * - 2, if server configuration descriptor is used + * - 2*DTM_NUM_LINK, if client configuration descriptor is used + * - 2, if extended properties is used + * The total amount of memory needed is the sum of the above quantities for each attribute. + */ +#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) + +/** + * Prepare Write List size in terms of number of packet + */ +//#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) + +/** + * Number of allocated memory blocks + */ +//#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) +#define CFG_BLE_MBLOCK_COUNT (0x79) +/** + * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. + */ +#define CFG_BLE_DATA_LENGTH_EXTENSION 1 + +/** + * Sleep clock accuracy in Slave mode (ppm value) + */ +#define CFG_BLE_SLAVE_SCA 500 + +/** + * Sleep clock accuracy in Master mode + * 0 : 251 ppm to 500 ppm + * 1 : 151 ppm to 250 ppm + * 2 : 101 ppm to 150 ppm + * 3 : 76 ppm to 100 ppm + * 4 : 51 ppm to 75 ppm + * 5 : 31 ppm to 50 ppm + * 6 : 21 ppm to 30 ppm + * 7 : 0 ppm to 20 ppm + */ +#define CFG_BLE_MASTER_SCA 0 + +/** + * Source for the 32 kHz slow speed clock + * 1 : internal RO + * 0 : external crystal ( no calibration ) + */ +#define CFG_BLE_LSE_SOURCE 0 + +/** + * 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 + +/** + * Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us) + */ +#define CFG_BLE_MAX_CONN_EVENT_LENGTH ( 0xFFFFFFFF ) + +/** + * Viterbi Mode + * 1 : enabled + * 0 : disabled + */ +#define CFG_BLE_VITERBI_MODE 1 + +/** + * LL Only Mode + * 1 : LL Only + * 0 : LL + Host + */ +#define CFG_BLE_LL_ONLY 1 + +#endif /* APP_CONF_H */ -#endif /* APP_CONF_H */ \ No newline at end of file +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h deleted file mode 100644 index 58c9f5bb..00000000 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ /dev/null @@ -1,185 +0,0 @@ -/** - ****************************************************************************** - * File Name : app_conf_default.h - * Description : Default application configuration file for STM32WPAN Middleware. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef APP_CONF_DEFAULT_H -#define APP_CONF_DEFAULT_H - -/****************************************************************************** - * 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 - -/****************************************************************************** - * BLE Stack - ******************************************************************************/ -/** - * Maximum number of simultaneous connections that the device will support. - * Valid values are from 1 to 8 - */ -#ifndef CFG_BLE_NUM_LINK -#define CFG_BLE_NUM_LINK 8 -#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 - */ -#ifndef CFG_BLE_NUM_GATT_SERVICES -#define CFG_BLE_NUM_GATT_SERVICES 8 -#endif - -/** - * Maximum number of Attributes - * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the - * services) that can be stored in the GATT database. 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 -#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 -#endif - -/** - * Maximum supported ATT_MTU size - */ -#ifndef CFG_BLE_MAX_ATT_MTU -#define CFG_BLE_MAX_ATT_MTU (156) -#endif - -/** - * Size of the storage area for Attribute values - * This value depends on the number of attributes used by application. In particular the sum of the following - * quantities (in octets) should be made for each attribute: - * - attribute value length - * - 5, if UUID is 16 bit; 19, if UUID is 128 bit - * - 2, if server configuration descriptor is used - * - 2*DTM_NUM_LINK, if client configuration descriptor is used - * - 2, if extended properties is used - * The total amount of memory needed is the sum of the above quantities for each attribute. - */ -#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE -#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) -#endif - -/** - * Prepare Write List size in terms of number of packet - */ -//#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) -#endif - -/** - * Number of allocated memory blocks - */ -//#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, -// CFG_BLE_NUM_LINK)) -#ifndef CFG_BLE_MBLOCK_COUNT -#define CFG_BLE_MBLOCK_COUNT (0x79) -#endif - -/** - * 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 - -/** - * Sleep clock accuracy in Slave mode (ppm value) - */ -#ifndef CFG_BLE_SLAVE_SCA -#define CFG_BLE_SLAVE_SCA 500 -#endif - -/** - * Sleep clock accuracy in Master mode - * 0 : 251 ppm to 500 ppm - * 1 : 151 ppm to 250 ppm - * 2 : 101 ppm to 150 ppm - * 3 : 76 ppm to 100 ppm - * 4 : 51 ppm to 75 ppm - * 5 : 31 ppm to 50 ppm - * 6 : 21 ppm to 30 ppm - * 7 : 0 ppm to 20 ppm - */ -#ifndef CFG_BLE_MASTER_SCA -#define CFG_BLE_MASTER_SCA 0 -#endif - -/** - * Source for the 32 kHz slow speed clock - * 1 : internal RO - * 0 : external crystal ( no calibration ) - */ -#ifndef CFG_BLE_LSE_SOURCE -#define CFG_BLE_LSE_SOURCE 0 -#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 - -/** - * Maximum duration of the connection event when the device is in Slave 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 - -/** - * Viterbi Mode - * 1 : enabled - * 0 : disabled - */ -#define CFG_BLE_VITERBI_MODE 1 - -/** - * LL Only Mode - * 1 : LL Only - * 0 : LL + Host - */ -#define CFG_BLE_LL_ONLY 1 - -#endif /* APP_CONF_DEFAULT_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From b64df412e90a7cd61966115560077d2479c9abd5 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 1 Dec 2021 10:22:00 +0100 Subject: [PATCH 04/58] Revert "Include a timeout when waiting for the cmd_resp" This reverts commit 3a063dff2f8d4159ced2c98e7d866973dbaf6eec. --- src/utility/STM32Cube_FW/shci_tl.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index c2d7589e..1ab15b47 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -21,8 +21,6 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" -#include - #include "stm_list.h" #include "shci_tl.h" #include "stm32_def.h" @@ -325,12 +323,11 @@ static void OutputEvtTrace(TL_EvtPacket_t *phcievtbuffer) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { + (void)timeout; + CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; - for (unsigned long start = millis(); (millis() - start) < timeout;) { - if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { - break; - } - } + while (CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); + return; } From a5260674fd145fa82d3871b7339439594ad6f9fa Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Thu, 19 Nov 2020 19:07:13 +0100 Subject: [PATCH 05/58] Revert "Fix [-Waddress-of-packed-member] warning" --- src/utility/STM32Cube_FW/stm_list.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/utility/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h index 885b50c1..b5f1cc8d 100644 --- a/src/utility/STM32Cube_FW/stm_list.h +++ b/src/utility/STM32Cube_FW/stm_list.h @@ -23,14 +23,10 @@ /* Includes ------------------------------------------------------------------*/ +#include "stdint.h" #include "stdbool.h" -#include "stm32_wpan_common.h" -#ifdef __cplusplus -extern "C" { -#endif - -typedef PACKED_STRUCT _tListNode { +typedef struct _tListNode { struct _tListNode *next; struct _tListNode *prev; } tListNode; @@ -59,8 +55,4 @@ void LST_get_next_node(tListNode *ref_node, tListNode **node); void LST_get_prev_node(tListNode *ref_node, tListNode **node); -#ifdef __cplusplus -} -#endif - #endif /* _STM_LIST_H_ */ From 643daea841c8eae8c96133a694fb8b0bd6ce0bda Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 1 Dec 2021 10:29:17 +0100 Subject: [PATCH 06/58] Revert "Missing IPCC enable for C2 in several examples from stm32CubeWB" This reverts commit 163bd85bf724a6d4f17c48ae051bd6ca1a108c3d. --- src/utility/STM32Cube_FW/hw_ipcc.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c index 925075f8..dbeb3eeb 100644 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ b/src/utility/STM32Cube_FW/hw_ipcc.c @@ -94,12 +94,6 @@ void IPCC_C1_TX_IRQHandler(void) ******************************************************************************/ void HW_IPCC_Enable(void) { - /** - * Such as IPCC IP available to the CPU2, it is required to keep the IPCC clock running - when FUS is running on CPU2 and CPU1 enters deep sleep mode - */ - LL_C2_AHB3_GRP1_EnableClock(LL_C2_AHB3_GRP1_PERIPH_IPCC); - /** * When the device is out of standby, it is required to use the EXTI mechanism to wakeup CPU2 */ From 98952728fec94cebb2db5ccbffbcefb3c5fb66ba Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 1 Dec 2021 10:38:36 +0100 Subject: [PATCH 07/58] Revert "This BLE RF configuration has many unused define values" This reverts commit 732ffed41b4b4ff32e9a8a23fd53fc0cc3867387. --- src/utility/STM32Cube_FW/app_conf.h | 403 +++++++++++++++++++++++++++- 1 file changed, 390 insertions(+), 13 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf.h b/src/utility/STM32Cube_FW/app_conf.h index 667dbbd4..22c7b5c5 100644 --- a/src/utility/STM32Cube_FW/app_conf.h +++ b/src/utility/STM32Cube_FW/app_conf.h @@ -29,24 +29,117 @@ ******************************************************************************/ /**< 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 */ +/** + * Define Advertising parameters + */ +#define CFG_ADV_BD_ADDRESS (0x7257acd87a6c) +#define CFG_FAST_CONN_ADV_INTERVAL_MIN (0x80) /**< 80ms */ +#define CFG_FAST_CONN_ADV_INTERVAL_MAX (0xa0) /**< 100ms */ +#define CFG_LP_CONN_ADV_INTERVAL_MIN (0x640) /**< 1s */ +#define CFG_LP_CONN_ADV_INTERVAL_MAX (0xfa0) /**< 2.5s */ + +/** + * Define IO Authentication + */ +#define CFG_BONDING_MODE (1) +#define CFG_FIXED_PIN (111111) +#define CFG_USED_FIXED_PIN (0) +#define CFG_ENCRYPTION_KEY_SIZE_MAX (16) +#define CFG_ENCRYPTION_KEY_SIZE_MIN (8) + +/** + * Define IO capabilities + */ +#define CFG_IO_CAPABILITY_DISPLAY_ONLY (0x00) +#define CFG_IO_CAPABILITY_DISPLAY_YES_NO (0x01) +#define CFG_IO_CAPABILITY_KEYBOARD_ONLY (0x02) +#define CFG_IO_CAPABILITY_NO_INPUT_NO_OUTPUT (0x03) +#define CFG_IO_CAPABILITY_KEYBOARD_DISPLAY (0x04) + +#define CFG_IO_CAPABILITY CFG_IO_CAPABILITY_DISPLAY_YES_NO + +/** + * Define MITM modes + */ +#define CFG_MITM_PROTECTION_NOT_REQUIRED (0x00) +#define CFG_MITM_PROTECTION_REQUIRED (0x01) + +#define CFG_MITM_PROTECTION CFG_MITM_PROTECTION_REQUIRED + +/** + * Define Secure Connections Support + */ +#define CFG_SECURE_NOT_SUPPORTED (0x00) +#define CFG_SECURE_OPTIONAL (0x01) +#define CFG_SECURE_MANDATORY (0x02) + +#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL + +/** + * Define Keypress Notification Support + */ +#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) +#define CFG_KEYPRESS_SUPPORTED (0x01) + +#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED + +/** + * Numeric Comparison Answers + */ +#define YES (0x01) +#define NO (0x00) + +/** + * Device name configuration for Generic Access Service + */ +#define CFG_GAP_DEVICE_NAME "TEMPLATE" +#define CFG_GAP_DEVICE_NAME_LENGTH (8) + +/** + * Define PHY + */ +#define ALL_PHYS_PREFERENCE 0x00 +#define RX_2M_PREFERRED 0x02 +#define TX_2M_PREFERRED 0x02 +#define TX_1M 0x01 +#define TX_2M 0x02 +#define RX_1M 0x01 +#define RX_2M 0x02 + +/** +* Identity root key used to derive LTK and CSRK +*/ +#define CFG_BLE_IRK {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0} + +/** +* Encryption root key used to derive LTK and CSRK +*/ +#define CFG_BLE_ERK {0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21,0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21} + +/* USER CODE BEGIN Generic_Parameters */ +/** + * SMPS supply + * SMPS not used when Set to 0 + * SMPS used when Set to 1 + */ +#define CFG_USE_SMPS 1 +/* USER CODE END Generic_Parameters */ + +/**< specific parameters */ +/*****************************************************/ + +/** +* AD Element - Group B Feature +*/ +/* LSB - Second Byte */ +#define CFG_FEATURE_OTA_REBOOT (0x20) + /****************************************************************************** * BLE Stack ******************************************************************************/ @@ -152,7 +245,291 @@ * 0 : LL + Host */ #define CFG_BLE_LL_ONLY 1 +/****************************************************************************** + * Transport Layer + ******************************************************************************/ +/** + * Queue length of BLE Event + * This parameter defines the number of asynchronous events that can be stored in the HCI layer before + * being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer + * is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large + * enough to store all asynchronous events received in between. + * When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events + * between the HCI command and its event. + * This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small, + * the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting + * for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate + * to the application a HCI command did not receive its command event within 30s (Default HCI Timeout). + */ +#define CFG_TLBLE_EVT_QUEUE_LENGTH 5 +/** + * This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element + * allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager. + * It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will + * never be used) + * It shall be at least 4 to receive the command status event in one frame. + * The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced + * further depending on the application. + * + */ +#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */ + +#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE ) +/****************************************************************************** + * UART interfaces + ******************************************************************************/ + +/** + * Select UART interfaces + */ +#define CFG_DEBUG_TRACE_UART hw_uart1 +#define CFG_CONSOLE_MENU 0 +/****************************************************************************** + * USB interface + ******************************************************************************/ + +/** + * Enable/Disable USB interface + */ +#define CFG_USB_INTERFACE_ENABLE 0 + +/****************************************************************************** + * Low Power + ******************************************************************************/ +/** + * When set to 1, the low power mode is enable + * When set to 0, the device stays in RUN mode + */ +#define CFG_LPM_SUPPORTED 1 + +/****************************************************************************** + * Timer Server + ******************************************************************************/ +/** + * CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer. + * The higher is the value, the better is the power consumption and the accuracy of the timerserver + * The lower is the value, the finest is the granularity + * + * CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to output + * clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding + * the wakeup timer. A lower clock speed would impact the accuracy of the timer server. + * + * CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC. + * When the 1Hz calendar clock is required, it shall be sets according to other settings + * When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE) + * + * CFG_RTCCLK_DIVIDER_CONF: + * Shall be set to either 0,2,4,8,16 + * When set to either 2,4,8,16, the 1Hhz calendar is supported + * When set to 0, the user sets its own configuration + * + * The following settings are computed with LSI as input to the RTC + */ +#define CFG_RTCCLK_DIVIDER_CONF 0 + +#if (CFG_RTCCLK_DIVIDER_CONF == 0) + /** + * Custom configuration + * It does not support 1Hz calendar + * It divides the RTC CLK by 16 + */ + #define CFG_RTCCLK_DIV (16) + #define CFG_RTC_WUCKSEL_DIVIDER (0) + #define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) + #define CFG_RTC_SYNCH_PRESCALER (0x7FFF) + +#else + + #if (CFG_RTCCLK_DIVIDER_CONF == 2) + /** + * It divides the RTC CLK by 2 + */ + #define CFG_RTC_WUCKSEL_DIVIDER (3) + #endif + + #if (CFG_RTCCLK_DIVIDER_CONF == 4) + /** + * It divides the RTC CLK by 4 + */ + #define CFG_RTC_WUCKSEL_DIVIDER (2) + #endif + + #if (CFG_RTCCLK_DIVIDER_CONF == 8) + /** + * It divides the RTC CLK by 8 + */ + #define CFG_RTC_WUCKSEL_DIVIDER (1) + #endif + + #if (CFG_RTCCLK_DIVIDER_CONF == 16) + /** + * It divides the RTC CLK by 16 + */ + #define CFG_RTC_WUCKSEL_DIVIDER (0) + #endif + + #define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF + #define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) + #define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 ) + +#endif + +/** tick timer value in us */ +#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE ) + +typedef enum { + CFG_TIM_PROC_ID_ISR, +} CFG_TimProcID_t; + +/****************************************************************************** + * Debug + ******************************************************************************/ +/** + * When set, this resets some hw resources to set the device in the same state than the power up + * The FW resets only register that may prevent the FW to run properly + * + * This shall be set to 0 in a final product + * + */ +#define CFG_HW_RESET_BY_FW 1 + +/** + * keep debugger enabled while in any low power mode when set to 1 + * should be set to 0 in production + */ +#define CFG_DEBUGGER_SUPPORTED 0 + +/** + * When set to 1, the traces are enabled in the BLE services + */ +#define CFG_DEBUG_BLE_TRACE 0 + +/** + * Enable or Disable traces in application + */ +#define CFG_DEBUG_APP_TRACE 0 + +#if (CFG_DEBUG_APP_TRACE != 0) + #define APP_DBG_MSG PRINT_MESG_DBG +#else + #define APP_DBG_MSG PRINT_NO_MESG +#endif + +#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) ) + #define CFG_DEBUG_TRACE 1 +#endif + +#if (CFG_DEBUG_TRACE != 0) + #undef CFG_LPM_SUPPORTED + #undef CFG_DEBUGGER_SUPPORTED + #define CFG_LPM_SUPPORTED 0 + #define CFG_DEBUGGER_SUPPORTED 1 +#endif + +/** + * When CFG_DEBUG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number + * When CFG_DEBUG_TRACE_LIGHT is set to 1, only the debug message is output + * + * When both are set to 0, no trace are output + * When both are set to 1, CFG_DEBUG_TRACE_FULL is selected + */ +#define CFG_DEBUG_TRACE_LIGHT 0 +#define CFG_DEBUG_TRACE_FULL 0 + +#if (( CFG_DEBUG_TRACE != 0 ) && ( CFG_DEBUG_TRACE_LIGHT == 0 ) && (CFG_DEBUG_TRACE_FULL == 0)) + #undef CFG_DEBUG_TRACE_FULL + #undef CFG_DEBUG_TRACE_LIGHT + #define CFG_DEBUG_TRACE_FULL 0 + #define CFG_DEBUG_TRACE_LIGHT 1 +#endif + +#if ( CFG_DEBUG_TRACE == 0 ) + #undef CFG_DEBUG_TRACE_FULL + #undef CFG_DEBUG_TRACE_LIGHT + #define CFG_DEBUG_TRACE_FULL 0 + #define CFG_DEBUG_TRACE_LIGHT 0 +#endif + +/** + * When not set, the traces is looping on sending the trace over UART + */ +#define DBG_TRACE_USE_CIRCULAR_QUEUE 1 + +/** + * max buffer Size to queue data traces and max data trace allowed. + * Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined + */ +#define DBG_TRACE_MSG_QUEUE_SIZE 4096 +#define MAX_DBG_TRACE_MSG_SIZE 1024 + +/* USER CODE BEGIN Defines */ +#define CFG_LED_SUPPORTED 0 +#define CFG_BUTTON_SUPPORTED 1 +/* USER CODE END Defines */ + +/****************************************************************************** + * FreeRTOS + ******************************************************************************/ +#define CFG_SHCI_USER_EVT_PROCESS_NAME "SHCI_USER_EVT_PROCESS" +#define CFG_SHCI_USER_EVT_PROCESS_ATTR_BITS (0) +#define CFG_SHCI_USER_EVT_PROCESS_CB_MEM (0) +#define CFG_SHCI_USER_EVT_PROCESS_CB_SIZE (0) +#define CFG_SHCI_USER_EVT_PROCESS_STACK_MEM (0) +#define CFG_SHCI_USER_EVT_PROCESS_PRIORITY osPriorityNone +#define CFG_SHCI_USER_EVT_PROCESS_STACK_SIZE (128 * 7) + +#define CFG_HCI_USER_EVT_PROCESS_NAME "HCI_USER_EVT_PROCESS" +#define CFG_HCI_USER_EVT_PROCESS_ATTR_BITS (0) +#define CFG_HCI_USER_EVT_PROCESS_CB_MEM (0) +#define CFG_HCI_USER_EVT_PROCESS_CB_SIZE (0) +#define CFG_HCI_USER_EVT_PROCESS_STACK_MEM (0) +#define CFG_HCI_USER_EVT_PROCESS_PRIORITY osPriorityNone +#define CFG_HCI_USER_EVT_PROCESS_STACK_SIZE (128 * 8) + +#define CFG_ADV_UPDATE_PROCESS_NAME "ADV_UPDATE_PROCESS" +#define CFG_ADV_UPDATE_PROCESS_ATTR_BITS (0) +#define CFG_ADV_UPDATE_PROCESS_CB_MEM (0) +#define CFG_ADV_UPDATE_PROCESS_CB_SIZE (0) +#define CFG_ADV_UPDATE_PROCESS_STACK_MEM (0) +#define CFG_ADV_UPDATE_PROCESS_PRIORITY osPriorityNone +#define CFG_ADV_UPDATE_PROCESS_STACK_SIZE (128 * 6) + +#define CFG_HRS_PROCESS_NAME "HRS_PROCESS" +#define CFG_HRS_PROCESS_ATTR_BITS (0) +#define CFG_HRS_PROCESS_CB_MEM (0) +#define CFG_HRS_PROCESS_CB_SIZE (0) +#define CFG_HRS_PROCESS_STACK_MEM (0) +#define CFG_HRS_PROCESS_PRIORITY osPriorityNone +#define CFG_HRS_PROCESS_STACK_SIZE (128 * 5) + +/* USER CODE BEGIN FreeRTOS_Defines */ +#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler +#define PUSH_BUTTON_SW2_EXTI_IRQHandler EXTI0_IRQHandler +#define PUSH_BUTTON_SW3_EXTI_IRQHandler EXTI1_IRQHandler +/* USER CODE END FreeRTOS_Defines */ + +/****************************************************************************** + * LOW POWER + ******************************************************************************/ +/** + * Supported requester to the MCU Low Power Manager - can be increased up to 32 + * It lists a bit mapping of all user of the Low Power Manager + */ +typedef enum { + CFG_LPM_APP, + CFG_LPM_APP_BLE, + /* USER CODE BEGIN CFG_LPM_Id_t */ + + /* USER CODE END CFG_LPM_Id_t */ +} CFG_LPM_Id_t; + +/****************************************************************************** + * OTP manager + ******************************************************************************/ +#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE + +#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR -#endif /* APP_CONF_H */ +#endif /*APP_CONF_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From ce7cb45b33e9590d3bdf6268dbda3d60cb2a8e06 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 1 Dec 2021 10:38:58 +0100 Subject: [PATCH 08/58] Revert "Include the STM32Cube_FW to support the BLE of the stm32wb55" This reverts commit 3019930966782e57d119e62b64248b0fee36d20f. --- src/utility/STM32Cube_FW/app_conf.h | 535 ----------- src/utility/STM32Cube_FW/ble_bufsize.h | 161 ---- src/utility/STM32Cube_FW/hw.h | 97 -- src/utility/STM32Cube_FW/hw_ipcc.c | 342 ------- src/utility/STM32Cube_FW/mbox_def.h | 212 ----- src/utility/STM32Cube_FW/shci.c | 567 ------------ src/utility/STM32Cube_FW/shci.h | 888 ------------------- src/utility/STM32Cube_FW/shci_tl.c | 344 ------- src/utility/STM32Cube_FW/shci_tl.h | 169 ---- src/utility/STM32Cube_FW/stm32_wpan_common.h | 143 --- src/utility/STM32Cube_FW/stm_list.c | 206 ----- src/utility/STM32Cube_FW/stm_list.h | 58 -- src/utility/STM32Cube_FW/tl.h | 294 ------ src/utility/STM32Cube_FW/tl_mbox.c | 545 ------------ 14 files changed, 4561 deletions(-) delete mode 100644 src/utility/STM32Cube_FW/app_conf.h delete mode 100644 src/utility/STM32Cube_FW/ble_bufsize.h delete mode 100644 src/utility/STM32Cube_FW/hw.h delete mode 100644 src/utility/STM32Cube_FW/hw_ipcc.c delete mode 100644 src/utility/STM32Cube_FW/mbox_def.h delete mode 100644 src/utility/STM32Cube_FW/shci.c delete mode 100644 src/utility/STM32Cube_FW/shci.h delete mode 100644 src/utility/STM32Cube_FW/shci_tl.c delete mode 100644 src/utility/STM32Cube_FW/shci_tl.h delete mode 100644 src/utility/STM32Cube_FW/stm32_wpan_common.h delete mode 100644 src/utility/STM32Cube_FW/stm_list.c delete mode 100644 src/utility/STM32Cube_FW/stm_list.h delete mode 100644 src/utility/STM32Cube_FW/tl.h delete mode 100644 src/utility/STM32Cube_FW/tl_mbox.c diff --git a/src/utility/STM32Cube_FW/app_conf.h b/src/utility/STM32Cube_FW/app_conf.h deleted file mode 100644 index 22c7b5c5..00000000 --- a/src/utility/STM32Cube_FW/app_conf.h +++ /dev/null @@ -1,535 +0,0 @@ -/** - ****************************************************************************** - * File Name : app_conf.h - * Description : Application configuration file for STM32WPAN Middleware. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef APP_CONF_H -#define APP_CONF_H - -#include "hw.h" -#include "ble_bufsize.h" - - -/****************************************************************************** - * Application Config - ******************************************************************************/ - -/**< generic parameters ******************************************************/ - -/** - * Define Tx Power - */ -#define CFG_TX_POWER (0x18) /* -0.15dBm */ - -/** - * Define Advertising parameters - */ -#define CFG_ADV_BD_ADDRESS (0x7257acd87a6c) -#define CFG_FAST_CONN_ADV_INTERVAL_MIN (0x80) /**< 80ms */ -#define CFG_FAST_CONN_ADV_INTERVAL_MAX (0xa0) /**< 100ms */ -#define CFG_LP_CONN_ADV_INTERVAL_MIN (0x640) /**< 1s */ -#define CFG_LP_CONN_ADV_INTERVAL_MAX (0xfa0) /**< 2.5s */ - -/** - * Define IO Authentication - */ -#define CFG_BONDING_MODE (1) -#define CFG_FIXED_PIN (111111) -#define CFG_USED_FIXED_PIN (0) -#define CFG_ENCRYPTION_KEY_SIZE_MAX (16) -#define CFG_ENCRYPTION_KEY_SIZE_MIN (8) - -/** - * Define IO capabilities - */ -#define CFG_IO_CAPABILITY_DISPLAY_ONLY (0x00) -#define CFG_IO_CAPABILITY_DISPLAY_YES_NO (0x01) -#define CFG_IO_CAPABILITY_KEYBOARD_ONLY (0x02) -#define CFG_IO_CAPABILITY_NO_INPUT_NO_OUTPUT (0x03) -#define CFG_IO_CAPABILITY_KEYBOARD_DISPLAY (0x04) - -#define CFG_IO_CAPABILITY CFG_IO_CAPABILITY_DISPLAY_YES_NO - -/** - * Define MITM modes - */ -#define CFG_MITM_PROTECTION_NOT_REQUIRED (0x00) -#define CFG_MITM_PROTECTION_REQUIRED (0x01) - -#define CFG_MITM_PROTECTION CFG_MITM_PROTECTION_REQUIRED - -/** - * Define Secure Connections Support - */ -#define CFG_SECURE_NOT_SUPPORTED (0x00) -#define CFG_SECURE_OPTIONAL (0x01) -#define CFG_SECURE_MANDATORY (0x02) - -#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL - -/** - * Define Keypress Notification Support - */ -#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) -#define CFG_KEYPRESS_SUPPORTED (0x01) - -#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED - -/** - * Numeric Comparison Answers - */ -#define YES (0x01) -#define NO (0x00) - -/** - * Device name configuration for Generic Access Service - */ -#define CFG_GAP_DEVICE_NAME "TEMPLATE" -#define CFG_GAP_DEVICE_NAME_LENGTH (8) - -/** - * Define PHY - */ -#define ALL_PHYS_PREFERENCE 0x00 -#define RX_2M_PREFERRED 0x02 -#define TX_2M_PREFERRED 0x02 -#define TX_1M 0x01 -#define TX_2M 0x02 -#define RX_1M 0x01 -#define RX_2M 0x02 - -/** -* Identity root key used to derive LTK and CSRK -*/ -#define CFG_BLE_IRK {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0} - -/** -* Encryption root key used to derive LTK and CSRK -*/ -#define CFG_BLE_ERK {0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21,0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21} - -/* USER CODE BEGIN Generic_Parameters */ -/** - * SMPS supply - * SMPS not used when Set to 0 - * SMPS used when Set to 1 - */ -#define CFG_USE_SMPS 1 -/* USER CODE END Generic_Parameters */ - -/**< specific parameters */ -/*****************************************************/ - -/** -* AD Element - Group B Feature -*/ -/* LSB - Second Byte */ -#define CFG_FEATURE_OTA_REBOOT (0x20) - -/****************************************************************************** - * BLE Stack - ******************************************************************************/ -/** - * Maximum number of simultaneous connections that the device will support. - * Valid values are from 1 to 8 - */ -#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 - */ -#define CFG_BLE_NUM_GATT_SERVICES 8 - -/** - * Maximum number of Attributes - * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) - * that can be stored in the GATT database. - * 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 - -/** - * Maximum supported ATT_MTU size - */ -#define CFG_BLE_MAX_ATT_MTU (156) - -/** - * Size of the storage area for Attribute values - * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: - * - attribute value length - * - 5, if UUID is 16 bit; 19, if UUID is 128 bit - * - 2, if server configuration descriptor is used - * - 2*DTM_NUM_LINK, if client configuration descriptor is used - * - 2, if extended properties is used - * The total amount of memory needed is the sum of the above quantities for each attribute. - */ -#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) - -/** - * Prepare Write List size in terms of number of packet - */ -//#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) - -/** - * Number of allocated memory blocks - */ -//#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) -#define CFG_BLE_MBLOCK_COUNT (0x79) -/** - * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. - */ -#define CFG_BLE_DATA_LENGTH_EXTENSION 1 - -/** - * Sleep clock accuracy in Slave mode (ppm value) - */ -#define CFG_BLE_SLAVE_SCA 500 - -/** - * Sleep clock accuracy in Master mode - * 0 : 251 ppm to 500 ppm - * 1 : 151 ppm to 250 ppm - * 2 : 101 ppm to 150 ppm - * 3 : 76 ppm to 100 ppm - * 4 : 51 ppm to 75 ppm - * 5 : 31 ppm to 50 ppm - * 6 : 21 ppm to 30 ppm - * 7 : 0 ppm to 20 ppm - */ -#define CFG_BLE_MASTER_SCA 0 - -/** - * Source for the 32 kHz slow speed clock - * 1 : internal RO - * 0 : external crystal ( no calibration ) - */ -#define CFG_BLE_LSE_SOURCE 0 - -/** - * 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 - -/** - * Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us) - */ -#define CFG_BLE_MAX_CONN_EVENT_LENGTH ( 0xFFFFFFFF ) - -/** - * Viterbi Mode - * 1 : enabled - * 0 : disabled - */ -#define CFG_BLE_VITERBI_MODE 1 - -/** - * LL Only Mode - * 1 : LL Only - * 0 : LL + Host - */ -#define CFG_BLE_LL_ONLY 1 -/****************************************************************************** - * Transport Layer - ******************************************************************************/ -/** - * Queue length of BLE Event - * This parameter defines the number of asynchronous events that can be stored in the HCI layer before - * being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer - * is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large - * enough to store all asynchronous events received in between. - * When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events - * between the HCI command and its event. - * This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small, - * the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting - * for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate - * to the application a HCI command did not receive its command event within 30s (Default HCI Timeout). - */ -#define CFG_TLBLE_EVT_QUEUE_LENGTH 5 -/** - * This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element - * allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager. - * It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will - * never be used) - * It shall be at least 4 to receive the command status event in one frame. - * The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced - * further depending on the application. - * - */ -#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */ - -#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE ) -/****************************************************************************** - * UART interfaces - ******************************************************************************/ - -/** - * Select UART interfaces - */ -#define CFG_DEBUG_TRACE_UART hw_uart1 -#define CFG_CONSOLE_MENU 0 -/****************************************************************************** - * USB interface - ******************************************************************************/ - -/** - * Enable/Disable USB interface - */ -#define CFG_USB_INTERFACE_ENABLE 0 - -/****************************************************************************** - * Low Power - ******************************************************************************/ -/** - * When set to 1, the low power mode is enable - * When set to 0, the device stays in RUN mode - */ -#define CFG_LPM_SUPPORTED 1 - -/****************************************************************************** - * Timer Server - ******************************************************************************/ -/** - * CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer. - * The higher is the value, the better is the power consumption and the accuracy of the timerserver - * The lower is the value, the finest is the granularity - * - * CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to output - * clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding - * the wakeup timer. A lower clock speed would impact the accuracy of the timer server. - * - * CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC. - * When the 1Hz calendar clock is required, it shall be sets according to other settings - * When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE) - * - * CFG_RTCCLK_DIVIDER_CONF: - * Shall be set to either 0,2,4,8,16 - * When set to either 2,4,8,16, the 1Hhz calendar is supported - * When set to 0, the user sets its own configuration - * - * The following settings are computed with LSI as input to the RTC - */ -#define CFG_RTCCLK_DIVIDER_CONF 0 - -#if (CFG_RTCCLK_DIVIDER_CONF == 0) - /** - * Custom configuration - * It does not support 1Hz calendar - * It divides the RTC CLK by 16 - */ - #define CFG_RTCCLK_DIV (16) - #define CFG_RTC_WUCKSEL_DIVIDER (0) - #define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) - #define CFG_RTC_SYNCH_PRESCALER (0x7FFF) - -#else - - #if (CFG_RTCCLK_DIVIDER_CONF == 2) - /** - * It divides the RTC CLK by 2 - */ - #define CFG_RTC_WUCKSEL_DIVIDER (3) - #endif - - #if (CFG_RTCCLK_DIVIDER_CONF == 4) - /** - * It divides the RTC CLK by 4 - */ - #define CFG_RTC_WUCKSEL_DIVIDER (2) - #endif - - #if (CFG_RTCCLK_DIVIDER_CONF == 8) - /** - * It divides the RTC CLK by 8 - */ - #define CFG_RTC_WUCKSEL_DIVIDER (1) - #endif - - #if (CFG_RTCCLK_DIVIDER_CONF == 16) - /** - * It divides the RTC CLK by 16 - */ - #define CFG_RTC_WUCKSEL_DIVIDER (0) - #endif - - #define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF - #define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) - #define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 ) - -#endif - -/** tick timer value in us */ -#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE ) - -typedef enum { - CFG_TIM_PROC_ID_ISR, -} CFG_TimProcID_t; - -/****************************************************************************** - * Debug - ******************************************************************************/ -/** - * When set, this resets some hw resources to set the device in the same state than the power up - * The FW resets only register that may prevent the FW to run properly - * - * This shall be set to 0 in a final product - * - */ -#define CFG_HW_RESET_BY_FW 1 - -/** - * keep debugger enabled while in any low power mode when set to 1 - * should be set to 0 in production - */ -#define CFG_DEBUGGER_SUPPORTED 0 - -/** - * When set to 1, the traces are enabled in the BLE services - */ -#define CFG_DEBUG_BLE_TRACE 0 - -/** - * Enable or Disable traces in application - */ -#define CFG_DEBUG_APP_TRACE 0 - -#if (CFG_DEBUG_APP_TRACE != 0) - #define APP_DBG_MSG PRINT_MESG_DBG -#else - #define APP_DBG_MSG PRINT_NO_MESG -#endif - -#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) ) - #define CFG_DEBUG_TRACE 1 -#endif - -#if (CFG_DEBUG_TRACE != 0) - #undef CFG_LPM_SUPPORTED - #undef CFG_DEBUGGER_SUPPORTED - #define CFG_LPM_SUPPORTED 0 - #define CFG_DEBUGGER_SUPPORTED 1 -#endif - -/** - * When CFG_DEBUG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number - * When CFG_DEBUG_TRACE_LIGHT is set to 1, only the debug message is output - * - * When both are set to 0, no trace are output - * When both are set to 1, CFG_DEBUG_TRACE_FULL is selected - */ -#define CFG_DEBUG_TRACE_LIGHT 0 -#define CFG_DEBUG_TRACE_FULL 0 - -#if (( CFG_DEBUG_TRACE != 0 ) && ( CFG_DEBUG_TRACE_LIGHT == 0 ) && (CFG_DEBUG_TRACE_FULL == 0)) - #undef CFG_DEBUG_TRACE_FULL - #undef CFG_DEBUG_TRACE_LIGHT - #define CFG_DEBUG_TRACE_FULL 0 - #define CFG_DEBUG_TRACE_LIGHT 1 -#endif - -#if ( CFG_DEBUG_TRACE == 0 ) - #undef CFG_DEBUG_TRACE_FULL - #undef CFG_DEBUG_TRACE_LIGHT - #define CFG_DEBUG_TRACE_FULL 0 - #define CFG_DEBUG_TRACE_LIGHT 0 -#endif - -/** - * When not set, the traces is looping on sending the trace over UART - */ -#define DBG_TRACE_USE_CIRCULAR_QUEUE 1 - -/** - * max buffer Size to queue data traces and max data trace allowed. - * Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined - */ -#define DBG_TRACE_MSG_QUEUE_SIZE 4096 -#define MAX_DBG_TRACE_MSG_SIZE 1024 - -/* USER CODE BEGIN Defines */ -#define CFG_LED_SUPPORTED 0 -#define CFG_BUTTON_SUPPORTED 1 -/* USER CODE END Defines */ - -/****************************************************************************** - * FreeRTOS - ******************************************************************************/ -#define CFG_SHCI_USER_EVT_PROCESS_NAME "SHCI_USER_EVT_PROCESS" -#define CFG_SHCI_USER_EVT_PROCESS_ATTR_BITS (0) -#define CFG_SHCI_USER_EVT_PROCESS_CB_MEM (0) -#define CFG_SHCI_USER_EVT_PROCESS_CB_SIZE (0) -#define CFG_SHCI_USER_EVT_PROCESS_STACK_MEM (0) -#define CFG_SHCI_USER_EVT_PROCESS_PRIORITY osPriorityNone -#define CFG_SHCI_USER_EVT_PROCESS_STACK_SIZE (128 * 7) - -#define CFG_HCI_USER_EVT_PROCESS_NAME "HCI_USER_EVT_PROCESS" -#define CFG_HCI_USER_EVT_PROCESS_ATTR_BITS (0) -#define CFG_HCI_USER_EVT_PROCESS_CB_MEM (0) -#define CFG_HCI_USER_EVT_PROCESS_CB_SIZE (0) -#define CFG_HCI_USER_EVT_PROCESS_STACK_MEM (0) -#define CFG_HCI_USER_EVT_PROCESS_PRIORITY osPriorityNone -#define CFG_HCI_USER_EVT_PROCESS_STACK_SIZE (128 * 8) - -#define CFG_ADV_UPDATE_PROCESS_NAME "ADV_UPDATE_PROCESS" -#define CFG_ADV_UPDATE_PROCESS_ATTR_BITS (0) -#define CFG_ADV_UPDATE_PROCESS_CB_MEM (0) -#define CFG_ADV_UPDATE_PROCESS_CB_SIZE (0) -#define CFG_ADV_UPDATE_PROCESS_STACK_MEM (0) -#define CFG_ADV_UPDATE_PROCESS_PRIORITY osPriorityNone -#define CFG_ADV_UPDATE_PROCESS_STACK_SIZE (128 * 6) - -#define CFG_HRS_PROCESS_NAME "HRS_PROCESS" -#define CFG_HRS_PROCESS_ATTR_BITS (0) -#define CFG_HRS_PROCESS_CB_MEM (0) -#define CFG_HRS_PROCESS_CB_SIZE (0) -#define CFG_HRS_PROCESS_STACK_MEM (0) -#define CFG_HRS_PROCESS_PRIORITY osPriorityNone -#define CFG_HRS_PROCESS_STACK_SIZE (128 * 5) - -/* USER CODE BEGIN FreeRTOS_Defines */ -#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler -#define PUSH_BUTTON_SW2_EXTI_IRQHandler EXTI0_IRQHandler -#define PUSH_BUTTON_SW3_EXTI_IRQHandler EXTI1_IRQHandler -/* USER CODE END FreeRTOS_Defines */ - -/****************************************************************************** - * LOW POWER - ******************************************************************************/ -/** - * Supported requester to the MCU Low Power Manager - can be increased up to 32 - * It lists a bit mapping of all user of the Low Power Manager - */ -typedef enum { - CFG_LPM_APP, - CFG_LPM_APP_BLE, - /* USER CODE BEGIN CFG_LPM_Id_t */ - - /* USER CODE END CFG_LPM_Id_t */ -} CFG_LPM_Id_t; - -/****************************************************************************** - * OTP manager - ******************************************************************************/ -#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE - -#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR - -#endif /*APP_CONF_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h deleted file mode 100644 index 2961cd99..00000000 --- a/src/utility/STM32Cube_FW/ble_bufsize.h +++ /dev/null @@ -1,161 +0,0 @@ -/***************************************************************************** - * @file ble_bufsize.h - * @author MCD Application Team - * @brief Definition of BLE stack buffers size - ***************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ***************************************************************************** - */ - -#ifndef BLE_BUFSIZE_H__ -#define BLE_BUFSIZE_H__ - - -/* - * BLE_DEFAULT_ATT_MTU: minimum MTU value that GATT must support. - */ -#define BLE_DEFAULT_ATT_MTU 23 - -/* - * BLE_DEFAULT_MAX_ATT_MTU: maximum supported ATT MTU size. - */ -#define BLE_DEFAULT_MAX_ATT_MTU 158 - -/* - * BLE_DEFAULT_MAX_ATT_SIZE: maximum attribute size. - */ -#define BLE_DEFAULT_MAX_ATT_SIZE 512 - -/* - * BLE_PREP_WRITE_X_ATT: compute how many Prepare Write Request are needed to - * write a characteristic with size 'max_att' when the used ATT_MTU value is - * equal to BLE_DEFAULT_ATT_MTU (23). - */ -#define BLE_PREP_WRITE_X_ATT(max_att) \ - (DIVC(max_att, BLE_DEFAULT_ATT_MTU - 5) * 2) - -/* - * BLE_DEFAULT_PREP_WRITE_LIST_SIZE: default minimum Prepare Write List size. - */ -#define BLE_DEFAULT_PREP_WRITE_LIST_SIZE \ - BLE_PREP_WRITE_X_ATT(BLE_DEFAULT_MAX_ATT_SIZE) - -/* - * BLE_MEM_BLOCK_X_MTU: compute how many memory blocks are needed to compose - * an ATT packet with ATT_MTU=mtu. - */ -#define BLE_MEM_BLOCK_SIZE 32 - -#define BLE_MEM_BLOCK_X_TX(mtu) \ - (DIVC((mtu) + 4U, BLE_MEM_BLOCK_SIZE) + 1U) - -#define BLE_MEM_BLOCK_X_RX(mtu, n_link) \ - ((DIVC((mtu) + 4U, BLE_MEM_BLOCK_SIZE) + 2U) * (n_link) + 1) - -#define BLE_MEM_BLOCK_X_MTU(mtu, n_link) \ - (BLE_MEM_BLOCK_X_TX(mtu) + BLE_MEM_BLOCK_X_RX(mtu, n_link)) - -/* - * BLE_MBLOCKS_SECURE_CONNECTIONS: minimum number of blocks required for - * secure connections - */ -#define BLE_MBLOCKS_SECURE_CONNECTIONS 4 - -/* - * BLE_MBLOCKS_CALC: minimum number of buffers needed by the stack. - * This is the minimum racomanded value and depends on: - * - pw: size of Prepare Write List - * - mtu: ATT_MTU size - * - n_link: maximum number of simultaneous connections - */ -#define BLE_MBLOCKS_CALC(pw, mtu, n_link) \ - ((pw) + MAX(BLE_MEM_BLOCK_X_MTU(mtu, n_link), \ - BLE_MBLOCKS_SECURE_CONNECTIONS)) - -/* - * BLE_DEFAULT_MBLOCKS_COUNT: default memory blocks count - */ -#define BLE_DEFAULT_MBLOCKS_COUNT(n_link) \ - BLE_MBLOCKS_CALC(BLE_DEFAULT_PREP_WRITE_LIST_SIZE, \ - BLE_DEFAULT_MAX_ATT_MTU, n_link) - -/* - * BLE_FIXED_BUFFER_SIZE_BYTES: - * A part of the RAM, is dynamically allocated by initializing all the pointers - * defined in a global context variable "mem_alloc_ctx_p". - * This initialization is made in the Dynamic_allocator functions, which - * assign a portion of RAM given by the external application to the above - * mentioned "global pointers". - * - * The size of this Dynamic RAM is made of 2 main components: - * - a part that is parameters-dependent (num of links, GATT buffers, ...), - * and which value is defined by the following macro; - * - a part, that may be considered "fixed", i.e. independent from the above - * mentioned parameters. -*/ -#if (SLAVE_ONLY == 0) && (LL_ONLY == 0) - #define BLE_FIXED_BUFFER_SIZE_BYTES 6960 /* Full stack */ -#elif SLAVE_ONLY == 0 - #define BLE_FIXED_BUFFER_SIZE_BYTES 6256 /* LL only */ -#else - #define BLE_FIXED_BUFFER_SIZE_BYTES 6696 /* Slave only */ -#endif - -/* - * BLE_PER_LINK_SIZE_BYTES: additional memory size used per link - */ -#if (SLAVE_ONLY == 0) && (LL_ONLY == 0) - #define BLE_PER_LINK_SIZE_BYTES 380 /* Full stack */ -#elif SLAVE_ONLY == 0 - #define BLE_PER_LINK_SIZE_BYTES 196 /* LL only */ -#else - #define BLE_PER_LINK_SIZE_BYTES 332 /* Slave only */ -#endif - -/* - * BLE_TOTAL_BUFFER_SIZE: this macro returns the amount of memory, in bytes, - * needed for the storage of data structures (except GATT database elements) - * whose size depends on the number of supported connections. - * - * @param num_links: Maximum number of simultaneous connections that the device - * will support. Valid values are from 1 to 8. - * - * @param mblocks_count: Number of memory blocks allocated for packets. - */ -#define BLE_TOTAL_BUFFER_SIZE(n_link, mblocks_count) \ - (BLE_FIXED_BUFFER_SIZE_BYTES + \ - (BLE_PER_LINK_SIZE_BYTES * (n_link)) + \ - ((BLE_MEM_BLOCK_SIZE + 12) * (mblocks_count))) - -/* - * BLE_TOTAL_BUFFER_SIZE_GATT: this macro returns the amount of memory, - * in bytes, needed for the storage of GATT database elements. - * - * @param num_gatt_attributes: Maximum number of Attributes (i.e. the number - * of characteristic + the number of characteristic values + the number of - * descriptors, excluding the services) that can be stored in the GATT - * database. 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 - * - * @param num_gatt_services: 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 - * - * @param att_value_array_size: Size of the storage area for Attribute values. - */ -#define BLE_TOTAL_BUFFER_SIZE_GATT(num_gatt_attributes, num_gatt_services, att_value_array_size) \ - (((((att_value_array_size) - 1) | 3) + 1) + \ - (40 * (num_gatt_attributes)) + (48 * (num_gatt_services))) - - -#endif /* ! BLE_BUFSIZE_H__ */ diff --git a/src/utility/STM32Cube_FW/hw.h b/src/utility/STM32Cube_FW/hw.h deleted file mode 100644 index 09b12aff..00000000 --- a/src/utility/STM32Cube_FW/hw.h +++ /dev/null @@ -1,97 +0,0 @@ -/** - ****************************************************************************** - * @file hw.h - * @author MCD Application Team - * @brief Hardware - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __HW_H -#define __HW_H - -#ifdef __cplusplus -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_BLE_Init(void); -void HW_IPCC_BLE_SendCmd(void); -void HW_IPCC_MM_SendFreeBuf(void (*cb)(void)); -void HW_IPCC_BLE_RxEvtNot(void); -void HW_IPCC_BLE_SendAclData(void); -void HW_IPCC_BLE_AclDataAckNot(void); - -void HW_IPCC_SYS_Init(void); -void HW_IPCC_SYS_SendCmd(void); -void HW_IPCC_SYS_CmdEvtNot(void); -void HW_IPCC_SYS_EvtNot(void); - -void HW_IPCC_THREAD_Init(void); -void HW_IPCC_OT_SendCmd(void); -void HW_IPCC_CLI_SendCmd(void); -void HW_IPCC_THREAD_SendAck(void); -void HW_IPCC_OT_CmdEvtNot(void); -void HW_IPCC_CLI_CmdEvtNot(void); -void HW_IPCC_THREAD_EvtNot(void); -void HW_IPCC_THREAD_CliSendAck(void); -void HW_IPCC_THREAD_CliEvtNot(void); - - -void HW_IPCC_LLDTESTS_Init(void); -void HW_IPCC_LLDTESTS_SendCliCmd(void); -void HW_IPCC_LLDTESTS_ReceiveCliRsp(void); -void HW_IPCC_LLDTESTS_SendCliRspAck(void); -void HW_IPCC_LLDTESTS_ReceiveM0Cmd(void); -void HW_IPCC_LLDTESTS_SendM0CmdAck(void); - - -void HW_IPCC_LLD_BLE_Init(void); -void HW_IPCC_LLD_BLE_SendCliCmd(void); -void HW_IPCC_LLD_BLE_ReceiveCliRsp(void); -void HW_IPCC_LLD_BLE_SendCliRspAck(void); -void HW_IPCC_LLD_BLE_ReceiveM0Cmd(void); -void HW_IPCC_LLD_BLE_SendM0CmdAck(void); -void HW_IPCC_LLD_BLE_SendCmd(void); -void HW_IPCC_LLD_BLE_ReceiveRsp(void); -void HW_IPCC_LLD_BLE_SendRspAck(void); - - -void HW_IPCC_TRACES_Init(void); -void HW_IPCC_TRACES_EvtNot(void); - -#ifdef __cplusplus -} -#endif - -#endif /*__HW_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c deleted file mode 100644 index dbeb3eeb..00000000 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ /dev/null @@ -1,342 +0,0 @@ -/** - ****************************************************************************** - * File Name : Target/hw_ipcc.c - * Description : Hardware IPCC source file for STM32WPAN Middleware. - * - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ -#if defined(STM32WBxx) -/* Includes ------------------------------------------------------------------*/ -#include "hw.h" -#include "mbox_def.h" - -/* Global variables ---------------------------------------------------------*/ -/* Private defines -----------------------------------------------------------*/ -#define HW_IPCC_TX_PENDING( channel ) ( !(LL_C1_IPCC_IsActiveFlag_CHx( IPCC, channel )) ) && (((~(IPCC->C1MR)) & (channel << 16U))) -#define HW_IPCC_RX_PENDING( channel ) (LL_C2_IPCC_IsActiveFlag_CHx( IPCC, channel )) && (((~(IPCC->C1MR)) & (channel << 0U))) - -/* Private macros ------------------------------------------------------------*/ -/* Private typedef -----------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -static void (*FreeBufCb)(void); - -/* Private function prototypes -----------------------------------------------*/ -static void HW_IPCC_BLE_EvtHandler(void); -static void HW_IPCC_BLE_AclDataEvtHandler(void); -static void HW_IPCC_MM_FreeBufHandler(void); -static void HW_IPCC_SYS_CmdEvtHandler(void); -static void HW_IPCC_SYS_EvtHandler(void); -static void HW_IPCC_TRACES_EvtHandler(void); - -#ifdef THREAD_WB - static void HW_IPCC_OT_CmdEvtHandler(void); - static void HW_IPCC_THREAD_NotEvtHandler(void); - static void HW_IPCC_THREAD_CliNotEvtHandler(void); -#endif - -/* Public function definition -----------------------------------------------*/ - -/****************************************************************************** - * INTERRUPT HANDLER - ******************************************************************************/ - -void IPCC_C1_RX_IRQHandler(void) -{ - if (HW_IPCC_RX_PENDING(HW_IPCC_SYSTEM_EVENT_CHANNEL)) { - HW_IPCC_SYS_EvtHandler(); - } -#ifdef THREAD_WB - else if (HW_IPCC_RX_PENDING(HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL)) { - HW_IPCC_THREAD_NotEvtHandler(); - } else if (HW_IPCC_RX_PENDING(HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL)) { - HW_IPCC_THREAD_CliNotEvtHandler(); - } -#endif /* THREAD_WB */ - else if (HW_IPCC_RX_PENDING(HW_IPCC_BLE_EVENT_CHANNEL)) { - HW_IPCC_BLE_EvtHandler(); - } else if (HW_IPCC_RX_PENDING(HW_IPCC_TRACES_CHANNEL)) { - HW_IPCC_TRACES_EvtHandler(); - } -} - -void IPCC_C1_TX_IRQHandler(void) -{ - if (HW_IPCC_TX_PENDING(HW_IPCC_SYSTEM_CMD_RSP_CHANNEL)) { - HW_IPCC_SYS_CmdEvtHandler(); - } -#ifdef THREAD_WB - else if (HW_IPCC_TX_PENDING(HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL)) { - HW_IPCC_OT_CmdEvtHandler(); - } -#endif /* THREAD_WB */ - else if (HW_IPCC_TX_PENDING(HW_IPCC_SYSTEM_CMD_RSP_CHANNEL)) { - HW_IPCC_SYS_CmdEvtHandler(); - } else if (HW_IPCC_TX_PENDING(HW_IPCC_MM_RELEASE_BUFFER_CHANNEL)) { - HW_IPCC_MM_FreeBufHandler(); - } else if (HW_IPCC_TX_PENDING(HW_IPCC_HCI_ACL_DATA_CHANNEL)) { - HW_IPCC_BLE_AclDataEvtHandler(); - } -} - -/****************************************************************************** - * GENERAL - ******************************************************************************/ -void HW_IPCC_Enable(void) -{ - /** - * When the device is out of standby, it is required to use the EXTI mechanism to wakeup CPU2 - */ - LL_C2_EXTI_EnableEvent_32_63(LL_EXTI_LINE_41); - LL_EXTI_EnableRisingTrig_32_63(LL_EXTI_LINE_41); - - /** - * In case the SBSFU is implemented, it may have already set the C2BOOT bit to startup the CPU2. - * In that case, to keep the mechanism transparent to the user application, it shall call the system command - * SHCI_C2_Reinit( ) before jumping to the application. - * When the CPU2 receives that command, it waits for its event input to be set to restart the CPU2 firmware. - * This is required because once C2BOOT has been set once, a clear/set on C2BOOT has no effect. - * When SHCI_C2_Reinit( ) is not called, generating an event to the CPU2 does not have any effect - * So, by default, the application shall both set the event flag and set the C2BOOT bit. - */ - __SEV(); /* Set the internal event flag and send an event to the CPU2 */ - __WFE(); /* Clear the internal event flag */ - LL_PWR_EnableBootC2(); - - return; -} - -void HW_IPCC_Init(void) -{ - LL_AHB3_GRP1_EnableClock(LL_AHB3_GRP1_PERIPH_IPCC); - - LL_C1_IPCC_EnableIT_RXO(IPCC); - LL_C1_IPCC_EnableIT_TXF(IPCC); - - HAL_NVIC_EnableIRQ(IPCC_C1_RX_IRQn); - HAL_NVIC_EnableIRQ(IPCC_C1_TX_IRQn); - - return; -} - -/****************************************************************************** - * BLE - ******************************************************************************/ -void HW_IPCC_BLE_Init(void) -{ - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_BLE_EVENT_CHANNEL); - - return; -} - -void HW_IPCC_BLE_SendCmd(void) -{ - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_BLE_CMD_CHANNEL); - - return; -} - -static void HW_IPCC_BLE_EvtHandler(void) -{ - HW_IPCC_BLE_RxEvtNot(); - - LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_BLE_EVENT_CHANNEL); - - return; -} - -void HW_IPCC_BLE_SendAclData(void) -{ - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL); - LL_C1_IPCC_EnableTransmitChannel(IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL); - - return; -} - -static void HW_IPCC_BLE_AclDataEvtHandler(void) -{ - LL_C1_IPCC_DisableTransmitChannel(IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL); - - HW_IPCC_BLE_AclDataAckNot(); - - return; -} - -__WEAK void HW_IPCC_BLE_AclDataAckNot(void) {}; -__WEAK void HW_IPCC_BLE_RxEvtNot(void) {}; - -/****************************************************************************** - * SYSTEM - ******************************************************************************/ -void HW_IPCC_SYS_Init(void) -{ - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL); - - return; -} - -void HW_IPCC_SYS_SendCmd(void) -{ - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL); - LL_C1_IPCC_EnableTransmitChannel(IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL); - - return; -} - -static void HW_IPCC_SYS_CmdEvtHandler(void) -{ - LL_C1_IPCC_DisableTransmitChannel(IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL); - - HW_IPCC_SYS_CmdEvtNot(); - - return; -} - -static void HW_IPCC_SYS_EvtHandler(void) -{ - HW_IPCC_SYS_EvtNot(); - - LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL); - - return; -} - -__WEAK void HW_IPCC_SYS_CmdEvtNot(void) {}; -__WEAK void HW_IPCC_SYS_EvtNot(void) {}; - -/****************************************************************************** - * THREAD - ******************************************************************************/ -#ifdef THREAD_WB -void HW_IPCC_THREAD_Init(void) -{ - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL); - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL); - - return; -} - -void HW_IPCC_OT_SendCmd(void) -{ - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL); - LL_C1_IPCC_EnableTransmitChannel(IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL); - - return; -} - -void HW_IPCC_CLI_SendCmd(void) -{ - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_THREAD_CLI_CMD_CHANNEL); - - return; -} - -void HW_IPCC_THREAD_SendAck(void) -{ - LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL); - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL); - - return; -} - -void HW_IPCC_THREAD_CliSendAck(void) -{ - LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL); - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL); - - return; -} - -static void HW_IPCC_OT_CmdEvtHandler(void) -{ - LL_C1_IPCC_DisableTransmitChannel(IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL); - - HW_IPCC_OT_CmdEvtNot(); - - return; -} - -static void HW_IPCC_THREAD_NotEvtHandler(void) -{ - LL_C1_IPCC_DisableReceiveChannel(IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL); - - HW_IPCC_THREAD_EvtNot(); - - return; -} - -static void HW_IPCC_THREAD_CliNotEvtHandler(void) -{ - LL_C1_IPCC_DisableReceiveChannel(IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL); - - HW_IPCC_THREAD_CliEvtNot(); - - return; -} - -__WEAK void HW_IPCC_OT_CmdEvtNot(void) {}; -__WEAK void HW_IPCC_CLI_CmdEvtNot(void) {}; -__WEAK void HW_IPCC_THREAD_EvtNot(void) {}; - -#endif /* THREAD_WB */ - -/****************************************************************************** - * MEMORY MANAGER - ******************************************************************************/ -void HW_IPCC_MM_SendFreeBuf(void (*cb)(void)) -{ - if (LL_C1_IPCC_IsActiveFlag_CHx(IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL)) { - FreeBufCb = cb; - LL_C1_IPCC_EnableTransmitChannel(IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL); - } else { - cb(); - - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL); - } - - return; -} - -static void HW_IPCC_MM_FreeBufHandler(void) -{ - LL_C1_IPCC_DisableTransmitChannel(IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL); - - FreeBufCb(); - - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL); - - return; -} - -/****************************************************************************** - * TRACES - ******************************************************************************/ -void HW_IPCC_TRACES_Init(void) -{ - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_TRACES_CHANNEL); - - return; -} - -static void HW_IPCC_TRACES_EvtHandler(void) -{ - HW_IPCC_TRACES_EvtNot(); - - LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_TRACES_CHANNEL); - - return; -} - -__WEAK void HW_IPCC_TRACES_EvtNot(void) {}; -#endif /* STM32WBxx */ -/******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h deleted file mode 100644 index d5a7d46b..00000000 --- a/src/utility/STM32Cube_FW/mbox_def.h +++ /dev/null @@ -1,212 +0,0 @@ -/** - ****************************************************************************** - * @file mbox_def.h - * @author MCD Application Team - * @brief Mailbox definition - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __MBOX_H -#define __MBOX_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "stm32_wpan_common.h" - -/** - * This file shall be identical between the CPU1 and the CPU2 - */ - -/** - ********************************************************************************* - * TABLES - ********************************************************************************* - */ - -/** - * Version - * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version - * [4:7] = branch - 0: Mass Market - x: ... - * [8:15] = Subversion - * [16:23] = Version minor - * [24:31] = Version major - * - * Memory Size - * [0:7] = Flash ( Number of 4k sector) - * [8:15] = Reserved ( Shall be set to 0 - may be used as flash extension ) - * [16:23] = SRAM2b ( Number of 1k sector) - * [24:31] = SRAM2a ( Number of 1k sector) - */ -typedef PACKED_STRUCT { - uint32_t Version; -} MB_SafeBootInfoTable_t; - -typedef PACKED_STRUCT { - uint32_t Version; - uint32_t MemorySize; - uint32_t FusInfo; -} MB_FusInfoTable_t; - -typedef PACKED_STRUCT { - uint32_t Version; - uint32_t MemorySize; - uint32_t InfoStack; - uint32_t Reserved; -} MB_WirelessFwInfoTable_t; - -typedef struct { - MB_SafeBootInfoTable_t SafeBootInfoTable; - MB_FusInfoTable_t FusInfoTable; - MB_WirelessFwInfoTable_t WirelessFwInfoTable; -} MB_DeviceInfoTable_t; - -typedef struct { - uint8_t *pcmd_buffer; - uint8_t *pcs_buffer; - uint8_t *pevt_queue; - uint8_t *phci_acl_data_buffer; -} MB_BleTable_t; - -typedef struct { - uint8_t *notack_buffer; - uint8_t *clicmdrsp_buffer; - uint8_t *otcmdrsp_buffer; -} MB_ThreadTable_t; - -typedef struct { - uint8_t *clicmdrsp_buffer; - uint8_t *m0cmd_buffer; -} MB_LldTestsTable_t; - -typedef struct { - uint8_t *cmdrsp_buffer; - uint8_t *m0cmd_buffer; -} MB_LldBleTable_t; - -/** - * msg - * [0:7] = cmd/evt - * [8:31] = Reserved - */ -typedef struct { - uint8_t *pcmd_buffer; - uint8_t *sys_queue; -} MB_SysTable_t; - -typedef struct { - uint8_t *spare_ble_buffer; - uint8_t *spare_sys_buffer; - uint8_t *blepool; - uint32_t blepoolsize; - uint8_t *pevt_free_buffer_queue; - uint8_t *traces_evt_pool; - uint32_t tracespoolsize; -} MB_MemManagerTable_t; - -typedef struct { - uint8_t *traces_queue; -} MB_TracesTable_t; - -typedef struct { - MB_DeviceInfoTable_t *p_device_info_table; - MB_BleTable_t *p_ble_table; - MB_ThreadTable_t *p_thread_table; - MB_SysTable_t *p_sys_table; - MB_MemManagerTable_t *p_mem_manager_table; - MB_TracesTable_t *p_traces_table; - MB_LldTestsTable_t *p_lld_tests_table; - MB_LldBleTable_t *p_lld_ble_table; -} MB_RefTable_t; - -#ifdef __cplusplus -} -#endif - -/** - ********************************************************************************* - * IPCC CHANNELS - ********************************************************************************* - */ - -/* CPU1 CPU2 - * | (SYSTEM) | - * |----HW_IPCC_SYSTEM_CMD_RSP_CHANNEL-------------->| - * | | - * |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------| - * | | - * | (THREAD) | - * |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->| - * | | - * |----HW_IPCC_THREAD_CLI_CMD_CHANNEL-------------->| - * | | - * |<---HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL------| - * | | - * |<---HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL--| - * | | - * | (BLE) | - * |----HW_IPCC_BLE_CMD_CHANNEL--------------------->| - * | | - * |----HW_IPCC_HCI_ACL_DATA_CHANNEL---------------->| - * | | - * |<---HW_IPCC_BLE_EVENT_CHANNEL--------------------| - * | | - * | (LLD BLE) | - * |----HW_IPCC_LLD_BLE_CMD_CHANNEL----------------->| - * | | - * |<---HW_IPCC_LLD_BLE_RSP_CHANNEL------------------| - * | | - * |<---HW_IPCC_LLD_BLE_M0_CMD_CHANNEL---------------| - * | | - * | (BUFFER) | - * |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>| - * | | - * | (TRACE) | - * |<----HW_IPCC_TRACES_CHANNEL----------------------| - * | | - * - * - * - */ - - - -/** CPU1 */ -#define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1 -#define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2 -#define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4 -#define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_LLD_BLE_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_LLD_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_HCI_ACL_DATA_CHANNEL LL_IPCC_CHANNEL_6 - -/** CPU2 */ -#define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1 -#define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2 -#define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_LLD_BLE_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4 -#define HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_LLD_BLE_RSP_CHANNEL LL_IPCC_CHANNEL_5 -#endif /*__MBOX_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c deleted file mode 100644 index d23157f2..00000000 --- a/src/utility/STM32Cube_FW/shci.c +++ /dev/null @@ -1,567 +0,0 @@ -/** - ****************************************************************************** - * @file shci.c - * @author MCD Application Team - * @brief HCI command for the system channel - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -#if defined(STM32WBxx) -/* Includes ------------------------------------------------------------------*/ -#include "stm32_wpan_common.h" - -#include "shci_tl.h" -#include "shci.h" -#include "stm32wbxx.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private defines -----------------------------------------------------------*/ -/* Private macros ------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Global variables ----------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -/* Local Functions Definition ------------------------------------------------------*/ -/* Public Functions Definition ------------------------------------------------------*/ - -/** - * C2 COMMAND - * These commands are sent to the CPU2 - */ -uint8_t SHCI_C2_FUS_GetState(SHCI_FUS_GetState_ErrorCode_t *p_error_code) -{ - /** - * A command status event + payload has the same size than the expected command complete - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE + 1]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_FUS_GET_STATE, - 0, - 0, - p_rsp); - - if (p_error_code != 0) { - *p_error_code = (SHCI_FUS_GetState_ErrorCode_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[1]); - } - - return (((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade(uint32_t fw_src_add, uint32_t fw_dest_add) -{ - /** - * TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 8 bytes of command parameters - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - uint32_t *p_cmd; - uint8_t cmd_length; - - p_cmd = (uint32_t *)local_buffer; - cmd_length = 0; - - if (fw_src_add != 0) { - *p_cmd = fw_src_add; - cmd_length += 4; - } - - if (fw_dest_add != 0) { - *(p_cmd + 1) = fw_dest_add; - cmd_length += 4; - } - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_FUS_FW_UPGRADE, - cmd_length, - local_buffer, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete(void) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_FUS_FW_DELETE, - 0, - 0, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey(SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t *pParam) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_FUS_UPDATE_AUTH_KEY, - sizeof(SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t), - (uint8_t *)pParam, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey(void) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_FUS_LOCK_AUTH_KEY, - 0, - 0, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey(SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *pParam, uint8_t *p_key_index) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE + 1]; - TL_EvtPacket_t *p_rsp; - uint8_t local_payload_len; - - if (pParam->KeyType == KEYTYPE_ENCRYPTED) { - /** - * When the key is encrypted, the 12 bytes IV Key is included in the payload as well - * The IV key is always 12 bytes - */ - local_payload_len = pParam->KeySize + 2 + 12; - } else { - local_payload_len = pParam->KeySize + 2; - } - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_FUS_STORE_USR_KEY, - local_payload_len, - (uint8_t *)pParam, - p_rsp); - - *p_key_index = (((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[1]); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey(uint8_t key_index) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - local_buffer[0] = key_index; - - shci_send(SHCI_OPCODE_C2_FUS_LOAD_USR_KEY, - 1, - local_buffer, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_FUS_StartWs(void) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_FUS_START_WS, - 0, - 0, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - - -SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey(uint8_t key_index) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - local_buffer[0] = key_index; - - shci_send(SHCI_OPCODE_C2_FUS_LOCK_USR_KEY, - 1, - local_buffer, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_BLE_Init(SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_BLE_INIT, - sizeof(SHCI_C2_Ble_Init_Cmd_Param_t), - (uint8_t *)&pCmdPacket->Param, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_THREAD_Init(void) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_THREAD_INIT, - 0, - 0, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init(uint8_t param_size, uint8_t *p_param) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_LLD_TESTS_INIT, - param_size, - p_param, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init(uint8_t param_size, uint8_t *p_param) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_LLD_BLE_INIT, - param_size, - p_param, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_DEBUG_Init(SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_DEBUG_INIT, - sizeof(SHCI_C2_DEBUG_init_Cmd_Param_t), - (uint8_t *)&pCmdPacket->Param, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity(SHCI_EraseActivity_t erase_activity) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - local_buffer[0] = erase_activity; - - shci_send(SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY, - 1, - local_buffer, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode(SHCI_C2_CONCURRENT_Mode_Param_t Mode) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - local_buffer[0] = Mode; - - shci_send(SHCI_OPCODE_C2_CONCURRENT_SET_MODE, - 1, - local_buffer, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData(SHCI_C2_FLASH_Ip_t Ip) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - local_buffer[0] = Ip; - - shci_send(SHCI_OPCODE_C2_FLASH_STORE_DATA, - 1, - local_buffer, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData(SHCI_C2_FLASH_Ip_t Ip) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - local_buffer[0] = Ip; - - shci_send(SHCI_OPCODE_C2_FLASH_ERASE_DATA, - 1, - local_buffer, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower(SHCI_C2_FLASH_Ip_t Ip, uint8_t FlagRadioLowPowerOn) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - local_buffer[0] = Ip; - local_buffer[1] = FlagRadioLowPowerOn; - - shci_send(SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER, - 2, - local_buffer, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_Reinit(void) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_REINIT, - 0, - 0, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_number, uint8_t gpio_polarity, uint8_t gpio_status) -{ - /** - * TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 8 bytes of command parameters - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t *)local_buffer)->gpio_port = gpio_port; - ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t *)local_buffer)->gpio_pin_number = gpio_pin_number; - ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t *)local_buffer)->gpio_polarity = gpio_polarity; - ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t *)local_buffer)->gpio_status = gpio_status; - - shci_send(SHCI_OPCODE_C2_EXTPA_CONFIG, - 8, - local_buffer, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t Source) -{ - /** - * TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 1 byte of command parameter - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - local_buffer[0] = (uint8_t)Source; - - shci_send(SHCI_OPCODE_C2_SET_FLASH_ACTIVITY_CONTROL, - 1, - local_buffer, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - -SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send(SHCI_OPCODE_C2_CONFIG, - sizeof(SHCI_C2_CONFIG_Cmd_Param_t), - (uint8_t *)pCmdPacket, - p_rsp); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); -} - - -/** - * Local System COMMAND - * These commands are NOT sent to the CPU2 - */ - -SHCI_CmdStatus_t SHCI_GetWirelessFwInfo(WirelessFwInfo_t *pWirelessInfo) -{ - uint32_t ipccdba = 0; - MB_RefTable_t *p_RefTable = NULL; - uint32_t version = 0; - uint32_t memorySize = 0; - uint32_t infoStack = 0; - - ipccdba = READ_BIT(FLASH->IPCCBR, FLASH_IPCCBR_IPCCDBA); - p_RefTable = (MB_RefTable_t *)((ipccdba << 2) + SRAM2A_BASE); - - /** - * Retrieve the WirelessFwInfoTable - * This table is stored in RAM at startup during the TL (transport layer) initialization - */ - version = p_RefTable->p_device_info_table->WirelessFwInfoTable.Version; - pWirelessInfo->VersionMajor = ((version & INFO_VERSION_MAJOR_MASK) >> INFO_VERSION_MAJOR_OFFSET); - pWirelessInfo->VersionMinor = ((version & INFO_VERSION_MINOR_MASK) >> INFO_VERSION_MINOR_OFFSET); - pWirelessInfo->VersionSub = ((version & INFO_VERSION_SUB_MASK) >> INFO_VERSION_SUB_OFFSET); - pWirelessInfo->VersionBranch = ((version & INFO_VERSION_BRANCH_MASK) >> INFO_VERSION_BRANCH_OFFSET); - pWirelessInfo->VersionReleaseType = ((version & INFO_VERSION_TYPE_MASK) >> INFO_VERSION_TYPE_OFFSET); - - memorySize = p_RefTable->p_device_info_table->WirelessFwInfoTable.MemorySize; - pWirelessInfo->MemorySizeSram2B = ((memorySize & INFO_SIZE_SRAM2B_MASK) >> INFO_SIZE_SRAM2B_OFFSET); - pWirelessInfo->MemorySizeSram2A = ((memorySize & INFO_SIZE_SRAM2A_MASK) >> INFO_SIZE_SRAM2A_OFFSET); - pWirelessInfo->MemorySizeSram1 = ((memorySize & INFO_SIZE_SRAM1_MASK) >> INFO_SIZE_SRAM1_OFFSET); - pWirelessInfo->MemorySizeFlash = ((memorySize & INFO_SIZE_FLASH_MASK) >> INFO_SIZE_FLASH_OFFSET); - - infoStack = p_RefTable->p_device_info_table->WirelessFwInfoTable.InfoStack; - pWirelessInfo->StackType = ((infoStack & INFO_STACK_TYPE_MASK) >> INFO_STACK_TYPE_OFFSET); - - /** - * Retrieve the FusInfoTable - * This table is stored in RAM at startup during the TL (transport layer) initialization - */ - version = p_RefTable->p_device_info_table->FusInfoTable.Version; - pWirelessInfo->FusVersionMajor = ((version & INFO_VERSION_MAJOR_MASK) >> INFO_VERSION_MAJOR_OFFSET); - pWirelessInfo->FusVersionMinor = ((version & INFO_VERSION_MINOR_MASK) >> INFO_VERSION_MINOR_OFFSET); - pWirelessInfo->FusVersionSub = ((version & INFO_VERSION_SUB_MASK) >> INFO_VERSION_SUB_OFFSET); - - memorySize = p_RefTable->p_device_info_table->FusInfoTable.MemorySize; - pWirelessInfo->FusMemorySizeSram2B = ((memorySize & INFO_SIZE_SRAM2B_MASK) >> INFO_SIZE_SRAM2B_OFFSET); - pWirelessInfo->FusMemorySizeSram2A = ((memorySize & INFO_SIZE_SRAM2A_MASK) >> INFO_SIZE_SRAM2A_OFFSET); - pWirelessInfo->FusMemorySizeFlash = ((memorySize & INFO_SIZE_FLASH_MASK) >> INFO_SIZE_FLASH_OFFSET); - - return (SHCI_Success); -} -#endif /* STM32WBxx */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h deleted file mode 100644 index 35227c76..00000000 --- a/src/utility/STM32Cube_FW/shci.h +++ /dev/null @@ -1,888 +0,0 @@ -/** - ****************************************************************************** - * @file shci.h - * @author MCD Application Team - * @brief HCI command for the system channel - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __SHCI_H -#define __SHCI_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Includes ------------------------------------------------------------------*/ -#include "mbox_def.h" /* Requested to expose the MB_WirelessFwInfoTable_t structure */ - -/* Exported types ------------------------------------------------------------*/ - -/* SYSTEM EVENT */ -typedef enum { - WIRELESS_FW_RUNNING = 0x00, - RSS_FW_RUNNING = 0x01, -} SHCI_SysEvt_Ready_Rsp_t; - -/* ERROR CODES - * - * These error codes are detected on M0 side and are send back to the M4 via a system - * notification message. It is up to the application running on M4 to manage these errors - * - * These errors can be generated by all layers (low level driver, stack, framework infrastructure, etc..) - */ -typedef enum { - ERR_BLE_INIT = 0, - ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ - ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the M4 to control the Thread stack is unknown */ -} SCHI_SystemErrCode_t; - -#define SHCI_EVTCODE ( 0xFF ) -#define SHCI_SUB_EVT_CODE_BASE ( 0x9200 ) - -/** - * THE ORDER SHALL NOT BE CHANGED TO GUARANTEE COMPATIBILITY WITH THE CPU1 DEFINITION - */ -typedef enum { - SHCI_SUB_EVT_CODE_READY = SHCI_SUB_EVT_CODE_BASE, - SHCI_SUB_EVT_ERROR_NOTIF, - SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE, - SHCI_SUB_EVT_OT_NVM_RAM_UPDATE, - SHCI_SUB_EVT_NVM_START_WRITE, - SHCI_SUB_EVT_NVM_END_WRITE, - SHCI_SUB_EVT_NVM_START_ERASE, - SHCI_SUB_EVT_NVM_END_ERASE, -} SHCI_SUB_EVT_CODE_t; - -/** - * SHCI_SUB_EVT_CODE_READY - * This notifies the CPU1 that the CPU2 is now ready to receive commands - * It reports as well which firmware is running on CPU2 : The wireless stack of the FUS (previously named RSS) - */ -typedef PACKED_STRUCT{ - SHCI_SysEvt_Ready_Rsp_t sysevt_ready_rsp; -} SHCI_C2_Ready_Evt_t; - -/** - * SHCI_SUB_EVT_ERROR_NOTIF - * This reports to the CPU1 some error form the CPU2 - */ -typedef PACKED_STRUCT{ - SCHI_SystemErrCode_t errorCode; -} SHCI_C2_ErrorNotif_Evt_t; - -/** - * SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE - * This notifies the CPU1 which part of the BLE NVM RAM has been updated so that only the modified - * section could be written in Flash/NVM - * StartAddress : Start address of the section that has been modified - * Size : Size (in bytes) of the section that has been modified - */ -typedef PACKED_STRUCT{ - uint32_t StartAddress; - uint32_t Size; -} SHCI_C2_BleNvmRamUpdate_Evt_t; - -/** - * SHCI_SUB_EVT_OT_NVM_RAM_UPDATE - * This notifies the CPU1 which part of the 'OT NVM RAM' has been updated so that only the modified - * section could be written in Flash/NVM - * StartAddress : Start address of the section that has been modified - * Size : Size (in bytes) of the section that has been modified - */ -typedef PACKED_STRUCT{ - uint32_t StartAddress; - uint32_t Size; -} SHCI_C2_OtNvmRamUpdate_Evt_t; - -/** - * SHCI_SUB_EVT_NVM_START_WRITE - * This notifies the CPU1 that the CPU2 has started a write procedure in Flash - * NumberOfWords : The number of 64bits data the CPU2 needs to write in Flash. - * For each 64bits data, the algorithm as described in AN5289 is executed. - * When this number is reported to 0, it means the Number of 64bits to be written - * was unknown when the procedure has started. - * When all data are written, the SHCI_SUB_EVT_NVM_END_WRITE event is reported - */ -typedef PACKED_STRUCT{ - uint32_t NumberOfWords; -} SHCI_C2_NvmStartWrite_Evt_t; - -/** - * SHCI_SUB_EVT_NVM_END_WRITE - * This notifies the CPU1 that the CPU2 has written all expected data in Flash - */ - -/** - * SHCI_SUB_EVT_NVM_START_ERASE - * This notifies the CPU1 that the CPU2 has started a erase procedure in Flash - * NumberOfSectors : The number of sectors the CPU2 needs to erase in Flash. - * For each sector, the algorithm as described in AN5289 is executed. - * When this number is reported to 0, it means the Number of sectors to be erased - * was unknown when the procedure has started. - * When all sectors are erased, the SHCI_SUB_EVT_NVM_END_ERASE event is reported - */ -typedef PACKED_STRUCT{ - uint32_t NumberOfSectors; -} SHCI_C2_NvmStartErase_Evt_t; - -/** - * SHCI_SUB_EVT_NVM_END_ERASE - * This notifies the CPU1 that the CPU2 has erased all expected flash sectors - */ - -/* SYSTEM COMMAND */ -typedef PACKED_STRUCT { - uint32_t MetaData[3]; -} SHCI_Header_t; - -typedef enum { - SHCI_Success = 0x00, - SHCI_UNKNOWN_CMD = 0x01, - SHCI_ERR_UNSUPPORTED_FEATURE = 0x11, - SHCI_ERR_INVALID_HCI_CMD_PARAMS = 0x12, - SHCI_FUS_CMD_NOT_SUPPORTED = 0xFF, -} SHCI_CmdStatus_t; - -typedef enum { - SHCI_8BITS = 0x01, - SHCI_16BITS = 0x02, - SHCI_32BITS = 0x04, -} SHCI_Busw_t; - -#define SHCI_OGF ( 0x3F ) -#define SHCI_OCF_BASE ( 0x50 ) - -/** - * THE ORDER SHALL NOT BE CHANGED TO GUARANTEE COMPATIBILITY WITH THE CPU2 DEFINITION - */ -typedef enum { - SHCI_OCF_C2_RESERVED1 = SHCI_OCF_BASE, - SHCI_OCF_C2_RESERVED2, - SHCI_OCF_C2_FUS_GET_STATE, - SHCI_OCF_C2_FUS_RESERVED1, - SHCI_OCF_C2_FUS_FW_UPGRADE, - SHCI_OCF_C2_FUS_FW_DELETE, - SHCI_OCF_C2_FUS_UPDATE_AUTH_KEY, - SHCI_OCF_C2_FUS_LOCK_AUTH_KEY, - SHCI_OCF_C2_FUS_STORE_USR_KEY, - SHCI_OCF_C2_FUS_LOAD_USR_KEY, - SHCI_OCF_C2_FUS_START_WS, - SHCI_OCF_C2_FUS_RESERVED2, - SHCI_OCF_C2_FUS_RESERVED3, - SHCI_OCF_C2_FUS_LOCK_USR_KEY, - SHCI_OCF_C2_FUS_RESERVED5, - SHCI_OCF_C2_FUS_RESERVED6, - SHCI_OCF_C2_FUS_RESERVED7, - SHCI_OCF_C2_FUS_RESERVED8, - SHCI_OCF_C2_FUS_RESERVED9, - SHCI_OCF_C2_FUS_RESERVED10, - SHCI_OCF_C2_FUS_RESERVED11, - SHCI_OCF_C2_FUS_RESERVED12, - SHCI_OCF_C2_BLE_INIT, - SHCI_OCF_C2_THREAD_INIT, - SHCI_OCF_C2_DEBUG_INIT, - SHCI_OCF_C2_FLASH_ERASE_ACTIVITY, - SHCI_OCF_C2_CONCURRENT_SET_MODE, - SHCI_OCF_C2_FLASH_STORE_DATA, - SHCI_OCF_C2_FLASH_ERASE_DATA, - SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, - SHCI_OCF_C2_REINIT, - SHCI_OCF_C2_LLD_TESTS_INIT, - SHCI_OCF_C2_EXTPA_CONFIG, - SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, - SHCI_OCF_C2_LLD_BLE_INIT, - SHCI_OCF_C2_CONFIG, -} SHCI_OCF_t; - -#define SHCI_OPCODE_C2_FUS_GET_STATE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_GET_STATE) -/** No command parameters */ -/** Response parameters*/ -typedef enum { - FUS_STATE_NO_ERROR = 0x00, - FUS_STATE_IMG_NOT_FOUND = 0x01, - FUS_STATE_IMG_CORRUPT = 0x02, - FUS_STATE_IMG_NOT_AUTHENTIC = 0x03, - FUS_STATE_IMG_NOT_ENOUGH_SPACE = 0x04, - FUS_STATE_ERR_UNKNOWN = 0xFF, -} SHCI_FUS_GetState_ErrorCode_t; - -#define SHCI_OPCODE_C2_FUS_RESERVED1 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED1) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_FW_UPGRADE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_FW_UPGRADE) -/** No structure for command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_FW_DELETE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_FW_DELETE) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_UPDATE_AUTH_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_UPDATE_AUTH_KEY) -typedef PACKED_STRUCT { - uint8_t KeySize; - uint8_t KeyData[64]; -} SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t; - -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_LOCK_AUTH_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOCK_AUTH_KEY) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_STORE_USR_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_STORE_USR_KEY) -/** Command parameters */ -/* List of supported key type */ -enum { - KEYTYPE_NONE = 0x00, - KEYTYPE_SIMPLE = 0x01, - KEYTYPE_MASTER = 0x02, - KEYTYPE_ENCRYPTED = 0x03, -}; - -/* List of supported key size */ -enum { - KEYSIZE_16 = 16, - KEYSIZE_32 = 32, -}; - -typedef PACKED_STRUCT{ - uint8_t KeyType; - uint8_t KeySize; - uint8_t KeyData[32 + 12]; -} SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t; - -/** Response parameters*/ -/** It responds a 1 byte value holding the index given for the stored key */ - -#define SHCI_OPCODE_C2_FUS_LOAD_USR_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOAD_USR_KEY) -/** Command parameters */ -/** 1 byte holding the key index value */ - -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_START_WS (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_START_WS) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_RESERVED2 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED2) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_RESERVED3 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED3) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_LOCK_USR_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOCK_USR_KEY) -/** Command parameters */ -/** 1 byte holding the key index value */ - -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_RESERVED5 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED5) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_RESERVED6 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED6) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_RESERVED7 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED7) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_RESERVED8 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED8) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_RESERVED9 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED9) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_RESERVED10 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED10) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_RESERVED11 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED11) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FUS_RESERVED12 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED12) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_BLE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_INIT) -/** THE ORDER SHALL NOT BE CHANGED */ -typedef PACKED_STRUCT{ - uint8_t *pBleBufferAddress; /**< NOT USED CURRENTLY */ - uint32_t BleBufferSize; /**< Size of the Buffer allocated in pBleBufferAddress */ - uint16_t NumAttrRecord; - uint16_t NumAttrServ; - uint16_t AttrValueArrSize; - uint8_t NumOfLinks; - uint8_t ExtendedPacketLengthEnable; - uint8_t PrWriteListSize; - uint8_t MblockCount; - uint16_t AttMtu; - uint16_t SlaveSca; - uint8_t MasterSca; - uint8_t LsSource; - uint32_t MaxConnEventLength; - uint16_t HsStartupTime; - uint8_t ViterbiEnable; - uint8_t LlOnly; - uint8_t HwVersion; -} SHCI_C2_Ble_Init_Cmd_Param_t; - -typedef PACKED_STRUCT{ - SHCI_Header_t Header; /** Does not need to be initialized by the user */ - SHCI_C2_Ble_Init_Cmd_Param_t Param; -} SHCI_C2_Ble_Init_Cmd_Packet_t; - -/** No response parameters*/ - -#define SHCI_OPCODE_C2_THREAD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_THREAD_INIT) -/** No command parameters */ -/** No response parameters*/ - -#define SHCI_OPCODE_C2_DEBUG_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_DEBUG_INIT) -/** Command parameters */ -typedef PACKED_STRUCT { - uint8_t thread_config; - uint8_t ble_config; -} SHCI_C2_DEBUG_TracesConfig_t; - -typedef PACKED_STRUCT { - uint8_t ble_dtb_cfg; - uint8_t reserved[3]; -} SHCI_C2_DEBUG_GeneralConfig_t; - -typedef PACKED_STRUCT{ - uint8_t *pGpioConfig; - uint8_t *pTracesConfig; - uint8_t *pGeneralConfig; - uint8_t GpioConfigSize; - uint8_t TracesConfigSize; - uint8_t GeneralConfigSize; -} SHCI_C2_DEBUG_init_Cmd_Param_t; - -typedef PACKED_STRUCT{ - SHCI_Header_t Header; /** Does not need to be initialized by the user */ - SHCI_C2_DEBUG_init_Cmd_Param_t Param; -} SHCI_C2_DEBUG_Init_Cmd_Packet_t; -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_ERASE_ACTIVITY) -/** Command parameters */ -typedef enum { - ERASE_ACTIVITY_OFF = 0x00, - ERASE_ACTIVITY_ON = 0x01, -} SHCI_EraseActivity_t; - -/** No response parameters*/ - -#define SHCI_OPCODE_C2_CONCURRENT_SET_MODE (( SHCI_OGF << 10) + SHCI_OCF_C2_CONCURRENT_SET_MODE) -/** command parameters */ -typedef enum { - BLE_ENABLE, - THREAD_ENABLE, -} SHCI_C2_CONCURRENT_Mode_Param_t; -/** No response parameters*/ - -#define SHCI_OPCODE_C2_FLASH_STORE_DATA (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_STORE_DATA) -#define SHCI_OPCODE_C2_FLASH_ERASE_DATA (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_ERASE_DATA) -/** command parameters */ -typedef enum { - BLE_IP, - THREAD_IP, -} SHCI_C2_FLASH_Ip_t; -/** No response parameters*/ - -#define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) - -#define SHCI_OPCODE_C2_REINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_REINIT) - -#define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) - -#define SHCI_OPCODE_C2_LLD_BLE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_BLE_INIT) - -#define SHCI_OPCODE_C2_EXTPA_CONFIG (( SHCI_OGF << 10) + SHCI_OCF_C2_EXTPA_CONFIG) -/** Command parameters */ -enum { - EXT_PA_ENABLED_LOW, - EXT_PA_ENABLED_HIGH, -}/* gpio_polarity */; - -enum { - EXT_PA_DISABLED, - EXT_PA_ENABLED, -}/* gpio_status */; - -typedef PACKED_STRUCT{ - uint32_t gpio_port; - uint16_t gpio_pin_number; - uint8_t gpio_polarity; - uint8_t gpio_status; -} SHCI_C2_EXTPA_CONFIG_Cmd_Param_t; - -/** No response parameters*/ - -#define SHCI_OPCODE_C2_SET_FLASH_ACTIVITY_CONTROL (( SHCI_OGF << 10) + SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL) -/** Command parameters */ -typedef enum { - FLASH_ACTIVITY_CONTROL_PES, - FLASH_ACTIVITY_CONTROL_SEM7, -} SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t; - -/** No response parameters*/ - -#define SHCI_OPCODE_C2_CONFIG (( SHCI_OGF << 10) + SHCI_OCF_C2_CONFIG) -/** Command parameters */ -typedef PACKED_STRUCT{ - uint8_t PayloadCmdSize; - uint8_t Config1; - uint8_t EvtMask1; - uint8_t Spare1; - uint32_t BleNvmRamAddress; - uint32_t ThreadNvmRamAddress; -} SHCI_C2_CONFIG_Cmd_Param_t; - -/** - * PayloadCmdSize - * Value that shall be used - */ -#define SHCI_C2_CONFIG_PAYLOAD_CMD_SIZE (sizeof(SHCI_C2_CONFIG_Cmd_Param_t) - 1) - -/** - * Config1 - * Each definition below may be added together to build the Config1 value - * WARNING : Only one definition per bit shall be added to build the Config1 value - */ -#define SHCI_C2_CONFIG_CONFIG1_BIT0_BLE_NVM_DATA_TO_INTERNAL_FLASH (0<<0) -#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) - -/** - * EvtMask1 - * Each definition below may be added together to build the EvtMask1 value - */ -#define SHCI_C2_CONFIG_EVTMASK1_BIT0_ERROR_NOTIF_ENABLE (1<<0) -#define SHCI_C2_CONFIG_EVTMASK1_BIT1_BLE_NVM_RAM_UPDATE_ENABLE (1<<1) -#define SHCI_C2_CONFIG_EVTMASK1_BIT2_OT_NVM_RAM_UPDATE_ENABLE (1<<2) -#define SHCI_C2_CONFIG_EVTMASK1_BIT3_NVM_START_WRITE_ENABLE (1<<3) -#define SHCI_C2_CONFIG_EVTMASK1_BIT4_NVM_END_WRITE_ENABLE (1<<4) -#define SHCI_C2_CONFIG_EVTMASK1_BIT5_NVM_START_ERASE_ENABLE (1<<5) -#define SHCI_C2_CONFIG_EVTMASK1_BIT6_NVM_END_ERASE_ENABLE (1<<6) - -/** - * BleNvmRamAddress - * The buffer shall have a size of BLE_NVM_SRAM_SIZE number of 32bits - * The buffer shall be allocated in SRAM2 - */ -#define BLE_NVM_SRAM_SIZE (507) - -/** - * ThreadNvmRamAddress - * The buffer shall have a size of THREAD_NVM_SRAM_SIZE number of 32bits - * The buffer shall be allocated in SRAM2 - */ -#define THREAD_NVM_SRAM_SIZE (1016) - - -/** No response parameters*/ - -/* Exported type --------------------------------------------------------*/ - -typedef MB_WirelessFwInfoTable_t SHCI_WirelessFwInfoTable_t; - -/* - * At startup, the information relative to the wireless binary are stored in RAM through a structure defined by - * SHCI_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) - * each of those coded on 32 bits as shown on the table below: - * - * - * |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 | - * ------------------------------------------------------------------------------------------------- - * Version | Major version | Minor version | Sub version | Branch |Release Type| - * ------------------------------------------------------------------------------------------------- - * MemorySize | SRAM2B (kB) | SRAM2A (kB) | SRAM1 (kB) | FLASH (4kb) | - * ------------------------------------------------------------------------------------------------- - * Info stack | Reserved | Reserved | Reserved | Type (MAC,Thread,BLE) | - * ------------------------------------------------------------------------------------------------- - * Reserved | Reserved | Reserved | Reserved | Reserved | - * ------------------------------------------------------------------------------------------------- - * - */ - -/* Field Version */ -#define INFO_VERSION_MAJOR_OFFSET 24 -#define INFO_VERSION_MAJOR_MASK 0xff000000 -#define INFO_VERSION_MINOR_OFFSET 16 -#define INFO_VERSION_MINOR_MASK 0x00ff0000 -#define INFO_VERSION_SUB_OFFSET 8 -#define INFO_VERSION_SUB_MASK 0x0000ff00 -#define INFO_VERSION_BRANCH_OFFSET 4 -#define INFO_VERSION_BRANCH_MASK 0x0000000f0 -#define INFO_VERSION_TYPE_OFFSET 0 -#define INFO_VERSION_TYPE_MASK 0x00000000f - -#define INFO_VERSION_TYPE_RELEASE 1 - -/* Field Memory */ -#define INFO_SIZE_SRAM2B_OFFSET 24 -#define INFO_SIZE_SRAM2B_MASK 0xff000000 -#define INFO_SIZE_SRAM2A_OFFSET 16 -#define INFO_SIZE_SRAM2A_MASK 0x00ff0000 -#define INFO_SIZE_SRAM1_OFFSET 8 -#define INFO_SIZE_SRAM1_MASK 0x0000ff00 -#define INFO_SIZE_FLASH_OFFSET 0 -#define INFO_SIZE_FLASH_MASK 0x000000ff - -/* Field stack information */ -#define INFO_STACK_TYPE_OFFSET 0 -#define INFO_STACK_TYPE_MASK 0x000000ff -#define INFO_STACK_TYPE_NONE 0 - -#define INFO_STACK_TYPE_BLE_STANDARD 0x01 -#define INFO_STACK_TYPE_BLE_HCI 0x02 -#define INFO_STACK_TYPE_BLE_LIGHT 0x03 -#define INFO_STACK_TYPE_THREAD_FTD 0x10 -#define INFO_STACK_TYPE_THREAD_MTD 0x11 -#define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 -#define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 -#define INFO_STACK_TYPE_BLE_PHY_VALID 0x62 -#define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 -#define INFO_STACK_TYPE_BLE_RLV 0x64 -#define INFO_STACK_TYPE_RLV 0x80 - -typedef struct { - /** - * Wireless Info - */ - uint8_t VersionMajor; - uint8_t VersionMinor; - uint8_t VersionSub; - uint8_t VersionBranch; - uint8_t VersionReleaseType; - uint8_t MemorySizeSram2B; /*< Multiple of 1K */ - uint8_t MemorySizeSram2A; /*< Multiple of 1K */ - uint8_t MemorySizeSram1; /*< Multiple of 1K */ - uint8_t MemorySizeFlash; /*< Multiple of 4K */ - uint8_t StackType; - /** - * Fus Info - */ - uint8_t FusVersionMajor; - uint8_t FusVersionMinor; - uint8_t FusVersionSub; - uint8_t FusMemorySizeSram2B; /*< Multiple of 1K */ - uint8_t FusMemorySizeSram2A; /*< Multiple of 1K */ - uint8_t FusMemorySizeFlash; /*< Multiple of 4K */ -} WirelessFwInfo_t; - - -/* Exported functions ------------------------------------------------------- */ - -/** - * For all SHCI_C2_FUS_xxx() command: - * When the wireless FW is running on the CPU2, the command returns SHCI_FUS_CMD_NOT_SUPPORTED - * When any FUS command is sent after the SHCI_FUS_CMD_NOT_SUPPORTED has been received, - * the CPU2 switches on the RSS ( This reboots automatically the device ) - */ -/** -* SHCI_C2_FUS_GetState -* @brief Read the FUS State -* If the user is not interested by the Error code response, a null value may -* be passed as parameter -* -* @param p_rsp : return the error code when the FUS State Value = 0xFF -* @retval FUS State Values -*/ -uint8_t SHCI_C2_FUS_GetState(SHCI_FUS_GetState_ErrorCode_t *p_rsp); - -/** -* SHCI_C2_FUS_FwUpgrade -* @brief Request the FUS to install the CPU2 firmware update -* -* @param fw_src_add: Address of the firmware image location -* @param fw_dest_add: Address of the firmware destination -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade(uint32_t fw_src_add, uint32_t fw_dest_add); - -/** -* SHCI_C2_FUS_FwDelete -* @brief Delete the wireless stack on CPU2 -* -* @param None -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete(void); - -/** -* SHCI_C2_FUS_UpdateAuthKey -* @brief Request the FUS to update the authentication key -* -* @param pCmdPacket -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey(SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t *pParam); - -/** -* SHCI_C2_FUS_LockAuthKey -* @brief Request the FUS to prevent any future update of the authentication key -* -* @param None -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey(void); - -/** -* SHCI_C2_FUS_StoreUsrKey -* @brief Request the FUS to store the user key -* -* @param pParam : command parameter -* @param p_key_index : Index allocated by the FUS to the stored key -* -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey(SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *pParam, uint8_t *p_key_index); - -/** -* SHCI_C2_FUS_LoadUsrKey -* @brief Request the FUS to load the user key into the AES -* -* @param key_index : index of the user key to load in AES1 -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey(uint8_t key_index); - -/** -* SHCI_C2_FUS_StartWs -* @brief Request the FUS to reboot on the wireless stack -* -* @param None -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_StartWs(void); - -/** -* SHCI_C2_FUS_LockUsrKey -* @brief Request the FUS to lock the user key so that it cannot be updated later on -* -* @param key_index : index of the user key to lock -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey(uint8_t key_index); - -/** -* SHCI_C2_BLE_Init -* @brief Provides parameters and starts the BLE Stack -* -* @param pCmdPacket : Parameters to be provided to the BLE Stack -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_BLE_Init(SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket); - -/** -* SHCI_C2_THREAD_Init -* @brief Starts the THREAD Stack -* -* @param None -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_THREAD_Init(void); - -/** -* SHCI_C2_LLDTESTS_Init -* @brief Starts the LLD tests CLI -* -* @param param_size : Nb of bytes -* @param p_param : pointer with data to give from M4 to M0 -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init(uint8_t param_size, uint8_t *p_param); - -/** -* SHCI_C2_LLD_BLE_Init -* @brief Starts the LLD tests CLI -* -* @param param_size : Nb of bytes -* @param p_param : pointer with data to give from M4 to M0 -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init(uint8_t param_size, uint8_t *p_param); - -/** -* SHCI_C2_DEBUG_Init -* @brief Starts the Traces -* -* @param None -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_DEBUG_Init(SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket); - -/** -* SHCI_C2_FLASH_EraseActivity -* @brief Provides the information of the start and the end of a flash erase window on the CPU1 -* -* @param erase_activity: Start/End of erase activity -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity(SHCI_EraseActivity_t erase_activity); - -/** -* SHCI_C2_CONCURRENT_SetMode -* @brief Enable/Disable Thread on CPU2 (M0+) -* -* @param Mode: BLE or Thread enable flag -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode(SHCI_C2_CONCURRENT_Mode_Param_t Mode); - -/** -* SHCI_C2_FLASH_StoreData -* @brief Store Data in Flash -* -* @param Ip: BLE or THREAD -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData(SHCI_C2_FLASH_Ip_t Ip); - -/** -* SHCI_C2_FLASH_EraseData -* @brief Erase Data in Flash -* -* @param Ip: BLE or THREAD -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData(SHCI_C2_FLASH_Ip_t Ip); - -/** -* SHCI_C2_RADIO_AllowLowPower -* @brief Allow or forbid IP_radio (802_15_4 or BLE) to enter in low power mode. -* -* @param Ip: BLE or 802_15_5 -* @param FlagRadioLowPowerOn: True or false -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower(SHCI_C2_FLASH_Ip_t Ip, uint8_t FlagRadioLowPowerOn); - -/** - * SHCI_GetWirelessFwInfo - * @brief This function read back the information relative to the wireless binary loaded. - * Refer yourself to SHCI_WirelessFwInfoTable_t structure to get the significance - * of the different parameters returned. - * @param pWirelessInfo : Pointer to WirelessFwInfo_t. - * - * @retval SHCI_Success - */ -SHCI_CmdStatus_t SHCI_GetWirelessFwInfo(WirelessFwInfo_t *pWirelessInfo); - -/** -* SHCI_C2_Reinit -* @brief This is required to allow the CPU1 to fake a set C2BOOT when it has already been set. -* In order to fake a C2BOOT, the CPU1 shall : -* - Send SHCI_C2_Reinit() -* - call SEV instruction -* WARNING: -* This function is intended to be used by the SBSFU -* -* @param None -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_Reinit(void); - -/** -* SHCI_C2_ExtpaConfig -* @brief Send the Ext PA configuration -* When the CPU2 receives the command, it controls the Ext PA as requested by the configuration -* This configures only which IO is used to enable/disable the ExtPA and the associated polarity -* This command has no effect on the other IO that is used to control the mode of the Ext PA (Rx/Tx) -* -* @param gpio_port: GPIOx where x can be (A..F) to select the GPIO peripheral for STM32WBxx family -* @param gpio_pin_number: This parameter can be one of GPIO_PIN_x (= LL_GPIO_PIN_x) where x can be (0..15). -* @param gpio_polarity: This parameter can be either -* - EXT_PA_ENABLED_LOW: ExtPA is enabled when GPIO is low -* - EXT_PA_ENABLED_HIGH: ExtPA is enabled when GPIO is high -* @param gpio_status: This parameter can be either -* - EXT_PA_DISABLED: Stop driving the ExtPA -* - EXT_PA_ENABLED: Drive the ExtPA according to radio activity -* (ON before the Event and OFF at the end of the event) -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_number, uint8_t gpio_polarity, uint8_t gpio_status); - -/** -* SHCI_C2_SetFlashActivityControl -* @brief Set the mechanism to be used on CPU2 to prevent the CPU1 to either write or erase in flash -* -* @param Source: It can be one of the following list -* - FLASH_ACTIVITY_CONTROL_PES : The CPU2 set the PES bit to prevent the CPU1 to either read or write in flash -* - FLASH_ACTIVITY_CONTROL_SEM7 : The CPU2 gets the semaphore 7 to prevent the CPU1 to either read or write in flash. -* This requires the CPU1 to first get semaphore 7 before erasing or writing the flash. -* -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t Source); - -/** -* SHCI_C2_Config -* @brief Send the system configuration to the CPU2 -* -* @param pCmdPacket: address of the buffer holding following parameters -* uint8_t PayloadCmdSize : Size of the payload - shall be SHCI_C2_CONFIG_PAYLOAD_CMD_SIZE -* uint8_t Config1 : -* - bit0 : 0 - BLE NVM Data data are flushed in internal secure flash -* 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 -* 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) -* ... -* bit31 : Asynchronous Event with Sub Evt Code 0x9220 -* uint8_t Spare1 : Unused, shall be set to 0 -* uint32_t BleNvmRamAddress : -* Only considered when Config1.bit0 = 1 -* When set to 0, data are kept in internal SRAM on CPU2 -* Otherwise, data are copied in the cache pointed by BleNvmRamAddress -* The size of the buffer shall be BLE_NVM_SRAM_SIZE (number of 32bits) -* The buffer shall be allocated in SRAM2 -* uint32_t ThreadNvmRamAddress : -* Only considered when Config1.bit1 = 1 -* When set to 0, data are kept in internal SRAM on CPU2 -* Otherwise, data are copied in the cache pointed by ThreadNvmRamAddress -* The size of the buffer shall be THREAD_NVM_SRAM_SIZE (number of 32bits) -* The buffer shall be allocated in SRAM2 -* -* Please check macro definition to be used for this function -* They are defined in this file next to the definition of SHCI_OPCODE_C2_CONFIG -* -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket); - -#ifdef __cplusplus -} -#endif - -#endif /*__SHCI_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c deleted file mode 100644 index 1ab15b47..00000000 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ /dev/null @@ -1,344 +0,0 @@ -/** - ****************************************************************************** - * @file shci.c - * @author MCD Application Team - * @brief System HCI command implementation - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -#if defined(STM32WBxx) -/* Includes ------------------------------------------------------------------*/ -#include "stm32_wpan_common.h" - -#include "stm_list.h" -#include "shci_tl.h" -#include "stm32_def.h" - -/** - * These traces are not yet supported in an usual way in the delivery package - * They can enabled by adding the definition of TL_SHCI_CMD_DBG_EN and/or TL_SHCI_EVT_DBG_EN in the preprocessor option in the IDE - */ -#if ( (TL_SHCI_CMD_DBG_EN != 0) || (TL_SHCI_EVT_DBG_EN != 0) ) - #include "app_conf.h" - #include "dbg_trace.h" -#endif - -#if (TL_SHCI_CMD_DBG_EN != 0) - #define TL_SHCI_CMD_DBG_MSG PRINT_MESG_DBG - #define TL_SHCI_CMD_DBG_BUF PRINT_LOG_BUFF_DBG -#else - #define TL_SHCI_CMD_DBG_MSG(...) - #define TL_SHCI_CMD_DBG_BUF(...) -#endif - -#if (TL_SHCI_EVT_DBG_EN != 0) - #define TL_SHCI_EVT_DBG_MSG PRINT_MESG_DBG - #define TL_SHCI_EVT_DBG_BUF PRINT_LOG_BUFF_DBG -#else - #define TL_SHCI_EVT_DBG_MSG(...) - #define TL_SHCI_EVT_DBG_BUF(...) -#endif - -/* Private typedef -----------------------------------------------------------*/ -typedef enum { - SHCI_TL_CMD_RESP_RELEASE, - SHCI_TL_CMD_RESP_WAIT, -} SHCI_TL_CmdRespStatus_t; - -/* Private defines -----------------------------------------------------------*/ -/** - * The default System HCI layer timeout is set to 33s - */ -#define SHCI_TL_DEFAULT_TIMEOUT (33000) - -/* Private macros ------------------------------------------------------------*/ -/* Public variables ---------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/** - * START of Section SYSTEM_DRIVER_CONTEXT - */ -PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") static tListNode SHciAsynchEventQueue; -PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") static volatile SHCI_TL_CmdStatus_t SHCICmdStatus; -PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") static TL_CmdPacket_t *pCmdBuffer; -PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") SHCI_TL_UserEventFlowStatus_t SHCI_TL_UserEventFlow; -/** - * END of Section SYSTEM_DRIVER_CONTEXT - */ - -static tSHciContext shciContext; -static void (* StatusNotCallBackFunction)(SHCI_TL_CmdStatus_t status); - -static volatile SHCI_TL_CmdRespStatus_t CmdRspStatusFlag; - -/* Private function prototypes -----------------------------------------------*/ -static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus); -static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt); -static void TlUserEvtReceived(TL_EvtPacket_t *shcievt); -static void TlInit(TL_CmdPacket_t *p_cmdbuffer); -static void OutputCmdTrace(TL_CmdPacket_t *pCmdBuffer); -static void OutputRspTrace(TL_EvtPacket_t *p_rsp); -static void OutputEvtTrace(TL_EvtPacket_t *phcievtbuffer); - -/* Interface ------- ---------------------------------------------------------*/ -void shci_init(void(* UserEvtRx)(void *pData), void *pConf) -{ - StatusNotCallBackFunction = ((SHCI_TL_HciInitConf_t *)pConf)->StatusNotCallBack; - shciContext.UserEvtRx = UserEvtRx; - - shci_register_io_bus(&shciContext.io); - - TlInit((TL_CmdPacket_t *)(((SHCI_TL_HciInitConf_t *)pConf)->p_cmdbuffer)); - - return; -} - -void shci_user_evt_proc(void) -{ - TL_EvtPacket_t *phcievtbuffer; - tSHCI_UserEvtRxParam UserEvtRxParam; - - /** - * Up to release version v1.2.0, a while loop was implemented to read out events from the queue as long as - * it is not empty. However, in a bare metal implementation, this leads to calling in a "blocking" mode - * shci_user_evt_proc() as long as events are received without giving the opportunity to run other tasks - * in the background. - * From now, the events are reported one by one. When it is checked there is still an event pending in the queue, - * a request to the user is made to call again shci_user_evt_proc(). - * This gives the opportunity to the application to run other background tasks between each event. - */ - - /** - * It is more secure to use LST_remove_head()/LST_insert_head() compare to LST_get_next_node()/LST_remove_node() - * in case the user overwrite the header where the next/prev pointers are located - */ - if ((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable)) { - LST_remove_head(&SHciAsynchEventQueue, (tListNode **)&phcievtbuffer); - - OutputEvtTrace(phcievtbuffer); - - if (shciContext.UserEvtRx != NULL) { - UserEvtRxParam.pckt = phcievtbuffer; - UserEvtRxParam.status = SHCI_TL_UserEventFlow_Enable; - shciContext.UserEvtRx((void *)&UserEvtRxParam); - SHCI_TL_UserEventFlow = UserEvtRxParam.status; - } else { - SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable; - } - - if (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable) { - TL_MM_EvtDone(phcievtbuffer); - } else { - /** - * put back the event in the queue - */ - LST_insert_head(&SHciAsynchEventQueue, (tListNode *)phcievtbuffer); - } - } - - if ((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable)) { - shci_notify_asynch_evt((void *) &SHciAsynchEventQueue); - } - - return; -} - -void shci_resume_flow(void) -{ - SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable; - - /** - * It is better to go through the background process as it is not sure from which context this API may - * be called - */ - shci_notify_asynch_evt((void *) &SHciAsynchEventQueue); - - return; -} - -void shci_send(uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t *p_cmd_payload, TL_EvtPacket_t *p_rsp) -{ - Cmd_SetStatus(SHCI_TL_CmdBusy); - - pCmdBuffer->cmdserial.cmd.cmdcode = cmd_code; - pCmdBuffer->cmdserial.cmd.plen = len_cmd_payload; - - memcpy(pCmdBuffer->cmdserial.cmd.payload, p_cmd_payload, len_cmd_payload); - - OutputCmdTrace(pCmdBuffer); - - shciContext.io.Send(0, 0); - - shci_cmd_resp_wait(SHCI_TL_DEFAULT_TIMEOUT); - - /** - * The command complete of a system command does not have the header - * It starts immediately with the evtserial field - */ - memcpy(&(p_rsp->evtserial), pCmdBuffer, ((TL_EvtSerial_t *)pCmdBuffer)->evt.plen + TL_EVT_HDR_SIZE); - - OutputRspTrace(p_rsp); - - Cmd_SetStatus(SHCI_TL_CmdAvailable); - - 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) -{ - TL_SYS_InitConf_t Conf; - - pCmdBuffer = p_cmdbuffer; - - LST_init_head(&SHciAsynchEventQueue); - - Cmd_SetStatus(SHCI_TL_CmdAvailable); - - SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable; - - /* Initialize low level driver */ - if (shciContext.io.Init) { - - Conf.p_cmdbuffer = (uint8_t *)p_cmdbuffer; - Conf.IoBusCallBackCmdEvt = TlCmdEvtReceived; - Conf.IoBusCallBackUserEvt = TlUserEvtReceived; - shciContext.io.Init(&Conf); - } - - return; -} - -static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus) -{ - if (shcicmdstatus == SHCI_TL_CmdBusy) { - if (StatusNotCallBackFunction != 0) { - StatusNotCallBackFunction(SHCI_TL_CmdBusy); - } - SHCICmdStatus = SHCI_TL_CmdBusy; - } else { - SHCICmdStatus = SHCI_TL_CmdAvailable; - if (StatusNotCallBackFunction != 0) { - StatusNotCallBackFunction(SHCI_TL_CmdAvailable); - } - } - - return; -} - -static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt) -{ - (void)(shcievt); - shci_cmd_resp_release(0); /**< Notify the application the Cmd response has been received */ - - return; -} - -static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) -{ - LST_insert_tail(&SHciAsynchEventQueue, (tListNode *)shcievt); - shci_notify_asynch_evt((void *) &SHciAsynchEventQueue); /**< Notify the application a full HCI event has been received */ - - return; -} - -static void OutputCmdTrace(TL_CmdPacket_t *pCmdBuffer) -{ - TL_SHCI_CMD_DBG_MSG("sys cmd: 0x%04X", pCmdBuffer->cmdserial.cmd.cmdcode); - - if (pCmdBuffer->cmdserial.cmd.plen != 0) { - TL_SHCI_CMD_DBG_MSG(" payload:"); - TL_SHCI_CMD_DBG_BUF(pCmdBuffer->cmdserial.cmd.payload, pCmdBuffer->cmdserial.cmd.plen, ""); - } - TL_SHCI_CMD_DBG_MSG("\r\n"); - - return; -} - -static void OutputRspTrace(TL_EvtPacket_t *p_rsp) -{ - switch (p_rsp->evtserial.evt.evtcode) { - case TL_BLEEVT_CC_OPCODE: - TL_SHCI_CMD_DBG_MSG("sys rsp: 0x%02X", p_rsp->evtserial.evt.evtcode); - TL_SHCI_CMD_DBG_MSG(" cmd opcode: 0x%02X", ((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->cmdcode); - TL_SHCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); - if ((p_rsp->evtserial.evt.plen - 4) != 0) { - TL_SHCI_CMD_DBG_MSG(" payload:"); - TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[1], p_rsp->evtserial.evt.plen - 4, ""); - } - break; - - default: - TL_SHCI_CMD_DBG_MSG("unknown sys rsp received: %02X", p_rsp->evtserial.evt.evtcode); - break; - } - - TL_SHCI_CMD_DBG_MSG("\r\n"); - - return; -} - -static void OutputEvtTrace(TL_EvtPacket_t *phcievtbuffer) -{ - if (phcievtbuffer->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) { - TL_SHCI_EVT_DBG_MSG("unknown sys evt received: %02X", phcievtbuffer->evtserial.evt.evtcode); - } else { - TL_SHCI_EVT_DBG_MSG("sys evt: 0x%02X", phcievtbuffer->evtserial.evt.evtcode); - TL_SHCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t *)(phcievtbuffer->evtserial.evt.payload))->subevtcode); - if ((phcievtbuffer->evtserial.evt.plen - 2) != 0) { - TL_SHCI_EVT_DBG_MSG(" payload:"); - TL_SHCI_EVT_DBG_BUF(((TL_AsynchEvt_t *)(phcievtbuffer->evtserial.evt.payload))->payload, phcievtbuffer->evtserial.evt.plen - 2, ""); - } - } - - TL_SHCI_EVT_DBG_MSG("\r\n"); - - return; -} - -/* Weak implementation ----------------------------------------------------------------*/ -__WEAK void shci_cmd_resp_wait(uint32_t timeout) -{ - (void)timeout; - - CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; - while (CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); - - return; -} - -__WEAK void shci_cmd_resp_release(uint32_t flag) -{ - (void)flag; - - CmdRspStatusFlag = SHCI_TL_CMD_RESP_RELEASE; - - return; -} - -#endif /* STM32WBxx */ - diff --git a/src/utility/STM32Cube_FW/shci_tl.h b/src/utility/STM32Cube_FW/shci_tl.h deleted file mode 100644 index f6cc8043..00000000 --- a/src/utility/STM32Cube_FW/shci_tl.h +++ /dev/null @@ -1,169 +0,0 @@ -/** - ****************************************************************************** - * @file shci_tl.h - * @author MCD Application Team - * @brief System HCI command header for the system channel - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - - -#ifndef __SHCI_TL_H_ -#define __SHCI_TL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "tl.h" - -/* Exported defines -----------------------------------------------------------*/ -typedef enum { - SHCI_TL_UserEventFlow_Disable, - SHCI_TL_UserEventFlow_Enable, -} SHCI_TL_UserEventFlowStatus_t; - -typedef enum { - SHCI_TL_CmdBusy, - SHCI_TL_CmdAvailable -} SHCI_TL_CmdStatus_t; - -/** - * @brief Structure used to manage the BUS IO operations. - * All the structure fields will point to functions defined at user level. - * @{ - */ -typedef struct { - int32_t (* Init)(void *pConf); /**< Pointer to SHCI TL function for the IO Bus initialization */ - int32_t (* DeInit)(void); /**< Pointer to SHCI TL function for the IO Bus de-initialization */ - int32_t (* Reset)(void); /**< Pointer to SHCI TL function for the IO Bus reset */ - int32_t (* Receive)(uint8_t *, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data reception */ - int32_t (* Send)(uint8_t *, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data transmission */ - int32_t (* DataAck)(uint8_t *, uint16_t *len); /**< Pointer to SHCI TL function for the IO Bus data ack reception */ - int32_t (* GetTick)(void); /**< Pointer to BSP function for getting the HAL time base timestamp */ -} tSHciIO; -/** - * @} - */ - -/** - * @brief Contain the SHCI context - * @{ - */ -typedef struct { - tSHciIO io; /**< Manage the BUS IO operations */ - void (* UserEvtRx)(void *pData); /**< User System events callback function pointer */ -} tSHciContext; - -typedef struct { - SHCI_TL_UserEventFlowStatus_t status; - TL_EvtPacket_t *pckt; -} tSHCI_UserEvtRxParam; - -typedef struct { - uint8_t *p_cmdbuffer; - void (* StatusNotCallBack)(SHCI_TL_CmdStatus_t status); -} SHCI_TL_HciInitConf_t; - -/** - * shci_send - * @brief Send an System HCI Command - * - * @param : cmd_code = Opcode of the command - * @param : len_cmd_payload = Length of the command payload - * @param : p_cmd_payload = Address of the command payload - * @param : p_rsp_status = Address of the full buffer holding the command complete event - * @retval : None - */ -void shci_send(uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t *p_cmd_payload, TL_EvtPacket_t *p_rsp_status); - -/** - * @brief Register IO bus services. - * @param fops The SHCI IO structure managing the IO BUS - * @retval None - */ -void shci_register_io_bus(tSHciIO *fops); - -/** - * @brief Interrupt service routine that must be called when the system channel - * reports a packet has been received - * - * @param pdata Packet or event pointer - * @retval None - */ -void shci_notify_asynch_evt(void *pdata); - -/** - * @brief This function resume the User Event Flow which has been stopped on return - * from UserEvtRx() when the User Event has not been processed. - * - * @param None - * @retval None - */ -void shci_resume_flow(void); - - -/** - * @brief This function is called when an System HCI Command is sent to the CPU2 and the response is waited. - * It is called from the same context the System HCI command has been sent. - * It shall not return until the command response notified by shci_cmd_resp_release() is received. - * A weak implementation is available in shci_tl.c based on polling mechanism - * The user may re-implement this function in the application to improve performance : - * - It may use UTIL_SEQ_WaitEvt() API when using the Sequencer - * - It may use a semaphore when using cmsis_os interface - * - * @param timeout: Waiting timeout - * @retval None - */ -void shci_cmd_resp_wait(uint32_t timeout); - -/** - * @brief This function is called when an System HCI command is received from the CPU2. - * A weak implementation is available in shci_tl.c based on polling mechanism - * The user may re-implement this function in the application to improve performance : - * - It may use UTIL_SEQ_SetEvt() API when using the Sequencer - * - It may use a semaphore when using cmsis_os interface - * - * - * @param flag: Release flag - * @retval None - */ -void shci_cmd_resp_release(uint32_t flag); - - -/** - * @brief This process shall be called each time the shci_notify_asynch_evt notification is received - * - * @param None - * @retval None - */ - -void shci_user_evt_proc(void); - -/** - * @brief Initialize the System Host Controller Interface. - * This function must be called before any communication on the System Channel - * - * @param pData: System events callback function pointer - * This callback is triggered when an user event is received on - * the System Channel from CPU2. - * @param pConf: Configuration structure pointer - * @retval None - */ -void shci_init(void(* UserEvtRx)(void *pData), void *pConf); - -#ifdef __cplusplus -} -#endif - -#endif /* __SHCI_TL_H_ */ diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h deleted file mode 100644 index 12f1a583..00000000 --- a/src/utility/STM32Cube_FW/stm32_wpan_common.h +++ /dev/null @@ -1,143 +0,0 @@ -/** - ****************************************************************************** - * @file stm32_wpan_common.h - * @author MCD Application Team - * @brief Common file to utilities - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2018 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM32_WPAN_COMMON_H -#define __STM32_WPAN_COMMON_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define __ASM __asm /*!< asm keyword for GNU Compiler */ -#define __INLINE inline /*!< inline keyword for GNU Compiler */ -#define __STATIC_INLINE static inline - -#include -#include -#include -#include -#include -#include "cmsis_compiler.h" - -/* -------------------------------- * - * Basic definitions * - * -------------------------------- */ - -#undef NULL -#define NULL 0U - -#undef FALSE -#define FALSE 0U - -#undef TRUE -#define TRUE (!0U) - -/* -------------------------------- * - * Critical Section definition * - * -------------------------------- */ -#undef BACKUP_PRIMASK -#define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK() - -#undef DISABLE_IRQ -#define DISABLE_IRQ() __disable_irq() - -#undef RESTORE_PRIMASK -#define RESTORE_PRIMASK() __set_PRIMASK(primask_bit) - -/* -------------------------------- * - * Macro delimiters * - * -------------------------------- */ -#undef M_BEGIN -#define M_BEGIN do { - -#undef M_END -#define M_END } while(0) - -/* -------------------------------- * - * Some useful macro definitions * - * -------------------------------- */ -#undef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - -#undef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) - -#undef MODINC -#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END - -#undef MODDEC -#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END - -#undef MODADD -#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END - -#undef MODSUB -#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m ) - -#undef ALIGN -#ifdef WIN32 -#define ALIGN(n) -#else -#define ALIGN(n) __attribute__((aligned(n))) -#endif - -#undef PAUSE -#define PAUSE( t ) M_BEGIN \ - volatile int _i; \ - for ( _i = t; _i > 0; _i -- ); \ - M_END -#undef DIVF -#define DIVF( x, y ) ((x)/(y)) - -#undef DIVC -#define DIVC( x, y ) (((x)+(y)-1)/(y)) - -#undef DIVR -#define DIVR( x, y ) (((x)+((y)/2))/(y)) - -#undef SHRR -#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1) - -#undef BITN -#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1) - -#undef BITNSET -#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END - -/* -------------------------------- * - * Section attribute * - * -------------------------------- */ -#undef PLACE_IN_SECTION -#define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__))) - -/* ----------------------------------- * - * Packed usage (compiler dependent) * - * ----------------------------------- */ -#undef PACKED_STRUCT -#define PACKED_STRUCT struct __packed - -#ifdef __cplusplus -} -#endif - -#endif /*__STM32_WPAN_COMMON_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c deleted file mode 100644 index 509b2b57..00000000 --- a/src/utility/STM32Cube_FW/stm_list.c +++ /dev/null @@ -1,206 +0,0 @@ -/** - ****************************************************************************** - * @file stm_list.c - * @author MCD Application Team - * @brief TCircular Linked List Implementation. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -#if defined(STM32WBxx) -/****************************************************************************** - * Include Files - ******************************************************************************/ -#include "stm_list.h" -#include "cmsis_gcc.h" -#include "stm32_wpan_common.h" - -/****************************************************************************** - * Function Definitions - ******************************************************************************/ -void LST_init_head(tListNode *listHead) -{ - listHead->next = listHead; - listHead->prev = listHead; -} - -bool LST_is_empty(tListNode *listHead) -{ - uint32_t primask_bit; - bool return_value; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - if (listHead->next == listHead) { - return_value = TRUE; - } else { - return_value = FALSE; - } - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ - - return return_value; -} - -void LST_insert_head(tListNode *listHead, tListNode *node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = listHead->next; - node->prev = listHead; - listHead->next = node; - (node->next)->prev = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_insert_tail(tListNode *listHead, tListNode *node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = listHead; - node->prev = listHead->prev; - listHead->prev = node; - (node->prev)->next = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_remove_node(tListNode *node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - (node->prev)->next = node->next; - (node->next)->prev = node->prev; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_remove_head(tListNode *listHead, tListNode **node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = listHead->next; - LST_remove_node(listHead->next); - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_remove_tail(tListNode *listHead, tListNode **node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = listHead->prev; - LST_remove_node(listHead->prev); - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_insert_node_after(tListNode *node, tListNode *ref_node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = ref_node->next; - node->prev = ref_node; - ref_node->next = node; - (node->next)->prev = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_insert_node_before(tListNode *node, tListNode *ref_node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = ref_node; - node->prev = ref_node->prev; - ref_node->prev = node; - (node->prev)->next = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -int LST_get_size(tListNode *listHead) -{ - int size = 0; - tListNode *temp; - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - temp = listHead->next; - while (temp != listHead) { - size++; - temp = temp->next; - } - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ - - return (size); -} - -void LST_get_next_node(tListNode *ref_node, tListNode **node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = ref_node->next; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_get_prev_node(tListNode *ref_node, tListNode **node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = ref_node->prev; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - -#endif /* STM32WBxx */ - diff --git a/src/utility/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h deleted file mode 100644 index b5f1cc8d..00000000 --- a/src/utility/STM32Cube_FW/stm_list.h +++ /dev/null @@ -1,58 +0,0 @@ -/** - ****************************************************************************** - * @file stm_list.h - * @author MCD Application Team - * @brief Header file for linked list library. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - - -#ifndef _STM_LIST_H_ -#define _STM_LIST_H_ - -/* Includes ------------------------------------------------------------------*/ - -#include "stdint.h" -#include "stdbool.h" - -typedef struct _tListNode { - struct _tListNode *next; - struct _tListNode *prev; -} tListNode; - -void LST_init_head(tListNode *listHead); - -bool LST_is_empty(tListNode *listHead); - -void LST_insert_head(tListNode *listHead, tListNode *node); - -void LST_insert_tail(tListNode *listHead, tListNode *node); - -void LST_remove_node(tListNode *node); - -void LST_remove_head(tListNode *listHead, tListNode **node); - -void LST_remove_tail(tListNode *listHead, tListNode **node); - -void LST_insert_node_after(tListNode *node, tListNode *ref_node); - -void LST_insert_node_before(tListNode *node, tListNode *ref_node); - -int LST_get_size(tListNode *listHead); - -void LST_get_next_node(tListNode *ref_node, tListNode **node); - -void LST_get_prev_node(tListNode *ref_node, tListNode **node); - -#endif /* _STM_LIST_H_ */ diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h deleted file mode 100644 index f8abf288..00000000 --- a/src/utility/STM32Cube_FW/tl.h +++ /dev/null @@ -1,294 +0,0 @@ -/** - ****************************************************************************** - * @file tl.h - * @author MCD Application Team - * @brief Header for tl module - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __TL_H -#define __TL_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Includes ------------------------------------------------------------------*/ -#include "stm32_wpan_common.h" - -/* Exported defines -----------------------------------------------------------*/ -#define TL_BLECMD_PKT_TYPE ( 0x01 ) -#define TL_ACL_DATA_PKT_TYPE ( 0x02 ) -#define TL_BLEEVT_PKT_TYPE ( 0x04 ) -#define TL_OTCMD_PKT_TYPE ( 0x08 ) -#define TL_OTRSP_PKT_TYPE ( 0x09 ) -#define TL_CLICMD_PKT_TYPE ( 0x0A ) -#define TL_OTNOT_PKT_TYPE ( 0x0C ) -#define TL_OTACK_PKT_TYPE ( 0x0D ) -#define TL_CLINOT_PKT_TYPE ( 0x0E ) -#define TL_CLIACK_PKT_TYPE ( 0x0F ) -#define TL_SYSCMD_PKT_TYPE ( 0x10 ) -#define TL_SYSRSP_PKT_TYPE ( 0x11 ) -#define TL_SYSEVT_PKT_TYPE ( 0x12 ) -#define TL_CLIRESP_PKT_TYPE ( 0x15 ) -#define TL_M0CMD_PKT_TYPE ( 0x16 ) -#define TL_LOCCMD_PKT_TYPE ( 0x20 ) -#define TL_LOCRSP_PKT_TYPE ( 0x21 ) -#define TL_TRACES_APP_PKT_TYPE ( 0x40 ) -#define TL_TRACES_WL_PKT_TYPE ( 0x41 ) - -#define TL_CMD_HDR_SIZE (4) -#define TL_EVT_HDR_SIZE (3) -#define TL_EVT_CS_PAYLOAD_SIZE (4) - -#define TL_BLEEVT_CC_OPCODE (0x0E) -#define TL_BLEEVT_CS_OPCODE (0x0F) -#define TL_BLEEVT_VS_OPCODE (0xFF) - -#define TL_BLEEVT_CS_PACKET_SIZE (TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)) -#define TL_BLEEVT_CS_BUFFER_SIZE (sizeof(TL_PacketHeader_t) + TL_BLEEVT_CS_PACKET_SIZE) - -/* Exported types ------------------------------------------------------------*/ -/**< Packet header */ -typedef PACKED_STRUCT { - uint32_t *next; - uint32_t *prev; -} TL_PacketHeader_t; - -/******************************************************************************* - * Event type - */ - -/** - * This the payload of TL_Evt_t for a command status event - */ -typedef PACKED_STRUCT { - uint8_t status; - uint8_t numcmd; - uint16_t cmdcode; -} TL_CsEvt_t; - -/** - * This the payload of TL_Evt_t for a command complete event - */ -typedef PACKED_STRUCT { - uint8_t numcmd; - uint16_t cmdcode; - uint8_t payload[1]; -} TL_CcEvt_t; - -/** - * This the payload of TL_Evt_t for an asynchronous event - */ -typedef PACKED_STRUCT { - uint16_t subevtcode; - uint8_t payload[1]; -} TL_AsynchEvt_t; - -typedef PACKED_STRUCT { - uint8_t evtcode; - uint8_t plen; - uint8_t payload[1]; -} TL_Evt_t; - -typedef PACKED_STRUCT { - uint8_t type; - TL_Evt_t evt; -} TL_EvtSerial_t; - -/** - * This format shall be used for all events (asynchronous and command response) reported - * by the CPU2 except for the command response of a system command where the header is not there - * and the format to be used shall be TL_EvtSerial_t. - * Note: Be careful that the asynchronous events reported by the CPU2 on the system channel do - * include the header and shall use TL_EvtPacket_t format. Only the command response format on the - * system channel is different. - */ -typedef PACKED_STRUCT { - TL_PacketHeader_t header; - TL_EvtSerial_t evtserial; -} TL_EvtPacket_t; - -/***************************************************************************************** - * Command type - */ - -typedef PACKED_STRUCT { - uint16_t cmdcode; - uint8_t plen; - uint8_t payload[255]; -} TL_Cmd_t; - -typedef PACKED_STRUCT { - uint8_t type; - TL_Cmd_t cmd; -} TL_CmdSerial_t; - -typedef PACKED_STRUCT { - TL_PacketHeader_t header; - TL_CmdSerial_t cmdserial; -} TL_CmdPacket_t; - -/***************************************************************************************** - * HCI ACL DATA type - */ -typedef PACKED_STRUCT { - uint8_t type; - uint16_t handle; - uint16_t length; - uint8_t acl_data[1]; -} TL_AclDataSerial_t; - -typedef PACKED_STRUCT { - TL_PacketHeader_t header; - TL_AclDataSerial_t AclDataSerial; -} TL_AclDataPacket_t; - -typedef struct { - uint8_t *p_BleSpareEvtBuffer; - uint8_t *p_SystemSpareEvtBuffer; - uint8_t *p_AsynchEvtPool; - uint32_t AsynchEvtPoolSize; - uint8_t *p_TracesEvtPool; - uint32_t TracesEvtPoolSize; -} TL_MM_Config_t; - -typedef struct { - uint8_t *p_ThreadOtCmdRspBuffer; - uint8_t *p_ThreadCliRspBuffer; - uint8_t *p_ThreadNotAckBuffer; -} TL_TH_Config_t; - -typedef struct { - uint8_t *p_LldTestsCliCmdRspBuffer; - uint8_t *p_LldTestsM0CmdBuffer; -} TL_LLD_tests_Config_t; - -typedef struct { - uint8_t *p_LldBleCmdRspBuffer; - uint8_t *p_LldBleM0CmdBuffer; -} TL_LLD_BLE_Config_t; - -typedef struct { - uint8_t *p_Mac_802_15_4_CmdRspBuffer; - uint8_t *p_Mac_802_15_4_NotAckBuffer; -} TL_MAC_802_15_4_Config_t; - -typedef struct { - uint8_t *p_ZigbeeOtCmdRspBuffer; - uint8_t *p_ZigbeeNotAckBuffer; - uint8_t *p_ZigbeeNotifRequestBuffer; -} TL_ZIGBEE_Config_t; - -/** - * @brief Contain the BLE HCI Init Configuration - * @{ - */ -typedef struct { - void (* IoBusEvtCallBack)(TL_EvtPacket_t *phcievt); - void (* IoBusAclDataTxAck)(void); - uint8_t *p_cmdbuffer; - uint8_t *p_AclDataBuffer; -} TL_BLE_InitConf_t; - -/** - * @brief Contain the SYSTEM HCI Init Configuration - * @{ - */ -typedef struct { - void (* IoBusCallBackCmdEvt)(TL_EvtPacket_t *phcievt); - void (* IoBusCallBackUserEvt)(TL_EvtPacket_t *phcievt); - uint8_t *p_cmdbuffer; -} TL_SYS_InitConf_t; - -/* Exported constants --------------------------------------------------------*/ -/* External variables --------------------------------------------------------*/ -/* Exported macros -----------------------------------------------------------*/ -/* Exported functions ------------------------------------------------------- */ - -/****************************************************************************** - * GENERAL - ******************************************************************************/ -void TL_Enable(void); -void TL_Init(void); - -/****************************************************************************** - * BLE - ******************************************************************************/ -int32_t TL_BLE_Init(void *pConf); -int32_t TL_BLE_SendCmd(uint8_t *buffer, uint16_t size); -int32_t TL_BLE_SendAclData(uint8_t *buffer, uint16_t size); - -/****************************************************************************** - * SYSTEM - ******************************************************************************/ -int32_t TL_SYS_Init(void *pConf); -int32_t TL_SYS_SendCmd(uint8_t *buffer, uint16_t size); - -/****************************************************************************** - * THREAD - ******************************************************************************/ -void TL_THREAD_Init(TL_TH_Config_t *p_Config); -void TL_OT_SendCmd(void); -void TL_CLI_SendCmd(void); -void TL_OT_CmdEvtReceived(TL_EvtPacket_t *Otbuffer); -void TL_THREAD_NotReceived(TL_EvtPacket_t *Notbuffer); -void TL_THREAD_SendAck(void); -void TL_THREAD_CliSendAck(void); -void TL_THREAD_CliNotReceived(TL_EvtPacket_t *Notbuffer); - -/****************************************************************************** - * LLD TESTS - ******************************************************************************/ -void TL_LLDTESTS_Init(TL_LLD_tests_Config_t *p_Config); -void TL_LLDTESTS_SendCliCmd(void); -void TL_LLDTESTS_ReceiveCliRsp(TL_CmdPacket_t *Notbuffer); -void TL_LLDTESTS_SendCliRspAck(void); -void TL_LLDTESTS_ReceiveM0Cmd(TL_CmdPacket_t *Notbuffer); -void TL_LLDTESTS_SendM0CmdAck(void); - -/****************************************************************************** - * LLD BLE - ******************************************************************************/ -void TL_LLD_BLE_Init(TL_LLD_BLE_Config_t *p_Config); -void TL_LLD_BLE_SendCliCmd(void); -void TL_LLD_BLE_ReceiveCliRsp(TL_CmdPacket_t *Notbuffer); -void TL_LLD_BLE_SendCliRspAck(void); -void TL_LLD_BLE_ReceiveM0Cmd(TL_CmdPacket_t *Notbuffer); -void TL_LLD_BLE_SendM0CmdAck(void); -void TL_LLD_BLE_SendCmd(void); -void TL_LLD_BLE_ReceiveRsp(TL_CmdPacket_t *Notbuffer); -void TL_LLD_BLE_SendRspAck(void); -/****************************************************************************** - * MEMORY MANAGER - ******************************************************************************/ -void TL_MM_Init(TL_MM_Config_t *p_Config); -void TL_MM_EvtDone(TL_EvtPacket_t *hcievt); - -/****************************************************************************** - * TRACES - ******************************************************************************/ -void TL_TRACES_Init(void); -void TL_TRACES_EvtReceived(TL_EvtPacket_t *hcievt); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /*__TL_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c deleted file mode 100644 index a235493d..00000000 --- a/src/utility/STM32Cube_FW/tl_mbox.c +++ /dev/null @@ -1,545 +0,0 @@ -/** - ****************************************************************************** - * @file tl_mbox.c - * @author MCD Application Team - * @brief Transport layer for the mailbox interface - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** - */ - -#if defined(STM32WBxx) -/* Includes ------------------------------------------------------------------*/ -#include "stm32_wpan_common.h" -#include "hw.h" - -#include "stm_list.h" -#include "tl.h" -#include "mbox_def.h" - -/** - * These traces are not yet supported in an usual way in the delivery package - * They can enabled by adding the definition of TL_MM_DBG_EN in the preprocessor option in the IDE - */ -#if(TL_MM_DBG_EN != 0) - #include "app_conf.h" - #include "dbg_trace.h" -#endif - -#if (TL_MM_DBG_EN != 0) - #define TL_MM_DBG__MSG PRINT_MESG_DBG -#else - #define TL_MM_DBG__MSG(...) -#endif - -/* Private typedef -----------------------------------------------------------*/ -/* Private defines -----------------------------------------------------------*/ -/* Private macros ------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ - -/**< reference table */ -PLACE_IN_SECTION("MAPPING_TABLE") static volatile MB_RefTable_t TL_RefTable; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_DeviceInfoTable_t TL_DeviceInfoTable; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleTable_t TL_BleTable; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ThreadTable_t TL_ThreadTable; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_LldTestsTable_t TL_LldTestsTable; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_LldBleTable_t TL_LldBleTable; -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; - -/**< tables */ -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue; -PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)]; -PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode EvtQueue; -PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode SystemEvtQueue; - - -static tListNode LocalFreeBufQueue; -static void (* BLE_IoBusEvtCallBackFunction)(TL_EvtPacket_t *phcievt); -static void (* BLE_IoBusAclDataTxAck)(void); -static void (* SYS_CMD_IoBusCallBackFunction)(TL_EvtPacket_t *phcievt); -static void (* SYS_EVT_IoBusCallBackFunction)(TL_EvtPacket_t *phcievt); - - -/* Global variables ----------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -static void SendFreeBuf(void); -static void OutputMemReleaseTrace(TL_EvtPacket_t *phcievt); - -/* Public Functions Definition ------------------------------------------------------*/ - -/****************************************************************************** - * GENERAL - ******************************************************************************/ -void TL_Enable(void) -{ - HW_IPCC_Enable(); - - return; -} - - -void TL_Init(void) -{ - TL_RefTable.p_device_info_table = &TL_DeviceInfoTable; - TL_RefTable.p_ble_table = &TL_BleTable; - TL_RefTable.p_thread_table = &TL_ThreadTable; - TL_RefTable.p_lld_tests_table = &TL_LldTestsTable; - TL_RefTable.p_lld_ble_table = &TL_LldBleTable; - TL_RefTable.p_sys_table = &TL_SysTable; - TL_RefTable.p_mem_manager_table = &TL_MemManagerTable; - TL_RefTable.p_traces_table = &TL_TracesTable; - - HW_IPCC_Init(); - - return; -} - -/****************************************************************************** - * BLE - ******************************************************************************/ -int32_t TL_BLE_Init(void *pConf) -{ - MB_BleTable_t *p_bletable; - - TL_BLE_InitConf_t *pInitHciConf = (TL_BLE_InitConf_t *) pConf; - - LST_init_head(&EvtQueue); - - p_bletable = TL_RefTable.p_ble_table; - - p_bletable->pcmd_buffer = pInitHciConf->p_cmdbuffer; - p_bletable->phci_acl_data_buffer = pInitHciConf->p_AclDataBuffer; - p_bletable->pcs_buffer = (uint8_t *)CsBuffer; - p_bletable->pevt_queue = (uint8_t *)&EvtQueue; - - HW_IPCC_BLE_Init(); - - BLE_IoBusEvtCallBackFunction = pInitHciConf->IoBusEvtCallBack; - BLE_IoBusAclDataTxAck = pInitHciConf->IoBusAclDataTxAck; - - return 0; -} - -int32_t TL_BLE_SendCmd(uint8_t *buffer, uint16_t size) -{ - (void)(buffer); - (void)(size); - - ((TL_CmdPacket_t *)(TL_RefTable.p_ble_table->pcmd_buffer))->cmdserial.type = TL_BLECMD_PKT_TYPE; - - HW_IPCC_BLE_SendCmd(); - - return 0; -} - -void HW_IPCC_BLE_RxEvtNot(void) -{ - TL_EvtPacket_t *phcievt; - - while (LST_is_empty(&EvtQueue) == FALSE) { - LST_remove_head(&EvtQueue, (tListNode **)&phcievt); - - BLE_IoBusEvtCallBackFunction(phcievt); - } - - return; -} - -int32_t TL_BLE_SendAclData(uint8_t *buffer, uint16_t size) -{ - (void)(buffer); - (void)(size); - - ((TL_AclDataPacket_t *)(TL_RefTable.p_ble_table->phci_acl_data_buffer))->AclDataSerial.type = TL_ACL_DATA_PKT_TYPE; - - HW_IPCC_BLE_SendAclData(); - - return 0; -} - -void HW_IPCC_BLE_AclDataAckNot(void) -{ - BLE_IoBusAclDataTxAck(); - - return; -} - -/****************************************************************************** - * SYSTEM - ******************************************************************************/ -int32_t TL_SYS_Init(void *pConf) -{ - MB_SysTable_t *p_systable; - - TL_SYS_InitConf_t *pInitHciConf = (TL_SYS_InitConf_t *) pConf; - - LST_init_head(&SystemEvtQueue); - p_systable = TL_RefTable.p_sys_table; - p_systable->pcmd_buffer = pInitHciConf->p_cmdbuffer; - p_systable->sys_queue = (uint8_t *)&SystemEvtQueue; - - HW_IPCC_SYS_Init(); - - SYS_CMD_IoBusCallBackFunction = pInitHciConf->IoBusCallBackCmdEvt; - SYS_EVT_IoBusCallBackFunction = pInitHciConf->IoBusCallBackUserEvt; - - return 0; -} - -int32_t TL_SYS_SendCmd(uint8_t *buffer, uint16_t size) -{ - (void)(buffer); - (void)(size); - - ((TL_CmdPacket_t *)(TL_RefTable.p_sys_table->pcmd_buffer))->cmdserial.type = TL_SYSCMD_PKT_TYPE; - - HW_IPCC_SYS_SendCmd(); - - return 0; -} - -void HW_IPCC_SYS_CmdEvtNot(void) -{ - SYS_CMD_IoBusCallBackFunction((TL_EvtPacket_t *)(TL_RefTable.p_sys_table->pcmd_buffer)); - - return; -} - -void HW_IPCC_SYS_EvtNot(void) -{ - TL_EvtPacket_t *p_evt; - - while (LST_is_empty(&SystemEvtQueue) == FALSE) { - LST_remove_head(&SystemEvtQueue, (tListNode **)&p_evt); - SYS_EVT_IoBusCallBackFunction(p_evt); - } - - return; -} - -/****************************************************************************** - * THREAD - ******************************************************************************/ -#ifdef THREAD_WB -void TL_THREAD_Init(TL_TH_Config_t *p_Config) -{ - MB_ThreadTable_t *p_thread_table; - - p_thread_table = TL_RefTable.p_thread_table; - - p_thread_table->clicmdrsp_buffer = p_Config->p_ThreadCliRspBuffer; - p_thread_table->otcmdrsp_buffer = p_Config->p_ThreadOtCmdRspBuffer; - p_thread_table->notack_buffer = p_Config->p_ThreadNotAckBuffer; - - HW_IPCC_THREAD_Init(); - - return; -} - -void TL_OT_SendCmd(void) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->otcmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; - - HW_IPCC_OT_SendCmd(); - - return; -} - -void TL_CLI_SendCmd(void) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->clicmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; - - HW_IPCC_CLI_SendCmd(); - - return; -} - -void TL_THREAD_SendAck(void) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_THREAD_SendAck(); - - return; -} - -void TL_THREAD_CliSendAck(void) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_THREAD_CliSendAck(); - - return; -} - -void HW_IPCC_OT_CmdEvtNot(void) -{ - TL_OT_CmdEvtReceived((TL_EvtPacket_t *)(TL_RefTable.p_thread_table->otcmdrsp_buffer)); - - return; -} - -void HW_IPCC_THREAD_EvtNot(void) -{ - TL_THREAD_NotReceived((TL_EvtPacket_t *)(TL_RefTable.p_thread_table->notack_buffer)); - - return; -} - -void HW_IPCC_THREAD_CliEvtNot(void) -{ - TL_THREAD_CliNotReceived((TL_EvtPacket_t *)(TL_RefTable.p_thread_table->clicmdrsp_buffer)); - - return; -} - -__WEAK void TL_OT_CmdEvtReceived(TL_EvtPacket_t *Otbuffer) {}; -__WEAK void TL_THREAD_NotReceived(TL_EvtPacket_t *Notbuffer) {}; -__WEAK void TL_THREAD_CliNotReceived(TL_EvtPacket_t *Notbuffer) {}; - -#endif /* THREAD_WB */ - -/****************************************************************************** - * LLD TESTS - ******************************************************************************/ -#ifdef LLD_TESTS_WB -void TL_LLDTESTS_Init(TL_LLD_tests_Config_t *p_Config) -{ - MB_LldTestsTable_t *p_lld_tests_table; - - p_lld_tests_table = TL_RefTable.p_lld_tests_table; - p_lld_tests_table->clicmdrsp_buffer = p_Config->p_LldTestsCliCmdRspBuffer; - p_lld_tests_table->m0cmd_buffer = p_Config->p_LldTestsM0CmdBuffer; - HW_IPCC_LLDTESTS_Init(); - return; -} - -void TL_LLDTESTS_SendCliCmd(void) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; - HW_IPCC_LLDTESTS_SendCliCmd(); - return; -} - -void HW_IPCC_LLDTESTS_ReceiveCliRsp(void) -{ - TL_LLDTESTS_ReceiveCliRsp((TL_CmdPacket_t *)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer)); - return; -} - -void TL_LLDTESTS_SendCliRspAck(void) -{ - HW_IPCC_LLDTESTS_SendCliRspAck(); - return; -} - -void HW_IPCC_LLDTESTS_ReceiveM0Cmd(void) -{ - TL_LLDTESTS_ReceiveM0Cmd((TL_CmdPacket_t *)(TL_RefTable.p_lld_tests_table->m0cmd_buffer)); - return; -} - - -void TL_LLDTESTS_SendM0CmdAck(void) -{ - HW_IPCC_LLDTESTS_SendM0CmdAck(); - return; -} - -__WEAK void TL_LLDTESTS_ReceiveCliRsp(TL_CmdPacket_t *Notbuffer) {}; -__WEAK void TL_LLDTESTS_ReceiveM0Cmd(TL_CmdPacket_t *Notbuffer) {}; -#endif /* LLD_TESTS_WB */ - -/****************************************************************************** - * LLD BLE - ******************************************************************************/ -#ifdef LLD_BLE_WB -void TL_LLD_BLE_Init(TL_LLD_BLE_Config_t *p_Config) -{ - MB_LldBleTable_t *p_lld_ble_table; - - p_lld_ble_table = TL_RefTable.p_lld_ble_table; - p_lld_ble_table->cmdrsp_buffer = p_Config->p_LldBleCmdRspBuffer; - p_lld_ble_table->m0cmd_buffer = p_Config->p_LldBleM0CmdBuffer; - HW_IPCC_LLD_BLE_Init(); - return; -} - -void TL_LLD_BLE_SendCliCmd(void) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; - HW_IPCC_LLD_BLE_SendCliCmd(); - return; -} - -void HW_IPCC_LLD_BLE_ReceiveCliRsp(void) -{ - TL_LLD_BLE_ReceiveCliRsp((TL_CmdPacket_t *)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer)); - return; -} - -void TL_LLD_BLE_SendCliRspAck(void) -{ - HW_IPCC_LLD_BLE_SendCliRspAck(); - return; -} - -void HW_IPCC_LLD_BLE_ReceiveM0Cmd(void) -{ - TL_LLD_BLE_ReceiveM0Cmd((TL_CmdPacket_t *)(TL_RefTable.p_lld_ble_table->m0cmd_buffer)); - return; -} - - -void TL_LLD_BLE_SendM0CmdAck(void) -{ - HW_IPCC_LLD_BLE_SendM0CmdAck(); - return; -} - -__WEAK void TL_LLD_BLE_ReceiveCliRsp(TL_CmdPacket_t *Notbuffer) {}; -__WEAK void TL_LLD_BLE_ReceiveM0Cmd(TL_CmdPacket_t *Notbuffer) {}; - -/* Transparent Mode */ -void TL_LLD_BLE_SendCmd(void) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; - HW_IPCC_LLD_BLE_SendCmd(); - return; -} - -void HW_IPCC_LLD_BLE_ReceiveRsp(void) -{ - TL_LLD_BLE_ReceiveRsp((TL_CmdPacket_t *)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer)); - return; -} - -void TL_LLD_BLE_SendRspAck(void) -{ - HW_IPCC_LLD_BLE_SendRspAck(); - return; -} -#endif /* LLD_BLE_WB */ - -/****************************************************************************** - * MEMORY MANAGER - ******************************************************************************/ -void TL_MM_Init(TL_MM_Config_t *p_Config) -{ - static MB_MemManagerTable_t *p_mem_manager_table; - - LST_init_head(&FreeBufQueue); - LST_init_head(&LocalFreeBufQueue); - - p_mem_manager_table = TL_RefTable.p_mem_manager_table; - - p_mem_manager_table->blepool = p_Config->p_AsynchEvtPool; - p_mem_manager_table->blepoolsize = p_Config->AsynchEvtPoolSize; - p_mem_manager_table->pevt_free_buffer_queue = (uint8_t *)&FreeBufQueue; - p_mem_manager_table->spare_ble_buffer = p_Config->p_BleSpareEvtBuffer; - p_mem_manager_table->spare_sys_buffer = p_Config->p_SystemSpareEvtBuffer; - p_mem_manager_table->traces_evt_pool = p_Config->p_TracesEvtPool; - p_mem_manager_table->tracespoolsize = p_Config->TracesEvtPoolSize; - - return; -} - -void TL_MM_EvtDone(TL_EvtPacket_t *phcievt) -{ - LST_insert_tail(&LocalFreeBufQueue, (tListNode *)phcievt); - - OutputMemReleaseTrace(phcievt); - - HW_IPCC_MM_SendFreeBuf(SendFreeBuf); - - return; -} - -static void SendFreeBuf(void) -{ - tListNode *p_node; - - while (FALSE == LST_is_empty(&LocalFreeBufQueue)) { - LST_remove_head(&LocalFreeBufQueue, (tListNode **)&p_node); - LST_insert_tail((tListNode *)(TL_RefTable.p_mem_manager_table->pevt_free_buffer_queue), p_node); - } - - return; -} - -static void OutputMemReleaseTrace(TL_EvtPacket_t *phcievt) -{ - switch (phcievt->evtserial.evt.evtcode) { - case TL_BLEEVT_CS_OPCODE: - TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode); - TL_MM_DBG__MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t *)(phcievt->evtserial.evt.payload))->cmdcode); - TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); - break; - - case TL_BLEEVT_CC_OPCODE: - TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode); - TL_MM_DBG__MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t *)(phcievt->evtserial.evt.payload))->cmdcode); - TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); - break; - - case TL_BLEEVT_VS_OPCODE: - TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode); - TL_MM_DBG__MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t *)(phcievt->evtserial.evt.payload))->subevtcode); - TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); - break; - - default: - TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode); - TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); - break; - } - - TL_MM_DBG__MSG("\r\n"); - - return; -} - -/****************************************************************************** - * TRACES - ******************************************************************************/ -void TL_TRACES_Init(void) -{ - LST_init_head(&TracesEvtQueue); - - TL_RefTable.p_traces_table->traces_queue = (uint8_t *)&TracesEvtQueue; - - HW_IPCC_TRACES_Init(); - - return; -} - -void HW_IPCC_TRACES_EvtNot(void) -{ - TL_EvtPacket_t *phcievt; - - while (LST_is_empty(&TracesEvtQueue) == FALSE) { - LST_remove_head(&TracesEvtQueue, (tListNode **)&phcievt); - TL_TRACES_EvtReceived(phcievt); - } - - return; -} - -__WEAK void TL_TRACES_EvtReceived(TL_EvtPacket_t *hcievt) -{ - (void)(hcievt); -} -#endif /* STM32WBxx */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From 370b06da90ebfa990d15b34787fd1e9002b520fa Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 1 Dec 2021 11:15:00 +0100 Subject: [PATCH 09/58] chore: include STM32Cube_FW to support the BLE of the stm32wb55 Orignal file from the v1.8.0: https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.8.0 Signed-off-by: Frederic Pillon --- src/utility/STM32Cube_FW/app_conf.h | 510 ++++++++++ src/utility/STM32Cube_FW/ble_bufsize.h | 161 ++++ src/utility/STM32Cube_FW/hw.h | 107 +++ src/utility/STM32Cube_FW/hw_ipcc.c | 517 ++++++++++ src/utility/STM32Cube_FW/mbox_def.h | 258 +++++ src/utility/STM32Cube_FW/shci.c | 609 ++++++++++++ src/utility/STM32Cube_FW/shci.h | 944 +++++++++++++++++++ src/utility/STM32Cube_FW/shci_tl.c | 351 +++++++ src/utility/STM32Cube_FW/shci_tl.h | 175 ++++ src/utility/STM32Cube_FW/stm32_wpan_common.h | 170 ++++ src/utility/STM32Cube_FW/stm_list.c | 208 ++++ src/utility/STM32Cube_FW/stm_list.h | 55 ++ src/utility/STM32Cube_FW/tl.h | 334 +++++++ src/utility/STM32Cube_FW/tl_mbox.c | 686 ++++++++++++++ 14 files changed, 5085 insertions(+) create mode 100644 src/utility/STM32Cube_FW/app_conf.h create mode 100644 src/utility/STM32Cube_FW/ble_bufsize.h create mode 100644 src/utility/STM32Cube_FW/hw.h create mode 100644 src/utility/STM32Cube_FW/hw_ipcc.c create mode 100644 src/utility/STM32Cube_FW/mbox_def.h create mode 100644 src/utility/STM32Cube_FW/shci.c create mode 100644 src/utility/STM32Cube_FW/shci.h create mode 100644 src/utility/STM32Cube_FW/shci_tl.c create mode 100644 src/utility/STM32Cube_FW/shci_tl.h create mode 100644 src/utility/STM32Cube_FW/stm32_wpan_common.h create mode 100644 src/utility/STM32Cube_FW/stm_list.c create mode 100644 src/utility/STM32Cube_FW/stm_list.h create mode 100644 src/utility/STM32Cube_FW/tl.h create mode 100644 src/utility/STM32Cube_FW/tl_mbox.c diff --git a/src/utility/STM32Cube_FW/app_conf.h b/src/utility/STM32Cube_FW/app_conf.h new file mode 100644 index 00000000..ac5ccd4d --- /dev/null +++ b/src/utility/STM32Cube_FW/app_conf.h @@ -0,0 +1,510 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : app_conf.h + * Description : Application configuration file for STM32WPAN Middleware. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef APP_CONF_H +#define APP_CONF_H + +#include "hw.h" +#include "hw_conf.h" +#include "hw_if.h" + +/****************************************************************************** + * Application Config + ******************************************************************************/ + +/** + * Define Secure Connections Support + */ +#define CFG_SECURE_NOT_SUPPORTED (0x00) +#define CFG_SECURE_OPTIONAL (0x01) +#define CFG_SECURE_MANDATORY (0x02) + +#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL + +/** + * Define Keypress Notification Support + */ +#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) +#define CFG_KEYPRESS_SUPPORTED (0x01) + +#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED + +/** + * Numeric Comparison Answers + */ +#define YES (0x01) +#define NO (0x00) + +/** + * Device name configuration for Generic Access Service + */ +#define CFG_GAP_DEVICE_NAME "TEMPLATE" +#define CFG_GAP_DEVICE_NAME_LENGTH (8) + +/** +* Identity root key used to derive LTK and CSRK +*/ +#define CFG_BLE_IRK {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0} + +/** +* Encryption root key used to derive LTK and CSRK +*/ +#define CFG_BLE_ERK {0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21,0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21} + +/* USER CODE BEGIN Generic_Parameters */ +/** + * SMPS supply + * SMPS not used when Set to 0 + * SMPS used when Set to 1 + */ +#define CFG_USE_SMPS 1 +/* USER CODE END Generic_Parameters */ + +/**< specific parameters */ +/*****************************************************/ + +#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler + +/****************************************************************************** + * Information Table + * + * Version + * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version + * [4:7] = branch - 0: Mass Market - x: ... + * [8:15] = Subversion + * [16:23] = Version minor + * [24:31] = Version major + * + ******************************************************************************/ +#define CFG_FW_MAJOR_VERSION (0) +#define CFG_FW_MINOR_VERSION (0) +#define CFG_FW_SUBVERSION (1) +#define CFG_FW_BRANCH (0) +#define CFG_FW_BUILD (0) + +/****************************************************************************** + * BLE Stack + ******************************************************************************/ +/** + * Maximum number of simultaneous connections that the device will support. + * Valid values are from 1 to 8 + */ +#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 + */ +#define CFG_BLE_NUM_GATT_SERVICES 8 + +/** + * Maximum number of Attributes + * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) + * that can be stored in the GATT database. + * 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 + +/** + * Maximum supported ATT_MTU size + */ +#define CFG_BLE_MAX_ATT_MTU (156) + +/** + * Size of the storage area for Attribute values + * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: + * - attribute value length + * - 5, if UUID is 16 bit; 19, if UUID is 128 bit + * - 2, if server configuration descriptor is used + * - 2*DTM_NUM_LINK, if client configuration descriptor is used + * - 2, if extended properties is used + * The total amount of memory needed is the sum of the above quantities for each attribute. + */ +#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) + +/** + * Prepare Write List size in terms of number of packet + */ +#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) + +/** + * Number of allocated memory blocks + */ +#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) + +/** + * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. + */ +#define CFG_BLE_DATA_LENGTH_EXTENSION 1 + +/** + * Sleep clock accuracy in Slave mode (ppm value) + */ +#define CFG_BLE_SLAVE_SCA 500 + +/** + * Sleep clock accuracy in Master mode + * 0 : 251 ppm to 500 ppm + * 1 : 151 ppm to 250 ppm + * 2 : 101 ppm to 150 ppm + * 3 : 76 ppm to 100 ppm + * 4 : 51 ppm to 75 ppm + * 5 : 31 ppm to 50 ppm + * 6 : 21 ppm to 30 ppm + * 7 : 0 ppm to 20 ppm + */ +#define CFG_BLE_MASTER_SCA 0 + +/** + * Source for the 32 kHz slow speed clock + * 1 : internal RO + * 0 : external crystal ( no calibration ) + */ +#define CFG_BLE_LSE_SOURCE 0 + +/** + * 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 + +/** + * Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us) + */ +#define CFG_BLE_MAX_CONN_EVENT_LENGTH ( 0xFFFFFFFF ) + +/** + * Viterbi Mode + * 1 : enabled + * 0 : disabled + */ +#define CFG_BLE_VITERBI_MODE 1 + +/** + * LL Only Mode + * 1 : LL Only + * 0 : LL + Host + */ +#define CFG_BLE_LL_ONLY 0 +/****************************************************************************** + * Transport Layer + ******************************************************************************/ +/** + * Queue length of BLE Event + * This parameter defines the number of asynchronous events that can be stored in the HCI layer before + * being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer + * is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large + * enough to store all asynchronous events received in between. + * When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events + * between the HCI command and its event. + * This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small, + * the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting + * for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate + * to the application a HCI command did not receive its command event within 30s (Default HCI Timeout). + */ +#define CFG_TLBLE_EVT_QUEUE_LENGTH 5 +/** + * This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element + * allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager. + * It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will + * never be used) + * It shall be at least 4 to receive the command status event in one frame. + * The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced + * further depending on the application. + * + */ +#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */ + +#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE ) +/****************************************************************************** + * UART interfaces + ******************************************************************************/ + +/** + * Select UART interfaces + */ +#define CFG_UART_GUI hw_uart1 +#define CFG_DEBUG_TRACE_UART 0 +/****************************************************************************** + * USB interface + ******************************************************************************/ + +/** + * Enable/Disable USB interface + */ +#define CFG_USB_INTERFACE_ENABLE 0 + +/****************************************************************************** + * Low Power + ******************************************************************************/ +/** + * When set to 1, the low power mode is enable + * When set to 0, the device stays in RUN mode + */ +#define CFG_LPM_SUPPORTED 1 + +/****************************************************************************** + * Timer Server + ******************************************************************************/ +/** + * CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer. + * The higher is the value, the better is the power consumption and the accuracy of the timerserver + * The lower is the value, the finest is the granularity + * + * CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to ouput + * clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding + * the wakeup timer. A lower clock speed would impact the accuracy of the timer server. + * + * CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC. + * When the 1Hz calendar clock is required, it shall be sets according to other settings + * When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE) + * + * CFG_RTCCLK_DIVIDER_CONF: + * Shall be set to either 0,2,4,8,16 + * When set to either 2,4,8,16, the 1Hhz calendar is supported + * When set to 0, the user sets its own configuration + * + * The following settings are computed with LSI as input to the RTC + */ +#define CFG_RTCCLK_DIVIDER_CONF 0 + +#if (CFG_RTCCLK_DIVIDER_CONF == 0) +/** + * Custom configuration + * It does not support 1Hz calendar + * It divides the RTC CLK by 16 + */ +#define CFG_RTCCLK_DIV (16) +#define CFG_RTC_WUCKSEL_DIVIDER (0) +#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) +#define CFG_RTC_SYNCH_PRESCALER (0x7FFF) + +#else + +#if (CFG_RTCCLK_DIVIDER_CONF == 2) +/** + * It divides the RTC CLK by 2 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (3) +#endif + +#if (CFG_RTCCLK_DIVIDER_CONF == 4) +/** + * It divides the RTC CLK by 4 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (2) +#endif + +#if (CFG_RTCCLK_DIVIDER_CONF == 8) +/** + * It divides the RTC CLK by 8 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (1) +#endif + +#if (CFG_RTCCLK_DIVIDER_CONF == 16) +/** + * It divides the RTC CLK by 16 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (0) +#endif + +#define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF +#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) +#define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 ) + +#endif + +/** tick timer value in us */ +#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE ) + +typedef enum +{ + CFG_TIM_PROC_ID_ISR, +} CFG_TimProcID_t; + +/****************************************************************************** + * Debug + ******************************************************************************/ +/** + * When set, this resets some hw resources to set the device in the same state than the power up + * The FW resets only register that may prevent the FW to run properly + * + * This shall be set to 0 in a final product + * + */ +#define CFG_HW_RESET_BY_FW 1 + +/** + * keep debugger enabled while in any low power mode when set to 1 + * should be set to 0 in production + */ +#define CFG_DEBUGGER_SUPPORTED 0 + +/** + * When set to 1, the traces are enabled in the BLE services + */ +#define CFG_DEBUG_BLE_TRACE 0 + +/** + * Enable or Disable traces in application + */ +#define CFG_DEBUG_APP_TRACE 0 + +#if (CFG_DEBUG_APP_TRACE != 0) +#define APP_DBG_MSG PRINT_MESG_DBG +#else +#define APP_DBG_MSG PRINT_NO_MESG +#endif + +#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) ) +#define CFG_DEBUG_TRACE 1 +#endif + +#if (CFG_DEBUG_TRACE != 0) +#undef CFG_LPM_SUPPORTED +#undef CFG_DEBUGGER_SUPPORTED +#define CFG_LPM_SUPPORTED 0 +#define CFG_DEBUGGER_SUPPORTED 1 +#endif + +/** + * When CFG_DEBUG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number + * When CFG_DEBUG_TRACE_LIGHT is set to 1, only the debug message is output + * + * When both are set to 0, no trace are output + * When both are set to 1, CFG_DEBUG_TRACE_FULL is selected + */ +#define CFG_DEBUG_TRACE_LIGHT 0 +#define CFG_DEBUG_TRACE_FULL 0 + +#if (( CFG_DEBUG_TRACE != 0 ) && ( CFG_DEBUG_TRACE_LIGHT == 0 ) && (CFG_DEBUG_TRACE_FULL == 0)) +#undef CFG_DEBUG_TRACE_FULL +#undef CFG_DEBUG_TRACE_LIGHT +#define CFG_DEBUG_TRACE_FULL 0 +#define CFG_DEBUG_TRACE_LIGHT 1 +#endif + +#if ( CFG_DEBUG_TRACE == 0 ) +#undef CFG_DEBUG_TRACE_FULL +#undef CFG_DEBUG_TRACE_LIGHT +#define CFG_DEBUG_TRACE_FULL 0 +#define CFG_DEBUG_TRACE_LIGHT 0 +#endif + +/** + * When not set, the traces is looping on sending the trace over UART + */ +#define DBG_TRACE_USE_CIRCULAR_QUEUE 1 + +/** + * max buffer Size to queue data traces and max data trace allowed. + * Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined + */ +#define DBG_TRACE_MSG_QUEUE_SIZE 4096 +#define MAX_DBG_TRACE_MSG_SIZE 1024 + +/* USER CODE BEGIN Defines */ +#define CFG_LED_SUPPORTED 1 +#define CFG_BUTTON_SUPPORTED 1 +/* USER CODE END Defines */ + +/****************************************************************************** + * Scheduler + ******************************************************************************/ + +/** + * These are the lists of task id registered to the scheduler + * Each task id shall be in the range [0:31] + * This mechanism allows to implement a generic code in the API TL_BLE_HCI_StatusNot() to comply with + * the requirement that a HCI/ACI command shall never be sent if there is already one pending + */ + +/**< Add in that list all tasks that may send a ACI/HCI command */ +typedef enum +{ + CFG_TASK_BLE_HCI_CMD_ID, + CFG_TASK_SYS_HCI_CMD_ID, + CFG_TASK_HCI_ACL_DATA_ID, + CFG_TASK_SYS_LOCAL_CMD_ID, + CFG_TASK_TX_TO_HOST_ID, +/* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */ + +/* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */ + CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */ +} CFG_Task_Id_With_HCI_Cmd_t; + +/**< Add in that list all tasks that never send a ACI/HCI command */ +typedef enum +{ + CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */ + CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID, +/* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */ + +/* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */ + CFG_LAST_TASK_ID_WITHO_NO_HCICMD /**< Shall be LAST in the list */ +} CFG_Task_Id_With_NO_HCI_Cmd_t; +#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITHO_NO_HCICMD + +/** + * This is the list of priority required by the application + * Each Id shall be in the range 0..31 + */ +typedef enum +{ + CFG_SCH_PRIO_0, + CFG_PRIO_NBR, +} CFG_SCH_Prio_Id_t; + +/** + * This is a bit mapping over 32bits listing all events id supported in the application + */ +typedef enum +{ + CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID, +} CFG_IdleEvt_Id_t; + +/****************************************************************************** + * LOW POWER + ******************************************************************************/ +/** + * Supported requester to the MCU Low Power Manager - can be increased up to 32 + * It lits a bit mapping of all user of the Low Power Manager + */ +typedef enum +{ + CFG_LPM_APP, + CFG_LPM_APP_BLE, + /* USER CODE BEGIN CFG_LPM_Id_t */ + + /* USER CODE END CFG_LPM_Id_t */ +} CFG_LPM_Id_t; + +/****************************************************************************** + * OTP manager + ******************************************************************************/ +#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE + +#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR + +#endif /*APP_CONF_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h new file mode 100644 index 00000000..c5a5d569 --- /dev/null +++ b/src/utility/STM32Cube_FW/ble_bufsize.h @@ -0,0 +1,161 @@ +/***************************************************************************** + * @file ble_bufsize.h + * @author MCD Application Team + * @brief Definition of BLE stack buffers size + ***************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ***************************************************************************** + */ + +#ifndef BLE_BUFSIZE_H__ +#define BLE_BUFSIZE_H__ + + +/* + * BLE_DEFAULT_ATT_MTU: minimum MTU value that GATT must support. + */ +#define BLE_DEFAULT_ATT_MTU 23 + +/* + * BLE_DEFAULT_MAX_ATT_MTU: maximum supported ATT MTU size. + */ +#define BLE_DEFAULT_MAX_ATT_MTU 158 + +/* + * BLE_DEFAULT_MAX_ATT_SIZE: maximum attribute size. + */ +#define BLE_DEFAULT_MAX_ATT_SIZE 512 + +/* + * BLE_PREP_WRITE_X_ATT: compute how many Prepare Write Request are needed to + * write a characteristic with size 'max_att' when the used ATT_MTU value is + * equal to BLE_DEFAULT_ATT_MTU (23). + */ +#define BLE_PREP_WRITE_X_ATT(max_att) \ + (DIVC(max_att, BLE_DEFAULT_ATT_MTU - 5) * 2) + +/* + * BLE_DEFAULT_PREP_WRITE_LIST_SIZE: default minimum Prepare Write List size. + */ +#define BLE_DEFAULT_PREP_WRITE_LIST_SIZE \ + BLE_PREP_WRITE_X_ATT(BLE_DEFAULT_MAX_ATT_SIZE) + +/* + * BLE_MEM_BLOCK_X_MTU: compute how many memory blocks are needed to compose + * an ATT packet with ATT_MTU=mtu. + */ +#define BLE_MEM_BLOCK_SIZE 32 + +#define BLE_MEM_BLOCK_X_TX(mtu) \ + (DIVC((mtu) + 4U, BLE_MEM_BLOCK_SIZE) + 1U) + +#define BLE_MEM_BLOCK_X_RX(mtu, n_link) \ + ((DIVC((mtu) + 4U, BLE_MEM_BLOCK_SIZE) + 2U) * (n_link) + 1) + +#define BLE_MEM_BLOCK_X_MTU(mtu, n_link) \ + (BLE_MEM_BLOCK_X_TX(mtu) + BLE_MEM_BLOCK_X_RX(mtu, n_link)) + +/* + * BLE_MBLOCKS_SECURE_CONNECTIONS: minimum number of blocks required for + * secure connections + */ +#define BLE_MBLOCKS_SECURE_CONNECTIONS 4 + +/* + * BLE_MBLOCKS_CALC: minimum number of buffers needed by the stack. + * This is the minimum racomanded value and depends on: + * - pw: size of Prepare Write List + * - mtu: ATT_MTU size + * - n_link: maximum number of simultaneous connections + */ +#define BLE_MBLOCKS_CALC(pw, mtu, n_link) \ + ((pw) + MAX(BLE_MEM_BLOCK_X_MTU(mtu, n_link), \ + BLE_MBLOCKS_SECURE_CONNECTIONS)) + +/* + * BLE_DEFAULT_MBLOCKS_COUNT: default memory blocks count + */ +#define BLE_DEFAULT_MBLOCKS_COUNT(n_link) \ + BLE_MBLOCKS_CALC(BLE_DEFAULT_PREP_WRITE_LIST_SIZE, \ + BLE_DEFAULT_MAX_ATT_MTU, n_link) + +/* + * BLE_FIXED_BUFFER_SIZE_BYTES: + * A part of the RAM, is dinamically allocated by initilizing all the pointers + * defined in a global context variable "mem_alloc_ctx_p". + * This initialization is made in the Dynamic_allocator functions, which + * assing a portion of RAM given by the external application to the above + * mentioned "global pointers". + * + * The size of this Dynamic RAM is made of 2 main components: + * - a part that is parameters-dependent (num of links, GATT buffers, ...), + * and which value is explicited by the following macro; + * - a part, that may be considered "fixed", i.e. independent from the above + * mentioned parameters. +*/ +#if (SLAVE_ONLY == 0) && (LL_ONLY == 0) +#define BLE_FIXED_BUFFER_SIZE_BYTES 6960 /* Full stack */ +#elif SLAVE_ONLY == 0 +#define BLE_FIXED_BUFFER_SIZE_BYTES 6256 /* LL only */ +#else +#define BLE_FIXED_BUFFER_SIZE_BYTES 6696 /* Slave only */ +#endif + +/* + * BLE_PER_LINK_SIZE_BYTES: additional memory size used per link + */ +#if (SLAVE_ONLY == 0) && (LL_ONLY == 0) +#define BLE_PER_LINK_SIZE_BYTES 380 /* Full stack */ +#elif SLAVE_ONLY == 0 +#define BLE_PER_LINK_SIZE_BYTES 196 /* LL only */ +#else +#define BLE_PER_LINK_SIZE_BYTES 332 /* Slave only */ +#endif + +/* + * BLE_TOTAL_BUFFER_SIZE: this macro returns the amount of memory, in bytes, + * needed for the storage of data structures (except GATT database elements) + * whose size depends on the number of supported connections. + * + * @param num_links: Maximum number of simultaneous connections that the device + * will support. Valid values are from 1 to 8. + * + * @param mblocks_count: Number of memory blocks allocated for packets. + */ +#define BLE_TOTAL_BUFFER_SIZE(n_link, mblocks_count) \ + (BLE_FIXED_BUFFER_SIZE_BYTES + \ + (BLE_PER_LINK_SIZE_BYTES * (n_link)) + \ + ((BLE_MEM_BLOCK_SIZE + 12) * (mblocks_count))) + +/* + * BLE_TOTAL_BUFFER_SIZE_GATT: this macro returns the amount of memory, + * in bytes, needed for the storage of GATT database elements. + * + * @param num_gatt_attributes: Maximum number of Attributes (i.e. the number + * of characteristic + the number of characteristic values + the number of + * descriptors, excluding the services) that can be stored in the GATT + * database. 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 + * + * @param num_gatt_services: 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 + * + * @param att_value_array_size: Size of the storage area for Attribute values. + */ +#define BLE_TOTAL_BUFFER_SIZE_GATT(num_gatt_attributes, num_gatt_services, att_value_array_size) \ + (((((att_value_array_size) - 1) | 3) + 1) + \ + (40 * (num_gatt_attributes)) + (48 * (num_gatt_services))) + + +#endif /* ! BLE_BUFSIZE_H__ */ diff --git a/src/utility/STM32Cube_FW/hw.h b/src/utility/STM32Cube_FW/hw.h new file mode 100644 index 00000000..879fa6de --- /dev/null +++ b/src/utility/STM32Cube_FW/hw.h @@ -0,0 +1,107 @@ +/** + ****************************************************************************** + * @file hw.h + * @author MCD Application Team + * @brief Hardware + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __HW_H +#define __HW_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* Includes ------------------------------------------------------------------*/ + + /****************************************************************************** + * HW IPCC + ******************************************************************************/ + void HW_IPCC_Enable( void ); + void HW_IPCC_Init( void ); + void HW_IPCC_Rx_Handler( void ); + void HW_IPCC_Tx_Handler( void ); + + void HW_IPCC_BLE_Init( void ); + void HW_IPCC_BLE_SendCmd( void ); + void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) ); + void HW_IPCC_BLE_RxEvtNot( void ); + void HW_IPCC_BLE_SendAclData( void ); + void HW_IPCC_BLE_AclDataAckNot( void ); + + void HW_IPCC_SYS_Init( void ); + void HW_IPCC_SYS_SendCmd( void ); + void HW_IPCC_SYS_CmdEvtNot( void ); + void HW_IPCC_SYS_EvtNot( void ); + + void HW_IPCC_THREAD_Init( void ); + void HW_IPCC_OT_SendCmd( void ); + void HW_IPCC_CLI_SendCmd( void ); + void HW_IPCC_THREAD_SendAck( void ); + void HW_IPCC_OT_CmdEvtNot( void ); + void HW_IPCC_CLI_CmdEvtNot( void ); + void HW_IPCC_THREAD_EvtNot( void ); + void HW_IPCC_THREAD_CliSendAck( void ); + void HW_IPCC_THREAD_CliEvtNot( void ); + + + void HW_IPCC_LLDTESTS_Init( void ); + void HW_IPCC_LLDTESTS_SendCliCmd( void ); + void HW_IPCC_LLDTESTS_ReceiveCliRsp( void ); + void HW_IPCC_LLDTESTS_SendCliRspAck( void ); + void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void ); + void HW_IPCC_LLDTESTS_SendM0CmdAck( void ); + + + void HW_IPCC_LLD_BLE_Init( void ); + void HW_IPCC_LLD_BLE_SendCliCmd( void ); + void HW_IPCC_LLD_BLE_ReceiveCliRsp( void ); + void HW_IPCC_LLD_BLE_SendCliRspAck( void ); + void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ); + void HW_IPCC_LLD_BLE_SendM0CmdAck( void ); + void HW_IPCC_LLD_BLE_SendCmd( void ); + void HW_IPCC_LLD_BLE_ReceiveRsp( void ); + void HW_IPCC_LLD_BLE_SendRspAck( void ); + + + void HW_IPCC_TRACES_Init( void ); + void HW_IPCC_TRACES_EvtNot( void ); + + void HW_IPCC_MAC_802_15_4_Init( void ); + void HW_IPCC_MAC_802_15_4_SendCmd( void ); + void HW_IPCC_MAC_802_15_4_SendAck( void ); + void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ); + void HW_IPCC_MAC_802_15_4_EvtNot( void ); + + void HW_IPCC_ZIGBEE_Init( void ); + + void HW_IPCC_ZIGBEE_SendM4RequestToM0(void); /* M4 Request to M0 */ + void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void); /* Request ACK from M0 */ + + void HW_IPCC_ZIGBEE_RecvM0NotifyToM4(void); /* M0 Notify to M4 */ + void HW_IPCC_ZIGBEE_SendM4AckToM0Notify(void); /* Notify ACK from M4 */ + void HW_IPCC_ZIGBEE_RecvM0RequestToM4(void); /* M0 Request to M4 */ + void HW_IPCC_ZIGBEE_SendM4AckToM0Request(void); /* Request ACK from M4 */ + + +#ifdef __cplusplus +} +#endif + +#endif /*__HW_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c new file mode 100644 index 00000000..6da31992 --- /dev/null +++ b/src/utility/STM32Cube_FW/hw_ipcc.c @@ -0,0 +1,517 @@ +/** + ****************************************************************************** + * File Name : Target/hw_ipcc.c + * Description : Hardware IPCC source file for STM32WPAN Middleware. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "app_common.h" +#include "mbox_def.h" + +/* Global variables ---------------------------------------------------------*/ +/* Private defines -----------------------------------------------------------*/ +#define HW_IPCC_TX_PENDING( channel ) ( !(LL_C1_IPCC_IsActiveFlag_CHx( IPCC, channel )) ) && (((~(IPCC->C1MR)) & (channel << 16U))) +#define HW_IPCC_RX_PENDING( channel ) (LL_C2_IPCC_IsActiveFlag_CHx( IPCC, channel )) && (((~(IPCC->C1MR)) & (channel << 0U))) + +/* Private macros ------------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +static void (*FreeBufCb)( void ); + +/* Private function prototypes -----------------------------------------------*/ +static void HW_IPCC_BLE_EvtHandler( void ); +static void HW_IPCC_BLE_AclDataEvtHandler( void ); +static void HW_IPCC_MM_FreeBufHandler( void ); +static void HW_IPCC_SYS_CmdEvtHandler( void ); +static void HW_IPCC_SYS_EvtHandler( void ); +static void HW_IPCC_TRACES_EvtHandler( void ); + +#ifdef THREAD_WB +static void HW_IPCC_OT_CmdEvtHandler( void ); +static void HW_IPCC_THREAD_NotEvtHandler( void ); +static void HW_IPCC_THREAD_CliNotEvtHandler( void ); +#endif + +#ifdef MAC_802_15_4_WB +static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ); +static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ); +#endif + +#ifdef ZIGBEE_WB +static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ); +static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ); +static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ); + +#endif + +/* Public function definition -----------------------------------------------*/ + +/****************************************************************************** + * INTERRUPT HANDLER + ******************************************************************************/ +void HW_IPCC_Rx_Handler( void ) +{ + if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL )) + { + HW_IPCC_SYS_EvtHandler(); + } +#ifdef MAC_802_15_4_WB + else if (HW_IPCC_RX_PENDING( HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL )) + { + HW_IPCC_MAC_802_15_4_NotEvtHandler(); + } +#endif /* MAC_802_15_4_WB */ +#ifdef THREAD_WB + else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL )) + { + HW_IPCC_THREAD_NotEvtHandler(); + } + else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL )) + { + HW_IPCC_THREAD_CliNotEvtHandler(); + } +#endif /* THREAD_WB */ +#ifdef ZIGBEE_WB + else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL )) + { + HW_IPCC_ZIGBEE_StackNotifEvtHandler(); + } + else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL )) + { + HW_IPCC_ZIGBEE_StackM0RequestHandler(); + } +#endif /* ZIGBEE_WB */ + else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL )) + { + HW_IPCC_BLE_EvtHandler(); + } + else if (HW_IPCC_RX_PENDING( HW_IPCC_TRACES_CHANNEL )) + { + HW_IPCC_TRACES_EvtHandler(); + } + + return; +} + +void HW_IPCC_Tx_Handler( void ) +{ + if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) + { + HW_IPCC_SYS_CmdEvtHandler(); + } +#ifdef MAC_802_15_4_WB + else if (HW_IPCC_TX_PENDING( HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL )) + { + HW_IPCC_MAC_802_15_4_CmdEvtHandler(); + } +#endif /* MAC_802_15_4_WB */ +#ifdef THREAD_WB + else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) + { + HW_IPCC_OT_CmdEvtHandler(); + } +#endif /* THREAD_WB */ +#ifdef ZIGBEE_WB + if (HW_IPCC_TX_PENDING( HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL )) + { + HW_IPCC_ZIGBEE_CmdEvtHandler(); + } +#endif /* ZIGBEE_WB */ + else if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) + { + HW_IPCC_SYS_CmdEvtHandler(); + } + else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL )) + { + HW_IPCC_MM_FreeBufHandler(); + } + else if (HW_IPCC_TX_PENDING( HW_IPCC_HCI_ACL_DATA_CHANNEL )) + { + HW_IPCC_BLE_AclDataEvtHandler(); + } + + return; +} +/****************************************************************************** + * GENERAL + ******************************************************************************/ +void HW_IPCC_Enable( void ) +{ + /** + * When the device is out of standby, it is required to use the EXTI mechanism to wakeup CPU2 + */ + LL_C2_EXTI_EnableEvent_32_63( LL_EXTI_LINE_41 ); + LL_EXTI_EnableRisingTrig_32_63( LL_EXTI_LINE_41 ); + + /** + * In case the SBSFU is implemented, it may have already set the C2BOOT bit to startup the CPU2. + * In that case, to keep the mechanism transparent to the user application, it shall call the system command + * SHCI_C2_Reinit( ) before jumping to the application. + * When the CPU2 receives that command, it waits for its event input to be set to restart the CPU2 firmware. + * This is required because once C2BOOT has been set once, a clear/set on C2BOOT has no effect. + * When SHCI_C2_Reinit( ) is not called, generating an event to the CPU2 does not have any effect + * So, by default, the application shall both set the event flag and set the C2BOOT bit. + */ + __SEV( ); /* Set the internal event flag and send an event to the CPU2 */ + __WFE( ); /* Clear the internal event flag */ + LL_PWR_EnableBootC2( ); + + return; +} + +void HW_IPCC_Init( void ) +{ + LL_AHB3_GRP1_EnableClock( LL_AHB3_GRP1_PERIPH_IPCC ); + + LL_C1_IPCC_EnableIT_RXO( IPCC ); + LL_C1_IPCC_EnableIT_TXF( IPCC ); + + HAL_NVIC_EnableIRQ(IPCC_C1_RX_IRQn); + HAL_NVIC_EnableIRQ(IPCC_C1_TX_IRQn); + + return; +} + +/****************************************************************************** + * BLE + ******************************************************************************/ +void HW_IPCC_BLE_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_BLE_EVENT_CHANNEL ); + + return; +} + +void HW_IPCC_BLE_SendCmd( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_BLE_CMD_CHANNEL ); + + return; +} + +static void HW_IPCC_BLE_EvtHandler( void ) +{ + HW_IPCC_BLE_RxEvtNot(); + + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_BLE_EVENT_CHANNEL ); + + return; +} + +void HW_IPCC_BLE_SendAclData( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); + + return; +} + +static void HW_IPCC_BLE_AclDataEvtHandler( void ) +{ + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); + + HW_IPCC_BLE_AclDataAckNot(); + + return; +} + +__weak void HW_IPCC_BLE_AclDataAckNot( void ){}; +__weak void HW_IPCC_BLE_RxEvtNot( void ){}; + +/****************************************************************************** + * SYSTEM + ******************************************************************************/ +void HW_IPCC_SYS_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL ); + + return; +} + +void HW_IPCC_SYS_SendCmd( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); + + return; +} + +static void HW_IPCC_SYS_CmdEvtHandler( void ) +{ + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); + + HW_IPCC_SYS_CmdEvtNot(); + + return; +} + +static void HW_IPCC_SYS_EvtHandler( void ) +{ + HW_IPCC_SYS_EvtNot(); + + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL ); + + return; +} + +__weak void HW_IPCC_SYS_CmdEvtNot( void ){}; +__weak void HW_IPCC_SYS_EvtNot( void ){}; + +/****************************************************************************** + * MAC 802.15.4 + ******************************************************************************/ +#ifdef MAC_802_15_4_WB +void HW_IPCC_MAC_802_15_4_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + + return; +} + +void HW_IPCC_MAC_802_15_4_SendCmd( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + + return; +} + +void HW_IPCC_MAC_802_15_4_SendAck( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + + return; +} + +static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ) +{ + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + + HW_IPCC_MAC_802_15_4_CmdEvtNot(); + + return; +} + +static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + + HW_IPCC_MAC_802_15_4_EvtNot(); + + return; +} +__weak void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ){}; +__weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){}; +#endif + +/****************************************************************************** + * THREAD + ******************************************************************************/ +#ifdef THREAD_WB +void HW_IPCC_THREAD_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); + + return; +} + +void HW_IPCC_OT_SendCmd( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); + + return; +} + +void HW_IPCC_CLI_SendCmd( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_CMD_CHANNEL ); + + return; +} + +void HW_IPCC_THREAD_SendAck( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); + + return; +} + +void HW_IPCC_THREAD_CliSendAck( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); + + return; +} + +static void HW_IPCC_OT_CmdEvtHandler( void ) +{ + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); + + HW_IPCC_OT_CmdEvtNot(); + + return; +} + +static void HW_IPCC_THREAD_NotEvtHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); + + HW_IPCC_THREAD_EvtNot(); + + return; +} + +static void HW_IPCC_THREAD_CliNotEvtHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); + + HW_IPCC_THREAD_CliEvtNot(); + + return; +} + +__weak void HW_IPCC_OT_CmdEvtNot( void ){}; +__weak void HW_IPCC_CLI_CmdEvtNot( void ){}; +__weak void HW_IPCC_THREAD_EvtNot( void ){}; + +#endif /* THREAD_WB */ + +/****************************************************************************** + * ZIGBEE + ******************************************************************************/ +#ifdef ZIGBEE_WB +void HW_IPCC_ZIGBEE_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + + return; +} + +void HW_IPCC_ZIGBEE_SendM4RequestToM0( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + + return; +} + +void HW_IPCC_ZIGBEE_SendM4AckToM0Notify( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + + return; +} + +static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ) +{ + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + + HW_IPCC_ZIGBEE_RecvAppliAckFromM0(); + + return; +} + +static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + + HW_IPCC_ZIGBEE_RecvM0NotifyToM4(); + + return; +} + +static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + + HW_IPCC_ZIGBEE_RecvM0RequestToM4(); + + return; +} + +void HW_IPCC_ZIGBEE_SendM4AckToM0Request( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + + return; +} + +__weak void HW_IPCC_ZIGBEE_RecvAppliAckFromM0( void ){}; +__weak void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ){}; +__weak void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ){}; +#endif /* ZIGBEE_WB */ + +/****************************************************************************** + * MEMORY MANAGER + ******************************************************************************/ +void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) ) +{ + if ( LL_C1_IPCC_IsActiveFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ) ) + { + FreeBufCb = cb; + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); + } + else + { + cb(); + + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); + } + + return; +} + +static void HW_IPCC_MM_FreeBufHandler( void ) +{ + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); + + FreeBufCb(); + + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); + + return; +} + +/****************************************************************************** + * TRACES + ******************************************************************************/ +void HW_IPCC_TRACES_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_TRACES_CHANNEL ); + + return; +} + +static void HW_IPCC_TRACES_EvtHandler( void ) +{ + HW_IPCC_TRACES_EvtNot(); + + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_TRACES_CHANNEL ); + + return; +} + +__weak void HW_IPCC_TRACES_EvtNot( void ){}; + +/******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h new file mode 100644 index 00000000..1741a8c3 --- /dev/null +++ b/src/utility/STM32Cube_FW/mbox_def.h @@ -0,0 +1,258 @@ +/** + ****************************************************************************** + * @file mbox_def.h + * @author MCD Application Team + * @brief Mailbox definition + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MBOX_H +#define __MBOX_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "stm32_wpan_common.h" + + /** + * This file shall be identical between the CPU1 and the CPU2 + */ + + /** + ********************************************************************************* + * TABLES + ********************************************************************************* + */ + + /** + * Version + * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version + * [4:7] = branch - 0: Mass Market - x: ... + * [8:15] = Subversion + * [16:23] = Version minor + * [24:31] = Version major + * + * Memory Size + * [0:7] = Flash ( Number of 4k sector) + * [8:15] = Reserved ( Shall be set to 0 - may be used as flash extension ) + * [16:23] = SRAM2b ( Number of 1k sector) + * [24:31] = SRAM2a ( Number of 1k sector) + */ + typedef PACKED_STRUCT + { + uint32_t Version; + } MB_SafeBootInfoTable_t; + + typedef PACKED_STRUCT + { + uint32_t Version; + uint32_t MemorySize; + uint32_t FusInfo; + } MB_FusInfoTable_t; + + typedef PACKED_STRUCT + { + uint32_t Version; + uint32_t MemorySize; + uint32_t InfoStack; + uint32_t Reserved; + } MB_WirelessFwInfoTable_t; + + typedef struct + { + MB_SafeBootInfoTable_t SafeBootInfoTable; + MB_FusInfoTable_t FusInfoTable; + MB_WirelessFwInfoTable_t WirelessFwInfoTable; + } MB_DeviceInfoTable_t; + + typedef struct + { + uint8_t *pcmd_buffer; + uint8_t *pcs_buffer; + uint8_t *pevt_queue; + uint8_t *phci_acl_data_buffer; + } MB_BleTable_t; + + typedef struct + { + uint8_t *notack_buffer; + uint8_t *clicmdrsp_buffer; + uint8_t *otcmdrsp_buffer; + } MB_ThreadTable_t; + + typedef struct + { + uint8_t *clicmdrsp_buffer; + uint8_t *m0cmd_buffer; + } MB_LldTestsTable_t; + + typedef struct + { + uint8_t *cmdrsp_buffer; + uint8_t *m0cmd_buffer; + } MB_LldBleTable_t; + + typedef struct + { + uint8_t *notifM0toM4_buffer; + uint8_t *appliCmdM4toM0_buffer; + uint8_t *requestM0toM4_buffer; + } MB_ZigbeeTable_t; + /** + * msg + * [0:7] = cmd/evt + * [8:31] = Reserved + */ + typedef struct + { + uint8_t *pcmd_buffer; + uint8_t *sys_queue; + } MB_SysTable_t; + + typedef struct + { + uint8_t *spare_ble_buffer; + uint8_t *spare_sys_buffer; + uint8_t *blepool; + uint32_t blepoolsize; + uint8_t *pevt_free_buffer_queue; + uint8_t *traces_evt_pool; + uint32_t tracespoolsize; + } MB_MemManagerTable_t; + + typedef struct + { + uint8_t *traces_queue; + } MB_TracesTable_t; + + typedef struct + { + uint8_t *p_cmdrsp_buffer; + uint8_t *p_notack_buffer; + uint8_t *evt_queue; + } MB_Mac_802_15_4_t; + + typedef struct + { + MB_DeviceInfoTable_t *p_device_info_table; + MB_BleTable_t *p_ble_table; + MB_ThreadTable_t *p_thread_table; + MB_SysTable_t *p_sys_table; + MB_MemManagerTable_t *p_mem_manager_table; + MB_TracesTable_t *p_traces_table; + MB_Mac_802_15_4_t *p_mac_802_15_4_table; + MB_ZigbeeTable_t *p_zigbee_table; + MB_LldTestsTable_t *p_lld_tests_table; + MB_LldBleTable_t *p_lld_ble_table; +} MB_RefTable_t; + +#ifdef __cplusplus +} +#endif + +/** + ********************************************************************************* + * IPCC CHANNELS + ********************************************************************************* + */ + +/* CPU1 CPU2 + * | (SYSTEM) | + * |----HW_IPCC_SYSTEM_CMD_RSP_CHANNEL-------------->| + * | | + * |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------| + * | | + * | (ZIGBEE) | + * |----HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL------------>| + * | | + * |----HW_IPCC_ZIGBEE_CMD_CLI_CHANNEL-------------->| + * | | + * |<---HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL-------| + * | | + * |<---HW_IPCC_ZIGBEE_CLI_NOTIF_ACK_CHANNEL---------| + * | | + * | (THREAD) | + * |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->| + * | | + * |----HW_IPCC_THREAD_CLI_CMD_CHANNEL-------------->| + * | | + * |<---HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL------| + * | | + * |<---HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL--| + * | | + * | (BLE) | + * |----HW_IPCC_BLE_CMD_CHANNEL--------------------->| + * | | + * |----HW_IPCC_HCI_ACL_DATA_CHANNEL---------------->| + * | | + * |<---HW_IPCC_BLE_EVENT_CHANNEL--------------------| + * | | + * | (LLD BLE) | + * |----HW_IPCC_LLD_BLE_CMD_CHANNEL----------------->| + * | | + * |<---HW_IPCC_LLD_BLE_RSP_CHANNEL------------------| + * | | + * |<---HW_IPCC_LLD_BLE_M0_CMD_CHANNEL---------------| + * | | + * | (MAC) | + * |----HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL-------->| + * | | + * |<---HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL| + * | | + * | (BUFFER) | + * |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>| + * | | + * | (TRACE) | + * |<----HW_IPCC_TRACES_CHANNEL----------------------| + * | | + * + * + * + */ + + + +/** CPU1 */ +#define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1 +#define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2 +#define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4 +#define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_LLD_BLE_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_LLD_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_HCI_ACL_DATA_CHANNEL LL_IPCC_CHANNEL_6 + +/** CPU2 */ +#define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1 +#define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2 +#define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_LLD_BLE_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4 +#define HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_LLD_BLE_RSP_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL LL_IPCC_CHANNEL_5 +#endif /*__MBOX_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c new file mode 100644 index 00000000..1edf1feb --- /dev/null +++ b/src/utility/STM32Cube_FW/shci.c @@ -0,0 +1,609 @@ +/** + ****************************************************************************** + * @file shci.c + * @author MCD Application Team + * @brief HCI command for the system channel + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "stm32_wpan_common.h" + +#include "shci_tl.h" +#include "shci.h" +#include "stm32wbxx.h" + +/* Private typedef -----------------------------------------------------------*/ +/* Private defines -----------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Global variables ----------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Local Functions Definition ------------------------------------------------------*/ +/* Public Functions Definition ------------------------------------------------------*/ + +/** + * C2 COMMAND + * These commands are sent to the CPU2 + */ +uint8_t SHCI_C2_FUS_GetState( SHCI_FUS_GetState_ErrorCode_t *p_error_code ) +{ + /** + * A command status event + payload has the same size than the expected command complete + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE + 1]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_FUS_GET_STATE, + 0, + 0, + p_rsp ); + + if(p_error_code != 0) + { + *p_error_code = (SHCI_FUS_GetState_ErrorCode_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1]); + } + + return (((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade( uint32_t fw_src_add, uint32_t fw_dest_add ) +{ + /** + * TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 8 bytes of command parameters + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + uint32_t *p_cmd; + uint8_t cmd_length; + + p_cmd = (uint32_t*)local_buffer; + cmd_length = 0; + + if(fw_src_add != 0) + { + *p_cmd = fw_src_add; + cmd_length += 4; + } + + if(fw_dest_add != 0) + { + *(p_cmd+1) = fw_dest_add; + cmd_length += 4; + } + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_FUS_FW_UPGRADE, + cmd_length, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_FUS_FW_DELETE, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t *pParam ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_FUS_UPDATE_AUTH_KEY, + sizeof( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t ), + (uint8_t*)pParam, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_FUS_LOCK_AUTH_KEY, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey( SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *pParam, uint8_t *p_key_index ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE + 1]; + TL_EvtPacket_t * p_rsp; + uint8_t local_payload_len; + + if(pParam->KeyType == KEYTYPE_ENCRYPTED) + { + /** + * When the key is encrypted, the 12 bytes IV Key is included in the payload as well + * The IV key is always 12 bytes + */ + local_payload_len = pParam->KeySize + 2 + 12; + } + else + { + local_payload_len = pParam->KeySize + 2; + } + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_FUS_STORE_USR_KEY, + local_payload_len , + (uint8_t*)pParam, + p_rsp ); + + *p_key_index = (((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1]); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey( uint8_t key_index ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + local_buffer[0] = key_index; + + shci_send( SHCI_OPCODE_C2_FUS_LOAD_USR_KEY, + 1, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_FUS_StartWs( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_FUS_START_WS, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + + +SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey( uint8_t key_index ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + local_buffer[0] = key_index; + + shci_send( SHCI_OPCODE_C2_FUS_LOCK_USR_KEY, + 1, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_BLE_INIT, + sizeof( SHCI_C2_Ble_Init_Cmd_Param_t ), + (uint8_t*)&pCmdPacket->Param, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_THREAD_Init( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_THREAD_INIT, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_LLD_TESTS_INIT, + param_size, + p_param, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init( uint8_t param_size, uint8_t * p_param ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_LLD_BLE_INIT, + param_size, + p_param, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_ZIGBEE_INIT, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_DEBUG_INIT, + sizeof( SHCI_C2_DEBUG_init_Cmd_Param_t ), + (uint8_t*)&pCmdPacket->Param, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity( SHCI_EraseActivity_t erase_activity ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + local_buffer[0] = erase_activity; + + shci_send( SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY, + 1, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mode ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + local_buffer[0] = Mode; + + shci_send( SHCI_OPCODE_C2_CONCURRENT_SET_MODE, + 1, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + local_buffer[0] = Ip; + + shci_send( SHCI_OPCODE_C2_FLASH_STORE_DATA, + 1, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData( SHCI_C2_FLASH_Ip_t Ip ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + local_buffer[0] = Ip; + + shci_send( SHCI_OPCODE_C2_FLASH_ERASE_DATA, + 1, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + local_buffer[0] = Ip; + local_buffer[1] = FlagRadioLowPowerOn; + + shci_send( SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER, + 2, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_MAC_802_15_4_INIT, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_Reinit( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_REINIT, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_number, uint8_t gpio_polarity, uint8_t gpio_status) +{ + /** + * TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 8 bytes of command parameters + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_port = gpio_port; + ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_pin_number = gpio_pin_number; + ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_polarity = gpio_polarity; + ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_status = gpio_status; + + shci_send( SHCI_OPCODE_C2_EXTPA_CONFIG, + 8, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t Source) +{ + /** + * TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 1 byte of command parameter + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + local_buffer[0] = (uint8_t)Source; + + shci_send( SHCI_OPCODE_C2_SET_FLASH_ACTIVITY_CONTROL, + 1, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_CONFIG, + sizeof(SHCI_C2_CONFIG_Cmd_Param_t), + (uint8_t*)pCmdPacket, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + + +/** + * Local System COMMAND + * These commands are NOT sent to the CPU2 + */ + +SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) +{ + uint32_t ipccdba = 0; + MB_RefTable_t * p_RefTable = NULL; + uint32_t version = 0; + uint32_t memorySize = 0; + uint32_t infoStack = 0; + + ipccdba = READ_BIT( FLASH->IPCCBR, FLASH_IPCCBR_IPCCDBA ); + p_RefTable = (MB_RefTable_t*)((ipccdba<<2) + SRAM2A_BASE); + + /** + * Retrieve the WirelessFwInfoTable + * This table is stored in RAM at startup during the TL (transport layer) initialization + */ + version = p_RefTable->p_device_info_table->WirelessFwInfoTable.Version; + pWirelessInfo->VersionMajor = ((version & INFO_VERSION_MAJOR_MASK) >> INFO_VERSION_MAJOR_OFFSET); + pWirelessInfo->VersionMinor = ((version & INFO_VERSION_MINOR_MASK) >> INFO_VERSION_MINOR_OFFSET); + pWirelessInfo->VersionSub = ((version & INFO_VERSION_SUB_MASK) >> INFO_VERSION_SUB_OFFSET); + pWirelessInfo->VersionBranch = ((version & INFO_VERSION_BRANCH_MASK) >> INFO_VERSION_BRANCH_OFFSET); + pWirelessInfo->VersionReleaseType = ((version & INFO_VERSION_TYPE_MASK) >> INFO_VERSION_TYPE_OFFSET); + + memorySize = p_RefTable->p_device_info_table->WirelessFwInfoTable.MemorySize; + pWirelessInfo->MemorySizeSram2B = ((memorySize & INFO_SIZE_SRAM2B_MASK) >> INFO_SIZE_SRAM2B_OFFSET); + pWirelessInfo->MemorySizeSram2A = ((memorySize & INFO_SIZE_SRAM2A_MASK) >> INFO_SIZE_SRAM2A_OFFSET); + pWirelessInfo->MemorySizeSram1 = ((memorySize & INFO_SIZE_SRAM1_MASK) >> INFO_SIZE_SRAM1_OFFSET); + pWirelessInfo->MemorySizeFlash = ((memorySize & INFO_SIZE_FLASH_MASK) >> INFO_SIZE_FLASH_OFFSET); + + infoStack = p_RefTable->p_device_info_table->WirelessFwInfoTable.InfoStack; + pWirelessInfo->StackType = ((infoStack & INFO_STACK_TYPE_MASK) >> INFO_STACK_TYPE_OFFSET); + + /** + * Retrieve the FusInfoTable + * This table is stored in RAM at startup during the TL (transport layer) initialization + */ + version = p_RefTable->p_device_info_table->FusInfoTable.Version; + pWirelessInfo->FusVersionMajor = ((version & INFO_VERSION_MAJOR_MASK) >> INFO_VERSION_MAJOR_OFFSET); + pWirelessInfo->FusVersionMinor = ((version & INFO_VERSION_MINOR_MASK) >> INFO_VERSION_MINOR_OFFSET); + pWirelessInfo->FusVersionSub = ((version & INFO_VERSION_SUB_MASK) >> INFO_VERSION_SUB_OFFSET); + + memorySize = p_RefTable->p_device_info_table->FusInfoTable.MemorySize; + pWirelessInfo->FusMemorySizeSram2B = ((memorySize & INFO_SIZE_SRAM2B_MASK) >> INFO_SIZE_SRAM2B_OFFSET); + pWirelessInfo->FusMemorySizeSram2A = ((memorySize & INFO_SIZE_SRAM2A_MASK) >> INFO_SIZE_SRAM2A_OFFSET); + pWirelessInfo->FusMemorySizeFlash = ((memorySize & INFO_SIZE_FLASH_MASK) >> INFO_SIZE_FLASH_OFFSET); + + return (SHCI_Success); +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h new file mode 100644 index 00000000..e737f4c5 --- /dev/null +++ b/src/utility/STM32Cube_FW/shci.h @@ -0,0 +1,944 @@ +/** + ****************************************************************************** + * @file shci.h + * @author MCD Application Team + * @brief HCI command for the system channel + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __SHCI_H +#define __SHCI_H + +#ifdef __cplusplus +extern "C" { +#endif + + /* Includes ------------------------------------------------------------------*/ +#include "mbox_def.h" /* Requested to expose the MB_WirelessFwInfoTable_t structure */ + + /* Exported types ------------------------------------------------------------*/ + + /* SYSTEM EVENT */ + typedef enum + { + WIRELESS_FW_RUNNING = 0x00, + RSS_FW_RUNNING = 0x01, + } SHCI_SysEvt_Ready_Rsp_t; + + /* ERROR CODES + * + * These error codes are detected on M0 side and are send back to the M4 via a system + * notification message. It is up to the application running on M4 to manage these errors + * + * These errors can be generated by all layers (low level driver, stack, framework infrastructure, etc..) + */ + typedef enum + { + ERR_BLE_INIT = 0, + ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ + ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the M4 to control the Thread stack is unknown */ + ERR_ZIGBEE_UNKNOWN_CMD = 200, /* The command send by the M4 to control the Zigbee stack is unknown */ + } SCHI_SystemErrCode_t; + +#define SHCI_EVTCODE ( 0xFF ) +#define SHCI_SUB_EVT_CODE_BASE ( 0x9200 ) + + /** + * THE ORDER SHALL NOT BE CHANGED TO GUARANTEE COMPATIBILITY WITH THE CPU1 DEFINITION + */ + typedef enum + { + SHCI_SUB_EVT_CODE_READY = SHCI_SUB_EVT_CODE_BASE, + SHCI_SUB_EVT_ERROR_NOTIF, + SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE, + SHCI_SUB_EVT_OT_NVM_RAM_UPDATE, + SHCI_SUB_EVT_NVM_START_WRITE, + SHCI_SUB_EVT_NVM_END_WRITE, + SHCI_SUB_EVT_NVM_START_ERASE, + SHCI_SUB_EVT_NVM_END_ERASE, + } SHCI_SUB_EVT_CODE_t; + + /** + * SHCI_SUB_EVT_CODE_READY + * This notifies the CPU1 that the CPU2 is now ready to receive commands + * It reports as well which firmware is running on CPU2 : The wireless stack of the FUS (previously named RSS) + */ + typedef PACKED_STRUCT{ + SHCI_SysEvt_Ready_Rsp_t sysevt_ready_rsp; + } SHCI_C2_Ready_Evt_t; + + /** + * SHCI_SUB_EVT_ERROR_NOTIF + * This reports to the CPU1 some error form the CPU2 + */ + typedef PACKED_STRUCT{ + SCHI_SystemErrCode_t errorCode; + } SHCI_C2_ErrorNotif_Evt_t; + + /** + * SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE + * This notifies the CPU1 which part of the BLE NVM RAM has been updated so that only the modified + * section could be written in Flash/NVM + * StartAddress : Start address of the section that has been modified + * Size : Size (in bytes) of the section that has been modified + */ + typedef PACKED_STRUCT{ + uint32_t StartAddress; + uint32_t Size; + } SHCI_C2_BleNvmRamUpdate_Evt_t; + + /** + * SHCI_SUB_EVT_OT_NVM_RAM_UPDATE + * This notifies the CPU1 which part of the OT NVM RAM has been updated so that only the modified + * section could be written in Flash/NVM + * StartAddress : Start address of the section that has been modified + * Size : Size (in bytes) of the section that has been modified + */ + typedef PACKED_STRUCT{ + uint32_t StartAddress; + uint32_t Size; + } SHCI_C2_OtNvmRamUpdate_Evt_t; + + /** + * SHCI_SUB_EVT_NVM_START_WRITE + * This notifies the CPU1 that the CPU2 has started a write procedure in Flash + * NumberOfWords : The number of 64bits data the CPU2 needs to write in Flash. + * For each 64bits data, the algorithm as described in AN5289 is executed. + * When this number is reported to 0, it means the Number of 64bits to be written + * was unknown when the procedure has started. + * When all data are written, the SHCI_SUB_EVT_NVM_END_WRITE event is reported + */ + typedef PACKED_STRUCT{ + uint32_t NumberOfWords; + } SHCI_C2_NvmStartWrite_Evt_t; + + /** + * SHCI_SUB_EVT_NVM_END_WRITE + * This notifies the CPU1 that the CPU2 has written all expected data in Flash + */ + + /** + * SHCI_SUB_EVT_NVM_START_ERASE + * This notifies the CPU1 that the CPU2 has started a erase procedure in Flash + * NumberOfSectors : The number of sectors the CPU2 needs to erase in Flash. + * For each sector, the algorithm as described in AN5289 is executed. + * When this number is reported to 0, it means the Number of sectors to be erased + * was unknown when the procedure has started. + * When all sectors are erased, the SHCI_SUB_EVT_NVM_END_ERASE event is reported + */ + typedef PACKED_STRUCT{ + uint32_t NumberOfSectors; + } SHCI_C2_NvmStartErase_Evt_t; + + /** + * SHCI_SUB_EVT_NVM_END_ERASE + * This notifies the CPU1 that the CPU2 has erased all expected flash sectors + */ + + /* SYSTEM COMMAND */ + typedef PACKED_STRUCT + { + uint32_t MetaData[3]; + } SHCI_Header_t; + + typedef enum + { + SHCI_Success = 0x00, + SHCI_UNKNOWN_CMD = 0x01, + SHCI_ERR_UNSUPPORTED_FEATURE = 0x11, + SHCI_ERR_INVALID_HCI_CMD_PARAMS = 0x12, + SHCI_FUS_CMD_NOT_SUPPORTED = 0xFF, + } SHCI_CmdStatus_t; + + typedef enum + { + SHCI_8BITS = 0x01, + SHCI_16BITS = 0x02, + SHCI_32BITS = 0x04, + } SHCI_Busw_t; + +#define SHCI_OGF ( 0x3F ) +#define SHCI_OCF_BASE ( 0x50 ) + + /** + * THE ORDER SHALL NOT BE CHANGED TO GUARANTEE COMPATIBILITY WITH THE CPU2 DEFINITION + */ + typedef enum + { + SHCI_OCF_C2_RESERVED1 = SHCI_OCF_BASE, + SHCI_OCF_C2_RESERVED2, + SHCI_OCF_C2_FUS_GET_STATE, + SHCI_OCF_C2_FUS_RESERVED1, + SHCI_OCF_C2_FUS_FW_UPGRADE, + SHCI_OCF_C2_FUS_FW_DELETE, + SHCI_OCF_C2_FUS_UPDATE_AUTH_KEY, + SHCI_OCF_C2_FUS_LOCK_AUTH_KEY, + SHCI_OCF_C2_FUS_STORE_USR_KEY, + SHCI_OCF_C2_FUS_LOAD_USR_KEY, + SHCI_OCF_C2_FUS_START_WS, + SHCI_OCF_C2_FUS_RESERVED2, + SHCI_OCF_C2_FUS_RESERVED3, + SHCI_OCF_C2_FUS_LOCK_USR_KEY, + SHCI_OCF_C2_FUS_RESERVED5, + SHCI_OCF_C2_FUS_RESERVED6, + SHCI_OCF_C2_FUS_RESERVED7, + SHCI_OCF_C2_FUS_RESERVED8, + SHCI_OCF_C2_FUS_RESERVED9, + SHCI_OCF_C2_FUS_RESERVED10, + SHCI_OCF_C2_FUS_RESERVED11, + SHCI_OCF_C2_FUS_RESERVED12, + SHCI_OCF_C2_BLE_INIT, + SHCI_OCF_C2_THREAD_INIT, + SHCI_OCF_C2_DEBUG_INIT, + SHCI_OCF_C2_FLASH_ERASE_ACTIVITY, + SHCI_OCF_C2_CONCURRENT_SET_MODE, + SHCI_OCF_C2_FLASH_STORE_DATA, + SHCI_OCF_C2_FLASH_ERASE_DATA, + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, + SHCI_OCF_C2_MAC_802_15_4_INIT, + SHCI_OCF_C2_REINIT, + SHCI_OCF_C2_ZIGBEE_INIT, + SHCI_OCF_C2_LLD_TESTS_INIT, + SHCI_OCF_C2_EXTPA_CONFIG, + SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, + SHCI_OCF_C2_LLD_BLE_INIT, + SHCI_OCF_C2_CONFIG, + } SHCI_OCF_t; + +#define SHCI_OPCODE_C2_FUS_GET_STATE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_GET_STATE) +/** No command parameters */ +/** Response parameters*/ + typedef enum + { + FUS_STATE_NO_ERROR = 0x00, + FUS_STATE_IMG_NOT_FOUND = 0x01, + FUS_STATE_IMG_CORRUPT = 0x02, + FUS_STATE_IMG_NOT_AUTHENTIC = 0x03, + FUS_STATE_IMG_NOT_ENOUGH_SPACE = 0x04, + FUS_STATE_ERR_UNKNOWN = 0xFF, + } SHCI_FUS_GetState_ErrorCode_t; + +#define SHCI_OPCODE_C2_FUS_RESERVED1 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED1) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_FW_UPGRADE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_FW_UPGRADE) + /** No structure for command parameters */ + /** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_FW_DELETE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_FW_DELETE) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_UPDATE_AUTH_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_UPDATE_AUTH_KEY) + typedef PACKED_STRUCT{ + uint8_t KeySize; + uint8_t KeyData[64]; + } SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t; + + /** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_LOCK_AUTH_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOCK_AUTH_KEY) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_STORE_USR_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_STORE_USR_KEY) + /** Command parameters */ + /* List of supported key type */ + enum + { + KEYTYPE_NONE = 0x00, + KEYTYPE_SIMPLE = 0x01, + KEYTYPE_MASTER = 0x02, + KEYTYPE_ENCRYPTED = 0x03, + }; + + /* List of supported key size */ + enum + { + KEYSIZE_16 = 16, + KEYSIZE_32 = 32, + }; + + typedef PACKED_STRUCT{ + uint8_t KeyType; + uint8_t KeySize; + uint8_t KeyData[32 + 12]; + } SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t; + + /** Response parameters*/ + /** It responds a 1 byte value holding the index given for the stored key */ + +#define SHCI_OPCODE_C2_FUS_LOAD_USR_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOAD_USR_KEY) + /** Command parameters */ + /** 1 byte holding the key index value */ + + /** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_START_WS (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_START_WS) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_RESERVED2 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED2) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_RESERVED3 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED3) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_LOCK_USR_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOCK_USR_KEY) + /** Command parameters */ + /** 1 byte holding the key index value */ + + /** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_RESERVED5 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED5) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_RESERVED6 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED6) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_RESERVED7 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED7) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_RESERVED8 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED8) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_RESERVED9 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED9) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_RESERVED10 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED10) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_RESERVED11 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED11) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_FUS_RESERVED12 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED12) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_BLE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_INIT) + /** THE ORDER SHALL NOT BE CHANGED */ + typedef PACKED_STRUCT{ + uint8_t* pBleBufferAddress; /**< NOT USED CURRENTLY */ + uint32_t BleBufferSize; /**< Size of the Buffer allocated in pBleBufferAddress */ + uint16_t NumAttrRecord; + uint16_t NumAttrServ; + uint16_t AttrValueArrSize; + uint8_t NumOfLinks; + uint8_t ExtendedPacketLengthEnable; + uint8_t PrWriteListSize; + uint8_t MblockCount; + uint16_t AttMtu; + uint16_t SlaveSca; + uint8_t MasterSca; + uint8_t LsSource; + uint32_t MaxConnEventLength; + uint16_t HsStartupTime; + uint8_t ViterbiEnable; + uint8_t LlOnly; + uint8_t HwVersion; + } SHCI_C2_Ble_Init_Cmd_Param_t; + + typedef PACKED_STRUCT{ + SHCI_Header_t Header; /** Does not need to be initialized by the user */ + SHCI_C2_Ble_Init_Cmd_Param_t Param; + } SHCI_C2_Ble_Init_Cmd_Packet_t; + + /** No response parameters*/ + +#define SHCI_OPCODE_C2_THREAD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_THREAD_INIT) +/** No command parameters */ +/** No response parameters*/ + +#define SHCI_OPCODE_C2_DEBUG_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_DEBUG_INIT) + /** Command parameters */ + typedef PACKED_STRUCT + { + uint8_t thread_config; + uint8_t ble_config; + uint8_t mac_802_15_4_config; + uint8_t zigbee_config; + } SHCI_C2_DEBUG_TracesConfig_t; + + typedef PACKED_STRUCT + { + uint8_t ble_dtb_cfg; + uint8_t reserved[3]; + } SHCI_C2_DEBUG_GeneralConfig_t; + + typedef PACKED_STRUCT{ + uint8_t *pGpioConfig; + uint8_t *pTracesConfig; + uint8_t *pGeneralConfig; + uint8_t GpioConfigSize; + uint8_t TracesConfigSize; + uint8_t GeneralConfigSize; + } SHCI_C2_DEBUG_init_Cmd_Param_t; + + typedef PACKED_STRUCT{ + SHCI_Header_t Header; /** Does not need to be initialized by the user */ + SHCI_C2_DEBUG_init_Cmd_Param_t Param; + } SHCI_C2_DEBUG_Init_Cmd_Packet_t; + /** No response parameters*/ + +#define SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_ERASE_ACTIVITY) + /** Command parameters */ + typedef enum + { + ERASE_ACTIVITY_OFF = 0x00, + ERASE_ACTIVITY_ON = 0x01, + } SHCI_EraseActivity_t; + + /** No response parameters*/ + +#define SHCI_OPCODE_C2_CONCURRENT_SET_MODE (( SHCI_OGF << 10) + SHCI_OCF_C2_CONCURRENT_SET_MODE) +/** command parameters */ + typedef enum + { + BLE_ENABLE, + THREAD_ENABLE, + ZIGBEE_ENABLE, + } SHCI_C2_CONCURRENT_Mode_Param_t; + /** No response parameters*/ + +#define SHCI_OPCODE_C2_FLASH_STORE_DATA (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_STORE_DATA) +#define SHCI_OPCODE_C2_FLASH_ERASE_DATA (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_ERASE_DATA) +/** command parameters */ + typedef enum + { + BLE_IP, + THREAD_IP, + ZIGBEE_IP, + } SHCI_C2_FLASH_Ip_t; + /** No response parameters*/ + +#define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) + +#define SHCI_OPCODE_C2_MAC_802_15_4_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_MAC_802_15_4_INIT) + +#define SHCI_OPCODE_C2_REINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_REINIT) + +#define SHCI_OPCODE_C2_ZIGBEE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_ZIGBEE_INIT) + +#define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) + +#define SHCI_OPCODE_C2_LLD_BLE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_BLE_INIT) + +#define SHCI_OPCODE_C2_EXTPA_CONFIG (( SHCI_OGF << 10) + SHCI_OCF_C2_EXTPA_CONFIG) + /** Command parameters */ + enum + { + EXT_PA_ENABLED_LOW, + EXT_PA_ENABLED_HIGH, + }/* gpio_polarity */; + + enum + { + EXT_PA_DISABLED, + EXT_PA_ENABLED, + }/* gpio_status */; + + typedef PACKED_STRUCT{ + uint32_t gpio_port; + uint16_t gpio_pin_number; + uint8_t gpio_polarity; + uint8_t gpio_status; + } SHCI_C2_EXTPA_CONFIG_Cmd_Param_t; + + /** No response parameters*/ + +#define SHCI_OPCODE_C2_SET_FLASH_ACTIVITY_CONTROL (( SHCI_OGF << 10) + SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL) + /** Command parameters */ + typedef enum + { + FLASH_ACTIVITY_CONTROL_PES, + FLASH_ACTIVITY_CONTROL_SEM7, + }SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t; + + /** No response parameters*/ + +#define SHCI_OPCODE_C2_CONFIG (( SHCI_OGF << 10) + SHCI_OCF_C2_CONFIG) + /** Command parameters */ + typedef PACKED_STRUCT{ + uint8_t PayloadCmdSize; + uint8_t Config1; + uint8_t EvtMask1; + uint8_t Spare1; + uint32_t BleNvmRamAddress; + uint32_t ThreadNvmRamAddress; + } SHCI_C2_CONFIG_Cmd_Param_t; + +/** + * PayloadCmdSize + * Value that shall be used + */ +#define SHCI_C2_CONFIG_PAYLOAD_CMD_SIZE (sizeof(SHCI_C2_CONFIG_Cmd_Param_t) - 1) + +/** + * Config1 + * Each definition below may be added together to build the Config1 value + * WARNING : Only one definition per bit shall be added to build the Config1 value + */ +#define SHCI_C2_CONFIG_CONFIG1_BIT0_BLE_NVM_DATA_TO_INTERNAL_FLASH (0<<0) +#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) + +/** + * EvtMask1 + * Each definition below may be added together to build the EvtMask1 value + */ +#define SHCI_C2_CONFIG_EVTMASK1_BIT0_ERROR_NOTIF_ENABLE (1<<0) +#define SHCI_C2_CONFIG_EVTMASK1_BIT1_BLE_NVM_RAM_UPDATE_ENABLE (1<<1) +#define SHCI_C2_CONFIG_EVTMASK1_BIT2_OT_NVM_RAM_UPDATE_ENABLE (1<<2) +#define SHCI_C2_CONFIG_EVTMASK1_BIT3_NVM_START_WRITE_ENABLE (1<<3) +#define SHCI_C2_CONFIG_EVTMASK1_BIT4_NVM_END_WRITE_ENABLE (1<<4) +#define SHCI_C2_CONFIG_EVTMASK1_BIT5_NVM_START_ERASE_ENABLE (1<<5) +#define SHCI_C2_CONFIG_EVTMASK1_BIT6_NVM_END_ERASE_ENABLE (1<<6) + +/** + * BleNvmRamAddress + * The buffer shall have a size of BLE_NVM_SRAM_SIZE number of 32bits + * The buffer shall be allocated in SRAM2 + */ +#define BLE_NVM_SRAM_SIZE (507) + +/** + * ThreadNvmRamAddress + * The buffer shall have a size of THREAD_NVM_SRAM_SIZE number of 32bits + * The buffer shall be allocated in SRAM2 + */ +#define THREAD_NVM_SRAM_SIZE (1016) + + + /** No response parameters*/ + + /* Exported type --------------------------------------------------------*/ + +typedef MB_WirelessFwInfoTable_t SHCI_WirelessFwInfoTable_t; + +/* + * At startup, the informations relative to the wireless binary are stored in RAM trough a structure defined by + * SHCI_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) + * each of those coded on 32 bits as shown on the table below: + * + * + * |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 | + * ------------------------------------------------------------------------------------------------- + * Version | Major version | Minor version | Sub version | Branch |Releas Type| + * ------------------------------------------------------------------------------------------------- + * MemorySize | SRAM2B (kB) | SRAM2A (kB) | SRAM1 (kB) | FLASH (4kb) | + * ------------------------------------------------------------------------------------------------- + * Info stack | Reserved | Reserved | Reserved | Type (MAC,Thread,BLE) | + * ------------------------------------------------------------------------------------------------- + * Reserved | Reserved | Reserved | Reserved | Reserved | + * ------------------------------------------------------------------------------------------------- + * + */ + +/* Field Version */ +#define INFO_VERSION_MAJOR_OFFSET 24 +#define INFO_VERSION_MAJOR_MASK 0xff000000 +#define INFO_VERSION_MINOR_OFFSET 16 +#define INFO_VERSION_MINOR_MASK 0x00ff0000 +#define INFO_VERSION_SUB_OFFSET 8 +#define INFO_VERSION_SUB_MASK 0x0000ff00 +#define INFO_VERSION_BRANCH_OFFSET 4 +#define INFO_VERSION_BRANCH_MASK 0x0000000f0 +#define INFO_VERSION_TYPE_OFFSET 0 +#define INFO_VERSION_TYPE_MASK 0x00000000f + +#define INFO_VERSION_TYPE_RELEASE 1 + +/* Field Memory */ +#define INFO_SIZE_SRAM2B_OFFSET 24 +#define INFO_SIZE_SRAM2B_MASK 0xff000000 +#define INFO_SIZE_SRAM2A_OFFSET 16 +#define INFO_SIZE_SRAM2A_MASK 0x00ff0000 +#define INFO_SIZE_SRAM1_OFFSET 8 +#define INFO_SIZE_SRAM1_MASK 0x0000ff00 +#define INFO_SIZE_FLASH_OFFSET 0 +#define INFO_SIZE_FLASH_MASK 0x000000ff + +/* Field stack information */ +#define INFO_STACK_TYPE_OFFSET 0 +#define INFO_STACK_TYPE_MASK 0x000000ff +#define INFO_STACK_TYPE_NONE 0 + +#define INFO_STACK_TYPE_BLE_STANDARD 0x01 +#define INFO_STACK_TYPE_BLE_HCI 0x02 +#define INFO_STACK_TYPE_BLE_LIGHT 0x03 +#define INFO_STACK_TYPE_THREAD_FTD 0x10 +#define INFO_STACK_TYPE_THREAD_MTD 0x11 +#define INFO_STACK_TYPE_ZIGBEE_FFD 0x30 +#define INFO_STACK_TYPE_ZIGBEE_RFD 0x31 +#define INFO_STACK_TYPE_MAC 0x40 +#define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 +#define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 +#define INFO_STACK_TYPE_802154_LLD_TESTS 0x60 +#define INFO_STACK_TYPE_802154_PHY_VALID 0x61 +#define INFO_STACK_TYPE_BLE_PHY_VALID 0x62 +#define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 +#define INFO_STACK_TYPE_BLE_RLV 0x64 +#define INFO_STACK_TYPE_802154_RLV 0x65 +#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_STATIC 0x70 +#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_DYNAMIC 0x78 +#define INFO_STACK_TYPE_RLV 0x80 + +typedef struct { +/** + * Wireless Info + */ + uint8_t VersionMajor; + uint8_t VersionMinor; + uint8_t VersionSub; + uint8_t VersionBranch; + uint8_t VersionReleaseType; + uint8_t MemorySizeSram2B; /*< Multiple of 1K */ + uint8_t MemorySizeSram2A; /*< Multiple of 1K */ + uint8_t MemorySizeSram1; /*< Multiple of 1K */ + uint8_t MemorySizeFlash; /*< Multiple of 4K */ + uint8_t StackType; +/** + * Fus Info + */ + uint8_t FusVersionMajor; + uint8_t FusVersionMinor; + uint8_t FusVersionSub; + uint8_t FusMemorySizeSram2B; /*< Multiple of 1K */ + uint8_t FusMemorySizeSram2A; /*< Multiple of 1K */ + uint8_t FusMemorySizeFlash; /*< Multiple of 4K */ +}WirelessFwInfo_t; + + +/* Exported functions ------------------------------------------------------- */ + +/** + * For all SHCI_C2_FUS_xxx() command: + * When the wireless FW is running on the CPU2, the command returns SHCI_FUS_CMD_NOT_SUPPORTED + * When any FUS command is sent after the SHCI_FUS_CMD_NOT_SUPPORTED has been received, + * the CPU2 switches on the RSS ( This reboots automatically the device ) + */ + /** + * SHCI_C2_FUS_GetState + * @brief Read the FUS State + * If the user is not interested by the Error code response, a null value may + * be passed as parameter + * + * @param p_rsp : return the error code when the FUS State Value = 0xFF + * @retval FUS State Values + */ + uint8_t SHCI_C2_FUS_GetState( SHCI_FUS_GetState_ErrorCode_t *p_rsp ); + + /** + * SHCI_C2_FUS_FwUpgrade + * @brief Request the FUS to install the CPU2 firmware update + * + * @param fw_src_add: Address of the firmware image location + * @param fw_dest_add: Address of the firmware destination + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade( uint32_t fw_src_add, uint32_t fw_dest_add ); + + /** + * SHCI_C2_FUS_FwDelete + * @brief Delete the wireless stack on CPU2 + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete( void ); + + /** + * SHCI_C2_FUS_UpdateAuthKey + * @brief Request the FUS to update the authentication key + * + * @param pCmdPacket + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t *pParam ); + + /** + * SHCI_C2_FUS_LockAuthKey + * @brief Request the FUS to prevent any future update of the authentication key + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey( void ); + + /** + * SHCI_C2_FUS_StoreUsrKey + * @brief Request the FUS to store the user key + * + * @param pParam : command parameter + * @param p_key_index : Index allocated by the FUS to the stored key + * + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey( SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *pParam, uint8_t *p_key_index ); + + /** + * SHCI_C2_FUS_LoadUsrKey + * @brief Request the FUS to load the user key into the AES + * + * @param key_index : index of the user key to load in AES1 + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey( uint8_t key_index ); + + /** + * SHCI_C2_FUS_StartWs + * @brief Request the FUS to reboot on the wireless stack + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_StartWs( void ); + + /** + * SHCI_C2_FUS_LockUsrKey + * @brief Request the FUS to lock the user key so that it cannot be updated later on + * + * @param key_index : index of the user key to lock + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey( uint8_t key_index ); + + /** + * SHCI_C2_BLE_Init + * @brief Provides parameters and starts the BLE Stack + * + * @param pCmdPacket : Parameters to be provided to the BLE Stack + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket ); + + /** + * SHCI_C2_THREAD_Init + * @brief Starts the THREAD Stack + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_THREAD_Init( void ); + + /** + * SHCI_C2_LLDTESTS_Init + * @brief Starts the LLD tests CLI + * + * @param param_size : Nb of bytes + * @param p_param : pointeur with data to give from M4 to M0 + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ); + + /** + * SHCI_C2_LLD_BLE_Init + * @brief Starts the LLD tests CLI + * + * @param param_size : Nb of bytes + * @param p_param : pointeur with data to give from M4 to M0 + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init( uint8_t param_size, uint8_t * p_param ); + + /** + * SHCI_C2_ZIGBEE_Init + * @brief Starts the Zigbee Stack + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ); + + /** + * SHCI_C2_DEBUG_Init + * @brief Starts the Traces + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ); + + /** + * SHCI_C2_FLASH_EraseActivity + * @brief Provides the information of the start and the end of a flash erase window on the CPU1 + * + * @param erase_activity: Start/End of erase activity + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity( SHCI_EraseActivity_t erase_activity ); + + /** + * SHCI_C2_CONCURRENT_SetMode + * @brief Enable/Disable Thread on CPU2 (M0+) + * + * @param Mode: BLE or Thread enable flag + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mode ); + + /** + * SHCI_C2_FLASH_StoreData + * @brief Store Data in Flash + * + * @param Ip: BLE or THREAD + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip ); + + /** + * SHCI_C2_FLASH_EraseData + * @brief Erase Data in Flash + * + * @param Ip: BLE or THREAD + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData( SHCI_C2_FLASH_Ip_t Ip ); + + /** + * SHCI_C2_RADIO_AllowLowPower + * @brief Allow or forbid IP_radio (802_15_4 or BLE) to enter in low power mode. + * + * @param Ip: BLE or 802_15_5 + * @param FlagRadioLowPowerOn: True or false + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn); + + + /** + * SHCI_C2_MAC_802_15_4_Init + * @brief Starts the MAC 802.15.4 on M0 + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ); + + /** + * SHCI_GetWirelessFwInfo + * @brief This function read back the informations relative to the wireless binary loaded. + * Refer yourself to SHCI_WirelessFwInfoTable_t structure to get the significance + * of the different parameters returned. + * @param pWirelessInfo : Pointer to WirelessFwInfo_t. + * + * @retval SHCI_Success + */ + SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ); + + /** + * SHCI_C2_Reinit + * @brief This is required to allow the CPU1 to fake a set C2BOOT when it has already been set. + * In order to fake a C2BOOT, the CPU1 shall : + * - Send SHCI_C2_Reinit() + * - call SEV instruction + * WARNING: + * This function is intended to be used by the SBSFU + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_Reinit( void ); + + /** + * SHCI_C2_ExtpaConfig + * @brief Send the Ext PA configuration + * When the CPU2 receives the command, it controls the Ext PA as requested by the configuration + * This configures only which IO is used to enable/disable the ExtPA and the associated polarity + * This command has no effect on the other IO that is used to control the mode of the Ext PA (Rx/Tx) + * + * @param gpio_port: GPIOx where x can be (A..F) to select the GPIO peripheral for STM32WBxx family + * @param gpio_pin_number: This parameter can be one of GPIO_PIN_x (= LL_GPIO_PIN_x) where x can be (0..15). + * @param gpio_polarity: This parameter can be either + * - EXT_PA_ENABLED_LOW: ExtPA is enabled when GPIO is low + * - EXT_PA_ENABLED_HIGH: ExtPA is enabled when GPIO is high + * @param gpio_status: This parameter can be either + * - EXT_PA_DISABLED: Stop driving the ExtPA + * - EXT_PA_ENABLED: Drive the ExtPA according to radio activity + * (ON before the Event and OFF at the end of the event) + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_number, uint8_t gpio_polarity, uint8_t gpio_status); + + /** + * SHCI_C2_SetFlashActivityControl + * @brief Set the mechanism to be used on CPU2 to prevent the CPU1 to either write or erase in flash + * + * @param Source: It can be one of the following list + * - FLASH_ACTIVITY_CONTROL_PES : The CPU2 set the PES bit to prevent the CPU1 to either read or write in flash + * - FLASH_ACTIVITY_CONTROL_SEM7 : The CPU2 gets the semaphore 7 to prevent the CPU1 to either read or write in flash. + * This requires the CPU1 to first get semaphore 7 before erasing or writing the flash. + * + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t Source); + + /** + * SHCI_C2_Config + * @brief Send the system configuration to the CPU2 + * + * @param pCmdPacket: address of the buffer holding following parameters + * uint8_t PayloadCmdSize : Size of the payload - shall be SHCI_C2_CONFIG_PAYLOAD_CMD_SIZE + * uint8_t Config1 : + * - bit0 : 0 - BLE NVM Data data are flushed in internal secure flash + * 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 + * 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) + * ... + * bit31 : Asynchronous Event with Sub Evt Code 0x9220 + * uint8_t Spare1 : Unused, shall be set to 0 + * uint32_t BleNvmRamAddress : + * Only considered when Config1.bit0 = 1 + * When set to 0, data are kept in internal SRAM on CPU2 + * Otherwise, data are copied in the cache pointed by BleNvmRamAddress + * The size of the buffer shall be BLE_NVM_SRAM_SIZE (number of 32bits) + * The buffer shall be allocated in SRAM2 + * uint32_t ThreadNvmRamAddress : + * Only considered when Config1.bit1 = 1 + * When set to 0, data are kept in internal SRAM on CPU2 + * Otherwise, data are copied in the cache pointed by ThreadNvmRamAddress + * The size of the buffer shall be THREAD_NVM_SRAM_SIZE (number of 32bits) + * The buffer shall be allocated in SRAM2 + * + * Please check macro definition to be used for this function + * They are defined in this file next to the definition of SHCI_OPCODE_C2_CONFIG + * + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket); + + #ifdef __cplusplus +} +#endif + +#endif /*__SHCI_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c new file mode 100644 index 00000000..736f2793 --- /dev/null +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -0,0 +1,351 @@ +/** + ****************************************************************************** + * @file shci.c + * @author MCD Application Team + * @brief System HCI command implementation + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "stm32_wpan_common.h" + +#include "stm_list.h" +#include "shci_tl.h" + +/** + * These traces are not yet supported in an usual way in the delivery package + * They can enabled by adding the definition of TL_SHCI_CMD_DBG_EN and/or TL_SHCI_EVT_DBG_EN in the preprocessor option in the IDE + */ +#if ( (TL_SHCI_CMD_DBG_EN != 0) || (TL_SHCI_EVT_DBG_EN != 0) ) +#include "app_conf.h" +#include "dbg_trace.h" +#endif + +#if (TL_SHCI_CMD_DBG_EN != 0) +#define TL_SHCI_CMD_DBG_MSG PRINT_MESG_DBG +#define TL_SHCI_CMD_DBG_BUF PRINT_LOG_BUFF_DBG +#else +#define TL_SHCI_CMD_DBG_MSG(...) +#define TL_SHCI_CMD_DBG_BUF(...) +#endif + +#if (TL_SHCI_EVT_DBG_EN != 0) +#define TL_SHCI_EVT_DBG_MSG PRINT_MESG_DBG +#define TL_SHCI_EVT_DBG_BUF PRINT_LOG_BUFF_DBG +#else +#define TL_SHCI_EVT_DBG_MSG(...) +#define TL_SHCI_EVT_DBG_BUF(...) +#endif + +/* Private typedef -----------------------------------------------------------*/ +typedef enum +{ + SHCI_TL_CMD_RESP_RELEASE, + SHCI_TL_CMD_RESP_WAIT, +} SHCI_TL_CmdRespStatus_t; + +/* Private defines -----------------------------------------------------------*/ +/** + * The default System HCI layer timeout is set to 33s + */ +#define SHCI_TL_DEFAULT_TIMEOUT (33000) + +/* Private macros ------------------------------------------------------------*/ +/* Public variables ---------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/** + * START of Section SYSTEM_DRIVER_CONTEXT + */ +PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") static tListNode SHciAsynchEventQueue; +PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") static volatile SHCI_TL_CmdStatus_t SHCICmdStatus; +PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") static TL_CmdPacket_t *pCmdBuffer; +PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") SHCI_TL_UserEventFlowStatus_t SHCI_TL_UserEventFlow; +/** + * END of Section SYSTEM_DRIVER_CONTEXT + */ + +static tSHciContext shciContext; +static void (* StatusNotCallBackFunction) (SHCI_TL_CmdStatus_t status); + +static volatile SHCI_TL_CmdRespStatus_t CmdRspStatusFlag; + +/* Private function prototypes -----------------------------------------------*/ +static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus); +static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt); +static void TlUserEvtReceived(TL_EvtPacket_t *shcievt); +static void TlInit( TL_CmdPacket_t * p_cmdbuffer ); +static void OutputCmdTrace(TL_CmdPacket_t *pCmdBuffer); +static void OutputRspTrace(TL_EvtPacket_t *p_rsp); +static void OutputEvtTrace(TL_EvtPacket_t *phcievtbuffer); + +/* Interface ------- ---------------------------------------------------------*/ +void shci_init(void(* UserEvtRx)(void* pData), void* pConf) +{ + StatusNotCallBackFunction = ((SHCI_TL_HciInitConf_t *)pConf)->StatusNotCallBack; + shciContext.UserEvtRx = UserEvtRx; + + shci_register_io_bus (&shciContext.io); + + TlInit((TL_CmdPacket_t *)(((SHCI_TL_HciInitConf_t *)pConf)->p_cmdbuffer)); + + return; +} + +void shci_user_evt_proc(void) +{ + TL_EvtPacket_t *phcievtbuffer; + tSHCI_UserEvtRxParam UserEvtRxParam; + + /** + * Up to release version v1.2.0, a while loop was implemented to read out events from the queue as long as + * it is not empty. However, in a bare metal implementation, this leads to calling in a "blocking" mode + * shci_user_evt_proc() as long as events are received without giving the opportunity to run other tasks + * in the background. + * From now, the events are reported one by one. When it is checked there is still an event pending in the queue, + * a request to the user is made to call again shci_user_evt_proc(). + * This gives the opportunity to the application to run other background tasks between each event. + */ + + /** + * It is more secure to use LST_remove_head()/LST_insert_head() compare to LST_get_next_node()/LST_remove_node() + * in case the user overwrite the header where the next/prev pointers are located + */ + if((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable)) + { + LST_remove_head ( &SHciAsynchEventQueue, (tListNode **)&phcievtbuffer ); + + OutputEvtTrace(phcievtbuffer); + + if (shciContext.UserEvtRx != NULL) + { + UserEvtRxParam.pckt = phcievtbuffer; + UserEvtRxParam.status = SHCI_TL_UserEventFlow_Enable; + shciContext.UserEvtRx((void *)&UserEvtRxParam); + SHCI_TL_UserEventFlow = UserEvtRxParam.status; + } + else + { + SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable; + } + + if(SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable) + { + TL_MM_EvtDone( phcievtbuffer ); + } + else + { + /** + * put back the event in the queue + */ + LST_insert_head ( &SHciAsynchEventQueue, (tListNode *)phcievtbuffer ); + } + } + + if((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable)) + { + shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); + } + + + return; +} + +void shci_resume_flow( void ) +{ + SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable; + + /** + * It is better to go through the background process as it is not sure from which context this API may + * be called + */ + shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); + + return; +} + +void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payload, TL_EvtPacket_t * p_rsp ) +{ + Cmd_SetStatus(SHCI_TL_CmdBusy); + + pCmdBuffer->cmdserial.cmd.cmdcode = cmd_code; + pCmdBuffer->cmdserial.cmd.plen = len_cmd_payload; + + memcpy(pCmdBuffer->cmdserial.cmd.payload, p_cmd_payload, len_cmd_payload ); + + OutputCmdTrace(pCmdBuffer); + + shciContext.io.Send(0,0); + + shci_cmd_resp_wait(SHCI_TL_DEFAULT_TIMEOUT); + + /** + * The command complete of a system command does not have the header + * It starts immediately with the evtserial field + */ + memcpy( &(p_rsp->evtserial), pCmdBuffer, ((TL_EvtSerial_t*)pCmdBuffer)->evt.plen + TL_EVT_HDR_SIZE ); + + OutputRspTrace(p_rsp); + + Cmd_SetStatus(SHCI_TL_CmdAvailable); + + return; +} + +/* Private functions ---------------------------------------------------------*/ +static void TlInit( TL_CmdPacket_t * p_cmdbuffer ) +{ + TL_SYS_InitConf_t Conf; + + pCmdBuffer = p_cmdbuffer; + + LST_init_head (&SHciAsynchEventQueue); + + Cmd_SetStatus(SHCI_TL_CmdAvailable); + + SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable; + + /* Initialize low level driver */ + if (shciContext.io.Init) + { + + Conf.p_cmdbuffer = (uint8_t *)p_cmdbuffer; + Conf.IoBusCallBackCmdEvt = TlCmdEvtReceived; + Conf.IoBusCallBackUserEvt = TlUserEvtReceived; + shciContext.io.Init(&Conf); + } + + return; +} + +static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus) +{ + if(shcicmdstatus == SHCI_TL_CmdBusy) + { + if(StatusNotCallBackFunction != 0) + { + StatusNotCallBackFunction( SHCI_TL_CmdBusy ); + } + SHCICmdStatus = SHCI_TL_CmdBusy; + } + else + { + SHCICmdStatus = SHCI_TL_CmdAvailable; + if(StatusNotCallBackFunction != 0) + { + StatusNotCallBackFunction( SHCI_TL_CmdAvailable ); + } + } + + return; +} + +static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt) +{ + (void)(shcievt); + shci_cmd_resp_release(0); /**< Notify the application the Cmd response has been received */ + + return; +} + +static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) +{ + LST_insert_tail(&SHciAsynchEventQueue, (tListNode *)shcievt); + shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); /**< Notify the application a full HCI event has been received */ + + return; +} + +static void OutputCmdTrace(TL_CmdPacket_t *pCmdBuffer) +{ + TL_SHCI_CMD_DBG_MSG("sys cmd: 0x%04X", pCmdBuffer->cmdserial.cmd.cmdcode); + + if(pCmdBuffer->cmdserial.cmd.plen != 0) + { + TL_SHCI_CMD_DBG_MSG(" payload:"); + TL_SHCI_CMD_DBG_BUF(pCmdBuffer->cmdserial.cmd.payload, pCmdBuffer->cmdserial.cmd.plen, ""); + } + TL_SHCI_CMD_DBG_MSG("\r\n"); + + return; +} + +static void OutputRspTrace(TL_EvtPacket_t *p_rsp) +{ + switch(p_rsp->evtserial.evt.evtcode) + { + case TL_BLEEVT_CC_OPCODE: + TL_SHCI_CMD_DBG_MSG("sys rsp: 0x%02X", p_rsp->evtserial.evt.evtcode); + TL_SHCI_CMD_DBG_MSG(" cmd opcode: 0x%02X", ((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->cmdcode); + TL_SHCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); + if((p_rsp->evtserial.evt.plen-4) != 0) + { + TL_SHCI_CMD_DBG_MSG(" payload:"); + TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1], p_rsp->evtserial.evt.plen-4, ""); + } + break; + + default: + TL_SHCI_CMD_DBG_MSG("unknown sys rsp received: %02X", p_rsp->evtserial.evt.evtcode); + break; + } + + TL_SHCI_CMD_DBG_MSG("\r\n"); + + return; +} + +static void OutputEvtTrace(TL_EvtPacket_t *phcievtbuffer) +{ + if(phcievtbuffer->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) + { + TL_SHCI_EVT_DBG_MSG("unknown sys evt received: %02X", phcievtbuffer->evtserial.evt.evtcode); + } + else + { + TL_SHCI_EVT_DBG_MSG("sys evt: 0x%02X", phcievtbuffer->evtserial.evt.evtcode); + TL_SHCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(phcievtbuffer->evtserial.evt.payload))->subevtcode); + if((phcievtbuffer->evtserial.evt.plen-2) != 0) + { + TL_SHCI_EVT_DBG_MSG(" payload:"); + TL_SHCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(phcievtbuffer->evtserial.evt.payload))->payload, phcievtbuffer->evtserial.evt.plen-2, ""); + } + } + + TL_SHCI_EVT_DBG_MSG("\r\n"); + + return; +} + +/* Weak implementation ----------------------------------------------------------------*/ +__WEAK void shci_cmd_resp_wait(uint32_t timeout) +{ + (void)timeout; + + CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; + while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); + + return; +} + +__WEAK void shci_cmd_resp_release(uint32_t flag) +{ + (void)flag; + + CmdRspStatusFlag = SHCI_TL_CMD_RESP_RELEASE; + + return; +} + + diff --git a/src/utility/STM32Cube_FW/shci_tl.h b/src/utility/STM32Cube_FW/shci_tl.h new file mode 100644 index 00000000..3fbc492f --- /dev/null +++ b/src/utility/STM32Cube_FW/shci_tl.h @@ -0,0 +1,175 @@ +/** + ****************************************************************************** + * @file shci_tl.h + * @author MCD Application Team + * @brief System HCI command header for the system channel + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +#ifndef __SHCI_TL_H_ +#define __SHCI_TL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "tl.h" + +/* Exported defines -----------------------------------------------------------*/ +typedef enum +{ + SHCI_TL_UserEventFlow_Disable, + SHCI_TL_UserEventFlow_Enable, +} SHCI_TL_UserEventFlowStatus_t; + +typedef enum +{ + SHCI_TL_CmdBusy, + SHCI_TL_CmdAvailable +} SHCI_TL_CmdStatus_t; + +/** + * @brief Structure used to manage the BUS IO operations. + * All the structure fields will point to functions defined at user level. + * @{ + */ +typedef struct +{ + int32_t (* Init) (void* pConf); /**< Pointer to SHCI TL function for the IO Bus initialization */ + int32_t (* DeInit) (void); /**< Pointer to SHCI TL function for the IO Bus de-initialization */ + int32_t (* Reset) (void); /**< Pointer to SHCI TL function for the IO Bus reset */ + int32_t (* Receive) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data reception */ + int32_t (* Send) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data transmission */ + int32_t (* DataAck) (uint8_t*, uint16_t* len); /**< Pointer to SHCI TL function for the IO Bus data ack reception */ + int32_t (* GetTick) (void); /**< Pointer to BSP function for getting the HAL time base timestamp */ +} tSHciIO; +/** + * @} + */ + +/** + * @brief Contain the SHCI context + * @{ + */ +typedef struct +{ + tSHciIO io; /**< Manage the BUS IO operations */ + void (* UserEvtRx) (void * pData); /**< User System events callback function pointer */ +} tSHciContext; + +typedef struct +{ + SHCI_TL_UserEventFlowStatus_t status; + TL_EvtPacket_t *pckt; +} tSHCI_UserEvtRxParam; + +typedef struct +{ + uint8_t *p_cmdbuffer; + void (* StatusNotCallBack) (SHCI_TL_CmdStatus_t status); +} SHCI_TL_HciInitConf_t; + +/** + * shci_send + * @brief Send an System HCI Command + * + * @param : cmd_code = Opcode of the command + * @param : len_cmd_payload = Length of the command payload + * @param : p_cmd_payload = Address of the command payload + * @param : p_rsp_status = Address of the full buffer holding the command complete event + * @retval : None + */ +void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payload, TL_EvtPacket_t * p_rsp_status ); + +/** + * @brief Register IO bus services. + * @param fops The SHCI IO structure managing the IO BUS + * @retval None + */ +void shci_register_io_bus(tSHciIO* fops); + +/** + * @brief Interrupt service routine that must be called when the system channel + * reports a packet has been received + * + * @param pdata Packet or event pointer + * @retval None + */ +void shci_notify_asynch_evt(void* pdata); + +/** + * @brief This function resume the User Event Flow which has been stopped on return + * from UserEvtRx() when the User Event has not been processed. + * + * @param None + * @retval None + */ +void shci_resume_flow(void); + + +/** + * @brief This function is called when an System HCI Command is sent to the CPU2 and the response is waited. + * It is called from the same context the System HCI command has been sent. + * It shall not return until the command response notified by shci_cmd_resp_release() is received. + * A weak implementation is available in shci_tl.c based on polling mechanism + * The user may re-implement this function in the application to improve performance : + * - It may use UTIL_SEQ_WaitEvt() API when using the Sequencer + * - It may use a semaphore when using cmsis_os interface + * + * @param timeout: Waiting timeout + * @retval None + */ +void shci_cmd_resp_wait(uint32_t timeout); + +/** + * @brief This function is called when an System HCI command is received from the CPU2. + * A weak implementation is available in shci_tl.c based on polling mechanism + * The user may re-implement this function in the application to improve performance : + * - It may use UTIL_SEQ_SetEvt() API when using the Sequencer + * - It may use a semaphore when using cmsis_os interface + * + * + * @param flag: Release flag + * @retval None + */ +void shci_cmd_resp_release(uint32_t flag); + + +/** + * @brief This process shall be called each time the shci_notify_asynch_evt notification is received + * + * @param None + * @retval None + */ + +void shci_user_evt_proc(void); + +/** + * @brief Initialize the System Host Controller Interface. + * This function must be called before any communication on the System Channel + * + * @param pData: System events callback function pointer + * This callback is triggered when an user event is received on + * the System Channel from CPU2. + * @param pConf: Configuration structure pointer + * @retval None + */ +void shci_init(void(* UserEvtRx)(void* pData), void* pConf); + +#ifdef __cplusplus +} +#endif + +#endif /* __SHCI_TL_H_ */ diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h new file mode 100644 index 00000000..cad9026d --- /dev/null +++ b/src/utility/STM32Cube_FW/stm32_wpan_common.h @@ -0,0 +1,170 @@ +/** + ****************************************************************************** + * @file stm32_wpan_common.h + * @author MCD Application Team + * @brief Common file to utilities + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2018 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32_WPAN_COMMON_H +#define __STM32_WPAN_COMMON_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline +#endif + +#include +#include +#include +#include +#include +#include "cmsis_compiler.h" + + /* -------------------------------- * + * Basic definitions * + * -------------------------------- */ + +#undef NULL +#define NULL 0U + +#undef FALSE +#define FALSE 0U + +#undef TRUE +#define TRUE (!0U) + + /* -------------------------------- * + * Critical Section definition * + * -------------------------------- */ +#undef BACKUP_PRIMASK +#define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK() + +#undef DISABLE_IRQ +#define DISABLE_IRQ() __disable_irq() + +#undef RESTORE_PRIMASK +#define RESTORE_PRIMASK() __set_PRIMASK(primask_bit) + + /* -------------------------------- * + * Macro delimiters * + * -------------------------------- */ +#undef M_BEGIN +#define M_BEGIN do { + +#undef M_END +#define M_END } while(0) + + /* -------------------------------- * + * Some useful macro definitions * + * -------------------------------- */ +#undef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) + +#undef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) + +#undef MODINC +#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END + +#undef MODDEC +#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END + +#undef MODADD +#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END + +#undef MODSUB +#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m ) + +#undef ALIGN +#ifdef WIN32 +#define ALIGN(n) +#else +#define ALIGN(n) __attribute__((aligned(n))) +#endif + +#undef PAUSE +#define PAUSE( t ) M_BEGIN \ + volatile int _i; \ + for ( _i = t; _i > 0; _i -- ); \ + M_END +#undef DIVF +#define DIVF( x, y ) ((x)/(y)) + +#undef DIVC +#define DIVC( x, y ) (((x)+(y)-1)/(y)) + +#undef DIVR +#define DIVR( x, y ) (((x)+((y)/2))/(y)) + +#undef SHRR +#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1) + +#undef BITN +#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1) + +#undef BITNSET +#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END + +/* -------------------------------- * + * Section attribute * + * -------------------------------- */ +#undef PLACE_IN_SECTION +#define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__))) + +/* ----------------------------------- * + * Packed usage (compiler dependent) * + * ----------------------------------- */ +#undef PACKED__ +#undef PACKED_STRUCT + +#if defined ( __CC_ARM ) + #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050U) + #define PACKED__ __attribute__((packed)) + #define PACKED_STRUCT struct PACKED__ + #else + #define PACKED__(TYPE) __packed TYPE + #define PACKED_STRUCT PACKED__(struct) + #endif +#elif defined ( __GNUC__ ) + #define PACKED__ __attribute__((packed)) + #define PACKED_STRUCT struct PACKED__ +#elif defined (__ICCARM__) + #define PACKED_STRUCT __packed struct +#elif + #define PACKED_STRUCT __packed struct +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*__STM32_WPAN_COMMON_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c new file mode 100644 index 00000000..42e2d500 --- /dev/null +++ b/src/utility/STM32Cube_FW/stm_list.c @@ -0,0 +1,208 @@ +/** + ****************************************************************************** + * @file stm_list.c + * @author MCD Application Team + * @brief TCircular Linked List Implementation. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +/****************************************************************************** + * Include Files + ******************************************************************************/ +#include "utilities_common.h" + +#include "stm_list.h" + +/****************************************************************************** + * Function Definitions + ******************************************************************************/ +void LST_init_head (tListNode * listHead) +{ + listHead->next = listHead; + listHead->prev = listHead; +} + +uint8_t LST_is_empty (tListNode * listHead) +{ + uint32_t primask_bit; + uint8_t return_value; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + if(listHead->next == listHead) + { + return_value = TRUE; + } + else + { + return_value = FALSE; + } + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ + + return return_value; +} + +void LST_insert_head (tListNode * listHead, tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = listHead->next; + node->prev = listHead; + listHead->next = node; + (node->next)->prev = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_insert_tail (tListNode * listHead, tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = listHead; + node->prev = listHead->prev; + listHead->prev = node; + (node->prev)->next = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_remove_node (tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + (node->prev)->next = node->next; + (node->next)->prev = node->prev; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_remove_head (tListNode * listHead, tListNode ** node ) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = listHead->next; + LST_remove_node (listHead->next); + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_remove_tail (tListNode * listHead, tListNode ** node ) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = listHead->prev; + LST_remove_node (listHead->prev); + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_insert_node_after (tListNode * node, tListNode * ref_node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = ref_node->next; + node->prev = ref_node; + ref_node->next = node; + (node->next)->prev = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_insert_node_before (tListNode * node, tListNode * ref_node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = ref_node; + node->prev = ref_node->prev; + ref_node->prev = node; + (node->prev)->next = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +int LST_get_size (tListNode * listHead) +{ + int size = 0; + tListNode * temp; + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + temp = listHead->next; + while (temp != listHead) + { + size++; + temp = temp->next; + } + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ + + return (size); +} + +void LST_get_next_node (tListNode * ref_node, tListNode ** node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = ref_node->next; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_get_prev_node (tListNode * ref_node, tListNode ** node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = ref_node->prev; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + diff --git a/src/utility/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h new file mode 100644 index 00000000..78e74463 --- /dev/null +++ b/src/utility/STM32Cube_FW/stm_list.h @@ -0,0 +1,55 @@ +/** + ****************************************************************************** + * @file stm_list.h + * @author MCD Application Team + * @brief Header file for linked list library. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +#ifndef _STM_LIST_H_ +#define _STM_LIST_H_ + +/* Includes ------------------------------------------------------------------*/ + +typedef struct _tListNode { + struct _tListNode * next; + struct _tListNode * prev; +} tListNode; + +void LST_init_head (tListNode * listHead); + +uint8_t LST_is_empty (tListNode * listHead); + +void LST_insert_head (tListNode * listHead, tListNode * node); + +void LST_insert_tail (tListNode * listHead, tListNode * node); + +void LST_remove_node (tListNode * node); + +void LST_remove_head (tListNode * listHead, tListNode ** node ); + +void LST_remove_tail (tListNode * listHead, tListNode ** node ); + +void LST_insert_node_after (tListNode * node, tListNode * ref_node); + +void LST_insert_node_before (tListNode * node, tListNode * ref_node); + +int LST_get_size (tListNode * listHead); + +void LST_get_next_node (tListNode * ref_node, tListNode ** node); + +void LST_get_prev_node (tListNode * ref_node, tListNode ** node); + +#endif /* _STM_LIST_H_ */ diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h new file mode 100644 index 00000000..e5fac413 --- /dev/null +++ b/src/utility/STM32Cube_FW/tl.h @@ -0,0 +1,334 @@ +/** + ****************************************************************************** + * @file tl.h + * @author MCD Application Team + * @brief Header for tl module + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __TL_H +#define __TL_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Includes ------------------------------------------------------------------*/ +#include "stm32_wpan_common.h" + +/* Exported defines -----------------------------------------------------------*/ +#define TL_BLECMD_PKT_TYPE ( 0x01 ) +#define TL_ACL_DATA_PKT_TYPE ( 0x02 ) +#define TL_BLEEVT_PKT_TYPE ( 0x04 ) +#define TL_OTCMD_PKT_TYPE ( 0x08 ) +#define TL_OTRSP_PKT_TYPE ( 0x09 ) +#define TL_CLICMD_PKT_TYPE ( 0x0A ) +#define TL_OTNOT_PKT_TYPE ( 0x0C ) +#define TL_OTACK_PKT_TYPE ( 0x0D ) +#define TL_CLINOT_PKT_TYPE ( 0x0E ) +#define TL_CLIACK_PKT_TYPE ( 0x0F ) +#define TL_SYSCMD_PKT_TYPE ( 0x10 ) +#define TL_SYSRSP_PKT_TYPE ( 0x11 ) +#define TL_SYSEVT_PKT_TYPE ( 0x12 ) +#define TL_CLIRESP_PKT_TYPE ( 0x15 ) +#define TL_M0CMD_PKT_TYPE ( 0x16 ) +#define TL_LOCCMD_PKT_TYPE ( 0x20 ) +#define TL_LOCRSP_PKT_TYPE ( 0x21 ) +#define TL_TRACES_APP_PKT_TYPE ( 0x40 ) +#define TL_TRACES_WL_PKT_TYPE ( 0x41 ) + +#define TL_CMD_HDR_SIZE (4) +#define TL_EVT_HDR_SIZE (3) +#define TL_EVT_CS_PAYLOAD_SIZE (4) + +#define TL_BLEEVT_CC_OPCODE (0x0E) +#define TL_BLEEVT_CS_OPCODE (0x0F) +#define TL_BLEEVT_VS_OPCODE (0xFF) + +#define TL_BLEEVT_CS_PACKET_SIZE (TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)) +#define TL_BLEEVT_CS_BUFFER_SIZE (sizeof(TL_PacketHeader_t) + TL_BLEEVT_CS_PACKET_SIZE) + +/* Exported types ------------------------------------------------------------*/ +/**< Packet header */ +typedef PACKED_STRUCT +{ + uint32_t *next; + uint32_t *prev; +} TL_PacketHeader_t; + +/******************************************************************************* + * Event type + */ + +/** + * This the payload of TL_Evt_t for a command status event + */ +typedef PACKED_STRUCT +{ + uint8_t status; + uint8_t numcmd; + uint16_t cmdcode; +} TL_CsEvt_t; + +/** + * This the payload of TL_Evt_t for a command complete event + */ +typedef PACKED_STRUCT +{ + uint8_t numcmd; + uint16_t cmdcode; + uint8_t payload[1]; +} TL_CcEvt_t; + +/** + * This the payload of TL_Evt_t for an asynchronous event + */ +typedef PACKED_STRUCT +{ + uint16_t subevtcode; + uint8_t payload[1]; +} TL_AsynchEvt_t; + +typedef PACKED_STRUCT +{ + uint8_t evtcode; + uint8_t plen; + uint8_t payload[1]; +} TL_Evt_t; + +typedef PACKED_STRUCT +{ + uint8_t type; + TL_Evt_t evt; +} TL_EvtSerial_t; + +/** + * This format shall be used for all events (asynchronous and command response) reported + * by the CPU2 except for the command response of a system command where the header is not there + * and the format to be used shall be TL_EvtSerial_t. + * Note: Be careful that the asynchronous events reported by the CPU2 on the system channel do + * include the header and shall use TL_EvtPacket_t format. Only the command response format on the + * system channel is different. + */ +typedef PACKED_STRUCT +{ + TL_PacketHeader_t header; + TL_EvtSerial_t evtserial; +} TL_EvtPacket_t; + +/***************************************************************************************** + * Command type + */ + +typedef PACKED_STRUCT +{ + uint16_t cmdcode; + uint8_t plen; + uint8_t payload[255]; +} TL_Cmd_t; + +typedef PACKED_STRUCT +{ + uint8_t type; + TL_Cmd_t cmd; +} TL_CmdSerial_t; + +typedef PACKED_STRUCT +{ + TL_PacketHeader_t header; + TL_CmdSerial_t cmdserial; +} TL_CmdPacket_t; + +/***************************************************************************************** + * HCI ACL DATA type + */ +typedef PACKED_STRUCT +{ + uint8_t type; + uint16_t handle; + uint16_t length; + uint8_t acl_data[1]; +} TL_AclDataSerial_t; + +typedef PACKED_STRUCT +{ + TL_PacketHeader_t header; + TL_AclDataSerial_t AclDataSerial; +} TL_AclDataPacket_t; + +typedef struct +{ + uint8_t *p_BleSpareEvtBuffer; + uint8_t *p_SystemSpareEvtBuffer; + uint8_t *p_AsynchEvtPool; + uint32_t AsynchEvtPoolSize; + uint8_t *p_TracesEvtPool; + uint32_t TracesEvtPoolSize; +} TL_MM_Config_t; + +typedef struct +{ + uint8_t *p_ThreadOtCmdRspBuffer; + uint8_t *p_ThreadCliRspBuffer; + uint8_t *p_ThreadNotAckBuffer; +} TL_TH_Config_t; + +typedef struct +{ + uint8_t *p_LldTestsCliCmdRspBuffer; + uint8_t *p_LldTestsM0CmdBuffer; +} TL_LLD_tests_Config_t; + +typedef struct +{ + uint8_t *p_LldBleCmdRspBuffer; + uint8_t *p_LldBleM0CmdBuffer; +} TL_LLD_BLE_Config_t; + +typedef struct +{ + uint8_t *p_Mac_802_15_4_CmdRspBuffer; + uint8_t *p_Mac_802_15_4_NotAckBuffer; +} TL_MAC_802_15_4_Config_t; + +typedef struct +{ + uint8_t *p_ZigbeeOtCmdRspBuffer; + uint8_t *p_ZigbeeNotAckBuffer; + uint8_t *p_ZigbeeNotifRequestBuffer; +} TL_ZIGBEE_Config_t; + +/** + * @brief Contain the BLE HCI Init Configuration + * @{ + */ +typedef struct +{ + void (* IoBusEvtCallBack) ( TL_EvtPacket_t *phcievt ); + void (* IoBusAclDataTxAck) ( void ); + uint8_t *p_cmdbuffer; + uint8_t *p_AclDataBuffer; +} TL_BLE_InitConf_t; + +/** + * @brief Contain the SYSTEM HCI Init Configuration + * @{ + */ +typedef struct +{ + void (* IoBusCallBackCmdEvt) (TL_EvtPacket_t *phcievt); + void (* IoBusCallBackUserEvt) (TL_EvtPacket_t *phcievt); + uint8_t *p_cmdbuffer; +} TL_SYS_InitConf_t; + +/* Exported constants --------------------------------------------------------*/ +/* External variables --------------------------------------------------------*/ +/* Exported macros -----------------------------------------------------------*/ +/* Exported functions ------------------------------------------------------- */ + +/****************************************************************************** + * GENERAL + ******************************************************************************/ +void TL_Enable( void ); +void TL_Init( void ); + +/****************************************************************************** + * BLE + ******************************************************************************/ +int32_t TL_BLE_Init( void* pConf ); +int32_t TL_BLE_SendCmd( uint8_t* buffer, uint16_t size ); +int32_t TL_BLE_SendAclData( uint8_t* buffer, uint16_t size ); + +/****************************************************************************** + * SYSTEM + ******************************************************************************/ +int32_t TL_SYS_Init( void* pConf ); +int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size ); + +/****************************************************************************** + * THREAD + ******************************************************************************/ +void TL_THREAD_Init( TL_TH_Config_t *p_Config ); +void TL_OT_SendCmd( void ); +void TL_CLI_SendCmd( void ); +void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); +void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer ); +void TL_THREAD_SendAck ( void ); +void TL_THREAD_CliSendAck ( void ); +void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer ); + +/****************************************************************************** + * LLD TESTS + ******************************************************************************/ +void TL_LLDTESTS_Init( TL_LLD_tests_Config_t *p_Config ); +void TL_LLDTESTS_SendCliCmd( void ); +void TL_LLDTESTS_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ); +void TL_LLDTESTS_SendCliRspAck( void ); +void TL_LLDTESTS_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ); +void TL_LLDTESTS_SendM0CmdAck( void ); + +/****************************************************************************** + * LLD BLE + ******************************************************************************/ +void TL_LLD_BLE_Init( TL_LLD_BLE_Config_t *p_Config ); +void TL_LLD_BLE_SendCliCmd( void ); +void TL_LLD_BLE_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ); +void TL_LLD_BLE_SendCliRspAck( void ); +void TL_LLD_BLE_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ); +void TL_LLD_BLE_SendM0CmdAck( void ); +void TL_LLD_BLE_SendCmd( void ); +void TL_LLD_BLE_ReceiveRsp( TL_CmdPacket_t * Notbuffer ); +void TL_LLD_BLE_SendRspAck( void ); +/****************************************************************************** + * MEMORY MANAGER + ******************************************************************************/ +void TL_MM_Init( TL_MM_Config_t *p_Config ); +void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); + +/****************************************************************************** + * TRACES + ******************************************************************************/ +void TL_TRACES_Init( void ); +void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ); + +/****************************************************************************** + * MAC 802.15.4 + ******************************************************************************/ +void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ); +void TL_MAC_802_15_4_SendCmd( void ); +void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); +void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ); +void TL_MAC_802_15_4_SendAck ( void ); + +/****************************************************************************** + * ZIGBEE + ******************************************************************************/ +void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ); +void TL_ZIGBEE_SendM4RequestToM0( void ); +void TL_ZIGBEE_SendM4AckToM0Notify ( void ); +void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ); +void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); +void TL_ZIGBEE_M0RequestReceived(TL_EvtPacket_t * Otbuffer ); +void TL_ZIGBEE_SendM4AckToM0Request(void); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__TL_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c new file mode 100644 index 00000000..507edba2 --- /dev/null +++ b/src/utility/STM32Cube_FW/tl_mbox.c @@ -0,0 +1,686 @@ +/** + ****************************************************************************** + * @file tl_mbox.c + * @author MCD Application Team + * @brief Transport layer for the mailbox interface + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2019 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "stm32_wpan_common.h" +#include "hw.h" + +#include "stm_list.h" +#include "tl.h" +#include "mbox_def.h" + +/** + * These traces are not yet supported in an usual way in the delivery package + * They can enabled by adding the definition of TL_MM_DBG_EN in the preprocessor option in the IDE + */ +#if(TL_MM_DBG_EN != 0) +#include "app_conf.h" +#include "dbg_trace.h" +#endif + +#if (TL_MM_DBG_EN != 0) +#define TL_MM_DBG__MSG PRINT_MESG_DBG +#else +#define TL_MM_DBG__MSG(...) +#endif + +/* Private typedef -----------------------------------------------------------*/ +/* Private defines -----------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ + +/**< reference table */ +PLACE_IN_SECTION("MAPPING_TABLE") static volatile MB_RefTable_t TL_RefTable; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_DeviceInfoTable_t TL_DeviceInfoTable; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleTable_t TL_BleTable; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ThreadTable_t TL_ThreadTable; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_LldTestsTable_t TL_LldTestsTable; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_LldBleTable_t TL_LldBleTable; +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; +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; + +/**< tables */ +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue; +PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)]; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode EvtQueue; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode SystemEvtQueue; + + +static tListNode LocalFreeBufQueue; +static void (* BLE_IoBusEvtCallBackFunction) (TL_EvtPacket_t *phcievt); +static void (* BLE_IoBusAclDataTxAck) ( void ); +static void (* SYS_CMD_IoBusCallBackFunction) (TL_EvtPacket_t *phcievt); +static void (* SYS_EVT_IoBusCallBackFunction) (TL_EvtPacket_t *phcievt); + + +/* Global variables ----------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +static void SendFreeBuf( void ); +static void OutputMemReleaseTrace(TL_EvtPacket_t * phcievt); + +/* Public Functions Definition ------------------------------------------------------*/ + +/****************************************************************************** + * GENERAL + ******************************************************************************/ +void TL_Enable( void ) +{ + HW_IPCC_Enable(); + + return; +} + + +void TL_Init( void ) +{ + TL_RefTable.p_device_info_table = &TL_DeviceInfoTable; + TL_RefTable.p_ble_table = &TL_BleTable; + TL_RefTable.p_thread_table = &TL_ThreadTable; + TL_RefTable.p_lld_tests_table = &TL_LldTestsTable; + TL_RefTable.p_lld_ble_table = &TL_LldBleTable; + TL_RefTable.p_sys_table = &TL_SysTable; + TL_RefTable.p_mem_manager_table = &TL_MemManagerTable; + TL_RefTable.p_traces_table = &TL_TracesTable; + TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; + TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; + HW_IPCC_Init(); + + return; +} + +/****************************************************************************** + * BLE + ******************************************************************************/ +int32_t TL_BLE_Init( void* pConf ) +{ + MB_BleTable_t * p_bletable; + + TL_BLE_InitConf_t *pInitHciConf = (TL_BLE_InitConf_t *) pConf; + + LST_init_head (&EvtQueue); + + p_bletable = TL_RefTable.p_ble_table; + + p_bletable->pcmd_buffer = pInitHciConf->p_cmdbuffer; + p_bletable->phci_acl_data_buffer = pInitHciConf->p_AclDataBuffer; + p_bletable->pcs_buffer = (uint8_t*)CsBuffer; + p_bletable->pevt_queue = (uint8_t*)&EvtQueue; + + HW_IPCC_BLE_Init(); + + BLE_IoBusEvtCallBackFunction = pInitHciConf->IoBusEvtCallBack; + BLE_IoBusAclDataTxAck = pInitHciConf->IoBusAclDataTxAck; + + return 0; +} + +int32_t TL_BLE_SendCmd( uint8_t* buffer, uint16_t size ) +{ + (void)(buffer); + (void)(size); + + ((TL_CmdPacket_t*)(TL_RefTable.p_ble_table->pcmd_buffer))->cmdserial.type = TL_BLECMD_PKT_TYPE; + + HW_IPCC_BLE_SendCmd(); + + return 0; +} + +void HW_IPCC_BLE_RxEvtNot(void) +{ + TL_EvtPacket_t *phcievt; + + while(LST_is_empty(&EvtQueue) == FALSE) + { + LST_remove_head (&EvtQueue, (tListNode **)&phcievt); + + BLE_IoBusEvtCallBackFunction(phcievt); + } + + return; +} + +int32_t TL_BLE_SendAclData( uint8_t* buffer, uint16_t size ) +{ + (void)(buffer); + (void)(size); + + ((TL_AclDataPacket_t *)(TL_RefTable.p_ble_table->phci_acl_data_buffer))->AclDataSerial.type = TL_ACL_DATA_PKT_TYPE; + + HW_IPCC_BLE_SendAclData(); + + return 0; +} + +void HW_IPCC_BLE_AclDataAckNot(void) +{ + BLE_IoBusAclDataTxAck( ); + + return; +} + +/****************************************************************************** + * SYSTEM + ******************************************************************************/ +int32_t TL_SYS_Init( void* pConf ) +{ + MB_SysTable_t * p_systable; + + TL_SYS_InitConf_t *pInitHciConf = (TL_SYS_InitConf_t *) pConf; + + LST_init_head (&SystemEvtQueue); + p_systable = TL_RefTable.p_sys_table; + p_systable->pcmd_buffer = pInitHciConf->p_cmdbuffer; + p_systable->sys_queue = (uint8_t*)&SystemEvtQueue; + + HW_IPCC_SYS_Init(); + + SYS_CMD_IoBusCallBackFunction = pInitHciConf->IoBusCallBackCmdEvt; + SYS_EVT_IoBusCallBackFunction = pInitHciConf->IoBusCallBackUserEvt; + + return 0; +} + +int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size ) +{ + (void)(buffer); + (void)(size); + + ((TL_CmdPacket_t *)(TL_RefTable.p_sys_table->pcmd_buffer))->cmdserial.type = TL_SYSCMD_PKT_TYPE; + + HW_IPCC_SYS_SendCmd(); + + return 0; +} + +void HW_IPCC_SYS_CmdEvtNot(void) +{ + SYS_CMD_IoBusCallBackFunction( (TL_EvtPacket_t*)(TL_RefTable.p_sys_table->pcmd_buffer) ); + + return; +} + +void HW_IPCC_SYS_EvtNot( void ) +{ + TL_EvtPacket_t *p_evt; + + while(LST_is_empty(&SystemEvtQueue) == FALSE) + { + LST_remove_head (&SystemEvtQueue, (tListNode **)&p_evt); + SYS_EVT_IoBusCallBackFunction( p_evt ); + } + + return; +} + +/****************************************************************************** + * THREAD + ******************************************************************************/ +#ifdef THREAD_WB +void TL_THREAD_Init( TL_TH_Config_t *p_Config ) +{ + MB_ThreadTable_t * p_thread_table; + + p_thread_table = TL_RefTable.p_thread_table; + + p_thread_table->clicmdrsp_buffer = p_Config->p_ThreadCliRspBuffer; + p_thread_table->otcmdrsp_buffer = p_Config->p_ThreadOtCmdRspBuffer; + p_thread_table->notack_buffer = p_Config->p_ThreadNotAckBuffer; + + HW_IPCC_THREAD_Init(); + + return; +} + +void TL_OT_SendCmd( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->otcmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; + + HW_IPCC_OT_SendCmd(); + + return; +} + +void TL_CLI_SendCmd( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->clicmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; + + HW_IPCC_CLI_SendCmd(); + + return; +} + +void TL_THREAD_SendAck ( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_THREAD_SendAck(); + + return; +} + +void TL_THREAD_CliSendAck ( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_THREAD_CliSendAck(); + + return; +} + +void HW_IPCC_OT_CmdEvtNot(void) +{ + TL_OT_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->otcmdrsp_buffer) ); + + return; +} + +void HW_IPCC_THREAD_EvtNot( void ) +{ + TL_THREAD_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->notack_buffer) ); + + return; +} + +void HW_IPCC_THREAD_CliEvtNot( void ) +{ + TL_THREAD_CliNotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->clicmdrsp_buffer) ); + + return; +} + +__WEAK void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; +__WEAK void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer ){}; +__WEAK void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer ){}; + +#endif /* THREAD_WB */ + +/****************************************************************************** + * LLD TESTS + ******************************************************************************/ +#ifdef LLD_TESTS_WB +void TL_LLDTESTS_Init( TL_LLD_tests_Config_t *p_Config ) +{ + MB_LldTestsTable_t * p_lld_tests_table; + + p_lld_tests_table = TL_RefTable.p_lld_tests_table; + p_lld_tests_table->clicmdrsp_buffer = p_Config->p_LldTestsCliCmdRspBuffer; + p_lld_tests_table->m0cmd_buffer = p_Config->p_LldTestsM0CmdBuffer; + HW_IPCC_LLDTESTS_Init(); + return; +} + +void TL_LLDTESTS_SendCliCmd( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; + HW_IPCC_LLDTESTS_SendCliCmd(); + return; +} + +void HW_IPCC_LLDTESTS_ReceiveCliRsp( void ) +{ + TL_LLDTESTS_ReceiveCliRsp( (TL_CmdPacket_t*)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer) ); + return; +} + +void TL_LLDTESTS_SendCliRspAck( void ) +{ + HW_IPCC_LLDTESTS_SendCliRspAck(); + return; +} + +void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void ) +{ + TL_LLDTESTS_ReceiveM0Cmd( (TL_CmdPacket_t*)(TL_RefTable.p_lld_tests_table->m0cmd_buffer) ); + return; +} + + +void TL_LLDTESTS_SendM0CmdAck( void ) +{ + HW_IPCC_LLDTESTS_SendM0CmdAck(); + return; +} + +__WEAK void TL_LLDTESTS_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ){}; +__WEAK void TL_LLDTESTS_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ){}; +#endif /* LLD_TESTS_WB */ + +/****************************************************************************** + * LLD BLE + ******************************************************************************/ +#ifdef LLD_BLE_WB +void TL_LLD_BLE_Init( TL_LLD_BLE_Config_t *p_Config ) +{ + MB_LldBleTable_t * p_lld_ble_table; + + p_lld_ble_table = TL_RefTable.p_lld_ble_table; + p_lld_ble_table->cmdrsp_buffer = p_Config->p_LldBleCmdRspBuffer; + p_lld_ble_table->m0cmd_buffer = p_Config->p_LldBleM0CmdBuffer; + HW_IPCC_LLD_BLE_Init(); + return; +} + +void TL_LLD_BLE_SendCliCmd( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; + HW_IPCC_LLD_BLE_SendCliCmd(); + return; +} + +void HW_IPCC_LLD_BLE_ReceiveCliRsp( void ) +{ + TL_LLD_BLE_ReceiveCliRsp( (TL_CmdPacket_t*)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer) ); + return; +} + +void TL_LLD_BLE_SendCliRspAck( void ) +{ + HW_IPCC_LLD_BLE_SendCliRspAck(); + return; +} + +void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ) +{ + TL_LLD_BLE_ReceiveM0Cmd( (TL_CmdPacket_t*)(TL_RefTable.p_lld_ble_table->m0cmd_buffer) ); + return; +} + + +void TL_LLD_BLE_SendM0CmdAck( void ) +{ + HW_IPCC_LLD_BLE_SendM0CmdAck(); + return; +} + +__WEAK void TL_LLD_BLE_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ){}; +__WEAK void TL_LLD_BLE_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ){}; + +/* Transparent Mode */ +void TL_LLD_BLE_SendCmd( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; + HW_IPCC_LLD_BLE_SendCmd(); + return; +} + +void HW_IPCC_LLD_BLE_ReceiveRsp( void ) +{ + TL_LLD_BLE_ReceiveRsp( (TL_CmdPacket_t*)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer) ); + return; +} + +void TL_LLD_BLE_SendRspAck( void ) +{ + HW_IPCC_LLD_BLE_SendRspAck(); + return; +} +#endif /* LLD_BLE_WB */ + +#ifdef MAC_802_15_4_WB +/****************************************************************************** + * MAC 802.15.4 + ******************************************************************************/ +void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ) +{ + MB_Mac_802_15_4_t * p_mac_802_15_4_table; + + p_mac_802_15_4_table = TL_RefTable.p_mac_802_15_4_table; + + p_mac_802_15_4_table->p_cmdrsp_buffer = p_Config->p_Mac_802_15_4_CmdRspBuffer; + p_mac_802_15_4_table->p_notack_buffer = p_Config->p_Mac_802_15_4_NotAckBuffer; + + HW_IPCC_MAC_802_15_4_Init(); + + return; +} + +void TL_MAC_802_15_4_SendCmd( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; + + HW_IPCC_MAC_802_15_4_SendCmd(); + + return; +} + +void TL_MAC_802_15_4_SendAck ( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_MAC_802_15_4_SendAck(); + + return; +} + +void HW_IPCC_MAC_802_15_4_CmdEvtNot(void) +{ + TL_MAC_802_15_4_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer) ); + + return; +} + +void HW_IPCC_MAC_802_15_4_EvtNot( void ) +{ + TL_MAC_802_15_4_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer) ); + + return; +} + +__WEAK void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; +__WEAK void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){}; +#endif + +#ifdef ZIGBEE_WB +/****************************************************************************** + * ZIGBEE + ******************************************************************************/ +void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ) +{ + MB_ZigbeeTable_t * p_zigbee_table; + + p_zigbee_table = TL_RefTable.p_zigbee_table; + p_zigbee_table->appliCmdM4toM0_buffer = p_Config->p_ZigbeeOtCmdRspBuffer; + p_zigbee_table->notifM0toM4_buffer = p_Config->p_ZigbeeNotAckBuffer; + p_zigbee_table->requestM0toM4_buffer = p_Config->p_ZigbeeNotifRequestBuffer; + + HW_IPCC_ZIGBEE_Init(); + + return; +} + +/* Zigbee M4 to M0 Request */ +void TL_ZIGBEE_SendM4RequestToM0( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4RequestToM0(); + + return; +} + +/* Used to receive an ACK from the M0 */ +void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void) +{ + TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) ); + + return; +} + +/* Zigbee notification from M0 to M4 */ +void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ) +{ + TL_ZIGBEE_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer) ); + + return; +} + +/* Send an ACK to the M0 for a Notification */ +void TL_ZIGBEE_SendM4AckToM0Notify ( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4AckToM0Notify(); + + return; +} + +/* Zigbee M0 to M4 Request */ +void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ) +{ + TL_ZIGBEE_M0RequestReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer) ); + + return; +} + +/* Send an ACK to the M0 for a Request */ +void TL_ZIGBEE_SendM4AckToM0Request(void) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4AckToM0Request(); + + return; +} + + +__WEAK void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; +__WEAK void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){}; +#endif + + + +/****************************************************************************** + * MEMORY MANAGER + ******************************************************************************/ +void TL_MM_Init( TL_MM_Config_t *p_Config ) +{ + static MB_MemManagerTable_t * p_mem_manager_table; + + LST_init_head (&FreeBufQueue); + LST_init_head (&LocalFreeBufQueue); + + p_mem_manager_table = TL_RefTable.p_mem_manager_table; + + p_mem_manager_table->blepool = p_Config->p_AsynchEvtPool; + p_mem_manager_table->blepoolsize = p_Config->AsynchEvtPoolSize; + p_mem_manager_table->pevt_free_buffer_queue = (uint8_t*)&FreeBufQueue; + p_mem_manager_table->spare_ble_buffer = p_Config->p_BleSpareEvtBuffer; + p_mem_manager_table->spare_sys_buffer = p_Config->p_SystemSpareEvtBuffer; + p_mem_manager_table->traces_evt_pool = p_Config->p_TracesEvtPool; + p_mem_manager_table->tracespoolsize = p_Config->TracesEvtPoolSize; + + return; +} + +void TL_MM_EvtDone(TL_EvtPacket_t * phcievt) +{ + LST_insert_tail(&LocalFreeBufQueue, (tListNode *)phcievt); + + OutputMemReleaseTrace(phcievt); + + HW_IPCC_MM_SendFreeBuf( SendFreeBuf ); + + return; +} + +static void SendFreeBuf( void ) +{ + tListNode *p_node; + + while ( FALSE == LST_is_empty (&LocalFreeBufQueue) ) + { + LST_remove_head( &LocalFreeBufQueue, (tListNode **)&p_node ); + LST_insert_tail( (tListNode*)(TL_RefTable.p_mem_manager_table->pevt_free_buffer_queue), p_node ); + } + + return; +} + +static void OutputMemReleaseTrace(TL_EvtPacket_t * phcievt) +{ + switch(phcievt->evtserial.evt.evtcode) + { + case TL_BLEEVT_CS_OPCODE: + TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode); + TL_MM_DBG__MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(phcievt->evtserial.evt.payload))->cmdcode); + TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); + break; + + case TL_BLEEVT_CC_OPCODE: + TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode); + TL_MM_DBG__MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(phcievt->evtserial.evt.payload))->cmdcode); + TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); + break; + + case TL_BLEEVT_VS_OPCODE: + TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode); + TL_MM_DBG__MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(phcievt->evtserial.evt.payload))->subevtcode); + TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); + break; + + default: + TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode); + TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); + break; + } + + TL_MM_DBG__MSG("\r\n"); + + return; +} + +/****************************************************************************** + * TRACES + ******************************************************************************/ +void TL_TRACES_Init( void ) +{ + LST_init_head (&TracesEvtQueue); + + TL_RefTable.p_traces_table->traces_queue = (uint8_t*)&TracesEvtQueue; + + HW_IPCC_TRACES_Init(); + + return; +} + +void HW_IPCC_TRACES_EvtNot(void) +{ + TL_EvtPacket_t *phcievt; + + while(LST_is_empty(&TracesEvtQueue) == FALSE) + { + LST_remove_head (&TracesEvtQueue, (tListNode **)&phcievt); + TL_TRACES_EvtReceived( phcievt ); + } + + return; +} + +__WEAK void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ) +{ + (void)(hcievt); +} + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From ac3469e5f51cd684d75e85510319922c0530da05 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 1 Dec 2021 15:13:05 +0100 Subject: [PATCH 10/58] chore: clean up and adapt STM32Cube_FW sources for STM32duino Signed-off-by: Frederic Pillon --- src/utility/STM32Cube_FW/app_conf.h | 390 +------------------ src/utility/STM32Cube_FW/ble_bufsize.h | 6 +- src/utility/STM32Cube_FW/hw.h | 28 +- src/utility/STM32Cube_FW/hw_ipcc.c | 187 +-------- src/utility/STM32Cube_FW/mbox_def.h | 34 -- src/utility/STM32Cube_FW/shci.c | 40 +- src/utility/STM32Cube_FW/shci.h | 50 +-- src/utility/STM32Cube_FW/shci_tl.c | 19 +- src/utility/STM32Cube_FW/stm32_wpan_common.h | 35 +- src/utility/STM32Cube_FW/stm_list.c | 11 +- src/utility/STM32Cube_FW/stm_list.h | 4 +- src/utility/STM32Cube_FW/tl.h | 33 -- src/utility/STM32Cube_FW/tl_mbox.c | 144 +------ 13 files changed, 87 insertions(+), 894 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf.h b/src/utility/STM32Cube_FW/app_conf.h index ac5ccd4d..df081ef1 100644 --- a/src/utility/STM32Cube_FW/app_conf.h +++ b/src/utility/STM32Cube_FW/app_conf.h @@ -1,4 +1,3 @@ -/* USER CODE BEGIN Header */ /** ****************************************************************************** * File Name : app_conf.h @@ -16,89 +15,36 @@ * ****************************************************************************** */ -/* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef APP_CONF_H #define APP_CONF_H #include "hw.h" -#include "hw_conf.h" -#include "hw_if.h" +#include "ble_bufsize.h" /****************************************************************************** * Application Config ******************************************************************************/ -/** - * Define Secure Connections Support - */ -#define CFG_SECURE_NOT_SUPPORTED (0x00) -#define CFG_SECURE_OPTIONAL (0x01) -#define CFG_SECURE_MANDATORY (0x02) - -#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL +/**< generic parameters ******************************************************/ +/* HCI related defines */ -/** - * Define Keypress Notification Support - */ -#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) -#define CFG_KEYPRESS_SUPPORTED (0x01) - -#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED - -/** - * Numeric Comparison Answers - */ -#define YES (0x01) -#define NO (0x00) +#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 -/** - * Device name configuration for Generic Access Service - */ -#define CFG_GAP_DEVICE_NAME "TEMPLATE" -#define CFG_GAP_DEVICE_NAME_LENGTH (8) - -/** -* Identity root key used to derive LTK and CSRK -*/ -#define CFG_BLE_IRK {0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0} - -/** -* Encryption root key used to derive LTK and CSRK -*/ -#define CFG_BLE_ERK {0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21,0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21} +#ifndef BLE_SHARED_MEM_BYTE_ORDER + #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST +#endif +#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 -/* USER CODE BEGIN Generic_Parameters */ /** - * SMPS supply - * SMPS not used when Set to 0 - * SMPS used when Set to 1 + * Define Tx Power */ -#define CFG_USE_SMPS 1 -/* USER CODE END Generic_Parameters */ - -/**< specific parameters */ -/*****************************************************/ - -#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler - -/****************************************************************************** - * Information Table - * - * Version - * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version - * [4:7] = branch - 0: Mass Market - x: ... - * [8:15] = Subversion - * [16:23] = Version minor - * [24:31] = Version major - * - ******************************************************************************/ -#define CFG_FW_MAJOR_VERSION (0) -#define CFG_FW_MINOR_VERSION (0) -#define CFG_FW_SUBVERSION (1) -#define CFG_FW_BRANCH (0) -#define CFG_FW_BUILD (0) +#define CFG_TX_POWER (0x18) /* -0.15dBm */ /****************************************************************************** * BLE Stack @@ -144,12 +90,14 @@ /** * Prepare Write List size in terms of number of packet */ -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +// #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) /** * Number of allocated memory blocks */ -#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) +// #define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) +#define CFG_BLE_MBLOCK_COUNT (0x79) /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. @@ -203,307 +151,7 @@ * 1 : LL Only * 0 : LL + Host */ -#define CFG_BLE_LL_ONLY 0 -/****************************************************************************** - * Transport Layer - ******************************************************************************/ -/** - * Queue length of BLE Event - * This parameter defines the number of asynchronous events that can be stored in the HCI layer before - * being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer - * is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large - * enough to store all asynchronous events received in between. - * When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events - * between the HCI command and its event. - * This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small, - * the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting - * for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate - * to the application a HCI command did not receive its command event within 30s (Default HCI Timeout). - */ -#define CFG_TLBLE_EVT_QUEUE_LENGTH 5 -/** - * This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element - * allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager. - * It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will - * never be used) - * It shall be at least 4 to receive the command status event in one frame. - * The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced - * further depending on the application. - * - */ -#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */ - -#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE ) -/****************************************************************************** - * UART interfaces - ******************************************************************************/ - -/** - * Select UART interfaces - */ -#define CFG_UART_GUI hw_uart1 -#define CFG_DEBUG_TRACE_UART 0 -/****************************************************************************** - * USB interface - ******************************************************************************/ - -/** - * Enable/Disable USB interface - */ -#define CFG_USB_INTERFACE_ENABLE 0 - -/****************************************************************************** - * Low Power - ******************************************************************************/ -/** - * When set to 1, the low power mode is enable - * When set to 0, the device stays in RUN mode - */ -#define CFG_LPM_SUPPORTED 1 - -/****************************************************************************** - * Timer Server - ******************************************************************************/ -/** - * CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer. - * The higher is the value, the better is the power consumption and the accuracy of the timerserver - * The lower is the value, the finest is the granularity - * - * CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to ouput - * clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding - * the wakeup timer. A lower clock speed would impact the accuracy of the timer server. - * - * CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC. - * When the 1Hz calendar clock is required, it shall be sets according to other settings - * When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE) - * - * CFG_RTCCLK_DIVIDER_CONF: - * Shall be set to either 0,2,4,8,16 - * When set to either 2,4,8,16, the 1Hhz calendar is supported - * When set to 0, the user sets its own configuration - * - * The following settings are computed with LSI as input to the RTC - */ -#define CFG_RTCCLK_DIVIDER_CONF 0 - -#if (CFG_RTCCLK_DIVIDER_CONF == 0) -/** - * Custom configuration - * It does not support 1Hz calendar - * It divides the RTC CLK by 16 - */ -#define CFG_RTCCLK_DIV (16) -#define CFG_RTC_WUCKSEL_DIVIDER (0) -#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) -#define CFG_RTC_SYNCH_PRESCALER (0x7FFF) - -#else - -#if (CFG_RTCCLK_DIVIDER_CONF == 2) -/** - * It divides the RTC CLK by 2 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (3) -#endif - -#if (CFG_RTCCLK_DIVIDER_CONF == 4) -/** - * It divides the RTC CLK by 4 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (2) -#endif - -#if (CFG_RTCCLK_DIVIDER_CONF == 8) -/** - * It divides the RTC CLK by 8 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (1) -#endif - -#if (CFG_RTCCLK_DIVIDER_CONF == 16) -/** - * It divides the RTC CLK by 16 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (0) -#endif - -#define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF -#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) -#define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 ) - -#endif - -/** tick timer value in us */ -#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE ) - -typedef enum -{ - CFG_TIM_PROC_ID_ISR, -} CFG_TimProcID_t; - -/****************************************************************************** - * Debug - ******************************************************************************/ -/** - * When set, this resets some hw resources to set the device in the same state than the power up - * The FW resets only register that may prevent the FW to run properly - * - * This shall be set to 0 in a final product - * - */ -#define CFG_HW_RESET_BY_FW 1 - -/** - * keep debugger enabled while in any low power mode when set to 1 - * should be set to 0 in production - */ -#define CFG_DEBUGGER_SUPPORTED 0 - -/** - * When set to 1, the traces are enabled in the BLE services - */ -#define CFG_DEBUG_BLE_TRACE 0 - -/** - * Enable or Disable traces in application - */ -#define CFG_DEBUG_APP_TRACE 0 - -#if (CFG_DEBUG_APP_TRACE != 0) -#define APP_DBG_MSG PRINT_MESG_DBG -#else -#define APP_DBG_MSG PRINT_NO_MESG -#endif - -#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) ) -#define CFG_DEBUG_TRACE 1 -#endif - -#if (CFG_DEBUG_TRACE != 0) -#undef CFG_LPM_SUPPORTED -#undef CFG_DEBUGGER_SUPPORTED -#define CFG_LPM_SUPPORTED 0 -#define CFG_DEBUGGER_SUPPORTED 1 -#endif - -/** - * When CFG_DEBUG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number - * When CFG_DEBUG_TRACE_LIGHT is set to 1, only the debug message is output - * - * When both are set to 0, no trace are output - * When both are set to 1, CFG_DEBUG_TRACE_FULL is selected - */ -#define CFG_DEBUG_TRACE_LIGHT 0 -#define CFG_DEBUG_TRACE_FULL 0 - -#if (( CFG_DEBUG_TRACE != 0 ) && ( CFG_DEBUG_TRACE_LIGHT == 0 ) && (CFG_DEBUG_TRACE_FULL == 0)) -#undef CFG_DEBUG_TRACE_FULL -#undef CFG_DEBUG_TRACE_LIGHT -#define CFG_DEBUG_TRACE_FULL 0 -#define CFG_DEBUG_TRACE_LIGHT 1 -#endif - -#if ( CFG_DEBUG_TRACE == 0 ) -#undef CFG_DEBUG_TRACE_FULL -#undef CFG_DEBUG_TRACE_LIGHT -#define CFG_DEBUG_TRACE_FULL 0 -#define CFG_DEBUG_TRACE_LIGHT 0 -#endif - -/** - * When not set, the traces is looping on sending the trace over UART - */ -#define DBG_TRACE_USE_CIRCULAR_QUEUE 1 - -/** - * max buffer Size to queue data traces and max data trace allowed. - * Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined - */ -#define DBG_TRACE_MSG_QUEUE_SIZE 4096 -#define MAX_DBG_TRACE_MSG_SIZE 1024 - -/* USER CODE BEGIN Defines */ -#define CFG_LED_SUPPORTED 1 -#define CFG_BUTTON_SUPPORTED 1 -/* USER CODE END Defines */ - -/****************************************************************************** - * Scheduler - ******************************************************************************/ - -/** - * These are the lists of task id registered to the scheduler - * Each task id shall be in the range [0:31] - * This mechanism allows to implement a generic code in the API TL_BLE_HCI_StatusNot() to comply with - * the requirement that a HCI/ACI command shall never be sent if there is already one pending - */ - -/**< Add in that list all tasks that may send a ACI/HCI command */ -typedef enum -{ - CFG_TASK_BLE_HCI_CMD_ID, - CFG_TASK_SYS_HCI_CMD_ID, - CFG_TASK_HCI_ACL_DATA_ID, - CFG_TASK_SYS_LOCAL_CMD_ID, - CFG_TASK_TX_TO_HOST_ID, -/* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */ - -/* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */ - CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */ -} CFG_Task_Id_With_HCI_Cmd_t; - -/**< Add in that list all tasks that never send a ACI/HCI command */ -typedef enum -{ - CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */ - CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID, -/* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */ - -/* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */ - CFG_LAST_TASK_ID_WITHO_NO_HCICMD /**< Shall be LAST in the list */ -} CFG_Task_Id_With_NO_HCI_Cmd_t; -#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITHO_NO_HCICMD - -/** - * This is the list of priority required by the application - * Each Id shall be in the range 0..31 - */ -typedef enum -{ - CFG_SCH_PRIO_0, - CFG_PRIO_NBR, -} CFG_SCH_Prio_Id_t; - -/** - * This is a bit mapping over 32bits listing all events id supported in the application - */ -typedef enum -{ - CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID, -} CFG_IdleEvt_Id_t; - -/****************************************************************************** - * LOW POWER - ******************************************************************************/ -/** - * Supported requester to the MCU Low Power Manager - can be increased up to 32 - * It lits a bit mapping of all user of the Low Power Manager - */ -typedef enum -{ - CFG_LPM_APP, - CFG_LPM_APP_BLE, - /* USER CODE BEGIN CFG_LPM_Id_t */ - - /* USER CODE END CFG_LPM_Id_t */ -} CFG_LPM_Id_t; - -/****************************************************************************** - * OTP manager - ******************************************************************************/ -#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE - -#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR +#define CFG_BLE_LL_ONLY 1 #endif /*APP_CONF_H */ diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h index c5a5d569..8930e401 100644 --- a/src/utility/STM32Cube_FW/ble_bufsize.h +++ b/src/utility/STM32Cube_FW/ble_bufsize.h @@ -90,15 +90,15 @@ /* * BLE_FIXED_BUFFER_SIZE_BYTES: - * A part of the RAM, is dinamically allocated by initilizing all the pointers + * A part of the RAM, is dynamically allocated by initializing all the pointers * defined in a global context variable "mem_alloc_ctx_p". * This initialization is made in the Dynamic_allocator functions, which - * assing a portion of RAM given by the external application to the above + * assign a portion of RAM given by the external application to the above * mentioned "global pointers". * * The size of this Dynamic RAM is made of 2 main components: * - a part that is parameters-dependent (num of links, GATT buffers, ...), - * and which value is explicited by the following macro; + * and which value is defined by the following macro; * - a part, that may be considered "fixed", i.e. independent from the above * mentioned parameters. */ diff --git a/src/utility/STM32Cube_FW/hw.h b/src/utility/STM32Cube_FW/hw.h index 879fa6de..a94bec9c 100644 --- a/src/utility/STM32Cube_FW/hw.h +++ b/src/utility/STM32Cube_FW/hw.h @@ -27,14 +27,21 @@ 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 ); void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); @@ -80,23 +87,6 @@ extern "C" { void HW_IPCC_TRACES_Init( void ); void HW_IPCC_TRACES_EvtNot( void ); - - void HW_IPCC_MAC_802_15_4_Init( void ); - void HW_IPCC_MAC_802_15_4_SendCmd( void ); - void HW_IPCC_MAC_802_15_4_SendAck( void ); - void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ); - void HW_IPCC_MAC_802_15_4_EvtNot( void ); - - void HW_IPCC_ZIGBEE_Init( void ); - - void HW_IPCC_ZIGBEE_SendM4RequestToM0(void); /* M4 Request to M0 */ - void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void); /* Request ACK from M0 */ - - void HW_IPCC_ZIGBEE_RecvM0NotifyToM4(void); /* M0 Notify to M4 */ - void HW_IPCC_ZIGBEE_SendM4AckToM0Notify(void); /* Notify ACK from M4 */ - void HW_IPCC_ZIGBEE_RecvM0RequestToM4(void); /* M0 Request to M4 */ - void HW_IPCC_ZIGBEE_SendM4AckToM0Request(void); /* Request ACK from M4 */ - #ifdef __cplusplus } diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c index 6da31992..d1f8b650 100644 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ b/src/utility/STM32Cube_FW/hw_ipcc.c @@ -16,9 +16,9 @@ * ****************************************************************************** */ - +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ -#include "app_common.h" +#include "hw.h" #include "mbox_def.h" /* Global variables ---------------------------------------------------------*/ @@ -45,35 +45,17 @@ static void HW_IPCC_THREAD_NotEvtHandler( void ); static void HW_IPCC_THREAD_CliNotEvtHandler( void ); #endif -#ifdef MAC_802_15_4_WB -static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ); -static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ); -#endif - -#ifdef ZIGBEE_WB -static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ); -static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ); -static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ); - -#endif - /* Public function definition -----------------------------------------------*/ /****************************************************************************** * INTERRUPT HANDLER ******************************************************************************/ -void HW_IPCC_Rx_Handler( void ) +void IPCC_C1_RX_IRQHandler(void) { if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL )) { HW_IPCC_SYS_EvtHandler(); } -#ifdef MAC_802_15_4_WB - else if (HW_IPCC_RX_PENDING( HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL )) - { - HW_IPCC_MAC_802_15_4_NotEvtHandler(); - } -#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL )) { @@ -84,16 +66,6 @@ void HW_IPCC_Rx_Handler( void ) HW_IPCC_THREAD_CliNotEvtHandler(); } #endif /* THREAD_WB */ -#ifdef ZIGBEE_WB - else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL )) - { - HW_IPCC_ZIGBEE_StackNotifEvtHandler(); - } - else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL )) - { - HW_IPCC_ZIGBEE_StackM0RequestHandler(); - } -#endif /* ZIGBEE_WB */ else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL )) { HW_IPCC_BLE_EvtHandler(); @@ -102,34 +74,20 @@ void HW_IPCC_Rx_Handler( void ) { HW_IPCC_TRACES_EvtHandler(); } - - return; } -void HW_IPCC_Tx_Handler( void ) +void IPCC_C1_TX_IRQHandler(void) { if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) { HW_IPCC_SYS_CmdEvtHandler(); } -#ifdef MAC_802_15_4_WB - else if (HW_IPCC_TX_PENDING( HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL )) - { - HW_IPCC_MAC_802_15_4_CmdEvtHandler(); - } -#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) { HW_IPCC_OT_CmdEvtHandler(); } #endif /* THREAD_WB */ -#ifdef ZIGBEE_WB - if (HW_IPCC_TX_PENDING( HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL )) - { - HW_IPCC_ZIGBEE_CmdEvtHandler(); - } -#endif /* ZIGBEE_WB */ else if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) { HW_IPCC_SYS_CmdEvtHandler(); @@ -142,9 +100,8 @@ void HW_IPCC_Tx_Handler( void ) { HW_IPCC_BLE_AclDataEvtHandler(); } - - return; } + /****************************************************************************** * GENERAL ******************************************************************************/ @@ -228,8 +185,8 @@ static void HW_IPCC_BLE_AclDataEvtHandler( void ) return; } -__weak void HW_IPCC_BLE_AclDataAckNot( void ){}; -__weak void HW_IPCC_BLE_RxEvtNot( void ){}; +__WEAK void HW_IPCC_BLE_AclDataAckNot( void ){}; +__WEAK void HW_IPCC_BLE_RxEvtNot( void ){}; /****************************************************************************** * SYSTEM @@ -267,56 +224,8 @@ static void HW_IPCC_SYS_EvtHandler( void ) return; } -__weak void HW_IPCC_SYS_CmdEvtNot( void ){}; -__weak void HW_IPCC_SYS_EvtNot( void ){}; - -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -#ifdef MAC_802_15_4_WB -void HW_IPCC_MAC_802_15_4_Init( void ) -{ - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -void HW_IPCC_MAC_802_15_4_SendCmd( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - - return; -} - -void HW_IPCC_MAC_802_15_4_SendAck( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ) -{ - LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - - HW_IPCC_MAC_802_15_4_CmdEvtNot(); - - return; -} - -static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - HW_IPCC_MAC_802_15_4_EvtNot(); - - return; -} -__weak void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ){}; -__weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){}; -#endif +__WEAK void HW_IPCC_SYS_CmdEvtNot( void ){}; +__WEAK void HW_IPCC_SYS_EvtNot( void ){}; /****************************************************************************** * THREAD @@ -388,80 +297,12 @@ static void HW_IPCC_THREAD_CliNotEvtHandler( void ) return; } -__weak void HW_IPCC_OT_CmdEvtNot( void ){}; -__weak void HW_IPCC_CLI_CmdEvtNot( void ){}; -__weak void HW_IPCC_THREAD_EvtNot( void ){}; +__WEAK void HW_IPCC_OT_CmdEvtNot( void ){}; +__WEAK void HW_IPCC_CLI_CmdEvtNot( void ){}; +__WEAK void HW_IPCC_THREAD_EvtNot( void ){}; #endif /* THREAD_WB */ -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -#ifdef ZIGBEE_WB -void HW_IPCC_ZIGBEE_Init( void ) -{ - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - - return; -} - -void HW_IPCC_ZIGBEE_SendM4RequestToM0( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); - LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); - - return; -} - -void HW_IPCC_ZIGBEE_SendM4AckToM0Notify( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - - return; -} - -static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ) -{ - LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); - - HW_IPCC_ZIGBEE_RecvAppliAckFromM0(); - - return; -} - -static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - - HW_IPCC_ZIGBEE_RecvM0NotifyToM4(); - - return; -} - -static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - - HW_IPCC_ZIGBEE_RecvM0RequestToM4(); - - return; -} - -void HW_IPCC_ZIGBEE_SendM4AckToM0Request( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - - return; -} - -__weak void HW_IPCC_ZIGBEE_RecvAppliAckFromM0( void ){}; -__weak void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ){}; -__weak void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ){}; -#endif /* ZIGBEE_WB */ - /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -512,6 +353,6 @@ static void HW_IPCC_TRACES_EvtHandler( void ) return; } -__weak void HW_IPCC_TRACES_EvtNot( void ){}; - +__WEAK void HW_IPCC_TRACES_EvtNot( void ){}; +#endif /* STM32WBxx */ /******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h index 1741a8c3..6bddf696 100644 --- a/src/utility/STM32Cube_FW/mbox_def.h +++ b/src/utility/STM32Cube_FW/mbox_def.h @@ -106,12 +106,6 @@ extern "C" { uint8_t *m0cmd_buffer; } MB_LldBleTable_t; - typedef struct - { - uint8_t *notifM0toM4_buffer; - uint8_t *appliCmdM4toM0_buffer; - uint8_t *requestM0toM4_buffer; - } MB_ZigbeeTable_t; /** * msg * [0:7] = cmd/evt @@ -139,13 +133,6 @@ extern "C" { uint8_t *traces_queue; } MB_TracesTable_t; - typedef struct - { - uint8_t *p_cmdrsp_buffer; - uint8_t *p_notack_buffer; - uint8_t *evt_queue; - } MB_Mac_802_15_4_t; - typedef struct { MB_DeviceInfoTable_t *p_device_info_table; @@ -154,8 +141,6 @@ extern "C" { MB_SysTable_t *p_sys_table; MB_MemManagerTable_t *p_mem_manager_table; MB_TracesTable_t *p_traces_table; - MB_Mac_802_15_4_t *p_mac_802_15_4_table; - MB_ZigbeeTable_t *p_zigbee_table; MB_LldTestsTable_t *p_lld_tests_table; MB_LldBleTable_t *p_lld_ble_table; } MB_RefTable_t; @@ -176,15 +161,6 @@ extern "C" { * | | * |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------| * | | - * | (ZIGBEE) | - * |----HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL------------>| - * | | - * |----HW_IPCC_ZIGBEE_CMD_CLI_CHANNEL-------------->| - * | | - * |<---HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL-------| - * | | - * |<---HW_IPCC_ZIGBEE_CLI_NOTIF_ACK_CHANNEL---------| - * | | * | (THREAD) | * |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->| * | | @@ -208,11 +184,6 @@ extern "C" { * | | * |<---HW_IPCC_LLD_BLE_M0_CMD_CHANNEL---------------| * | | - * | (MAC) | - * |----HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL-------->| - * | | - * |<---HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL| - * | | * | (BUFFER) | * |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>| * | | @@ -230,8 +201,6 @@ extern "C" { #define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4 #define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 @@ -243,8 +212,6 @@ extern "C" { #define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_LLD_BLE_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4 @@ -252,7 +219,6 @@ extern "C" { #define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_LLD_BLE_RSP_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL LL_IPCC_CHANNEL_5 #endif /*__MBOX_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c index 1edf1feb..b848dd85 100644 --- a/src/utility/STM32Cube_FW/shci.c +++ b/src/utility/STM32Cube_FW/shci.c @@ -17,7 +17,7 @@ ****************************************************************************** */ - +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -316,24 +316,6 @@ SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init( uint8_t param_size, uint8_t * p_param ) return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t * p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send( SHCI_OPCODE_C2_ZIGBEE_INIT, - 0, - 0, - p_rsp ); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); -} - SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ) { /** @@ -453,24 +435,6 @@ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t Fla return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t * p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send( SHCI_OPCODE_C2_MAC_802_15_4_INIT, - 0, - 0, - p_rsp ); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); -} - SHCI_CmdStatus_t SHCI_C2_Reinit( void ) { /** @@ -605,5 +569,5 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } - +#endif /* STM32WBxx */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h index e737f4c5..11c53ced 100644 --- a/src/utility/STM32Cube_FW/shci.h +++ b/src/utility/STM32Cube_FW/shci.h @@ -50,7 +50,6 @@ extern "C" { ERR_BLE_INIT = 0, ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the M4 to control the Thread stack is unknown */ - ERR_ZIGBEE_UNKNOWN_CMD = 200, /* The command send by the M4 to control the Zigbee stack is unknown */ } SCHI_SystemErrCode_t; #define SHCI_EVTCODE ( 0xFF ) @@ -102,7 +101,7 @@ extern "C" { /** * SHCI_SUB_EVT_OT_NVM_RAM_UPDATE - * This notifies the CPU1 which part of the OT NVM RAM has been updated so that only the modified + * This notifies the CPU1 which part of the 'OT NVM RAM' has been updated so that only the modified * section could be written in Flash/NVM * StartAddress : Start address of the section that has been modified * Size : Size (in bytes) of the section that has been modified @@ -208,9 +207,7 @@ extern "C" { SHCI_OCF_C2_FLASH_STORE_DATA, SHCI_OCF_C2_FLASH_ERASE_DATA, SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, - SHCI_OCF_C2_MAC_802_15_4_INIT, SHCI_OCF_C2_REINIT, - SHCI_OCF_C2_ZIGBEE_INIT, SHCI_OCF_C2_LLD_TESTS_INIT, SHCI_OCF_C2_EXTPA_CONFIG, SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, @@ -378,8 +375,6 @@ extern "C" { { uint8_t thread_config; uint8_t ble_config; - uint8_t mac_802_15_4_config; - uint8_t zigbee_config; } SHCI_C2_DEBUG_TracesConfig_t; typedef PACKED_STRUCT @@ -419,7 +414,6 @@ extern "C" { { BLE_ENABLE, THREAD_ENABLE, - ZIGBEE_ENABLE, } SHCI_C2_CONCURRENT_Mode_Param_t; /** No response parameters*/ @@ -430,18 +424,13 @@ extern "C" { { BLE_IP, THREAD_IP, - ZIGBEE_IP, } SHCI_C2_FLASH_Ip_t; /** No response parameters*/ #define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) -#define SHCI_OPCODE_C2_MAC_802_15_4_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_MAC_802_15_4_INIT) - #define SHCI_OPCODE_C2_REINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_REINIT) -#define SHCI_OPCODE_C2_ZIGBEE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_ZIGBEE_INIT) - #define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) #define SHCI_OPCODE_C2_LLD_BLE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_BLE_INIT) @@ -540,14 +529,14 @@ extern "C" { typedef MB_WirelessFwInfoTable_t SHCI_WirelessFwInfoTable_t; /* - * At startup, the informations relative to the wireless binary are stored in RAM trough a structure defined by + * At startup, the information relative to the wireless binary are stored in RAM through a structure defined by * SHCI_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) * each of those coded on 32 bits as shown on the table below: * * * |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 | * ------------------------------------------------------------------------------------------------- - * Version | Major version | Minor version | Sub version | Branch |Releas Type| + * Version | Major version | Minor version | Sub version | Branch |Release Type| * ------------------------------------------------------------------------------------------------- * MemorySize | SRAM2B (kB) | SRAM2A (kB) | SRAM1 (kB) | FLASH (4kb) | * ------------------------------------------------------------------------------------------------- @@ -592,19 +581,11 @@ typedef MB_WirelessFwInfoTable_t SHCI_WirelessFwInfoTable_t; #define INFO_STACK_TYPE_BLE_LIGHT 0x03 #define INFO_STACK_TYPE_THREAD_FTD 0x10 #define INFO_STACK_TYPE_THREAD_MTD 0x11 -#define INFO_STACK_TYPE_ZIGBEE_FFD 0x30 -#define INFO_STACK_TYPE_ZIGBEE_RFD 0x31 -#define INFO_STACK_TYPE_MAC 0x40 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 #define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 -#define INFO_STACK_TYPE_802154_LLD_TESTS 0x60 -#define INFO_STACK_TYPE_802154_PHY_VALID 0x61 #define INFO_STACK_TYPE_BLE_PHY_VALID 0x62 #define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 #define INFO_STACK_TYPE_BLE_RLV 0x64 -#define INFO_STACK_TYPE_802154_RLV 0x65 -#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_STATIC 0x70 -#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_DYNAMIC 0x78 #define INFO_STACK_TYPE_RLV 0x80 typedef struct { @@ -750,7 +731,7 @@ typedef struct { * @brief Starts the LLD tests CLI * * @param param_size : Nb of bytes - * @param p_param : pointeur with data to give from M4 to M0 + * @param p_param : pointer with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ); @@ -760,20 +741,11 @@ typedef struct { * @brief Starts the LLD tests CLI * * @param param_size : Nb of bytes - * @param p_param : pointeur with data to give from M4 to M0 + * @param p_param : pointer with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init( uint8_t param_size, uint8_t * p_param ); - /** - * SHCI_C2_ZIGBEE_Init - * @brief Starts the Zigbee Stack - * - * @param None - * @retval Status - */ - SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ); - /** * SHCI_C2_DEBUG_Init * @brief Starts the Traces @@ -829,19 +801,9 @@ typedef struct { */ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn); - - /** - * SHCI_C2_MAC_802_15_4_Init - * @brief Starts the MAC 802.15.4 on M0 - * - * @param None - * @retval Status - */ - SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ); - /** * SHCI_GetWirelessFwInfo - * @brief This function read back the informations relative to the wireless binary loaded. + * @brief This function read back the information relative to the wireless binary loaded. * Refer yourself to SHCI_WirelessFwInfoTable_t structure to get the significance * of the different parameters returned. * @param pWirelessInfo : Pointer to WirelessFwInfo_t. diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index 736f2793..27906395 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -17,12 +17,13 @@ ****************************************************************************** */ - +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "stm_list.h" #include "shci_tl.h" +#include "stm32_def.h" /** * These traces are not yet supported in an usual way in the delivery package @@ -203,6 +204,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 ) { @@ -348,4 +363,4 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } - +#endif /* STM32WBxx */ \ No newline at end of file diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h index cad9026d..93e909ca 100644 --- a/src/utility/STM32Cube_FW/stm32_wpan_common.h +++ b/src/utility/STM32Cube_FW/stm32_wpan_common.h @@ -26,19 +26,9 @@ extern "C" { #endif -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline -#endif +#define __ASM __asm /*!< asm keyword for GNU Compiler */ +#define __INLINE inline /*!< inline keyword for GNU Compiler */ +#define __STATIC_INLINE static inline #include #include @@ -141,25 +131,8 @@ extern "C" { /* ----------------------------------- * * Packed usage (compiler dependent) * * ----------------------------------- */ -#undef PACKED__ #undef PACKED_STRUCT - -#if defined ( __CC_ARM ) - #if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050U) - #define PACKED__ __attribute__((packed)) - #define PACKED_STRUCT struct PACKED__ - #else - #define PACKED__(TYPE) __packed TYPE - #define PACKED_STRUCT PACKED__(struct) - #endif -#elif defined ( __GNUC__ ) - #define PACKED__ __attribute__((packed)) - #define PACKED_STRUCT struct PACKED__ -#elif defined (__ICCARM__) - #define PACKED_STRUCT __packed struct -#elif - #define PACKED_STRUCT __packed struct -#endif +#define PACKED_STRUCT struct __packed #ifdef __cplusplus } diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c index 42e2d500..6e802a07 100644 --- a/src/utility/STM32Cube_FW/stm_list.c +++ b/src/utility/STM32Cube_FW/stm_list.c @@ -17,13 +17,13 @@ ****************************************************************************** */ - +#if defined(STM32WBxx) /****************************************************************************** * Include Files ******************************************************************************/ -#include "utilities_common.h" - #include "stm_list.h" +#include "cmsis_gcc.h" +#include "stm32_wpan_common.h" /****************************************************************************** * Function Definitions @@ -34,10 +34,10 @@ void LST_init_head (tListNode * listHead) listHead->prev = listHead; } -uint8_t LST_is_empty (tListNode * listHead) +bool LST_is_empty (tListNode * listHead) { uint32_t primask_bit; - uint8_t return_value; + bool return_value; primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ @@ -206,3 +206,4 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } +#endif /* STM32WBxx */ \ No newline at end of file diff --git a/src/utility/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h index 78e74463..84e22cd7 100644 --- a/src/utility/STM32Cube_FW/stm_list.h +++ b/src/utility/STM32Cube_FW/stm_list.h @@ -22,6 +22,8 @@ #define _STM_LIST_H_ /* Includes ------------------------------------------------------------------*/ +#include "stdint.h" +#include "stdbool.h" typedef struct _tListNode { struct _tListNode * next; @@ -30,7 +32,7 @@ typedef struct _tListNode { void LST_init_head (tListNode * listHead); -uint8_t LST_is_empty (tListNode * listHead); +bool LST_is_empty (tListNode * listHead); void LST_insert_head (tListNode * listHead, tListNode * node); diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h index e5fac413..4741599d 100644 --- a/src/utility/STM32Cube_FW/tl.h +++ b/src/utility/STM32Cube_FW/tl.h @@ -199,19 +199,6 @@ typedef struct uint8_t *p_LldBleM0CmdBuffer; } TL_LLD_BLE_Config_t; -typedef struct -{ - uint8_t *p_Mac_802_15_4_CmdRspBuffer; - uint8_t *p_Mac_802_15_4_NotAckBuffer; -} TL_MAC_802_15_4_Config_t; - -typedef struct -{ - uint8_t *p_ZigbeeOtCmdRspBuffer; - uint8_t *p_ZigbeeNotAckBuffer; - uint8_t *p_ZigbeeNotifRequestBuffer; -} TL_ZIGBEE_Config_t; - /** * @brief Contain the BLE HCI Init Configuration * @{ @@ -305,26 +292,6 @@ void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); void TL_TRACES_Init( void ); void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ); -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ); -void TL_MAC_802_15_4_SendCmd( void ); -void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); -void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ); -void TL_MAC_802_15_4_SendAck ( void ); - -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ); -void TL_ZIGBEE_SendM4RequestToM0( void ); -void TL_ZIGBEE_SendM4AckToM0Notify ( void ); -void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ); -void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); -void TL_ZIGBEE_M0RequestReceived(TL_EvtPacket_t * Otbuffer ); -void TL_ZIGBEE_SendM4AckToM0Request(void); - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c index 507edba2..8b579d5b 100644 --- a/src/utility/STM32Cube_FW/tl_mbox.c +++ b/src/utility/STM32Cube_FW/tl_mbox.c @@ -17,7 +17,7 @@ ****************************************************************************** */ - +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -56,15 +56,13 @@ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_LldBleTable_t TL_LldBleTable; 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; -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; /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue; PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)]; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode EvtQueue; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode SystemEvtQueue; +PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode EvtQueue; +PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode SystemEvtQueue; static tListNode LocalFreeBufQueue; @@ -102,8 +100,6 @@ 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; - TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; - TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; HW_IPCC_Init(); return; @@ -438,139 +434,6 @@ void TL_LLD_BLE_SendRspAck( void ) } #endif /* LLD_BLE_WB */ -#ifdef MAC_802_15_4_WB -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ) -{ - MB_Mac_802_15_4_t * p_mac_802_15_4_table; - - p_mac_802_15_4_table = TL_RefTable.p_mac_802_15_4_table; - - p_mac_802_15_4_table->p_cmdrsp_buffer = p_Config->p_Mac_802_15_4_CmdRspBuffer; - p_mac_802_15_4_table->p_notack_buffer = p_Config->p_Mac_802_15_4_NotAckBuffer; - - HW_IPCC_MAC_802_15_4_Init(); - - return; -} - -void TL_MAC_802_15_4_SendCmd( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; - - HW_IPCC_MAC_802_15_4_SendCmd(); - - return; -} - -void TL_MAC_802_15_4_SendAck ( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_MAC_802_15_4_SendAck(); - - return; -} - -void HW_IPCC_MAC_802_15_4_CmdEvtNot(void) -{ - TL_MAC_802_15_4_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer) ); - - return; -} - -void HW_IPCC_MAC_802_15_4_EvtNot( void ) -{ - TL_MAC_802_15_4_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer) ); - - return; -} - -__WEAK void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; -__WEAK void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){}; -#endif - -#ifdef ZIGBEE_WB -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ) -{ - MB_ZigbeeTable_t * p_zigbee_table; - - p_zigbee_table = TL_RefTable.p_zigbee_table; - p_zigbee_table->appliCmdM4toM0_buffer = p_Config->p_ZigbeeOtCmdRspBuffer; - p_zigbee_table->notifM0toM4_buffer = p_Config->p_ZigbeeNotAckBuffer; - p_zigbee_table->requestM0toM4_buffer = p_Config->p_ZigbeeNotifRequestBuffer; - - HW_IPCC_ZIGBEE_Init(); - - return; -} - -/* Zigbee M4 to M0 Request */ -void TL_ZIGBEE_SendM4RequestToM0( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendM4RequestToM0(); - - return; -} - -/* Used to receive an ACK from the M0 */ -void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void) -{ - TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) ); - - return; -} - -/* Zigbee notification from M0 to M4 */ -void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ) -{ - TL_ZIGBEE_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer) ); - - return; -} - -/* Send an ACK to the M0 for a Notification */ -void TL_ZIGBEE_SendM4AckToM0Notify ( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendM4AckToM0Notify(); - - return; -} - -/* Zigbee M0 to M4 Request */ -void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ) -{ - TL_ZIGBEE_M0RequestReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer) ); - - return; -} - -/* Send an ACK to the M0 for a Request */ -void TL_ZIGBEE_SendM4AckToM0Request(void) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendM4AckToM0Request(); - - return; -} - - -__WEAK void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; -__WEAK void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){}; -#endif - - - /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -683,4 +546,5 @@ __WEAK void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ) (void)(hcievt); } +#endif /* STM32WBxx */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From 4d9fd3129ba4818d3ee4890b5d488c0f374ff81f Mon Sep 17 00:00:00 2001 From: Francois Ramu Date: Thu, 12 Nov 2020 13:21:31 +0100 Subject: [PATCH 11/58] fix: missing IPCC enable for C2 in several examples from stm32CubeWB This fix is coming from https://github.com/STMicroelectronics/STM32CubeWB/issues/19 Signed-off-by: Francois Ramu --- src/utility/STM32Cube_FW/hw_ipcc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c index d1f8b650..658aadb4 100644 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ b/src/utility/STM32Cube_FW/hw_ipcc.c @@ -107,6 +107,12 @@ void IPCC_C1_TX_IRQHandler(void) ******************************************************************************/ void HW_IPCC_Enable( void ) { + /** + * Such as IPCC IP available to the CPU2, it is required to keep the IPCC clock running + when FUS is running on CPU2 and CPU1 enters deep sleep mode + */ + LL_C2_AHB3_GRP1_EnableClock(LL_C2_AHB3_GRP1_PERIPH_IPCC); + /** * When the device is out of standby, it is required to use the EXTI mechanism to wakeup CPU2 */ From 108f46f8eeee221646a87f9823ac58ddec3252f6 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 1 Dec 2021 18:38:39 +0100 Subject: [PATCH 12/58] fix: [-Waddress-of-packed-member] warning Signed-off-by: Frederic Pillon --- src/utility/STM32Cube_FW/stm_list.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utility/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h index 84e22cd7..529eeddb 100644 --- a/src/utility/STM32Cube_FW/stm_list.h +++ b/src/utility/STM32Cube_FW/stm_list.h @@ -20,12 +20,13 @@ #ifndef _STM_LIST_H_ #define _STM_LIST_H_ +#include "stm32_wpan_common.h" /* Includes ------------------------------------------------------------------*/ #include "stdint.h" #include "stdbool.h" -typedef struct _tListNode { +typedef PACKED_STRUCT _tListNode { struct _tListNode * next; struct _tListNode * prev; } tListNode; From 09680e7e3f4b7d04de1c4ef6eb9ab45c734cd8fa Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 1 Dec 2021 18:42:57 +0100 Subject: [PATCH 13/58] fix: include a timeout when waiting for the cmd_resp Signed-off-by: Francois Ramu --- src/utility/STM32Cube_FW/shci_tl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index 27906395..8d4d4ff4 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -21,6 +21,8 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" +#include + #include "stm_list.h" #include "shci_tl.h" #include "stm32_def.h" @@ -346,11 +348,12 @@ static void OutputEvtTrace(TL_EvtPacket_t *phcievtbuffer) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { - (void)timeout; - CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; - while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); - + for (unsigned long start = millis(); (millis() - start) < timeout;) { + if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { + break; + } + } return; } @@ -363,4 +366,4 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } -#endif /* STM32WBxx */ \ No newline at end of file +#endif /* STM32WBxx */ From 14c0f7381f919d618c4a3f98e236bc9f86d7bdfd Mon Sep 17 00:00:00 2001 From: KMeldgaard <36625114+KMeldgaard@users.noreply.github.com> Date: Mon, 15 Nov 2021 14:54:07 +0100 Subject: [PATCH 14/58] Added support for custom app_conf.h (#35) --- README.md | 7 + src/utility/STM32Cube_FW/app_conf.h | 160 ++--------------- src/utility/STM32Cube_FW/app_conf_default.h | 185 ++++++++++++++++++++ 3 files changed, 203 insertions(+), 149 deletions(-) create mode 100644 src/utility/STM32Cube_FW/app_conf_default.h diff --git a/README.md b/README.md index 2fb6e425..3a0691ab 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,13 @@ https://github.com/stm32duino/wiki/wiki/STM32duinoBLE#stm32duinoble-with-x-nucle For more information about ArduinoBLE library please visit the official web page at: https://github.com/arduino-libraries/ArduinoBLE +# Configuration +STM32Cube_WPAN has several configuration options, which are set in the `app_conf.h`. +This package has a default configuration named `app_conf_default.h`. +The user can include the file `app_conf_custom.h` to customize the BLE application. +Options wrapped in `#ifndef`, `#endif` in `app_conf_default.h` can be overwritten. +Additional options can be added. + ## License ``` diff --git a/src/utility/STM32Cube_FW/app_conf.h b/src/utility/STM32Cube_FW/app_conf.h index df081ef1..3246393f 100644 --- a/src/utility/STM32Cube_FW/app_conf.h +++ b/src/utility/STM32Cube_FW/app_conf.h @@ -1,158 +1,20 @@ -/** - ****************************************************************************** - * File Name : app_conf.h - * Description : Application configuration file for STM32WPAN Middleware. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ +//----------------------------- +// @file app_conf.h +// @author Kasper Meldgaard +// @brief Wrapper for BLE app configuration based on comment by fpistm +// (https://github.com/stm32duino/STM32duinoBLE/issues/34). +// @date 15-11-2021 +// @copyright Copyright (c) 2021 -/* Define to prevent recursive inclusion -------------------------------------*/ #ifndef APP_CONF_H #define APP_CONF_H #include "hw.h" #include "ble_bufsize.h" -/****************************************************************************** - * 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 +#if __has_include("app_conf_custom.h") + #include "app_conf_custom.h" #endif -#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 - -/** - * Define Tx Power - */ -#define CFG_TX_POWER (0x18) /* -0.15dBm */ - -/****************************************************************************** - * BLE Stack - ******************************************************************************/ -/** - * Maximum number of simultaneous connections that the device will support. - * Valid values are from 1 to 8 - */ -#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 - */ -#define CFG_BLE_NUM_GATT_SERVICES 8 - -/** - * Maximum number of Attributes - * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) - * that can be stored in the GATT database. - * 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 - -/** - * Maximum supported ATT_MTU size - */ -#define CFG_BLE_MAX_ATT_MTU (156) - -/** - * Size of the storage area for Attribute values - * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: - * - attribute value length - * - 5, if UUID is 16 bit; 19, if UUID is 128 bit - * - 2, if server configuration descriptor is used - * - 2*DTM_NUM_LINK, if client configuration descriptor is used - * - 2, if extended properties is used - * The total amount of memory needed is the sum of the above quantities for each attribute. - */ -#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) - -/** - * Prepare Write List size in terms of number of packet - */ -// #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) - -/** - * Number of allocated memory blocks - */ -// #define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) -#define CFG_BLE_MBLOCK_COUNT (0x79) - -/** - * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. - */ -#define CFG_BLE_DATA_LENGTH_EXTENSION 1 - -/** - * Sleep clock accuracy in Slave mode (ppm value) - */ -#define CFG_BLE_SLAVE_SCA 500 - -/** - * Sleep clock accuracy in Master mode - * 0 : 251 ppm to 500 ppm - * 1 : 151 ppm to 250 ppm - * 2 : 101 ppm to 150 ppm - * 3 : 76 ppm to 100 ppm - * 4 : 51 ppm to 75 ppm - * 5 : 31 ppm to 50 ppm - * 6 : 21 ppm to 30 ppm - * 7 : 0 ppm to 20 ppm - */ -#define CFG_BLE_MASTER_SCA 0 - -/** - * Source for the 32 kHz slow speed clock - * 1 : internal RO - * 0 : external crystal ( no calibration ) - */ -#define CFG_BLE_LSE_SOURCE 0 - -/** - * 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 - -/** - * Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us) - */ -#define CFG_BLE_MAX_CONN_EVENT_LENGTH ( 0xFFFFFFFF ) - -/** - * Viterbi Mode - * 1 : enabled - * 0 : disabled - */ -#define CFG_BLE_VITERBI_MODE 1 - -/** - * LL Only Mode - * 1 : LL Only - * 0 : LL + Host - */ -#define CFG_BLE_LL_ONLY 1 - -#endif /*APP_CONF_H */ +#include "app_conf_default.h" -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +#endif /* APP_CONF_H */ diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h new file mode 100644 index 00000000..e870c321 --- /dev/null +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -0,0 +1,185 @@ +/** + ****************************************************************************** + * File Name : app_conf_default.h + * Description : Default application configuration file for STM32WPAN Middleware. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Ultimate Liberty license + * SLA0044, the "License"; You may not use this file except in compliance with + * the License. You may obtain a copy of the License at: + * www.st.com/SLA0044 + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef APP_CONF_DEFAULT_H +#define APP_CONF_DEFAULT_H + +/****************************************************************************** + * 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 + +/****************************************************************************** + * BLE Stack + ******************************************************************************/ +/** + * Maximum number of simultaneous connections that the device will support. + * Valid values are from 1 to 8 + */ +#ifndef CFG_BLE_NUM_LINK + #define CFG_BLE_NUM_LINK 8 +#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 + */ +#ifndef CFG_BLE_NUM_GATT_SERVICES + #define CFG_BLE_NUM_GATT_SERVICES 8 +#endif + +/** + * Maximum number of Attributes + * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the + * services) that can be stored in the GATT database. 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 + #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#endif + +/** + * Maximum supported ATT_MTU size + */ +#ifndef CFG_BLE_MAX_ATT_MTU + #define CFG_BLE_MAX_ATT_MTU (156) +#endif + +/** + * Size of the storage area for Attribute values + * This value depends on the number of attributes used by application. In particular the sum of the following + * quantities (in octets) should be made for each attribute: + * - attribute value length + * - 5, if UUID is 16 bit; 19, if UUID is 128 bit + * - 2, if server configuration descriptor is used + * - 2*DTM_NUM_LINK, if client configuration descriptor is used + * - 2, if extended properties is used + * The total amount of memory needed is the sum of the above quantities for each attribute. + */ +#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE + #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) +#endif + +/** + * Prepare Write List size in terms of number of packet + */ +//#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE + #define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) +#endif + +/** + * Number of allocated memory blocks + */ +//#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, +// CFG_BLE_NUM_LINK)) +#ifndef CFG_BLE_MBLOCK_COUNT + #define CFG_BLE_MBLOCK_COUNT (0x79) +#endif + +/** + * 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 + +/** + * Sleep clock accuracy in Slave mode (ppm value) + */ +#ifndef CFG_BLE_SLAVE_SCA + #define CFG_BLE_SLAVE_SCA 500 +#endif + +/** + * Sleep clock accuracy in Master mode + * 0 : 251 ppm to 500 ppm + * 1 : 151 ppm to 250 ppm + * 2 : 101 ppm to 150 ppm + * 3 : 76 ppm to 100 ppm + * 4 : 51 ppm to 75 ppm + * 5 : 31 ppm to 50 ppm + * 6 : 21 ppm to 30 ppm + * 7 : 0 ppm to 20 ppm + */ +#ifndef CFG_BLE_MASTER_SCA + #define CFG_BLE_MASTER_SCA 0 +#endif + +/** + * Source for the 32 kHz slow speed clock + * 1 : internal RO + * 0 : external crystal ( no calibration ) + */ +#ifndef CFG_BLE_LSE_SOURCE + #define CFG_BLE_LSE_SOURCE 0 +#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 + +/** + * Maximum duration of the connection event when the device is in Slave 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 + +/** + * Viterbi Mode + * 1 : enabled + * 0 : disabled + */ +#define CFG_BLE_VITERBI_MODE 1 + +/** + * LL Only Mode + * 1 : LL Only + * 0 : LL + Host + */ +#define CFG_BLE_LL_ONLY 1 + +#endif /* APP_CONF_DEFAULT_H */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ From a36ed33ac795f449ec6e46dba9137650490d12c9 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 8 Dec 2021 11:03:29 +0100 Subject: [PATCH 15/58] Update spell-check.yml --- .github/workflows/spell-check.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index 6c44bcfb..f8da452a 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -13,4 +13,5 @@ jobs: - name: Spell check uses: arduino/actions/libraries/spell-check@master with: - skip-paths: ./extras/test \ No newline at end of file + skip-paths: ./extras/test, ./extras/STM32Cube_FW + From 331c39a9580374061464f562f0df92e6a3002eb5 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 8 Dec 2021 11:14:45 +0100 Subject: [PATCH 16/58] Update spell-check.yml --- .github/workflows/spell-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index f8da452a..6fded7ff 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -13,5 +13,5 @@ jobs: - name: Spell check uses: arduino/actions/libraries/spell-check@master with: - skip-paths: ./extras/test, ./extras/STM32Cube_FW + skip-paths: ./extras/test,./extras/STM32Cube_FW From 8ce1025219060f97cdd5575ed3cae1044aedcef4 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Thu, 2 Dec 2021 10:23:30 +0100 Subject: [PATCH 17/58] Add patch files to be applied on stm32wb Cube update Patches correspond to somes commits of PR #38 Signed-off-by: Alexandre Bourdiol --- ...nd-adapt-STM32Cube_FW-sources-for-ST.patch | 1582 +++++++++++++++++ ...imeout-when-waiting-for-the-cmd_resp.patch | 44 + ...ded-support-for-custom-app_conf.h-35.patch | 186 ++ .../0004-Stub-OutputDbgTrace-function.patch | 209 +++ 4 files changed, 2021 insertions(+) create mode 100644 extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch create mode 100644 extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch create mode 100644 extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h-35.patch create mode 100644 extras/STM32Cube_FW/0004-Stub-OutputDbgTrace-function.patch diff --git a/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch b/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch new file mode 100644 index 00000000..3ae29806 --- /dev/null +++ b/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch @@ -0,0 +1,1582 @@ +From 6fcfc029ba21a3674456a12032720bff6ecfe27d Mon Sep 17 00:00:00 2001 +From: Alexandre Bourdiol +Date: Mon, 6 Dec 2021 11:08:32 +0100 +Subject: [PATCH 1/4] chore: clean up and adapt STM32Cube_FW sources for + STM32duino + +Signed-off-by: Frederic Pillon +Signed-off-by: Alexandre Bourdiol +--- + src/utility/STM32Cube_FW/app_conf_default.h | 422 +------------------ + src/utility/STM32Cube_FW/ble_bufsize.h | 13 +- + src/utility/STM32Cube_FW/hw.h | 28 +- + src/utility/STM32Cube_FW/hw_ipcc.c | 184 +------- + src/utility/STM32Cube_FW/mbox_def.h | 34 -- + src/utility/STM32Cube_FW/shci.c | 40 +- + src/utility/STM32Cube_FW/shci.h | 47 +-- + src/utility/STM32Cube_FW/shci_tl.c | 19 +- + src/utility/STM32Cube_FW/stm32_wpan_common.h | 39 +- + src/utility/STM32Cube_FW/stm_list.c | 11 +- + src/utility/STM32Cube_FW/stm_list.h | 4 +- + src/utility/STM32Cube_FW/tl.h | 33 -- + src/utility/STM32Cube_FW/tl_mbox.c | 144 +------ + 13 files changed, 94 insertions(+), 924 deletions(-) + +diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h +index 7ebc65a..4f300e0 100644 +--- a/src/utility/STM32Cube_FW/app_conf_default.h ++++ b/src/utility/STM32Cube_FW/app_conf_default.h +@@ -1,4 +1,3 @@ +-/* USER CODE BEGIN Header */ + /** + ****************************************************************************** + * @file app_conf.h +@@ -16,94 +15,36 @@ + * + ****************************************************************************** + */ +-/* USER CODE END Header */ + + /* Define to prevent recursive inclusion -------------------------------------*/ + #ifndef APP_CONF_H + #define APP_CONF_H + + #include "hw.h" +-#include "hw_conf.h" +-#include "hw_if.h" + #include "ble_bufsize.h" + + /****************************************************************************** + * Application Config + ******************************************************************************/ + +-/** +- * Define Secure Connections Support +- */ +-#define CFG_SECURE_NOT_SUPPORTED (0x00) +-#define CFG_SECURE_OPTIONAL (0x01) +-#define CFG_SECURE_MANDATORY (0x02) +- +-#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL +- +-/** +- * Define Keypress Notification Support +- */ +-#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) +-#define CFG_KEYPRESS_SUPPORTED (0x01) ++/**< generic parameters ******************************************************/ ++/* HCI related defines */ + +-#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED ++#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 + +-/** +- * Numeric Comparison Answers +- */ +-#define YES (0x01) +-#define NO (0x00) +- +-/** +- * Device name configuration for Generic Access Service +- */ +-#define CFG_GAP_DEVICE_NAME "TEMPLATE" +-#define CFG_GAP_DEVICE_NAME_LENGTH (8) +- +-/** +-* Identity root key used to derive LTK and CSRK +-*/ +-#define CFG_BLE_IRK {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0} +- +-/** +-* Encryption root key used to derive LTK and CSRK +-*/ +-#define CFG_BLE_ERK {0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21, 0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21} ++#ifndef BLE_SHARED_MEM_BYTE_ORDER ++ #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST ++#endif ++#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 + + /** +- * SMPS supply +- * SMPS not used when Set to 0 +- * SMPS used when Set to 1 ++ * Define Tx Power + */ +-#define CFG_USE_SMPS 0 +- +-/* USER CODE BEGIN Generic_Parameters */ +-/* USER CODE END Generic_Parameters */ +- +-/**< specific parameters */ +-/*****************************************************/ +- +-/* USER CODE BEGIN Specific_Parameters */ +-#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler +- +-/* USER CODE END Specific_Parameters */ +- +-/****************************************************************************** +- * Information Table +- * +- * Version +- * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version +- * [4:7] = branch - 0: Mass Market - x: ... +- * [8:15] = Subversion +- * [16:23] = Version minor +- * [24:31] = Version major +- * +- ******************************************************************************/ +-#define CFG_FW_MAJOR_VERSION (0) +-#define CFG_FW_MINOR_VERSION (0) +-#define CFG_FW_SUBVERSION (1) +-#define CFG_FW_BRANCH (0) +-#define CFG_FW_BUILD (0) ++#define CFG_TX_POWER (0x18) /* -0.15dBm */ + + /****************************************************************************** + * BLE Stack +@@ -152,13 +93,15 @@ + * Prepare Write List size in terms of number of packet + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" + */ +-#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) ++// #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) ++#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) + + /** + * Number of allocated memory blocks + * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter when CFG_BLE_OPTIONS is set to 1 + */ +-#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) ++// #define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) ++#define CFG_BLE_MBLOCK_COUNT (0x79) + + /** + * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. +@@ -236,7 +179,7 @@ + * 0: LE Power Class 2-3 + * other bits: reserved (shall be set to 0) + */ +-#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_NO_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) ++#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY) + + #define CFG_BLE_MAX_COC_INITIATOR_NBR (32) + +@@ -256,334 +199,5 @@ + + #define CFG_BLE_RX_MODEL_CONFIG SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY + +-/****************************************************************************** +- * Transport Layer +- ******************************************************************************/ +-/** +- * Queue length of BLE Event +- * This parameter defines the number of asynchronous events that can be stored in the HCI layer before +- * being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer +- * is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large +- * enough to store all asynchronous events received in between. +- * When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events +- * between the HCI command and its event. +- * This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small, +- * the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting +- * for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate +- * to the application a HCI command did not receive its command event within 30s (Default HCI Timeout). +- */ +-#define CFG_TLBLE_EVT_QUEUE_LENGTH 5 +-/** +- * This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element +- * allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager. +- * It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will +- * never be used) +- * It shall be at least 4 to receive the command status event in one frame. +- * The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced +- * further depending on the application. +- */ +-#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */ +- +-#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE ) +-/****************************************************************************** +- * UART interfaces +- ******************************************************************************/ +- +-/** +- * Select UART interfaces +- */ +-#define CFG_UART_GUI hw_uart1 +-#define CFG_DEBUG_TRACE_UART 0 +-/****************************************************************************** +- * USB interface +- ******************************************************************************/ +- +-/** +- * Enable/Disable USB interface +- */ +-#define CFG_USB_INTERFACE_ENABLE 0 +- +-/****************************************************************************** +- * IPCC interface +- ******************************************************************************/ +- +-/** +- * The IPCC is dedicated to the communication between the CPU2 and the CPU1 +- * and shall not be modified by the application +- * The two following definitions shall not be modified +- */ +-#define HAL_IPCC_TX_IRQHandler(...) HW_IPCC_Tx_Handler( ) +-#define HAL_IPCC_RX_IRQHandler(...) HW_IPCC_Rx_Handler( ) +- +-/****************************************************************************** +- * Low Power +- ******************************************************************************/ +-/** +- * When set to 1, the low power mode is enable +- * When set to 0, the device stays in RUN mode +- */ +-#define CFG_LPM_SUPPORTED 1 +- +-/****************************************************************************** +- * RTC interface +- ******************************************************************************/ +-#define HAL_RTCEx_WakeUpTimerIRQHandler(...) HW_TS_RTC_Wakeup_Handler( ) +- +-/****************************************************************************** +- * Timer Server +- ******************************************************************************/ +-/** +- * CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer. +- * The lower is the value, the better is the power consumption and the accuracy of the timerserver +- * The higher is the value, the finest is the granularity +- * +- * CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to output +- * clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding +- * the wakeup timer. A lower clock speed would impact the accuracy of the timer server. +- * +- * CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC. +- * When the 1Hz calendar clock is required, it shall be sets according to other settings +- * When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE) +- * +- * CFG_RTCCLK_DIVIDER_CONF: +- * Shall be set to either 0,2,4,8,16 +- * When set to either 2,4,8,16, the 1Hhz calendar is supported +- * When set to 0, the user sets its own configuration +- * +- * The following settings are computed with LSI as input to the RTC +- */ +- +-#define CFG_RTCCLK_DIVIDER_CONF 0 +- +-#if (CFG_RTCCLK_DIVIDER_CONF == 0) +-/** +- * Custom configuration +- * It does not support 1Hz calendar +- * It divides the RTC CLK by 16 +- */ +- +-#define CFG_RTCCLK_DIV (16) +-#define CFG_RTC_WUCKSEL_DIVIDER (0) +-#define CFG_RTC_ASYNCH_PRESCALER (0x0F) +-#define CFG_RTC_SYNCH_PRESCALER (0x7FFF) +- +-#else +- +-#if (CFG_RTCCLK_DIVIDER_CONF == 2) +-/** +- * It divides the RTC CLK by 2 +- */ +-#define CFG_RTC_WUCKSEL_DIVIDER (3) +-#endif +- +-#if (CFG_RTCCLK_DIVIDER_CONF == 4) +-/** +- * It divides the RTC CLK by 4 +- */ +-#define CFG_RTC_WUCKSEL_DIVIDER (2) +-#endif +- +-#if (CFG_RTCCLK_DIVIDER_CONF == 8) +-/** +- * It divides the RTC CLK by 8 +- */ +-#define CFG_RTC_WUCKSEL_DIVIDER (1) +-#endif +- +-#if (CFG_RTCCLK_DIVIDER_CONF == 16) +-/** +- * It divides the RTC CLK by 16 +- */ +-#define CFG_RTC_WUCKSEL_DIVIDER (0) +-#endif +- +-#define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF +-#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) +-#define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 ) +- +-#endif +- +-/** tick timer values */ +-#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE ) +-#define CFG_TS_TICK_VAL_PS DIVR( ((uint64_t)CFG_RTCCLK_DIV * 1e12), (uint64_t)LSE_VALUE ) +- +-typedef enum +-{ +- CFG_TIM_PROC_ID_ISR, +- /* USER CODE BEGIN CFG_TimProcID_t */ +- +- /* USER CODE END CFG_TimProcID_t */ +-} CFG_TimProcID_t; +- +-/****************************************************************************** +- * Debug +- ******************************************************************************/ +-/** +- * When set, this resets some hw resources to set the device in the same state than the power up +- * The FW resets only register that may prevent the FW to run properly +- * +- * This shall be set to 0 in a final product +- * +- */ +-#define CFG_HW_RESET_BY_FW 1 +- +-/** +- * keep debugger enabled while in any low power mode when set to 1 +- * should be set to 0 in production +- */ +-#define CFG_DEBUGGER_SUPPORTED 0 +- +-/** +- * When set to 1, the traces are enabled in the BLE services +- */ +-#define CFG_DEBUG_BLE_TRACE 0 +- +-/** +- * Enable or Disable traces in application +- */ +-#define CFG_DEBUG_APP_TRACE 0 +- +-#if (CFG_DEBUG_APP_TRACE != 0) +-#define APP_DBG_MSG PRINT_MESG_DBG +-#else +-#define APP_DBG_MSG PRINT_NO_MESG +-#endif +- +-#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) ) +-#define CFG_DEBUG_TRACE 1 +-#endif +- +-#if (CFG_DEBUG_TRACE != 0) +-#undef CFG_LPM_SUPPORTED +-#undef CFG_DEBUGGER_SUPPORTED +-#define CFG_LPM_SUPPORTED 0 +-#define CFG_DEBUGGER_SUPPORTED 1 +-#endif +- +-/** +- * When CFG_DEBUG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number +- * When CFG_DEBUG_TRACE_LIGHT is set to 1, only the debug message is output +- * +- * When both are set to 0, no trace are output +- * When both are set to 1, CFG_DEBUG_TRACE_FULL is selected +- */ +-#define CFG_DEBUG_TRACE_LIGHT 0 +-#define CFG_DEBUG_TRACE_FULL 0 +- +-#if (( CFG_DEBUG_TRACE != 0 ) && ( CFG_DEBUG_TRACE_LIGHT == 0 ) && (CFG_DEBUG_TRACE_FULL == 0)) +-#undef CFG_DEBUG_TRACE_FULL +-#undef CFG_DEBUG_TRACE_LIGHT +-#define CFG_DEBUG_TRACE_FULL 0 +-#define CFG_DEBUG_TRACE_LIGHT 1 +-#endif +- +-#if ( CFG_DEBUG_TRACE == 0 ) +-#undef CFG_DEBUG_TRACE_FULL +-#undef CFG_DEBUG_TRACE_LIGHT +-#define CFG_DEBUG_TRACE_FULL 0 +-#define CFG_DEBUG_TRACE_LIGHT 0 +-#endif +- +-/** +- * When not set, the traces is looping on sending the trace over UART +- */ +-#define DBG_TRACE_USE_CIRCULAR_QUEUE 1 +- +-/** +- * max buffer Size to queue data traces and max data trace allowed. +- * Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined +- */ +-#define DBG_TRACE_MSG_QUEUE_SIZE 4096 +-#define MAX_DBG_TRACE_MSG_SIZE 1024 +- +-/* USER CODE BEGIN Defines */ +-#define CFG_LED_SUPPORTED 1 +-#define CFG_BUTTON_SUPPORTED 1 +- +-#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler +-#define PUSH_BUTTON_SW2_EXTI_IRQHandler EXTI0_IRQHandler +-#define PUSH_BUTTON_SW3_EXTI_IRQHandler EXTI1_IRQHandler +-/* USER CODE END Defines */ +- +-/****************************************************************************** +- * Scheduler +- ******************************************************************************/ +- +-/** +- * These are the lists of task id registered to the scheduler +- * Each task id shall be in the range [0:31] +- * This mechanism allows to implement a generic code in the API TL_BLE_HCI_StatusNot() to comply with +- * the requirement that a HCI/ACI command shall never be sent if there is already one pending +- */ +- +-/**< Add in that list all tasks that may send a ACI/HCI command */ +-typedef enum +-{ +- CFG_TASK_BLE_HCI_CMD_ID, +- CFG_TASK_SYS_HCI_CMD_ID, +- CFG_TASK_HCI_ACL_DATA_ID, +- CFG_TASK_SYS_LOCAL_CMD_ID, +- CFG_TASK_TX_TO_HOST_ID, +- /* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */ +- CFG_TASK_SW1_BUTTON_PUSHED_ID, +- CFG_TASK_SW2_BUTTON_PUSHED_ID, +- CFG_TASK_SW3_BUTTON_PUSHED_ID, +- /* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */ +- CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */ +-} CFG_Task_Id_With_HCI_Cmd_t; +- +-/**< Add in that list all tasks that never send a ACI/HCI command */ +-typedef enum +-{ +- CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */ +- CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID, +- /* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */ +- +- /* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */ +- CFG_LAST_TASK_ID_WITHO_NO_HCICMD /**< Shall be LAST in the list */ +-} CFG_Task_Id_With_NO_HCI_Cmd_t; +- +-#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITHO_NO_HCICMD +- +-/** +- * This is the list of priority required by the application +- * Each Id shall be in the range 0..31 +- */ +-typedef enum +-{ +- CFG_SCH_PRIO_0, +- CFG_PRIO_NBR, +-} CFG_SCH_Prio_Id_t; +- +-/** +- * This is a bit mapping over 32bits listing all events id supported in the application +- */ +-typedef enum +-{ +- CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID, +-} CFG_IdleEvt_Id_t; +- +-/****************************************************************************** +- * LOW POWER +- ******************************************************************************/ +-/** +- * Supported requester to the MCU Low Power Manager - can be increased up to 32 +- * It list a bit mapping of all user of the Low Power Manager +- */ +-typedef enum +-{ +- CFG_LPM_APP, +- CFG_LPM_APP_BLE, +- /* USER CODE BEGIN CFG_LPM_Id_t */ +- +- /* USER CODE END CFG_LPM_Id_t */ +-} CFG_LPM_Id_t; +- +-/****************************************************************************** +- * OTP manager +- ******************************************************************************/ +-#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE +- +-#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR + + #endif /*APP_CONF_H */ +diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h +index ba9c4d3..73b7887 100644 +--- a/src/utility/STM32Cube_FW/ble_bufsize.h ++++ b/src/utility/STM32Cube_FW/ble_bufsize.h +@@ -75,17 +75,24 @@ + ((pw) + MAX(BLE_MEM_BLOCK_X_MTU(mtu, n_link), \ + BLE_MBLOCKS_SECURE_CONNECTIONS)) + ++/* ++ * BLE_DEFAULT_MBLOCKS_COUNT: default memory blocks count ++ */ ++#define BLE_DEFAULT_MBLOCKS_COUNT(n_link) \ ++ BLE_MBLOCKS_CALC(BLE_DEFAULT_PREP_WRITE_LIST_SIZE, \ ++ BLE_DEFAULT_MAX_ATT_MTU, n_link) ++ + /* + * BLE_FIXED_BUFFER_SIZE_BYTES: +- * A part of the RAM, is dinamically allocated by initilizing all the pointers ++ * A part of the RAM, is dynamically allocated by initializing all the pointers + * defined in a global context variable "mem_alloc_ctx_p". + * This initialization is made in the Dynamic_allocator functions, which +- * assing a portion of RAM given by the external application to the above ++ * assign a portion of RAM given by the external application to the above + * mentioned "global pointers". + * + * The size of this Dynamic RAM is made of 2 main components: + * - a part that is parameters-dependent (num of links, GATT buffers, ...), +- * and which value is explicited by the following macro; ++ * and which value is defined by the following macro; + * - a part, that may be considered "fixed", i.e. independent from the above + * mentioned parameters. + */ +diff --git a/src/utility/STM32Cube_FW/hw.h b/src/utility/STM32Cube_FW/hw.h +index 503fa2c..fcf0451 100644 +--- a/src/utility/STM32Cube_FW/hw.h ++++ b/src/utility/STM32Cube_FW/hw.h +@@ -26,14 +26,21 @@ 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 ); + + void HW_IPCC_BLE_Init( void ); + void HW_IPCC_BLE_SendCmd( void ); +@@ -80,23 +87,6 @@ extern "C" { + void HW_IPCC_TRACES_Init( void ); + void HW_IPCC_TRACES_EvtNot( void ); + +- void HW_IPCC_MAC_802_15_4_Init( void ); +- void HW_IPCC_MAC_802_15_4_SendCmd( void ); +- void HW_IPCC_MAC_802_15_4_SendAck( void ); +- void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ); +- void HW_IPCC_MAC_802_15_4_EvtNot( void ); +- +- void HW_IPCC_ZIGBEE_Init( void ); +- +- void HW_IPCC_ZIGBEE_SendM4RequestToM0(void); /* M4 Request to M0 */ +- void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void); /* Request ACK from M0 */ +- +- void HW_IPCC_ZIGBEE_RecvM0NotifyToM4(void); /* M0 Notify to M4 */ +- void HW_IPCC_ZIGBEE_SendM4AckToM0Notify(void); /* Notify ACK from M4 */ +- void HW_IPCC_ZIGBEE_RecvM0RequestToM4(void); /* M0 Request to M4 */ +- void HW_IPCC_ZIGBEE_SendM4AckToM0Request(void); /* Request ACK from M4 */ +- +- + #ifdef __cplusplus + } + #endif +diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c +index c5a941d..2f4f6cc 100644 +--- a/src/utility/STM32Cube_FW/hw_ipcc.c ++++ b/src/utility/STM32Cube_FW/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 ---------------------------------------------------------*/ +@@ -56,34 +57,17 @@ static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ); + static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void ); + #endif + +-#ifdef MAC_802_15_4_WB +-static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ); +-static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ); +-#endif +- +-#ifdef ZIGBEE_WB +-static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ); +-static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ); +-static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ); +-#endif +- + /* Public function definition -----------------------------------------------*/ + + /****************************************************************************** + * INTERRUPT HANDLER + ******************************************************************************/ +-void HW_IPCC_Rx_Handler( void ) ++void IPCC_C1_RX_IRQHandler(void) + { + if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL )) + { + HW_IPCC_SYS_EvtHandler(); + } +-#ifdef MAC_802_15_4_WB +- else if (HW_IPCC_RX_PENDING( HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL )) +- { +- HW_IPCC_MAC_802_15_4_NotEvtHandler(); +- } +-#endif /* MAC_802_15_4_WB */ + #ifdef THREAD_WB + else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL )) + { +@@ -114,16 +98,6 @@ void HW_IPCC_Rx_Handler( void ) + HW_IPCC_LLD_BLE_ReceiveM0CmdHandler(); + } + #endif /* LLD_TESTS_WB */ +-#ifdef ZIGBEE_WB +- else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL )) +- { +- HW_IPCC_ZIGBEE_StackNotifEvtHandler(); +- } +- else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL )) +- { +- HW_IPCC_ZIGBEE_StackM0RequestHandler(); +- } +-#endif /* ZIGBEE_WB */ + else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL )) + { + HW_IPCC_BLE_EvtHandler(); +@@ -132,22 +106,14 @@ void HW_IPCC_Rx_Handler( void ) + { + HW_IPCC_TRACES_EvtHandler(); + } +- +- return; + } + +-void HW_IPCC_Tx_Handler( void ) ++void IPCC_C1_TX_IRQHandler(void) + { + if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) + { + HW_IPCC_SYS_CmdEvtHandler(); + } +-#ifdef MAC_802_15_4_WB +- else if (HW_IPCC_TX_PENDING( HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL )) +- { +- HW_IPCC_MAC_802_15_4_CmdEvtHandler(); +- } +-#endif /* MAC_802_15_4_WB */ + #ifdef THREAD_WB + else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) + { +@@ -157,12 +123,6 @@ void HW_IPCC_Tx_Handler( void ) + #ifdef LLD_TESTS_WB + // No TX handler for LLD tests + #endif /* LLD_TESTS_WB */ +-#ifdef ZIGBEE_WB +- if (HW_IPCC_TX_PENDING( HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL )) +- { +- HW_IPCC_ZIGBEE_CmdEvtHandler(); +- } +-#endif /* ZIGBEE_WB */ + else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL )) + { + HW_IPCC_MM_FreeBufHandler(); +@@ -171,9 +131,8 @@ void HW_IPCC_Tx_Handler( void ) + { + HW_IPCC_BLE_AclDataEvtHandler(); + } +- +- return; + } ++ + /****************************************************************************** + * GENERAL + ******************************************************************************/ +@@ -263,8 +222,8 @@ static void HW_IPCC_BLE_AclDataEvtHandler( void ) + return; + } + +-__weak void HW_IPCC_BLE_AclDataAckNot( void ){}; +-__weak void HW_IPCC_BLE_RxEvtNot( void ){}; ++__WEAK void HW_IPCC_BLE_AclDataAckNot( void ){}; ++__WEAK void HW_IPCC_BLE_RxEvtNot( void ){}; + + /****************************************************************************** + * SYSTEM +@@ -302,56 +261,8 @@ static void HW_IPCC_SYS_EvtHandler( void ) + return; + } + +-__weak void HW_IPCC_SYS_CmdEvtNot( void ){}; +-__weak void HW_IPCC_SYS_EvtNot( void ){}; +- +-/****************************************************************************** +- * MAC 802.15.4 +- ******************************************************************************/ +-#ifdef MAC_802_15_4_WB +-void HW_IPCC_MAC_802_15_4_Init( void ) +-{ +- LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); +- +- return; +-} +- +-void HW_IPCC_MAC_802_15_4_SendCmd( void ) +-{ +- LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); +- LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); +- +- return; +-} +- +-void HW_IPCC_MAC_802_15_4_SendAck( void ) +-{ +- LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); +- LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); +- +- return; +-} +- +-static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ) +-{ +- LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); +- +- HW_IPCC_MAC_802_15_4_CmdEvtNot(); +- +- return; +-} +- +-static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ) +-{ +- LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); +- +- HW_IPCC_MAC_802_15_4_EvtNot(); +- +- return; +-} +-__weak void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ){}; +-__weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){}; +-#endif ++__WEAK void HW_IPCC_SYS_CmdEvtNot( void ){}; ++__WEAK void HW_IPCC_SYS_EvtNot( void ){}; + + /****************************************************************************** + * THREAD +@@ -423,9 +334,9 @@ static void HW_IPCC_THREAD_CliNotEvtHandler( void ) + return; + } + +-__weak void HW_IPCC_OT_CmdEvtNot( void ){}; +-__weak void HW_IPCC_CLI_CmdEvtNot( void ){}; +-__weak void HW_IPCC_THREAD_EvtNot( void ){}; ++__WEAK void HW_IPCC_OT_CmdEvtNot( void ){}; ++__WEAK void HW_IPCC_CLI_CmdEvtNot( void ){}; ++__WEAK void HW_IPCC_THREAD_EvtNot( void ){}; + + #endif /* THREAD_WB */ + +@@ -547,74 +458,6 @@ void HW_IPCC_LLD_BLE_SendRspAck( void ) + + #endif /* LLD_BLE_WB */ + +-/****************************************************************************** +- * ZIGBEE +- ******************************************************************************/ +-#ifdef ZIGBEE_WB +-void HW_IPCC_ZIGBEE_Init( void ) +-{ +- LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); +- LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); +- +- return; +-} +- +-void HW_IPCC_ZIGBEE_SendM4RequestToM0( void ) +-{ +- LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); +- LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); +- +- return; +-} +- +-void HW_IPCC_ZIGBEE_SendM4AckToM0Notify( void ) +-{ +- LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); +- LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); +- +- return; +-} +- +-static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ) +-{ +- LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); +- +- HW_IPCC_ZIGBEE_RecvAppliAckFromM0(); +- +- return; +-} +- +-static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ) +-{ +- LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); +- +- HW_IPCC_ZIGBEE_RecvM0NotifyToM4(); +- +- return; +-} +- +-static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ) +-{ +- LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); +- +- HW_IPCC_ZIGBEE_RecvM0RequestToM4(); +- +- return; +-} +- +-void HW_IPCC_ZIGBEE_SendM4AckToM0Request( void ) +-{ +- LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); +- LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); +- +- return; +-} +- +-__weak void HW_IPCC_ZIGBEE_RecvAppliAckFromM0( void ){}; +-__weak void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ){}; +-__weak void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ){}; +-#endif /* ZIGBEE_WB */ +- + /****************************************************************************** + * MEMORY MANAGER + ******************************************************************************/ +@@ -665,4 +508,5 @@ static void HW_IPCC_TRACES_EvtHandler( void ) + return; + } + +-__weak void HW_IPCC_TRACES_EvtNot( void ){}; ++__WEAK void HW_IPCC_TRACES_EvtNot( void ){}; ++#endif /* STM32WBxx */ +diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h +index 06536d3..c898e52 100644 +--- a/src/utility/STM32Cube_FW/mbox_def.h ++++ b/src/utility/STM32Cube_FW/mbox_def.h +@@ -105,12 +105,6 @@ extern "C" { + uint8_t *m0cmd_buffer; + } MB_BleLldTable_t; + +- typedef struct +- { +- uint8_t *notifM0toM4_buffer; +- uint8_t *appliCmdM4toM0_buffer; +- uint8_t *requestM0toM4_buffer; +- } MB_ZigbeeTable_t; + /** + * msg + * [0:7] = cmd/evt +@@ -138,13 +132,6 @@ extern "C" { + uint8_t *traces_queue; + } MB_TracesTable_t; + +- typedef struct +- { +- uint8_t *p_cmdrsp_buffer; +- uint8_t *p_notack_buffer; +- uint8_t *evt_queue; +- } MB_Mac_802_15_4_t; +- + typedef struct + { + MB_DeviceInfoTable_t *p_device_info_table; +@@ -153,8 +140,6 @@ extern "C" { + MB_SysTable_t *p_sys_table; + MB_MemManagerTable_t *p_mem_manager_table; + MB_TracesTable_t *p_traces_table; +- MB_Mac_802_15_4_t *p_mac_802_15_4_table; +- MB_ZigbeeTable_t *p_zigbee_table; + MB_LldTestsTable_t *p_lld_tests_table; + MB_BleLldTable_t *p_ble_lld_table; + } MB_RefTable_t; +@@ -198,15 +183,6 @@ typedef struct + * | | + * |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------| + * | | +- * | (ZIGBEE) | +- * |----HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL------------>| +- * | | +- * |----HW_IPCC_ZIGBEE_CMD_CLI_CHANNEL-------------->| +- * | | +- * |<---HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL-------| +- * | | +- * |<---HW_IPCC_ZIGBEE_CLI_NOTIF_ACK_CHANNEL---------| +- * | | + * | (THREAD) | + * |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->| + * | | +@@ -230,11 +206,6 @@ typedef struct + * | | + * |<---HW_IPCC_BLE_LLD_M0_CMD_CHANNEL---------------| + * | | +- * | (MAC) | +- * |----HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL-------->| +- * | | +- * |<---HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL| +- * | | + * | (BUFFER) | + * |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>| + * | | +@@ -252,8 +223,6 @@ typedef struct + #define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1 + #define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2 + #define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 +-#define HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL LL_IPCC_CHANNEL_3 +-#define HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 + #define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4 + #define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 + #define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 +@@ -265,8 +234,6 @@ typedef struct + #define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1 + #define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2 + #define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 +-#define HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL LL_IPCC_CHANNEL_3 +-#define HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 + #define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 + #define HW_IPCC_BLE_LLD_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 + #define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4 +@@ -274,6 +241,5 @@ typedef struct + #define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 + #define HW_IPCC_BLE_LLD_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 + #define HW_IPCC_BLE_LLD_RSP_CHANNEL LL_IPCC_CHANNEL_5 +-#define HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL LL_IPCC_CHANNEL_5 + #endif /*__MBOX_H */ + +diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c +index 301db76..bd7bb3a 100644 +--- a/src/utility/STM32Cube_FW/shci.c ++++ b/src/utility/STM32Cube_FW/shci.c +@@ -16,7 +16,7 @@ + ****************************************************************************** + */ + +- ++#if defined(STM32WBxx) + /* Includes ------------------------------------------------------------------*/ + #include "stm32_wpan_common.h" + +@@ -352,24 +352,6 @@ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ) + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); + } + +-SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ) +-{ +- /** +- * Buffer is large enough to hold command complete without payload +- */ +- uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; +- TL_EvtPacket_t * p_rsp; +- +- p_rsp = (TL_EvtPacket_t *)local_buffer; +- +- shci_send( SHCI_OPCODE_C2_ZIGBEE_INIT, +- 0, +- 0, +- p_rsp ); +- +- return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +-} +- + SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ) + { + /** +@@ -527,24 +509,6 @@ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t Fla + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); + } + +-SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ) +-{ +- /** +- * Buffer is large enough to hold command complete without payload +- */ +- uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; +- TL_EvtPacket_t * p_rsp; +- +- p_rsp = (TL_EvtPacket_t *)local_buffer; +- +- shci_send( SHCI_OPCODE_C2_MAC_802_15_4_INIT, +- 0, +- 0, +- p_rsp ); +- +- return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +-} +- + SHCI_CmdStatus_t SHCI_C2_Reinit( void ) + { + /** +@@ -739,3 +703,5 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) + + return (SHCI_Success); + } ++#endif /* STM32WBxx */ ++ +diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h +index c08f056..9449c22 100644 +--- a/src/utility/STM32Cube_FW/shci.h ++++ b/src/utility/STM32Cube_FW/shci.h +@@ -49,7 +49,6 @@ extern "C" { + ERR_BLE_INIT = 0, /* This event is currently not reported by the CPU2 */ + ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ + ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the CPU1 to control the Thread stack is unknown */ +- ERR_ZIGBEE_UNKNOWN_CMD = 200, /* The command send by the CPU1 to control the Zigbee stack is unknown */ + } SCHI_SystemErrCode_t; + + #define SHCI_EVTCODE ( 0xFF ) +@@ -102,7 +101,7 @@ extern "C" { + + /** + * SHCI_SUB_EVT_THREAD_NVM_RAM_UPDATE +- * This notifies the CPU1 which part of the OT NVM RAM has been updated so that only the modified ++ * This notifies the CPU1 which part of the 'OT NVM RAM' has been updated so that only the modified + * section could be written in Flash/NVM + * StartAddress : Start address of the section that has been modified + * Size : Size (in bytes) of the section that has been modified +@@ -214,9 +213,7 @@ extern "C" { + SHCI_OCF_C2_FLASH_STORE_DATA, + SHCI_OCF_C2_FLASH_ERASE_DATA, + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, +- SHCI_OCF_C2_MAC_802_15_4_INIT, + SHCI_OCF_C2_REINIT, +- SHCI_OCF_C2_ZIGBEE_INIT, + SHCI_OCF_C2_LLD_TESTS_INIT, + SHCI_OCF_C2_EXTPA_CONFIG, + SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, +@@ -614,8 +611,6 @@ extern "C" { + { + uint8_t thread_config; + uint8_t ble_config; +- uint8_t mac_802_15_4_config; +- uint8_t zigbee_config; + } SHCI_C2_DEBUG_TracesConfig_t; + + typedef PACKED_STRUCT +@@ -674,8 +669,6 @@ extern "C" { + { + BLE_ENABLE, + THREAD_ENABLE, +- ZIGBEE_ENABLE, +- MAC_ENABLE, + } SHCI_C2_CONCURRENT_Mode_Param_t; + /** No response parameters*/ + +@@ -698,18 +691,13 @@ extern "C" { + { + BLE_IP, + THREAD_IP, +- ZIGBEE_IP, + } SHCI_C2_FLASH_Ip_t; + /** No response parameters*/ + + #define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) + +-#define SHCI_OPCODE_C2_MAC_802_15_4_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_MAC_802_15_4_INIT) +- + #define SHCI_OPCODE_C2_REINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_REINIT) + +-#define SHCI_OPCODE_C2_ZIGBEE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_ZIGBEE_INIT) +- + #define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) + + #define SHCI_OPCODE_C2_BLE_LLD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_LLD_INIT) +@@ -817,7 +805,7 @@ extern "C" { + #define FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD (0xA94656B9) + + /* +- * At startup, the informations relative to the wireless binary are stored in RAM trough a structure defined by ++ * At startup, the information relative to the wireless binary are stored in RAM through a structure defined by + * MB_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) + * each of those coded on 32 bits as shown on the table below: + * +@@ -870,9 +858,6 @@ extern "C" { + #define INFO_STACK_TYPE_BLE_BEACON 0x04 + #define INFO_STACK_TYPE_THREAD_FTD 0x10 + #define INFO_STACK_TYPE_THREAD_MTD 0x11 +-#define INFO_STACK_TYPE_ZIGBEE_FFD 0x30 +-#define INFO_STACK_TYPE_ZIGBEE_RFD 0x31 +-#define INFO_STACK_TYPE_MAC 0x40 + #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 + #define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 + #define INFO_STACK_TYPE_802154_LLD_TESTS 0x60 +@@ -881,12 +866,7 @@ extern "C" { + #define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 + #define INFO_STACK_TYPE_BLE_RLV 0x64 + #define INFO_STACK_TYPE_802154_RLV 0x65 +-#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_STATIC 0x70 +-#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_STATIC 0x71 +-#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_DYNAMIC 0x78 +-#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_DYNAMIC 0x79 + #define INFO_STACK_TYPE_RLV 0x80 +-#define INFO_STACK_TYPE_BLE_MAC_STATIC 0x90 + + typedef struct { + /** +@@ -1060,7 +1040,7 @@ typedef struct { + * @brief Starts the LLD tests CLI + * + * @param param_size : Nb of bytes +- * @param p_param : pointeur with data to give from M4 to M0 ++ * @param p_param : pointer with data to give from M4 to M0 + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ); +@@ -1070,19 +1050,10 @@ typedef struct { + * @brief Starts the LLD tests BLE + * + * @param param_size : Nb of bytes +- * @param p_param : pointeur with data to give from M4 to M0 ++ * @param p_param : pointer with data to give from M4 to M0 + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ); +- +- /** +- * SHCI_C2_ZIGBEE_Init +- * @brief Starts the Zigbee Stack +- * +- * @param None +- * @retval Status +- */ +- SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ); + + /** + * SHCI_C2_DEBUG_Init +@@ -1158,16 +1129,6 @@ typedef struct { + */ + SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn); + +- +- /** +- * SHCI_C2_MAC_802_15_4_Init +- * @brief Starts the MAC 802.15.4 on M0 +- * +- * @param None +- * @retval Status +- */ +- SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ); +- + /** + * SHCI_GetWirelessFwInfo + * @brief This function read back the informations relative to the wireless binary loaded. +diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c +index 449b8b1..ef403aa 100644 +--- a/src/utility/STM32Cube_FW/shci_tl.c ++++ b/src/utility/STM32Cube_FW/shci_tl.c +@@ -16,12 +16,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 +169,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 ) + { +@@ -252,3 +267,5 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) + return; + } + ++#endif /* STM32WBxx */ ++ +diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h +index b47b804..5a2b2a5 100644 +--- a/src/utility/STM32Cube_FW/stm32_wpan_common.h ++++ b/src/utility/STM32Cube_FW/stm32_wpan_common.h +@@ -25,19 +25,9 @@ + extern "C" { + #endif + +-#if defined ( __CC_ARM ) +- #define __ASM __asm /*!< asm keyword for ARM Compiler */ +- #define __INLINE __inline /*!< inline keyword for ARM Compiler */ +- #define __STATIC_INLINE static __inline +-#elif defined ( __ICCARM__ ) +- #define __ASM __asm /*!< asm keyword for IAR Compiler */ +- #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ +- #define __STATIC_INLINE static inline +-#elif defined ( __GNUC__ ) +- #define __ASM __asm /*!< asm keyword for GNU Compiler */ +- #define __INLINE inline /*!< inline keyword for GNU Compiler */ +- #define __STATIC_INLINE static inline +-#endif ++#define __ASM __asm /*!< asm keyword for GNU Compiler */ ++#define __INLINE inline /*!< inline keyword for GNU Compiler */ ++#define __STATIC_INLINE static inline + + #include + #include +@@ -140,29 +130,8 @@ extern "C" { + /* ----------------------------------- * + * Packed usage (compiler dependent) * + * ----------------------------------- */ +-#undef PACKED__ + #undef PACKED_STRUCT +- +-#if defined ( __CC_ARM ) +- #if defined ( __GNUC__ ) +- /* GNU extension */ +- #define PACKED__ __attribute__((packed)) +- #define PACKED_STRUCT struct PACKED__ +- #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050U) +- #define PACKED__ __attribute__((packed)) +- #define PACKED_STRUCT struct PACKED__ +- #else +- #define PACKED__(TYPE) __packed TYPE +- #define PACKED_STRUCT PACKED__(struct) +- #endif +-#elif defined ( __GNUC__ ) +- #define PACKED__ __attribute__((packed)) +- #define PACKED_STRUCT struct PACKED__ +-#elif defined (__ICCARM__) +- #define PACKED_STRUCT __packed struct +-#else +- #define PACKED_STRUCT __packed struct +-#endif ++#define PACKED_STRUCT struct __packed + + #ifdef __cplusplus + } +diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c +index 69c8c06..3dea751 100644 +--- a/src/utility/STM32Cube_FW/stm_list.c ++++ b/src/utility/STM32Cube_FW/stm_list.c +@@ -16,13 +16,13 @@ + ****************************************************************************** + */ + +- ++#if defined(STM32WBxx) + /****************************************************************************** + * Include Files + ******************************************************************************/ +-#include "utilities_common.h" +- + #include "stm_list.h" ++#include "cmsis_gcc.h" ++#include "stm32_wpan_common.h" + + /****************************************************************************** + * Function Definitions +@@ -33,10 +33,10 @@ void LST_init_head (tListNode * listHead) + listHead->prev = listHead; + } + +-uint8_t LST_is_empty (tListNode * listHead) ++bool LST_is_empty (tListNode * listHead) + { + uint32_t primask_bit; +- uint8_t return_value; ++ bool return_value; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ +@@ -205,3 +205,4 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ + } + ++#endif /* STM32WBxx */ +\ No newline at end of file +diff --git a/src/utility/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h +index b7c3254..769c211 100644 +--- a/src/utility/STM32Cube_FW/stm_list.h ++++ b/src/utility/STM32Cube_FW/stm_list.h +@@ -21,6 +21,8 @@ + #define _STM_LIST_H_ + + /* Includes ------------------------------------------------------------------*/ ++#include "stdint.h" ++#include "stdbool.h" + #include "stm32_wpan_common.h" + + typedef PACKED_STRUCT _tListNode { +@@ -30,7 +32,7 @@ typedef PACKED_STRUCT _tListNode { + + void LST_init_head (tListNode * listHead); + +-uint8_t LST_is_empty (tListNode * listHead); ++bool LST_is_empty (tListNode * listHead); + + void LST_insert_head (tListNode * listHead, tListNode * node); + +diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h +index cb27246..16de7f1 100644 +--- a/src/utility/STM32Cube_FW/tl.h ++++ b/src/utility/STM32Cube_FW/tl.h +@@ -198,19 +198,6 @@ typedef struct + uint8_t *p_BleLldM0CmdBuffer; + } TL_BLE_LLD_Config_t; + +-typedef struct +-{ +- uint8_t *p_Mac_802_15_4_CmdRspBuffer; +- uint8_t *p_Mac_802_15_4_NotAckBuffer; +-} TL_MAC_802_15_4_Config_t; +- +-typedef struct +-{ +- uint8_t *p_ZigbeeOtCmdRspBuffer; +- uint8_t *p_ZigbeeNotAckBuffer; +- uint8_t *p_ZigbeeNotifRequestBuffer; +-} TL_ZIGBEE_Config_t; +- + /** + * @brief Contain the BLE HCI Init Configuration + * @{ +@@ -304,26 +291,6 @@ void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); + void TL_TRACES_Init( void ); + void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ); + +-/****************************************************************************** +- * MAC 802.15.4 +- ******************************************************************************/ +-void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ); +-void TL_MAC_802_15_4_SendCmd( void ); +-void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); +-void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ); +-void TL_MAC_802_15_4_SendAck ( void ); +- +-/****************************************************************************** +- * ZIGBEE +- ******************************************************************************/ +-void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ); +-void TL_ZIGBEE_SendM4RequestToM0( void ); +-void TL_ZIGBEE_SendM4AckToM0Notify ( void ); +-void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ); +-void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); +-void TL_ZIGBEE_M0RequestReceived(TL_EvtPacket_t * Otbuffer ); +-void TL_ZIGBEE_SendM4AckToM0Request(void); +- + #ifdef __cplusplus + } /* extern "C" */ + #endif +diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c +index 148bcb1..709f5d2 100644 +--- a/src/utility/STM32Cube_FW/tl_mbox.c ++++ b/src/utility/STM32Cube_FW/tl_mbox.c +@@ -16,6 +16,7 @@ + ****************************************************************************** + */ + ++#if defined(STM32WBxx) + /* Includes ------------------------------------------------------------------*/ + #include "stm32_wpan_common.h" + #include "hw.h" +@@ -51,15 +52,13 @@ 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; +-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; + + /**< tables */ + PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; + PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue; + PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)]; +-PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode EvtQueue; +-PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode SystemEvtQueue; ++PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode EvtQueue; ++PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode SystemEvtQueue; + + + static tListNode LocalFreeBufQueue; +@@ -97,8 +96,6 @@ 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; +- TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; +- TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; + HW_IPCC_Init(); + + return; +@@ -451,139 +448,6 @@ void TL_BLE_LLD_SendRspAck( void ) + } + #endif /* BLE_LLD_WB */ + +-#ifdef MAC_802_15_4_WB +-/****************************************************************************** +- * MAC 802.15.4 +- ******************************************************************************/ +-void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ) +-{ +- MB_Mac_802_15_4_t * p_mac_802_15_4_table; +- +- p_mac_802_15_4_table = TL_RefTable.p_mac_802_15_4_table; +- +- p_mac_802_15_4_table->p_cmdrsp_buffer = p_Config->p_Mac_802_15_4_CmdRspBuffer; +- p_mac_802_15_4_table->p_notack_buffer = p_Config->p_Mac_802_15_4_NotAckBuffer; +- +- HW_IPCC_MAC_802_15_4_Init(); +- +- return; +-} +- +-void TL_MAC_802_15_4_SendCmd( void ) +-{ +- ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; +- +- HW_IPCC_MAC_802_15_4_SendCmd(); +- +- return; +-} +- +-void TL_MAC_802_15_4_SendAck ( void ) +-{ +- ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; +- +- HW_IPCC_MAC_802_15_4_SendAck(); +- +- return; +-} +- +-void HW_IPCC_MAC_802_15_4_CmdEvtNot(void) +-{ +- TL_MAC_802_15_4_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer) ); +- +- return; +-} +- +-void HW_IPCC_MAC_802_15_4_EvtNot( void ) +-{ +- TL_MAC_802_15_4_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer) ); +- +- return; +-} +- +-__WEAK void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; +-__WEAK void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){}; +-#endif +- +-#ifdef ZIGBEE_WB +-/****************************************************************************** +- * ZIGBEE +- ******************************************************************************/ +-void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ) +-{ +- MB_ZigbeeTable_t * p_zigbee_table; +- +- p_zigbee_table = TL_RefTable.p_zigbee_table; +- p_zigbee_table->appliCmdM4toM0_buffer = p_Config->p_ZigbeeOtCmdRspBuffer; +- p_zigbee_table->notifM0toM4_buffer = p_Config->p_ZigbeeNotAckBuffer; +- p_zigbee_table->requestM0toM4_buffer = p_Config->p_ZigbeeNotifRequestBuffer; +- +- HW_IPCC_ZIGBEE_Init(); +- +- return; +-} +- +-/* Zigbee M4 to M0 Request */ +-void TL_ZIGBEE_SendM4RequestToM0( void ) +-{ +- ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; +- +- HW_IPCC_ZIGBEE_SendM4RequestToM0(); +- +- return; +-} +- +-/* Used to receive an ACK from the M0 */ +-void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void) +-{ +- TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) ); +- +- return; +-} +- +-/* Zigbee notification from M0 to M4 */ +-void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ) +-{ +- TL_ZIGBEE_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer) ); +- +- return; +-} +- +-/* Send an ACK to the M0 for a Notification */ +-void TL_ZIGBEE_SendM4AckToM0Notify ( void ) +-{ +- ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; +- +- HW_IPCC_ZIGBEE_SendM4AckToM0Notify(); +- +- return; +-} +- +-/* Zigbee M0 to M4 Request */ +-void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ) +-{ +- TL_ZIGBEE_M0RequestReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer) ); +- +- return; +-} +- +-/* Send an ACK to the M0 for a Request */ +-void TL_ZIGBEE_SendM4AckToM0Request(void) +-{ +- ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; +- +- HW_IPCC_ZIGBEE_SendM4AckToM0Request(); +- +- return; +-} +- +- +-__WEAK void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; +-__WEAK void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){}; +-#endif +- +- +- + /****************************************************************************** + * MEMORY MANAGER + ******************************************************************************/ +@@ -845,3 +709,5 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) + + return; + } ++ ++#endif /* STM32WBxx */ +-- +2.31.1.windows.1 + diff --git a/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch b/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch new file mode 100644 index 00000000..c4a83d6e --- /dev/null +++ b/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch @@ -0,0 +1,44 @@ +From ac18897f0f9b87bb3196efb93ef47ccaaa0eff64 Mon Sep 17 00:00:00 2001 +From: Alexandre Bourdiol +Date: Mon, 6 Dec 2021 11:18:02 +0100 +Subject: [PATCH 2/4] fix: include a timeout when waiting for the cmd_resp + +Signed-off-by: Francois Ramu +Signed-off-by: Alexandre Bourdiol +--- + src/utility/STM32Cube_FW/shci_tl.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c +index ef403aa..6cccc5d 100644 +--- a/src/utility/STM32Cube_FW/shci_tl.c ++++ b/src/utility/STM32Cube_FW/shci_tl.c +@@ -20,6 +20,8 @@ + /* Includes ------------------------------------------------------------------*/ + #include "stm32_wpan_common.h" + ++#include ++ + #include "stm_list.h" + #include "shci_tl.h" + #include "stm32_def.h" +@@ -250,11 +252,12 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) + /* Weak implementation ----------------------------------------------------------------*/ + __WEAK void shci_cmd_resp_wait(uint32_t timeout) + { +- (void)timeout; +- + CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; +- while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); +- ++ for (unsigned long start = millis(); (millis() - start) < timeout;) { ++ if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { ++ break; ++ } ++ } + return; + } + +-- +2.31.1.windows.1 + diff --git a/extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h-35.patch b/extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h-35.patch new file mode 100644 index 00000000..268523d5 --- /dev/null +++ b/extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h-35.patch @@ -0,0 +1,186 @@ +From a771c9e9a12d085fc240a45f68ca5aafb8b42006 Mon Sep 17 00:00:00 2001 +From: Alexandre Bourdiol +Date: Mon, 6 Dec 2021 18:59:38 +0100 +Subject: [PATCH 3/4] Added support for custom app_conf.h (#35) + +--- + src/utility/STM32Cube_FW/app_conf_default.h | 75 ++++++++++++++------- + 1 file changed, 49 insertions(+), 26 deletions(-) + +diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h +index 4f300e0..9f8e085 100644 +--- a/src/utility/STM32Cube_FW/app_conf_default.h ++++ b/src/utility/STM32Cube_FW/app_conf_default.h +@@ -1,8 +1,8 @@ + /** + ****************************************************************************** +- * @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 + * +@@ -17,11 +17,8 @@ + */ + + /* Define to prevent recursive inclusion -------------------------------------*/ +-#ifndef APP_CONF_H +-#define APP_CONF_H +- +-#include "hw.h" +-#include "ble_bufsize.h" ++#ifndef APP_CONF_DEFAULT_H ++#define APP_CONF_DEFAULT_H + + /****************************************************************************** + * Application Config +@@ -44,7 +41,9 @@ + /** + * Define Tx Power + */ +-#define CFG_TX_POWER (0x18) /* -0.15dBm */ ++#ifndef CFG_TX_POWER ++ #define CFG_TX_POWER (0x18) /* -0.15dBm */ ++#endif + + /****************************************************************************** + * BLE Stack +@@ -53,32 +52,41 @@ + * Maximum number of simultaneous connections that the device will support. + * Valid values are from 1 to 8 + */ +-#define CFG_BLE_NUM_LINK 2 ++#ifndef CFG_BLE_NUM_LINK ++ #define CFG_BLE_NUM_LINK 2 ++#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 ++ * 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 + #define CFG_BLE_NUM_GATT_SERVICES 8 ++#endif + + /** + * Maximum number of Attributes +- * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) +- * that can be stored in the GATT database. +- * 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 ++ * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the ++ * services) that can be stored in the GATT database. 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 ++ #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 ++#endif + + /** + * Maximum supported ATT_MTU size + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" + */ +-#define CFG_BLE_MAX_ATT_MTU (156) ++#ifndef CFG_BLE_MAX_ATT_MTU ++ #define CFG_BLE_MAX_ATT_MTU (156) ++#endif + + /** + * Size of the storage area for Attribute values +- * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: ++ * This value depends on the number of attributes used by application. In particular the sum of the following ++ * quantities (in octets) should be made for each attribute: + * - attribute value length + * - 5, if UUID is 16 bit; 19, if UUID is 128 bit + * - 2, if server configuration descriptor is used +@@ -87,14 +95,18 @@ + * The total amount of memory needed is the sum of the above quantities for each attribute. + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" + */ ++#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE + #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) ++#endif + + /** + * Prepare Write List size in terms of number of packet + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" + */ + // #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +-#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) ++#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE ++ #define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) ++#endif + + /** + * Number of allocated memory blocks +@@ -106,12 +118,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 Slave mode (ppm value) + */ +-#define CFG_BLE_SLAVE_SCA 500 ++#ifndef CFG_BLE_SLAVE_SCA ++ #define CFG_BLE_SLAVE_SCA 500 ++#endif + + /** + * Sleep clock accuracy in Master mode +@@ -124,24 +140,32 @@ + * 6 : 21 ppm to 30 ppm + * 7 : 0 ppm to 20 ppm + */ +-#define CFG_BLE_MASTER_SCA 0 ++#ifndef CFG_BLE_MASTER_SCA ++ #define CFG_BLE_MASTER_SCA 0 ++#endif + + /** + * Source for the low speed clock for RF wake-up + * 1 : external high speed crystal HSE/32/32 + * 0 : external low speed crystal ( no calibration ) + */ +-#define CFG_BLE_LSE_SOURCE 0 ++#ifndef CFG_BLE_LSE_SOURCE ++ #define CFG_BLE_LSE_SOURCE 0 ++#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 Slave 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 +@@ -199,5 +223,4 @@ + + #define CFG_BLE_RX_MODEL_CONFIG SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY + +- +-#endif /*APP_CONF_H */ ++#endif /* APP_CONF_DEFAULT_H */ +-- +2.31.1.windows.1 + diff --git a/extras/STM32Cube_FW/0004-Stub-OutputDbgTrace-function.patch b/extras/STM32Cube_FW/0004-Stub-OutputDbgTrace-function.patch new file mode 100644 index 00000000..6f844f7a --- /dev/null +++ b/extras/STM32Cube_FW/0004-Stub-OutputDbgTrace-function.patch @@ -0,0 +1,209 @@ +From a015490bdd861f421addd761ee4164358dc07c19 Mon Sep 17 00:00:00 2001 +From: Alexandre Bourdiol +Date: Tue, 7 Dec 2021 14:27:27 +0100 +Subject: [PATCH 4/4] Stub OutputDbgTrace() function + +Signed-off-by: Alexandre Bourdiol +--- + src/utility/STM32Cube_FW/tl_mbox.c | 178 +---------------------------- + 1 file changed, 3 insertions(+), 175 deletions(-) + +diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c +index 709f5d2..db192c4 100644 +--- a/src/utility/STM32Cube_FW/tl_mbox.c ++++ b/src/utility/STM32Cube_FW/tl_mbox.c +@@ -24,7 +24,6 @@ + #include "stm_list.h" + #include "tl.h" + #include "mbox_def.h" +-#include "tl_dbg_conf.h" + + /* Private typedef -----------------------------------------------------------*/ + typedef enum +@@ -532,180 +531,9 @@ __WEAK void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ) + ******************************************************************************/ + static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) + { +- TL_EvtPacket_t *p_evt_packet; +- TL_CmdPacket_t *p_cmd_packet; +- +- switch(packet_type) +- { +- case TL_MB_MM_RELEASE_BUFFER: +- p_evt_packet = (TL_EvtPacket_t*)buffer; +- switch(p_evt_packet->evtserial.evt.evtcode) +- { +- case TL_BLEEVT_CS_OPCODE: +- TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); +- TL_MM_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); +- TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); +- break; +- +- case TL_BLEEVT_CC_OPCODE: +- TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); +- TL_MM_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); +- TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); +- break; +- +- case TL_BLEEVT_VS_OPCODE: +- TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); +- TL_MM_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); +- TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); +- break; +- +- default: +- TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); +- TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); +- break; +- } +- +- TL_MM_DBG_MSG("\r\n"); +- break; +- +- case TL_MB_BLE_CMD: +- p_cmd_packet = (TL_CmdPacket_t*)buffer; +- TL_HCI_CMD_DBG_MSG("ble cmd: 0x%04X", p_cmd_packet->cmdserial.cmd.cmdcode); +- if(p_cmd_packet->cmdserial.cmd.plen != 0) +- { +- TL_HCI_CMD_DBG_MSG(" payload:"); +- TL_HCI_CMD_DBG_BUF(p_cmd_packet->cmdserial.cmd.payload, p_cmd_packet->cmdserial.cmd.plen, ""); +- } +- TL_HCI_CMD_DBG_MSG("\r\n"); +- +- TL_HCI_CMD_DBG_RAW(&p_cmd_packet->cmdserial, p_cmd_packet->cmdserial.cmd.plen+TL_CMD_HDR_SIZE); +- break; +- +- case TL_MB_BLE_CMD_RSP: +- p_evt_packet = (TL_EvtPacket_t*)buffer; +- switch(p_evt_packet->evtserial.evt.evtcode) +- { +- case TL_BLEEVT_CS_OPCODE: +- TL_HCI_CMD_DBG_MSG("ble rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode); +- TL_HCI_CMD_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); +- TL_HCI_CMD_DBG_MSG(" numhci: 0x%02X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->numcmd); +- TL_HCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->status); +- break; +- +- case TL_BLEEVT_CC_OPCODE: +- TL_HCI_CMD_DBG_MSG("ble rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode); +- TL_HCI_CMD_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); +- TL_HCI_CMD_DBG_MSG(" numhci: 0x%02X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->numcmd); +- TL_HCI_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_HCI_CMD_DBG_MSG(" payload:"); +- TL_HCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[1], p_evt_packet->evtserial.evt.plen-4, ""); +- } +- break; +- +- default: +- TL_HCI_CMD_DBG_MSG("unknown ble rsp received: %02X", p_evt_packet->evtserial.evt.evtcode); +- break; +- } +- +- TL_HCI_CMD_DBG_MSG("\r\n"); +- +- TL_HCI_CMD_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); +- break; +- +- case TL_MB_BLE_ASYNCH_EVT: +- p_evt_packet = (TL_EvtPacket_t*)buffer; +- if(p_evt_packet->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) +- { +- TL_HCI_EVT_DBG_MSG("ble evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); +- if((p_evt_packet->evtserial.evt.plen) != 0) +- { +- TL_HCI_EVT_DBG_MSG(" payload:"); +- TL_HCI_EVT_DBG_BUF(p_evt_packet->evtserial.evt.payload, p_evt_packet->evtserial.evt.plen, ""); +- } +- } +- else +- { +- TL_HCI_EVT_DBG_MSG("ble evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); +- TL_HCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); +- if((p_evt_packet->evtserial.evt.plen-2) != 0) +- { +- TL_HCI_EVT_DBG_MSG(" payload:"); +- TL_HCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload, p_evt_packet->evtserial.evt.plen-2, ""); +- } +- } +- +- TL_HCI_EVT_DBG_MSG("\r\n"); +- +- TL_HCI_EVT_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); +- break; +- +- case TL_MB_SYS_CMD: +- p_cmd_packet = (TL_CmdPacket_t*)buffer; +- +- TL_SHCI_CMD_DBG_MSG("sys cmd: 0x%04X", p_cmd_packet->cmdserial.cmd.cmdcode); +- +- if(p_cmd_packet->cmdserial.cmd.plen != 0) +- { +- TL_SHCI_CMD_DBG_MSG(" payload:"); +- TL_SHCI_CMD_DBG_BUF(p_cmd_packet->cmdserial.cmd.payload, p_cmd_packet->cmdserial.cmd.plen, ""); +- } +- TL_SHCI_CMD_DBG_MSG("\r\n"); +- +- TL_SHCI_CMD_DBG_RAW(&p_cmd_packet->cmdserial, p_cmd_packet->cmdserial.cmd.plen+TL_CMD_HDR_SIZE); +- break; +- +- case TL_MB_SYS_CMD_RSP: +- p_evt_packet = (TL_EvtPacket_t*)buffer; +- switch(p_evt_packet->evtserial.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(" payload:"); +- TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[1], p_evt_packet->evtserial.evt.plen-4, ""); +- } +- break; +- +- default: +- TL_SHCI_CMD_DBG_MSG("unknown sys rsp received: %02X", p_evt_packet->evtserial.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); +- break; +- +- case TL_MB_SYS_ASYNCH_EVT: +- p_evt_packet = (TL_EvtPacket_t*)buffer; +- if(p_evt_packet->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) +- { +- TL_SHCI_EVT_DBG_MSG("unknown sys evt received: %02X", p_evt_packet->evtserial.evt.evtcode); +- } +- else +- { +- TL_SHCI_EVT_DBG_MSG("sys evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); +- TL_SHCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); +- if((p_evt_packet->evtserial.evt.plen-2) != 0) +- { +- TL_SHCI_EVT_DBG_MSG(" payload:"); +- TL_SHCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload, p_evt_packet->evtserial.evt.plen-2, ""); +- } +- } +- +- TL_SHCI_EVT_DBG_MSG("\r\n"); +- +- TL_SHCI_EVT_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); +- break; +- +- default: +- break; +- } ++ /* Function stubbed */ ++ UNUSED(packet_type); ++ UNUSED(buffer); + + return; + } +-- +2.31.1.windows.1 + From ab9e2f90350292d2390f58abe9f4b8e5a18ab851 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Mon, 6 Dec 2021 19:17:44 +0100 Subject: [PATCH 18/58] Update STM32Cube_FW from Cube version v1.13.0 Signed-off-by: Alexandre Bourdiol --- src/utility/HCISharedMemTransport.cpp | 8 +- src/utility/STM32Cube_FW/LICENSE.md | 80 +++ src/utility/STM32Cube_FW/README.md | 4 +- src/utility/STM32Cube_FW/app_conf_default.h | 588 ++++++++++++++++--- src/utility/STM32Cube_FW/ble_bufsize.h | 73 +-- src/utility/STM32Cube_FW/hw.h | 58 +- src/utility/STM32Cube_FW/hw_ipcc.c | 362 +++++++++++- src/utility/STM32Cube_FW/mbox_def.h | 101 +++- src/utility/STM32Cube_FW/shci.c | 252 ++++++-- src/utility/STM32Cube_FW/shci.h | 503 ++++++++++++++-- src/utility/STM32Cube_FW/shci_tl.c | 145 +---- src/utility/STM32Cube_FW/shci_tl.h | 24 +- src/utility/STM32Cube_FW/stm32_wpan_common.h | 52 +- src/utility/STM32Cube_FW/stm_list.c | 26 +- src/utility/STM32Cube_FW/stm_list.h | 23 +- src/utility/STM32Cube_FW/tl.h | 81 ++- src/utility/STM32Cube_FW/tl_mbox.c | 481 ++++++++++++--- 17 files changed, 2248 insertions(+), 613 deletions(-) create mode 100644 src/utility/STM32Cube_FW/LICENSE.md diff --git a/src/utility/HCISharedMemTransport.cpp b/src/utility/HCISharedMemTransport.cpp index ee2a41a6..c8de8c56 100644 --- a/src/utility/HCISharedMemTransport.cpp +++ b/src/utility/HCISharedMemTransport.cpp @@ -735,8 +735,12 @@ int HCISharedMemTransportClass::stm32wb_start_ble(void) CFG_BLE_MAX_CONN_EVENT_LENGTH, CFG_BLE_HSE_STARTUP_TIME, CFG_BLE_VITERBI_MODE, - CFG_BLE_LL_ONLY, - 0 /** TODO Should be read from HW */ + CFG_BLE_OPTIONS, + 0, /** TODO Should be read from HW */ + CFG_BLE_MAX_COC_INITIATOR_NBR, + CFG_BLE_MIN_TX_POWER, + CFG_BLE_MAX_TX_POWER, + CFG_BLE_RX_MODEL_CONFIG }; /** * Starts the BLE Stack on CPU2 diff --git a/src/utility/STM32Cube_FW/LICENSE.md b/src/utility/STM32Cube_FW/LICENSE.md new file mode 100644 index 00000000..1af52330 --- /dev/null +++ b/src/utility/STM32Cube_FW/LICENSE.md @@ -0,0 +1,80 @@ +SLA0044 Rev5/February 2018 + +## Software license agreement + +### __ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT__ + +BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE +OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS +INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES +(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON +BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES +TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT. + +Under STMicroelectronics’ intellectual property rights, the redistribution, +reproduction and use in source and binary forms of the software or any part +thereof, with or without modification, are permitted provided that the following +conditions are met: + +1. Redistribution of source code (modified or not) must retain any copyright +notice, this list of conditions and the disclaimer set forth below as items 10 +and 11. + +2. Redistributions in binary form, except as embedded into microcontroller or +microprocessor device manufactured by or for STMicroelectronics or a software +update for such device, must reproduce any copyright notice provided with the +binary code, this list of conditions, and the disclaimer set forth below as +items 10 and 11, in documentation and/or other materials provided with the +distribution. + +3. Neither the name of STMicroelectronics nor the names of other contributors to +this software may be used to endorse or promote products derived from this +software or part thereof without specific written permission. + +4. This software or any part thereof, including modifications and/or derivative +works of this software, must be used and execute solely and exclusively on or in +combination with a microcontroller or microprocessor device manufactured by or +for STMicroelectronics. + +5. No use, reproduction or redistribution of this software partially or totally +may be done in any manner that would subject this software to any Open Source +Terms. “Open Source Terms†shall mean any open source license which requires as +part of distribution of software that the source code of such software is +distributed therewith or otherwise made available, or open source license that +substantially complies with the Open Source definition specified at +www.opensource.org and any other comparable open source license such as for +example GNU General Public License (GPL), Eclipse Public License (EPL), Apache +Software License, BSD license or MIT license. + +6. STMicroelectronics has no obligation to provide any maintenance, support or +updates for the software. + +7. The software is and will remain the exclusive property of STMicroelectronics +and its licensors. The recipient will not take any action that jeopardizes +STMicroelectronics and its licensors' proprietary rights or acquire any rights +in the software, except the limited rights specified hereunder. + +8. The recipient shall comply with all applicable laws and regulations affecting +the use of the software or any part thereof including any applicable export +control law or regulation. + +9. Redistribution and use of this software or any part thereof other than as +permitted under this license is void and will automatically terminate your +rights under this license. + +10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE +DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL +STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER +EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY +RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY. diff --git a/src/utility/STM32Cube_FW/README.md b/src/utility/STM32Cube_FW/README.md index 880fcbbc..419d0eb0 100644 --- a/src/utility/STM32Cube_FW/README.md +++ b/src/utility/STM32Cube_FW/README.md @@ -1,6 +1,6 @@ ## Source -[STMicroelectronics/STM32CubeWB Release v1.8.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.8.0) -- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.8.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) +[STMicroelectronics/STM32CubeWB Release v1.13.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.13.0) +- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.13.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h index e870c321..7ebc65aa 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -1,49 +1,109 @@ +/* USER CODE BEGIN Header */ /** - ****************************************************************************** - * File Name : app_conf_default.h - * Description : Default application configuration file for STM32WPAN Middleware. - ****************************************************************************** - * @attention - * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 - * - ****************************************************************************** - */ + ****************************************************************************** + * @file app_conf.h + * @author MCD Application Team + * @brief Application configuration file for STM32WPAN Middleware. + ****************************************************************************** + * @attention + * + * Copyright (c) 2020-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 APP_CONF_DEFAULT_H -#define APP_CONF_DEFAULT_H +#ifndef APP_CONF_H +#define APP_CONF_H + +#include "hw.h" +#include "hw_conf.h" +#include "hw_if.h" +#include "ble_bufsize.h" /****************************************************************************** * Application Config ******************************************************************************/ -/**< generic parameters ******************************************************/ -/* HCI related defines */ +/** + * Define Secure Connections Support + */ +#define CFG_SECURE_NOT_SUPPORTED (0x00) +#define CFG_SECURE_OPTIONAL (0x01) +#define CFG_SECURE_MANDATORY (0x02) + +#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL -#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 +/** + * Define Keypress Notification Support + */ +#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) +#define CFG_KEYPRESS_SUPPORTED (0x01) -#ifndef BLE_SHARED_MEM_BYTE_ORDER - #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST -#endif -#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 +#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED /** - * Define Tx Power + * Numeric Comparison Answers */ -#ifndef CFG_TX_POWER - #define CFG_TX_POWER (0x18) /* -0.15dBm */ -#endif +#define YES (0x01) +#define NO (0x00) + +/** + * Device name configuration for Generic Access Service + */ +#define CFG_GAP_DEVICE_NAME "TEMPLATE" +#define CFG_GAP_DEVICE_NAME_LENGTH (8) + +/** +* Identity root key used to derive LTK and CSRK +*/ +#define CFG_BLE_IRK {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0} + +/** +* Encryption root key used to derive LTK and CSRK +*/ +#define CFG_BLE_ERK {0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21, 0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21} + +/** + * SMPS supply + * SMPS not used when Set to 0 + * SMPS used when Set to 1 + */ +#define CFG_USE_SMPS 0 + +/* USER CODE BEGIN Generic_Parameters */ +/* USER CODE END Generic_Parameters */ + +/**< specific parameters */ +/*****************************************************/ + +/* USER CODE BEGIN Specific_Parameters */ +#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler + +/* USER CODE END Specific_Parameters */ + +/****************************************************************************** + * Information Table + * + * Version + * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version + * [4:7] = branch - 0: Mass Market - x: ... + * [8:15] = Subversion + * [16:23] = Version minor + * [24:31] = Version major + * + ******************************************************************************/ +#define CFG_FW_MAJOR_VERSION (0) +#define CFG_FW_MINOR_VERSION (0) +#define CFG_FW_SUBVERSION (1) +#define CFG_FW_BRANCH (0) +#define CFG_FW_BUILD (0) /****************************************************************************** * BLE Stack @@ -52,81 +112,63 @@ * Maximum number of simultaneous connections that the device will support. * Valid values are from 1 to 8 */ -#ifndef CFG_BLE_NUM_LINK - #define CFG_BLE_NUM_LINK 8 -#endif +#define CFG_BLE_NUM_LINK 2 /** * 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 + * 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 - #define CFG_BLE_NUM_GATT_SERVICES 8 -#endif +#define CFG_BLE_NUM_GATT_SERVICES 8 /** * Maximum number of Attributes - * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the - * services) that can be stored in the GATT database. 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 + * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) + * that can be stored in the GATT database. + * 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 - #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 -#endif +#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 /** * Maximum supported ATT_MTU size + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" */ -#ifndef CFG_BLE_MAX_ATT_MTU - #define CFG_BLE_MAX_ATT_MTU (156) -#endif +#define CFG_BLE_MAX_ATT_MTU (156) /** * Size of the storage area for Attribute values - * This value depends on the number of attributes used by application. In particular the sum of the following - * quantities (in octets) should be made for each attribute: + * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: * - attribute value length * - 5, if UUID is 16 bit; 19, if UUID is 128 bit * - 2, if server configuration descriptor is used * - 2*DTM_NUM_LINK, if client configuration descriptor is used * - 2, if extended properties is used * The total amount of memory needed is the sum of the above quantities for each attribute. + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" */ -#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE - #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) -#endif +#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) /** * Prepare Write List size in terms of number of packet + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" */ -//#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE - #define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) -#endif +#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) /** * Number of allocated memory blocks + * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter when CFG_BLE_OPTIONS is set to 1 */ -//#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, -// CFG_BLE_NUM_LINK)) -#ifndef CFG_BLE_MBLOCK_COUNT - #define CFG_BLE_MBLOCK_COUNT (0x79) -#endif +#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) /** * 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 Slave mode (ppm value) */ -#ifndef CFG_BLE_SLAVE_SCA - #define CFG_BLE_SLAVE_SCA 500 -#endif +#define CFG_BLE_SLAVE_SCA 500 /** * Sleep clock accuracy in Master mode @@ -139,47 +181,409 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#ifndef CFG_BLE_MASTER_SCA - #define CFG_BLE_MASTER_SCA 0 -#endif +#define CFG_BLE_MASTER_SCA 0 /** - * Source for the 32 kHz slow speed clock - * 1 : internal RO - * 0 : external crystal ( no calibration ) + * Source for the low speed clock for RF wake-up + * 1 : external high speed crystal HSE/32/32 + * 0 : external low speed crystal ( no calibration ) */ -#ifndef CFG_BLE_LSE_SOURCE - #define CFG_BLE_LSE_SOURCE 0 -#endif +#define CFG_BLE_LSE_SOURCE 0 /** * 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 Slave 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 * 1 : enabled * 0 : disabled */ -#define CFG_BLE_VITERBI_MODE 1 +#define CFG_BLE_VITERBI_MODE 1 + +/** + * BLE stack Options flags to be configured with: + * - SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY + * - SHCI_C2_BLE_INIT_OPTIONS_LL_HOST + * - SHCI_C2_BLE_INIT_OPTIONS_NO_SVC_CHANGE_DESC + * - SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC + * - SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RO + * - SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW + * - SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV + * - SHCI_C2_BLE_INIT_OPTIONS_NO_EXT_ADV + * - SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 + * - SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2 + * - SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_1 + * - SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3 + * which are used to set following configuration bits: + * (bit 0): 1: LL only + * 0: LL + host + * (bit 1): 1: no service change desc. + * 0: with service change desc. + * (bit 2): 1: device name Read-Only + * 0: device name R/W + * (bit 3): 1: extended advertizing supported [NOT SUPPORTED] + * 0: extended advertizing not supported [NOT SUPPORTED] + * (bit 4): 1: CS Algo #2 supported + * 0: CS Algo #2 not supported + * (bit 7): 1: LE Power Class 1 + * 0: LE Power Class 2-3 + * other bits: reserved (shall be set to 0) + */ +#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_NO_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) + +#define CFG_BLE_MAX_COC_INITIATOR_NBR (32) + +#define CFG_BLE_MIN_TX_POWER (0) + +#define CFG_BLE_MAX_TX_POWER (0) + +/** + * BLE Rx model configuration flags to be configured with: + * - SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY + * - SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_BLOCKER + * which are used to set following configuration bits: + * (bit 0): 1: agc_rssi model improved vs RF blockers + * 0: Legacy agc_rssi model + * other bits: reserved (shall be set to 0) + */ + +#define CFG_BLE_RX_MODEL_CONFIG SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY + +/****************************************************************************** + * Transport Layer + ******************************************************************************/ +/** + * Queue length of BLE Event + * This parameter defines the number of asynchronous events that can be stored in the HCI layer before + * being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer + * is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large + * enough to store all asynchronous events received in between. + * When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events + * between the HCI command and its event. + * This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small, + * the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting + * for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate + * to the application a HCI command did not receive its command event within 30s (Default HCI Timeout). + */ +#define CFG_TLBLE_EVT_QUEUE_LENGTH 5 +/** + * This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element + * allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager. + * It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will + * never be used) + * It shall be at least 4 to receive the command status event in one frame. + * The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced + * further depending on the application. + */ +#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */ + +#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE ) +/****************************************************************************** + * UART interfaces + ******************************************************************************/ + +/** + * Select UART interfaces + */ +#define CFG_UART_GUI hw_uart1 +#define CFG_DEBUG_TRACE_UART 0 +/****************************************************************************** + * USB interface + ******************************************************************************/ + +/** + * Enable/Disable USB interface + */ +#define CFG_USB_INTERFACE_ENABLE 0 + +/****************************************************************************** + * IPCC interface + ******************************************************************************/ + +/** + * The IPCC is dedicated to the communication between the CPU2 and the CPU1 + * and shall not be modified by the application + * The two following definitions shall not be modified + */ +#define HAL_IPCC_TX_IRQHandler(...) HW_IPCC_Tx_Handler( ) +#define HAL_IPCC_RX_IRQHandler(...) HW_IPCC_Rx_Handler( ) + +/****************************************************************************** + * Low Power + ******************************************************************************/ +/** + * When set to 1, the low power mode is enable + * When set to 0, the device stays in RUN mode + */ +#define CFG_LPM_SUPPORTED 1 + +/****************************************************************************** + * RTC interface + ******************************************************************************/ +#define HAL_RTCEx_WakeUpTimerIRQHandler(...) HW_TS_RTC_Wakeup_Handler( ) + +/****************************************************************************** + * Timer Server + ******************************************************************************/ +/** + * CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer. + * The lower is the value, the better is the power consumption and the accuracy of the timerserver + * The higher is the value, the finest is the granularity + * + * CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to output + * clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding + * the wakeup timer. A lower clock speed would impact the accuracy of the timer server. + * + * CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC. + * When the 1Hz calendar clock is required, it shall be sets according to other settings + * When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE) + * + * CFG_RTCCLK_DIVIDER_CONF: + * Shall be set to either 0,2,4,8,16 + * When set to either 2,4,8,16, the 1Hhz calendar is supported + * When set to 0, the user sets its own configuration + * + * The following settings are computed with LSI as input to the RTC + */ + +#define CFG_RTCCLK_DIVIDER_CONF 0 + +#if (CFG_RTCCLK_DIVIDER_CONF == 0) +/** + * Custom configuration + * It does not support 1Hz calendar + * It divides the RTC CLK by 16 + */ + +#define CFG_RTCCLK_DIV (16) +#define CFG_RTC_WUCKSEL_DIVIDER (0) +#define CFG_RTC_ASYNCH_PRESCALER (0x0F) +#define CFG_RTC_SYNCH_PRESCALER (0x7FFF) + +#else + +#if (CFG_RTCCLK_DIVIDER_CONF == 2) +/** + * It divides the RTC CLK by 2 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (3) +#endif + +#if (CFG_RTCCLK_DIVIDER_CONF == 4) +/** + * It divides the RTC CLK by 4 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (2) +#endif + +#if (CFG_RTCCLK_DIVIDER_CONF == 8) +/** + * It divides the RTC CLK by 8 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (1) +#endif + +#if (CFG_RTCCLK_DIVIDER_CONF == 16) +/** + * It divides the RTC CLK by 16 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (0) +#endif + +#define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF +#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) +#define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 ) + +#endif + +/** tick timer values */ +#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE ) +#define CFG_TS_TICK_VAL_PS DIVR( ((uint64_t)CFG_RTCCLK_DIV * 1e12), (uint64_t)LSE_VALUE ) +typedef enum +{ + CFG_TIM_PROC_ID_ISR, + /* USER CODE BEGIN CFG_TimProcID_t */ + + /* USER CODE END CFG_TimProcID_t */ +} CFG_TimProcID_t; + +/****************************************************************************** + * Debug + ******************************************************************************/ /** - * LL Only Mode - * 1 : LL Only - * 0 : LL + Host + * When set, this resets some hw resources to set the device in the same state than the power up + * The FW resets only register that may prevent the FW to run properly + * + * This shall be set to 0 in a final product + * */ -#define CFG_BLE_LL_ONLY 1 +#define CFG_HW_RESET_BY_FW 1 + +/** + * keep debugger enabled while in any low power mode when set to 1 + * should be set to 0 in production + */ +#define CFG_DEBUGGER_SUPPORTED 0 + +/** + * When set to 1, the traces are enabled in the BLE services + */ +#define CFG_DEBUG_BLE_TRACE 0 + +/** + * Enable or Disable traces in application + */ +#define CFG_DEBUG_APP_TRACE 0 + +#if (CFG_DEBUG_APP_TRACE != 0) +#define APP_DBG_MSG PRINT_MESG_DBG +#else +#define APP_DBG_MSG PRINT_NO_MESG +#endif + +#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) ) +#define CFG_DEBUG_TRACE 1 +#endif + +#if (CFG_DEBUG_TRACE != 0) +#undef CFG_LPM_SUPPORTED +#undef CFG_DEBUGGER_SUPPORTED +#define CFG_LPM_SUPPORTED 0 +#define CFG_DEBUGGER_SUPPORTED 1 +#endif + +/** + * When CFG_DEBUG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number + * When CFG_DEBUG_TRACE_LIGHT is set to 1, only the debug message is output + * + * When both are set to 0, no trace are output + * When both are set to 1, CFG_DEBUG_TRACE_FULL is selected + */ +#define CFG_DEBUG_TRACE_LIGHT 0 +#define CFG_DEBUG_TRACE_FULL 0 + +#if (( CFG_DEBUG_TRACE != 0 ) && ( CFG_DEBUG_TRACE_LIGHT == 0 ) && (CFG_DEBUG_TRACE_FULL == 0)) +#undef CFG_DEBUG_TRACE_FULL +#undef CFG_DEBUG_TRACE_LIGHT +#define CFG_DEBUG_TRACE_FULL 0 +#define CFG_DEBUG_TRACE_LIGHT 1 +#endif + +#if ( CFG_DEBUG_TRACE == 0 ) +#undef CFG_DEBUG_TRACE_FULL +#undef CFG_DEBUG_TRACE_LIGHT +#define CFG_DEBUG_TRACE_FULL 0 +#define CFG_DEBUG_TRACE_LIGHT 0 +#endif + +/** + * When not set, the traces is looping on sending the trace over UART + */ +#define DBG_TRACE_USE_CIRCULAR_QUEUE 1 + +/** + * max buffer Size to queue data traces and max data trace allowed. + * Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined + */ +#define DBG_TRACE_MSG_QUEUE_SIZE 4096 +#define MAX_DBG_TRACE_MSG_SIZE 1024 + +/* USER CODE BEGIN Defines */ +#define CFG_LED_SUPPORTED 1 +#define CFG_BUTTON_SUPPORTED 1 + +#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler +#define PUSH_BUTTON_SW2_EXTI_IRQHandler EXTI0_IRQHandler +#define PUSH_BUTTON_SW3_EXTI_IRQHandler EXTI1_IRQHandler +/* USER CODE END Defines */ + +/****************************************************************************** + * Scheduler + ******************************************************************************/ + +/** + * These are the lists of task id registered to the scheduler + * Each task id shall be in the range [0:31] + * This mechanism allows to implement a generic code in the API TL_BLE_HCI_StatusNot() to comply with + * the requirement that a HCI/ACI command shall never be sent if there is already one pending + */ + +/**< Add in that list all tasks that may send a ACI/HCI command */ +typedef enum +{ + CFG_TASK_BLE_HCI_CMD_ID, + CFG_TASK_SYS_HCI_CMD_ID, + CFG_TASK_HCI_ACL_DATA_ID, + CFG_TASK_SYS_LOCAL_CMD_ID, + CFG_TASK_TX_TO_HOST_ID, + /* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */ + CFG_TASK_SW1_BUTTON_PUSHED_ID, + CFG_TASK_SW2_BUTTON_PUSHED_ID, + CFG_TASK_SW3_BUTTON_PUSHED_ID, + /* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */ + CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */ +} CFG_Task_Id_With_HCI_Cmd_t; + +/**< Add in that list all tasks that never send a ACI/HCI command */ +typedef enum +{ + CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */ + CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID, + /* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */ + + /* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */ + CFG_LAST_TASK_ID_WITHO_NO_HCICMD /**< Shall be LAST in the list */ +} CFG_Task_Id_With_NO_HCI_Cmd_t; + +#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITHO_NO_HCICMD + +/** + * This is the list of priority required by the application + * Each Id shall be in the range 0..31 + */ +typedef enum +{ + CFG_SCH_PRIO_0, + CFG_PRIO_NBR, +} CFG_SCH_Prio_Id_t; + +/** + * This is a bit mapping over 32bits listing all events id supported in the application + */ +typedef enum +{ + CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID, +} CFG_IdleEvt_Id_t; + +/****************************************************************************** + * LOW POWER + ******************************************************************************/ +/** + * Supported requester to the MCU Low Power Manager - can be increased up to 32 + * It list a bit mapping of all user of the Low Power Manager + */ +typedef enum +{ + CFG_LPM_APP, + CFG_LPM_APP_BLE, + /* USER CODE BEGIN CFG_LPM_Id_t */ + + /* USER CODE END CFG_LPM_Id_t */ +} CFG_LPM_Id_t; + +/****************************************************************************** + * OTP manager + ******************************************************************************/ +#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE -#endif /* APP_CONF_DEFAULT_H */ +#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +#endif /*APP_CONF_H */ diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h index 8930e401..ba9c4d3c 100644 --- a/src/utility/STM32Cube_FW/ble_bufsize.h +++ b/src/utility/STM32Cube_FW/ble_bufsize.h @@ -1,17 +1,16 @@ /***************************************************************************** * @file ble_bufsize.h - * @author MCD Application Team + * @author MCD * @brief Definition of BLE stack buffers size ***************************************************************************** * @attention * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2018-2021 STMicroelectronics. + * All rights reserved. * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 + * 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. * ***************************************************************************** */ @@ -25,11 +24,6 @@ */ #define BLE_DEFAULT_ATT_MTU 23 -/* - * BLE_DEFAULT_MAX_ATT_MTU: maximum supported ATT MTU size. - */ -#define BLE_DEFAULT_MAX_ATT_MTU 158 - /* * BLE_DEFAULT_MAX_ATT_SIZE: maximum attribute size. */ @@ -81,44 +75,45 @@ ((pw) + MAX(BLE_MEM_BLOCK_X_MTU(mtu, n_link), \ BLE_MBLOCKS_SECURE_CONNECTIONS)) -/* - * BLE_DEFAULT_MBLOCKS_COUNT: default memory blocks count - */ -#define BLE_DEFAULT_MBLOCKS_COUNT(n_link) \ - BLE_MBLOCKS_CALC(BLE_DEFAULT_PREP_WRITE_LIST_SIZE, \ - BLE_DEFAULT_MAX_ATT_MTU, n_link) - /* * BLE_FIXED_BUFFER_SIZE_BYTES: - * A part of the RAM, is dynamically allocated by initializing all the pointers + * A part of the RAM, is dinamically allocated by initilizing all the pointers * defined in a global context variable "mem_alloc_ctx_p". * This initialization is made in the Dynamic_allocator functions, which - * assign a portion of RAM given by the external application to the above + * assing a portion of RAM given by the external application to the above * mentioned "global pointers". * * The size of this Dynamic RAM is made of 2 main components: * - a part that is parameters-dependent (num of links, GATT buffers, ...), - * and which value is defined by the following macro; + * and which value is explicited by the following macro; * - a part, that may be considered "fixed", i.e. independent from the above * mentioned parameters. */ -#if (SLAVE_ONLY == 0) && (LL_ONLY == 0) -#define BLE_FIXED_BUFFER_SIZE_BYTES 6960 /* Full stack */ -#elif SLAVE_ONLY == 0 -#define BLE_FIXED_BUFFER_SIZE_BYTES 6256 /* LL only */ +#if (BEACON_ONLY != 0) +#define BLE_FIXED_BUFFER_SIZE_BYTES 4184 /* Beacon only */ +#elif (LL_ONLY != 0) +#define BLE_FIXED_BUFFER_SIZE_BYTES 6068 /* LL only */ +#elif (SLAVE_ONLY != 0) +#define BLE_FIXED_BUFFER_SIZE_BYTES 6096 /* Peripheral only */ +#elif (BASIC_FEATURES != 0) +#define BLE_FIXED_BUFFER_SIZE_BYTES 6400 /* Basic Features */ #else -#define BLE_FIXED_BUFFER_SIZE_BYTES 6696 /* Slave only */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 7312 /* Full stack */ #endif /* * BLE_PER_LINK_SIZE_BYTES: additional memory size used per link */ -#if (SLAVE_ONLY == 0) && (LL_ONLY == 0) -#define BLE_PER_LINK_SIZE_BYTES 380 /* Full stack */ -#elif SLAVE_ONLY == 0 -#define BLE_PER_LINK_SIZE_BYTES 196 /* LL only */ +#if (BEACON_ONLY != 0) +#define BLE_PER_LINK_SIZE_BYTES 192 /* Beacon only */ +#elif (LL_ONLY != 0) +#define BLE_PER_LINK_SIZE_BYTES 260 /* LL only */ +#elif (SLAVE_ONLY != 0) +#define BLE_PER_LINK_SIZE_BYTES 388 /* Peripheral only */ +#elif (BASIC_FEATURES != 0) +#define BLE_PER_LINK_SIZE_BYTES 388 /* Basic Features */ #else -#define BLE_PER_LINK_SIZE_BYTES 332 /* Slave only */ +#define BLE_PER_LINK_SIZE_BYTES 444 /* Full stack */ #endif /* @@ -126,16 +121,24 @@ * needed for the storage of data structures (except GATT database elements) * whose size depends on the number of supported connections. * - * @param num_links: Maximum number of simultaneous connections that the device + * @param n_link: Maximum number of simultaneous connections that the device * will support. Valid values are from 1 to 8. * * @param mblocks_count: Number of memory blocks allocated for packets. */ #define BLE_TOTAL_BUFFER_SIZE(n_link, mblocks_count) \ - (BLE_FIXED_BUFFER_SIZE_BYTES + \ + (16 + BLE_FIXED_BUFFER_SIZE_BYTES + \ (BLE_PER_LINK_SIZE_BYTES * (n_link)) + \ ((BLE_MEM_BLOCK_SIZE + 12) * (mblocks_count))) +/* + * BLE_EXT_ADV_BUFFER_SIZE + * additional memory size used for Extended advertising; + * It has to be added to BLE_TOTAL_BUFFER_SIZE(). + * The formula used is based on:(1792 + ((set_nbr) * (60 + (2 * (data_len))))) + */ +#define BLE_EXT_ADV_BUFFER_SIZE(set_nbr, data_len) (7596) + /* * BLE_TOTAL_BUFFER_SIZE_GATT: this macro returns the amount of memory, * in bytes, needed for the storage of GATT database elements. @@ -158,4 +161,4 @@ (40 * (num_gatt_attributes)) + (48 * (num_gatt_services))) -#endif /* ! BLE_BUFSIZE_H__ */ +#endif /* BLE_BUFSIZE_H__ */ diff --git a/src/utility/STM32Cube_FW/hw.h b/src/utility/STM32Cube_FW/hw.h index a94bec9c..503fa2ca 100644 --- a/src/utility/STM32Cube_FW/hw.h +++ b/src/utility/STM32Cube_FW/hw.h @@ -6,13 +6,12 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2018-2021 STMicroelectronics. + * All rights reserved. * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause + * 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. * ****************************************************************************** */ @@ -27,21 +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 ); + void HW_IPCC_Rx_Handler( void ); + void HW_IPCC_Tx_Handler( void ); void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); @@ -74,24 +66,40 @@ extern "C" { void HW_IPCC_LLDTESTS_SendM0CmdAck( void ); - void HW_IPCC_LLD_BLE_Init( void ); - void HW_IPCC_LLD_BLE_SendCliCmd( void ); - void HW_IPCC_LLD_BLE_ReceiveCliRsp( void ); - void HW_IPCC_LLD_BLE_SendCliRspAck( void ); - void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ); - void HW_IPCC_LLD_BLE_SendM0CmdAck( void ); - void HW_IPCC_LLD_BLE_SendCmd( void ); - void HW_IPCC_LLD_BLE_ReceiveRsp( void ); - void HW_IPCC_LLD_BLE_SendRspAck( void ); + void HW_IPCC_BLE_LLD_Init( void ); + void HW_IPCC_BLE_LLD_SendCliCmd( void ); + void HW_IPCC_BLE_LLD_ReceiveCliRsp( void ); + void HW_IPCC_BLE_LLD_SendCliRspAck( void ); + void HW_IPCC_BLE_LLD_ReceiveM0Cmd( void ); + void HW_IPCC_BLE_LLD_SendM0CmdAck( void ); + void HW_IPCC_BLE_LLD_SendCmd( void ); + void HW_IPCC_BLE_LLD_ReceiveRsp( void ); + void HW_IPCC_BLE_LLD_SendRspAck( void ); void HW_IPCC_TRACES_Init( void ); void HW_IPCC_TRACES_EvtNot( void ); + void HW_IPCC_MAC_802_15_4_Init( void ); + void HW_IPCC_MAC_802_15_4_SendCmd( void ); + void HW_IPCC_MAC_802_15_4_SendAck( void ); + void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ); + void HW_IPCC_MAC_802_15_4_EvtNot( void ); + + void HW_IPCC_ZIGBEE_Init( void ); + + void HW_IPCC_ZIGBEE_SendM4RequestToM0(void); /* M4 Request to M0 */ + void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void); /* Request ACK from M0 */ + + void HW_IPCC_ZIGBEE_RecvM0NotifyToM4(void); /* M0 Notify to M4 */ + void HW_IPCC_ZIGBEE_SendM4AckToM0Notify(void); /* Notify ACK from M4 */ + void HW_IPCC_ZIGBEE_RecvM0RequestToM4(void); /* M0 Request to M4 */ + void HW_IPCC_ZIGBEE_SendM4AckToM0Request(void); /* Request ACK from M4 */ + + #ifdef __cplusplus } #endif #endif /*__HW_H */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c index 658aadb4..c5a941d2 100644 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ b/src/utility/STM32Cube_FW/hw_ipcc.c @@ -1,24 +1,25 @@ +/* USER CODE BEGIN Header */ /** - ****************************************************************************** - * File Name : Target/hw_ipcc.c - * Description : Hardware IPCC source file for STM32WPAN Middleware. - * - ****************************************************************************** + ****************************************************************************** + * @file hw_ipcc.c + * @author MCD Application Team + * @brief Hardware IPCC source file for STM32WPAN Middleware. + ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2020-2021 STMicroelectronics. + * All rights reserved. * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 + * 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. * ****************************************************************************** */ -#if defined(STM32WBxx) +/* USER CODE END Header */ + /* Includes ------------------------------------------------------------------*/ -#include "hw.h" +#include "app_common.h" #include "mbox_def.h" /* Global variables ---------------------------------------------------------*/ @@ -45,17 +46,44 @@ static void HW_IPCC_THREAD_NotEvtHandler( void ); static void HW_IPCC_THREAD_CliNotEvtHandler( void ); #endif +#ifdef LLD_TESTS_WB +static void HW_IPCC_LLDTESTS_ReceiveCliRspHandler( void ); +static void HW_IPCC_LLDTESTS_ReceiveM0CmdHandler( void ); +#endif +#ifdef LLD_BLE_WB +/*static void HW_IPCC_LLD_BLE_ReceiveCliRspHandler( void );*/ +static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ); +static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void ); +#endif + +#ifdef MAC_802_15_4_WB +static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ); +static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ); +#endif + +#ifdef ZIGBEE_WB +static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ); +static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ); +static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ); +#endif + /* Public function definition -----------------------------------------------*/ /****************************************************************************** * INTERRUPT HANDLER ******************************************************************************/ -void IPCC_C1_RX_IRQHandler(void) +void HW_IPCC_Rx_Handler( void ) { if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL )) { HW_IPCC_SYS_EvtHandler(); } +#ifdef MAC_802_15_4_WB + else if (HW_IPCC_RX_PENDING( HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL )) + { + HW_IPCC_MAC_802_15_4_NotEvtHandler(); + } +#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL )) { @@ -66,6 +94,36 @@ void IPCC_C1_RX_IRQHandler(void) HW_IPCC_THREAD_CliNotEvtHandler(); } #endif /* THREAD_WB */ +#ifdef LLD_TESTS_WB + else if (HW_IPCC_RX_PENDING( HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL )) + { + HW_IPCC_LLDTESTS_ReceiveCliRspHandler(); + } + else if (HW_IPCC_RX_PENDING( HW_IPCC_LLDTESTS_M0_CMD_CHANNEL )) + { + HW_IPCC_LLDTESTS_ReceiveM0CmdHandler(); + } +#endif /* LLD_TESTS_WB */ +#ifdef LLD_BLE_WB + else if (HW_IPCC_RX_PENDING( HW_IPCC_LLD_BLE_RSP_CHANNEL )) + { + HW_IPCC_LLD_BLE_ReceiveRspHandler(); + } + else if (HW_IPCC_RX_PENDING( HW_IPCC_LLD_BLE_M0_CMD_CHANNEL )) + { + HW_IPCC_LLD_BLE_ReceiveM0CmdHandler(); + } +#endif /* LLD_TESTS_WB */ +#ifdef ZIGBEE_WB + else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL )) + { + HW_IPCC_ZIGBEE_StackNotifEvtHandler(); + } + else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL )) + { + HW_IPCC_ZIGBEE_StackM0RequestHandler(); + } +#endif /* ZIGBEE_WB */ else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL )) { HW_IPCC_BLE_EvtHandler(); @@ -74,24 +132,37 @@ void IPCC_C1_RX_IRQHandler(void) { HW_IPCC_TRACES_EvtHandler(); } + + return; } -void IPCC_C1_TX_IRQHandler(void) +void HW_IPCC_Tx_Handler( void ) { if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) { HW_IPCC_SYS_CmdEvtHandler(); } +#ifdef MAC_802_15_4_WB + else if (HW_IPCC_TX_PENDING( HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL )) + { + HW_IPCC_MAC_802_15_4_CmdEvtHandler(); + } +#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) { HW_IPCC_OT_CmdEvtHandler(); } #endif /* THREAD_WB */ - else if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) +#ifdef LLD_TESTS_WB +// No TX handler for LLD tests +#endif /* LLD_TESTS_WB */ +#ifdef ZIGBEE_WB + if (HW_IPCC_TX_PENDING( HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL )) { - HW_IPCC_SYS_CmdEvtHandler(); + HW_IPCC_ZIGBEE_CmdEvtHandler(); } +#endif /* ZIGBEE_WB */ else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL )) { HW_IPCC_MM_FreeBufHandler(); @@ -100,8 +171,9 @@ void IPCC_C1_TX_IRQHandler(void) { HW_IPCC_BLE_AclDataEvtHandler(); } -} + return; +} /****************************************************************************** * GENERAL ******************************************************************************/ @@ -113,7 +185,7 @@ void HW_IPCC_Enable( void ) */ LL_C2_AHB3_GRP1_EnableClock(LL_C2_AHB3_GRP1_PERIPH_IPCC); - /** + /** * When the device is out of standby, it is required to use the EXTI mechanism to wakeup CPU2 */ LL_C2_EXTI_EnableEvent_32_63( LL_EXTI_LINE_41 ); @@ -191,8 +263,8 @@ static void HW_IPCC_BLE_AclDataEvtHandler( void ) return; } -__WEAK void HW_IPCC_BLE_AclDataAckNot( void ){}; -__WEAK void HW_IPCC_BLE_RxEvtNot( void ){}; +__weak void HW_IPCC_BLE_AclDataAckNot( void ){}; +__weak void HW_IPCC_BLE_RxEvtNot( void ){}; /****************************************************************************** * SYSTEM @@ -230,8 +302,56 @@ static void HW_IPCC_SYS_EvtHandler( void ) return; } -__WEAK void HW_IPCC_SYS_CmdEvtNot( void ){}; -__WEAK void HW_IPCC_SYS_EvtNot( void ){}; +__weak void HW_IPCC_SYS_CmdEvtNot( void ){}; +__weak void HW_IPCC_SYS_EvtNot( void ){}; + +/****************************************************************************** + * MAC 802.15.4 + ******************************************************************************/ +#ifdef MAC_802_15_4_WB +void HW_IPCC_MAC_802_15_4_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + + return; +} + +void HW_IPCC_MAC_802_15_4_SendCmd( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + + return; +} + +void HW_IPCC_MAC_802_15_4_SendAck( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + + return; +} + +static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ) +{ + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + + HW_IPCC_MAC_802_15_4_CmdEvtNot(); + + return; +} + +static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + + HW_IPCC_MAC_802_15_4_EvtNot(); + + return; +} +__weak void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ){}; +__weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){}; +#endif /****************************************************************************** * THREAD @@ -303,12 +423,198 @@ static void HW_IPCC_THREAD_CliNotEvtHandler( void ) return; } -__WEAK void HW_IPCC_OT_CmdEvtNot( void ){}; -__WEAK void HW_IPCC_CLI_CmdEvtNot( void ){}; -__WEAK void HW_IPCC_THREAD_EvtNot( void ){}; +__weak void HW_IPCC_OT_CmdEvtNot( void ){}; +__weak void HW_IPCC_CLI_CmdEvtNot( void ){}; +__weak void HW_IPCC_THREAD_EvtNot( void ){}; #endif /* THREAD_WB */ +/****************************************************************************** + * LLD TESTS + ******************************************************************************/ +#ifdef LLD_TESTS_WB +void HW_IPCC_LLDTESTS_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); + return; +} + +void HW_IPCC_LLDTESTS_SendCliCmd( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL ); + return; +} + +static void HW_IPCC_LLDTESTS_ReceiveCliRspHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); + HW_IPCC_LLDTESTS_ReceiveCliRsp(); + return; +} + +void HW_IPCC_LLDTESTS_SendCliRspAck( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); + return; +} + +static void HW_IPCC_LLDTESTS_ReceiveM0CmdHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); + HW_IPCC_LLDTESTS_ReceiveM0Cmd(); + return; +} + +void HW_IPCC_LLDTESTS_SendM0CmdAck( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); + return; +} +__weak void HW_IPCC_LLDTESTS_ReceiveCliRsp( void ){}; +__weak void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void ){}; +#endif /* LLD_TESTS_WB */ + +/****************************************************************************** + * LLD BLE + ******************************************************************************/ +#ifdef LLD_BLE_WB +void HW_IPCC_LLD_BLE_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); + return; +} + +void HW_IPCC_LLD_BLE_SendCliCmd( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CLI_CMD_CHANNEL ); + return; +} + +/*static void HW_IPCC_LLD_BLE_ReceiveCliRspHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL ); + HW_IPCC_LLD_BLE_ReceiveCliRsp(); + return; +}*/ + +void HW_IPCC_LLD_BLE_SendCliRspAck( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL ); + return; +} + +static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void ) +{ + //LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); + HW_IPCC_LLD_BLE_ReceiveM0Cmd(); + return; +} + +void HW_IPCC_LLD_BLE_SendM0CmdAck( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); + //LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); + return; +} +__weak void HW_IPCC_LLD_BLE_ReceiveCliRsp( void ){}; +__weak void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ){}; + +/* Transparent Mode */ +void HW_IPCC_LLD_BLE_SendCmd( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CMD_CHANNEL ); + return; +} + +static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); + HW_IPCC_LLD_BLE_ReceiveRsp(); + return; +} + +void HW_IPCC_LLD_BLE_SendRspAck( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); + return; +} + +#endif /* LLD_BLE_WB */ + +/****************************************************************************** + * ZIGBEE + ******************************************************************************/ +#ifdef ZIGBEE_WB +void HW_IPCC_ZIGBEE_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + + return; +} + +void HW_IPCC_ZIGBEE_SendM4RequestToM0( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + + return; +} + +void HW_IPCC_ZIGBEE_SendM4AckToM0Notify( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + + return; +} + +static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ) +{ + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + + HW_IPCC_ZIGBEE_RecvAppliAckFromM0(); + + return; +} + +static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + + HW_IPCC_ZIGBEE_RecvM0NotifyToM4(); + + return; +} + +static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + + HW_IPCC_ZIGBEE_RecvM0RequestToM4(); + + return; +} + +void HW_IPCC_ZIGBEE_SendM4AckToM0Request( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + + return; +} + +__weak void HW_IPCC_ZIGBEE_RecvAppliAckFromM0( void ){}; +__weak void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ){}; +__weak void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ){}; +#endif /* ZIGBEE_WB */ + /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -359,6 +665,4 @@ static void HW_IPCC_TRACES_EvtHandler( void ) return; } -__WEAK void HW_IPCC_TRACES_EvtNot( void ){}; -#endif /* STM32WBxx */ -/******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/ +__weak void HW_IPCC_TRACES_EvtNot( void ){}; diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h index 6bddf696..06536d34 100644 --- a/src/utility/STM32Cube_FW/mbox_def.h +++ b/src/utility/STM32Cube_FW/mbox_def.h @@ -4,17 +4,16 @@ * @author MCD Application Team * @brief Mailbox definition ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** + * @attention + * + * Copyright (c) 2018-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. + * + ****************************************************************************** */ @@ -104,8 +103,14 @@ extern "C" { { uint8_t *cmdrsp_buffer; uint8_t *m0cmd_buffer; - } MB_LldBleTable_t; + } MB_BleLldTable_t; + typedef struct + { + uint8_t *notifM0toM4_buffer; + uint8_t *appliCmdM4toM0_buffer; + uint8_t *requestM0toM4_buffer; + } MB_ZigbeeTable_t; /** * msg * [0:7] = cmd/evt @@ -133,6 +138,13 @@ extern "C" { uint8_t *traces_queue; } MB_TracesTable_t; + typedef struct + { + uint8_t *p_cmdrsp_buffer; + uint8_t *p_notack_buffer; + uint8_t *evt_queue; + } MB_Mac_802_15_4_t; + typedef struct { MB_DeviceInfoTable_t *p_device_info_table; @@ -141,10 +153,35 @@ extern "C" { MB_SysTable_t *p_sys_table; MB_MemManagerTable_t *p_mem_manager_table; MB_TracesTable_t *p_traces_table; + MB_Mac_802_15_4_t *p_mac_802_15_4_table; + MB_ZigbeeTable_t *p_zigbee_table; MB_LldTestsTable_t *p_lld_tests_table; - MB_LldBleTable_t *p_lld_ble_table; + MB_BleLldTable_t *p_ble_lld_table; } MB_RefTable_t; +/** + * This table shall be used only in the case the CPU2 runs the FUS. + * It is used by the command SHCI_GetWirelessFwInfo() + */ +typedef struct +{ + uint32_t DeviceInfoTableState; + uint8_t Reserved1; + uint8_t LastFusActiveState; + uint8_t LastWirelessStackState; + uint8_t CurrentWirelessStackType; + uint32_t SafeBootVersion; + uint32_t FusVersion; + uint32_t FusMemorySize; + uint32_t WirelessStackVersion; + uint32_t WirelessStackMemorySize; + uint32_t WirelessFirmwareBleInfo; + uint32_t WirelessFirmwareThreadInfo; + uint32_t Reserved2; + uint64_t UID64; + uint16_t DeviceId; +} MB_FUS_DeviceInfoTable_t ; + #ifdef __cplusplus } #endif @@ -161,6 +198,15 @@ extern "C" { * | | * |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------| * | | + * | (ZIGBEE) | + * |----HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL------------>| + * | | + * |----HW_IPCC_ZIGBEE_CMD_CLI_CHANNEL-------------->| + * | | + * |<---HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL-------| + * | | + * |<---HW_IPCC_ZIGBEE_CLI_NOTIF_ACK_CHANNEL---------| + * | | * | (THREAD) | * |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->| * | | @@ -177,12 +223,17 @@ extern "C" { * | | * |<---HW_IPCC_BLE_EVENT_CHANNEL--------------------| * | | - * | (LLD BLE) | - * |----HW_IPCC_LLD_BLE_CMD_CHANNEL----------------->| + * | (BLE LLD) | + * |----HW_IPCC_BLE_LLD_CMD_CHANNEL----------------->| + * | | + * |<---HW_IPCC_BLE_LLD_RSP_CHANNEL------------------| + * | | + * |<---HW_IPCC_BLE_LLD_M0_CMD_CHANNEL---------------| * | | - * |<---HW_IPCC_LLD_BLE_RSP_CHANNEL------------------| + * | (MAC) | + * |----HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL-------->| * | | - * |<---HW_IPCC_LLD_BLE_M0_CMD_CHANNEL---------------| + * |<---HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL| * | | * | (BUFFER) | * |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>| @@ -201,24 +252,28 @@ extern "C" { #define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4 #define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_LLD_BLE_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_LLD_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_BLE_LLD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_BLE_LLD_CMD_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_HCI_ACL_DATA_CHANNEL LL_IPCC_CHANNEL_6 /** CPU2 */ #define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_LLD_BLE_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_BLE_LLD_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4 #define HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_LLD_BLE_RSP_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_BLE_LLD_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_BLE_LLD_RSP_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL LL_IPCC_CHANNEL_5 #endif /*__MBOX_H */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c index b848dd85..301db76d 100644 --- a/src/utility/STM32Cube_FW/shci.c +++ b/src/utility/STM32Cube_FW/shci.c @@ -4,20 +4,19 @@ * @author MCD Application Team * @brief HCI command for the system channel ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** + * @attention + * + * Copyright (c) 2018-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. + * + ****************************************************************************** */ -#if defined(STM32WBxx) + /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -223,7 +222,6 @@ SHCI_CmdStatus_t SHCI_C2_FUS_StartWs( void ) return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } - SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey( uint8_t key_index ) { /** @@ -244,6 +242,44 @@ SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey( uint8_t key_index ) return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } +SHCI_CmdStatus_t SHCI_C2_FUS_UnloadUsrKey( uint8_t key_index ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + local_buffer[0] = key_index; + + shci_send( SHCI_OPCODE_C2_FUS_UNLOAD_USR_KEY, + 1, + local_buffer, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_FUS_ActivateAntiRollback( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_FUS_ACTIVATE_ANTIROLLBACK, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket ) { /** @@ -298,7 +334,7 @@ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ) return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init( uint8_t param_size, uint8_t * p_param ) +SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ) { /** * Buffer is large enough to hold command complete without payload @@ -308,7 +344,7 @@ SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init( uint8_t param_size, uint8_t * p_param ) p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send( SHCI_OPCODE_C2_LLD_BLE_INIT, + shci_send( SHCI_OPCODE_C2_BLE_LLD_INIT, param_size, p_param, p_rsp ); @@ -316,6 +352,24 @@ SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init( uint8_t param_size, uint8_t * p_param ) return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } +SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_ZIGBEE_INIT, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ) { /** @@ -374,6 +428,44 @@ SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mod return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } +SHCI_CmdStatus_t SHCI_C2_CONCURRENT_GetNextBleEvtTime( SHCI_C2_CONCURRENT_GetNextBleEvtTime_Param_t *pParam ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE+4]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_CONCURRENT_GET_NEXT_BLE_EVT_TIME, + 0, + 0, + p_rsp ); + + memcpy((void*)&(pParam->relative_time), (void*)&((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1], sizeof(pParam->relative_time)); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + +SHCI_CmdStatus_t SHCI_C2_CONCURRENT_EnableNext_802154_EvtNotification( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_CONCURRENT_ENABLE_NEXT_802154_EVT_NOTIFICATION, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip ) { /** @@ -435,6 +527,24 @@ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t Fla return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } +SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_MAC_802_15_4_INIT, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + SHCI_CmdStatus_t SHCI_C2_Reinit( void ) { /** @@ -516,6 +626,23 @@ SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket) return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } +SHCI_CmdStatus_t SHCI_C2_802_15_4_DeInit( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_802_15_4_DEINIT, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} /** * Local System COMMAND @@ -526,48 +653,89 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) { uint32_t ipccdba = 0; MB_RefTable_t * p_RefTable = NULL; - uint32_t version = 0; - uint32_t memorySize = 0; - uint32_t infoStack = 0; + uint32_t wireless_firmware_version = 0; + uint32_t wireless_firmware_memorySize = 0; + uint32_t wireless_firmware_infoStack = 0; + MB_FUS_DeviceInfoTable_t * p_fus_device_info_table = NULL; + uint32_t fus_version = 0; + uint32_t fus_memorySize = 0; ipccdba = READ_BIT( FLASH->IPCCBR, FLASH_IPCCBR_IPCCDBA ); - p_RefTable = (MB_RefTable_t*)((ipccdba<<2) + SRAM2A_BASE); + + /** + * The Device Info Table mapping depends on which firmware is running on CPU2. + * If the FUS is running on CPU2, FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD shall be written in the table. + * Otherwise, it means the Wireless Firmware is running on the CPU2 + */ + p_fus_device_info_table = (MB_FUS_DeviceInfoTable_t*)(*(uint32_t*)((ipccdba<<2) + SRAM2A_BASE)); + + if(p_fus_device_info_table->DeviceInfoTableState == FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD) + { + /* The FUS is running on CPU2 */ + /** + * Retrieve the WirelessFwInfoTable + * This table is stored in RAM at startup during the TL (transport layer) initialization + */ + wireless_firmware_version = p_fus_device_info_table->WirelessStackVersion; + wireless_firmware_memorySize = p_fus_device_info_table->WirelessStackMemorySize; + wireless_firmware_infoStack = p_fus_device_info_table->WirelessFirmwareBleInfo; + + /** + * Retrieve the FusInfoTable + * This table is stored in RAM at startup during the TL (transport layer) initialization + */ + fus_version = p_fus_device_info_table->FusVersion; + fus_memorySize = p_fus_device_info_table->FusMemorySize; + } + else + { + /* The Wireless Firmware is running on CPU2 */ + p_RefTable = (MB_RefTable_t*)((ipccdba<<2) + SRAM2A_BASE); + + /** + * Retrieve the WirelessFwInfoTable + * This table is stored in RAM at startup during the TL (transport layer) initialization + */ + wireless_firmware_version = p_RefTable->p_device_info_table->WirelessFwInfoTable.Version; + wireless_firmware_memorySize = p_RefTable->p_device_info_table->WirelessFwInfoTable.MemorySize; + wireless_firmware_infoStack = p_RefTable->p_device_info_table->WirelessFwInfoTable.InfoStack; + + /** + * Retrieve the FusInfoTable + * This table is stored in RAM at startup during the TL (transport layer) initialization + */ + fus_version = p_RefTable->p_device_info_table->FusInfoTable.Version; + fus_memorySize = p_RefTable->p_device_info_table->FusInfoTable.MemorySize; + } /** * Retrieve the WirelessFwInfoTable * This table is stored in RAM at startup during the TL (transport layer) initialization */ - version = p_RefTable->p_device_info_table->WirelessFwInfoTable.Version; - pWirelessInfo->VersionMajor = ((version & INFO_VERSION_MAJOR_MASK) >> INFO_VERSION_MAJOR_OFFSET); - pWirelessInfo->VersionMinor = ((version & INFO_VERSION_MINOR_MASK) >> INFO_VERSION_MINOR_OFFSET); - pWirelessInfo->VersionSub = ((version & INFO_VERSION_SUB_MASK) >> INFO_VERSION_SUB_OFFSET); - pWirelessInfo->VersionBranch = ((version & INFO_VERSION_BRANCH_MASK) >> INFO_VERSION_BRANCH_OFFSET); - pWirelessInfo->VersionReleaseType = ((version & INFO_VERSION_TYPE_MASK) >> INFO_VERSION_TYPE_OFFSET); + pWirelessInfo->VersionMajor = ((wireless_firmware_version & INFO_VERSION_MAJOR_MASK) >> INFO_VERSION_MAJOR_OFFSET); + pWirelessInfo->VersionMinor = ((wireless_firmware_version & INFO_VERSION_MINOR_MASK) >> INFO_VERSION_MINOR_OFFSET); + pWirelessInfo->VersionSub = ((wireless_firmware_version & INFO_VERSION_SUB_MASK) >> INFO_VERSION_SUB_OFFSET); + pWirelessInfo->VersionBranch = ((wireless_firmware_version & INFO_VERSION_BRANCH_MASK) >> INFO_VERSION_BRANCH_OFFSET); + pWirelessInfo->VersionReleaseType = ((wireless_firmware_version & INFO_VERSION_TYPE_MASK) >> INFO_VERSION_TYPE_OFFSET); - memorySize = p_RefTable->p_device_info_table->WirelessFwInfoTable.MemorySize; - pWirelessInfo->MemorySizeSram2B = ((memorySize & INFO_SIZE_SRAM2B_MASK) >> INFO_SIZE_SRAM2B_OFFSET); - pWirelessInfo->MemorySizeSram2A = ((memorySize & INFO_SIZE_SRAM2A_MASK) >> INFO_SIZE_SRAM2A_OFFSET); - pWirelessInfo->MemorySizeSram1 = ((memorySize & INFO_SIZE_SRAM1_MASK) >> INFO_SIZE_SRAM1_OFFSET); - pWirelessInfo->MemorySizeFlash = ((memorySize & INFO_SIZE_FLASH_MASK) >> INFO_SIZE_FLASH_OFFSET); + pWirelessInfo->MemorySizeSram2B = ((wireless_firmware_memorySize & INFO_SIZE_SRAM2B_MASK) >> INFO_SIZE_SRAM2B_OFFSET); + pWirelessInfo->MemorySizeSram2A = ((wireless_firmware_memorySize & INFO_SIZE_SRAM2A_MASK) >> INFO_SIZE_SRAM2A_OFFSET); + pWirelessInfo->MemorySizeSram1 = ((wireless_firmware_memorySize & INFO_SIZE_SRAM1_MASK) >> INFO_SIZE_SRAM1_OFFSET); + pWirelessInfo->MemorySizeFlash = ((wireless_firmware_memorySize & INFO_SIZE_FLASH_MASK) >> INFO_SIZE_FLASH_OFFSET); - infoStack = p_RefTable->p_device_info_table->WirelessFwInfoTable.InfoStack; - pWirelessInfo->StackType = ((infoStack & INFO_STACK_TYPE_MASK) >> INFO_STACK_TYPE_OFFSET); + pWirelessInfo->StackType = ((wireless_firmware_infoStack & INFO_STACK_TYPE_MASK) >> INFO_STACK_TYPE_OFFSET); /** * Retrieve the FusInfoTable * This table is stored in RAM at startup during the TL (transport layer) initialization */ - version = p_RefTable->p_device_info_table->FusInfoTable.Version; - pWirelessInfo->FusVersionMajor = ((version & INFO_VERSION_MAJOR_MASK) >> INFO_VERSION_MAJOR_OFFSET); - pWirelessInfo->FusVersionMinor = ((version & INFO_VERSION_MINOR_MASK) >> INFO_VERSION_MINOR_OFFSET); - pWirelessInfo->FusVersionSub = ((version & INFO_VERSION_SUB_MASK) >> INFO_VERSION_SUB_OFFSET); + pWirelessInfo->FusVersionMajor = ((fus_version & INFO_VERSION_MAJOR_MASK) >> INFO_VERSION_MAJOR_OFFSET); + pWirelessInfo->FusVersionMinor = ((fus_version & INFO_VERSION_MINOR_MASK) >> INFO_VERSION_MINOR_OFFSET); + pWirelessInfo->FusVersionSub = ((fus_version & INFO_VERSION_SUB_MASK) >> INFO_VERSION_SUB_OFFSET); - memorySize = p_RefTable->p_device_info_table->FusInfoTable.MemorySize; - pWirelessInfo->FusMemorySizeSram2B = ((memorySize & INFO_SIZE_SRAM2B_MASK) >> INFO_SIZE_SRAM2B_OFFSET); - pWirelessInfo->FusMemorySizeSram2A = ((memorySize & INFO_SIZE_SRAM2A_MASK) >> INFO_SIZE_SRAM2A_OFFSET); - pWirelessInfo->FusMemorySizeFlash = ((memorySize & INFO_SIZE_FLASH_MASK) >> INFO_SIZE_FLASH_OFFSET); + pWirelessInfo->FusMemorySizeSram2B = ((fus_memorySize & INFO_SIZE_SRAM2B_MASK) >> INFO_SIZE_SRAM2B_OFFSET); + pWirelessInfo->FusMemorySizeSram2A = ((fus_memorySize & INFO_SIZE_SRAM2A_MASK) >> INFO_SIZE_SRAM2A_OFFSET); + pWirelessInfo->FusMemorySizeFlash = ((fus_memorySize & INFO_SIZE_FLASH_MASK) >> INFO_SIZE_FLASH_OFFSET); return (SHCI_Success); } -#endif /* STM32WBxx */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h index 11c53ced..c08f056f 100644 --- a/src/utility/STM32Cube_FW/shci.h +++ b/src/utility/STM32Cube_FW/shci.h @@ -4,17 +4,16 @@ * @author MCD Application Team * @brief HCI command for the system channel ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** + * @attention + * + * Copyright (c) 2018-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. + * + ****************************************************************************** */ @@ -35,21 +34,22 @@ extern "C" { typedef enum { WIRELESS_FW_RUNNING = 0x00, - RSS_FW_RUNNING = 0x01, + FUS_FW_RUNNING = 0x01, } SHCI_SysEvt_Ready_Rsp_t; /* ERROR CODES * - * These error codes are detected on M0 side and are send back to the M4 via a system - * notification message. It is up to the application running on M4 to manage these errors + * These error codes are detected on CPU2 side and are send back to the CPU1 via a system + * notification message. It is up to the application running on CPU1 to manage these errors * * These errors can be generated by all layers (low level driver, stack, framework infrastructure, etc..) */ typedef enum { - ERR_BLE_INIT = 0, - ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ - ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the M4 to control the Thread stack is unknown */ + ERR_BLE_INIT = 0, /* This event is currently not reported by the CPU2 */ + ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ + ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the CPU1 to control the Thread stack is unknown */ + ERR_ZIGBEE_UNKNOWN_CMD = 200, /* The command send by the CPU1 to control the Zigbee stack is unknown */ } SCHI_SystemErrCode_t; #define SHCI_EVTCODE ( 0xFF ) @@ -63,11 +63,12 @@ extern "C" { SHCI_SUB_EVT_CODE_READY = SHCI_SUB_EVT_CODE_BASE, SHCI_SUB_EVT_ERROR_NOTIF, SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE, - SHCI_SUB_EVT_OT_NVM_RAM_UPDATE, + SHCI_SUB_EVT_THREAD_NVM_RAM_UPDATE, SHCI_SUB_EVT_NVM_START_WRITE, SHCI_SUB_EVT_NVM_END_WRITE, SHCI_SUB_EVT_NVM_START_ERASE, SHCI_SUB_EVT_NVM_END_ERASE, + SHCI_SUB_EVT_CODE_CONCURRENT_802154_EVT, } SHCI_SUB_EVT_CODE_t; /** @@ -100,8 +101,8 @@ extern "C" { } SHCI_C2_BleNvmRamUpdate_Evt_t; /** - * SHCI_SUB_EVT_OT_NVM_RAM_UPDATE - * This notifies the CPU1 which part of the 'OT NVM RAM' has been updated so that only the modified + * SHCI_SUB_EVT_THREAD_NVM_RAM_UPDATE + * This notifies the CPU1 which part of the OT NVM RAM has been updated so that only the modified * section could be written in Flash/NVM * StartAddress : Start address of the section that has been modified * Size : Size (in bytes) of the section that has been modified @@ -109,7 +110,7 @@ extern "C" { typedef PACKED_STRUCT{ uint32_t StartAddress; uint32_t Size; - } SHCI_C2_OtNvmRamUpdate_Evt_t; + } SHCI_C2_ThreadNvmRamUpdate_Evt_t; /** * SHCI_SUB_EVT_NVM_START_WRITE @@ -150,6 +151,11 @@ extern "C" { /* SYSTEM COMMAND */ typedef PACKED_STRUCT { + /** + * MetaData holds : + * 2*32bits for chaining list + * 1*32bits with BLE header (type + Opcode + Length) + */ uint32_t MetaData[3]; } SHCI_Header_t; @@ -159,6 +165,7 @@ extern "C" { SHCI_UNKNOWN_CMD = 0x01, SHCI_ERR_UNSUPPORTED_FEATURE = 0x11, SHCI_ERR_INVALID_HCI_CMD_PARAMS = 0x12, + SHCI_ERR_INVALID_PARAMS = 0x42, SHCI_FUS_CMD_NOT_SUPPORTED = 0xFF, } SHCI_CmdStatus_t; @@ -191,8 +198,8 @@ extern "C" { SHCI_OCF_C2_FUS_RESERVED2, SHCI_OCF_C2_FUS_RESERVED3, SHCI_OCF_C2_FUS_LOCK_USR_KEY, - SHCI_OCF_C2_FUS_RESERVED5, - SHCI_OCF_C2_FUS_RESERVED6, + SHCI_OCF_C2_FUS_UNLOAD_USR_KEY, + SHCI_OCF_C2_FUS_ACTIVATE_ANTIROLLBACK, SHCI_OCF_C2_FUS_RESERVED7, SHCI_OCF_C2_FUS_RESERVED8, SHCI_OCF_C2_FUS_RESERVED9, @@ -207,27 +214,53 @@ extern "C" { SHCI_OCF_C2_FLASH_STORE_DATA, SHCI_OCF_C2_FLASH_ERASE_DATA, SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, + SHCI_OCF_C2_MAC_802_15_4_INIT, SHCI_OCF_C2_REINIT, + SHCI_OCF_C2_ZIGBEE_INIT, SHCI_OCF_C2_LLD_TESTS_INIT, SHCI_OCF_C2_EXTPA_CONFIG, SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, - SHCI_OCF_C2_LLD_BLE_INIT, - SHCI_OCF_C2_CONFIG, + SHCI_OCF_C2_BLE_LLD_INIT, + SHCI_OCF_C2_CONFIG, + SHCI_OCF_C2_CONCURRENT_GET_NEXT_BLE_EVT_TIME, + SHCI_OCF_C2_CONCURRENT_ENABLE_NEXT_802154_EVT_NOTIFICATION, + SHCI_OCF_C2_802_15_4_DEINIT, } SHCI_OCF_t; #define SHCI_OPCODE_C2_FUS_GET_STATE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_GET_STATE) /** No command parameters */ /** Response parameters*/ +/** It responds a 1 byte value holding FUS State error code when the FUS State value is 0xFF (FUS_STATE_VALUE_ERROR) */ typedef enum { - FUS_STATE_NO_ERROR = 0x00, - FUS_STATE_IMG_NOT_FOUND = 0x01, - FUS_STATE_IMG_CORRUPT = 0x02, - FUS_STATE_IMG_NOT_AUTHENTIC = 0x03, - FUS_STATE_IMG_NOT_ENOUGH_SPACE = 0x04, - FUS_STATE_ERR_UNKNOWN = 0xFF, + FUS_STATE_ERROR_NO_ERROR = 0x00, + FUS_STATE_ERROR_IMG_NOT_FOUND = 0x01, + FUS_STATE_ERROR_IMG_CORRUPT = 0x02, + FUS_STATE_ERROR_IMG_NOT_AUTHENTIC = 0x03, + FUS_STATE_ERROR_IMG_NOT_ENOUGH_SPACE = 0x04, + FUS_STATE_ERROR_IMAGE_USRABORT = 0x05, + FUS_STATE_ERROR_IMAGE_ERSERROR = 0x06, + FUS_STATE_ERROR_IMAGE_WRTERROR = 0x07, + FUS_STATE_ERROR_AUTH_TAG_ST_NOTFOUND = 0x08, + FUS_STATE_ERROR_AUTH_TAG_CUST_NOTFOUND = 0x09, + FUS_STATE_ERROR_AUTH_KEY_LOCKED = 0x0A, + FUS_STATE_ERROR_FW_ROLLBACK_ERROR = 0x11, + FUS_STATE_ERROR_STATE_NOT_RUNNING = 0xFE, + FUS_STATE_ERROR_ERR_UNKNOWN = 0xFF, } SHCI_FUS_GetState_ErrorCode_t; + enum + { + FUS_STATE_VALUE_IDLE = 0x00, + FUS_STATE_VALUE_FW_UPGRD_ONGOING = 0x10, + FUS_STATE_VALUE_FW_UPGRD_ONGOING_END = 0x1F, /* All values between 0x10 and 0x1F has the same meaning */ + FUS_STATE_VALUE_FUS_UPGRD_ONGOING = 0x20, + FUS_STATE_VALUE_FUS_UPGRD_ONGOING_END = 0x2F, /* All values between 0x20 and 0x2F has the same meaning */ + FUS_STATE_VALUE_SERVICE_ONGOING = 0x30, + FUS_STATE_VALUE_SERVICE_ONGOING_END = 0x3F, /* All values between 0x30 and 0x3F has the same meaning */ + FUS_STATE_VALUE_ERROR = 0xFF, + }; + #define SHCI_OPCODE_C2_FUS_RESERVED1 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED1) /** No command parameters */ /** No response parameters*/ @@ -303,11 +336,11 @@ extern "C" { /** No response parameters*/ -#define SHCI_OPCODE_C2_FUS_RESERVED5 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED5) +#define SHCI_OPCODE_C2_FUS_UNLOAD_USR_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_UNLOAD_USR_KEY) /** No command parameters */ -/** No response parameters*/ +/** 1 byte holding the key index value */ -#define SHCI_OPCODE_C2_FUS_RESERVED6 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED6) +#define SHCI_OPCODE_C2_FUS_ACTIVATE_ANTIROLLBACK (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_ACTIVATE_ANTIROLLBACK) /** No command parameters */ /** No response parameters*/ @@ -338,32 +371,238 @@ extern "C" { #define SHCI_OPCODE_C2_BLE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_INIT) /** THE ORDER SHALL NOT BE CHANGED */ typedef PACKED_STRUCT{ - uint8_t* pBleBufferAddress; /**< NOT USED CURRENTLY */ - uint32_t BleBufferSize; /**< Size of the Buffer allocated in pBleBufferAddress */ + uint8_t* pBleBufferAddress; /**< NOT USED - shall be set to 0 */ + uint32_t BleBufferSize; /**< NOT USED - shall be set to 0 */ + + /** + * NumAttrRecord + * Maximum number of attribute records related to all the required characteristics (excluding the services) + * that can be stored in the GATT database, for the specific BLE user application. + * For each characteristic, the number of attribute records goes from two to five depending on the characteristic properties: + * - minimum of two (one for declaration and one for the value) + * - add one more record for each additional property: notify or indicate, broadcast, extended property. + * The total calculated value must be increased by 9, due to the records related to the standard attribute profile and + * GAP service characteristics, and automatically added when initializing GATT and GAP layers + * - Min value: + 9 + * - Max value: depending on the GATT database defined by user application + */ uint16_t NumAttrRecord; + + /** + * NumAttrServ + * Defines the maximum number of services that can be stored in the GATT database. Note that the GAP and GATT services + * are automatically added at initialization so this parameter must be the number of user services increased by two. + * - Min value: + 2 + * - Max value: depending GATT database defined by user application + */ uint16_t NumAttrServ; + + /** + * AttrValueArrSize + * NOTE: This parameter is ignored by the CPU2 when the parameter "Options" is set to "LL_only" ( see Options description in that structure ) + * + * Size of the storage area for the attribute values. + * Each characteristic contributes to the attrValueArrSize value as follows: + * - Characteristic value length plus: + * + 5 bytes if characteristic UUID is 16 bits + * + 19 bytes if characteristic UUID is 128 bits + * + 2 bytes if characteristic has a server configuration descriptor + * + 2 bytes * NumOfLinks if the characteristic has a client configuration descriptor + * + 2 bytes if the characteristic has extended properties + * Each descriptor contributes to the attrValueArrSize value as follows: + * - Descriptor length + */ uint16_t AttrValueArrSize; + + /** + * NumOfLinks + * Maximum number of BLE links supported + * - Min value: 1 + * - Max value: 8 + */ uint8_t NumOfLinks; + + /** + * ExtendedPacketLengthEnable + * Disable/enable the extended packet length BLE 5.0 feature + * - Disable: 0 + * - Enable: 1 + */ uint8_t ExtendedPacketLengthEnable; + + /** + * PrWriteListSize + * NOTE: This parameter is ignored by the CPU2 when the parameter "Options" is set to "LL_only" ( see Options description in that structure ) + * + * Maximum number of supported “prepare write request” + * - Min value: given by the macro DEFAULT_PREP_WRITE_LIST_SIZE + * - Max value: a value higher than the minimum required can be specified, but it is not recommended + */ uint8_t PrWriteListSize; + + /** + * MblockCount + * NOTE: This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter "Options" is set to "LL_only" + * ( see Options description in that structure ) + * + * Number of allocated memory blocks for the BLE stack + * - Min value: given by the macro MBLOCKS_CALC + * - Max value: a higher value can improve data throughput performance, but uses more memory + */ uint8_t MblockCount; + + /** + * AttMtu + * NOTE: This parameter is ignored by the CPU2 when the parameter "Options" is set to "LL_only" ( see Options description in that structure ) + * + * Maximum ATT MTU size supported + * - Min value: 23 + * - Max value: 512 + */ uint16_t AttMtu; + + /** + * SlaveSca + * The sleep clock accuracy (ppm value) that used in BLE connected slave mode to calculate the window widening + * (in combination with the sleep clock accuracy sent by master in CONNECT_REQ PDU), + * refer to BLE 5.0 specifications - Vol 6 - Part B - chap 4.5.7 and 4.2.2 + * - Min value: 0 + * - Max value: 500 (worst possible admitted by specification) + */ uint16_t SlaveSca; + + /** + * MasterSca + * The sleep clock accuracy handled in master mode. It is used to determine the connection and advertising events timing. + * It is transmitted to the slave in CONNEC_REQ PDU used by the slave to calculate the window widening, + * see SlaveSca and Bluetooth Core Specification v5.0 Vol 6 - Part B - chap 4.5.7 and 4.2.2 + * Possible values: + * - 251 ppm to 500 ppm: 0 + * - 151 ppm to 250 ppm: 1 + * - 101 ppm to 150 ppm: 2 + * - 76 ppm to 100 ppm: 3 + * - 51 ppm to 75 ppm: 4 + * - 31 ppm to 50 ppm: 5 + * - 21 ppm to 30 ppm: 6 + * - 0 ppm to 20 ppm: 7 + */ uint8_t MasterSca; + + /** + * LsSource + * Source for the 32 kHz slow speed clock. + * - External crystal LSE: 0 - No calibration + * - Others:1 - As the accuracy of this oscillator can vary depending upon external conditions (temperature), + * it is calibrated every second to ensure correct behavior of timing sensitive BLE operations + */ uint8_t LsSource; + + /** + * MaxConnEventLength + * This parameter determines the maximum duration of a slave connection event. When this duration is reached the slave closes + * the current connections event (whatever is the CE_length parameter specified by the master in HCI_CREATE_CONNECTION HCI command), + * expressed in units of 625/256 µs (~2.44 µs) + * - Min value: 0 (if 0 is specified, the master and slave perform only a single TX-RX exchange per connection event) + * - Max value: 1638400 (4000 ms). A higher value can be specified (max 0xFFFFFFFF) but results in a maximum connection time + * of 4000 ms as specified. In this case the parameter is not applied, and the predicted CE length calculated on slave is not shortened + */ uint32_t MaxConnEventLength; + + /** + * HsStartupTime + * Startup time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 µs (~2.44 µs). + * - Min value: 0 + * - Max value: 820 (~2 ms). A higher value can be specified, but the value that implemented in stack is forced to ~2 ms + */ uint16_t HsStartupTime; + + /** + * ViterbiEnable + * Viterbi implementation in BLE LL reception. + * - 0: Enable + * - 1: Disable + */ uint8_t ViterbiEnable; - uint8_t LlOnly; + + /** + * Options flags + * - bit 0: 1: LL only 0: LL + host + * - bit 1: 1: no service change desc. 0: with service change desc. + * - bit 2: 1: device name Read-Only 0: device name R/W + * - bit 3: 1: extended advertizing supported 0: extended advertizing not supported [NOT SUPPORTED] + * - bit 4: 1: CS Algo #2 supported 0: CS Algo #2 not supported + * - bit 7: 1: LE Power Class 1 0: LE Power Classe 2-3 + * - other bits: reserved ( shall be set to 0) + */ + uint8_t Options; + + /** + * HwVersion + * Reserved for future use - shall be set to 0 + */ uint8_t HwVersion; - } SHCI_C2_Ble_Init_Cmd_Param_t; + + /** + * Maximum number of connection-oriented channels in initiator mode. + * Range: 0 .. 64 + */ + uint8_t max_coc_initiator_nbr; + + /** + * Minimum transmit power in dBm supported by the Controller. + * Range: -127 .. 20 + */ + int8_t min_tx_power; + + /** + * Maximum transmit power in dBm supported by the Controller. + * Range: -127 .. 20 + */ + int8_t max_tx_power; + + /** + * RX model configuration + * - bit 0: 1: agc_rssi model improved vs RF blockers 0: Legacy agc_rssi model + * - other bits: reserved ( shall be set to 0) + */ + uint8_t rx_model_config; + + } SHCI_C2_Ble_Init_Cmd_Param_t; typedef PACKED_STRUCT{ SHCI_Header_t Header; /** Does not need to be initialized by the user */ SHCI_C2_Ble_Init_Cmd_Param_t Param; } SHCI_C2_Ble_Init_Cmd_Packet_t; - /** No response parameters*/ + /** + * Options + * Each definition below may be added together to build the Options value + * WARNING : Only one definition per bit shall be added to build the Options value + */ +#define SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY (1<<0) +#define SHCI_C2_BLE_INIT_OPTIONS_LL_HOST (0<<0) + +#define SHCI_C2_BLE_INIT_OPTIONS_NO_SVC_CHANGE_DESC (1<<1) +#define SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC (0<<1) + +#define SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RO (1<<2) +#define SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW (0<<2) + +#define SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV (1<<3) /*NOT SUPPORTED*/ +#define SHCI_C2_BLE_INIT_OPTIONS_NO_EXT_ADV (0<<3) /*NOT SUPPORTED*/ + +#define SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 (1<<4) +#define SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2 (0<<4) + +#define SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_1 (1<<7) +#define SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3 (0<<7) + + /** + * RX models configuration + */ +#define SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY (0<<0) +#define SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_BLOCKER (1<<0) + #define SHCI_OPCODE_C2_THREAD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_THREAD_INIT) /** No command parameters */ @@ -375,12 +614,21 @@ extern "C" { { uint8_t thread_config; uint8_t ble_config; + uint8_t mac_802_15_4_config; + uint8_t zigbee_config; } SHCI_C2_DEBUG_TracesConfig_t; typedef PACKED_STRUCT { uint8_t ble_dtb_cfg; - uint8_t reserved[3]; + /** + * sys_dbg_cfg1 options flag + * - bit 0: 0: IP BLE core in LP mode 1: IP BLE core in run mode (no LP supported) + * - bit 1: 0: CPU2 STOP mode Enable 1: CPU2 STOP mode Disable + * - bit [2-7]: bits reserved ( shall be set to 0) + */ + uint8_t sys_dbg_cfg1; + uint8_t reserved[2]; } SHCI_C2_DEBUG_GeneralConfig_t; typedef PACKED_STRUCT{ @@ -398,6 +646,18 @@ extern "C" { } SHCI_C2_DEBUG_Init_Cmd_Packet_t; /** No response parameters*/ + /** + * Options + * Each definition below may be added together to build the Options value + * WARNING : Only one definition per bit shall be added to build the Options value + */ +#define SHCI_C2_DEBUG_OPTIONS_IPCORE_LP (0<<0) +#define SHCI_C2_DEBUG_OPTIONS_IPCORE_NO_LP (1<<0) + +#define SHCI_C2_DEBUG_OPTIONS_CPU2_STOP_EN (0<<1) +#define SHCI_C2_DEBUG_OPTIONS_CPU2_STOP_DIS (1<<1) + + #define SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_ERASE_ACTIVITY) /** Command parameters */ typedef enum @@ -414,9 +674,23 @@ extern "C" { { BLE_ENABLE, THREAD_ENABLE, + ZIGBEE_ENABLE, + MAC_ENABLE, } SHCI_C2_CONCURRENT_Mode_Param_t; /** No response parameters*/ +#define SHCI_OPCODE_C2_CONCURRENT_GET_NEXT_BLE_EVT_TIME (( SHCI_OGF << 10) + SHCI_OCF_C2_CONCURRENT_GET_NEXT_BLE_EVT_TIME) +/** command parameters */ + typedef PACKED_STRUCT + { + uint32_t relative_time; + } SHCI_C2_CONCURRENT_GetNextBleEvtTime_Param_t; + /** No response parameters*/ + +#define SHCI_OPCODE_C2_CONCURRENT_ENABLE_NEXT_802154_EVT_NOTIFICATION (( SHCI_OGF << 10) + SHCI_OCF_C2_CONCURRENT_ENABLE_NEXT_802154_EVT_NOTIFICATION) + /** No command parameters */ + /** No response parameters*/ + #define SHCI_OPCODE_C2_FLASH_STORE_DATA (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_STORE_DATA) #define SHCI_OPCODE_C2_FLASH_ERASE_DATA (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_ERASE_DATA) /** command parameters */ @@ -424,16 +698,21 @@ extern "C" { { BLE_IP, THREAD_IP, + ZIGBEE_IP, } SHCI_C2_FLASH_Ip_t; /** No response parameters*/ #define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) +#define SHCI_OPCODE_C2_MAC_802_15_4_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_MAC_802_15_4_INIT) + #define SHCI_OPCODE_C2_REINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_REINIT) +#define SHCI_OPCODE_C2_ZIGBEE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_ZIGBEE_INIT) + #define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) -#define SHCI_OPCODE_C2_LLD_BLE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_BLE_INIT) +#define SHCI_OPCODE_C2_BLE_LLD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_LLD_INIT) #define SHCI_OPCODE_C2_EXTPA_CONFIG (( SHCI_OGF << 10) + SHCI_OCF_C2_EXTPA_CONFIG) /** Command parameters */ @@ -477,14 +756,24 @@ extern "C" { uint8_t Spare1; uint32_t BleNvmRamAddress; uint32_t ThreadNvmRamAddress; + uint16_t RevisionID; } SHCI_C2_CONFIG_Cmd_Param_t; +#define SHCI_OPCODE_C2_802_15_4_DEINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_802_15_4_DEINIT) + /** * PayloadCmdSize * Value that shall be used */ #define SHCI_C2_CONFIG_PAYLOAD_CMD_SIZE (sizeof(SHCI_C2_CONFIG_Cmd_Param_t) - 1) +/** + * Device revision ID + */ +#define SHCI_C2_CONFIG_CUT2_0 (0x2000) +#define SHCI_C2_CONFIG_CUT2_1 (0x2001) +#define SHCI_C2_CONFIG_CUT2_2 (0x2003) + /** * Config1 * Each definition below may be added together to build the Config1 value @@ -501,7 +790,7 @@ extern "C" { */ #define SHCI_C2_CONFIG_EVTMASK1_BIT0_ERROR_NOTIF_ENABLE (1<<0) #define SHCI_C2_CONFIG_EVTMASK1_BIT1_BLE_NVM_RAM_UPDATE_ENABLE (1<<1) -#define SHCI_C2_CONFIG_EVTMASK1_BIT2_OT_NVM_RAM_UPDATE_ENABLE (1<<2) +#define SHCI_C2_CONFIG_EVTMASK1_BIT2_THREAD_NVM_RAM_UPDATE_ENABLE (1<<2) #define SHCI_C2_CONFIG_EVTMASK1_BIT3_NVM_START_WRITE_ENABLE (1<<3) #define SHCI_C2_CONFIG_EVTMASK1_BIT4_NVM_END_WRITE_ENABLE (1<<4) #define SHCI_C2_CONFIG_EVTMASK1_BIT5_NVM_START_ERASE_ENABLE (1<<5) @@ -525,18 +814,17 @@ extern "C" { /** No response parameters*/ /* Exported type --------------------------------------------------------*/ - -typedef MB_WirelessFwInfoTable_t SHCI_WirelessFwInfoTable_t; +#define FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD (0xA94656B9) /* - * At startup, the information relative to the wireless binary are stored in RAM through a structure defined by - * SHCI_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) + * At startup, the informations relative to the wireless binary are stored in RAM trough a structure defined by + * MB_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) * each of those coded on 32 bits as shown on the table below: * * * |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 |7 |6 |5 |4 |3 |2 |1 |0 | * ------------------------------------------------------------------------------------------------- - * Version | Major version | Minor version | Sub version | Branch |Release Type| + * Version | Major version | Minor version | Sub version | Branch |ReleaseType| * ------------------------------------------------------------------------------------------------- * MemorySize | SRAM2B (kB) | SRAM2A (kB) | SRAM1 (kB) | FLASH (4kb) | * ------------------------------------------------------------------------------------------------- @@ -576,17 +864,29 @@ typedef MB_WirelessFwInfoTable_t SHCI_WirelessFwInfoTable_t; #define INFO_STACK_TYPE_MASK 0x000000ff #define INFO_STACK_TYPE_NONE 0 -#define INFO_STACK_TYPE_BLE_STANDARD 0x01 +#define INFO_STACK_TYPE_BLE_FULL 0x01 #define INFO_STACK_TYPE_BLE_HCI 0x02 #define INFO_STACK_TYPE_BLE_LIGHT 0x03 +#define INFO_STACK_TYPE_BLE_BEACON 0x04 #define INFO_STACK_TYPE_THREAD_FTD 0x10 #define INFO_STACK_TYPE_THREAD_MTD 0x11 +#define INFO_STACK_TYPE_ZIGBEE_FFD 0x30 +#define INFO_STACK_TYPE_ZIGBEE_RFD 0x31 +#define INFO_STACK_TYPE_MAC 0x40 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 -#define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 +#define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 +#define INFO_STACK_TYPE_802154_LLD_TESTS 0x60 +#define INFO_STACK_TYPE_802154_PHY_VALID 0x61 #define INFO_STACK_TYPE_BLE_PHY_VALID 0x62 #define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 #define INFO_STACK_TYPE_BLE_RLV 0x64 +#define INFO_STACK_TYPE_802154_RLV 0x65 +#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_STATIC 0x70 +#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_STATIC 0x71 +#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_DYNAMIC 0x78 +#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_DYNAMIC 0x79 #define INFO_STACK_TYPE_RLV 0x80 +#define INFO_STACK_TYPE_BLE_MAC_STATIC 0x90 typedef struct { /** @@ -616,18 +916,16 @@ typedef struct { /* Exported functions ------------------------------------------------------- */ -/** - * For all SHCI_C2_FUS_xxx() command: - * When the wireless FW is running on the CPU2, the command returns SHCI_FUS_CMD_NOT_SUPPORTED - * When any FUS command is sent after the SHCI_FUS_CMD_NOT_SUPPORTED has been received, - * the CPU2 switches on the RSS ( This reboots automatically the device ) - */ /** * SHCI_C2_FUS_GetState * @brief Read the FUS State * If the user is not interested by the Error code response, a null value may * be passed as parameter * + * Note: This command is fully supported only by the FUS. + * When the wireless firmware receives that command, it responds SHCI_FUS_CMD_NOT_SUPPORTED the first time. + * When the wireless firmware receives that command a second time, it reboots the full device with the FUS running on CPU2 + * * @param p_rsp : return the error code when the FUS State Value = 0xFF * @retval FUS State Values */ @@ -636,6 +934,7 @@ typedef struct { /** * SHCI_C2_FUS_FwUpgrade * @brief Request the FUS to install the CPU2 firmware update + * Note: This command is only supported by the FUS. * * @param fw_src_add: Address of the firmware image location * @param fw_dest_add: Address of the firmware destination @@ -646,6 +945,7 @@ typedef struct { /** * SHCI_C2_FUS_FwDelete * @brief Delete the wireless stack on CPU2 + * Note: This command is only supported by the FUS. * * @param None * @retval Status @@ -655,6 +955,7 @@ typedef struct { /** * SHCI_C2_FUS_UpdateAuthKey * @brief Request the FUS to update the authentication key + * Note: This command is only supported by the FUS. * * @param pCmdPacket * @retval Status @@ -664,6 +965,7 @@ typedef struct { /** * SHCI_C2_FUS_LockAuthKey * @brief Request the FUS to prevent any future update of the authentication key + * Note: This command is only supported by the FUS. * * @param None * @retval Status @@ -673,6 +975,7 @@ typedef struct { /** * SHCI_C2_FUS_StoreUsrKey * @brief Request the FUS to store the user key + * Note: This command is supported by both the FUS and the wireless stack. * * @param pParam : command parameter * @param p_key_index : Index allocated by the FUS to the stored key @@ -684,6 +987,7 @@ typedef struct { /** * SHCI_C2_FUS_LoadUsrKey * @brief Request the FUS to load the user key into the AES + * Note: This command is supported by both the FUS and the wireless stack. * * @param key_index : index of the user key to load in AES1 * @retval Status @@ -693,6 +997,7 @@ typedef struct { /** * SHCI_C2_FUS_StartWs * @brief Request the FUS to reboot on the wireless stack + * Note: This command is only supported by the FUS. * * @param None * @retval Status @@ -702,17 +1007,41 @@ typedef struct { /** * SHCI_C2_FUS_LockUsrKey * @brief Request the FUS to lock the user key so that it cannot be updated later on + * Note: This command is supported by both the FUS and the wireless stack. * * @param key_index : index of the user key to lock * @retval Status */ SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey( uint8_t key_index ); + /** + * SHCI_C2_FUS_UnloadUsrKey + * @brief Request the FUS to Unload the user key so that the CPU1 may use the AES with another Key + * Note: This command is supported by both the FUS and the wireless stack. + * + * @param key_index : index of the user key to unload + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_UnloadUsrKey( uint8_t key_index ); + + /** + * SHCI_C2_FUS_ActivateAntiRollback + * @brief Request the FUS to enable the AntiRollback feature so that it is not possible to update the wireless firmware + * with an older version than the current one. + * Note: + * - This command is only supported by the FUS. + * - Once this feature is enabled, it is not possible anymore to disable it. + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_ActivateAntiRollback( void ); + /** * SHCI_C2_BLE_Init * @brief Provides parameters and starts the BLE Stack * - * @param pCmdPacket : Parameters to be provided to the BLE Stack + * @param pCmdPacket : Parameters are described SHCI_C2_Ble_Init_Cmd_Packet_t declaration * @retval Status */ SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket ); @@ -731,20 +1060,29 @@ typedef struct { * @brief Starts the LLD tests CLI * * @param param_size : Nb of bytes - * @param p_param : pointer with data to give from M4 to M0 + * @param p_param : pointeur with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ); /** - * SHCI_C2_LLD_BLE_Init - * @brief Starts the LLD tests CLI + * SHCI_C2_BLE_LLD_Init + * @brief Starts the LLD tests BLE * * @param param_size : Nb of bytes - * @param p_param : pointer with data to give from M4 to M0 + * @param p_param : pointeur with data to give from M4 to M0 * @retval Status */ - SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init( uint8_t param_size, uint8_t * p_param ); + SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ); + + /** + * SHCI_C2_ZIGBEE_Init + * @brief Starts the Zigbee Stack + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ); /** * SHCI_C2_DEBUG_Init @@ -758,6 +1096,7 @@ typedef struct { /** * SHCI_C2_FLASH_EraseActivity * @brief Provides the information of the start and the end of a flash erase window on the CPU1 + * The protection will be active until next end of radio event. * * @param erase_activity: Start/End of erase activity * @retval Status @@ -773,6 +1112,24 @@ typedef struct { */ SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mode ); + /** + * SHCI_C2_CONCURRENT_GetNextBleEvtTime + * @brief Get the next BLE event date (relative time) + * + * @param Command Packet + * @retval None + */ + SHCI_CmdStatus_t SHCI_C2_CONCURRENT_GetNextBleEvtTime( SHCI_C2_CONCURRENT_GetNextBleEvtTime_Param_t *pParam ); + + /** + * SHCI_C2_CONCURRENT_EnableNext_802154_EvtNotification + * @brief Activate the next 802.15.4 event notification (one shot) + * + * @param None + * @retval None + */ + SHCI_CmdStatus_t SHCI_C2_CONCURRENT_EnableNext_802154_EvtNotification( void ); + /** * SHCI_C2_FLASH_StoreData * @brief Store Data in Flash @@ -801,10 +1158,20 @@ typedef struct { */ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn); + + /** + * SHCI_C2_MAC_802_15_4_Init + * @brief Starts the MAC 802.15.4 on M0 + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ); + /** * SHCI_GetWirelessFwInfo - * @brief This function read back the information relative to the wireless binary loaded. - * Refer yourself to SHCI_WirelessFwInfoTable_t structure to get the significance + * @brief This function read back the informations relative to the wireless binary loaded. + * Refer yourself to MB_WirelessFwInfoTable_t structure to get the significance * of the different parameters returned. * @param pWirelessInfo : Pointer to WirelessFwInfo_t. * @@ -897,10 +1264,18 @@ typedef struct { */ SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket); + /** + * SHCI_C2_802_15_4_DeInit + * @brief Deinit 802.15.4 layer (to be used before entering StandBy mode) + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_802_15_4_DeInit( void ); + #ifdef __cplusplus } #endif #endif /*__SHCI_H */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index 8d4d4ff4..449b8b16 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -4,53 +4,24 @@ * @author MCD Application Team * @brief System HCI command implementation ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** + * @attention + * + * Copyright (c) 2018-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. + * + ****************************************************************************** */ -#if defined(STM32WBxx) + /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" -#include - #include "stm_list.h" #include "shci_tl.h" -#include "stm32_def.h" - -/** - * These traces are not yet supported in an usual way in the delivery package - * They can enabled by adding the definition of TL_SHCI_CMD_DBG_EN and/or TL_SHCI_EVT_DBG_EN in the preprocessor option in the IDE - */ -#if ( (TL_SHCI_CMD_DBG_EN != 0) || (TL_SHCI_EVT_DBG_EN != 0) ) -#include "app_conf.h" -#include "dbg_trace.h" -#endif - -#if (TL_SHCI_CMD_DBG_EN != 0) -#define TL_SHCI_CMD_DBG_MSG PRINT_MESG_DBG -#define TL_SHCI_CMD_DBG_BUF PRINT_LOG_BUFF_DBG -#else -#define TL_SHCI_CMD_DBG_MSG(...) -#define TL_SHCI_CMD_DBG_BUF(...) -#endif - -#if (TL_SHCI_EVT_DBG_EN != 0) -#define TL_SHCI_EVT_DBG_MSG PRINT_MESG_DBG -#define TL_SHCI_EVT_DBG_BUF PRINT_LOG_BUFF_DBG -#else -#define TL_SHCI_EVT_DBG_MSG(...) -#define TL_SHCI_EVT_DBG_BUF(...) -#endif /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -89,9 +60,6 @@ static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus); static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt); static void TlUserEvtReceived(TL_EvtPacket_t *shcievt); static void TlInit( TL_CmdPacket_t * p_cmdbuffer ); -static void OutputCmdTrace(TL_CmdPacket_t *pCmdBuffer); -static void OutputRspTrace(TL_EvtPacket_t *p_rsp); -static void OutputEvtTrace(TL_EvtPacket_t *phcievtbuffer); /* Interface ------- ---------------------------------------------------------*/ void shci_init(void(* UserEvtRx)(void* pData), void* pConf) @@ -129,8 +97,6 @@ void shci_user_evt_proc(void) { LST_remove_head ( &SHciAsynchEventQueue, (tListNode **)&phcievtbuffer ); - OutputEvtTrace(phcievtbuffer); - if (shciContext.UserEvtRx != NULL) { UserEvtRxParam.pckt = phcievtbuffer; @@ -187,8 +153,6 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl memcpy(pCmdBuffer->cmdserial.cmd.payload, p_cmd_payload, len_cmd_payload ); - OutputCmdTrace(pCmdBuffer); - shciContext.io.Send(0,0); shci_cmd_resp_wait(SHCI_TL_DEFAULT_TIMEOUT); @@ -199,27 +163,11 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl */ memcpy( &(p_rsp->evtserial), pCmdBuffer, ((TL_EvtSerial_t*)pCmdBuffer)->evt.plen + TL_EVT_HDR_SIZE ); - OutputRspTrace(p_rsp); - Cmd_SetStatus(SHCI_TL_CmdAvailable); 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 ) { @@ -284,76 +232,14 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) return; } -static void OutputCmdTrace(TL_CmdPacket_t *pCmdBuffer) -{ - TL_SHCI_CMD_DBG_MSG("sys cmd: 0x%04X", pCmdBuffer->cmdserial.cmd.cmdcode); - - if(pCmdBuffer->cmdserial.cmd.plen != 0) - { - TL_SHCI_CMD_DBG_MSG(" payload:"); - TL_SHCI_CMD_DBG_BUF(pCmdBuffer->cmdserial.cmd.payload, pCmdBuffer->cmdserial.cmd.plen, ""); - } - TL_SHCI_CMD_DBG_MSG("\r\n"); - - return; -} - -static void OutputRspTrace(TL_EvtPacket_t *p_rsp) -{ - switch(p_rsp->evtserial.evt.evtcode) - { - case TL_BLEEVT_CC_OPCODE: - TL_SHCI_CMD_DBG_MSG("sys rsp: 0x%02X", p_rsp->evtserial.evt.evtcode); - TL_SHCI_CMD_DBG_MSG(" cmd opcode: 0x%02X", ((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->cmdcode); - TL_SHCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); - if((p_rsp->evtserial.evt.plen-4) != 0) - { - TL_SHCI_CMD_DBG_MSG(" payload:"); - TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1], p_rsp->evtserial.evt.plen-4, ""); - } - break; - - default: - TL_SHCI_CMD_DBG_MSG("unknown sys rsp received: %02X", p_rsp->evtserial.evt.evtcode); - break; - } - - TL_SHCI_CMD_DBG_MSG("\r\n"); - - return; -} - -static void OutputEvtTrace(TL_EvtPacket_t *phcievtbuffer) -{ - if(phcievtbuffer->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) - { - TL_SHCI_EVT_DBG_MSG("unknown sys evt received: %02X", phcievtbuffer->evtserial.evt.evtcode); - } - else - { - TL_SHCI_EVT_DBG_MSG("sys evt: 0x%02X", phcievtbuffer->evtserial.evt.evtcode); - TL_SHCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(phcievtbuffer->evtserial.evt.payload))->subevtcode); - if((phcievtbuffer->evtserial.evt.plen-2) != 0) - { - TL_SHCI_EVT_DBG_MSG(" payload:"); - TL_SHCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(phcievtbuffer->evtserial.evt.payload))->payload, phcievtbuffer->evtserial.evt.plen-2, ""); - } - } - - TL_SHCI_EVT_DBG_MSG("\r\n"); - - return; -} - /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { + (void)timeout; + CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; - for (unsigned long start = millis(); (millis() - start) < timeout;) { - if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { - break; - } - } + while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); + return; } @@ -366,4 +252,3 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/shci_tl.h b/src/utility/STM32Cube_FW/shci_tl.h index 3fbc492f..74d0ff38 100644 --- a/src/utility/STM32Cube_FW/shci_tl.h +++ b/src/utility/STM32Cube_FW/shci_tl.h @@ -4,20 +4,18 @@ * @author MCD Application Team * @brief System HCI command header for the system channel ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** + * @attention + * + * Copyright (c) 2018-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. + * + ****************************************************************************** */ - #ifndef __SHCI_TL_H_ #define __SHCI_TL_H_ @@ -160,7 +158,7 @@ void shci_user_evt_proc(void); * @brief Initialize the System Host Controller Interface. * This function must be called before any communication on the System Channel * - * @param pData: System events callback function pointer + * @param UserEvtRx: System events callback function pointer * This callback is triggered when an user event is received on * the System Channel from CPU2. * @param pConf: Configuration structure pointer diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h index 93e909ca..b47b804a 100644 --- a/src/utility/STM32Cube_FW/stm32_wpan_common.h +++ b/src/utility/STM32Cube_FW/stm32_wpan_common.h @@ -6,13 +6,12 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2018 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2018-2021 STMicroelectronics. + * All rights reserved. * - * This software component is licensed by ST under Ultimate Liberty license - * SLA0044, the "License"; You may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * www.st.com/SLA0044 + * 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. * ****************************************************************************** */ @@ -26,9 +25,19 @@ extern "C" { #endif -#define __ASM __asm /*!< asm keyword for GNU Compiler */ -#define __INLINE inline /*!< inline keyword for GNU Compiler */ -#define __STATIC_INLINE static inline +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline +#endif #include #include @@ -131,13 +140,32 @@ extern "C" { /* ----------------------------------- * * Packed usage (compiler dependent) * * ----------------------------------- */ +#undef PACKED__ #undef PACKED_STRUCT -#define PACKED_STRUCT struct __packed + +#if defined ( __CC_ARM ) + #if defined ( __GNUC__ ) + /* GNU extension */ + #define PACKED__ __attribute__((packed)) + #define PACKED_STRUCT struct PACKED__ + #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050U) + #define PACKED__ __attribute__((packed)) + #define PACKED_STRUCT struct PACKED__ + #else + #define PACKED__(TYPE) __packed TYPE + #define PACKED_STRUCT PACKED__(struct) + #endif +#elif defined ( __GNUC__ ) + #define PACKED__ __attribute__((packed)) + #define PACKED_STRUCT struct PACKED__ +#elif defined (__ICCARM__) + #define PACKED_STRUCT __packed struct +#else + #define PACKED_STRUCT __packed struct +#endif #ifdef __cplusplus } #endif #endif /*__STM32_WPAN_COMMON_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c index 6e802a07..69c8c064 100644 --- a/src/utility/STM32Cube_FW/stm_list.c +++ b/src/utility/STM32Cube_FW/stm_list.c @@ -4,26 +4,25 @@ * @author MCD Application Team * @brief TCircular Linked List Implementation. ****************************************************************************** - * @attention + * @attention * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2018-2021 STMicroelectronics. + * All rights reserved. * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause + * 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. * ****************************************************************************** - */ + */ + -#if defined(STM32WBxx) /****************************************************************************** * Include Files ******************************************************************************/ +#include "utilities_common.h" + #include "stm_list.h" -#include "cmsis_gcc.h" -#include "stm32_wpan_common.h" /****************************************************************************** * Function Definitions @@ -34,10 +33,10 @@ void LST_init_head (tListNode * listHead) listHead->prev = listHead; } -bool LST_is_empty (tListNode * listHead) +uint8_t LST_is_empty (tListNode * listHead) { uint32_t primask_bit; - bool return_value; + uint8_t return_value; primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ @@ -206,4 +205,3 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } -#endif /* STM32WBxx */ \ No newline at end of file diff --git a/src/utility/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h index 529eeddb..b7c3254c 100644 --- a/src/utility/STM32Cube_FW/stm_list.h +++ b/src/utility/STM32Cube_FW/stm_list.h @@ -4,36 +4,33 @@ * @author MCD Application Team * @brief Header file for linked list library. ****************************************************************************** - * @attention + * @attention * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2018-2021 STMicroelectronics. + * All rights reserved. * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause + * 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. * ****************************************************************************** - */ + */ #ifndef _STM_LIST_H_ #define _STM_LIST_H_ -#include "stm32_wpan_common.h" /* Includes ------------------------------------------------------------------*/ -#include "stdint.h" -#include "stdbool.h" +#include "stm32_wpan_common.h" -typedef PACKED_STRUCT _tListNode { +typedef PACKED_STRUCT _tListNode { struct _tListNode * next; struct _tListNode * prev; } tListNode; void LST_init_head (tListNode * listHead); -bool LST_is_empty (tListNode * listHead); +uint8_t LST_is_empty (tListNode * listHead); void LST_insert_head (tListNode * listHead, tListNode * node); diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h index 4741599d..cb27246b 100644 --- a/src/utility/STM32Cube_FW/tl.h +++ b/src/utility/STM32Cube_FW/tl.h @@ -4,17 +4,16 @@ * @author MCD Application Team * @brief Header for tl module ****************************************************************************** - * @attention - * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

- * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause - * - ****************************************************************************** + * @attention + * + * Copyright (c) 2018-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. + * + ****************************************************************************** */ @@ -195,9 +194,22 @@ typedef struct typedef struct { - uint8_t *p_LldBleCmdRspBuffer; - uint8_t *p_LldBleM0CmdBuffer; -} TL_LLD_BLE_Config_t; + uint8_t *p_BleLldCmdRspBuffer; + uint8_t *p_BleLldM0CmdBuffer; +} TL_BLE_LLD_Config_t; + +typedef struct +{ + uint8_t *p_Mac_802_15_4_CmdRspBuffer; + uint8_t *p_Mac_802_15_4_NotAckBuffer; +} TL_MAC_802_15_4_Config_t; + +typedef struct +{ + uint8_t *p_ZigbeeOtCmdRspBuffer; + uint8_t *p_ZigbeeNotAckBuffer; + uint8_t *p_ZigbeeNotifRequestBuffer; +} TL_ZIGBEE_Config_t; /** * @brief Contain the BLE HCI Init Configuration @@ -269,17 +281,17 @@ void TL_LLDTESTS_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ); void TL_LLDTESTS_SendM0CmdAck( void ); /****************************************************************************** - * LLD BLE + * BLE LLD ******************************************************************************/ -void TL_LLD_BLE_Init( TL_LLD_BLE_Config_t *p_Config ); -void TL_LLD_BLE_SendCliCmd( void ); -void TL_LLD_BLE_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ); -void TL_LLD_BLE_SendCliRspAck( void ); -void TL_LLD_BLE_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ); -void TL_LLD_BLE_SendM0CmdAck( void ); -void TL_LLD_BLE_SendCmd( void ); -void TL_LLD_BLE_ReceiveRsp( TL_CmdPacket_t * Notbuffer ); -void TL_LLD_BLE_SendRspAck( void ); +void TL_BLE_LLD_Init( TL_BLE_LLD_Config_t *p_Config ); +void TL_BLE_LLD_SendCliCmd( void ); +void TL_BLE_LLD_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ); +void TL_BLE_LLD_SendCliRspAck( void ); +void TL_BLE_LLD_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ); +void TL_BLE_LLD_SendM0CmdAck( void ); +void TL_BLE_LLD_SendCmd( void ); +void TL_BLE_LLD_ReceiveRsp( TL_CmdPacket_t * Notbuffer ); +void TL_BLE_LLD_SendRspAck( void ); /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -292,10 +304,29 @@ void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); void TL_TRACES_Init( void ); void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ); +/****************************************************************************** + * MAC 802.15.4 + ******************************************************************************/ +void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ); +void TL_MAC_802_15_4_SendCmd( void ); +void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); +void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ); +void TL_MAC_802_15_4_SendAck ( void ); + +/****************************************************************************** + * ZIGBEE + ******************************************************************************/ +void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ); +void TL_ZIGBEE_SendM4RequestToM0( void ); +void TL_ZIGBEE_SendM4AckToM0Notify ( void ); +void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ); +void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); +void TL_ZIGBEE_M0RequestReceived(TL_EvtPacket_t * Otbuffer ); +void TL_ZIGBEE_SendM4AckToM0Request(void); + #ifdef __cplusplus } /* extern "C" */ #endif #endif /*__TL_H */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c index 8b579d5b..148bcb19 100644 --- a/src/utility/STM32Cube_FW/tl_mbox.c +++ b/src/utility/STM32Cube_FW/tl_mbox.c @@ -6,18 +6,16 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2019 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2018-2021 STMicroelectronics. + * All rights reserved. * - * This software component is licensed by ST under BSD 3-Clause license, - * the "License"; You may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * opensource.org/licenses/BSD-3-Clause + * 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. * ****************************************************************************** */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -25,23 +23,20 @@ #include "stm_list.h" #include "tl.h" #include "mbox_def.h" - -/** - * These traces are not yet supported in an usual way in the delivery package - * They can enabled by adding the definition of TL_MM_DBG_EN in the preprocessor option in the IDE - */ -#if(TL_MM_DBG_EN != 0) -#include "app_conf.h" -#include "dbg_trace.h" -#endif - -#if (TL_MM_DBG_EN != 0) -#define TL_MM_DBG__MSG PRINT_MESG_DBG -#else -#define TL_MM_DBG__MSG(...) -#endif +#include "tl_dbg_conf.h" /* Private typedef -----------------------------------------------------------*/ +typedef enum +{ + TL_MB_MM_RELEASE_BUFFER, + TL_MB_BLE_CMD, + TL_MB_BLE_CMD_RSP, + TL_MB_BLE_ASYNCH_EVT, + TL_MB_SYS_CMD, + TL_MB_SYS_CMD_RSP, + TL_MB_SYS_ASYNCH_EVT, +} TL_MB_PacketType_t; + /* Private defines -----------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ @@ -52,17 +47,19 @@ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_DeviceInfoTable_t TL_DeviceInfoTa PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleTable_t TL_BleTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ThreadTable_t TL_ThreadTable; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_LldTestsTable_t TL_LldTestsTable; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_LldBleTable_t TL_LldBleTable; +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; +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; /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue; PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)]; -PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode EvtQueue; -PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode SystemEvtQueue; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode EvtQueue; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode SystemEvtQueue; static tListNode LocalFreeBufQueue; @@ -75,7 +72,7 @@ static void (* SYS_EVT_IoBusCallBackFunction) (TL_EvtPacket_t *phcievt); /* Global variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static void SendFreeBuf( void ); -static void OutputMemReleaseTrace(TL_EvtPacket_t * phcievt); +static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer); /* Public Functions Definition ------------------------------------------------------*/ @@ -96,10 +93,12 @@ void TL_Init( void ) TL_RefTable.p_ble_table = &TL_BleTable; TL_RefTable.p_thread_table = &TL_ThreadTable; TL_RefTable.p_lld_tests_table = &TL_LldTestsTable; - TL_RefTable.p_lld_ble_table = &TL_LldBleTable; + TL_RefTable.p_ble_lld_table = &TL_BleLldTable; TL_RefTable.p_sys_table = &TL_SysTable; TL_RefTable.p_mem_manager_table = &TL_MemManagerTable; TL_RefTable.p_traces_table = &TL_TracesTable; + TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; + TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; HW_IPCC_Init(); return; @@ -138,6 +137,8 @@ int32_t TL_BLE_SendCmd( uint8_t* buffer, uint16_t size ) ((TL_CmdPacket_t*)(TL_RefTable.p_ble_table->pcmd_buffer))->cmdserial.type = TL_BLECMD_PKT_TYPE; + OutputDbgTrace(TL_MB_BLE_CMD, TL_RefTable.p_ble_table->pcmd_buffer); + HW_IPCC_BLE_SendCmd(); return 0; @@ -151,6 +152,15 @@ void HW_IPCC_BLE_RxEvtNot(void) { LST_remove_head (&EvtQueue, (tListNode **)&phcievt); + if ( ((phcievt->evtserial.evt.evtcode) == TL_BLEEVT_CS_OPCODE) || ((phcievt->evtserial.evt.evtcode) == TL_BLEEVT_CC_OPCODE ) ) + { + OutputDbgTrace(TL_MB_BLE_CMD_RSP, (uint8_t*)phcievt); + } + else + { + OutputDbgTrace(TL_MB_BLE_ASYNCH_EVT, (uint8_t*)phcievt); + } + BLE_IoBusEvtCallBackFunction(phcievt); } @@ -205,6 +215,8 @@ int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size ) ((TL_CmdPacket_t *)(TL_RefTable.p_sys_table->pcmd_buffer))->cmdserial.type = TL_SYSCMD_PKT_TYPE; + OutputDbgTrace(TL_MB_SYS_CMD, TL_RefTable.p_sys_table->pcmd_buffer); + HW_IPCC_SYS_SendCmd(); return 0; @@ -212,6 +224,8 @@ int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size ) void HW_IPCC_SYS_CmdEvtNot(void) { + OutputDbgTrace(TL_MB_SYS_CMD_RSP, (uint8_t*)(TL_RefTable.p_sys_table->pcmd_buffer) ); + SYS_CMD_IoBusCallBackFunction( (TL_EvtPacket_t*)(TL_RefTable.p_sys_table->pcmd_buffer) ); return; @@ -224,6 +238,9 @@ void HW_IPCC_SYS_EvtNot( void ) while(LST_is_empty(&SystemEvtQueue) == FALSE) { LST_remove_head (&SystemEvtQueue, (tListNode **)&p_evt); + + OutputDbgTrace(TL_MB_SYS_ASYNCH_EVT, (uint8_t*)p_evt ); + SYS_EVT_IoBusCallBackFunction( p_evt ); } @@ -364,75 +381,208 @@ __WEAK void TL_LLDTESTS_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ){}; #endif /* LLD_TESTS_WB */ /****************************************************************************** - * LLD BLE + * BLE LLD ******************************************************************************/ -#ifdef LLD_BLE_WB -void TL_LLD_BLE_Init( TL_LLD_BLE_Config_t *p_Config ) +#ifdef BLE_LLD_WB +void TL_BLE_LLD_Init( TL_BLE_LLD_Config_t *p_Config ) { - MB_LldBleTable_t * p_lld_ble_table; + MB_BleLldTable_t * p_ble_lld_table; - p_lld_ble_table = TL_RefTable.p_lld_ble_table; - p_lld_ble_table->cmdrsp_buffer = p_Config->p_LldBleCmdRspBuffer; - p_lld_ble_table->m0cmd_buffer = p_Config->p_LldBleM0CmdBuffer; - HW_IPCC_LLD_BLE_Init(); + p_ble_lld_table = TL_RefTable.p_ble_lld_table; + p_ble_lld_table->cmdrsp_buffer = p_Config->p_BleLldCmdRspBuffer; + p_ble_lld_table->m0cmd_buffer = p_Config->p_BleLldM0CmdBuffer; + HW_IPCC_BLE_LLD_Init(); return; } -void TL_LLD_BLE_SendCliCmd( void ) +void TL_BLE_LLD_SendCliCmd( void ) { - ((TL_CmdPacket_t *)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; - HW_IPCC_LLD_BLE_SendCliCmd(); + ((TL_CmdPacket_t *)(TL_RefTable.p_ble_lld_table->cmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; + HW_IPCC_BLE_LLD_SendCliCmd(); return; } -void HW_IPCC_LLD_BLE_ReceiveCliRsp( void ) +void HW_IPCC_BLE_LLD_ReceiveCliRsp( void ) { - TL_LLD_BLE_ReceiveCliRsp( (TL_CmdPacket_t*)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer) ); + TL_BLE_LLD_ReceiveCliRsp( (TL_CmdPacket_t*)(TL_RefTable.p_ble_lld_table->cmdrsp_buffer) ); return; } -void TL_LLD_BLE_SendCliRspAck( void ) +void TL_BLE_LLD_SendCliRspAck( void ) { - HW_IPCC_LLD_BLE_SendCliRspAck(); + HW_IPCC_BLE_LLD_SendCliRspAck(); return; } -void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ) +void HW_IPCC_BLE_LLD_ReceiveM0Cmd( void ) { - TL_LLD_BLE_ReceiveM0Cmd( (TL_CmdPacket_t*)(TL_RefTable.p_lld_ble_table->m0cmd_buffer) ); + TL_BLE_LLD_ReceiveM0Cmd( (TL_CmdPacket_t*)(TL_RefTable.p_ble_lld_table->m0cmd_buffer) ); return; } -void TL_LLD_BLE_SendM0CmdAck( void ) +void TL_BLE_LLD_SendM0CmdAck( void ) { - HW_IPCC_LLD_BLE_SendM0CmdAck(); + HW_IPCC_BLE_LLD_SendM0CmdAck(); return; } -__WEAK void TL_LLD_BLE_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ){}; -__WEAK void TL_LLD_BLE_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ){}; +__WEAK void TL_BLE_LLD_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ){}; +__WEAK void TL_BLE_LLD_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ){}; /* Transparent Mode */ -void TL_LLD_BLE_SendCmd( void ) +void TL_BLE_LLD_SendCmd( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_ble_lld_table->cmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; + HW_IPCC_BLE_LLD_SendCmd(); + return; +} + +void HW_IPCC_BLE_LLD_ReceiveRsp( void ) +{ + TL_BLE_LLD_ReceiveRsp( (TL_CmdPacket_t*)(TL_RefTable.p_ble_lld_table->cmdrsp_buffer) ); + return; +} + +void TL_BLE_LLD_SendRspAck( void ) +{ + HW_IPCC_BLE_LLD_SendRspAck(); + return; +} +#endif /* BLE_LLD_WB */ + +#ifdef MAC_802_15_4_WB +/****************************************************************************** + * MAC 802.15.4 + ******************************************************************************/ +void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ) +{ + MB_Mac_802_15_4_t * p_mac_802_15_4_table; + + p_mac_802_15_4_table = TL_RefTable.p_mac_802_15_4_table; + + p_mac_802_15_4_table->p_cmdrsp_buffer = p_Config->p_Mac_802_15_4_CmdRspBuffer; + p_mac_802_15_4_table->p_notack_buffer = p_Config->p_Mac_802_15_4_NotAckBuffer; + + HW_IPCC_MAC_802_15_4_Init(); + + return; +} + +void TL_MAC_802_15_4_SendCmd( void ) { - ((TL_CmdPacket_t *)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; - HW_IPCC_LLD_BLE_SendCmd(); + ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; + + HW_IPCC_MAC_802_15_4_SendCmd(); + + return; +} + +void TL_MAC_802_15_4_SendAck ( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_MAC_802_15_4_SendAck(); + return; } -void HW_IPCC_LLD_BLE_ReceiveRsp( void ) +void HW_IPCC_MAC_802_15_4_CmdEvtNot(void) { - TL_LLD_BLE_ReceiveRsp( (TL_CmdPacket_t*)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer) ); + TL_MAC_802_15_4_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer) ); + return; } -void TL_LLD_BLE_SendRspAck( void ) +void HW_IPCC_MAC_802_15_4_EvtNot( void ) { - HW_IPCC_LLD_BLE_SendRspAck(); + TL_MAC_802_15_4_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer) ); + return; } -#endif /* LLD_BLE_WB */ + +__WEAK void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; +__WEAK void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){}; +#endif + +#ifdef ZIGBEE_WB +/****************************************************************************** + * ZIGBEE + ******************************************************************************/ +void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ) +{ + MB_ZigbeeTable_t * p_zigbee_table; + + p_zigbee_table = TL_RefTable.p_zigbee_table; + p_zigbee_table->appliCmdM4toM0_buffer = p_Config->p_ZigbeeOtCmdRspBuffer; + p_zigbee_table->notifM0toM4_buffer = p_Config->p_ZigbeeNotAckBuffer; + p_zigbee_table->requestM0toM4_buffer = p_Config->p_ZigbeeNotifRequestBuffer; + + HW_IPCC_ZIGBEE_Init(); + + return; +} + +/* Zigbee M4 to M0 Request */ +void TL_ZIGBEE_SendM4RequestToM0( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4RequestToM0(); + + return; +} + +/* Used to receive an ACK from the M0 */ +void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void) +{ + TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) ); + + return; +} + +/* Zigbee notification from M0 to M4 */ +void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ) +{ + TL_ZIGBEE_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer) ); + + return; +} + +/* Send an ACK to the M0 for a Notification */ +void TL_ZIGBEE_SendM4AckToM0Notify ( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4AckToM0Notify(); + + return; +} + +/* Zigbee M0 to M4 Request */ +void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ) +{ + TL_ZIGBEE_M0RequestReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer) ); + + return; +} + +/* Send an ACK to the M0 for a Request */ +void TL_ZIGBEE_SendM4AckToM0Request(void) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4AckToM0Request(); + + return; +} + + +__WEAK void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; +__WEAK void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){}; +#endif + + /****************************************************************************** * MEMORY MANAGER @@ -461,7 +611,7 @@ void TL_MM_EvtDone(TL_EvtPacket_t * phcievt) { LST_insert_tail(&LocalFreeBufQueue, (tListNode *)phcievt); - OutputMemReleaseTrace(phcievt); + OutputDbgTrace(TL_MB_MM_RELEASE_BUFFER, (uint8_t*)phcievt); HW_IPCC_MM_SendFreeBuf( SendFreeBuf ); @@ -481,39 +631,6 @@ static void SendFreeBuf( void ) return; } -static void OutputMemReleaseTrace(TL_EvtPacket_t * phcievt) -{ - switch(phcievt->evtserial.evt.evtcode) - { - case TL_BLEEVT_CS_OPCODE: - TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode); - TL_MM_DBG__MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(phcievt->evtserial.evt.payload))->cmdcode); - TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); - break; - - case TL_BLEEVT_CC_OPCODE: - TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode); - TL_MM_DBG__MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(phcievt->evtserial.evt.payload))->cmdcode); - TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); - break; - - case TL_BLEEVT_VS_OPCODE: - TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode); - TL_MM_DBG__MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(phcievt->evtserial.evt.payload))->subevtcode); - TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); - break; - - default: - TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode); - TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); - break; - } - - TL_MM_DBG__MSG("\r\n"); - - return; -} - /****************************************************************************** * TRACES ******************************************************************************/ @@ -546,5 +663,185 @@ __WEAK void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ) (void)(hcievt); } -#endif /* STM32WBxx */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +/****************************************************************************** + * DEBUG INFORMATION + ******************************************************************************/ +static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) +{ + TL_EvtPacket_t *p_evt_packet; + TL_CmdPacket_t *p_cmd_packet; + + switch(packet_type) + { + case TL_MB_MM_RELEASE_BUFFER: + p_evt_packet = (TL_EvtPacket_t*)buffer; + switch(p_evt_packet->evtserial.evt.evtcode) + { + case TL_BLEEVT_CS_OPCODE: + TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_MM_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); + TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); + break; + + case TL_BLEEVT_CC_OPCODE: + TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_MM_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); + TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); + break; + + case TL_BLEEVT_VS_OPCODE: + TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_MM_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); + TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); + break; + + default: + TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); + break; + } + + TL_MM_DBG_MSG("\r\n"); + break; + + case TL_MB_BLE_CMD: + p_cmd_packet = (TL_CmdPacket_t*)buffer; + TL_HCI_CMD_DBG_MSG("ble cmd: 0x%04X", p_cmd_packet->cmdserial.cmd.cmdcode); + if(p_cmd_packet->cmdserial.cmd.plen != 0) + { + TL_HCI_CMD_DBG_MSG(" payload:"); + TL_HCI_CMD_DBG_BUF(p_cmd_packet->cmdserial.cmd.payload, p_cmd_packet->cmdserial.cmd.plen, ""); + } + TL_HCI_CMD_DBG_MSG("\r\n"); + + TL_HCI_CMD_DBG_RAW(&p_cmd_packet->cmdserial, p_cmd_packet->cmdserial.cmd.plen+TL_CMD_HDR_SIZE); + break; + + case TL_MB_BLE_CMD_RSP: + p_evt_packet = (TL_EvtPacket_t*)buffer; + switch(p_evt_packet->evtserial.evt.evtcode) + { + case TL_BLEEVT_CS_OPCODE: + TL_HCI_CMD_DBG_MSG("ble rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_HCI_CMD_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); + TL_HCI_CMD_DBG_MSG(" numhci: 0x%02X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->numcmd); + TL_HCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->status); + break; + + case TL_BLEEVT_CC_OPCODE: + TL_HCI_CMD_DBG_MSG("ble rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_HCI_CMD_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); + TL_HCI_CMD_DBG_MSG(" numhci: 0x%02X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->numcmd); + TL_HCI_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_HCI_CMD_DBG_MSG(" payload:"); + TL_HCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[1], p_evt_packet->evtserial.evt.plen-4, ""); + } + break; + + default: + TL_HCI_CMD_DBG_MSG("unknown ble rsp received: %02X", p_evt_packet->evtserial.evt.evtcode); + break; + } + + TL_HCI_CMD_DBG_MSG("\r\n"); + + TL_HCI_CMD_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); + break; + + case TL_MB_BLE_ASYNCH_EVT: + p_evt_packet = (TL_EvtPacket_t*)buffer; + if(p_evt_packet->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) + { + TL_HCI_EVT_DBG_MSG("ble evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + if((p_evt_packet->evtserial.evt.plen) != 0) + { + TL_HCI_EVT_DBG_MSG(" payload:"); + TL_HCI_EVT_DBG_BUF(p_evt_packet->evtserial.evt.payload, p_evt_packet->evtserial.evt.plen, ""); + } + } + else + { + TL_HCI_EVT_DBG_MSG("ble evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_HCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); + if((p_evt_packet->evtserial.evt.plen-2) != 0) + { + TL_HCI_EVT_DBG_MSG(" payload:"); + TL_HCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload, p_evt_packet->evtserial.evt.plen-2, ""); + } + } + + TL_HCI_EVT_DBG_MSG("\r\n"); + + TL_HCI_EVT_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); + break; + + case TL_MB_SYS_CMD: + p_cmd_packet = (TL_CmdPacket_t*)buffer; + + TL_SHCI_CMD_DBG_MSG("sys cmd: 0x%04X", p_cmd_packet->cmdserial.cmd.cmdcode); + + if(p_cmd_packet->cmdserial.cmd.plen != 0) + { + TL_SHCI_CMD_DBG_MSG(" payload:"); + TL_SHCI_CMD_DBG_BUF(p_cmd_packet->cmdserial.cmd.payload, p_cmd_packet->cmdserial.cmd.plen, ""); + } + TL_SHCI_CMD_DBG_MSG("\r\n"); + + TL_SHCI_CMD_DBG_RAW(&p_cmd_packet->cmdserial, p_cmd_packet->cmdserial.cmd.plen+TL_CMD_HDR_SIZE); + break; + + case TL_MB_SYS_CMD_RSP: + p_evt_packet = (TL_EvtPacket_t*)buffer; + switch(p_evt_packet->evtserial.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(" payload:"); + TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[1], p_evt_packet->evtserial.evt.plen-4, ""); + } + break; + + default: + TL_SHCI_CMD_DBG_MSG("unknown sys rsp received: %02X", p_evt_packet->evtserial.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); + break; + + case TL_MB_SYS_ASYNCH_EVT: + p_evt_packet = (TL_EvtPacket_t*)buffer; + if(p_evt_packet->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) + { + TL_SHCI_EVT_DBG_MSG("unknown sys evt received: %02X", p_evt_packet->evtserial.evt.evtcode); + } + else + { + TL_SHCI_EVT_DBG_MSG("sys evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_SHCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); + if((p_evt_packet->evtserial.evt.plen-2) != 0) + { + TL_SHCI_EVT_DBG_MSG(" payload:"); + TL_SHCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload, p_evt_packet->evtserial.evt.plen-2, ""); + } + } + + TL_SHCI_EVT_DBG_MSG("\r\n"); + + TL_SHCI_EVT_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); + break; + + default: + break; + } + + return; +} From 6eb25bcc5bbc4c2299d6d3fe3a4452e94d82520e Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Mon, 6 Dec 2021 11:08:32 +0100 Subject: [PATCH 19/58] chore: clean up and adapt STM32Cube_FW sources for STM32duino Signed-off-by: Frederic Pillon Signed-off-by: Alexandre Bourdiol --- src/utility/STM32Cube_FW/app_conf_default.h | 422 +------------------ src/utility/STM32Cube_FW/ble_bufsize.h | 13 +- src/utility/STM32Cube_FW/hw.h | 28 +- src/utility/STM32Cube_FW/hw_ipcc.c | 184 +------- src/utility/STM32Cube_FW/mbox_def.h | 34 -- src/utility/STM32Cube_FW/shci.c | 40 +- src/utility/STM32Cube_FW/shci.h | 47 +-- src/utility/STM32Cube_FW/shci_tl.c | 19 +- src/utility/STM32Cube_FW/stm32_wpan_common.h | 39 +- src/utility/STM32Cube_FW/stm_list.c | 11 +- src/utility/STM32Cube_FW/stm_list.h | 4 +- src/utility/STM32Cube_FW/tl.h | 33 -- src/utility/STM32Cube_FW/tl_mbox.c | 144 +------ 13 files changed, 94 insertions(+), 924 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h index 7ebc65aa..4f300e0a 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -1,4 +1,3 @@ -/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file app_conf.h @@ -16,94 +15,36 @@ * ****************************************************************************** */ -/* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef APP_CONF_H #define APP_CONF_H #include "hw.h" -#include "hw_conf.h" -#include "hw_if.h" #include "ble_bufsize.h" /****************************************************************************** * Application Config ******************************************************************************/ -/** - * Define Secure Connections Support - */ -#define CFG_SECURE_NOT_SUPPORTED (0x00) -#define CFG_SECURE_OPTIONAL (0x01) -#define CFG_SECURE_MANDATORY (0x02) - -#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL - -/** - * Define Keypress Notification Support - */ -#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) -#define CFG_KEYPRESS_SUPPORTED (0x01) +/**< generic parameters ******************************************************/ +/* HCI related defines */ -#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED +#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 -/** - * Numeric Comparison Answers - */ -#define YES (0x01) -#define NO (0x00) - -/** - * Device name configuration for Generic Access Service - */ -#define CFG_GAP_DEVICE_NAME "TEMPLATE" -#define CFG_GAP_DEVICE_NAME_LENGTH (8) - -/** -* Identity root key used to derive LTK and CSRK -*/ -#define CFG_BLE_IRK {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0} - -/** -* Encryption root key used to derive LTK and CSRK -*/ -#define CFG_BLE_ERK {0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21, 0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21} +#ifndef BLE_SHARED_MEM_BYTE_ORDER + #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST +#endif +#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 /** - * SMPS supply - * SMPS not used when Set to 0 - * SMPS used when Set to 1 + * Define Tx Power */ -#define CFG_USE_SMPS 0 - -/* USER CODE BEGIN Generic_Parameters */ -/* USER CODE END Generic_Parameters */ - -/**< specific parameters */ -/*****************************************************/ - -/* USER CODE BEGIN Specific_Parameters */ -#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler - -/* USER CODE END Specific_Parameters */ - -/****************************************************************************** - * Information Table - * - * Version - * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version - * [4:7] = branch - 0: Mass Market - x: ... - * [8:15] = Subversion - * [16:23] = Version minor - * [24:31] = Version major - * - ******************************************************************************/ -#define CFG_FW_MAJOR_VERSION (0) -#define CFG_FW_MINOR_VERSION (0) -#define CFG_FW_SUBVERSION (1) -#define CFG_FW_BRANCH (0) -#define CFG_FW_BUILD (0) +#define CFG_TX_POWER (0x18) /* -0.15dBm */ /****************************************************************************** * BLE Stack @@ -152,13 +93,15 @@ * Prepare Write List size in terms of number of packet * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" */ -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +// #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) /** * Number of allocated memory blocks * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter when CFG_BLE_OPTIONS is set to 1 */ -#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) +// #define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) +#define CFG_BLE_MBLOCK_COUNT (0x79) /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. @@ -236,7 +179,7 @@ * 0: LE Power Class 2-3 * other bits: reserved (shall be set to 0) */ -#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_NO_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3) +#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY) #define CFG_BLE_MAX_COC_INITIATOR_NBR (32) @@ -256,334 +199,5 @@ #define CFG_BLE_RX_MODEL_CONFIG SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY -/****************************************************************************** - * Transport Layer - ******************************************************************************/ -/** - * Queue length of BLE Event - * This parameter defines the number of asynchronous events that can be stored in the HCI layer before - * being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer - * is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large - * enough to store all asynchronous events received in between. - * When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events - * between the HCI command and its event. - * This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small, - * the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting - * for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate - * to the application a HCI command did not receive its command event within 30s (Default HCI Timeout). - */ -#define CFG_TLBLE_EVT_QUEUE_LENGTH 5 -/** - * This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element - * allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager. - * It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will - * never be used) - * It shall be at least 4 to receive the command status event in one frame. - * The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced - * further depending on the application. - */ -#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */ - -#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE ) -/****************************************************************************** - * UART interfaces - ******************************************************************************/ - -/** - * Select UART interfaces - */ -#define CFG_UART_GUI hw_uart1 -#define CFG_DEBUG_TRACE_UART 0 -/****************************************************************************** - * USB interface - ******************************************************************************/ - -/** - * Enable/Disable USB interface - */ -#define CFG_USB_INTERFACE_ENABLE 0 - -/****************************************************************************** - * IPCC interface - ******************************************************************************/ - -/** - * The IPCC is dedicated to the communication between the CPU2 and the CPU1 - * and shall not be modified by the application - * The two following definitions shall not be modified - */ -#define HAL_IPCC_TX_IRQHandler(...) HW_IPCC_Tx_Handler( ) -#define HAL_IPCC_RX_IRQHandler(...) HW_IPCC_Rx_Handler( ) - -/****************************************************************************** - * Low Power - ******************************************************************************/ -/** - * When set to 1, the low power mode is enable - * When set to 0, the device stays in RUN mode - */ -#define CFG_LPM_SUPPORTED 1 - -/****************************************************************************** - * RTC interface - ******************************************************************************/ -#define HAL_RTCEx_WakeUpTimerIRQHandler(...) HW_TS_RTC_Wakeup_Handler( ) - -/****************************************************************************** - * Timer Server - ******************************************************************************/ -/** - * CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer. - * The lower is the value, the better is the power consumption and the accuracy of the timerserver - * The higher is the value, the finest is the granularity - * - * CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to output - * clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding - * the wakeup timer. A lower clock speed would impact the accuracy of the timer server. - * - * CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC. - * When the 1Hz calendar clock is required, it shall be sets according to other settings - * When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE) - * - * CFG_RTCCLK_DIVIDER_CONF: - * Shall be set to either 0,2,4,8,16 - * When set to either 2,4,8,16, the 1Hhz calendar is supported - * When set to 0, the user sets its own configuration - * - * The following settings are computed with LSI as input to the RTC - */ - -#define CFG_RTCCLK_DIVIDER_CONF 0 - -#if (CFG_RTCCLK_DIVIDER_CONF == 0) -/** - * Custom configuration - * It does not support 1Hz calendar - * It divides the RTC CLK by 16 - */ - -#define CFG_RTCCLK_DIV (16) -#define CFG_RTC_WUCKSEL_DIVIDER (0) -#define CFG_RTC_ASYNCH_PRESCALER (0x0F) -#define CFG_RTC_SYNCH_PRESCALER (0x7FFF) - -#else - -#if (CFG_RTCCLK_DIVIDER_CONF == 2) -/** - * It divides the RTC CLK by 2 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (3) -#endif - -#if (CFG_RTCCLK_DIVIDER_CONF == 4) -/** - * It divides the RTC CLK by 4 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (2) -#endif - -#if (CFG_RTCCLK_DIVIDER_CONF == 8) -/** - * It divides the RTC CLK by 8 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (1) -#endif - -#if (CFG_RTCCLK_DIVIDER_CONF == 16) -/** - * It divides the RTC CLK by 16 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (0) -#endif - -#define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF -#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) -#define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 ) - -#endif - -/** tick timer values */ -#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE ) -#define CFG_TS_TICK_VAL_PS DIVR( ((uint64_t)CFG_RTCCLK_DIV * 1e12), (uint64_t)LSE_VALUE ) - -typedef enum -{ - CFG_TIM_PROC_ID_ISR, - /* USER CODE BEGIN CFG_TimProcID_t */ - - /* USER CODE END CFG_TimProcID_t */ -} CFG_TimProcID_t; - -/****************************************************************************** - * Debug - ******************************************************************************/ -/** - * When set, this resets some hw resources to set the device in the same state than the power up - * The FW resets only register that may prevent the FW to run properly - * - * This shall be set to 0 in a final product - * - */ -#define CFG_HW_RESET_BY_FW 1 - -/** - * keep debugger enabled while in any low power mode when set to 1 - * should be set to 0 in production - */ -#define CFG_DEBUGGER_SUPPORTED 0 - -/** - * When set to 1, the traces are enabled in the BLE services - */ -#define CFG_DEBUG_BLE_TRACE 0 - -/** - * Enable or Disable traces in application - */ -#define CFG_DEBUG_APP_TRACE 0 - -#if (CFG_DEBUG_APP_TRACE != 0) -#define APP_DBG_MSG PRINT_MESG_DBG -#else -#define APP_DBG_MSG PRINT_NO_MESG -#endif - -#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) ) -#define CFG_DEBUG_TRACE 1 -#endif - -#if (CFG_DEBUG_TRACE != 0) -#undef CFG_LPM_SUPPORTED -#undef CFG_DEBUGGER_SUPPORTED -#define CFG_LPM_SUPPORTED 0 -#define CFG_DEBUGGER_SUPPORTED 1 -#endif - -/** - * When CFG_DEBUG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number - * When CFG_DEBUG_TRACE_LIGHT is set to 1, only the debug message is output - * - * When both are set to 0, no trace are output - * When both are set to 1, CFG_DEBUG_TRACE_FULL is selected - */ -#define CFG_DEBUG_TRACE_LIGHT 0 -#define CFG_DEBUG_TRACE_FULL 0 - -#if (( CFG_DEBUG_TRACE != 0 ) && ( CFG_DEBUG_TRACE_LIGHT == 0 ) && (CFG_DEBUG_TRACE_FULL == 0)) -#undef CFG_DEBUG_TRACE_FULL -#undef CFG_DEBUG_TRACE_LIGHT -#define CFG_DEBUG_TRACE_FULL 0 -#define CFG_DEBUG_TRACE_LIGHT 1 -#endif - -#if ( CFG_DEBUG_TRACE == 0 ) -#undef CFG_DEBUG_TRACE_FULL -#undef CFG_DEBUG_TRACE_LIGHT -#define CFG_DEBUG_TRACE_FULL 0 -#define CFG_DEBUG_TRACE_LIGHT 0 -#endif - -/** - * When not set, the traces is looping on sending the trace over UART - */ -#define DBG_TRACE_USE_CIRCULAR_QUEUE 1 - -/** - * max buffer Size to queue data traces and max data trace allowed. - * Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined - */ -#define DBG_TRACE_MSG_QUEUE_SIZE 4096 -#define MAX_DBG_TRACE_MSG_SIZE 1024 - -/* USER CODE BEGIN Defines */ -#define CFG_LED_SUPPORTED 1 -#define CFG_BUTTON_SUPPORTED 1 - -#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler -#define PUSH_BUTTON_SW2_EXTI_IRQHandler EXTI0_IRQHandler -#define PUSH_BUTTON_SW3_EXTI_IRQHandler EXTI1_IRQHandler -/* USER CODE END Defines */ - -/****************************************************************************** - * Scheduler - ******************************************************************************/ - -/** - * These are the lists of task id registered to the scheduler - * Each task id shall be in the range [0:31] - * This mechanism allows to implement a generic code in the API TL_BLE_HCI_StatusNot() to comply with - * the requirement that a HCI/ACI command shall never be sent if there is already one pending - */ - -/**< Add in that list all tasks that may send a ACI/HCI command */ -typedef enum -{ - CFG_TASK_BLE_HCI_CMD_ID, - CFG_TASK_SYS_HCI_CMD_ID, - CFG_TASK_HCI_ACL_DATA_ID, - CFG_TASK_SYS_LOCAL_CMD_ID, - CFG_TASK_TX_TO_HOST_ID, - /* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */ - CFG_TASK_SW1_BUTTON_PUSHED_ID, - CFG_TASK_SW2_BUTTON_PUSHED_ID, - CFG_TASK_SW3_BUTTON_PUSHED_ID, - /* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */ - CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */ -} CFG_Task_Id_With_HCI_Cmd_t; - -/**< Add in that list all tasks that never send a ACI/HCI command */ -typedef enum -{ - CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */ - CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID, - /* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */ - - /* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */ - CFG_LAST_TASK_ID_WITHO_NO_HCICMD /**< Shall be LAST in the list */ -} CFG_Task_Id_With_NO_HCI_Cmd_t; - -#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITHO_NO_HCICMD - -/** - * This is the list of priority required by the application - * Each Id shall be in the range 0..31 - */ -typedef enum -{ - CFG_SCH_PRIO_0, - CFG_PRIO_NBR, -} CFG_SCH_Prio_Id_t; - -/** - * This is a bit mapping over 32bits listing all events id supported in the application - */ -typedef enum -{ - CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID, -} CFG_IdleEvt_Id_t; - -/****************************************************************************** - * LOW POWER - ******************************************************************************/ -/** - * Supported requester to the MCU Low Power Manager - can be increased up to 32 - * It list a bit mapping of all user of the Low Power Manager - */ -typedef enum -{ - CFG_LPM_APP, - CFG_LPM_APP_BLE, - /* USER CODE BEGIN CFG_LPM_Id_t */ - - /* USER CODE END CFG_LPM_Id_t */ -} CFG_LPM_Id_t; - -/****************************************************************************** - * OTP manager - ******************************************************************************/ -#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE - -#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR #endif /*APP_CONF_H */ diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h index ba9c4d3c..73b78872 100644 --- a/src/utility/STM32Cube_FW/ble_bufsize.h +++ b/src/utility/STM32Cube_FW/ble_bufsize.h @@ -75,17 +75,24 @@ ((pw) + MAX(BLE_MEM_BLOCK_X_MTU(mtu, n_link), \ BLE_MBLOCKS_SECURE_CONNECTIONS)) +/* + * BLE_DEFAULT_MBLOCKS_COUNT: default memory blocks count + */ +#define BLE_DEFAULT_MBLOCKS_COUNT(n_link) \ + BLE_MBLOCKS_CALC(BLE_DEFAULT_PREP_WRITE_LIST_SIZE, \ + BLE_DEFAULT_MAX_ATT_MTU, n_link) + /* * BLE_FIXED_BUFFER_SIZE_BYTES: - * A part of the RAM, is dinamically allocated by initilizing all the pointers + * A part of the RAM, is dynamically allocated by initializing all the pointers * defined in a global context variable "mem_alloc_ctx_p". * This initialization is made in the Dynamic_allocator functions, which - * assing a portion of RAM given by the external application to the above + * assign a portion of RAM given by the external application to the above * mentioned "global pointers". * * The size of this Dynamic RAM is made of 2 main components: * - a part that is parameters-dependent (num of links, GATT buffers, ...), - * and which value is explicited by the following macro; + * and which value is defined by the following macro; * - a part, that may be considered "fixed", i.e. independent from the above * mentioned parameters. */ diff --git a/src/utility/STM32Cube_FW/hw.h b/src/utility/STM32Cube_FW/hw.h index 503fa2ca..fcf04517 100644 --- a/src/utility/STM32Cube_FW/hw.h +++ b/src/utility/STM32Cube_FW/hw.h @@ -26,14 +26,21 @@ 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 ); void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); @@ -80,23 +87,6 @@ extern "C" { void HW_IPCC_TRACES_Init( void ); void HW_IPCC_TRACES_EvtNot( void ); - void HW_IPCC_MAC_802_15_4_Init( void ); - void HW_IPCC_MAC_802_15_4_SendCmd( void ); - void HW_IPCC_MAC_802_15_4_SendAck( void ); - void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ); - void HW_IPCC_MAC_802_15_4_EvtNot( void ); - - void HW_IPCC_ZIGBEE_Init( void ); - - void HW_IPCC_ZIGBEE_SendM4RequestToM0(void); /* M4 Request to M0 */ - void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void); /* Request ACK from M0 */ - - void HW_IPCC_ZIGBEE_RecvM0NotifyToM4(void); /* M0 Notify to M4 */ - void HW_IPCC_ZIGBEE_SendM4AckToM0Notify(void); /* Notify ACK from M4 */ - void HW_IPCC_ZIGBEE_RecvM0RequestToM4(void); /* M0 Request to M4 */ - void HW_IPCC_ZIGBEE_SendM4AckToM0Request(void); /* Request ACK from M4 */ - - #ifdef __cplusplus } #endif diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c index c5a941d2..2f4f6cc2 100644 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ b/src/utility/STM32Cube_FW/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 ---------------------------------------------------------*/ @@ -56,34 +57,17 @@ static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ); static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void ); #endif -#ifdef MAC_802_15_4_WB -static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ); -static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ); -#endif - -#ifdef ZIGBEE_WB -static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ); -static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ); -static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ); -#endif - /* Public function definition -----------------------------------------------*/ /****************************************************************************** * INTERRUPT HANDLER ******************************************************************************/ -void HW_IPCC_Rx_Handler( void ) +void IPCC_C1_RX_IRQHandler(void) { if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL )) { HW_IPCC_SYS_EvtHandler(); } -#ifdef MAC_802_15_4_WB - else if (HW_IPCC_RX_PENDING( HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL )) - { - HW_IPCC_MAC_802_15_4_NotEvtHandler(); - } -#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL )) { @@ -114,16 +98,6 @@ void HW_IPCC_Rx_Handler( void ) HW_IPCC_LLD_BLE_ReceiveM0CmdHandler(); } #endif /* LLD_TESTS_WB */ -#ifdef ZIGBEE_WB - else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL )) - { - HW_IPCC_ZIGBEE_StackNotifEvtHandler(); - } - else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL )) - { - HW_IPCC_ZIGBEE_StackM0RequestHandler(); - } -#endif /* ZIGBEE_WB */ else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL )) { HW_IPCC_BLE_EvtHandler(); @@ -132,22 +106,14 @@ void HW_IPCC_Rx_Handler( void ) { HW_IPCC_TRACES_EvtHandler(); } - - return; } -void HW_IPCC_Tx_Handler( void ) +void IPCC_C1_TX_IRQHandler(void) { if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) { HW_IPCC_SYS_CmdEvtHandler(); } -#ifdef MAC_802_15_4_WB - else if (HW_IPCC_TX_PENDING( HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL )) - { - HW_IPCC_MAC_802_15_4_CmdEvtHandler(); - } -#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) { @@ -157,12 +123,6 @@ void HW_IPCC_Tx_Handler( void ) #ifdef LLD_TESTS_WB // No TX handler for LLD tests #endif /* LLD_TESTS_WB */ -#ifdef ZIGBEE_WB - if (HW_IPCC_TX_PENDING( HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL )) - { - HW_IPCC_ZIGBEE_CmdEvtHandler(); - } -#endif /* ZIGBEE_WB */ else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL )) { HW_IPCC_MM_FreeBufHandler(); @@ -171,9 +131,8 @@ void HW_IPCC_Tx_Handler( void ) { HW_IPCC_BLE_AclDataEvtHandler(); } - - return; } + /****************************************************************************** * GENERAL ******************************************************************************/ @@ -263,8 +222,8 @@ static void HW_IPCC_BLE_AclDataEvtHandler( void ) return; } -__weak void HW_IPCC_BLE_AclDataAckNot( void ){}; -__weak void HW_IPCC_BLE_RxEvtNot( void ){}; +__WEAK void HW_IPCC_BLE_AclDataAckNot( void ){}; +__WEAK void HW_IPCC_BLE_RxEvtNot( void ){}; /****************************************************************************** * SYSTEM @@ -302,56 +261,8 @@ static void HW_IPCC_SYS_EvtHandler( void ) return; } -__weak void HW_IPCC_SYS_CmdEvtNot( void ){}; -__weak void HW_IPCC_SYS_EvtNot( void ){}; - -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -#ifdef MAC_802_15_4_WB -void HW_IPCC_MAC_802_15_4_Init( void ) -{ - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -void HW_IPCC_MAC_802_15_4_SendCmd( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - - return; -} - -void HW_IPCC_MAC_802_15_4_SendAck( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ) -{ - LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - - HW_IPCC_MAC_802_15_4_CmdEvtNot(); - - return; -} - -static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - HW_IPCC_MAC_802_15_4_EvtNot(); - - return; -} -__weak void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ){}; -__weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){}; -#endif +__WEAK void HW_IPCC_SYS_CmdEvtNot( void ){}; +__WEAK void HW_IPCC_SYS_EvtNot( void ){}; /****************************************************************************** * THREAD @@ -423,9 +334,9 @@ static void HW_IPCC_THREAD_CliNotEvtHandler( void ) return; } -__weak void HW_IPCC_OT_CmdEvtNot( void ){}; -__weak void HW_IPCC_CLI_CmdEvtNot( void ){}; -__weak void HW_IPCC_THREAD_EvtNot( void ){}; +__WEAK void HW_IPCC_OT_CmdEvtNot( void ){}; +__WEAK void HW_IPCC_CLI_CmdEvtNot( void ){}; +__WEAK void HW_IPCC_THREAD_EvtNot( void ){}; #endif /* THREAD_WB */ @@ -547,74 +458,6 @@ void HW_IPCC_LLD_BLE_SendRspAck( void ) #endif /* LLD_BLE_WB */ -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -#ifdef ZIGBEE_WB -void HW_IPCC_ZIGBEE_Init( void ) -{ - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - - return; -} - -void HW_IPCC_ZIGBEE_SendM4RequestToM0( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); - LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); - - return; -} - -void HW_IPCC_ZIGBEE_SendM4AckToM0Notify( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - - return; -} - -static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ) -{ - LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); - - HW_IPCC_ZIGBEE_RecvAppliAckFromM0(); - - return; -} - -static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - - HW_IPCC_ZIGBEE_RecvM0NotifyToM4(); - - return; -} - -static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - - HW_IPCC_ZIGBEE_RecvM0RequestToM4(); - - return; -} - -void HW_IPCC_ZIGBEE_SendM4AckToM0Request( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - - return; -} - -__weak void HW_IPCC_ZIGBEE_RecvAppliAckFromM0( void ){}; -__weak void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ){}; -__weak void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ){}; -#endif /* ZIGBEE_WB */ - /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -665,4 +508,5 @@ static void HW_IPCC_TRACES_EvtHandler( void ) return; } -__weak void HW_IPCC_TRACES_EvtNot( void ){}; +__WEAK void HW_IPCC_TRACES_EvtNot( void ){}; +#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h index 06536d34..c898e52a 100644 --- a/src/utility/STM32Cube_FW/mbox_def.h +++ b/src/utility/STM32Cube_FW/mbox_def.h @@ -105,12 +105,6 @@ extern "C" { uint8_t *m0cmd_buffer; } MB_BleLldTable_t; - typedef struct - { - uint8_t *notifM0toM4_buffer; - uint8_t *appliCmdM4toM0_buffer; - uint8_t *requestM0toM4_buffer; - } MB_ZigbeeTable_t; /** * msg * [0:7] = cmd/evt @@ -138,13 +132,6 @@ extern "C" { uint8_t *traces_queue; } MB_TracesTable_t; - typedef struct - { - uint8_t *p_cmdrsp_buffer; - uint8_t *p_notack_buffer; - uint8_t *evt_queue; - } MB_Mac_802_15_4_t; - typedef struct { MB_DeviceInfoTable_t *p_device_info_table; @@ -153,8 +140,6 @@ extern "C" { MB_SysTable_t *p_sys_table; MB_MemManagerTable_t *p_mem_manager_table; MB_TracesTable_t *p_traces_table; - MB_Mac_802_15_4_t *p_mac_802_15_4_table; - MB_ZigbeeTable_t *p_zigbee_table; MB_LldTestsTable_t *p_lld_tests_table; MB_BleLldTable_t *p_ble_lld_table; } MB_RefTable_t; @@ -198,15 +183,6 @@ typedef struct * | | * |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------| * | | - * | (ZIGBEE) | - * |----HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL------------>| - * | | - * |----HW_IPCC_ZIGBEE_CMD_CLI_CHANNEL-------------->| - * | | - * |<---HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL-------| - * | | - * |<---HW_IPCC_ZIGBEE_CLI_NOTIF_ACK_CHANNEL---------| - * | | * | (THREAD) | * |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->| * | | @@ -230,11 +206,6 @@ typedef struct * | | * |<---HW_IPCC_BLE_LLD_M0_CMD_CHANNEL---------------| * | | - * | (MAC) | - * |----HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL-------->| - * | | - * |<---HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL| - * | | * | (BUFFER) | * |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>| * | | @@ -252,8 +223,6 @@ typedef struct #define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4 #define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 @@ -265,8 +234,6 @@ typedef struct #define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_BLE_LLD_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4 @@ -274,6 +241,5 @@ typedef struct #define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_BLE_LLD_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_BLE_LLD_RSP_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL LL_IPCC_CHANNEL_5 #endif /*__MBOX_H */ diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c index 301db76d..bd7bb3a1 100644 --- a/src/utility/STM32Cube_FW/shci.c +++ b/src/utility/STM32Cube_FW/shci.c @@ -16,7 +16,7 @@ ****************************************************************************** */ - +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -352,24 +352,6 @@ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ) return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t * p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send( SHCI_OPCODE_C2_ZIGBEE_INIT, - 0, - 0, - p_rsp ); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); -} - SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ) { /** @@ -527,24 +509,6 @@ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t Fla return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t * p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send( SHCI_OPCODE_C2_MAC_802_15_4_INIT, - 0, - 0, - p_rsp ); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); -} - SHCI_CmdStatus_t SHCI_C2_Reinit( void ) { /** @@ -739,3 +703,5 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } +#endif /* STM32WBxx */ + diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h index c08f056f..9449c224 100644 --- a/src/utility/STM32Cube_FW/shci.h +++ b/src/utility/STM32Cube_FW/shci.h @@ -49,7 +49,6 @@ extern "C" { ERR_BLE_INIT = 0, /* This event is currently not reported by the CPU2 */ ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the CPU1 to control the Thread stack is unknown */ - ERR_ZIGBEE_UNKNOWN_CMD = 200, /* The command send by the CPU1 to control the Zigbee stack is unknown */ } SCHI_SystemErrCode_t; #define SHCI_EVTCODE ( 0xFF ) @@ -102,7 +101,7 @@ extern "C" { /** * SHCI_SUB_EVT_THREAD_NVM_RAM_UPDATE - * This notifies the CPU1 which part of the OT NVM RAM has been updated so that only the modified + * This notifies the CPU1 which part of the 'OT NVM RAM' has been updated so that only the modified * section could be written in Flash/NVM * StartAddress : Start address of the section that has been modified * Size : Size (in bytes) of the section that has been modified @@ -214,9 +213,7 @@ extern "C" { SHCI_OCF_C2_FLASH_STORE_DATA, SHCI_OCF_C2_FLASH_ERASE_DATA, SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, - SHCI_OCF_C2_MAC_802_15_4_INIT, SHCI_OCF_C2_REINIT, - SHCI_OCF_C2_ZIGBEE_INIT, SHCI_OCF_C2_LLD_TESTS_INIT, SHCI_OCF_C2_EXTPA_CONFIG, SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, @@ -614,8 +611,6 @@ extern "C" { { uint8_t thread_config; uint8_t ble_config; - uint8_t mac_802_15_4_config; - uint8_t zigbee_config; } SHCI_C2_DEBUG_TracesConfig_t; typedef PACKED_STRUCT @@ -674,8 +669,6 @@ extern "C" { { BLE_ENABLE, THREAD_ENABLE, - ZIGBEE_ENABLE, - MAC_ENABLE, } SHCI_C2_CONCURRENT_Mode_Param_t; /** No response parameters*/ @@ -698,18 +691,13 @@ extern "C" { { BLE_IP, THREAD_IP, - ZIGBEE_IP, } SHCI_C2_FLASH_Ip_t; /** No response parameters*/ #define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) -#define SHCI_OPCODE_C2_MAC_802_15_4_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_MAC_802_15_4_INIT) - #define SHCI_OPCODE_C2_REINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_REINIT) -#define SHCI_OPCODE_C2_ZIGBEE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_ZIGBEE_INIT) - #define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) #define SHCI_OPCODE_C2_BLE_LLD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_LLD_INIT) @@ -817,7 +805,7 @@ extern "C" { #define FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD (0xA94656B9) /* - * At startup, the informations relative to the wireless binary are stored in RAM trough a structure defined by + * At startup, the information relative to the wireless binary are stored in RAM through a structure defined by * MB_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) * each of those coded on 32 bits as shown on the table below: * @@ -870,9 +858,6 @@ extern "C" { #define INFO_STACK_TYPE_BLE_BEACON 0x04 #define INFO_STACK_TYPE_THREAD_FTD 0x10 #define INFO_STACK_TYPE_THREAD_MTD 0x11 -#define INFO_STACK_TYPE_ZIGBEE_FFD 0x30 -#define INFO_STACK_TYPE_ZIGBEE_RFD 0x31 -#define INFO_STACK_TYPE_MAC 0x40 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 #define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 #define INFO_STACK_TYPE_802154_LLD_TESTS 0x60 @@ -881,12 +866,7 @@ extern "C" { #define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 #define INFO_STACK_TYPE_BLE_RLV 0x64 #define INFO_STACK_TYPE_802154_RLV 0x65 -#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_STATIC 0x70 -#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_STATIC 0x71 -#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_DYNAMIC 0x78 -#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_DYNAMIC 0x79 #define INFO_STACK_TYPE_RLV 0x80 -#define INFO_STACK_TYPE_BLE_MAC_STATIC 0x90 typedef struct { /** @@ -1060,7 +1040,7 @@ typedef struct { * @brief Starts the LLD tests CLI * * @param param_size : Nb of bytes - * @param p_param : pointeur with data to give from M4 to M0 + * @param p_param : pointer with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ); @@ -1070,19 +1050,10 @@ typedef struct { * @brief Starts the LLD tests BLE * * @param param_size : Nb of bytes - * @param p_param : pointeur with data to give from M4 to M0 + * @param p_param : pointer with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ); - - /** - * SHCI_C2_ZIGBEE_Init - * @brief Starts the Zigbee Stack - * - * @param None - * @retval Status - */ - SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ); /** * SHCI_C2_DEBUG_Init @@ -1158,16 +1129,6 @@ typedef struct { */ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn); - - /** - * SHCI_C2_MAC_802_15_4_Init - * @brief Starts the MAC 802.15.4 on M0 - * - * @param None - * @retval Status - */ - SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ); - /** * SHCI_GetWirelessFwInfo * @brief This function read back the informations relative to the wireless binary loaded. diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index 449b8b16..ef403aab 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -16,12 +16,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 +169,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 ) { @@ -252,3 +267,5 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } +#endif /* STM32WBxx */ + diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h index b47b804a..5a2b2a55 100644 --- a/src/utility/STM32Cube_FW/stm32_wpan_common.h +++ b/src/utility/STM32Cube_FW/stm32_wpan_common.h @@ -25,19 +25,9 @@ extern "C" { #endif -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline -#endif +#define __ASM __asm /*!< asm keyword for GNU Compiler */ +#define __INLINE inline /*!< inline keyword for GNU Compiler */ +#define __STATIC_INLINE static inline #include #include @@ -140,29 +130,8 @@ extern "C" { /* ----------------------------------- * * Packed usage (compiler dependent) * * ----------------------------------- */ -#undef PACKED__ #undef PACKED_STRUCT - -#if defined ( __CC_ARM ) - #if defined ( __GNUC__ ) - /* GNU extension */ - #define PACKED__ __attribute__((packed)) - #define PACKED_STRUCT struct PACKED__ - #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050U) - #define PACKED__ __attribute__((packed)) - #define PACKED_STRUCT struct PACKED__ - #else - #define PACKED__(TYPE) __packed TYPE - #define PACKED_STRUCT PACKED__(struct) - #endif -#elif defined ( __GNUC__ ) - #define PACKED__ __attribute__((packed)) - #define PACKED_STRUCT struct PACKED__ -#elif defined (__ICCARM__) - #define PACKED_STRUCT __packed struct -#else - #define PACKED_STRUCT __packed struct -#endif +#define PACKED_STRUCT struct __packed #ifdef __cplusplus } diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c index 69c8c064..3dea7512 100644 --- a/src/utility/STM32Cube_FW/stm_list.c +++ b/src/utility/STM32Cube_FW/stm_list.c @@ -16,13 +16,13 @@ ****************************************************************************** */ - +#if defined(STM32WBxx) /****************************************************************************** * Include Files ******************************************************************************/ -#include "utilities_common.h" - #include "stm_list.h" +#include "cmsis_gcc.h" +#include "stm32_wpan_common.h" /****************************************************************************** * Function Definitions @@ -33,10 +33,10 @@ void LST_init_head (tListNode * listHead) listHead->prev = listHead; } -uint8_t LST_is_empty (tListNode * listHead) +bool LST_is_empty (tListNode * listHead) { uint32_t primask_bit; - uint8_t return_value; + bool return_value; primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ @@ -205,3 +205,4 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } +#endif /* STM32WBxx */ \ No newline at end of file diff --git a/src/utility/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h index b7c3254c..769c2113 100644 --- a/src/utility/STM32Cube_FW/stm_list.h +++ b/src/utility/STM32Cube_FW/stm_list.h @@ -21,6 +21,8 @@ #define _STM_LIST_H_ /* Includes ------------------------------------------------------------------*/ +#include "stdint.h" +#include "stdbool.h" #include "stm32_wpan_common.h" typedef PACKED_STRUCT _tListNode { @@ -30,7 +32,7 @@ typedef PACKED_STRUCT _tListNode { void LST_init_head (tListNode * listHead); -uint8_t LST_is_empty (tListNode * listHead); +bool LST_is_empty (tListNode * listHead); void LST_insert_head (tListNode * listHead, tListNode * node); diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h index cb27246b..16de7f16 100644 --- a/src/utility/STM32Cube_FW/tl.h +++ b/src/utility/STM32Cube_FW/tl.h @@ -198,19 +198,6 @@ typedef struct uint8_t *p_BleLldM0CmdBuffer; } TL_BLE_LLD_Config_t; -typedef struct -{ - uint8_t *p_Mac_802_15_4_CmdRspBuffer; - uint8_t *p_Mac_802_15_4_NotAckBuffer; -} TL_MAC_802_15_4_Config_t; - -typedef struct -{ - uint8_t *p_ZigbeeOtCmdRspBuffer; - uint8_t *p_ZigbeeNotAckBuffer; - uint8_t *p_ZigbeeNotifRequestBuffer; -} TL_ZIGBEE_Config_t; - /** * @brief Contain the BLE HCI Init Configuration * @{ @@ -304,26 +291,6 @@ void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); void TL_TRACES_Init( void ); void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ); -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ); -void TL_MAC_802_15_4_SendCmd( void ); -void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); -void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ); -void TL_MAC_802_15_4_SendAck ( void ); - -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ); -void TL_ZIGBEE_SendM4RequestToM0( void ); -void TL_ZIGBEE_SendM4AckToM0Notify ( void ); -void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ); -void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); -void TL_ZIGBEE_M0RequestReceived(TL_EvtPacket_t * Otbuffer ); -void TL_ZIGBEE_SendM4AckToM0Request(void); - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c index 148bcb19..709f5d24 100644 --- a/src/utility/STM32Cube_FW/tl_mbox.c +++ b/src/utility/STM32Cube_FW/tl_mbox.c @@ -16,6 +16,7 @@ ****************************************************************************** */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -51,15 +52,13 @@ 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; -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; /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue; PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)]; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode EvtQueue; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode SystemEvtQueue; +PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode EvtQueue; +PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode SystemEvtQueue; static tListNode LocalFreeBufQueue; @@ -97,8 +96,6 @@ 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; - TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; - TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; HW_IPCC_Init(); return; @@ -451,139 +448,6 @@ void TL_BLE_LLD_SendRspAck( void ) } #endif /* BLE_LLD_WB */ -#ifdef MAC_802_15_4_WB -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ) -{ - MB_Mac_802_15_4_t * p_mac_802_15_4_table; - - p_mac_802_15_4_table = TL_RefTable.p_mac_802_15_4_table; - - p_mac_802_15_4_table->p_cmdrsp_buffer = p_Config->p_Mac_802_15_4_CmdRspBuffer; - p_mac_802_15_4_table->p_notack_buffer = p_Config->p_Mac_802_15_4_NotAckBuffer; - - HW_IPCC_MAC_802_15_4_Init(); - - return; -} - -void TL_MAC_802_15_4_SendCmd( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; - - HW_IPCC_MAC_802_15_4_SendCmd(); - - return; -} - -void TL_MAC_802_15_4_SendAck ( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_MAC_802_15_4_SendAck(); - - return; -} - -void HW_IPCC_MAC_802_15_4_CmdEvtNot(void) -{ - TL_MAC_802_15_4_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer) ); - - return; -} - -void HW_IPCC_MAC_802_15_4_EvtNot( void ) -{ - TL_MAC_802_15_4_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer) ); - - return; -} - -__WEAK void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; -__WEAK void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){}; -#endif - -#ifdef ZIGBEE_WB -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ) -{ - MB_ZigbeeTable_t * p_zigbee_table; - - p_zigbee_table = TL_RefTable.p_zigbee_table; - p_zigbee_table->appliCmdM4toM0_buffer = p_Config->p_ZigbeeOtCmdRspBuffer; - p_zigbee_table->notifM0toM4_buffer = p_Config->p_ZigbeeNotAckBuffer; - p_zigbee_table->requestM0toM4_buffer = p_Config->p_ZigbeeNotifRequestBuffer; - - HW_IPCC_ZIGBEE_Init(); - - return; -} - -/* Zigbee M4 to M0 Request */ -void TL_ZIGBEE_SendM4RequestToM0( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendM4RequestToM0(); - - return; -} - -/* Used to receive an ACK from the M0 */ -void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void) -{ - TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) ); - - return; -} - -/* Zigbee notification from M0 to M4 */ -void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ) -{ - TL_ZIGBEE_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer) ); - - return; -} - -/* Send an ACK to the M0 for a Notification */ -void TL_ZIGBEE_SendM4AckToM0Notify ( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendM4AckToM0Notify(); - - return; -} - -/* Zigbee M0 to M4 Request */ -void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ) -{ - TL_ZIGBEE_M0RequestReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer) ); - - return; -} - -/* Send an ACK to the M0 for a Request */ -void TL_ZIGBEE_SendM4AckToM0Request(void) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendM4AckToM0Request(); - - return; -} - - -__WEAK void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; -__WEAK void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){}; -#endif - - - /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -845,3 +709,5 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } + +#endif /* STM32WBxx */ From 0d821e8bef7b962d09f54088426fe99250953ee4 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Mon, 6 Dec 2021 11:18:02 +0100 Subject: [PATCH 20/58] fix: include a timeout when waiting for the cmd_resp Signed-off-by: Francois Ramu Signed-off-by: Alexandre Bourdiol --- src/utility/STM32Cube_FW/shci_tl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index ef403aab..6cccc5dd 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -20,6 +20,8 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" +#include + #include "stm_list.h" #include "shci_tl.h" #include "stm32_def.h" @@ -250,11 +252,12 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { - (void)timeout; - CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; - 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 55aa462a677c26d8a4f6f86b2efacdb6b82e77b4 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Mon, 6 Dec 2021 18:59:38 +0100 Subject: [PATCH 21/58] Added support for custom app_conf.h (#35) --- src/utility/STM32Cube_FW/app_conf_default.h | 75 ++++++++++++++------- 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h index 4f300e0a..9f8e085d 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -1,8 +1,8 @@ /** ****************************************************************************** - * @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 * @@ -17,11 +17,8 @@ */ /* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef APP_CONF_H -#define APP_CONF_H - -#include "hw.h" -#include "ble_bufsize.h" +#ifndef APP_CONF_DEFAULT_H +#define APP_CONF_DEFAULT_H /****************************************************************************** * Application Config @@ -44,7 +41,9 @@ /** * Define Tx Power */ -#define CFG_TX_POWER (0x18) /* -0.15dBm */ +#ifndef CFG_TX_POWER + #define CFG_TX_POWER (0x18) /* -0.15dBm */ +#endif /****************************************************************************** * BLE Stack @@ -53,32 +52,41 @@ * Maximum number of simultaneous connections that the device will support. * Valid values are from 1 to 8 */ -#define CFG_BLE_NUM_LINK 2 +#ifndef CFG_BLE_NUM_LINK + #define CFG_BLE_NUM_LINK 2 +#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 + * 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 #define CFG_BLE_NUM_GATT_SERVICES 8 +#endif /** * Maximum number of Attributes - * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) - * that can be stored in the GATT database. - * 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 + * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the + * services) that can be stored in the GATT database. 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 + #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#endif /** * Maximum supported ATT_MTU size * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" */ -#define CFG_BLE_MAX_ATT_MTU (156) +#ifndef CFG_BLE_MAX_ATT_MTU + #define CFG_BLE_MAX_ATT_MTU (156) +#endif /** * Size of the storage area for Attribute values - * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: + * This value depends on the number of attributes used by application. In particular the sum of the following + * quantities (in octets) should be made for each attribute: * - attribute value length * - 5, if UUID is 16 bit; 19, if UUID is 128 bit * - 2, if server configuration descriptor is used @@ -87,14 +95,18 @@ * The total amount of memory needed is the sum of the above quantities for each attribute. * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" */ +#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) +#endif /** * Prepare Write List size in terms of number of packet * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" */ // #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) +#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE + #define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) +#endif /** * Number of allocated memory blocks @@ -106,12 +118,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 Slave mode (ppm value) */ -#define CFG_BLE_SLAVE_SCA 500 +#ifndef CFG_BLE_SLAVE_SCA + #define CFG_BLE_SLAVE_SCA 500 +#endif /** * Sleep clock accuracy in Master mode @@ -124,24 +140,32 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#define CFG_BLE_MASTER_SCA 0 +#ifndef CFG_BLE_MASTER_SCA + #define CFG_BLE_MASTER_SCA 0 +#endif /** * Source for the low speed clock for RF wake-up * 1 : external high speed crystal HSE/32/32 * 0 : external low speed crystal ( no calibration ) */ -#define CFG_BLE_LSE_SOURCE 0 +#ifndef CFG_BLE_LSE_SOURCE + #define CFG_BLE_LSE_SOURCE 0 +#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 Slave 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 @@ -199,5 +223,4 @@ #define CFG_BLE_RX_MODEL_CONFIG SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY - -#endif /*APP_CONF_H */ +#endif /* APP_CONF_DEFAULT_H */ From abeaf9a760ec5937bb3a66e45dc3125d63fc2373 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Tue, 7 Dec 2021 14:27:27 +0100 Subject: [PATCH 22/58] Stub OutputDbgTrace() function Signed-off-by: Alexandre Bourdiol --- src/utility/STM32Cube_FW/tl_mbox.c | 178 +---------------------------- 1 file changed, 3 insertions(+), 175 deletions(-) diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c index 709f5d24..db192c4f 100644 --- a/src/utility/STM32Cube_FW/tl_mbox.c +++ b/src/utility/STM32Cube_FW/tl_mbox.c @@ -24,7 +24,6 @@ #include "stm_list.h" #include "tl.h" #include "mbox_def.h" -#include "tl_dbg_conf.h" /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -532,180 +531,9 @@ __WEAK void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ) ******************************************************************************/ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) { - TL_EvtPacket_t *p_evt_packet; - TL_CmdPacket_t *p_cmd_packet; - - switch(packet_type) - { - case TL_MB_MM_RELEASE_BUFFER: - p_evt_packet = (TL_EvtPacket_t*)buffer; - switch(p_evt_packet->evtserial.evt.evtcode) - { - case TL_BLEEVT_CS_OPCODE: - TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); - TL_MM_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); - TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); - break; - - case TL_BLEEVT_CC_OPCODE: - TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); - TL_MM_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); - TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); - break; - - case TL_BLEEVT_VS_OPCODE: - TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); - TL_MM_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); - TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); - break; - - default: - TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); - TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); - break; - } - - TL_MM_DBG_MSG("\r\n"); - break; - - case TL_MB_BLE_CMD: - p_cmd_packet = (TL_CmdPacket_t*)buffer; - TL_HCI_CMD_DBG_MSG("ble cmd: 0x%04X", p_cmd_packet->cmdserial.cmd.cmdcode); - if(p_cmd_packet->cmdserial.cmd.plen != 0) - { - TL_HCI_CMD_DBG_MSG(" payload:"); - TL_HCI_CMD_DBG_BUF(p_cmd_packet->cmdserial.cmd.payload, p_cmd_packet->cmdserial.cmd.plen, ""); - } - TL_HCI_CMD_DBG_MSG("\r\n"); - - TL_HCI_CMD_DBG_RAW(&p_cmd_packet->cmdserial, p_cmd_packet->cmdserial.cmd.plen+TL_CMD_HDR_SIZE); - break; - - case TL_MB_BLE_CMD_RSP: - p_evt_packet = (TL_EvtPacket_t*)buffer; - switch(p_evt_packet->evtserial.evt.evtcode) - { - case TL_BLEEVT_CS_OPCODE: - TL_HCI_CMD_DBG_MSG("ble rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode); - TL_HCI_CMD_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); - TL_HCI_CMD_DBG_MSG(" numhci: 0x%02X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->numcmd); - TL_HCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->status); - break; - - case TL_BLEEVT_CC_OPCODE: - TL_HCI_CMD_DBG_MSG("ble rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode); - TL_HCI_CMD_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); - TL_HCI_CMD_DBG_MSG(" numhci: 0x%02X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->numcmd); - TL_HCI_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_HCI_CMD_DBG_MSG(" payload:"); - TL_HCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[1], p_evt_packet->evtserial.evt.plen-4, ""); - } - break; - - default: - TL_HCI_CMD_DBG_MSG("unknown ble rsp received: %02X", p_evt_packet->evtserial.evt.evtcode); - break; - } - - TL_HCI_CMD_DBG_MSG("\r\n"); - - TL_HCI_CMD_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); - break; - - case TL_MB_BLE_ASYNCH_EVT: - p_evt_packet = (TL_EvtPacket_t*)buffer; - if(p_evt_packet->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) - { - TL_HCI_EVT_DBG_MSG("ble evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); - if((p_evt_packet->evtserial.evt.plen) != 0) - { - TL_HCI_EVT_DBG_MSG(" payload:"); - TL_HCI_EVT_DBG_BUF(p_evt_packet->evtserial.evt.payload, p_evt_packet->evtserial.evt.plen, ""); - } - } - else - { - TL_HCI_EVT_DBG_MSG("ble evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); - TL_HCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); - if((p_evt_packet->evtserial.evt.plen-2) != 0) - { - TL_HCI_EVT_DBG_MSG(" payload:"); - TL_HCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload, p_evt_packet->evtserial.evt.plen-2, ""); - } - } - - TL_HCI_EVT_DBG_MSG("\r\n"); - - TL_HCI_EVT_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); - break; - - case TL_MB_SYS_CMD: - p_cmd_packet = (TL_CmdPacket_t*)buffer; - - TL_SHCI_CMD_DBG_MSG("sys cmd: 0x%04X", p_cmd_packet->cmdserial.cmd.cmdcode); - - if(p_cmd_packet->cmdserial.cmd.plen != 0) - { - TL_SHCI_CMD_DBG_MSG(" payload:"); - TL_SHCI_CMD_DBG_BUF(p_cmd_packet->cmdserial.cmd.payload, p_cmd_packet->cmdserial.cmd.plen, ""); - } - TL_SHCI_CMD_DBG_MSG("\r\n"); - - TL_SHCI_CMD_DBG_RAW(&p_cmd_packet->cmdserial, p_cmd_packet->cmdserial.cmd.plen+TL_CMD_HDR_SIZE); - break; - - case TL_MB_SYS_CMD_RSP: - p_evt_packet = (TL_EvtPacket_t*)buffer; - switch(p_evt_packet->evtserial.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(" payload:"); - TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[1], p_evt_packet->evtserial.evt.plen-4, ""); - } - break; - - default: - TL_SHCI_CMD_DBG_MSG("unknown sys rsp received: %02X", p_evt_packet->evtserial.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); - break; - - case TL_MB_SYS_ASYNCH_EVT: - p_evt_packet = (TL_EvtPacket_t*)buffer; - if(p_evt_packet->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) - { - TL_SHCI_EVT_DBG_MSG("unknown sys evt received: %02X", p_evt_packet->evtserial.evt.evtcode); - } - else - { - TL_SHCI_EVT_DBG_MSG("sys evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); - TL_SHCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); - if((p_evt_packet->evtserial.evt.plen-2) != 0) - { - TL_SHCI_EVT_DBG_MSG(" payload:"); - TL_SHCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload, p_evt_packet->evtserial.evt.plen-2, ""); - } - } - - TL_SHCI_EVT_DBG_MSG("\r\n"); - - TL_SHCI_EVT_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); - break; - - default: - break; - } + /* Function stubbed */ + UNUSED(packet_type); + UNUSED(buffer); return; } From 061ec8e7902ab1754a65264787f704d4bb265766 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Fri, 8 Apr 2022 15:01:59 +0200 Subject: [PATCH 23/58] Update STM32Cube_FW from Cube version v1.13.3 Signed-off-by: Alexandre Bourdiol --- src/utility/STM32Cube_FW/README.md | 4 +- src/utility/STM32Cube_FW/ble_bufsize.h | 33 +- src/utility/STM32Cube_FW/shci.h | 9 +- src/utility/STM32Cube_FW/stm_list.c | 416 ++++++++++++------------- 4 files changed, 236 insertions(+), 226 deletions(-) diff --git a/src/utility/STM32Cube_FW/README.md b/src/utility/STM32Cube_FW/README.md index 419d0eb0..dc03bb92 100644 --- a/src/utility/STM32Cube_FW/README.md +++ b/src/utility/STM32Cube_FW/README.md @@ -1,6 +1,6 @@ ## Source -[STMicroelectronics/STM32CubeWB Release v1.13.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.13.0) -- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.13.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) +[STMicroelectronics/STM32CubeWB Release v1.13.3](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.13.3) +- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.13.3/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h index 73b78872..12b5fdb9 100644 --- a/src/utility/STM32Cube_FW/ble_bufsize.h +++ b/src/utility/STM32Cube_FW/ble_bufsize.h @@ -1,11 +1,11 @@ /***************************************************************************** * @file ble_bufsize.h - * @author MCD + * @author MDG * @brief Definition of BLE stack buffers size ***************************************************************************** * @attention * - * Copyright (c) 2018-2021 STMicroelectronics. + * Copyright (c) 2018-2022 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file @@ -97,28 +97,28 @@ * mentioned parameters. */ #if (BEACON_ONLY != 0) -#define BLE_FIXED_BUFFER_SIZE_BYTES 4184 /* Beacon only */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 4076 /* Beacon only */ #elif (LL_ONLY != 0) -#define BLE_FIXED_BUFFER_SIZE_BYTES 6068 /* LL only */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 5936 /* LL only */ #elif (SLAVE_ONLY != 0) -#define BLE_FIXED_BUFFER_SIZE_BYTES 6096 /* Peripheral only */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 6204 /* Peripheral only */ #elif (BASIC_FEATURES != 0) -#define BLE_FIXED_BUFFER_SIZE_BYTES 6400 /* Basic Features */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 6532 /* Basic Features */ #else -#define BLE_FIXED_BUFFER_SIZE_BYTES 7312 /* Full stack */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 7052 /* Full stack */ #endif /* * BLE_PER_LINK_SIZE_BYTES: additional memory size used per link */ #if (BEACON_ONLY != 0) -#define BLE_PER_LINK_SIZE_BYTES 192 /* Beacon only */ +#define BLE_PER_LINK_SIZE_BYTES 128 /* Beacon only */ #elif (LL_ONLY != 0) #define BLE_PER_LINK_SIZE_BYTES 260 /* LL only */ #elif (SLAVE_ONLY != 0) -#define BLE_PER_LINK_SIZE_BYTES 388 /* Peripheral only */ +#define BLE_PER_LINK_SIZE_BYTES 392 /* Peripheral only */ #elif (BASIC_FEATURES != 0) -#define BLE_PER_LINK_SIZE_BYTES 388 /* Basic Features */ +#define BLE_PER_LINK_SIZE_BYTES 440 /* Basic Features */ #else #define BLE_PER_LINK_SIZE_BYTES 444 /* Full stack */ #endif @@ -141,10 +141,17 @@ /* * BLE_EXT_ADV_BUFFER_SIZE * additional memory size used for Extended advertising; - * It has to be added to BLE_TOTAL_BUFFER_SIZE(). - * The formula used is based on:(1792 + ((set_nbr) * (60 + (2 * (data_len))))) + * It has to be added to BLE_TOTAL_BUFFER_SIZE() if the Extended advertising + * feature is used. + * + * @param set_nbr: Maximum number of advertising sets. + * Valid values are from 1 to 8. + * + * @param data_len: Maximum size of advertising data. + * Valid values are from 31 to 1650. */ -#define BLE_EXT_ADV_BUFFER_SIZE(set_nbr, data_len) (7596) +#define BLE_EXT_ADV_BUFFER_SIZE(set_nbr, data_len) \ + (2304 + ((892 + (DIVC(data_len, 207) * 244)) * (set_nbr))) /* * BLE_TOTAL_BUFFER_SIZE_GATT: this macro returns the amount of memory, diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h index 9449c224..d965ec84 100644 --- a/src/utility/STM32Cube_FW/shci.h +++ b/src/utility/STM32Cube_FW/shci.h @@ -526,7 +526,7 @@ extern "C" { * - bit 0: 1: LL only 0: LL + host * - bit 1: 1: no service change desc. 0: with service change desc. * - bit 2: 1: device name Read-Only 0: device name R/W - * - bit 3: 1: extended advertizing supported 0: extended advertizing not supported [NOT SUPPORTED] + * - bit 3: 1: extended advertizing supported 0: extended advertizing not supported * - bit 4: 1: CS Algo #2 supported 0: CS Algo #2 not supported * - bit 7: 1: LE Power Class 1 0: LE Power Classe 2-3 * - other bits: reserved ( shall be set to 0) @@ -585,8 +585,8 @@ extern "C" { #define SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RO (1<<2) #define SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW (0<<2) -#define SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV (1<<3) /*NOT SUPPORTED*/ -#define SHCI_C2_BLE_INIT_OPTIONS_NO_EXT_ADV (0<<3) /*NOT SUPPORTED*/ +#define SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV (1<<3) +#define SHCI_C2_BLE_INIT_OPTIONS_NO_EXT_ADV (0<<3) #define SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 (1<<4) #define SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2 (0<<4) @@ -856,6 +856,9 @@ extern "C" { #define INFO_STACK_TYPE_BLE_HCI 0x02 #define INFO_STACK_TYPE_BLE_LIGHT 0x03 #define INFO_STACK_TYPE_BLE_BEACON 0x04 +#define INFO_STACK_TYPE_BLE_BASIC 0x05 +#define INFO_STACK_TYPE_BLE_FULL_EXT_ADV 0x06 +#define INFO_STACK_TYPE_BLE_HCI_EXT_ADV 0x07 #define INFO_STACK_TYPE_THREAD_FTD 0x10 #define INFO_STACK_TYPE_THREAD_MTD 0x11 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c index 3dea7512..d8c9e093 100644 --- a/src/utility/STM32Cube_FW/stm_list.c +++ b/src/utility/STM32Cube_FW/stm_list.c @@ -1,208 +1,208 @@ -/** - ****************************************************************************** - * @file stm_list.c - * @author MCD Application Team - * @brief TCircular Linked List Implementation. - ****************************************************************************** - * @attention - * - * Copyright (c) 2018-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. - * - ****************************************************************************** - */ - -#if defined(STM32WBxx) -/****************************************************************************** - * Include Files - ******************************************************************************/ -#include "stm_list.h" -#include "cmsis_gcc.h" -#include "stm32_wpan_common.h" - -/****************************************************************************** - * Function Definitions - ******************************************************************************/ -void LST_init_head (tListNode * listHead) -{ - listHead->next = listHead; - listHead->prev = listHead; -} - -bool LST_is_empty (tListNode * listHead) -{ - uint32_t primask_bit; - bool return_value; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - if(listHead->next == listHead) - { - return_value = TRUE; - } - else - { - return_value = FALSE; - } - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ - - return return_value; -} - -void LST_insert_head (tListNode * listHead, tListNode * node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = listHead->next; - node->prev = listHead; - listHead->next = node; - (node->next)->prev = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_insert_tail (tListNode * listHead, tListNode * node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = listHead; - node->prev = listHead->prev; - listHead->prev = node; - (node->prev)->next = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_remove_node (tListNode * node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - (node->prev)->next = node->next; - (node->next)->prev = node->prev; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_remove_head (tListNode * listHead, tListNode ** node ) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = listHead->next; - LST_remove_node (listHead->next); - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_remove_tail (tListNode * listHead, tListNode ** node ) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = listHead->prev; - LST_remove_node (listHead->prev); - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_insert_node_after (tListNode * node, tListNode * ref_node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = ref_node->next; - node->prev = ref_node; - ref_node->next = node; - (node->next)->prev = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_insert_node_before (tListNode * node, tListNode * ref_node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = ref_node; - node->prev = ref_node->prev; - ref_node->prev = node; - (node->prev)->next = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -int LST_get_size (tListNode * listHead) -{ - int size = 0; - tListNode * temp; - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - temp = listHead->next; - while (temp != listHead) - { - size++; - temp = temp->next; - } - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ - - return (size); -} - -void LST_get_next_node (tListNode * ref_node, tListNode ** node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = ref_node->next; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_get_prev_node (tListNode * ref_node, tListNode ** node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = ref_node->prev; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - -#endif /* STM32WBxx */ \ No newline at end of file +/** + ****************************************************************************** + * @file stm_list.c + * @author MCD Application Team + * @brief TCircular Linked List Implementation. + ****************************************************************************** + * @attention + * + * Copyright (c) 2018-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. + * + ****************************************************************************** + */ + +#if defined(STM32WBxx) +/****************************************************************************** + * Include Files + ******************************************************************************/ +#include "stm_list.h" +#include "cmsis_gcc.h" +#include "stm32_wpan_common.h" + +/****************************************************************************** + * Function Definitions + ******************************************************************************/ +void LST_init_head (tListNode * listHead) +{ + listHead->next = listHead; + listHead->prev = listHead; +} + +bool LST_is_empty (tListNode * listHead) +{ + uint32_t primask_bit; + bool return_value; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + if(listHead->next == listHead) + { + return_value = TRUE; + } + else + { + return_value = FALSE; + } + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ + + return return_value; +} + +void LST_insert_head (tListNode * listHead, tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = listHead->next; + node->prev = listHead; + listHead->next = node; + (node->next)->prev = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_insert_tail (tListNode * listHead, tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = listHead; + node->prev = listHead->prev; + listHead->prev = node; + (node->prev)->next = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_remove_node (tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + (node->prev)->next = node->next; + (node->next)->prev = node->prev; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_remove_head (tListNode * listHead, tListNode ** node ) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = listHead->next; + LST_remove_node (listHead->next); + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_remove_tail (tListNode * listHead, tListNode ** node ) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = listHead->prev; + LST_remove_node (listHead->prev); + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_insert_node_after (tListNode * node, tListNode * ref_node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = ref_node->next; + node->prev = ref_node; + ref_node->next = node; + (node->next)->prev = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_insert_node_before (tListNode * node, tListNode * ref_node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = ref_node; + node->prev = ref_node->prev; + ref_node->prev = node; + (node->prev)->next = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +int LST_get_size (tListNode * listHead) +{ + int size = 0; + tListNode * temp; + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + temp = listHead->next; + while (temp != listHead) + { + size++; + temp = temp->next; + } + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ + + return (size); +} + +void LST_get_next_node (tListNode * ref_node, tListNode ** node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = ref_node->next; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_get_prev_node (tListNode * ref_node, tListNode ** node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = ref_node->prev; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + +#endif /* STM32WBxx */ \ No newline at end of file From 381c3ca61658983c9836545603869a185f04eee8 Mon Sep 17 00:00:00 2001 From: Giuseppe Roberti Date: Tue, 30 Aug 2022 11:55:17 +0200 Subject: [PATCH 24/58] Fix hard fault when str is NULL --- src/utility/BLEUuid.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utility/BLEUuid.cpp b/src/utility/BLEUuid.cpp index fba6244a..0465ea9a 100644 --- a/src/utility/BLEUuid.cpp +++ b/src/utility/BLEUuid.cpp @@ -30,6 +30,11 @@ BLEUuid::BLEUuid(const char * str) : memset(_data, 0x00, sizeof(_data)); _length = 0; + + if (str == NULL) { + return; + } + for (int i = strlen(str) - 1; i >= 0 && _length < BLE_UUID_MAX_LENGTH; i -= 2) { if (str[i] == '-') { i++; From 6e951334cbf0a703c6a5a61972c9ed0de1fb4509 Mon Sep 17 00:00:00 2001 From: Giuseppe Roberti Date: Tue, 9 Aug 2022 10:17:09 +0200 Subject: [PATCH 25/58] Support BlueNRG-LP --- examples/Peripheral/ButtonLED/ButtonLED.ino | 13 +- keywords.txt | 2 +- src/utility/HCISpiTransport.cpp | 314 +++++++++++++++++--- src/utility/HCISpiTransport.h | 7 +- 4 files changed, 295 insertions(+), 41 deletions(-) diff --git a/examples/Peripheral/ButtonLED/ButtonLED.ino b/examples/Peripheral/ButtonLED/ButtonLED.ino index c3f777d4..f12adb50 100644 --- a/examples/Peripheral/ButtonLED/ButtonLED.ino +++ b/examples/Peripheral/ButtonLED/ButtonLED.ino @@ -6,7 +6,7 @@ represents the state of the button. The circuit: - - STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 You can use a generic BLE central app, like LightBlue (iOS and Android) or nRF Connect (Android), to interact with the services and characteristics @@ -17,7 +17,16 @@ #include -#if defined(ARDUINO_STEVAL_MKSBOX1V1) +#if defined(ARDUINO_STEVAL_MKBOXPRO) +/* STEVAL-MKBOXPRO */ +SPIClass SpiHCI(PA7, PA6, PA5); +HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000, SPI_MODE3); +#if !defined(FAKE_BLELOCALDEVICE) +BLELocalDevice BLEObj(&HCISpiTransport); +BLELocalDevice& BLE = BLEObj; +#endif +const int buttonPin = PC13; // set buttonPin to digital pin PC13 +#elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000, SPI_MODE1); diff --git a/keywords.txt b/keywords.txt index 9214671b..e13de56d 100644 --- a/keywords.txt +++ b/keywords.txt @@ -143,5 +143,5 @@ BLEUpdated LITERAL1 SPBTLE_RF LITERAL1 SPBTLE_1S LITERAL1 BLUENRG_M2SP LITERAL1 +BLUENRG_LP LITERAL1 BLEChip_t LITERAL1 - diff --git a/src/utility/HCISpiTransport.cpp b/src/utility/HCISpiTransport.cpp index a503b427..b2abddd4 100644 --- a/src/utility/HCISpiTransport.cpp +++ b/src/utility/HCISpiTransport.cpp @@ -33,6 +33,7 @@ HCISpiTransportClass::HCISpiTransportClass(SPIClass &spi, BLEChip_t ble_chip, ui _write_index = 0; _write_index_initial = 0; _initial_phase = 1; + _random_addr_done = false; } HCISpiTransportClass::~HCISpiTransportClass() @@ -66,7 +67,7 @@ int HCISpiTransportClass::begin() digitalWrite(_ble_rst, HIGH); delay(5); - if (_ble_chip == SPBTLE_RF || _ble_chip == BLUENRG_M0) { + if (_ble_chip == SPBTLE_RF || _ble_chip == BLUENRG_M0 || _ble_chip == BLUENRG_LP) { // Wait for Blue Initialize wait_for_blue_initialize(); } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { @@ -97,7 +98,7 @@ void HCISpiTransportClass::wait(unsigned long timeout) int HCISpiTransportClass::available() { - if (_ble_chip != SPBTLE_RF && _ble_chip != SPBTLE_1S && _ble_chip != BLUENRG_M2SP && _ble_chip != BLUENRG_M0) { + if (_ble_chip != SPBTLE_RF && _ble_chip != SPBTLE_1S && _ble_chip != BLUENRG_M2SP && _ble_chip != BLUENRG_M0 && _ble_chip != BLUENRG_LP) { return 0; } @@ -115,7 +116,7 @@ int HCISpiTransportClass::available() while (digitalRead(_spi_irq) == 1 && _write_index != BLE_MODULE_SPI_BUFFER_SIZE) { uint8_t header_master[5] = {0x0b, 0x00, 0x00, 0x00, 0x00}; - if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { detachInterrupt(_spi_irq); } @@ -172,7 +173,7 @@ int HCISpiTransportClass::available() } } } - } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { uint16_t byte_count = (header_master[4] << 8) | header_master[3]; if (byte_count > 0) { @@ -222,13 +223,13 @@ int HCISpiTransportClass::available() _spi->endTransaction(); - if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); } } if (ble_reset) { - if (_ble_chip == SPBTLE_RF || _ble_chip == BLUENRG_M0) { + if (_ble_chip == SPBTLE_RF || _ble_chip == BLUENRG_M0 || _ble_chip == BLUENRG_LP) { /* BLE chip was reset: we need to enable LL_ONLY */ enable_ll_only(); wait_for_enable_ll_only(); @@ -238,18 +239,32 @@ int HCISpiTransportClass::available() } /* Call Gatt Init and Gap Init to activate the random BLE address */ - aci_gatt_init(); - wait_for_aci_gatt_init(); - aci_gap_init(); - wait_for_aci_gap_init(); - /* Call Read Config Parameter to retrieve the random BLE address */ - aci_read_config_parameter(); - wait_for_aci_read_config_parameter(); - - /* Now we can update the write index and close the initial phase */ - _write_index = _write_index_initial; - _initial_phase = 0; - _write_index_initial = 0; + if (!_random_addr_done) { + aci_gatt_init(); + wait_for_aci_gatt_init(); + aci_gap_init(); + wait_for_aci_gap_init(); + /* Call Read Config Parameter to retrieve the random BLE address */ + aci_read_config_parameter(); + wait_for_aci_read_config_parameter(); + if (_ble_chip == BLUENRG_LP) { + hci_reset(); + _read_index = _write_index = _write_index_initial = 0; + _initial_phase = 1; + } else { + /* Now we can update the write index and close the initial phase */ + _write_index = _write_index_initial; + _initial_phase = 0; + _write_index_initial = 0; + } + } else { + set_address(); + wait_for_set_address(); + /* Now we can update the write index and close the initial phase */ + _write_index = _write_index_initial; + _initial_phase = 0; + _write_index_initial = 0; + } } if (_read_index != _write_index) { @@ -297,7 +312,7 @@ size_t HCISpiTransportClass::write(const uint8_t *data, size_t length) int result = 0; uint32_t tickstart = millis(); - if (_ble_chip != SPBTLE_RF && _ble_chip != SPBTLE_1S && _ble_chip != BLUENRG_M2SP && _ble_chip != BLUENRG_M0) { + if (_ble_chip != SPBTLE_RF && _ble_chip != SPBTLE_1S && _ble_chip != BLUENRG_M2SP && _ble_chip != BLUENRG_M0 && _ble_chip != BLUENRG_LP) { return 0; } @@ -332,7 +347,7 @@ size_t HCISpiTransportClass::write(const uint8_t *data, size_t length) result = -3; break; } - } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { uint32_t tickstart_data_available = millis(); result = 0; @@ -406,7 +421,7 @@ void HCISpiTransportClass::wait_for_blue_initialize() while (digitalRead(_spi_irq) == 1) { uint8_t header_master[5] = {0x0b, 0x00, 0x00, 0x00, 0x00}; - if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { detachInterrupt(_spi_irq); } @@ -469,13 +484,38 @@ void HCISpiTransportClass::wait_for_blue_initialize() } } } + } else if (_ble_chip == BLUENRG_LP) { + uint8_t byte_count = (header_master[4] << 8) | header_master[3]; + + if (byte_count > 0) { + /* Read the response */ + if (byte_count == 7) { + for (int j = 0; j < byte_count; j++) { + event[j] = _spi->transfer(0xFF); + } + + if (event[0] == 0x82 && + event[1] == 0xFF && + event[2] == 0x03 && + event[3] == 0x00 && + event[4] == 0x01 && + event[5] == 0x00 && + event[6] == 0x01) { + event_blue_initialize = 1; + } + } else { + for (int j = 0; j < byte_count; j++) { + _spi->transfer(0xFF); + } + } + } } digitalWrite(_cs_pin, HIGH); _spi->endTransaction(); - if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); } } @@ -498,7 +538,7 @@ void HCISpiTransportClass::wait_for_enable_ll_only() while (digitalRead(_spi_irq) == 1) { uint8_t header_master[5] = {0x0b, 0x00, 0x00, 0x00, 0x00}; - if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { detachInterrupt(_spi_irq); } @@ -534,7 +574,7 @@ void HCISpiTransportClass::wait_for_enable_ll_only() } } } - } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { uint16_t byte_count = (header_master[4] << 8) | header_master[3]; if (byte_count > 0) { @@ -561,7 +601,7 @@ void HCISpiTransportClass::wait_for_enable_ll_only() _spi->endTransaction(); - if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); } } @@ -601,7 +641,7 @@ void HCISpiTransportClass::enable_ll_only() digitalWrite(_cs_pin, HIGH); _spi->endTransaction(); - } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { uint32_t tickstart_data_available = millis(); result = 0; @@ -660,7 +700,7 @@ void HCISpiTransportClass::wait_for_aci_gatt_init() while (digitalRead(_spi_irq) == 1) { uint8_t header_master[5] = {0x0b, 0x00, 0x00, 0x00, 0x00}; - if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { detachInterrupt(_spi_irq); } @@ -696,7 +736,7 @@ void HCISpiTransportClass::wait_for_aci_gatt_init() } } } - } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { uint16_t byte_count = (header_master[4] << 8) | header_master[3]; if (byte_count > 0) { @@ -723,7 +763,7 @@ void HCISpiTransportClass::wait_for_aci_gatt_init() _spi->endTransaction(); - if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); } } @@ -763,7 +803,7 @@ void HCISpiTransportClass::aci_gatt_init() digitalWrite(_cs_pin, HIGH); _spi->endTransaction(); - } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { uint32_t tickstart_data_available = millis(); result = 0; @@ -822,7 +862,7 @@ void HCISpiTransportClass::wait_for_aci_gap_init() while (digitalRead(_spi_irq) == 1) { uint8_t header_master[5] = {0x0b, 0x00, 0x00, 0x00, 0x00}; - if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { detachInterrupt(_spi_irq); } @@ -858,7 +898,7 @@ void HCISpiTransportClass::wait_for_aci_gap_init() } } } - } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { uint16_t byte_count = (header_master[4] << 8) | header_master[3]; if (byte_count > 0) { @@ -885,7 +925,7 @@ void HCISpiTransportClass::wait_for_aci_gap_init() _spi->endTransaction(); - if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); } } @@ -896,6 +936,7 @@ void HCISpiTransportClass::aci_gap_init() { uint8_t header_master[5] = {0x0a, 0x00, 0x00, 0x00, 0x00}; uint8_t cmd[7] = {0x01, 0x8A, 0xFC, 0x03, 0x0F, 0x00, 0x00}; // ACI_GAP_INIT + uint8_t cmd_lp[8] = {0x01, 0x8A, 0xFC, 0x04, 0x0F, 0x00, 0x00, 0x00}; // ACI_GAP_INIT for BlueNRG-LP int result = 0; do { @@ -963,6 +1004,45 @@ void HCISpiTransportClass::aci_gap_init() _spi->endTransaction(); + attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); + } else if (_ble_chip == BLUENRG_LP) { + uint32_t tickstart_data_available = millis(); + result = 0; + + detachInterrupt(_spi_irq); + + _spi->beginTransaction(_spiSettings); + + digitalWrite(_cs_pin, LOW); + + while (!(digitalRead(_spi_irq) == 1)) { + if ((millis() - tickstart_data_available) > 1000) { + result = -3; + break; + } + } + + if (result == -3) { + digitalWrite(_cs_pin, HIGH); + _spi->endTransaction(); + attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); + break; + } + + /* Write the header */ + _spi->transfer(header_master, 5); + + if ((int)((((uint16_t)header_master[2]) << 8) | ((uint16_t)header_master[1])) >= 8) { + /* Write the data */ + _spi->transfer((void *)cmd_lp, 8); + } else { + result = -2; + } + + digitalWrite(_cs_pin, HIGH); + + _spi->endTransaction(); + attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); } } while (result < 0); @@ -984,7 +1064,7 @@ void HCISpiTransportClass::wait_for_aci_read_config_parameter() while (digitalRead(_spi_irq) == 1) { uint8_t header_master[5] = {0x0b, 0x00, 0x00, 0x00, 0x00}; - if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { detachInterrupt(_spi_irq); } @@ -1021,7 +1101,7 @@ void HCISpiTransportClass::wait_for_aci_read_config_parameter() } } } - } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { uint16_t byte_count = (header_master[4] << 8) | header_master[3]; if (byte_count > 0) { @@ -1040,6 +1120,7 @@ void HCISpiTransportClass::wait_for_aci_read_config_parameter() data[6] == 0x00) { memcpy(_random_addr, &data[8], 6); status = 1; + _random_addr_done = true; } } } @@ -1049,7 +1130,7 @@ void HCISpiTransportClass::wait_for_aci_read_config_parameter() _spi->endTransaction(); - if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); } } @@ -1089,7 +1170,7 @@ void HCISpiTransportClass::aci_read_config_parameter() digitalWrite(_cs_pin, HIGH); _spi->endTransaction(); - } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { + } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { uint32_t tickstart_data_available = millis(); result = 0; @@ -1131,3 +1212,162 @@ void HCISpiTransportClass::aci_read_config_parameter() } } while (result < 0); } + +void HCISpiTransportClass::hci_reset() +{ + uint8_t header_master[5] = {0x0a, 0x00, 0x00, 0x00, 0x00}; + uint8_t cmd[4] = {0x01, 0x03, 0x0C, 0x00}; // HCI_RESET + int result = 0; + + do { + if (_ble_chip == BLUENRG_LP) { + uint32_t tickstart_data_available = millis(); + result = 0; + + detachInterrupt(_spi_irq); + + _spi->beginTransaction(_spiSettings); + + digitalWrite(_cs_pin, LOW); + + while (!(digitalRead(_spi_irq) == 1)) { + if ((millis() - tickstart_data_available) > 1000) { + result = -3; + break; + } + } + + if (result == -3) { + digitalWrite(_cs_pin, HIGH); + _spi->endTransaction(); + attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); + break; + } + + /* Write the header */ + _spi->transfer(header_master, 5); + + if ((int)((((uint16_t)header_master[2]) << 8) | ((uint16_t)header_master[1])) >= 4) { + /* Write the data */ + _spi->transfer((void *)cmd, 4); + } else { + result = -2; + } + + digitalWrite(_cs_pin, HIGH); + + _spi->endTransaction(); + + attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); + } + } while (result < 0); +} + +void HCISpiTransportClass::set_address() +{ + uint8_t header_master[5] = {0x0a, 0x00, 0x00, 0x00, 0x00}; + uint8_t cmd[10] = {0x01, 0x05, 0x20, 0x06}; // SET ADDR + int result = 0; + memcpy(&cmd[4], _random_addr, 6); + + do { + if (_ble_chip == BLUENRG_LP) { + uint32_t tickstart_data_available = millis(); + result = 0; + + detachInterrupt(_spi_irq); + + _spi->beginTransaction(_spiSettings); + + digitalWrite(_cs_pin, LOW); + + while (!(digitalRead(_spi_irq) == 1)) { + if ((millis() - tickstart_data_available) > 1000) { + result = -3; + break; + } + } + + if (result == -3) { + digitalWrite(_cs_pin, HIGH); + _spi->endTransaction(); + attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); + break; + } + + /* Write the header */ + _spi->transfer(header_master, 5); + + if ((int)((((uint16_t)header_master[2]) << 8) | ((uint16_t)header_master[1])) >= 10) { + /* Write the data */ + _spi->transfer((void *)cmd, 10); + } else { + result = -2; + } + + digitalWrite(_cs_pin, HIGH); + + _spi->endTransaction(); + + attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); + } + } while (result < 0); +} + +void HCISpiTransportClass::wait_for_set_address() +{ + uint8_t data[15]; + int status = 0; + + if (_ble_chip != BLUENRG_LP) return; + + do { + while (!data_avail); + + if (digitalRead(_spi_irq) == 0) { + continue; + } + + data_avail = 0; + while (digitalRead(_spi_irq) == 1) { + uint8_t header_master[5] = {0x0b, 0x00, 0x00, 0x00, 0x00}; + uint16_t byte_count = 0; + + detachInterrupt(_spi_irq); + + _spi->beginTransaction(_spiSettings); + + digitalWrite(_cs_pin, LOW); + + /* Write the header */ + _spi->transfer(header_master, 5); + + byte_count = (header_master[4] << 8) | header_master[3]; + + if (byte_count > 0) { + /* Read the response */ + for (int j = 0; j < byte_count; j++) { + data[j] = _spi->transfer(0xFF); + } + + if (byte_count >= 7) { // 040E0401052000 + if (data[0] == 0x04 && + data[1] == 0x0E && + data[2] == 0x04 && + data[3] == 0x01 && + data[4] == 0x05 && + data[5] == 0x20 && + data[6] == 0x00) { + status = 1; + } + } + } + + digitalWrite(_cs_pin, HIGH); + + _spi->endTransaction(); + + attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); + } + } while (!status); +} diff --git a/src/utility/HCISpiTransport.h b/src/utility/HCISpiTransport.h index 9c3afc34..34af1aa9 100644 --- a/src/utility/HCISpiTransport.h +++ b/src/utility/HCISpiTransport.h @@ -27,7 +27,8 @@ typedef enum BLEChip_s { SPBTLE_RF, SPBTLE_1S, BLUENRG_M2SP, - BLUENRG_M0 + BLUENRG_M0, + BLUENRG_LP } BLEChip_t; #ifndef BLE_SPI_BYTE_ORDER @@ -61,6 +62,9 @@ class HCISpiTransportClass : public HCITransportInterface { void aci_gap_init(); void wait_for_aci_read_config_parameter(); void aci_read_config_parameter(); + void hci_reset(); + void set_address(); + void wait_for_set_address(); SPIClass *_spi; SPISettings _spiSettings; BLEChip_t _ble_chip; @@ -73,6 +77,7 @@ class HCISpiTransportClass : public HCITransportInterface { uint16_t _write_index_initial; uint8_t _initial_phase; uint8_t _random_addr[6]; + bool _random_addr_done; }; #endif /* _HCI_SPI_TRANSPORT_H_ */ From 9cf284f8ce05446b1e0064bff07fd4e83b0075f5 Mon Sep 17 00:00:00 2001 From: Giuseppe Roberti Date: Tue, 9 Aug 2022 13:34:06 +0200 Subject: [PATCH 26/58] Ugly fix delay --- src/utility/HCISpiTransport.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utility/HCISpiTransport.cpp b/src/utility/HCISpiTransport.cpp index b2abddd4..eae96911 100644 --- a/src/utility/HCISpiTransport.cpp +++ b/src/utility/HCISpiTransport.cpp @@ -113,6 +113,11 @@ int HCISpiTransportClass::available() data_avail = 0; + // Wait for BlueNRG-LP to be ready (needs to be done after each HCI RESET) + if (_ble_chip == BLUENRG_LP && _initial_phase) { + delay(100); + } + while (digitalRead(_spi_irq) == 1 && _write_index != BLE_MODULE_SPI_BUFFER_SIZE) { uint8_t header_master[5] = {0x0b, 0x00, 0x00, 0x00, 0x00}; From 831e996f17f82efec25149e39ca8655f65dbdb05 Mon Sep 17 00:00:00 2001 From: Giuseppe Roberti Date: Tue, 9 Aug 2022 16:32:20 +0200 Subject: [PATCH 27/58] LP only differ in cmd, not procedure --- src/utility/HCISpiTransport.cpp | 61 ++++++++------------------------- 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/src/utility/HCISpiTransport.cpp b/src/utility/HCISpiTransport.cpp index eae96911..5c18083f 100644 --- a/src/utility/HCISpiTransport.cpp +++ b/src/utility/HCISpiTransport.cpp @@ -940,8 +940,16 @@ void HCISpiTransportClass::wait_for_aci_gap_init() void HCISpiTransportClass::aci_gap_init() { uint8_t header_master[5] = {0x0a, 0x00, 0x00, 0x00, 0x00}; - uint8_t cmd[7] = {0x01, 0x8A, 0xFC, 0x03, 0x0F, 0x00, 0x00}; // ACI_GAP_INIT - uint8_t cmd_lp[8] = {0x01, 0x8A, 0xFC, 0x04, 0x0F, 0x00, 0x00, 0x00}; // ACI_GAP_INIT for BlueNRG-LP + uint8_t cmd_lp[8] = {0x01, 0x8A, 0xFC, 0x04, 0x0F, 0x00, 0x00, 0x00}; // ACI_GAP_INIT + uint8_t cmd_others[7] = {0x01, 0x8A, 0xFC, 0x03, 0x0F, 0x00, 0x00}; // ACI_GAP_INIT + uint8_t *cmd, cmd_size; + if (_ble_chip == BLUENRG_LP) { + cmd = cmd_lp; + cmd_size = 8; + } else { + cmd = cmd_others; + cmd_size = 7; + } int result = 0; do { @@ -958,9 +966,9 @@ void HCISpiTransportClass::aci_gap_init() /* device is ready */ if (header_master[0] == 0x02) { /* Write the data */ - if (header_master[1] >= 7) { + if (header_master[1] >= cmd_size) { /* Write the data */ - _spi->transfer((void *)cmd, 7); + _spi->transfer((void *)cmd, cmd_size); } else { result = -2; } @@ -971,46 +979,7 @@ void HCISpiTransportClass::aci_gap_init() digitalWrite(_cs_pin, HIGH); _spi->endTransaction(); - } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP) { - uint32_t tickstart_data_available = millis(); - result = 0; - - detachInterrupt(_spi_irq); - - _spi->beginTransaction(_spiSettings); - - digitalWrite(_cs_pin, LOW); - - while (!(digitalRead(_spi_irq) == 1)) { - if ((millis() - tickstart_data_available) > 1000) { - result = -3; - break; - } - } - - if (result == -3) { - digitalWrite(_cs_pin, HIGH); - _spi->endTransaction(); - attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); - break; - } - - /* Write the header */ - _spi->transfer(header_master, 5); - - if ((int)((((uint16_t)header_master[2]) << 8) | ((uint16_t)header_master[1])) >= 7) { - /* Write the data */ - _spi->transfer((void *)cmd, 7); - } else { - result = -2; - } - - digitalWrite(_cs_pin, HIGH); - - _spi->endTransaction(); - - attachInterrupt(_spi_irq, SPI_Irq_Callback, RISING); - } else if (_ble_chip == BLUENRG_LP) { + } else if (_ble_chip == SPBTLE_1S || _ble_chip == BLUENRG_M2SP || _ble_chip == BLUENRG_LP) { uint32_t tickstart_data_available = millis(); result = 0; @@ -1037,9 +1006,9 @@ void HCISpiTransportClass::aci_gap_init() /* Write the header */ _spi->transfer(header_master, 5); - if ((int)((((uint16_t)header_master[2]) << 8) | ((uint16_t)header_master[1])) >= 8) { + if ((int)((((uint16_t)header_master[2]) << 8) | ((uint16_t)header_master[1])) >= cmd_size) { /* Write the data */ - _spi->transfer((void *)cmd_lp, 8); + _spi->transfer((void *)cmd, cmd_size); } else { result = -2; } From 93af438927ffc0119caf0b2b4d4c300da3dee364 Mon Sep 17 00:00:00 2001 From: Giuseppe Roberti Date: Tue, 30 Aug 2022 14:51:20 +0200 Subject: [PATCH 28/58] Enable STEVAL-MKBOXPRO support in examples --- examples/Central/LedControl/LedControl.ino | 13 +++++++++++-- .../PeripheralExplorer/PeripheralExplorer.ino | 13 +++++++++++-- examples/Central/Scan/Scan.ino | 13 +++++++++++-- examples/Central/ScanCallback/ScanCallback.ino | 13 +++++++++++-- .../Central/SensorTagButton/SensorTagButton.ino | 13 +++++++++++-- examples/Peripheral/CallbackLED/CallbackLED.ino | 13 +++++++++++-- examples/Peripheral/LED/LED.ino | 13 +++++++++++-- 7 files changed, 77 insertions(+), 14 deletions(-) diff --git a/examples/Central/LedControl/LedControl.ino b/examples/Central/LedControl/LedControl.ino index 2f64bc28..d0f73383 100644 --- a/examples/Central/LedControl/LedControl.ino +++ b/examples/Central/LedControl/LedControl.ino @@ -6,7 +6,7 @@ it will remotely control the BLE Peripheral's LED, when the button is pressed or released. The circuit: - - STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 You can use it with another board that is compatible with this library and the Peripherals -> LED example. @@ -16,7 +16,16 @@ #include -#if defined(ARDUINO_STEVAL_MKSBOX1V1) +#if defined(ARDUINO_STEVAL_MKBOXPRO) +/* STEVAL-MKBOXPRO */ +SPIClass SpiHCI(PA7, PA6, PA5); +HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000, SPI_MODE3); +#if !defined(FAKE_BLELOCALDEVICE) +BLELocalDevice BLEObj(&HCISpiTransport); +BLELocalDevice& BLE = BLEObj; +#endif +const int buttonPin = PC13; // set buttonPin to digital pin PC13 +#elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000, SPI_MODE1); diff --git a/examples/Central/PeripheralExplorer/PeripheralExplorer.ino b/examples/Central/PeripheralExplorer/PeripheralExplorer.ino index e5461fa5..ea8b3b24 100644 --- a/examples/Central/PeripheralExplorer/PeripheralExplorer.ino +++ b/examples/Central/PeripheralExplorer/PeripheralExplorer.ino @@ -5,7 +5,7 @@ is found. Then connects, and discovers + prints all the peripheral's attributes. The circuit: - - STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 You can use it with another board that is compatible with this library and the Peripherals -> LED example. @@ -15,7 +15,16 @@ #include -#if defined(ARDUINO_STEVAL_MKSBOX1V1) +#if defined(ARDUINO_STEVAL_MKBOXPRO) +/* STEVAL-MKBOXPRO */ +SPIClass SpiHCI(PA7, PA6, PA5); +HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000, SPI_MODE3); +#if !defined(FAKE_BLELOCALDEVICE) +BLELocalDevice BLEObj(&HCISpiTransport); +BLELocalDevice& BLE = BLEObj; +#endif +const int buttonPin = PC13; // set buttonPin to digital pin PC13 +#elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000, SPI_MODE1); diff --git a/examples/Central/Scan/Scan.ino b/examples/Central/Scan/Scan.ino index bf1bef5f..bd22c65e 100644 --- a/examples/Central/Scan/Scan.ino +++ b/examples/Central/Scan/Scan.ino @@ -5,14 +5,23 @@ address, local name, advertised service UUID's. The circuit: - - STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 This example code is in the public domain. */ #include -#if defined(ARDUINO_STEVAL_MKSBOX1V1) +#if defined(ARDUINO_STEVAL_MKBOXPRO) +/* STEVAL-MKBOXPRO */ +SPIClass SpiHCI(PA7, PA6, PA5); +HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000, SPI_MODE3); +#if !defined(FAKE_BLELOCALDEVICE) +BLELocalDevice BLEObj(&HCISpiTransport); +BLELocalDevice& BLE = BLEObj; +#endif +const int buttonPin = PC13; // set buttonPin to digital pin PC13 +#elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000, SPI_MODE1); diff --git a/examples/Central/ScanCallback/ScanCallback.ino b/examples/Central/ScanCallback/ScanCallback.ino index 4d9bbc77..dbc2536e 100644 --- a/examples/Central/ScanCallback/ScanCallback.ino +++ b/examples/Central/ScanCallback/ScanCallback.ino @@ -7,14 +7,23 @@ reported for every single advertisement it makes. The circuit: - - STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 This example code is in the public domain. */ #include -#if defined(ARDUINO_STEVAL_MKSBOX1V1) +#if defined(ARDUINO_STEVAL_MKBOXPRO) +/* STEVAL-MKBOXPRO */ +SPIClass SpiHCI(PA7, PA6, PA5); +HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000, SPI_MODE3); +#if !defined(FAKE_BLELOCALDEVICE) +BLELocalDevice BLEObj(&HCISpiTransport); +BLELocalDevice& BLE = BLEObj; +#endif +const int buttonPin = PC13; // set buttonPin to digital pin PC13 +#elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000, SPI_MODE1); diff --git a/examples/Central/SensorTagButton/SensorTagButton.ino b/examples/Central/SensorTagButton/SensorTagButton.ino index c6377f9f..1831b172 100644 --- a/examples/Central/SensorTagButton/SensorTagButton.ino +++ b/examples/Central/SensorTagButton/SensorTagButton.ino @@ -8,7 +8,7 @@ outputted to the Serial Monitor when one is pressed. The circuit: - - STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 - TI SensorTag This example code is in the public domain. @@ -16,7 +16,16 @@ #include -#if defined(ARDUINO_STEVAL_MKSBOX1V1) +#if defined(ARDUINO_STEVAL_MKBOXPRO) +/* STEVAL-MKBOXPRO */ +SPIClass SpiHCI(PA7, PA6, PA5); +HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000, SPI_MODE3); +#if !defined(FAKE_BLELOCALDEVICE) +BLELocalDevice BLEObj(&HCISpiTransport); +BLELocalDevice& BLE = BLEObj; +#endif +const int buttonPin = PC13; // set buttonPin to digital pin PC13 +#elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000, SPI_MODE1); diff --git a/examples/Peripheral/CallbackLED/CallbackLED.ino b/examples/Peripheral/CallbackLED/CallbackLED.ino index 28bf40a8..363d804b 100644 --- a/examples/Peripheral/CallbackLED/CallbackLED.ino +++ b/examples/Peripheral/CallbackLED/CallbackLED.ino @@ -6,7 +6,7 @@ library are used. The circuit: - - STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 You can use a generic BLE central app, like LightBlue (iOS and Android) or nRF Connect (Android), to interact with the services and characteristics @@ -17,7 +17,16 @@ #include -#if defined(ARDUINO_STEVAL_MKSBOX1V1) +#if defined(ARDUINO_STEVAL_MKBOXPRO) +/* STEVAL-MKBOXPRO */ +SPIClass SpiHCI(PA7, PA6, PA5); +HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000, SPI_MODE3); +#if !defined(FAKE_BLELOCALDEVICE) +BLELocalDevice BLEObj(&HCISpiTransport); +BLELocalDevice& BLE = BLEObj; +#endif +const int buttonPin = PC13; // set buttonPin to digital pin PC13 +#elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000, SPI_MODE1); diff --git a/examples/Peripheral/LED/LED.ino b/examples/Peripheral/LED/LED.ino index 2ea0e5ae..48de79d7 100644 --- a/examples/Peripheral/LED/LED.ino +++ b/examples/Peripheral/LED/LED.ino @@ -5,7 +5,7 @@ characteristic to control an LED. The circuit: - - STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 You can use a generic BLE central app, like LightBlue (iOS and Android) or nRF Connect (Android), to interact with the services and characteristics @@ -15,7 +15,16 @@ */ #include -#if defined(ARDUINO_STEVAL_MKSBOX1V1) +#if defined(ARDUINO_STEVAL_MKBOXPRO) +/* STEVAL-MKBOXPRO */ +SPIClass SpiHCI(PA7, PA6, PA5); +HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000, SPI_MODE3); +#if !defined(FAKE_BLELOCALDEVICE) +BLELocalDevice BLEObj(&HCISpiTransport); +BLELocalDevice& BLE = BLEObj; +#endif +const int buttonPin = PC13; // set buttonPin to digital pin PC13 +#elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000, SPI_MODE1); From 69a6b5fa1f2785d67e52d7e9b03771e215e437b6 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Tue, 30 Aug 2022 13:50:51 +0200 Subject: [PATCH 29/58] fix: Regenrate BLE patches prepare Update STM32Cube_FW Prepare update to version 1.14.0 Signed-off-by: Alexandre Bourdiol --- ...nd-adapt-STM32Cube_FW-sources-for-ST.patch | 208 ++++++++--------- ...imeout-when-waiting-for-the-cmd_resp.patch | 11 +- ...Added-support-for-custom-app_conf.h.patch} | 85 ++++--- .../0004-Stub-OutputDbgTrace-function.patch | 209 ------------------ 4 files changed, 153 insertions(+), 360 deletions(-) rename extras/STM32Cube_FW/{0003-Added-support-for-custom-app_conf.h-35.patch => 0003-Added-support-for-custom-app_conf.h.patch} (61%) delete mode 100644 extras/STM32Cube_FW/0004-Stub-OutputDbgTrace-function.patch diff --git a/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch b/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch index 3ae29806..bbc8ba44 100644 --- a/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch +++ b/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch @@ -1,29 +1,28 @@ -From 6fcfc029ba21a3674456a12032720bff6ecfe27d Mon Sep 17 00:00:00 2001 +From 1c3ca9f22842e3ae283d3e979a5f38a195d8d4ee Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol -Date: Mon, 6 Dec 2021 11:08:32 +0100 -Subject: [PATCH 1/4] chore: clean up and adapt STM32Cube_FW sources for +Date: Tue, 30 Aug 2022 11:28:41 +0200 +Subject: [PATCH 1/3] chore: clean up and adapt STM32Cube_FW sources for STM32duino -Signed-off-by: Frederic Pillon Signed-off-by: Alexandre Bourdiol --- - src/utility/STM32Cube_FW/app_conf_default.h | 422 +------------------ + src/utility/STM32Cube_FW/app_conf_default.h | 428 +------------------ src/utility/STM32Cube_FW/ble_bufsize.h | 13 +- src/utility/STM32Cube_FW/hw.h | 28 +- src/utility/STM32Cube_FW/hw_ipcc.c | 184 +------- src/utility/STM32Cube_FW/mbox_def.h | 34 -- src/utility/STM32Cube_FW/shci.c | 40 +- - src/utility/STM32Cube_FW/shci.h | 47 +-- + src/utility/STM32Cube_FW/shci.h | 47 +- src/utility/STM32Cube_FW/shci_tl.c | 19 +- src/utility/STM32Cube_FW/stm32_wpan_common.h | 39 +- src/utility/STM32Cube_FW/stm_list.c | 11 +- src/utility/STM32Cube_FW/stm_list.h | 4 +- src/utility/STM32Cube_FW/tl.h | 33 -- src/utility/STM32Cube_FW/tl_mbox.c | 144 +------ - 13 files changed, 94 insertions(+), 924 deletions(-) + 13 files changed, 91 insertions(+), 933 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h -index 7ebc65a..4f300e0 100644 +index c63c66e..54f824a 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -1,4 +1,3 @@ @@ -53,21 +52,21 @@ index 7ebc65a..4f300e0 100644 -/** - * Define Secure Connections Support - */ --#define CFG_SECURE_NOT_SUPPORTED (0x00) --#define CFG_SECURE_OPTIONAL (0x01) --#define CFG_SECURE_MANDATORY (0x02) +-#define CFG_SECURE_NOT_SUPPORTED (0x00) +-#define CFG_SECURE_OPTIONAL (0x01) +-#define CFG_SECURE_MANDATORY (0x02) - --#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL +-#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL - -/** - * Define Keypress Notification Support - */ --#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) --#define CFG_KEYPRESS_SUPPORTED (0x01) +-#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) +-#define CFG_KEYPRESS_SUPPORTED (0x01) +/**< generic parameters ******************************************************/ +/* HCI related defines */ --#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED +-#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED +#define ACI_HAL_SET_TX_POWER_LEVEL 0xFC0F +#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C +#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D @@ -141,7 +140,7 @@ index 7ebc65a..4f300e0 100644 * BLE Stack @@ -152,13 +93,15 @@ * Prepare Write List size in terms of number of packet - * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +// #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) @@ -149,7 +148,7 @@ index 7ebc65a..4f300e0 100644 /** * Number of allocated memory blocks - * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter when CFG_BLE_OPTIONS is set to 1 + * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) +// #define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) @@ -157,18 +156,18 @@ index 7ebc65a..4f300e0 100644 /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. -@@ -236,7 +179,7 @@ +@@ -241,7 +184,7 @@ * 0: LE Power Class 2-3 * other bits: reserved (shall be set to 0) */ --#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_NO_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2 | 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_POWER_CLASS_2_3) +#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY) #define CFG_BLE_MAX_COC_INITIATOR_NBR (32) -@@ -256,334 +199,5 @@ +@@ -291,340 +234,5 @@ - #define CFG_BLE_RX_MODEL_CONFIG SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY + #define CFG_BLE_RX_PATH_COMPENS (0) -/****************************************************************************** - * Transport Layer @@ -206,7 +205,7 @@ index 7ebc65a..4f300e0 100644 -/** - * Select UART interfaces - */ --#define CFG_UART_GUI hw_uart1 +-#define CFG_UART_GUI hw_uart1 -#define CFG_DEBUG_TRACE_UART 0 -/****************************************************************************** - * USB interface @@ -276,10 +275,10 @@ index 7ebc65a..4f300e0 100644 - * It divides the RTC CLK by 16 - */ - --#define CFG_RTCCLK_DIV (16) --#define CFG_RTC_WUCKSEL_DIVIDER (0) --#define CFG_RTC_ASYNCH_PRESCALER (0x0F) --#define CFG_RTC_SYNCH_PRESCALER (0x7FFF) +-#define CFG_RTCCLK_DIV (16) +-#define CFG_RTC_WUCKSEL_DIVIDER (0) +-#define CFG_RTC_ASYNCH_PRESCALER (0x0F) +-#define CFG_RTC_SYNCH_PRESCALER (0x7FFF) - -#else - @@ -370,7 +369,7 @@ index 7ebc65a..4f300e0 100644 -#if (CFG_DEBUG_TRACE != 0) -#undef CFG_LPM_SUPPORTED -#undef CFG_DEBUGGER_SUPPORTED --#define CFG_LPM_SUPPORTED 0 +-#define CFG_LPM_SUPPORTED 0 -#define CFG_DEBUGGER_SUPPORTED 1 -#endif - @@ -408,7 +407,7 @@ index 7ebc65a..4f300e0 100644 - * Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined - */ -#define DBG_TRACE_MSG_QUEUE_SIZE 4096 --#define MAX_DBG_TRACE_MSG_SIZE 1024 +-#define MAX_DBG_TRACE_MSG_SIZE 1024 - -/* USER CODE BEGIN Defines */ -#define CFG_LED_SUPPORTED 1 @@ -433,31 +432,31 @@ index 7ebc65a..4f300e0 100644 -/**< Add in that list all tasks that may send a ACI/HCI command */ -typedef enum -{ -- CFG_TASK_BLE_HCI_CMD_ID, -- CFG_TASK_SYS_HCI_CMD_ID, -- CFG_TASK_HCI_ACL_DATA_ID, -- CFG_TASK_SYS_LOCAL_CMD_ID, -- CFG_TASK_TX_TO_HOST_ID, -- /* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */ -- CFG_TASK_SW1_BUTTON_PUSHED_ID, -- CFG_TASK_SW2_BUTTON_PUSHED_ID, -- CFG_TASK_SW3_BUTTON_PUSHED_ID, -- /* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */ -- CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */ +- CFG_TASK_BLE_HCI_CMD_ID, +- CFG_TASK_SYS_HCI_CMD_ID, +- CFG_TASK_HCI_ACL_DATA_ID, +- CFG_TASK_SYS_LOCAL_CMD_ID, +- CFG_TASK_TX_TO_HOST_ID, +- /* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */ +- CFG_TASK_SW1_BUTTON_PUSHED_ID, +- CFG_TASK_SW2_BUTTON_PUSHED_ID, +- CFG_TASK_SW3_BUTTON_PUSHED_ID, +- /* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */ +- CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */ -} CFG_Task_Id_With_HCI_Cmd_t; - -/**< Add in that list all tasks that never send a ACI/HCI command */ -typedef enum -{ -- CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */ -- CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID, -- /* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */ +- CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */ +- CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID, +- /* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */ - -- /* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */ -- CFG_LAST_TASK_ID_WITHO_NO_HCICMD /**< Shall be LAST in the list */ +- /* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */ +- CFG_LAST_TASK_ID_WITH_NO_HCICMD /**< Shall be LAST in the list */ -} CFG_Task_Id_With_NO_HCI_Cmd_t; - --#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITHO_NO_HCICMD +-#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITH_NO_HCICMD - -/** - * This is the list of priority required by the application @@ -465,8 +464,10 @@ index 7ebc65a..4f300e0 100644 - */ -typedef enum -{ -- CFG_SCH_PRIO_0, -- CFG_PRIO_NBR, +- CFG_SCH_PRIO_0, +- /* USER CODE BEGIN CFG_SCH_Prio_Id_t */ +- +- /* USER CODE END CFG_SCH_Prio_Id_t */ -} CFG_SCH_Prio_Id_t; - -/** @@ -474,7 +475,10 @@ index 7ebc65a..4f300e0 100644 - */ -typedef enum -{ -- CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID, +- CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID, +- /* USER CODE BEGIN CFG_IdleEvt_Id_t */ +- +- /* USER CODE END CFG_IdleEvt_Id_t */ -} CFG_IdleEvt_Id_t; - -/****************************************************************************** @@ -486,11 +490,11 @@ index 7ebc65a..4f300e0 100644 - */ -typedef enum -{ -- CFG_LPM_APP, -- CFG_LPM_APP_BLE, -- /* USER CODE BEGIN CFG_LPM_Id_t */ +- CFG_LPM_APP, +- CFG_LPM_APP_BLE, +- /* USER CODE BEGIN CFG_LPM_Id_t */ - -- /* USER CODE END CFG_LPM_Id_t */ +- /* USER CODE END CFG_LPM_Id_t */ -} CFG_LPM_Id_t; - -/****************************************************************************** @@ -499,10 +503,11 @@ index 7ebc65a..4f300e0 100644 -#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE - -#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR - +- #endif /*APP_CONF_H */ + diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h -index ba9c4d3..73b7887 100644 +index 0f0f419..247573b 100644 --- a/src/utility/STM32Cube_FW/ble_bufsize.h +++ b/src/utility/STM32Cube_FW/ble_bufsize.h @@ -75,17 +75,24 @@ @@ -586,7 +591,7 @@ index 503fa2c..fcf0451 100644 } #endif diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c -index c5a941d..2f4f6cc 100644 +index fd620b8..7b9be81 100644 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ b/src/utility/STM32Cube_FW/hw_ipcc.c @@ -18,8 +18,9 @@ @@ -701,7 +706,7 @@ index c5a941d..2f4f6cc 100644 /****************************************************************************** * GENERAL ******************************************************************************/ -@@ -263,8 +222,8 @@ static void HW_IPCC_BLE_AclDataEvtHandler( void ) +@@ -264,8 +223,8 @@ static void HW_IPCC_BLE_AclDataEvtHandler( void ) return; } @@ -712,7 +717,7 @@ index c5a941d..2f4f6cc 100644 /****************************************************************************** * SYSTEM -@@ -302,56 +261,8 @@ static void HW_IPCC_SYS_EvtHandler( void ) +@@ -303,56 +262,8 @@ static void HW_IPCC_SYS_EvtHandler( void ) return; } @@ -771,7 +776,7 @@ index c5a941d..2f4f6cc 100644 /****************************************************************************** * THREAD -@@ -423,9 +334,9 @@ static void HW_IPCC_THREAD_CliNotEvtHandler( void ) +@@ -424,9 +335,9 @@ static void HW_IPCC_THREAD_CliNotEvtHandler( void ) return; } @@ -784,7 +789,7 @@ index c5a941d..2f4f6cc 100644 #endif /* THREAD_WB */ -@@ -547,74 +458,6 @@ void HW_IPCC_LLD_BLE_SendRspAck( void ) +@@ -548,74 +459,6 @@ void HW_IPCC_LLD_BLE_SendRspAck( void ) #endif /* LLD_BLE_WB */ @@ -859,7 +864,7 @@ index c5a941d..2f4f6cc 100644 /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ -@@ -665,4 +508,5 @@ static void HW_IPCC_TRACES_EvtHandler( void ) +@@ -666,4 +509,5 @@ static void HW_IPCC_TRACES_EvtHandler( void ) return; } @@ -867,10 +872,10 @@ index c5a941d..2f4f6cc 100644 +__WEAK void HW_IPCC_TRACES_EvtNot( void ){}; +#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h -index 06536d3..c898e52 100644 +index 68b71f9..0c974f8 100644 --- a/src/utility/STM32Cube_FW/mbox_def.h +++ b/src/utility/STM32Cube_FW/mbox_def.h -@@ -105,12 +105,6 @@ extern "C" { +@@ -106,12 +106,6 @@ extern "C" { uint8_t *m0cmd_buffer; } MB_BleLldTable_t; @@ -883,7 +888,7 @@ index 06536d3..c898e52 100644 /** * msg * [0:7] = cmd/evt -@@ -138,13 +132,6 @@ extern "C" { +@@ -139,13 +133,6 @@ extern "C" { uint8_t *traces_queue; } MB_TracesTable_t; @@ -897,7 +902,7 @@ index 06536d3..c898e52 100644 typedef struct { MB_DeviceInfoTable_t *p_device_info_table; -@@ -153,8 +140,6 @@ extern "C" { +@@ -154,8 +141,6 @@ extern "C" { MB_SysTable_t *p_sys_table; MB_MemManagerTable_t *p_mem_manager_table; MB_TracesTable_t *p_traces_table; @@ -906,7 +911,7 @@ index 06536d3..c898e52 100644 MB_LldTestsTable_t *p_lld_tests_table; MB_BleLldTable_t *p_ble_lld_table; } MB_RefTable_t; -@@ -198,15 +183,6 @@ typedef struct +@@ -199,15 +184,6 @@ typedef struct * | | * |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------| * | | @@ -922,7 +927,7 @@ index 06536d3..c898e52 100644 * | (THREAD) | * |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->| * | | -@@ -230,11 +206,6 @@ typedef struct +@@ -231,11 +207,6 @@ typedef struct * | | * |<---HW_IPCC_BLE_LLD_M0_CMD_CHANNEL---------------| * | | @@ -934,7 +939,7 @@ index 06536d3..c898e52 100644 * | (BUFFER) | * |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>| * | | -@@ -252,8 +223,6 @@ typedef struct +@@ -253,8 +224,6 @@ typedef struct #define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 @@ -943,7 +948,7 @@ index 06536d3..c898e52 100644 #define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4 #define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 -@@ -265,8 +234,6 @@ typedef struct +@@ -266,8 +235,6 @@ typedef struct #define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 @@ -952,7 +957,7 @@ index 06536d3..c898e52 100644 #define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_BLE_LLD_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4 -@@ -274,6 +241,5 @@ typedef struct +@@ -275,6 +242,5 @@ typedef struct #define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_BLE_LLD_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_BLE_LLD_RSP_CHANNEL LL_IPCC_CHANNEL_5 @@ -960,7 +965,7 @@ index 06536d3..c898e52 100644 #endif /*__MBOX_H */ diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c -index 301db76..bd7bb3a 100644 +index 472a108..a847522 100644 --- a/src/utility/STM32Cube_FW/shci.c +++ b/src/utility/STM32Cube_FW/shci.c @@ -16,7 +16,7 @@ @@ -1022,14 +1027,14 @@ index 301db76..bd7bb3a 100644 SHCI_CmdStatus_t SHCI_C2_Reinit( void ) { /** -@@ -739,3 +703,5 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) +@@ -739,4 +703,4 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } +- +#endif /* STM32WBxx */ -+ diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h -index c08f056..9449c22 100644 +index 102089e..6b6ffd1 100644 --- a/src/utility/STM32Cube_FW/shci.h +++ b/src/utility/STM32Cube_FW/shci.h @@ -49,7 +49,6 @@ extern "C" { @@ -1049,7 +1054,7 @@ index c08f056..9449c22 100644 * section could be written in Flash/NVM * StartAddress : Start address of the section that has been modified * Size : Size (in bytes) of the section that has been modified -@@ -214,9 +213,7 @@ extern "C" { +@@ -216,9 +215,7 @@ extern "C" { SHCI_OCF_C2_FLASH_STORE_DATA, SHCI_OCF_C2_FLASH_ERASE_DATA, SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, @@ -1059,7 +1064,7 @@ index c08f056..9449c22 100644 SHCI_OCF_C2_LLD_TESTS_INIT, SHCI_OCF_C2_EXTPA_CONFIG, SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, -@@ -614,8 +611,6 @@ extern "C" { +@@ -648,8 +645,6 @@ extern "C" { { uint8_t thread_config; uint8_t ble_config; @@ -1068,7 +1073,7 @@ index c08f056..9449c22 100644 } SHCI_C2_DEBUG_TracesConfig_t; typedef PACKED_STRUCT -@@ -674,8 +669,6 @@ extern "C" { +@@ -713,8 +708,6 @@ extern "C" { { BLE_ENABLE, THREAD_ENABLE, @@ -1077,7 +1082,7 @@ index c08f056..9449c22 100644 } SHCI_C2_CONCURRENT_Mode_Param_t; /** No response parameters*/ -@@ -698,18 +691,13 @@ extern "C" { +@@ -737,18 +730,13 @@ extern "C" { { BLE_IP, THREAD_IP, @@ -1096,7 +1101,7 @@ index c08f056..9449c22 100644 #define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) #define SHCI_OPCODE_C2_BLE_LLD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_LLD_INIT) -@@ -817,7 +805,7 @@ extern "C" { +@@ -856,7 +844,7 @@ extern "C" { #define FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD (0xA94656B9) /* @@ -1105,8 +1110,8 @@ index c08f056..9449c22 100644 * MB_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) * each of those coded on 32 bits as shown on the table below: * -@@ -870,9 +858,6 @@ extern "C" { - #define INFO_STACK_TYPE_BLE_BEACON 0x04 +@@ -912,9 +900,6 @@ extern "C" { + #define INFO_STACK_TYPE_BLE_HCI_EXT_ADV 0x07 #define INFO_STACK_TYPE_THREAD_FTD 0x10 #define INFO_STACK_TYPE_THREAD_MTD 0x11 -#define INFO_STACK_TYPE_ZIGBEE_FFD 0x30 @@ -1115,7 +1120,7 @@ index c08f056..9449c22 100644 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 #define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 #define INFO_STACK_TYPE_802154_LLD_TESTS 0x60 -@@ -881,12 +866,7 @@ extern "C" { +@@ -923,12 +908,7 @@ extern "C" { #define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 #define INFO_STACK_TYPE_BLE_RLV 0x64 #define INFO_STACK_TYPE_802154_RLV 0x65 @@ -1128,7 +1133,7 @@ index c08f056..9449c22 100644 typedef struct { /** -@@ -1060,7 +1040,7 @@ typedef struct { +@@ -1102,7 +1082,7 @@ typedef struct { * @brief Starts the LLD tests CLI * * @param param_size : Nb of bytes @@ -1137,7 +1142,7 @@ index c08f056..9449c22 100644 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ); -@@ -1070,19 +1050,10 @@ typedef struct { +@@ -1112,19 +1092,10 @@ typedef struct { * @brief Starts the LLD tests BLE * * @param param_size : Nb of bytes @@ -1146,7 +1151,7 @@ index c08f056..9449c22 100644 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ); -- +- - /** - * SHCI_C2_ZIGBEE_Init - * @brief Starts the Zigbee Stack @@ -1155,10 +1160,10 @@ index c08f056..9449c22 100644 - * @retval Status - */ - SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ); - + /** * SHCI_C2_DEBUG_Init -@@ -1158,16 +1129,6 @@ typedef struct { +@@ -1200,16 +1171,6 @@ typedef struct { */ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn); @@ -1176,7 +1181,7 @@ index c08f056..9449c22 100644 * SHCI_GetWirelessFwInfo * @brief This function read back the informations relative to the wireless binary loaded. diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c -index 449b8b1..ef403aa 100644 +index ddb3a02..d1a448d 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -16,12 +16,13 @@ @@ -1215,12 +1220,12 @@ index 449b8b1..ef403aa 100644 /* Private functions ---------------------------------------------------------*/ static void TlInit( TL_CmdPacket_t * p_cmdbuffer ) { -@@ -252,3 +267,5 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) +@@ -252,4 +267,4 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } +- +#endif /* STM32WBxx */ -+ diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h index b47b804..5a2b2a5 100644 --- a/src/utility/STM32Cube_FW/stm32_wpan_common.h @@ -1280,7 +1285,7 @@ index b47b804..5a2b2a5 100644 #ifdef __cplusplus } diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c -index 69c8c06..3dea751 100644 +index 4c92864..77dec64 100644 --- a/src/utility/STM32Cube_FW/stm_list.c +++ b/src/utility/STM32Cube_FW/stm_list.c @@ -16,13 +16,13 @@ @@ -1299,7 +1304,7 @@ index 69c8c06..3dea751 100644 +#include "stm32_wpan_common.h" /****************************************************************************** - * Function Definitions + * Function Definitions @@ -33,10 +33,10 @@ void LST_init_head (tListNode * listHead) listHead->prev = listHead; } @@ -1313,12 +1318,11 @@ index 69c8c06..3dea751 100644 primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ -@@ -205,3 +205,4 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) +@@ -204,3 +204,4 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } - +#endif /* STM32WBxx */ -\ No newline at end of file diff --git a/src/utility/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h index b7c3254..769c211 100644 --- a/src/utility/STM32Cube_FW/stm_list.h @@ -1342,10 +1346,10 @@ index b7c3254..769c211 100644 void LST_insert_head (tListNode * listHead, tListNode * node); diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h -index cb27246..16de7f1 100644 +index 2124d26..678769c 100644 --- a/src/utility/STM32Cube_FW/tl.h +++ b/src/utility/STM32Cube_FW/tl.h -@@ -198,19 +198,6 @@ typedef struct +@@ -199,19 +199,6 @@ typedef struct uint8_t *p_BleLldM0CmdBuffer; } TL_BLE_LLD_Config_t; @@ -1365,7 +1369,7 @@ index cb27246..16de7f1 100644 /** * @brief Contain the BLE HCI Init Configuration * @{ -@@ -304,26 +291,6 @@ void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); +@@ -305,26 +292,6 @@ void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); void TL_TRACES_Init( void ); void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ); @@ -1393,7 +1397,7 @@ index cb27246..16de7f1 100644 } /* extern "C" */ #endif diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c -index 148bcb1..709f5d2 100644 +index 4112429..a9abb18 100644 --- a/src/utility/STM32Cube_FW/tl_mbox.c +++ b/src/utility/STM32Cube_FW/tl_mbox.c @@ -16,6 +16,7 @@ @@ -1431,7 +1435,7 @@ index 148bcb1..709f5d2 100644 HW_IPCC_Init(); return; -@@ -451,139 +448,6 @@ void TL_BLE_LLD_SendRspAck( void ) +@@ -452,139 +449,6 @@ void TL_BLE_LLD_SendRspAck( void ) } #endif /* BLE_LLD_WB */ @@ -1571,12 +1575,12 @@ index 148bcb1..709f5d2 100644 /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ -@@ -845,3 +709,5 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) +@@ -846,4 +710,4 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } -+ +- +#endif /* STM32WBxx */ -- -2.31.1.windows.1 +2.33.0.windows.1 diff --git a/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch b/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch index c4a83d6e..326b767e 100644 --- a/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch +++ b/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch @@ -1,16 +1,15 @@ -From ac18897f0f9b87bb3196efb93ef47ccaaa0eff64 Mon Sep 17 00:00:00 2001 +From 979f153a4e6d5d616ddea616bcd732e32cb1773c Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol -Date: Mon, 6 Dec 2021 11:18:02 +0100 -Subject: [PATCH 2/4] fix: include a timeout when waiting for the cmd_resp +Date: Tue, 30 Aug 2022 13:19:36 +0200 +Subject: [PATCH 2/3] fix: include a timeout when waiting for the cmd_resp -Signed-off-by: Francois Ramu Signed-off-by: Alexandre Bourdiol --- src/utility/STM32Cube_FW/shci_tl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c -index ef403aa..6cccc5d 100644 +index d1a448d..678de84 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -20,6 +20,8 @@ @@ -40,5 +39,5 @@ index ef403aa..6cccc5d 100644 } -- -2.31.1.windows.1 +2.33.0.windows.1 diff --git a/extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h-35.patch b/extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h.patch similarity index 61% rename from extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h-35.patch rename to extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h.patch index 268523d5..33b69e55 100644 --- a/extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h-35.patch +++ b/extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h.patch @@ -1,14 +1,15 @@ -From a771c9e9a12d085fc240a45f68ca5aafb8b42006 Mon Sep 17 00:00:00 2001 +From d3ae98b9073e5f1e48efb32b1ef4d318814228fe Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol -Date: Mon, 6 Dec 2021 18:59:38 +0100 -Subject: [PATCH 3/4] Added support for custom app_conf.h (#35) +Date: Tue, 30 Aug 2022 13:31:31 +0200 +Subject: [PATCH 3/3] Added support for custom app_conf.h +Signed-off-by: Alexandre Bourdiol --- - src/utility/STM32Cube_FW/app_conf_default.h | 75 ++++++++++++++------- - 1 file changed, 49 insertions(+), 26 deletions(-) + src/utility/STM32Cube_FW/app_conf_default.h | 71 ++++++++++++++------- + 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h -index 4f300e0..9f8e085 100644 +index 54f824a..91672ac 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -1,8 +1,8 @@ @@ -47,34 +48,29 @@ index 4f300e0..9f8e085 100644 /****************************************************************************** * BLE Stack -@@ -53,32 +52,41 @@ +@@ -53,13 +52,17 @@ * Maximum number of simultaneous connections that the device will support. * Valid values are from 1 to 8 */ --#define CFG_BLE_NUM_LINK 2 +-#define CFG_BLE_NUM_LINK 8 +#ifndef CFG_BLE_NUM_LINK -+ #define CFG_BLE_NUM_LINK 2 ++ #define CFG_BLE_NUM_LINK 8 +#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 -+ * Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user -+ * services + * 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 - #define CFG_BLE_NUM_GATT_SERVICES 8 ++ #define CFG_BLE_NUM_GATT_SERVICES 8 +#endif /** * Maximum number of Attributes -- * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) -- * that can be stored in the GATT database. -- * 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 -+ * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the -+ * services) that can be stored in the GATT database. 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 +@@ -68,13 +71,17 @@ + * 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 @@ -83,7 +79,7 @@ index 4f300e0..9f8e085 100644 /** * Maximum supported ATT_MTU size - * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#define CFG_BLE_MAX_ATT_MTU (156) +#ifndef CFG_BLE_MAX_ATT_MTU @@ -92,23 +88,18 @@ index 4f300e0..9f8e085 100644 /** * Size of the storage area for Attribute values -- * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: -+ * This value depends on the number of attributes used by application. In particular the sum of the following -+ * quantities (in octets) should be made for each attribute: - * - attribute value length - * - 5, if UUID is 16 bit; 19, if UUID is 128 bit - * - 2, if server configuration descriptor is used -@@ -87,14 +95,18 @@ +@@ -87,14 +94,18 @@ * The total amount of memory needed is the sum of the above quantities for each attribute. - * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ +-#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) +#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE - #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) ++ #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) +#endif /** * Prepare Write List size in terms of number of packet - * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ // #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) @@ -118,7 +109,7 @@ index 4f300e0..9f8e085 100644 /** * Number of allocated memory blocks -@@ -106,12 +118,16 @@ +@@ -106,12 +117,16 @@ /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. */ @@ -137,7 +128,7 @@ index 4f300e0..9f8e085 100644 /** * Sleep clock accuracy in Master mode -@@ -124,24 +140,32 @@ +@@ -124,7 +139,9 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ @@ -147,14 +138,22 @@ index 4f300e0..9f8e085 100644 +#endif /** - * Source for the low speed clock for RF wake-up - * 1 : external high speed crystal HSE/32/32 - * 0 : external low speed crystal ( no calibration ) + * LsSource +@@ -132,21 +149,27 @@ + * - bit 0: 1: Calibration for the RF system wakeup clock source 0: No calibration for the RF system wakeup clock source + * - bit 1: 1: STM32W5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module */ --#define CFG_BLE_LSE_SOURCE 0 +-#if defined(STM32WB5Mxx) +- #define CFG_BLE_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_MOD5MM_DEV) +-#else +- #define CFG_BLE_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_OTHER_DEV) +#ifndef CFG_BLE_LSE_SOURCE -+ #define CFG_BLE_LSE_SOURCE 0 -+#endif ++ #if defined(STM32WB5Mxx) ++ #define CFG_BLE_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_MOD5MM_DEV) ++ #else ++ #define CFG_BLE_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_OTHER_DEV) ++ #endif + #endif /** * Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us) @@ -174,13 +173,13 @@ index 4f300e0..9f8e085 100644 /** * Viterbi Mode -@@ -199,5 +223,4 @@ +@@ -234,5 +257,5 @@ - #define CFG_BLE_RX_MODEL_CONFIG SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY + #define CFG_BLE_RX_PATH_COMPENS (0) -- -#endif /*APP_CONF_H */ +#endif /* APP_CONF_DEFAULT_H */ + -- -2.31.1.windows.1 +2.33.0.windows.1 diff --git a/extras/STM32Cube_FW/0004-Stub-OutputDbgTrace-function.patch b/extras/STM32Cube_FW/0004-Stub-OutputDbgTrace-function.patch deleted file mode 100644 index 6f844f7a..00000000 --- a/extras/STM32Cube_FW/0004-Stub-OutputDbgTrace-function.patch +++ /dev/null @@ -1,209 +0,0 @@ -From a015490bdd861f421addd761ee4164358dc07c19 Mon Sep 17 00:00:00 2001 -From: Alexandre Bourdiol -Date: Tue, 7 Dec 2021 14:27:27 +0100 -Subject: [PATCH 4/4] Stub OutputDbgTrace() function - -Signed-off-by: Alexandre Bourdiol ---- - src/utility/STM32Cube_FW/tl_mbox.c | 178 +---------------------------- - 1 file changed, 3 insertions(+), 175 deletions(-) - -diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c -index 709f5d2..db192c4 100644 ---- a/src/utility/STM32Cube_FW/tl_mbox.c -+++ b/src/utility/STM32Cube_FW/tl_mbox.c -@@ -24,7 +24,6 @@ - #include "stm_list.h" - #include "tl.h" - #include "mbox_def.h" --#include "tl_dbg_conf.h" - - /* Private typedef -----------------------------------------------------------*/ - typedef enum -@@ -532,180 +531,9 @@ __WEAK void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ) - ******************************************************************************/ - static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) - { -- TL_EvtPacket_t *p_evt_packet; -- TL_CmdPacket_t *p_cmd_packet; -- -- switch(packet_type) -- { -- case TL_MB_MM_RELEASE_BUFFER: -- p_evt_packet = (TL_EvtPacket_t*)buffer; -- switch(p_evt_packet->evtserial.evt.evtcode) -- { -- case TL_BLEEVT_CS_OPCODE: -- TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); -- TL_MM_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); -- TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); -- break; -- -- case TL_BLEEVT_CC_OPCODE: -- TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); -- TL_MM_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); -- TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); -- break; -- -- case TL_BLEEVT_VS_OPCODE: -- TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); -- TL_MM_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); -- TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); -- break; -- -- default: -- TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); -- TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); -- break; -- } -- -- TL_MM_DBG_MSG("\r\n"); -- break; -- -- case TL_MB_BLE_CMD: -- p_cmd_packet = (TL_CmdPacket_t*)buffer; -- TL_HCI_CMD_DBG_MSG("ble cmd: 0x%04X", p_cmd_packet->cmdserial.cmd.cmdcode); -- if(p_cmd_packet->cmdserial.cmd.plen != 0) -- { -- TL_HCI_CMD_DBG_MSG(" payload:"); -- TL_HCI_CMD_DBG_BUF(p_cmd_packet->cmdserial.cmd.payload, p_cmd_packet->cmdserial.cmd.plen, ""); -- } -- TL_HCI_CMD_DBG_MSG("\r\n"); -- -- TL_HCI_CMD_DBG_RAW(&p_cmd_packet->cmdserial, p_cmd_packet->cmdserial.cmd.plen+TL_CMD_HDR_SIZE); -- break; -- -- case TL_MB_BLE_CMD_RSP: -- p_evt_packet = (TL_EvtPacket_t*)buffer; -- switch(p_evt_packet->evtserial.evt.evtcode) -- { -- case TL_BLEEVT_CS_OPCODE: -- TL_HCI_CMD_DBG_MSG("ble rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode); -- TL_HCI_CMD_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); -- TL_HCI_CMD_DBG_MSG(" numhci: 0x%02X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->numcmd); -- TL_HCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->status); -- break; -- -- case TL_BLEEVT_CC_OPCODE: -- TL_HCI_CMD_DBG_MSG("ble rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode); -- TL_HCI_CMD_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); -- TL_HCI_CMD_DBG_MSG(" numhci: 0x%02X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->numcmd); -- TL_HCI_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_HCI_CMD_DBG_MSG(" payload:"); -- TL_HCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[1], p_evt_packet->evtserial.evt.plen-4, ""); -- } -- break; -- -- default: -- TL_HCI_CMD_DBG_MSG("unknown ble rsp received: %02X", p_evt_packet->evtserial.evt.evtcode); -- break; -- } -- -- TL_HCI_CMD_DBG_MSG("\r\n"); -- -- TL_HCI_CMD_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); -- break; -- -- case TL_MB_BLE_ASYNCH_EVT: -- p_evt_packet = (TL_EvtPacket_t*)buffer; -- if(p_evt_packet->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) -- { -- TL_HCI_EVT_DBG_MSG("ble evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); -- if((p_evt_packet->evtserial.evt.plen) != 0) -- { -- TL_HCI_EVT_DBG_MSG(" payload:"); -- TL_HCI_EVT_DBG_BUF(p_evt_packet->evtserial.evt.payload, p_evt_packet->evtserial.evt.plen, ""); -- } -- } -- else -- { -- TL_HCI_EVT_DBG_MSG("ble evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); -- TL_HCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); -- if((p_evt_packet->evtserial.evt.plen-2) != 0) -- { -- TL_HCI_EVT_DBG_MSG(" payload:"); -- TL_HCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload, p_evt_packet->evtserial.evt.plen-2, ""); -- } -- } -- -- TL_HCI_EVT_DBG_MSG("\r\n"); -- -- TL_HCI_EVT_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); -- break; -- -- case TL_MB_SYS_CMD: -- p_cmd_packet = (TL_CmdPacket_t*)buffer; -- -- TL_SHCI_CMD_DBG_MSG("sys cmd: 0x%04X", p_cmd_packet->cmdserial.cmd.cmdcode); -- -- if(p_cmd_packet->cmdserial.cmd.plen != 0) -- { -- TL_SHCI_CMD_DBG_MSG(" payload:"); -- TL_SHCI_CMD_DBG_BUF(p_cmd_packet->cmdserial.cmd.payload, p_cmd_packet->cmdserial.cmd.plen, ""); -- } -- TL_SHCI_CMD_DBG_MSG("\r\n"); -- -- TL_SHCI_CMD_DBG_RAW(&p_cmd_packet->cmdserial, p_cmd_packet->cmdserial.cmd.plen+TL_CMD_HDR_SIZE); -- break; -- -- case TL_MB_SYS_CMD_RSP: -- p_evt_packet = (TL_EvtPacket_t*)buffer; -- switch(p_evt_packet->evtserial.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(" payload:"); -- TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[1], p_evt_packet->evtserial.evt.plen-4, ""); -- } -- break; -- -- default: -- TL_SHCI_CMD_DBG_MSG("unknown sys rsp received: %02X", p_evt_packet->evtserial.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); -- break; -- -- case TL_MB_SYS_ASYNCH_EVT: -- p_evt_packet = (TL_EvtPacket_t*)buffer; -- if(p_evt_packet->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) -- { -- TL_SHCI_EVT_DBG_MSG("unknown sys evt received: %02X", p_evt_packet->evtserial.evt.evtcode); -- } -- else -- { -- TL_SHCI_EVT_DBG_MSG("sys evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); -- TL_SHCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); -- if((p_evt_packet->evtserial.evt.plen-2) != 0) -- { -- TL_SHCI_EVT_DBG_MSG(" payload:"); -- TL_SHCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload, p_evt_packet->evtserial.evt.plen-2, ""); -- } -- } -- -- TL_SHCI_EVT_DBG_MSG("\r\n"); -- -- TL_SHCI_EVT_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); -- break; -- -- default: -- break; -- } -+ /* Function stubbed */ -+ UNUSED(packet_type); -+ UNUSED(buffer); - - return; - } --- -2.31.1.windows.1 - From 2cc9f0f8152e49918ef3f352310930c9dfd869da Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Tue, 30 Aug 2022 10:56:46 +0200 Subject: [PATCH 30/58] Update STM32Cube_FW from Cube version 1.14.1 Signed-off-by: Alexandre Bourdiol --- src/utility/STM32Cube_FW/README.md | 4 +- src/utility/STM32Cube_FW/app_conf_default.h | 556 ++++++++++++++++--- src/utility/STM32Cube_FW/ble_bufsize.h | 23 +- src/utility/STM32Cube_FW/hw.h | 28 +- src/utility/STM32Cube_FW/hw_ipcc.c | 195 ++++++- src/utility/STM32Cube_FW/mbox_def.h | 35 ++ src/utility/STM32Cube_FW/shci.c | 39 +- src/utility/STM32Cube_FW/shci.h | 98 +++- src/utility/STM32Cube_FW/shci_tl.c | 29 +- src/utility/STM32Cube_FW/stm32_wpan_common.h | 39 +- src/utility/STM32Cube_FW/stm_list.c | 414 +++++++------- src/utility/STM32Cube_FW/stm_list.h | 4 +- src/utility/STM32Cube_FW/tl.h | 34 ++ src/utility/STM32Cube_FW/tl_mbox.c | 324 ++++++++++- 14 files changed, 1444 insertions(+), 378 deletions(-) diff --git a/src/utility/STM32Cube_FW/README.md b/src/utility/STM32Cube_FW/README.md index dc03bb92..2cd8302a 100644 --- a/src/utility/STM32Cube_FW/README.md +++ b/src/utility/STM32Cube_FW/README.md @@ -1,6 +1,6 @@ ## Source -[STMicroelectronics/STM32CubeWB Release v1.13.3](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.13.3) -- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.13.3/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) +[STMicroelectronics/STM32CubeWB Release 1.14.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/1.14.0) +- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/1.14.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h index 9f8e085d..c63c66e9 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -1,8 +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 * @@ -15,35 +16,94 @@ * ****************************************************************************** */ +/* 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 + +#include "hw.h" +#include "hw_conf.h" +#include "hw_if.h" +#include "ble_bufsize.h" /****************************************************************************** * Application Config ******************************************************************************/ -/**< generic parameters ******************************************************/ -/* HCI related defines */ +/** + * Define Secure Connections Support + */ +#define CFG_SECURE_NOT_SUPPORTED (0x00) +#define CFG_SECURE_OPTIONAL (0x01) +#define CFG_SECURE_MANDATORY (0x02) -#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 +#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL -#ifndef BLE_SHARED_MEM_BYTE_ORDER - #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST -#endif -#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 +/** + * Define Keypress Notification Support + */ +#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) +#define CFG_KEYPRESS_SUPPORTED (0x01) + +#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED /** - * Define Tx Power + * Numeric Comparison Answers */ -#ifndef CFG_TX_POWER - #define CFG_TX_POWER (0x18) /* -0.15dBm */ -#endif +#define YES (0x01) +#define NO (0x00) + +/** + * Device name configuration for Generic Access Service + */ +#define CFG_GAP_DEVICE_NAME "TEMPLATE" +#define CFG_GAP_DEVICE_NAME_LENGTH (8) + +/** +* Identity root key used to derive LTK and CSRK +*/ +#define CFG_BLE_IRK {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0} + +/** +* Encryption root key used to derive LTK and CSRK +*/ +#define CFG_BLE_ERK {0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21, 0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21} + +/** + * SMPS supply + * SMPS not used when Set to 0 + * SMPS used when Set to 1 + */ +#define CFG_USE_SMPS 0 + +/* USER CODE BEGIN Generic_Parameters */ +/* USER CODE END Generic_Parameters */ + +/**< specific parameters */ +/*****************************************************/ + +/* USER CODE BEGIN Specific_Parameters */ +#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler + +/* USER CODE END Specific_Parameters */ + +/****************************************************************************** + * Information Table + * + * Version + * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version + * [4:7] = branch - 0: Mass Market - x: ... + * [8:15] = Subversion + * [16:23] = Version minor + * [24:31] = Version major + * + ******************************************************************************/ +#define CFG_FW_MAJOR_VERSION (0) +#define CFG_FW_MINOR_VERSION (0) +#define CFG_FW_SUBVERSION (1) +#define CFG_FW_BRANCH (0) +#define CFG_FW_BUILD (0) /****************************************************************************** * BLE Stack @@ -52,82 +112,63 @@ * Maximum number of simultaneous connections that the device will support. * Valid values are from 1 to 8 */ -#ifndef CFG_BLE_NUM_LINK - #define CFG_BLE_NUM_LINK 2 -#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 + * 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 #define CFG_BLE_NUM_GATT_SERVICES 8 -#endif /** * Maximum number of Attributes - * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the - * services) that can be stored in the GATT database. 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 + * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) + * that can be stored in the GATT database. + * 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 - #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 -#endif +#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 /** * Maximum supported ATT_MTU size - * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#ifndef CFG_BLE_MAX_ATT_MTU - #define CFG_BLE_MAX_ATT_MTU (156) -#endif +#define CFG_BLE_MAX_ATT_MTU (156) /** * Size of the storage area for Attribute values - * This value depends on the number of attributes used by application. In particular the sum of the following - * quantities (in octets) should be made for each attribute: + * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: * - attribute value length * - 5, if UUID is 16 bit; 19, if UUID is 128 bit * - 2, if server configuration descriptor is used * - 2*DTM_NUM_LINK, if client configuration descriptor is used * - 2, if extended properties is used * The total amount of memory needed is the sum of the above quantities for each attribute. - * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) -#endif /** * Prepare Write List size in terms of number of packet - * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1" + * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -// #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE - #define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) -#endif +#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) /** * Number of allocated memory blocks - * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter when CFG_BLE_OPTIONS is set to 1 + * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -// #define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) -#define CFG_BLE_MBLOCK_COUNT (0x79) +#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) /** * 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 Slave mode (ppm value) */ -#ifndef CFG_BLE_SLAVE_SCA - #define CFG_BLE_SLAVE_SCA 500 -#endif +#define CFG_BLE_SLAVE_SCA 500 /** * Sleep clock accuracy in Master mode @@ -140,32 +181,29 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#ifndef CFG_BLE_MASTER_SCA - #define CFG_BLE_MASTER_SCA 0 -#endif +#define CFG_BLE_MASTER_SCA 0 /** - * Source for the low speed clock for RF wake-up - * 1 : external high speed crystal HSE/32/32 - * 0 : external low speed crystal ( no calibration ) + * LsSource + * Some information for Low speed clock mapped in bits field + * - bit 0: 1: Calibration for the RF system wakeup clock source 0: No calibration for the RF system wakeup clock source + * - bit 1: 1: STM32W5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module */ -#ifndef CFG_BLE_LSE_SOURCE - #define CFG_BLE_LSE_SOURCE 0 +#if defined(STM32WB5Mxx) + #define CFG_BLE_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_MOD5MM_DEV) +#else + #define CFG_BLE_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_OTHER_DEV) #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 Slave 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 @@ -195,21 +233,21 @@ * 0: with service change desc. * (bit 2): 1: device name Read-Only * 0: device name R/W - * (bit 3): 1: extended advertizing supported [NOT SUPPORTED] - * 0: extended advertizing not supported [NOT SUPPORTED] + * (bit 3): 1: extended advertizing supported + * 0: extended advertizing not supported * (bit 4): 1: CS Algo #2 supported * 0: CS Algo #2 not supported * (bit 7): 1: LE Power Class 1 * 0: LE Power Class 2-3 * other bits: reserved (shall be set to 0) */ -#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY) +#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_POWER_CLASS_2_3) #define CFG_BLE_MAX_COC_INITIATOR_NBR (32) -#define CFG_BLE_MIN_TX_POWER (0) +#define CFG_BLE_MIN_TX_POWER (-40) -#define CFG_BLE_MAX_TX_POWER (0) +#define CFG_BLE_MAX_TX_POWER (6) /** * BLE Rx model configuration flags to be configured with: @@ -221,6 +259,372 @@ * other bits: reserved (shall be set to 0) */ -#define CFG_BLE_RX_MODEL_CONFIG SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY +#define CFG_BLE_RX_MODEL_CONFIG (SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY) + +/* Maximum number of advertising sets. + * Range: 1 .. 8 with limitation: + * This parameter is linked to CFG_BLE_MAX_ADV_DATA_LEN such as both compliant with allocated Total memory computed with BLE_EXT_ADV_BUFFER_SIZE based + * on Max Extended advertising configuration supported. + * 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) + + /* Maximum advertising data length (in bytes) + * Range: 31 .. 1650 with limitation: + * This parameter is linked to CFG_BLE_MAX_ADV_SET_NBR such as both compliant with allocated Total memory computed with BLE_EXT_ADV_BUFFER_SIZE based + * on Max Extended advertising configuration supported. + * 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) + + /* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. + * Range: -1280 .. 1280 + */ + +#define CFG_BLE_TX_PATH_COMPENS (0) + + /* RF RX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. + * Range: -1280 .. 1280 + */ + +#define CFG_BLE_RX_PATH_COMPENS (0) + +/****************************************************************************** + * Transport Layer + ******************************************************************************/ +/** + * Queue length of BLE Event + * This parameter defines the number of asynchronous events that can be stored in the HCI layer before + * being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer + * is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large + * enough to store all asynchronous events received in between. + * When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events + * between the HCI command and its event. + * This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small, + * the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting + * for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate + * to the application a HCI command did not receive its command event within 30s (Default HCI Timeout). + */ +#define CFG_TLBLE_EVT_QUEUE_LENGTH 5 +/** + * This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element + * allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager. + * It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will + * never be used) + * It shall be at least 4 to receive the command status event in one frame. + * The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced + * further depending on the application. + */ +#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */ + +#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE ) +/****************************************************************************** + * UART interfaces + ******************************************************************************/ + +/** + * Select UART interfaces + */ +#define CFG_UART_GUI hw_uart1 +#define CFG_DEBUG_TRACE_UART 0 +/****************************************************************************** + * USB interface + ******************************************************************************/ + +/** + * Enable/Disable USB interface + */ +#define CFG_USB_INTERFACE_ENABLE 0 + +/****************************************************************************** + * IPCC interface + ******************************************************************************/ + +/** + * The IPCC is dedicated to the communication between the CPU2 and the CPU1 + * and shall not be modified by the application + * The two following definitions shall not be modified + */ +#define HAL_IPCC_TX_IRQHandler(...) HW_IPCC_Tx_Handler( ) +#define HAL_IPCC_RX_IRQHandler(...) HW_IPCC_Rx_Handler( ) + +/****************************************************************************** + * Low Power + ******************************************************************************/ +/** + * When set to 1, the low power mode is enable + * When set to 0, the device stays in RUN mode + */ +#define CFG_LPM_SUPPORTED 1 + +/****************************************************************************** + * RTC interface + ******************************************************************************/ +#define HAL_RTCEx_WakeUpTimerIRQHandler(...) HW_TS_RTC_Wakeup_Handler( ) + +/****************************************************************************** + * Timer Server + ******************************************************************************/ +/** + * CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer. + * The lower is the value, the better is the power consumption and the accuracy of the timerserver + * The higher is the value, the finest is the granularity + * + * CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to output + * clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding + * the wakeup timer. A lower clock speed would impact the accuracy of the timer server. + * + * CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC. + * When the 1Hz calendar clock is required, it shall be sets according to other settings + * When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE) + * + * CFG_RTCCLK_DIVIDER_CONF: + * Shall be set to either 0,2,4,8,16 + * When set to either 2,4,8,16, the 1Hhz calendar is supported + * When set to 0, the user sets its own configuration + * + * The following settings are computed with LSI as input to the RTC + */ + +#define CFG_RTCCLK_DIVIDER_CONF 0 + +#if (CFG_RTCCLK_DIVIDER_CONF == 0) +/** + * Custom configuration + * It does not support 1Hz calendar + * It divides the RTC CLK by 16 + */ + +#define CFG_RTCCLK_DIV (16) +#define CFG_RTC_WUCKSEL_DIVIDER (0) +#define CFG_RTC_ASYNCH_PRESCALER (0x0F) +#define CFG_RTC_SYNCH_PRESCALER (0x7FFF) + +#else + +#if (CFG_RTCCLK_DIVIDER_CONF == 2) +/** + * It divides the RTC CLK by 2 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (3) +#endif + +#if (CFG_RTCCLK_DIVIDER_CONF == 4) +/** + * It divides the RTC CLK by 4 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (2) +#endif + +#if (CFG_RTCCLK_DIVIDER_CONF == 8) +/** + * It divides the RTC CLK by 8 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (1) +#endif + +#if (CFG_RTCCLK_DIVIDER_CONF == 16) +/** + * It divides the RTC CLK by 16 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (0) +#endif + +#define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF +#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) +#define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 ) + +#endif + +/** tick timer values */ +#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE ) +#define CFG_TS_TICK_VAL_PS DIVR( ((uint64_t)CFG_RTCCLK_DIV * 1e12), (uint64_t)LSE_VALUE ) + +typedef enum +{ + CFG_TIM_PROC_ID_ISR, + /* USER CODE BEGIN CFG_TimProcID_t */ + + /* USER CODE END CFG_TimProcID_t */ +} CFG_TimProcID_t; + +/****************************************************************************** + * Debug + ******************************************************************************/ +/** + * When set, this resets some hw resources to set the device in the same state than the power up + * The FW resets only register that may prevent the FW to run properly + * + * This shall be set to 0 in a final product + * + */ +#define CFG_HW_RESET_BY_FW 1 + +/** + * keep debugger enabled while in any low power mode when set to 1 + * should be set to 0 in production + */ +#define CFG_DEBUGGER_SUPPORTED 0 + +/** + * When set to 1, the traces are enabled in the BLE services + */ +#define CFG_DEBUG_BLE_TRACE 0 + +/** + * Enable or Disable traces in application + */ +#define CFG_DEBUG_APP_TRACE 0 + +#if (CFG_DEBUG_APP_TRACE != 0) +#define APP_DBG_MSG PRINT_MESG_DBG +#else +#define APP_DBG_MSG PRINT_NO_MESG +#endif + +#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) ) +#define CFG_DEBUG_TRACE 1 +#endif + +#if (CFG_DEBUG_TRACE != 0) +#undef CFG_LPM_SUPPORTED +#undef CFG_DEBUGGER_SUPPORTED +#define CFG_LPM_SUPPORTED 0 +#define CFG_DEBUGGER_SUPPORTED 1 +#endif + +/** + * When CFG_DEBUG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number + * When CFG_DEBUG_TRACE_LIGHT is set to 1, only the debug message is output + * + * When both are set to 0, no trace are output + * When both are set to 1, CFG_DEBUG_TRACE_FULL is selected + */ +#define CFG_DEBUG_TRACE_LIGHT 0 +#define CFG_DEBUG_TRACE_FULL 0 + +#if (( CFG_DEBUG_TRACE != 0 ) && ( CFG_DEBUG_TRACE_LIGHT == 0 ) && (CFG_DEBUG_TRACE_FULL == 0)) +#undef CFG_DEBUG_TRACE_FULL +#undef CFG_DEBUG_TRACE_LIGHT +#define CFG_DEBUG_TRACE_FULL 0 +#define CFG_DEBUG_TRACE_LIGHT 1 +#endif + +#if ( CFG_DEBUG_TRACE == 0 ) +#undef CFG_DEBUG_TRACE_FULL +#undef CFG_DEBUG_TRACE_LIGHT +#define CFG_DEBUG_TRACE_FULL 0 +#define CFG_DEBUG_TRACE_LIGHT 0 +#endif + +/** + * When not set, the traces is looping on sending the trace over UART + */ +#define DBG_TRACE_USE_CIRCULAR_QUEUE 1 + +/** + * max buffer Size to queue data traces and max data trace allowed. + * Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined + */ +#define DBG_TRACE_MSG_QUEUE_SIZE 4096 +#define MAX_DBG_TRACE_MSG_SIZE 1024 + +/* USER CODE BEGIN Defines */ +#define CFG_LED_SUPPORTED 1 +#define CFG_BUTTON_SUPPORTED 1 + +#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler +#define PUSH_BUTTON_SW2_EXTI_IRQHandler EXTI0_IRQHandler +#define PUSH_BUTTON_SW3_EXTI_IRQHandler EXTI1_IRQHandler +/* USER CODE END Defines */ + +/****************************************************************************** + * Scheduler + ******************************************************************************/ + +/** + * These are the lists of task id registered to the scheduler + * Each task id shall be in the range [0:31] + * This mechanism allows to implement a generic code in the API TL_BLE_HCI_StatusNot() to comply with + * the requirement that a HCI/ACI command shall never be sent if there is already one pending + */ + +/**< Add in that list all tasks that may send a ACI/HCI command */ +typedef enum +{ + CFG_TASK_BLE_HCI_CMD_ID, + CFG_TASK_SYS_HCI_CMD_ID, + CFG_TASK_HCI_ACL_DATA_ID, + CFG_TASK_SYS_LOCAL_CMD_ID, + CFG_TASK_TX_TO_HOST_ID, + /* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */ + CFG_TASK_SW1_BUTTON_PUSHED_ID, + CFG_TASK_SW2_BUTTON_PUSHED_ID, + CFG_TASK_SW3_BUTTON_PUSHED_ID, + /* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */ + CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */ +} CFG_Task_Id_With_HCI_Cmd_t; + +/**< Add in that list all tasks that never send a ACI/HCI command */ +typedef enum +{ + CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */ + CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID, + /* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */ + + /* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */ + CFG_LAST_TASK_ID_WITH_NO_HCICMD /**< Shall be LAST in the list */ +} CFG_Task_Id_With_NO_HCI_Cmd_t; + +#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITH_NO_HCICMD + +/** + * This is the list of priority required by the application + * Each Id shall be in the range 0..31 + */ +typedef enum +{ + CFG_SCH_PRIO_0, + /* USER CODE BEGIN CFG_SCH_Prio_Id_t */ + + /* USER CODE END CFG_SCH_Prio_Id_t */ +} CFG_SCH_Prio_Id_t; + +/** + * This is a bit mapping over 32bits listing all events id supported in the application + */ +typedef enum +{ + CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID, + /* USER CODE BEGIN CFG_IdleEvt_Id_t */ + + /* USER CODE END CFG_IdleEvt_Id_t */ +} CFG_IdleEvt_Id_t; + +/****************************************************************************** + * LOW POWER + ******************************************************************************/ +/** + * Supported requester to the MCU Low Power Manager - can be increased up to 32 + * It list a bit mapping of all user of the Low Power Manager + */ +typedef enum +{ + CFG_LPM_APP, + CFG_LPM_APP_BLE, + /* USER CODE BEGIN CFG_LPM_Id_t */ + + /* USER CODE END CFG_LPM_Id_t */ +} CFG_LPM_Id_t; + +/****************************************************************************** + * OTP manager + ******************************************************************************/ +#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE + +#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR + +#endif /*APP_CONF_H */ -#endif /* APP_CONF_DEFAULT_H */ diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h index 12b5fdb9..0f0f4192 100644 --- a/src/utility/STM32Cube_FW/ble_bufsize.h +++ b/src/utility/STM32Cube_FW/ble_bufsize.h @@ -75,37 +75,32 @@ ((pw) + MAX(BLE_MEM_BLOCK_X_MTU(mtu, n_link), \ BLE_MBLOCKS_SECURE_CONNECTIONS)) -/* - * BLE_DEFAULT_MBLOCKS_COUNT: default memory blocks count - */ -#define BLE_DEFAULT_MBLOCKS_COUNT(n_link) \ - BLE_MBLOCKS_CALC(BLE_DEFAULT_PREP_WRITE_LIST_SIZE, \ - BLE_DEFAULT_MAX_ATT_MTU, n_link) - /* * BLE_FIXED_BUFFER_SIZE_BYTES: - * A part of the RAM, is dynamically allocated by initializing all the pointers + * A part of the RAM, is dinamically allocated by initilizing all the pointers * defined in a global context variable "mem_alloc_ctx_p". * This initialization is made in the Dynamic_allocator functions, which - * assign a portion of RAM given by the external application to the above + * assing a portion of RAM given by the external application to the above * mentioned "global pointers". * * The size of this Dynamic RAM is made of 2 main components: * - a part that is parameters-dependent (num of links, GATT buffers, ...), - * and which value is defined by the following macro; + * and which value is explicited by the following macro; * - a part, that may be considered "fixed", i.e. independent from the above * mentioned parameters. */ #if (BEACON_ONLY != 0) #define BLE_FIXED_BUFFER_SIZE_BYTES 4076 /* Beacon only */ +#elif (LL_ONLY_BASIC != 0) +#define BLE_FIXED_BUFFER_SIZE_BYTES 5692 /* LL only Basic*/ #elif (LL_ONLY != 0) -#define BLE_FIXED_BUFFER_SIZE_BYTES 5936 /* LL only */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 5940 /* LL only Full */ #elif (SLAVE_ONLY != 0) #define BLE_FIXED_BUFFER_SIZE_BYTES 6204 /* Peripheral only */ #elif (BASIC_FEATURES != 0) #define BLE_FIXED_BUFFER_SIZE_BYTES 6532 /* Basic Features */ #else -#define BLE_FIXED_BUFFER_SIZE_BYTES 7052 /* Full stack */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 7056 /* Full stack */ #endif /* @@ -113,8 +108,10 @@ */ #if (BEACON_ONLY != 0) #define BLE_PER_LINK_SIZE_BYTES 128 /* Beacon only */ +#elif (LL_ONLY_BASIC != 0) +#define BLE_PER_LINK_SIZE_BYTES 260 /* LL only Basic */ #elif (LL_ONLY != 0) -#define BLE_PER_LINK_SIZE_BYTES 260 /* LL only */ +#define BLE_PER_LINK_SIZE_BYTES 260 /* LL only Full */ #elif (SLAVE_ONLY != 0) #define BLE_PER_LINK_SIZE_BYTES 392 /* Peripheral only */ #elif (BASIC_FEATURES != 0) diff --git a/src/utility/STM32Cube_FW/hw.h b/src/utility/STM32Cube_FW/hw.h index fcf04517..503fa2ca 100644 --- a/src/utility/STM32Cube_FW/hw.h +++ b/src/utility/STM32Cube_FW/hw.h @@ -26,21 +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 ); + void HW_IPCC_Rx_Handler( void ); + void HW_IPCC_Tx_Handler( void ); void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); @@ -87,6 +80,23 @@ extern "C" { void HW_IPCC_TRACES_Init( void ); void HW_IPCC_TRACES_EvtNot( void ); + void HW_IPCC_MAC_802_15_4_Init( void ); + void HW_IPCC_MAC_802_15_4_SendCmd( void ); + void HW_IPCC_MAC_802_15_4_SendAck( void ); + void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ); + void HW_IPCC_MAC_802_15_4_EvtNot( void ); + + void HW_IPCC_ZIGBEE_Init( void ); + + void HW_IPCC_ZIGBEE_SendM4RequestToM0(void); /* M4 Request to M0 */ + void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void); /* Request ACK from M0 */ + + void HW_IPCC_ZIGBEE_RecvM0NotifyToM4(void); /* M0 Notify to M4 */ + void HW_IPCC_ZIGBEE_SendM4AckToM0Notify(void); /* Notify ACK from M4 */ + void HW_IPCC_ZIGBEE_RecvM0RequestToM4(void); /* M0 Request to M4 */ + void HW_IPCC_ZIGBEE_SendM4AckToM0Request(void); /* Request ACK from M4 */ + + #ifdef __cplusplus } #endif diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c index 2f4f6cc2..fd620b85 100644 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ b/src/utility/STM32Cube_FW/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 ---------------------------------------------------------*/ @@ -57,17 +56,34 @@ static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ); static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void ); #endif +#ifdef MAC_802_15_4_WB +static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ); +static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ); +#endif + +#ifdef ZIGBEE_WB +static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ); +static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ); +static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ); +#endif + /* Public function definition -----------------------------------------------*/ /****************************************************************************** * INTERRUPT HANDLER ******************************************************************************/ -void IPCC_C1_RX_IRQHandler(void) +void HW_IPCC_Rx_Handler( void ) { if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL )) { HW_IPCC_SYS_EvtHandler(); } +#ifdef MAC_802_15_4_WB + else if (HW_IPCC_RX_PENDING( HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL )) + { + HW_IPCC_MAC_802_15_4_NotEvtHandler(); + } +#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL )) { @@ -98,6 +114,16 @@ void IPCC_C1_RX_IRQHandler(void) HW_IPCC_LLD_BLE_ReceiveM0CmdHandler(); } #endif /* LLD_TESTS_WB */ +#ifdef ZIGBEE_WB + else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL )) + { + HW_IPCC_ZIGBEE_StackNotifEvtHandler(); + } + else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL )) + { + HW_IPCC_ZIGBEE_StackM0RequestHandler(); + } +#endif /* ZIGBEE_WB */ else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL )) { HW_IPCC_BLE_EvtHandler(); @@ -106,14 +132,22 @@ void IPCC_C1_RX_IRQHandler(void) { HW_IPCC_TRACES_EvtHandler(); } + + return; } -void IPCC_C1_TX_IRQHandler(void) +void HW_IPCC_Tx_Handler( void ) { if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) { HW_IPCC_SYS_CmdEvtHandler(); } +#ifdef MAC_802_15_4_WB + else if (HW_IPCC_TX_PENDING( HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL )) + { + HW_IPCC_MAC_802_15_4_CmdEvtHandler(); + } +#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) { @@ -123,6 +157,12 @@ void IPCC_C1_TX_IRQHandler(void) #ifdef LLD_TESTS_WB // No TX handler for LLD tests #endif /* LLD_TESTS_WB */ +#ifdef ZIGBEE_WB + if (HW_IPCC_TX_PENDING( HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL )) + { + HW_IPCC_ZIGBEE_CmdEvtHandler(); + } +#endif /* ZIGBEE_WB */ else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL )) { HW_IPCC_MM_FreeBufHandler(); @@ -131,8 +171,9 @@ void IPCC_C1_TX_IRQHandler(void) { HW_IPCC_BLE_AclDataEvtHandler(); } -} + return; +} /****************************************************************************** * GENERAL ******************************************************************************/ @@ -140,15 +181,16 @@ void HW_IPCC_Enable( void ) { /** * Such as IPCC IP available to the CPU2, it is required to keep the IPCC clock running - when FUS is running on CPU2 and CPU1 enters deep sleep mode + * when FUS is running on CPU2 and CPU1 enters deep sleep mode */ LL_C2_AHB3_GRP1_EnableClock(LL_C2_AHB3_GRP1_PERIPH_IPCC); - /** - * When the device is out of standby, it is required to use the EXTI mechanism to wakeup CPU2 - */ - LL_C2_EXTI_EnableEvent_32_63( LL_EXTI_LINE_41 ); + /** + * When the device is out of standby, it is required to use the EXTI mechanism to wakeup CPU2 + */ LL_EXTI_EnableRisingTrig_32_63( LL_EXTI_LINE_41 ); + /* It is required to have at least a system clock cycle before a SEV after LL_EXTI_EnableRisingTrig_32_63() */ + LL_C2_EXTI_EnableEvent_32_63( LL_EXTI_LINE_41 ); /** * In case the SBSFU is implemented, it may have already set the C2BOOT bit to startup the CPU2. @@ -222,8 +264,8 @@ static void HW_IPCC_BLE_AclDataEvtHandler( void ) return; } -__WEAK void HW_IPCC_BLE_AclDataAckNot( void ){}; -__WEAK void HW_IPCC_BLE_RxEvtNot( void ){}; +__weak void HW_IPCC_BLE_AclDataAckNot( void ){}; +__weak void HW_IPCC_BLE_RxEvtNot( void ){}; /****************************************************************************** * SYSTEM @@ -261,8 +303,56 @@ static void HW_IPCC_SYS_EvtHandler( void ) return; } -__WEAK void HW_IPCC_SYS_CmdEvtNot( void ){}; -__WEAK void HW_IPCC_SYS_EvtNot( void ){}; +__weak void HW_IPCC_SYS_CmdEvtNot( void ){}; +__weak void HW_IPCC_SYS_EvtNot( void ){}; + +/****************************************************************************** + * MAC 802.15.4 + ******************************************************************************/ +#ifdef MAC_802_15_4_WB +void HW_IPCC_MAC_802_15_4_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + + return; +} + +void HW_IPCC_MAC_802_15_4_SendCmd( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + + return; +} + +void HW_IPCC_MAC_802_15_4_SendAck( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + + return; +} + +static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ) +{ + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + + HW_IPCC_MAC_802_15_4_CmdEvtNot(); + + return; +} + +static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + + HW_IPCC_MAC_802_15_4_EvtNot(); + + return; +} +__weak void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ){}; +__weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){}; +#endif /****************************************************************************** * THREAD @@ -334,9 +424,9 @@ static void HW_IPCC_THREAD_CliNotEvtHandler( void ) return; } -__WEAK void HW_IPCC_OT_CmdEvtNot( void ){}; -__WEAK void HW_IPCC_CLI_CmdEvtNot( void ){}; -__WEAK void HW_IPCC_THREAD_EvtNot( void ){}; +__weak void HW_IPCC_OT_CmdEvtNot( void ){}; +__weak void HW_IPCC_CLI_CmdEvtNot( void ){}; +__weak void HW_IPCC_THREAD_EvtNot( void ){}; #endif /* THREAD_WB */ @@ -458,6 +548,74 @@ void HW_IPCC_LLD_BLE_SendRspAck( void ) #endif /* LLD_BLE_WB */ +/****************************************************************************** + * ZIGBEE + ******************************************************************************/ +#ifdef ZIGBEE_WB +void HW_IPCC_ZIGBEE_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + + return; +} + +void HW_IPCC_ZIGBEE_SendM4RequestToM0( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + + return; +} + +void HW_IPCC_ZIGBEE_SendM4AckToM0Notify( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + + return; +} + +static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ) +{ + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + + HW_IPCC_ZIGBEE_RecvAppliAckFromM0(); + + return; +} + +static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + + HW_IPCC_ZIGBEE_RecvM0NotifyToM4(); + + return; +} + +static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + + HW_IPCC_ZIGBEE_RecvM0RequestToM4(); + + return; +} + +void HW_IPCC_ZIGBEE_SendM4AckToM0Request( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + + return; +} + +__weak void HW_IPCC_ZIGBEE_RecvAppliAckFromM0( void ){}; +__weak void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ){}; +__weak void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ){}; +#endif /* ZIGBEE_WB */ + /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -508,5 +666,4 @@ static void HW_IPCC_TRACES_EvtHandler( void ) return; } -__WEAK void HW_IPCC_TRACES_EvtNot( void ){}; -#endif /* STM32WBxx */ +__weak void HW_IPCC_TRACES_EvtNot( void ){}; diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h index c898e52a..68b71f9c 100644 --- a/src/utility/STM32Cube_FW/mbox_def.h +++ b/src/utility/STM32Cube_FW/mbox_def.h @@ -91,6 +91,7 @@ extern "C" { uint8_t *notack_buffer; uint8_t *clicmdrsp_buffer; uint8_t *otcmdrsp_buffer; + uint8_t *clinot_buffer; } MB_ThreadTable_t; typedef struct @@ -105,6 +106,12 @@ extern "C" { uint8_t *m0cmd_buffer; } MB_BleLldTable_t; + typedef struct + { + uint8_t *notifM0toM4_buffer; + uint8_t *appliCmdM4toM0_buffer; + uint8_t *requestM0toM4_buffer; + } MB_ZigbeeTable_t; /** * msg * [0:7] = cmd/evt @@ -132,6 +139,13 @@ extern "C" { uint8_t *traces_queue; } MB_TracesTable_t; + typedef struct + { + uint8_t *p_cmdrsp_buffer; + uint8_t *p_notack_buffer; + uint8_t *evt_queue; + } MB_Mac_802_15_4_t; + typedef struct { MB_DeviceInfoTable_t *p_device_info_table; @@ -140,6 +154,8 @@ extern "C" { MB_SysTable_t *p_sys_table; MB_MemManagerTable_t *p_mem_manager_table; MB_TracesTable_t *p_traces_table; + MB_Mac_802_15_4_t *p_mac_802_15_4_table; + MB_ZigbeeTable_t *p_zigbee_table; MB_LldTestsTable_t *p_lld_tests_table; MB_BleLldTable_t *p_ble_lld_table; } MB_RefTable_t; @@ -183,6 +199,15 @@ typedef struct * | | * |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------| * | | + * | (ZIGBEE) | + * |----HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL------------>| + * | | + * |----HW_IPCC_ZIGBEE_CMD_CLI_CHANNEL-------------->| + * | | + * |<---HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL-------| + * | | + * |<---HW_IPCC_ZIGBEE_CLI_NOTIF_ACK_CHANNEL---------| + * | | * | (THREAD) | * |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->| * | | @@ -206,6 +231,11 @@ typedef struct * | | * |<---HW_IPCC_BLE_LLD_M0_CMD_CHANNEL---------------| * | | + * | (MAC) | + * |----HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL-------->| + * | | + * |<---HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL| + * | | * | (BUFFER) | * |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>| * | | @@ -223,6 +253,8 @@ typedef struct #define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4 #define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 @@ -234,6 +266,8 @@ typedef struct #define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_BLE_LLD_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4 @@ -241,5 +275,6 @@ typedef struct #define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_BLE_LLD_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_BLE_LLD_RSP_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL LL_IPCC_CHANNEL_5 #endif /*__MBOX_H */ diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c index bd7bb3a1..472a108e 100644 --- a/src/utility/STM32Cube_FW/shci.c +++ b/src/utility/STM32Cube_FW/shci.c @@ -16,7 +16,7 @@ ****************************************************************************** */ -#if defined(STM32WBxx) + /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -352,6 +352,24 @@ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ) return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } +SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_ZIGBEE_INIT, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ) { /** @@ -509,6 +527,24 @@ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t Fla return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } +SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_MAC_802_15_4_INIT, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + SHCI_CmdStatus_t SHCI_C2_Reinit( void ) { /** @@ -703,5 +739,4 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h index d965ec84..102089e2 100644 --- a/src/utility/STM32Cube_FW/shci.h +++ b/src/utility/STM32Cube_FW/shci.h @@ -49,6 +49,7 @@ extern "C" { ERR_BLE_INIT = 0, /* This event is currently not reported by the CPU2 */ ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the CPU1 to control the Thread stack is unknown */ + ERR_ZIGBEE_UNKNOWN_CMD = 200, /* The command send by the CPU1 to control the Zigbee stack is unknown */ } SCHI_SystemErrCode_t; #define SHCI_EVTCODE ( 0xFF ) @@ -101,7 +102,7 @@ extern "C" { /** * SHCI_SUB_EVT_THREAD_NVM_RAM_UPDATE - * This notifies the CPU1 which part of the 'OT NVM RAM' has been updated so that only the modified + * This notifies the CPU1 which part of the OT NVM RAM has been updated so that only the modified * section could be written in Flash/NVM * StartAddress : Start address of the section that has been modified * Size : Size (in bytes) of the section that has been modified @@ -162,9 +163,11 @@ extern "C" { { SHCI_Success = 0x00, SHCI_UNKNOWN_CMD = 0x01, + SHCI_MEMORY_CAPACITY_EXCEEDED_ERR_CODE= 0x07, SHCI_ERR_UNSUPPORTED_FEATURE = 0x11, SHCI_ERR_INVALID_HCI_CMD_PARAMS = 0x12, - SHCI_ERR_INVALID_PARAMS = 0x42, + SHCI_ERR_INVALID_PARAMS = 0x42, /* only used for release < v1.13.0 */ + SHCI_ERR_INVALID_PARAMS_V2 = 0x92, /* available for release >= v1.13.0 */ SHCI_FUS_CMD_NOT_SUPPORTED = 0xFF, } SHCI_CmdStatus_t; @@ -213,7 +216,9 @@ extern "C" { SHCI_OCF_C2_FLASH_STORE_DATA, SHCI_OCF_C2_FLASH_ERASE_DATA, SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, + SHCI_OCF_C2_MAC_802_15_4_INIT, SHCI_OCF_C2_REINIT, + SHCI_OCF_C2_ZIGBEE_INIT, SHCI_OCF_C2_LLD_TESTS_INIT, SHCI_OCF_C2_EXTPA_CONFIG, SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, @@ -487,10 +492,9 @@ extern "C" { /** * LsSource - * Source for the 32 kHz slow speed clock. - * - External crystal LSE: 0 - No calibration - * - Others:1 - As the accuracy of this oscillator can vary depending upon external conditions (temperature), - * it is calibrated every second to ensure correct behavior of timing sensitive BLE operations + * Some information for Low speed clock mapped in bits field + * - bit 0: 1: Calibration for the RF system wakeup clock source 0: No calibration for the RF system wakeup clock source + * - bit 1: 1: STM32W5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module */ uint8_t LsSource; @@ -564,6 +568,32 @@ extern "C" { */ uint8_t rx_model_config; + /* Maximum number of advertising sets. + * Range: 1 .. 8 with limitation: + * This parameter is linked to max_adv_data_len such as both compliant with allocated Total memory computed with BLE_EXT_ADV_BUFFER_SIZE based + * on Max Extended advertising configuration supported. + * This parameter is considered by the CPU2 when Options has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set + */ + uint8_t max_adv_set_nbr; + + /* Maximum advertising data length (in bytes) + * Range: 31 .. 1650 with limitation: + * This parameter is linked to max_adv_set_nbr such as both compliant with allocated Total memory computed with BLE_EXT_ADV_BUFFER_SIZE based + * on Max Extended advertising configuration supported. + * This parameter is considered by the CPU2 when Options has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set + */ + uint16_t max_adv_data_len; + + /* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. + * Range: -1280 .. 1280 + */ + int16_t tx_path_compens; + + /* RF RX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. + * Range: -1280 .. 1280 + */ + int16_t rx_path_compens; + } SHCI_C2_Ble_Init_Cmd_Param_t; typedef PACKED_STRUCT{ @@ -600,6 +630,13 @@ extern "C" { #define SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY (0<<0) #define SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_BLOCKER (1<<0) + /** + * LsSource information + */ +#define SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB (0<<0) +#define SHCI_C2_BLE_INIT_CFG_BLE_LSE_CALIB (1<<0) +#define SHCI_C2_BLE_INIT_CFG_BLE_LSE_OTHER_DEV (0<<1) +#define SHCI_C2_BLE_INIT_CFG_BLE_LSE_MOD5MM_DEV (1<<1) #define SHCI_OPCODE_C2_THREAD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_THREAD_INIT) /** No command parameters */ @@ -611,6 +648,8 @@ extern "C" { { uint8_t thread_config; uint8_t ble_config; + uint8_t mac_802_15_4_config; + uint8_t zigbee_config; } SHCI_C2_DEBUG_TracesConfig_t; typedef PACKED_STRUCT @@ -624,6 +663,11 @@ extern "C" { */ uint8_t sys_dbg_cfg1; uint8_t reserved[2]; + uint16_t STBY_DebugGpioaPinList; + uint16_t STBY_DebugGpiobPinList; + uint16_t STBY_DebugGpiocPinList; + uint16_t STBY_DtbGpioaPinList; + uint16_t STBY_DtbGpiobPinList; } SHCI_C2_DEBUG_GeneralConfig_t; typedef PACKED_STRUCT{ @@ -669,6 +713,8 @@ extern "C" { { BLE_ENABLE, THREAD_ENABLE, + ZIGBEE_ENABLE, + MAC_ENABLE, } SHCI_C2_CONCURRENT_Mode_Param_t; /** No response parameters*/ @@ -691,13 +737,18 @@ extern "C" { { BLE_IP, THREAD_IP, + ZIGBEE_IP, } SHCI_C2_FLASH_Ip_t; /** No response parameters*/ #define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) +#define SHCI_OPCODE_C2_MAC_802_15_4_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_MAC_802_15_4_INIT) + #define SHCI_OPCODE_C2_REINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_REINIT) +#define SHCI_OPCODE_C2_ZIGBEE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_ZIGBEE_INIT) + #define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) #define SHCI_OPCODE_C2_BLE_LLD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_LLD_INIT) @@ -805,7 +856,7 @@ extern "C" { #define FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD (0xA94656B9) /* - * At startup, the information relative to the wireless binary are stored in RAM through a structure defined by + * At startup, the informations relative to the wireless binary are stored in RAM trough a structure defined by * MB_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) * each of those coded on 32 bits as shown on the table below: * @@ -861,6 +912,9 @@ extern "C" { #define INFO_STACK_TYPE_BLE_HCI_EXT_ADV 0x07 #define INFO_STACK_TYPE_THREAD_FTD 0x10 #define INFO_STACK_TYPE_THREAD_MTD 0x11 +#define INFO_STACK_TYPE_ZIGBEE_FFD 0x30 +#define INFO_STACK_TYPE_ZIGBEE_RFD 0x31 +#define INFO_STACK_TYPE_MAC 0x40 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 #define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 #define INFO_STACK_TYPE_802154_LLD_TESTS 0x60 @@ -869,7 +923,12 @@ extern "C" { #define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 #define INFO_STACK_TYPE_BLE_RLV 0x64 #define INFO_STACK_TYPE_802154_RLV 0x65 +#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_STATIC 0x70 +#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_STATIC 0x71 +#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_DYNAMIC 0x78 +#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_DYNAMIC 0x79 #define INFO_STACK_TYPE_RLV 0x80 +#define INFO_STACK_TYPE_BLE_MAC_STATIC 0x90 typedef struct { /** @@ -1043,7 +1102,7 @@ typedef struct { * @brief Starts the LLD tests CLI * * @param param_size : Nb of bytes - * @param p_param : pointer with data to give from M4 to M0 + * @param p_param : pointeur with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ); @@ -1053,11 +1112,20 @@ typedef struct { * @brief Starts the LLD tests BLE * * @param param_size : Nb of bytes - * @param p_param : pointer with data to give from M4 to M0 + * @param p_param : pointeur with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ); + /** + * SHCI_C2_ZIGBEE_Init + * @brief Starts the Zigbee Stack + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ); + /** * SHCI_C2_DEBUG_Init * @brief Starts the Traces @@ -1132,6 +1200,16 @@ typedef struct { */ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn); + + /** + * SHCI_C2_MAC_802_15_4_Init + * @brief Starts the MAC 802.15.4 on M0 + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ); + /** * SHCI_GetWirelessFwInfo * @brief This function read back the informations relative to the wireless binary loaded. @@ -1219,7 +1297,7 @@ typedef struct { * When set to 0, data are kept in internal SRAM on CPU2 * Otherwise, data are copied in the cache pointed by ThreadNvmRamAddress * The size of the buffer shall be THREAD_NVM_SRAM_SIZE (number of 32bits) - * The buffer shall be allocated in SRAM2 + * The buffer shall be allocated in SRAM1 * * Please check macro definition to be used for this function * They are defined in this file next to the definition of SHCI_OPCODE_C2_CONFIG diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index 6cccc5dd..ddb3a02b 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -16,15 +16,12 @@ ****************************************************************************** */ -#if defined(STM32WBxx) + /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" -#include - #include "stm_list.h" #include "shci_tl.h" -#include "stm32_def.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,12 +235,11 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { + (void)timeout; + CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; - for (unsigned long start = millis(); (millis() - start) < timeout;) { - if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { - break; - } - } + while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); + return; } @@ -270,5 +252,4 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h index 5a2b2a55..b47b804a 100644 --- a/src/utility/STM32Cube_FW/stm32_wpan_common.h +++ b/src/utility/STM32Cube_FW/stm32_wpan_common.h @@ -25,9 +25,19 @@ extern "C" { #endif -#define __ASM __asm /*!< asm keyword for GNU Compiler */ -#define __INLINE inline /*!< inline keyword for GNU Compiler */ -#define __STATIC_INLINE static inline +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline +#endif #include #include @@ -130,8 +140,29 @@ extern "C" { /* ----------------------------------- * * Packed usage (compiler dependent) * * ----------------------------------- */ +#undef PACKED__ #undef PACKED_STRUCT -#define PACKED_STRUCT struct __packed + +#if defined ( __CC_ARM ) + #if defined ( __GNUC__ ) + /* GNU extension */ + #define PACKED__ __attribute__((packed)) + #define PACKED_STRUCT struct PACKED__ + #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050U) + #define PACKED__ __attribute__((packed)) + #define PACKED_STRUCT struct PACKED__ + #else + #define PACKED__(TYPE) __packed TYPE + #define PACKED_STRUCT PACKED__(struct) + #endif +#elif defined ( __GNUC__ ) + #define PACKED__ __attribute__((packed)) + #define PACKED_STRUCT struct PACKED__ +#elif defined (__ICCARM__) + #define PACKED_STRUCT __packed struct +#else + #define PACKED_STRUCT __packed struct +#endif #ifdef __cplusplus } diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c index d8c9e093..4c928647 100644 --- a/src/utility/STM32Cube_FW/stm_list.c +++ b/src/utility/STM32Cube_FW/stm_list.c @@ -1,208 +1,206 @@ -/** - ****************************************************************************** - * @file stm_list.c - * @author MCD Application Team - * @brief TCircular Linked List Implementation. - ****************************************************************************** - * @attention - * - * Copyright (c) 2018-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. - * - ****************************************************************************** - */ - -#if defined(STM32WBxx) -/****************************************************************************** - * Include Files - ******************************************************************************/ -#include "stm_list.h" -#include "cmsis_gcc.h" -#include "stm32_wpan_common.h" - -/****************************************************************************** - * Function Definitions - ******************************************************************************/ -void LST_init_head (tListNode * listHead) -{ - listHead->next = listHead; - listHead->prev = listHead; -} - -bool LST_is_empty (tListNode * listHead) -{ - uint32_t primask_bit; - bool return_value; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - if(listHead->next == listHead) - { - return_value = TRUE; - } - else - { - return_value = FALSE; - } - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ - - return return_value; -} - -void LST_insert_head (tListNode * listHead, tListNode * node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = listHead->next; - node->prev = listHead; - listHead->next = node; - (node->next)->prev = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_insert_tail (tListNode * listHead, tListNode * node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = listHead; - node->prev = listHead->prev; - listHead->prev = node; - (node->prev)->next = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_remove_node (tListNode * node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - (node->prev)->next = node->next; - (node->next)->prev = node->prev; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_remove_head (tListNode * listHead, tListNode ** node ) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = listHead->next; - LST_remove_node (listHead->next); - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_remove_tail (tListNode * listHead, tListNode ** node ) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = listHead->prev; - LST_remove_node (listHead->prev); - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_insert_node_after (tListNode * node, tListNode * ref_node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = ref_node->next; - node->prev = ref_node; - ref_node->next = node; - (node->next)->prev = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_insert_node_before (tListNode * node, tListNode * ref_node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - node->next = ref_node; - node->prev = ref_node->prev; - ref_node->prev = node; - (node->prev)->next = node; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -int LST_get_size (tListNode * listHead) -{ - int size = 0; - tListNode * temp; - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - temp = listHead->next; - while (temp != listHead) - { - size++; - temp = temp->next; - } - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ - - return (size); -} - -void LST_get_next_node (tListNode * ref_node, tListNode ** node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = ref_node->next; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - - -void LST_get_prev_node (tListNode * ref_node, tListNode ** node) -{ - uint32_t primask_bit; - - primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ - __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - - *node = ref_node->prev; - - __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ -} - -#endif /* STM32WBxx */ \ No newline at end of file +/** + ****************************************************************************** + * @file stm_list.c + * @author MCD Application Team + * @brief TCircular Linked List Implementation. + ****************************************************************************** + * @attention + * + * Copyright (c) 2018-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. + * + ****************************************************************************** + */ + + +/****************************************************************************** + * Include Files + ******************************************************************************/ +#include "utilities_common.h" + +#include "stm_list.h" + +/****************************************************************************** + * Function Definitions + ******************************************************************************/ +void LST_init_head (tListNode * listHead) +{ + listHead->next = listHead; + listHead->prev = listHead; +} + +uint8_t LST_is_empty (tListNode * listHead) +{ + uint32_t primask_bit; + uint8_t return_value; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + if(listHead->next == listHead) + { + return_value = TRUE; + } + else + { + return_value = FALSE; + } + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ + + return return_value; +} + +void LST_insert_head (tListNode * listHead, tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = listHead->next; + node->prev = listHead; + listHead->next = node; + (node->next)->prev = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_insert_tail (tListNode * listHead, tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = listHead; + node->prev = listHead->prev; + listHead->prev = node; + (node->prev)->next = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_remove_node (tListNode * node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + (node->prev)->next = node->next; + (node->next)->prev = node->prev; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_remove_head (tListNode * listHead, tListNode ** node ) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = listHead->next; + LST_remove_node (listHead->next); + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_remove_tail (tListNode * listHead, tListNode ** node ) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = listHead->prev; + LST_remove_node (listHead->prev); + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_insert_node_after (tListNode * node, tListNode * ref_node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = ref_node->next; + node->prev = ref_node; + ref_node->next = node; + (node->next)->prev = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_insert_node_before (tListNode * node, tListNode * ref_node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + node->next = ref_node; + node->prev = ref_node->prev; + ref_node->prev = node; + (node->prev)->next = node; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +int LST_get_size (tListNode * listHead) +{ + int size = 0; + tListNode * temp; + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + temp = listHead->next; + while (temp != listHead) + { + size++; + temp = temp->next; + } + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ + + return (size); +} + +void LST_get_next_node (tListNode * ref_node, tListNode ** node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = ref_node->next; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} + + +void LST_get_prev_node (tListNode * ref_node, tListNode ** node) +{ + uint32_t primask_bit; + + primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ + __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + + *node = ref_node->prev; + + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ +} diff --git a/src/utility/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h index 769c2113..b7c3254c 100644 --- a/src/utility/STM32Cube_FW/stm_list.h +++ b/src/utility/STM32Cube_FW/stm_list.h @@ -21,8 +21,6 @@ #define _STM_LIST_H_ /* Includes ------------------------------------------------------------------*/ -#include "stdint.h" -#include "stdbool.h" #include "stm32_wpan_common.h" typedef PACKED_STRUCT _tListNode { @@ -32,7 +30,7 @@ typedef PACKED_STRUCT _tListNode { void LST_init_head (tListNode * listHead); -bool LST_is_empty (tListNode * listHead); +uint8_t LST_is_empty (tListNode * listHead); void LST_insert_head (tListNode * listHead, tListNode * node); diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h index 16de7f16..2124d260 100644 --- a/src/utility/STM32Cube_FW/tl.h +++ b/src/utility/STM32Cube_FW/tl.h @@ -184,6 +184,7 @@ typedef struct uint8_t *p_ThreadOtCmdRspBuffer; uint8_t *p_ThreadCliRspBuffer; uint8_t *p_ThreadNotAckBuffer; + uint8_t *p_ThreadCliNotBuffer; } TL_TH_Config_t; typedef struct @@ -198,6 +199,19 @@ typedef struct uint8_t *p_BleLldM0CmdBuffer; } TL_BLE_LLD_Config_t; +typedef struct +{ + uint8_t *p_Mac_802_15_4_CmdRspBuffer; + uint8_t *p_Mac_802_15_4_NotAckBuffer; +} TL_MAC_802_15_4_Config_t; + +typedef struct +{ + uint8_t *p_ZigbeeOtCmdRspBuffer; + uint8_t *p_ZigbeeNotAckBuffer; + uint8_t *p_ZigbeeNotifRequestBuffer; +} TL_ZIGBEE_Config_t; + /** * @brief Contain the BLE HCI Init Configuration * @{ @@ -291,6 +305,26 @@ void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); void TL_TRACES_Init( void ); void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ); +/****************************************************************************** + * MAC 802.15.4 + ******************************************************************************/ +void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ); +void TL_MAC_802_15_4_SendCmd( void ); +void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); +void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ); +void TL_MAC_802_15_4_SendAck ( void ); + +/****************************************************************************** + * ZIGBEE + ******************************************************************************/ +void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ); +void TL_ZIGBEE_SendM4RequestToM0( void ); +void TL_ZIGBEE_SendM4AckToM0Notify ( void ); +void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ); +void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); +void TL_ZIGBEE_M0RequestReceived(TL_EvtPacket_t * Otbuffer ); +void TL_ZIGBEE_SendM4AckToM0Request(void); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c index db192c4f..4112429d 100644 --- a/src/utility/STM32Cube_FW/tl_mbox.c +++ b/src/utility/STM32Cube_FW/tl_mbox.c @@ -16,7 +16,6 @@ ****************************************************************************** */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -24,6 +23,7 @@ #include "stm_list.h" #include "tl.h" #include "mbox_def.h" +#include "tl_dbg_conf.h" /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -51,13 +51,15 @@ 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; +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; /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue; PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)]; -PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode EvtQueue; -PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode SystemEvtQueue; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode EvtQueue; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode SystemEvtQueue; static tListNode LocalFreeBufQueue; @@ -95,6 +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; + TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; + TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; HW_IPCC_Init(); return; @@ -256,6 +260,7 @@ void TL_THREAD_Init( TL_TH_Config_t *p_Config ) p_thread_table->clicmdrsp_buffer = p_Config->p_ThreadCliRspBuffer; p_thread_table->otcmdrsp_buffer = p_Config->p_ThreadOtCmdRspBuffer; p_thread_table->notack_buffer = p_Config->p_ThreadNotAckBuffer; + p_thread_table->clinot_buffer = p_Config->p_ThreadCliNotBuffer; HW_IPCC_THREAD_Init(); @@ -314,7 +319,7 @@ void HW_IPCC_THREAD_EvtNot( void ) void HW_IPCC_THREAD_CliEvtNot( void ) { - TL_THREAD_CliNotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->clicmdrsp_buffer) ); + TL_THREAD_CliNotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->clinot_buffer) ); return; } @@ -447,6 +452,139 @@ void TL_BLE_LLD_SendRspAck( void ) } #endif /* BLE_LLD_WB */ +#ifdef MAC_802_15_4_WB +/****************************************************************************** + * MAC 802.15.4 + ******************************************************************************/ +void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ) +{ + MB_Mac_802_15_4_t * p_mac_802_15_4_table; + + p_mac_802_15_4_table = TL_RefTable.p_mac_802_15_4_table; + + p_mac_802_15_4_table->p_cmdrsp_buffer = p_Config->p_Mac_802_15_4_CmdRspBuffer; + p_mac_802_15_4_table->p_notack_buffer = p_Config->p_Mac_802_15_4_NotAckBuffer; + + HW_IPCC_MAC_802_15_4_Init(); + + return; +} + +void TL_MAC_802_15_4_SendCmd( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; + + HW_IPCC_MAC_802_15_4_SendCmd(); + + return; +} + +void TL_MAC_802_15_4_SendAck ( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_MAC_802_15_4_SendAck(); + + return; +} + +void HW_IPCC_MAC_802_15_4_CmdEvtNot(void) +{ + TL_MAC_802_15_4_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer) ); + + return; +} + +void HW_IPCC_MAC_802_15_4_EvtNot( void ) +{ + TL_MAC_802_15_4_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer) ); + + return; +} + +__WEAK void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; +__WEAK void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){}; +#endif + +#ifdef ZIGBEE_WB +/****************************************************************************** + * ZIGBEE + ******************************************************************************/ +void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ) +{ + MB_ZigbeeTable_t * p_zigbee_table; + + p_zigbee_table = TL_RefTable.p_zigbee_table; + p_zigbee_table->appliCmdM4toM0_buffer = p_Config->p_ZigbeeOtCmdRspBuffer; + p_zigbee_table->notifM0toM4_buffer = p_Config->p_ZigbeeNotAckBuffer; + p_zigbee_table->requestM0toM4_buffer = p_Config->p_ZigbeeNotifRequestBuffer; + + HW_IPCC_ZIGBEE_Init(); + + return; +} + +/* Zigbee M4 to M0 Request */ +void TL_ZIGBEE_SendM4RequestToM0( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4RequestToM0(); + + return; +} + +/* Used to receive an ACK from the M0 */ +void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void) +{ + TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) ); + + return; +} + +/* Zigbee notification from M0 to M4 */ +void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ) +{ + TL_ZIGBEE_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer) ); + + return; +} + +/* Send an ACK to the M0 for a Notification */ +void TL_ZIGBEE_SendM4AckToM0Notify ( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4AckToM0Notify(); + + return; +} + +/* Zigbee M0 to M4 Request */ +void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ) +{ + TL_ZIGBEE_M0RequestReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer) ); + + return; +} + +/* Send an ACK to the M0 for a Request */ +void TL_ZIGBEE_SendM4AckToM0Request(void) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4AckToM0Request(); + + return; +} + + +__WEAK void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; +__WEAK void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){}; +#endif + + + /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -531,11 +669,181 @@ __WEAK void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ) ******************************************************************************/ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) { - /* Function stubbed */ - UNUSED(packet_type); - UNUSED(buffer); + TL_EvtPacket_t *p_evt_packet; + TL_CmdPacket_t *p_cmd_packet; + + switch(packet_type) + { + case TL_MB_MM_RELEASE_BUFFER: + p_evt_packet = (TL_EvtPacket_t*)buffer; + switch(p_evt_packet->evtserial.evt.evtcode) + { + case TL_BLEEVT_CS_OPCODE: + TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_MM_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); + TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); + break; + + case TL_BLEEVT_CC_OPCODE: + TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_MM_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); + TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); + break; + + case TL_BLEEVT_VS_OPCODE: + TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_MM_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); + TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); + break; + + default: + TL_MM_DBG_MSG("mm evt released: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_MM_DBG_MSG(" buffer addr: 0x%08X", p_evt_packet); + break; + } + + TL_MM_DBG_MSG("\r\n"); + break; + + case TL_MB_BLE_CMD: + p_cmd_packet = (TL_CmdPacket_t*)buffer; + TL_HCI_CMD_DBG_MSG("ble cmd: 0x%04X", p_cmd_packet->cmdserial.cmd.cmdcode); + if(p_cmd_packet->cmdserial.cmd.plen != 0) + { + TL_HCI_CMD_DBG_MSG(" payload:"); + TL_HCI_CMD_DBG_BUF(p_cmd_packet->cmdserial.cmd.payload, p_cmd_packet->cmdserial.cmd.plen, ""); + } + TL_HCI_CMD_DBG_MSG("\r\n"); + + TL_HCI_CMD_DBG_RAW(&p_cmd_packet->cmdserial, p_cmd_packet->cmdserial.cmd.plen+TL_CMD_HDR_SIZE); + break; + + case TL_MB_BLE_CMD_RSP: + p_evt_packet = (TL_EvtPacket_t*)buffer; + switch(p_evt_packet->evtserial.evt.evtcode) + { + case TL_BLEEVT_CS_OPCODE: + TL_HCI_CMD_DBG_MSG("ble rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_HCI_CMD_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); + TL_HCI_CMD_DBG_MSG(" numhci: 0x%02X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->numcmd); + TL_HCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CsEvt_t*)(p_evt_packet->evtserial.evt.payload))->status); + break; + + case TL_BLEEVT_CC_OPCODE: + TL_HCI_CMD_DBG_MSG("ble rsp: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_HCI_CMD_DBG_MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->cmdcode); + TL_HCI_CMD_DBG_MSG(" numhci: 0x%02X", ((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->numcmd); + TL_HCI_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_HCI_CMD_DBG_MSG(" payload:"); + TL_HCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[1], p_evt_packet->evtserial.evt.plen-4, ""); + } + break; + + default: + TL_HCI_CMD_DBG_MSG("unknown ble rsp received: %02X", p_evt_packet->evtserial.evt.evtcode); + break; + } + + TL_HCI_CMD_DBG_MSG("\r\n"); + + TL_HCI_CMD_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); + break; + + case TL_MB_BLE_ASYNCH_EVT: + p_evt_packet = (TL_EvtPacket_t*)buffer; + if(p_evt_packet->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) + { + TL_HCI_EVT_DBG_MSG("ble evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + if((p_evt_packet->evtserial.evt.plen) != 0) + { + TL_HCI_EVT_DBG_MSG(" payload:"); + TL_HCI_EVT_DBG_BUF(p_evt_packet->evtserial.evt.payload, p_evt_packet->evtserial.evt.plen, ""); + } + } + else + { + TL_HCI_EVT_DBG_MSG("ble evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_HCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); + if((p_evt_packet->evtserial.evt.plen-2) != 0) + { + TL_HCI_EVT_DBG_MSG(" payload:"); + TL_HCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload, p_evt_packet->evtserial.evt.plen-2, ""); + } + } + + TL_HCI_EVT_DBG_MSG("\r\n"); + + TL_HCI_EVT_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); + break; + + case TL_MB_SYS_CMD: + p_cmd_packet = (TL_CmdPacket_t*)buffer; + + TL_SHCI_CMD_DBG_MSG("sys cmd: 0x%04X", p_cmd_packet->cmdserial.cmd.cmdcode); + + if(p_cmd_packet->cmdserial.cmd.plen != 0) + { + TL_SHCI_CMD_DBG_MSG(" payload:"); + TL_SHCI_CMD_DBG_BUF(p_cmd_packet->cmdserial.cmd.payload, p_cmd_packet->cmdserial.cmd.plen, ""); + } + TL_SHCI_CMD_DBG_MSG("\r\n"); + + TL_SHCI_CMD_DBG_RAW(&p_cmd_packet->cmdserial, p_cmd_packet->cmdserial.cmd.plen+TL_CMD_HDR_SIZE); + break; + + case TL_MB_SYS_CMD_RSP: + p_evt_packet = (TL_EvtPacket_t*)buffer; + switch(p_evt_packet->evtserial.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(" payload:"); + TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload[1], p_evt_packet->evtserial.evt.plen-4, ""); + } + break; + + default: + TL_SHCI_CMD_DBG_MSG("unknown sys rsp received: %02X", p_evt_packet->evtserial.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); + break; + + case TL_MB_SYS_ASYNCH_EVT: + p_evt_packet = (TL_EvtPacket_t*)buffer; + if(p_evt_packet->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) + { + TL_SHCI_EVT_DBG_MSG("unknown sys evt received: %02X", p_evt_packet->evtserial.evt.evtcode); + } + else + { + TL_SHCI_EVT_DBG_MSG("sys evt: 0x%02X", p_evt_packet->evtserial.evt.evtcode); + TL_SHCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->subevtcode); + if((p_evt_packet->evtserial.evt.plen-2) != 0) + { + TL_SHCI_EVT_DBG_MSG(" payload:"); + TL_SHCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(p_evt_packet->evtserial.evt.payload))->payload, p_evt_packet->evtserial.evt.plen-2, ""); + } + } + + TL_SHCI_EVT_DBG_MSG("\r\n"); + + TL_SHCI_EVT_DBG_RAW(&p_evt_packet->evtserial, p_evt_packet->evtserial.evt.plen+TL_EVT_HDR_SIZE); + break; + + default: + break; + } return; } -#endif /* STM32WBxx */ From 4a9f4ae6b3e00b0bae34f806466b208919955afa Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Tue, 30 Aug 2022 11:28:41 +0200 Subject: [PATCH 31/58] chore: clean up and adapt STM32Cube_FW sources for STM32duino Signed-off-by: Alexandre Bourdiol --- src/utility/STM32Cube_FW/app_conf_default.h | 428 +------------------ src/utility/STM32Cube_FW/ble_bufsize.h | 13 +- src/utility/STM32Cube_FW/hw.h | 28 +- src/utility/STM32Cube_FW/hw_ipcc.c | 184 +------- src/utility/STM32Cube_FW/mbox_def.h | 34 -- src/utility/STM32Cube_FW/shci.c | 40 +- src/utility/STM32Cube_FW/shci.h | 47 +- src/utility/STM32Cube_FW/shci_tl.c | 19 +- src/utility/STM32Cube_FW/stm32_wpan_common.h | 39 +- src/utility/STM32Cube_FW/stm_list.c | 11 +- src/utility/STM32Cube_FW/stm_list.h | 4 +- src/utility/STM32Cube_FW/tl.h | 33 -- src/utility/STM32Cube_FW/tl_mbox.c | 144 +------ 13 files changed, 91 insertions(+), 933 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h index c63c66e9..54f824ae 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -1,4 +1,3 @@ -/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file app_conf.h @@ -16,94 +15,36 @@ * ****************************************************************************** */ -/* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef APP_CONF_H #define APP_CONF_H #include "hw.h" -#include "hw_conf.h" -#include "hw_if.h" #include "ble_bufsize.h" /****************************************************************************** * Application Config ******************************************************************************/ -/** - * Define Secure Connections Support - */ -#define CFG_SECURE_NOT_SUPPORTED (0x00) -#define CFG_SECURE_OPTIONAL (0x01) -#define CFG_SECURE_MANDATORY (0x02) - -#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL - -/** - * Define Keypress Notification Support - */ -#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) -#define CFG_KEYPRESS_SUPPORTED (0x01) +/**< generic parameters ******************************************************/ +/* HCI related defines */ -#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED +#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 -/** - * Numeric Comparison Answers - */ -#define YES (0x01) -#define NO (0x00) - -/** - * Device name configuration for Generic Access Service - */ -#define CFG_GAP_DEVICE_NAME "TEMPLATE" -#define CFG_GAP_DEVICE_NAME_LENGTH (8) - -/** -* Identity root key used to derive LTK and CSRK -*/ -#define CFG_BLE_IRK {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0} - -/** -* Encryption root key used to derive LTK and CSRK -*/ -#define CFG_BLE_ERK {0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21, 0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21} +#ifndef BLE_SHARED_MEM_BYTE_ORDER + #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST +#endif +#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 /** - * SMPS supply - * SMPS not used when Set to 0 - * SMPS used when Set to 1 + * Define Tx Power */ -#define CFG_USE_SMPS 0 - -/* USER CODE BEGIN Generic_Parameters */ -/* USER CODE END Generic_Parameters */ - -/**< specific parameters */ -/*****************************************************/ - -/* USER CODE BEGIN Specific_Parameters */ -#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler - -/* USER CODE END Specific_Parameters */ - -/****************************************************************************** - * Information Table - * - * Version - * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version - * [4:7] = branch - 0: Mass Market - x: ... - * [8:15] = Subversion - * [16:23] = Version minor - * [24:31] = Version major - * - ******************************************************************************/ -#define CFG_FW_MAJOR_VERSION (0) -#define CFG_FW_MINOR_VERSION (0) -#define CFG_FW_SUBVERSION (1) -#define CFG_FW_BRANCH (0) -#define CFG_FW_BUILD (0) +#define CFG_TX_POWER (0x18) /* -0.15dBm */ /****************************************************************************** * BLE Stack @@ -152,13 +93,15 @@ * Prepare Write List size in terms of number of packet * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +// #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) /** * Number of allocated memory blocks * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) +// #define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) +#define CFG_BLE_MBLOCK_COUNT (0x79) /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. @@ -241,7 +184,7 @@ * 0: LE Power Class 2-3 * other bits: reserved (shall be set to 0) */ -#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_POWER_CLASS_2_3) +#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY) #define CFG_BLE_MAX_COC_INITIATOR_NBR (32) @@ -291,340 +234,5 @@ #define CFG_BLE_RX_PATH_COMPENS (0) -/****************************************************************************** - * Transport Layer - ******************************************************************************/ -/** - * Queue length of BLE Event - * This parameter defines the number of asynchronous events that can be stored in the HCI layer before - * being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer - * is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large - * enough to store all asynchronous events received in between. - * When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events - * between the HCI command and its event. - * This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small, - * the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting - * for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate - * to the application a HCI command did not receive its command event within 30s (Default HCI Timeout). - */ -#define CFG_TLBLE_EVT_QUEUE_LENGTH 5 -/** - * This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element - * allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager. - * It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will - * never be used) - * It shall be at least 4 to receive the command status event in one frame. - * The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced - * further depending on the application. - */ -#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */ - -#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE ) -/****************************************************************************** - * UART interfaces - ******************************************************************************/ - -/** - * Select UART interfaces - */ -#define CFG_UART_GUI hw_uart1 -#define CFG_DEBUG_TRACE_UART 0 -/****************************************************************************** - * USB interface - ******************************************************************************/ - -/** - * Enable/Disable USB interface - */ -#define CFG_USB_INTERFACE_ENABLE 0 - -/****************************************************************************** - * IPCC interface - ******************************************************************************/ - -/** - * The IPCC is dedicated to the communication between the CPU2 and the CPU1 - * and shall not be modified by the application - * The two following definitions shall not be modified - */ -#define HAL_IPCC_TX_IRQHandler(...) HW_IPCC_Tx_Handler( ) -#define HAL_IPCC_RX_IRQHandler(...) HW_IPCC_Rx_Handler( ) - -/****************************************************************************** - * Low Power - ******************************************************************************/ -/** - * When set to 1, the low power mode is enable - * When set to 0, the device stays in RUN mode - */ -#define CFG_LPM_SUPPORTED 1 - -/****************************************************************************** - * RTC interface - ******************************************************************************/ -#define HAL_RTCEx_WakeUpTimerIRQHandler(...) HW_TS_RTC_Wakeup_Handler( ) - -/****************************************************************************** - * Timer Server - ******************************************************************************/ -/** - * CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer. - * The lower is the value, the better is the power consumption and the accuracy of the timerserver - * The higher is the value, the finest is the granularity - * - * CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to output - * clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding - * the wakeup timer. A lower clock speed would impact the accuracy of the timer server. - * - * CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC. - * When the 1Hz calendar clock is required, it shall be sets according to other settings - * When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE) - * - * CFG_RTCCLK_DIVIDER_CONF: - * Shall be set to either 0,2,4,8,16 - * When set to either 2,4,8,16, the 1Hhz calendar is supported - * When set to 0, the user sets its own configuration - * - * The following settings are computed with LSI as input to the RTC - */ - -#define CFG_RTCCLK_DIVIDER_CONF 0 - -#if (CFG_RTCCLK_DIVIDER_CONF == 0) -/** - * Custom configuration - * It does not support 1Hz calendar - * It divides the RTC CLK by 16 - */ - -#define CFG_RTCCLK_DIV (16) -#define CFG_RTC_WUCKSEL_DIVIDER (0) -#define CFG_RTC_ASYNCH_PRESCALER (0x0F) -#define CFG_RTC_SYNCH_PRESCALER (0x7FFF) - -#else - -#if (CFG_RTCCLK_DIVIDER_CONF == 2) -/** - * It divides the RTC CLK by 2 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (3) -#endif - -#if (CFG_RTCCLK_DIVIDER_CONF == 4) -/** - * It divides the RTC CLK by 4 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (2) -#endif - -#if (CFG_RTCCLK_DIVIDER_CONF == 8) -/** - * It divides the RTC CLK by 8 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (1) -#endif - -#if (CFG_RTCCLK_DIVIDER_CONF == 16) -/** - * It divides the RTC CLK by 16 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (0) -#endif - -#define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF -#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) -#define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 ) - -#endif - -/** tick timer values */ -#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE ) -#define CFG_TS_TICK_VAL_PS DIVR( ((uint64_t)CFG_RTCCLK_DIV * 1e12), (uint64_t)LSE_VALUE ) - -typedef enum -{ - CFG_TIM_PROC_ID_ISR, - /* USER CODE BEGIN CFG_TimProcID_t */ - - /* USER CODE END CFG_TimProcID_t */ -} CFG_TimProcID_t; - -/****************************************************************************** - * Debug - ******************************************************************************/ -/** - * When set, this resets some hw resources to set the device in the same state than the power up - * The FW resets only register that may prevent the FW to run properly - * - * This shall be set to 0 in a final product - * - */ -#define CFG_HW_RESET_BY_FW 1 - -/** - * keep debugger enabled while in any low power mode when set to 1 - * should be set to 0 in production - */ -#define CFG_DEBUGGER_SUPPORTED 0 - -/** - * When set to 1, the traces are enabled in the BLE services - */ -#define CFG_DEBUG_BLE_TRACE 0 - -/** - * Enable or Disable traces in application - */ -#define CFG_DEBUG_APP_TRACE 0 - -#if (CFG_DEBUG_APP_TRACE != 0) -#define APP_DBG_MSG PRINT_MESG_DBG -#else -#define APP_DBG_MSG PRINT_NO_MESG -#endif - -#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) ) -#define CFG_DEBUG_TRACE 1 -#endif - -#if (CFG_DEBUG_TRACE != 0) -#undef CFG_LPM_SUPPORTED -#undef CFG_DEBUGGER_SUPPORTED -#define CFG_LPM_SUPPORTED 0 -#define CFG_DEBUGGER_SUPPORTED 1 -#endif - -/** - * When CFG_DEBUG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number - * When CFG_DEBUG_TRACE_LIGHT is set to 1, only the debug message is output - * - * When both are set to 0, no trace are output - * When both are set to 1, CFG_DEBUG_TRACE_FULL is selected - */ -#define CFG_DEBUG_TRACE_LIGHT 0 -#define CFG_DEBUG_TRACE_FULL 0 - -#if (( CFG_DEBUG_TRACE != 0 ) && ( CFG_DEBUG_TRACE_LIGHT == 0 ) && (CFG_DEBUG_TRACE_FULL == 0)) -#undef CFG_DEBUG_TRACE_FULL -#undef CFG_DEBUG_TRACE_LIGHT -#define CFG_DEBUG_TRACE_FULL 0 -#define CFG_DEBUG_TRACE_LIGHT 1 -#endif - -#if ( CFG_DEBUG_TRACE == 0 ) -#undef CFG_DEBUG_TRACE_FULL -#undef CFG_DEBUG_TRACE_LIGHT -#define CFG_DEBUG_TRACE_FULL 0 -#define CFG_DEBUG_TRACE_LIGHT 0 -#endif - -/** - * When not set, the traces is looping on sending the trace over UART - */ -#define DBG_TRACE_USE_CIRCULAR_QUEUE 1 - -/** - * max buffer Size to queue data traces and max data trace allowed. - * Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined - */ -#define DBG_TRACE_MSG_QUEUE_SIZE 4096 -#define MAX_DBG_TRACE_MSG_SIZE 1024 - -/* USER CODE BEGIN Defines */ -#define CFG_LED_SUPPORTED 1 -#define CFG_BUTTON_SUPPORTED 1 - -#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler -#define PUSH_BUTTON_SW2_EXTI_IRQHandler EXTI0_IRQHandler -#define PUSH_BUTTON_SW3_EXTI_IRQHandler EXTI1_IRQHandler -/* USER CODE END Defines */ - -/****************************************************************************** - * Scheduler - ******************************************************************************/ - -/** - * These are the lists of task id registered to the scheduler - * Each task id shall be in the range [0:31] - * This mechanism allows to implement a generic code in the API TL_BLE_HCI_StatusNot() to comply with - * the requirement that a HCI/ACI command shall never be sent if there is already one pending - */ - -/**< Add in that list all tasks that may send a ACI/HCI command */ -typedef enum -{ - CFG_TASK_BLE_HCI_CMD_ID, - CFG_TASK_SYS_HCI_CMD_ID, - CFG_TASK_HCI_ACL_DATA_ID, - CFG_TASK_SYS_LOCAL_CMD_ID, - CFG_TASK_TX_TO_HOST_ID, - /* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */ - CFG_TASK_SW1_BUTTON_PUSHED_ID, - CFG_TASK_SW2_BUTTON_PUSHED_ID, - CFG_TASK_SW3_BUTTON_PUSHED_ID, - /* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */ - CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */ -} CFG_Task_Id_With_HCI_Cmd_t; - -/**< Add in that list all tasks that never send a ACI/HCI command */ -typedef enum -{ - CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */ - CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID, - /* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */ - - /* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */ - CFG_LAST_TASK_ID_WITH_NO_HCICMD /**< Shall be LAST in the list */ -} CFG_Task_Id_With_NO_HCI_Cmd_t; - -#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITH_NO_HCICMD - -/** - * This is the list of priority required by the application - * Each Id shall be in the range 0..31 - */ -typedef enum -{ - CFG_SCH_PRIO_0, - /* USER CODE BEGIN CFG_SCH_Prio_Id_t */ - - /* USER CODE END CFG_SCH_Prio_Id_t */ -} CFG_SCH_Prio_Id_t; - -/** - * This is a bit mapping over 32bits listing all events id supported in the application - */ -typedef enum -{ - CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID, - /* USER CODE BEGIN CFG_IdleEvt_Id_t */ - - /* USER CODE END CFG_IdleEvt_Id_t */ -} CFG_IdleEvt_Id_t; - -/****************************************************************************** - * LOW POWER - ******************************************************************************/ -/** - * Supported requester to the MCU Low Power Manager - can be increased up to 32 - * It list a bit mapping of all user of the Low Power Manager - */ -typedef enum -{ - CFG_LPM_APP, - CFG_LPM_APP_BLE, - /* USER CODE BEGIN CFG_LPM_Id_t */ - - /* USER CODE END CFG_LPM_Id_t */ -} CFG_LPM_Id_t; - -/****************************************************************************** - * OTP manager - ******************************************************************************/ -#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE - -#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR - #endif /*APP_CONF_H */ diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h index 0f0f4192..247573be 100644 --- a/src/utility/STM32Cube_FW/ble_bufsize.h +++ b/src/utility/STM32Cube_FW/ble_bufsize.h @@ -75,17 +75,24 @@ ((pw) + MAX(BLE_MEM_BLOCK_X_MTU(mtu, n_link), \ BLE_MBLOCKS_SECURE_CONNECTIONS)) +/* + * BLE_DEFAULT_MBLOCKS_COUNT: default memory blocks count + */ +#define BLE_DEFAULT_MBLOCKS_COUNT(n_link) \ + BLE_MBLOCKS_CALC(BLE_DEFAULT_PREP_WRITE_LIST_SIZE, \ + BLE_DEFAULT_MAX_ATT_MTU, n_link) + /* * BLE_FIXED_BUFFER_SIZE_BYTES: - * A part of the RAM, is dinamically allocated by initilizing all the pointers + * A part of the RAM, is dynamically allocated by initializing all the pointers * defined in a global context variable "mem_alloc_ctx_p". * This initialization is made in the Dynamic_allocator functions, which - * assing a portion of RAM given by the external application to the above + * assign a portion of RAM given by the external application to the above * mentioned "global pointers". * * The size of this Dynamic RAM is made of 2 main components: * - a part that is parameters-dependent (num of links, GATT buffers, ...), - * and which value is explicited by the following macro; + * and which value is defined by the following macro; * - a part, that may be considered "fixed", i.e. independent from the above * mentioned parameters. */ diff --git a/src/utility/STM32Cube_FW/hw.h b/src/utility/STM32Cube_FW/hw.h index 503fa2ca..fcf04517 100644 --- a/src/utility/STM32Cube_FW/hw.h +++ b/src/utility/STM32Cube_FW/hw.h @@ -26,14 +26,21 @@ 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 ); void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); @@ -80,23 +87,6 @@ extern "C" { void HW_IPCC_TRACES_Init( void ); void HW_IPCC_TRACES_EvtNot( void ); - void HW_IPCC_MAC_802_15_4_Init( void ); - void HW_IPCC_MAC_802_15_4_SendCmd( void ); - void HW_IPCC_MAC_802_15_4_SendAck( void ); - void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ); - void HW_IPCC_MAC_802_15_4_EvtNot( void ); - - void HW_IPCC_ZIGBEE_Init( void ); - - void HW_IPCC_ZIGBEE_SendM4RequestToM0(void); /* M4 Request to M0 */ - void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void); /* Request ACK from M0 */ - - void HW_IPCC_ZIGBEE_RecvM0NotifyToM4(void); /* M0 Notify to M4 */ - void HW_IPCC_ZIGBEE_SendM4AckToM0Notify(void); /* Notify ACK from M4 */ - void HW_IPCC_ZIGBEE_RecvM0RequestToM4(void); /* M0 Request to M4 */ - void HW_IPCC_ZIGBEE_SendM4AckToM0Request(void); /* Request ACK from M4 */ - - #ifdef __cplusplus } #endif diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c index fd620b85..7b9be81a 100644 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ b/src/utility/STM32Cube_FW/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 ---------------------------------------------------------*/ @@ -56,34 +57,17 @@ static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ); static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void ); #endif -#ifdef MAC_802_15_4_WB -static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ); -static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ); -#endif - -#ifdef ZIGBEE_WB -static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ); -static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ); -static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ); -#endif - /* Public function definition -----------------------------------------------*/ /****************************************************************************** * INTERRUPT HANDLER ******************************************************************************/ -void HW_IPCC_Rx_Handler( void ) +void IPCC_C1_RX_IRQHandler(void) { if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL )) { HW_IPCC_SYS_EvtHandler(); } -#ifdef MAC_802_15_4_WB - else if (HW_IPCC_RX_PENDING( HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL )) - { - HW_IPCC_MAC_802_15_4_NotEvtHandler(); - } -#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL )) { @@ -114,16 +98,6 @@ void HW_IPCC_Rx_Handler( void ) HW_IPCC_LLD_BLE_ReceiveM0CmdHandler(); } #endif /* LLD_TESTS_WB */ -#ifdef ZIGBEE_WB - else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL )) - { - HW_IPCC_ZIGBEE_StackNotifEvtHandler(); - } - else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL )) - { - HW_IPCC_ZIGBEE_StackM0RequestHandler(); - } -#endif /* ZIGBEE_WB */ else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL )) { HW_IPCC_BLE_EvtHandler(); @@ -132,22 +106,14 @@ void HW_IPCC_Rx_Handler( void ) { HW_IPCC_TRACES_EvtHandler(); } - - return; } -void HW_IPCC_Tx_Handler( void ) +void IPCC_C1_TX_IRQHandler(void) { if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) { HW_IPCC_SYS_CmdEvtHandler(); } -#ifdef MAC_802_15_4_WB - else if (HW_IPCC_TX_PENDING( HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL )) - { - HW_IPCC_MAC_802_15_4_CmdEvtHandler(); - } -#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) { @@ -157,12 +123,6 @@ void HW_IPCC_Tx_Handler( void ) #ifdef LLD_TESTS_WB // No TX handler for LLD tests #endif /* LLD_TESTS_WB */ -#ifdef ZIGBEE_WB - if (HW_IPCC_TX_PENDING( HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL )) - { - HW_IPCC_ZIGBEE_CmdEvtHandler(); - } -#endif /* ZIGBEE_WB */ else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL )) { HW_IPCC_MM_FreeBufHandler(); @@ -171,9 +131,8 @@ void HW_IPCC_Tx_Handler( void ) { HW_IPCC_BLE_AclDataEvtHandler(); } - - return; } + /****************************************************************************** * GENERAL ******************************************************************************/ @@ -264,8 +223,8 @@ static void HW_IPCC_BLE_AclDataEvtHandler( void ) return; } -__weak void HW_IPCC_BLE_AclDataAckNot( void ){}; -__weak void HW_IPCC_BLE_RxEvtNot( void ){}; +__WEAK void HW_IPCC_BLE_AclDataAckNot( void ){}; +__WEAK void HW_IPCC_BLE_RxEvtNot( void ){}; /****************************************************************************** * SYSTEM @@ -303,56 +262,8 @@ static void HW_IPCC_SYS_EvtHandler( void ) return; } -__weak void HW_IPCC_SYS_CmdEvtNot( void ){}; -__weak void HW_IPCC_SYS_EvtNot( void ){}; - -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -#ifdef MAC_802_15_4_WB -void HW_IPCC_MAC_802_15_4_Init( void ) -{ - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -void HW_IPCC_MAC_802_15_4_SendCmd( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - - return; -} - -void HW_IPCC_MAC_802_15_4_SendAck( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ) -{ - LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - - HW_IPCC_MAC_802_15_4_CmdEvtNot(); - - return; -} - -static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - HW_IPCC_MAC_802_15_4_EvtNot(); - - return; -} -__weak void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ){}; -__weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){}; -#endif +__WEAK void HW_IPCC_SYS_CmdEvtNot( void ){}; +__WEAK void HW_IPCC_SYS_EvtNot( void ){}; /****************************************************************************** * THREAD @@ -424,9 +335,9 @@ static void HW_IPCC_THREAD_CliNotEvtHandler( void ) return; } -__weak void HW_IPCC_OT_CmdEvtNot( void ){}; -__weak void HW_IPCC_CLI_CmdEvtNot( void ){}; -__weak void HW_IPCC_THREAD_EvtNot( void ){}; +__WEAK void HW_IPCC_OT_CmdEvtNot( void ){}; +__WEAK void HW_IPCC_CLI_CmdEvtNot( void ){}; +__WEAK void HW_IPCC_THREAD_EvtNot( void ){}; #endif /* THREAD_WB */ @@ -548,74 +459,6 @@ void HW_IPCC_LLD_BLE_SendRspAck( void ) #endif /* LLD_BLE_WB */ -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -#ifdef ZIGBEE_WB -void HW_IPCC_ZIGBEE_Init( void ) -{ - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - - return; -} - -void HW_IPCC_ZIGBEE_SendM4RequestToM0( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); - LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); - - return; -} - -void HW_IPCC_ZIGBEE_SendM4AckToM0Notify( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - - return; -} - -static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ) -{ - LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); - - HW_IPCC_ZIGBEE_RecvAppliAckFromM0(); - - return; -} - -static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - - HW_IPCC_ZIGBEE_RecvM0NotifyToM4(); - - return; -} - -static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - - HW_IPCC_ZIGBEE_RecvM0RequestToM4(); - - return; -} - -void HW_IPCC_ZIGBEE_SendM4AckToM0Request( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - - return; -} - -__weak void HW_IPCC_ZIGBEE_RecvAppliAckFromM0( void ){}; -__weak void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ){}; -__weak void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ){}; -#endif /* ZIGBEE_WB */ - /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -666,4 +509,5 @@ static void HW_IPCC_TRACES_EvtHandler( void ) return; } -__weak void HW_IPCC_TRACES_EvtNot( void ){}; +__WEAK void HW_IPCC_TRACES_EvtNot( void ){}; +#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h index 68b71f9c..0c974f8f 100644 --- a/src/utility/STM32Cube_FW/mbox_def.h +++ b/src/utility/STM32Cube_FW/mbox_def.h @@ -106,12 +106,6 @@ extern "C" { uint8_t *m0cmd_buffer; } MB_BleLldTable_t; - typedef struct - { - uint8_t *notifM0toM4_buffer; - uint8_t *appliCmdM4toM0_buffer; - uint8_t *requestM0toM4_buffer; - } MB_ZigbeeTable_t; /** * msg * [0:7] = cmd/evt @@ -139,13 +133,6 @@ extern "C" { uint8_t *traces_queue; } MB_TracesTable_t; - typedef struct - { - uint8_t *p_cmdrsp_buffer; - uint8_t *p_notack_buffer; - uint8_t *evt_queue; - } MB_Mac_802_15_4_t; - typedef struct { MB_DeviceInfoTable_t *p_device_info_table; @@ -154,8 +141,6 @@ extern "C" { MB_SysTable_t *p_sys_table; MB_MemManagerTable_t *p_mem_manager_table; MB_TracesTable_t *p_traces_table; - MB_Mac_802_15_4_t *p_mac_802_15_4_table; - MB_ZigbeeTable_t *p_zigbee_table; MB_LldTestsTable_t *p_lld_tests_table; MB_BleLldTable_t *p_ble_lld_table; } MB_RefTable_t; @@ -199,15 +184,6 @@ typedef struct * | | * |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------| * | | - * | (ZIGBEE) | - * |----HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL------------>| - * | | - * |----HW_IPCC_ZIGBEE_CMD_CLI_CHANNEL-------------->| - * | | - * |<---HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL-------| - * | | - * |<---HW_IPCC_ZIGBEE_CLI_NOTIF_ACK_CHANNEL---------| - * | | * | (THREAD) | * |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->| * | | @@ -231,11 +207,6 @@ typedef struct * | | * |<---HW_IPCC_BLE_LLD_M0_CMD_CHANNEL---------------| * | | - * | (MAC) | - * |----HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL-------->| - * | | - * |<---HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL| - * | | * | (BUFFER) | * |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>| * | | @@ -253,8 +224,6 @@ typedef struct #define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4 #define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 @@ -266,8 +235,6 @@ typedef struct #define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_BLE_LLD_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4 @@ -275,6 +242,5 @@ typedef struct #define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_BLE_LLD_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_BLE_LLD_RSP_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL LL_IPCC_CHANNEL_5 #endif /*__MBOX_H */ diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c index 472a108e..a8475222 100644 --- a/src/utility/STM32Cube_FW/shci.c +++ b/src/utility/STM32Cube_FW/shci.c @@ -16,7 +16,7 @@ ****************************************************************************** */ - +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -352,24 +352,6 @@ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ) return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t * p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send( SHCI_OPCODE_C2_ZIGBEE_INIT, - 0, - 0, - p_rsp ); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); -} - SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ) { /** @@ -527,24 +509,6 @@ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t Fla return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t * p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send( SHCI_OPCODE_C2_MAC_802_15_4_INIT, - 0, - 0, - p_rsp ); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); -} - SHCI_CmdStatus_t SHCI_C2_Reinit( void ) { /** @@ -739,4 +703,4 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } - +#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h index 102089e2..6b6ffd1a 100644 --- a/src/utility/STM32Cube_FW/shci.h +++ b/src/utility/STM32Cube_FW/shci.h @@ -49,7 +49,6 @@ extern "C" { ERR_BLE_INIT = 0, /* This event is currently not reported by the CPU2 */ ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the CPU1 to control the Thread stack is unknown */ - ERR_ZIGBEE_UNKNOWN_CMD = 200, /* The command send by the CPU1 to control the Zigbee stack is unknown */ } SCHI_SystemErrCode_t; #define SHCI_EVTCODE ( 0xFF ) @@ -102,7 +101,7 @@ extern "C" { /** * SHCI_SUB_EVT_THREAD_NVM_RAM_UPDATE - * This notifies the CPU1 which part of the OT NVM RAM has been updated so that only the modified + * This notifies the CPU1 which part of the 'OT NVM RAM' has been updated so that only the modified * section could be written in Flash/NVM * StartAddress : Start address of the section that has been modified * Size : Size (in bytes) of the section that has been modified @@ -216,9 +215,7 @@ extern "C" { SHCI_OCF_C2_FLASH_STORE_DATA, SHCI_OCF_C2_FLASH_ERASE_DATA, SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, - SHCI_OCF_C2_MAC_802_15_4_INIT, SHCI_OCF_C2_REINIT, - SHCI_OCF_C2_ZIGBEE_INIT, SHCI_OCF_C2_LLD_TESTS_INIT, SHCI_OCF_C2_EXTPA_CONFIG, SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, @@ -648,8 +645,6 @@ extern "C" { { uint8_t thread_config; uint8_t ble_config; - uint8_t mac_802_15_4_config; - uint8_t zigbee_config; } SHCI_C2_DEBUG_TracesConfig_t; typedef PACKED_STRUCT @@ -713,8 +708,6 @@ extern "C" { { BLE_ENABLE, THREAD_ENABLE, - ZIGBEE_ENABLE, - MAC_ENABLE, } SHCI_C2_CONCURRENT_Mode_Param_t; /** No response parameters*/ @@ -737,18 +730,13 @@ extern "C" { { BLE_IP, THREAD_IP, - ZIGBEE_IP, } SHCI_C2_FLASH_Ip_t; /** No response parameters*/ #define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) -#define SHCI_OPCODE_C2_MAC_802_15_4_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_MAC_802_15_4_INIT) - #define SHCI_OPCODE_C2_REINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_REINIT) -#define SHCI_OPCODE_C2_ZIGBEE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_ZIGBEE_INIT) - #define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) #define SHCI_OPCODE_C2_BLE_LLD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_LLD_INIT) @@ -856,7 +844,7 @@ extern "C" { #define FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD (0xA94656B9) /* - * At startup, the informations relative to the wireless binary are stored in RAM trough a structure defined by + * At startup, the information relative to the wireless binary are stored in RAM through a structure defined by * MB_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) * each of those coded on 32 bits as shown on the table below: * @@ -912,9 +900,6 @@ extern "C" { #define INFO_STACK_TYPE_BLE_HCI_EXT_ADV 0x07 #define INFO_STACK_TYPE_THREAD_FTD 0x10 #define INFO_STACK_TYPE_THREAD_MTD 0x11 -#define INFO_STACK_TYPE_ZIGBEE_FFD 0x30 -#define INFO_STACK_TYPE_ZIGBEE_RFD 0x31 -#define INFO_STACK_TYPE_MAC 0x40 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 #define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 #define INFO_STACK_TYPE_802154_LLD_TESTS 0x60 @@ -923,12 +908,7 @@ extern "C" { #define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 #define INFO_STACK_TYPE_BLE_RLV 0x64 #define INFO_STACK_TYPE_802154_RLV 0x65 -#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_STATIC 0x70 -#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_STATIC 0x71 -#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_DYNAMIC 0x78 -#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_DYNAMIC 0x79 #define INFO_STACK_TYPE_RLV 0x80 -#define INFO_STACK_TYPE_BLE_MAC_STATIC 0x90 typedef struct { /** @@ -1102,7 +1082,7 @@ typedef struct { * @brief Starts the LLD tests CLI * * @param param_size : Nb of bytes - * @param p_param : pointeur with data to give from M4 to M0 + * @param p_param : pointer with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ); @@ -1112,19 +1092,10 @@ typedef struct { * @brief Starts the LLD tests BLE * * @param param_size : Nb of bytes - * @param p_param : pointeur with data to give from M4 to M0 + * @param p_param : pointer with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ); - - /** - * SHCI_C2_ZIGBEE_Init - * @brief Starts the Zigbee Stack - * - * @param None - * @retval Status - */ - SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ); /** * SHCI_C2_DEBUG_Init @@ -1200,16 +1171,6 @@ typedef struct { */ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn); - - /** - * SHCI_C2_MAC_802_15_4_Init - * @brief Starts the MAC 802.15.4 on M0 - * - * @param None - * @retval Status - */ - SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ); - /** * SHCI_GetWirelessFwInfo * @brief This function read back the informations relative to the wireless binary loaded. diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index ddb3a02b..d1a448d5 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -16,12 +16,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 +169,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 ) { @@ -252,4 +267,4 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } - +#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h index b47b804a..5a2b2a55 100644 --- a/src/utility/STM32Cube_FW/stm32_wpan_common.h +++ b/src/utility/STM32Cube_FW/stm32_wpan_common.h @@ -25,19 +25,9 @@ extern "C" { #endif -#if defined ( __CC_ARM ) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline -#endif +#define __ASM __asm /*!< asm keyword for GNU Compiler */ +#define __INLINE inline /*!< inline keyword for GNU Compiler */ +#define __STATIC_INLINE static inline #include #include @@ -140,29 +130,8 @@ extern "C" { /* ----------------------------------- * * Packed usage (compiler dependent) * * ----------------------------------- */ -#undef PACKED__ #undef PACKED_STRUCT - -#if defined ( __CC_ARM ) - #if defined ( __GNUC__ ) - /* GNU extension */ - #define PACKED__ __attribute__((packed)) - #define PACKED_STRUCT struct PACKED__ - #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050U) - #define PACKED__ __attribute__((packed)) - #define PACKED_STRUCT struct PACKED__ - #else - #define PACKED__(TYPE) __packed TYPE - #define PACKED_STRUCT PACKED__(struct) - #endif -#elif defined ( __GNUC__ ) - #define PACKED__ __attribute__((packed)) - #define PACKED_STRUCT struct PACKED__ -#elif defined (__ICCARM__) - #define PACKED_STRUCT __packed struct -#else - #define PACKED_STRUCT __packed struct -#endif +#define PACKED_STRUCT struct __packed #ifdef __cplusplus } diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c index 4c928647..77dec64f 100644 --- a/src/utility/STM32Cube_FW/stm_list.c +++ b/src/utility/STM32Cube_FW/stm_list.c @@ -16,13 +16,13 @@ ****************************************************************************** */ - +#if defined(STM32WBxx) /****************************************************************************** * Include Files ******************************************************************************/ -#include "utilities_common.h" - #include "stm_list.h" +#include "cmsis_gcc.h" +#include "stm32_wpan_common.h" /****************************************************************************** * Function Definitions @@ -33,10 +33,10 @@ void LST_init_head (tListNode * listHead) listHead->prev = listHead; } -uint8_t LST_is_empty (tListNode * listHead) +bool LST_is_empty (tListNode * listHead) { uint32_t primask_bit; - uint8_t return_value; + bool return_value; primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ @@ -204,3 +204,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/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h index b7c3254c..769c2113 100644 --- a/src/utility/STM32Cube_FW/stm_list.h +++ b/src/utility/STM32Cube_FW/stm_list.h @@ -21,6 +21,8 @@ #define _STM_LIST_H_ /* Includes ------------------------------------------------------------------*/ +#include "stdint.h" +#include "stdbool.h" #include "stm32_wpan_common.h" typedef PACKED_STRUCT _tListNode { @@ -30,7 +32,7 @@ typedef PACKED_STRUCT _tListNode { void LST_init_head (tListNode * listHead); -uint8_t LST_is_empty (tListNode * listHead); +bool LST_is_empty (tListNode * listHead); void LST_insert_head (tListNode * listHead, tListNode * node); diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h index 2124d260..678769cb 100644 --- a/src/utility/STM32Cube_FW/tl.h +++ b/src/utility/STM32Cube_FW/tl.h @@ -199,19 +199,6 @@ typedef struct uint8_t *p_BleLldM0CmdBuffer; } TL_BLE_LLD_Config_t; -typedef struct -{ - uint8_t *p_Mac_802_15_4_CmdRspBuffer; - uint8_t *p_Mac_802_15_4_NotAckBuffer; -} TL_MAC_802_15_4_Config_t; - -typedef struct -{ - uint8_t *p_ZigbeeOtCmdRspBuffer; - uint8_t *p_ZigbeeNotAckBuffer; - uint8_t *p_ZigbeeNotifRequestBuffer; -} TL_ZIGBEE_Config_t; - /** * @brief Contain the BLE HCI Init Configuration * @{ @@ -305,26 +292,6 @@ void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); void TL_TRACES_Init( void ); void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ); -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ); -void TL_MAC_802_15_4_SendCmd( void ); -void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); -void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ); -void TL_MAC_802_15_4_SendAck ( void ); - -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ); -void TL_ZIGBEE_SendM4RequestToM0( void ); -void TL_ZIGBEE_SendM4AckToM0Notify ( void ); -void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ); -void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); -void TL_ZIGBEE_M0RequestReceived(TL_EvtPacket_t * Otbuffer ); -void TL_ZIGBEE_SendM4AckToM0Request(void); - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c index 4112429d..a9abb181 100644 --- a/src/utility/STM32Cube_FW/tl_mbox.c +++ b/src/utility/STM32Cube_FW/tl_mbox.c @@ -16,6 +16,7 @@ ****************************************************************************** */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -51,15 +52,13 @@ 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; -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; /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue; PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)]; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode EvtQueue; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode SystemEvtQueue; +PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode EvtQueue; +PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode SystemEvtQueue; static tListNode LocalFreeBufQueue; @@ -97,8 +96,6 @@ 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; - TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; - TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; HW_IPCC_Init(); return; @@ -452,139 +449,6 @@ void TL_BLE_LLD_SendRspAck( void ) } #endif /* BLE_LLD_WB */ -#ifdef MAC_802_15_4_WB -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ) -{ - MB_Mac_802_15_4_t * p_mac_802_15_4_table; - - p_mac_802_15_4_table = TL_RefTable.p_mac_802_15_4_table; - - p_mac_802_15_4_table->p_cmdrsp_buffer = p_Config->p_Mac_802_15_4_CmdRspBuffer; - p_mac_802_15_4_table->p_notack_buffer = p_Config->p_Mac_802_15_4_NotAckBuffer; - - HW_IPCC_MAC_802_15_4_Init(); - - return; -} - -void TL_MAC_802_15_4_SendCmd( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; - - HW_IPCC_MAC_802_15_4_SendCmd(); - - return; -} - -void TL_MAC_802_15_4_SendAck ( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_MAC_802_15_4_SendAck(); - - return; -} - -void HW_IPCC_MAC_802_15_4_CmdEvtNot(void) -{ - TL_MAC_802_15_4_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer) ); - - return; -} - -void HW_IPCC_MAC_802_15_4_EvtNot( void ) -{ - TL_MAC_802_15_4_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer) ); - - return; -} - -__WEAK void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; -__WEAK void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){}; -#endif - -#ifdef ZIGBEE_WB -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ) -{ - MB_ZigbeeTable_t * p_zigbee_table; - - p_zigbee_table = TL_RefTable.p_zigbee_table; - p_zigbee_table->appliCmdM4toM0_buffer = p_Config->p_ZigbeeOtCmdRspBuffer; - p_zigbee_table->notifM0toM4_buffer = p_Config->p_ZigbeeNotAckBuffer; - p_zigbee_table->requestM0toM4_buffer = p_Config->p_ZigbeeNotifRequestBuffer; - - HW_IPCC_ZIGBEE_Init(); - - return; -} - -/* Zigbee M4 to M0 Request */ -void TL_ZIGBEE_SendM4RequestToM0( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendM4RequestToM0(); - - return; -} - -/* Used to receive an ACK from the M0 */ -void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void) -{ - TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) ); - - return; -} - -/* Zigbee notification from M0 to M4 */ -void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ) -{ - TL_ZIGBEE_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer) ); - - return; -} - -/* Send an ACK to the M0 for a Notification */ -void TL_ZIGBEE_SendM4AckToM0Notify ( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendM4AckToM0Notify(); - - return; -} - -/* Zigbee M0 to M4 Request */ -void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ) -{ - TL_ZIGBEE_M0RequestReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer) ); - - return; -} - -/* Send an ACK to the M0 for a Request */ -void TL_ZIGBEE_SendM4AckToM0Request(void) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendM4AckToM0Request(); - - return; -} - - -__WEAK void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; -__WEAK void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){}; -#endif - - - /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -846,4 +710,4 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } - +#endif /* STM32WBxx */ From 882addad6a096adf402041d662f4edb941b80071 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Tue, 30 Aug 2022 13:19:36 +0200 Subject: [PATCH 32/58] fix: include a timeout when waiting for the cmd_resp Signed-off-by: Alexandre Bourdiol --- src/utility/STM32Cube_FW/shci_tl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index d1a448d5..678de84d 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -20,6 +20,8 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" +#include + #include "stm_list.h" #include "shci_tl.h" #include "stm32_def.h" @@ -250,11 +252,12 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { - (void)timeout; - CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; - 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 4eb33a136d8f59874fa112df868f8b025d128c83 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Tue, 30 Aug 2022 13:31:31 +0200 Subject: [PATCH 33/58] Added support for custom app_conf.h Signed-off-by: Alexandre Bourdiol --- src/utility/STM32Cube_FW/app_conf_default.h | 71 ++++++++++++++------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h index 54f824ae..91672ac9 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -1,8 +1,8 @@ /** ****************************************************************************** - * @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 * @@ -17,11 +17,8 @@ */ /* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef APP_CONF_H -#define APP_CONF_H - -#include "hw.h" -#include "ble_bufsize.h" +#ifndef APP_CONF_DEFAULT_H +#define APP_CONF_DEFAULT_H /****************************************************************************** * Application Config @@ -44,7 +41,9 @@ /** * Define Tx Power */ -#define CFG_TX_POWER (0x18) /* -0.15dBm */ +#ifndef CFG_TX_POWER + #define CFG_TX_POWER (0x18) /* -0.15dBm */ +#endif /****************************************************************************** * BLE Stack @@ -53,13 +52,17 @@ * 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 + #define CFG_BLE_NUM_LINK 8 +#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 + #define CFG_BLE_NUM_GATT_SERVICES 8 +#endif /** * Maximum number of Attributes @@ -68,13 +71,17 @@ * 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 + #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#endif /** * Maximum supported ATT_MTU size * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#define CFG_BLE_MAX_ATT_MTU (156) +#ifndef CFG_BLE_MAX_ATT_MTU + #define CFG_BLE_MAX_ATT_MTU (156) +#endif /** * Size of the storage area for Attribute values @@ -87,14 +94,18 @@ * The total amount of memory needed is the sum of the above quantities for each attribute. * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) +#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE + #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) +#endif /** * Prepare Write List size in terms of number of packet * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ // #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) +#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE + #define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) +#endif /** * Number of allocated memory blocks @@ -106,12 +117,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 Slave mode (ppm value) */ -#define CFG_BLE_SLAVE_SCA 500 +#ifndef CFG_BLE_SLAVE_SCA + #define CFG_BLE_SLAVE_SCA 500 +#endif /** * Sleep clock accuracy in Master mode @@ -124,7 +139,9 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#define CFG_BLE_MASTER_SCA 0 +#ifndef CFG_BLE_MASTER_SCA + #define CFG_BLE_MASTER_SCA 0 +#endif /** * LsSource @@ -132,21 +149,27 @@ * - bit 0: 1: Calibration for the RF system wakeup clock source 0: No calibration for the RF system wakeup clock source * - bit 1: 1: STM32W5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module */ -#if defined(STM32WB5Mxx) - #define CFG_BLE_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_MOD5MM_DEV) -#else - #define CFG_BLE_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_OTHER_DEV) +#ifndef CFG_BLE_LSE_SOURCE + #if defined(STM32WB5Mxx) + #define CFG_BLE_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_MOD5MM_DEV) + #else + #define CFG_BLE_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_OTHER_DEV) + #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 Slave 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 @@ -234,5 +257,5 @@ #define CFG_BLE_RX_PATH_COMPENS (0) -#endif /*APP_CONF_H */ +#endif /* APP_CONF_DEFAULT_H */ From 3f234253695437855f6e5a2fc9b5e884f33ee749 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Wed, 31 Aug 2022 17:18:16 +0200 Subject: [PATCH 34/58] Fix: Remove compilation warning about uninitialized struct field Signed-off-by: Alexandre Bourdiol --- src/utility/HCISharedMemTransport.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utility/HCISharedMemTransport.cpp b/src/utility/HCISharedMemTransport.cpp index c8de8c56..2a70c905 100644 --- a/src/utility/HCISharedMemTransport.cpp +++ b/src/utility/HCISharedMemTransport.cpp @@ -740,7 +740,12 @@ int HCISharedMemTransportClass::stm32wb_start_ble(void) CFG_BLE_MAX_COC_INITIATOR_NBR, CFG_BLE_MIN_TX_POWER, CFG_BLE_MAX_TX_POWER, - CFG_BLE_RX_MODEL_CONFIG + CFG_BLE_RX_MODEL_CONFIG, + CFG_BLE_MAX_ADV_SET_NBR, + CFG_BLE_MAX_ADV_DATA_LEN, + CFG_BLE_TX_PATH_COMPENS, + CFG_BLE_RX_PATH_COMPENS + }; /** * Starts the BLE Stack on CPU2 From f77db6b5fc4400c89b54abcb498822a2bf619ea2 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Fri, 2 Sep 2022 14:59:07 +0200 Subject: [PATCH 35/58] Fix: Move EvtPool array from MB_MEM2 to MB_MEM1 MB_MEM1 and MB_MEM2 ae now respectively in SRAM2a and SRAM2b SRAM2a being too small to put all shared memory variables Warning depends on split made on core: variants/STM32WBxx/WB55R(C-E-G)V/ldscript.ld Signed-off-by: Alexandre Bourdiol --- src/utility/HCISharedMemTransport.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/HCISharedMemTransport.cpp b/src/utility/HCISharedMemTransport.cpp index 2a70c905..0b46bda4 100644 --- a/src/utility/HCISharedMemTransport.cpp +++ b/src/utility/HCISharedMemTransport.cpp @@ -25,7 +25,7 @@ /* Private variables ---------------------------------------------------------*/ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static TL_CmdPacket_t BleCmdBuffer; -PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t EvtPool[POOL_SIZE]; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static uint8_t EvtPool[POOL_SIZE]; PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static TL_CmdPacket_t SystemCmdBuffer; PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t SystemSpareEvtBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + 255]; From f4c26072f6fa09225d3c7ae0ece8dbfc94b3c9d5 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Tue, 30 Aug 2022 13:32:30 +0200 Subject: [PATCH 36/58] fix: implement BLE debug based on core_debug() Signed-off-by: Alexandre Bourdiol --- src/utility/STM32Cube_FW/tl_dbg_conf.h | 140 +++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 src/utility/STM32Cube_FW/tl_dbg_conf.h diff --git a/src/utility/STM32Cube_FW/tl_dbg_conf.h b/src/utility/STM32Cube_FW/tl_dbg_conf.h new file mode 100644 index 00000000..841d1968 --- /dev/null +++ b/src/utility/STM32Cube_FW/tl_dbg_conf.h @@ -0,0 +1,140 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * File Name : tl_dbg_conf.h + * Description : Debug configuration file for stm32wpan transport layer interface. + * + ****************************************************************************** + * @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 TL_DBG_CONF_H +#define TL_DBG_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* USER CODE BEGIN Tl_Conf */ + +/* Includes ------------------------------------------------------------------*/ +#include "core_debug.h" + +/** + * Enable or Disable traces + * The raw data output is the hci binary packet format as specified by the BT specification * + */ +#ifndef TL_SHCI_CMD_DBG_EN +#define TL_SHCI_CMD_DBG_EN 1 /* Reports System commands sent to CPU2 and the command response */ +#endif + +#ifndef TL_SHCI_EVT_DBG_EN +#define TL_SHCI_EVT_DBG_EN 1 /* Reports System Asynchronous Events received from CPU2 */ +#endif + +#ifndef TL_HCI_CMD_DBG_EN +#define TL_HCI_CMD_DBG_EN 1 /* Reports BLE command sent to CPU2 and the command response */ +#endif + +#ifndef TL_HCI_EVT_DBG_EN +#define TL_HCI_EVT_DBG_EN 1 /* Reports BLE Asynchronous Events received from CPU2 */ +#endif + +#ifndef TL_MM_DBG_EN +#define TL_MM_DBG_EN 1 /* Reports the information of the buffer released to CPU2 */ +#endif + +/** + * Macro definition + */ + +/** + * System Transport Layer + */ +#if (TL_SHCI_CMD_DBG_EN != 0) +#define TL_SHCI_CMD_DBG_MSG core_debug +#define TL_SHCI_CMD_DBG_BUF PRINT_LOG_BUFF_DBG +#else +#define TL_SHCI_CMD_DBG_MSG(...) +#define TL_SHCI_CMD_DBG_BUF(...) +#endif + +#define TL_SHCI_CMD_DBG_RAW(...) + +#if (TL_SHCI_EVT_DBG_EN != 0) +#define TL_SHCI_EVT_DBG_MSG core_debug +#define TL_SHCI_EVT_DBG_BUF PRINT_LOG_BUFF_DBG +#else +#define TL_SHCI_EVT_DBG_MSG(...) +#define TL_SHCI_EVT_DBG_BUF(...) +#endif + +#define TL_SHCI_EVT_DBG_RAW(...) + +/** + * BLE Transport Layer + */ +#if (TL_HCI_CMD_DBG_EN != 0) +#define TL_HCI_CMD_DBG_MSG core_debug +#define TL_HCI_CMD_DBG_BUF PRINT_LOG_BUFF_DBG +#else +#define TL_HCI_CMD_DBG_MSG(...) +#define TL_HCI_CMD_DBG_BUF(...) +#endif + +#define TL_HCI_CMD_DBG_RAW(...) + +#if (TL_HCI_EVT_DBG_EN != 0) +#define TL_HCI_EVT_DBG_MSG core_debug +#define TL_HCI_EVT_DBG_BUF PRINT_LOG_BUFF_DBG +#else +#define TL_HCI_EVT_DBG_MSG(...) +#define TL_HCI_EVT_DBG_BUF(...) +#endif + +#define TL_HCI_EVT_DBG_RAW(...) + +/** + * Memory Manager - Released buffer tracing + */ +#if (TL_MM_DBG_EN != 0) +#define TL_MM_DBG_MSG core_debug +#else +#define TL_MM_DBG_MSG(...) +#endif + + +#define PRINT_LOG_BUFF_DBG(...) DbgTraceBuffer(__VA_ARGS__) + +void DbgTraceBuffer(const void *pBuffer, uint32_t u32Length, const char *strFormat, ...) +{ + va_list vaArgs; + uint32_t u32Index; + va_start(vaArgs, strFormat); + vprintf(strFormat, vaArgs); + va_end(vaArgs); + for (u32Index = 0; u32Index < u32Length; u32Index ++) + { + core_debug(" %02X", ((const uint8_t *) pBuffer)[u32Index]); + } +} + +/* USER CODE END Tl_Conf */ + +#ifdef __cplusplus +} +#endif + +#endif /* TL_DBG_CONF_H */ + From 1c8974d88f88d764e3b2aa9d045bcd61f0e0a4c5 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Mon, 24 Oct 2022 11:35:21 +0200 Subject: [PATCH 37/58] fix: HCI only Firmware not supporting ACI_GAP_INIT ACI_GATT_INIT On STM32WB, Cube FW version 1.14.1, messages ACI_GATT_INIT and ACI_GAP_INIT are not available on HCI only BLE firmware (stm32wb5x_BLE_HCILayer_fw.bin) This imply to move Random Address to host instead of relying on controller Signed-off-by: Alexandre Bourdiol --- src/local/BLELocalDevice.cpp | 12 ++ src/utility/HCI.cpp | 12 ++ src/utility/HCI.h | 1 + src/utility/HCISharedMemTransport.cpp | 214 +------------------------- src/utility/HCISharedMemTransport.h | 5 - 5 files changed, 33 insertions(+), 211 deletions(-) diff --git a/src/local/BLELocalDevice.cpp b/src/local/BLELocalDevice.cpp index d4824f53..36152065 100644 --- a/src/local/BLELocalDevice.cpp +++ b/src/local/BLELocalDevice.cpp @@ -51,6 +51,18 @@ int BLELocalDevice::begin() return 0; } + uint8_t randomNumber[8]; + if (HCI.leRand(randomNumber) != 0) { + end(); + return 0; + } + + randomNumber[5] |= 0xC0; // Force both MSB bit to b00 in order to define Random Address + if (HCI.leSetRandomAddress((uint8_t*)randomNumber) != 0) { + end(); + return 0; + } + uint8_t hciVer; uint16_t hciRev; uint8_t lmpVer; diff --git a/src/utility/HCI.cpp b/src/utility/HCI.cpp index 96b42537..f9c7d9c1 100644 --- a/src/utility/HCI.cpp +++ b/src/utility/HCI.cpp @@ -68,6 +68,7 @@ #define OCF_LE_CREATE_CONN 0x000d #define OCF_LE_CANCEL_CONN 0x000e #define OCF_LE_CONN_UPDATE 0x0013 +#define OCF_LE_RAND 0x0018 #define HCI_OE_USER_ENDED_CONNECTION 0x13 @@ -392,6 +393,17 @@ int HCIClass::leConnUpdate(uint16_t handle, uint16_t minInterval, uint16_t maxIn return sendCommand(OGF_LE_CTL << 10 | OCF_LE_CONN_UPDATE, sizeof(leConnUpdateData), &leConnUpdateData); } +int HCIClass::leRand(uint8_t randomNumber[8]) +{ + int result = sendCommand(OGF_LE_CTL << 10 | OCF_LE_RAND); + + if (result == 0) { + memcpy(randomNumber, _cmdResponse, 8); + } + + return result; +} + int HCIClass::sendAclPkt(uint16_t handle, uint8_t cid, uint8_t plen, void* data) { while (_pendingPkt >= _maxPkt) { diff --git a/src/utility/HCI.h b/src/utility/HCI.h index 0efd8125..b4a40e63 100644 --- a/src/utility/HCI.h +++ b/src/utility/HCI.h @@ -63,6 +63,7 @@ class HCIClass { virtual int leConnUpdate(uint16_t handle, uint16_t minInterval, uint16_t maxInterval, uint16_t latency, uint16_t supervisionTimeout); virtual int leCancelConn(); + virtual int leRand(uint8_t randomNumber[8]); virtual int sendAclPkt(uint16_t handle, uint8_t cid, uint8_t plen, void* data); diff --git a/src/utility/HCISharedMemTransport.cpp b/src/utility/HCISharedMemTransport.cpp index 0b46bda4..e8c422c9 100644 --- a/src/utility/HCISharedMemTransport.cpp +++ b/src/utility/HCISharedMemTransport.cpp @@ -48,17 +48,12 @@ volatile uint16_t _write_index; /* fifo position when receiving */ /* var of different device steps during init and receiving */ volatile bool phase_bd_addr; volatile bool phase_tx_power; -volatile bool phase_gatt_init; -volatile bool phase_gap_init; -volatile bool phase_random_addr; -volatile bool phase_get_random_addr; volatile bool phase_reset; volatile bool phase_running; -volatile bool is_random_addr_msg; + /** Bluetooth Device Address */ static uint8_t bd_addr_udn[CONFIG_DATA_PUBADDR_LEN]; -static uint8_t helper_random_addr[6]; /* Private functions ---------------------------------------------------------*/ /** @@ -186,16 +181,10 @@ void evt_received(TL_EvtPacket_t *hcievt) (hcievt->evtserial.evt.payload[0] == 0x01) && (hcievt->evtserial.evt.payload[1] == 0x0C) && (hcievt->evtserial.evt.payload[2] == 0xFC)) { - /* First setting must be global address and is_random_addr_msg should be false - * Second setting must be static random address and is_random_addr_msg should be true + /* First setting must be global address */ - if(!is_random_addr_msg) { - phase_bd_addr = true; - is_random_addr_msg = true; - } else { - phase_random_addr = true; - is_random_addr_msg = false; - } + phase_bd_addr = true; + if (hcievt->evtserial.evt.payload[3] != 0) { #if defined(PRINT_IPCC_INFO) printf("Error: wrong BD Addr\r\n"); @@ -218,50 +207,7 @@ void evt_received(TL_EvtPacket_t *hcievt) /* rx data is no more useful : not stored in the _rxbuff */ break; } - /* check the Rx event of complete the previous gatt init 0xFD01 */ - if ((hcievt->evtserial.evt.evtcode == TL_BLEEVT_CC_OPCODE) && - (hcievt->evtserial.evt.payload[0] == 0x01) && - (hcievt->evtserial.evt.payload[1] == 0x01) && - (hcievt->evtserial.evt.payload[2] == 0xFD)) { - phase_gatt_init = true; - if (hcievt->evtserial.evt.payload[3] != 0) { -#if defined(PRINT_IPCC_INFO) - printf("Error: wrong Random Addr\r\n"); -#endif /*(PRINT_IPCC_INFO)*/ - } - /* rx data is no more useful : not stored in the _rxbuff */ - break; - } - /* check the Rx event of complete the previous gap init 0xFC8A */ - if ((hcievt->evtserial.evt.evtcode == TL_BLEEVT_CC_OPCODE) && - (hcievt->evtserial.evt.payload[0] == 0x01) && - (hcievt->evtserial.evt.payload[1] == 0x8A) && - (hcievt->evtserial.evt.payload[2] == 0xFC)) { - phase_gap_init = true; - if (hcievt->evtserial.evt.payload[3] != 0) { -#if defined(PRINT_IPCC_INFO) - printf("Error: wrong Random Addr\r\n"); -#endif /*(PRINT_IPCC_INFO)*/ - } - /* rx data is no more useful : not stored in the _rxbuff */ - break; - } - /* check the Rx event of complete the previous get random addr opcode 0xFC0D */ - if ((hcievt->evtserial.evt.evtcode == TL_BLEEVT_CC_OPCODE) && - (hcievt->evtserial.evt.payload[0] == 0x01) && - (hcievt->evtserial.evt.payload[1] == 0x0D) && - (hcievt->evtserial.evt.payload[2] == 0xFC)) { - if (hcievt->evtserial.evt.payload[3] != 0) { -#if defined(PRINT_IPCC_INFO) - printf("Error: wrong Random Addr\r\n"); -#endif /*(PRINT_IPCC_INFO)*/ - } - memcpy(helper_random_addr, &hcievt->evtserial.evt.payload[5], 6); - phase_get_random_addr = true; - /* rx data is no more useful : not stored in the _rxbuff */ - break; - } /* check if the reset phase is in progress (opcode is 0x0C03) */ if ((hcievt->evtserial.evt.evtcode == TL_BLEEVT_CC_OPCODE) && (hcievt->evtserial.evt.payload[0] == 0x01) && @@ -391,10 +337,10 @@ static bool get_bd_address(uint8_t *bd_addr) bd_addr[0] = (uint8_t)(udn & 0x000000FF); bd_addr[1] = (uint8_t)((udn & 0x0000FF00) >> 8); - bd_addr[2] = (uint8_t)((udn & 0x00FF0000) >> 16); - bd_addr[3] = (uint8_t)device_id; - bd_addr[4] = (uint8_t)(company_id & 0x000000FF); - bd_addr[5] = (uint8_t)((company_id & 0x0000FF00) >> 8); + bd_addr[2] = (uint8_t)device_id; + bd_addr[3] = (uint8_t)(company_id & 0x000000FF); + bd_addr[4] = (uint8_t)((company_id & 0x0000FF00) >> 8); + bd_addr[5] = (uint8_t)((company_id & 0x00FF0000) >> 16); bd_found = true; } else { @@ -448,13 +394,8 @@ HCISharedMemTransportClass::HCISharedMemTransportClass() phase_bd_addr = false; phase_tx_power = false; - phase_gatt_init = false; - phase_gap_init = false; - phase_random_addr = false; - phase_get_random_addr = false; phase_reset = false; phase_running = false; - is_random_addr_msg = false; } HCISharedMemTransportClass::~HCISharedMemTransportClass() @@ -517,13 +458,8 @@ void HCISharedMemTransportClass::end() /* the HCI RESET command ready to be processed again */ phase_bd_addr = false; phase_tx_power = false; - phase_gatt_init = false; - phase_gap_init = false; - phase_random_addr = false; - phase_get_random_addr = false; phase_reset = false; phase_running = false; - is_random_addr_msg = false; } void HCISharedMemTransportClass::wait(unsigned long timeout) @@ -614,34 +550,11 @@ size_t HCISharedMemTransportClass::write(const uint8_t *data, size_t length) while (!phase_bd_addr); /* this sequence is now complete */ - /* set the random address */ - bt_ipm_set_random_addr(); - /* wait for the Rx complete */ - while (!phase_random_addr); - /* set the Tx power */ bt_ipm_set_power(); /* wait for the Rx complete */ while (!phase_tx_power); - /* gatt init */ - bt_ipm_gatt_init(); - /* wait for the Rx complete */ - while (!phase_gatt_init); - - /* gap init */ - bt_ipm_gap_init(); - /* wait for the Rx complete */ - while (!phase_gap_init); - - /* get the random address */ - bt_ipm_get_random_addr(); - /* wait for the Rx complete */ - while (!phase_get_random_addr); - - /* Now we can copy the random address and save it in the transport class */ - memcpy(_random_addr, helper_random_addr, 6); - /* this sequence is now complete */ phase_running = true; @@ -831,43 +744,6 @@ int HCISharedMemTransportClass::bt_ipm_set_addr(void) return 0; /* Error */ } -int HCISharedMemTransportClass::bt_ipm_set_random_addr(void) -{ - /* the specific table for set addr is 8 bytes: - * one byte for config_offset - * one byte for length - * 6 bytes for payload */ - uint8_t data[4 + 8]; - - /* - * Static random Address - * The two upper bits shall be set to 1 - * The lowest 32bits is read from the UDN to differentiate between devices - * The RNG may be used to provide a random number on each power on - */ - uint32_t srd_bd_addr[2]; - - phase_random_addr = false; - - srd_bd_addr[1] = 0x0000ED6E; - srd_bd_addr[0] = LL_FLASH_GetUDN( ); - - data[0] = BT_BUF_CMD; - data[1] = uint8_t(ACI_WRITE_CONFIG_DATA_OPCODE & 0x000000FF); /* OCF */ - data[2] = uint8_t((ACI_WRITE_CONFIG_DATA_OPCODE & 0x0000FF00) >> 8); /* OGF */ - data[3] = 8; /* length of parameters */ - /* fill the ACI_HAL_WRITE_CONFIG_DATA with the addr*/ - data[4] = 0x2E; /* the offset */ - data[5] = 6; /* is the length of the random address */ - memcpy(data + 6, srd_bd_addr, 6); - /* send the ACI_HAL_WRITE_CONFIG_DATA */ - if (mbox_write(data[0], 11, &data[1]) != 11) { - /* Error: no data are written */ - return 0; - } - /* now wait for the corresponding Rx event */ - return 1; /* success */ -} int HCISharedMemTransportClass::bt_ipm_set_power(void) { @@ -894,78 +770,4 @@ int HCISharedMemTransportClass::bt_ipm_set_power(void) return 1; /* success */ } -int HCISharedMemTransportClass::bt_ipm_gatt_init(void) -{ - /* the specific table for gatt init */ - uint8_t data[4]; - - phase_gatt_init = false; - - data[0] = BT_BUF_CMD; /* the type */ - data[1] = 0x01; /* the OPCODE */ - data[2] = 0xFD; - data[3] = 0; /* the length */ - - /* send the GATT_INIT */ - if (mbox_write(data[0], 3, &data[1]) != 3) { - /* Error: no data are written */ - return 0; - } - /* now wait for the corresponding Rx event */ - return 1; /* success */ -} - -int HCISharedMemTransportClass::bt_ipm_gap_init(void) -{ - /* the specific table for gap init is 3 bytes: - * Role byte, enable_privacy byte, device_name_char_len byte */ - uint8_t data[4 + 3]; - - phase_gap_init = false; - - data[0] = BT_BUF_CMD; /* the type */ - data[1] = 0x8A; /* the OPCODE */ - data[2] = 0xFC; - data[3] = 3; /* the length */ - /* fill the GAP_INIT */ - data[4] = 0x0F; /* role */ - data[5] = 0x00; /* enable_privacy */ - data[6] = 0x00; /* device_name_char_len */ - - /* send the GAP_INIT */ - if (mbox_write(data[0], 6, &data[1]) != 6) { - /* Error: no data are written */ - return 0; - } - /* now wait for the corresponding Rx event */ - return 1; /* success */ -} - -int HCISharedMemTransportClass::bt_ipm_get_random_addr(void) -{ - /* the specific table for set addr is 8 bytes: - * one byte for config_offset - * one byte for length - * 6 bytes for payload */ - uint8_t data[4 + 1]; - - phase_get_random_addr = false; - - /* create ACI_READ_CONFIG_DATA_OPCODE */ - data[0] = BT_BUF_CMD; - data[1] = uint8_t(ACI_READ_CONFIG_DATA_OPCODE & 0x000000FF); /* OCF */ - data[2] = uint8_t((ACI_READ_CONFIG_DATA_OPCODE & 0x0000FF00) >> 8); /* OGF */ - data[3] = 1; /* length of parameters */ - /* fill the ACI_READ_CONFIG_DATA_OPCODE with the offset*/ - data[4] = 0x2E; /* the offset */ - - /* send the ACI_READ_CONFIG_DATA_OPCODE */ - if (mbox_write(data[0], 4, &data[1]) != 4) { - /* Error: no data are written */ - return 0; - } - /* now wait for the corresponding Rx event */ - return 1; /* success */ -} - #endif /* STM32WBxx */ diff --git a/src/utility/HCISharedMemTransport.h b/src/utility/HCISharedMemTransport.h index 464a24f6..58fb871d 100644 --- a/src/utility/HCISharedMemTransport.h +++ b/src/utility/HCISharedMemTransport.h @@ -84,13 +84,8 @@ class HCISharedMemTransportClass : public HCITransportInterface { void start_ble_rf(void); void stm32wb_reset(void); int stm32wb_start_ble(void); - int bt_ipm_ble_init(void); int bt_ipm_set_addr(void); - int bt_ipm_set_random_addr(void); int bt_ipm_set_power(void); - int bt_ipm_gatt_init(void); - int bt_ipm_gap_init(void); - int bt_ipm_get_random_addr(void); uint8_t _random_addr[6]; }; From 8f40c2f3f68f301456ecad73c39287ff1a390d56 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Tue, 25 Oct 2022 18:28:48 +0200 Subject: [PATCH 38/58] fix: CI spell check Signed-off-by: Alexandre Bourdiol --- src/local/BLELocalDevice.cpp | 6 ++++-- src/utility/STM32Cube_FW/shci.h | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/local/BLELocalDevice.cpp b/src/local/BLELocalDevice.cpp index 36152065..b5869b5a 100644 --- a/src/local/BLELocalDevice.cpp +++ b/src/local/BLELocalDevice.cpp @@ -56,8 +56,10 @@ int BLELocalDevice::begin() end(); return 0; } - - randomNumber[5] |= 0xC0; // Force both MSB bit to b00 in order to define Random Address + /* Random address only requires 6 bytes (48 bits) + * Force both MSB bits to b00 in order to define Static Random Address + */ + randomNumber[5] |= 0xC0; if (HCI.leSetRandomAddress((uint8_t*)randomNumber) != 0) { end(); return 0; diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h index 6b6ffd1a..040baced 100644 --- a/src/utility/STM32Cube_FW/shci.h +++ b/src/utility/STM32Cube_FW/shci.h @@ -529,7 +529,7 @@ extern "C" { * - bit 2: 1: device name Read-Only 0: device name R/W * - bit 3: 1: extended advertizing supported 0: extended advertizing not supported * - bit 4: 1: CS Algo #2 supported 0: CS Algo #2 not supported - * - bit 7: 1: LE Power Class 1 0: LE Power Classe 2-3 + * - bit 7: 1: LE Power Class 1 0: LE Power Classes 2-3 * - other bits: reserved ( shall be set to 0) */ uint8_t Options; @@ -1173,7 +1173,7 @@ typedef struct { /** * SHCI_GetWirelessFwInfo - * @brief This function read back the informations relative to the wireless binary loaded. + * @brief This function read back the information relative to the wireless binary loaded. * Refer yourself to MB_WirelessFwInfoTable_t structure to get the significance * of the different parameters returned. * @param pWirelessInfo : Pointer to WirelessFwInfo_t. From 75ea6f44f51913ab7f6df5044d66545d4ddf5579 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 24 Nov 2022 10:01:39 +0100 Subject: [PATCH 39/58] ci: replace deprecated spellcheck by codespell --- .github/workflows/codespell.yml | 27 +++++++++++++++++++++++++++ .github/workflows/spell-check.yml | 17 ----------------- 2 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/codespell.yml delete mode 100644 .github/workflows/spell-check.yml diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 00000000..5ea11f42 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,27 @@ +name: codespell + +on: + push: + branches: + - main + pull_request: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@main + + # See: https://github.com/codespell-project/actions-codespell/blob/master/README.md + - name: Spell check + uses: codespell-project/actions-codespell@master + with: + check_filenames: true + check_hidden: true + # In the event of a false positive, add the word in all lower case to this file: + # ignore_words_file: ./extras/codespell-ignore-words-list.txt + path: src diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml deleted file mode 100644 index 6fded7ff..00000000 --- a/.github/workflows/spell-check.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Spell Check - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Spell check - uses: arduino/actions/libraries/spell-check@master - with: - skip-paths: ./extras/test,./extras/STM32Cube_FW - From 6ecff2be25fb83eeb6ee8acef35ee1af30d405f1 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Fri, 9 Dec 2022 17:28:57 +0100 Subject: [PATCH 40/58] fix: wrong release version Signed-off-by: Frederic Pillon --- src/utility/STM32Cube_FW/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utility/STM32Cube_FW/README.md b/src/utility/STM32Cube_FW/README.md index 2cd8302a..c9af001e 100644 --- a/src/utility/STM32Cube_FW/README.md +++ b/src/utility/STM32Cube_FW/README.md @@ -1,6 +1,6 @@ ## Source -[STMicroelectronics/STM32CubeWB Release 1.14.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/1.14.0) -- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/1.14.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) +[STMicroelectronics/STM32CubeWB Release v1.14.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.14.0) +- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.14.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) From ec0d56802bcea692eea78f98db08a2602d74ed07 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 13 Dec 2022 11:15:53 +0100 Subject: [PATCH 41/58] feat: adding gitattributes and editor config files Signed-off-by: Frederic Pillon --- .editorconfig | 17 +++++++++++++++++ .gitattributes | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..c9b76fd6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +[*.sh] +# like -i=2 +indent_style = space +indent_size = 2 + +#shell_variant = posix # like -ln=posix +#binary_next_line = true # like -bn +switch_case_indent = true # like -ci +space_redirects = true # like -sr +#keep_padding = true # like -kp diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..422ae6f5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,42 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files you want to always be normalized and converted +# to native line endings on checkout. +.editorconfig text eol=lf +.flake8 text eol=lf +.gitattributes text eol=lf +.gitignore text eol=lf + +*.adoc text eol=lf +*.c text eol=lf +*.cmake text eol=lf +*.cpp text eol=lf +*.css text eol=lf +*.dtsi text eol=lf +*.gv text eol=lf +*.h text eol=lf +*.html text eol=lf +*.in text eol=lf +*.ino text eol=lf +*.json text eol=lf +*.ld text eol=lf +*.md text eol=lf +*.MD text eol=lf +*.old text eol=lf +*.patch text eol=lf +*.pde text eol=lf +*.properties text eol=lf +*.py text eol=lf +*.s text eol=lf +*.S text eol=lf +*.sh text eol=lf +*.spec text eol=lf +*.txt text eol=lf +*.yml text eol=lf + +# Denote all files that are truly binary and should not be modified. +*.jpg binary +*.pdf binary +*.png binary + From 777b4a40f72e588000e609b79d24a78c7a7695ea Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 13 Dec 2022 15:20:56 +0100 Subject: [PATCH 42/58] fix: regenerate STM32Cube_FW patches Prepare update to version 1.15.0 Signed-off-by: Frederic Pillon --- ...nd-adapt-STM32Cube_FW-sources-for-ST.patch | 1122 ++++++++++++++--- ...imeout-when-waiting-for-the-cmd_resp.patch | 32 +- ...rt-for-customize-app_conf_default.h.patch} | 94 +- 3 files changed, 979 insertions(+), 269 deletions(-) rename extras/STM32Cube_FW/{0003-Added-support-for-custom-app_conf.h.patch => 0003-chore-add-support-for-customize-app_conf_default.h.patch} (58%) diff --git a/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch b/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch index bbc8ba44..8b9ba87d 100644 --- a/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch +++ b/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch @@ -1,54 +1,66 @@ -From 1c3ca9f22842e3ae283d3e979a5f38a195d8d4ee Mon Sep 17 00:00:00 2001 -From: Alexandre Bourdiol -Date: Tue, 30 Aug 2022 11:28:41 +0200 +From f72f61b2a895a9f02a338c600af1de239939b357 Mon Sep 17 00:00:00 2001 +From: Frederic Pillon +Date: Mon, 12 Dec 2022 17:15:26 +0100 Subject: [PATCH 1/3] chore: clean up and adapt STM32Cube_FW sources for STM32duino -Signed-off-by: Alexandre Bourdiol +Signed-off-by: Frederic Pillon --- - src/utility/STM32Cube_FW/app_conf_default.h | 428 +------------------ - src/utility/STM32Cube_FW/ble_bufsize.h | 13 +- + src/utility/STM32Cube_FW/app_conf_default.h | 914 ++++++------------- + src/utility/STM32Cube_FW/ble_bufsize.h | 7 + src/utility/STM32Cube_FW/hw.h | 28 +- - src/utility/STM32Cube_FW/hw_ipcc.c | 184 +------- - src/utility/STM32Cube_FW/mbox_def.h | 34 -- - src/utility/STM32Cube_FW/shci.c | 40 +- - src/utility/STM32Cube_FW/shci.h | 47 +- - src/utility/STM32Cube_FW/shci_tl.c | 19 +- + src/utility/STM32Cube_FW/hw_ipcc.c | 218 +---- + src/utility/STM32Cube_FW/mbox_def.h | 34 - + src/utility/STM32Cube_FW/shci.c | 39 +- + src/utility/STM32Cube_FW/shci.h | 51 +- + src/utility/STM32Cube_FW/shci_tl.c | 37 +- src/utility/STM32Cube_FW/stm32_wpan_common.h | 39 +- - src/utility/STM32Cube_FW/stm_list.c | 11 +- + src/utility/STM32Cube_FW/stm_list.c | 15 +- src/utility/STM32Cube_FW/stm_list.h | 4 +- - src/utility/STM32Cube_FW/tl.h | 33 -- - src/utility/STM32Cube_FW/tl_mbox.c | 144 +------ - 13 files changed, 91 insertions(+), 933 deletions(-) + src/utility/STM32Cube_FW/tl.h | 33 - + src/utility/STM32Cube_FW/tl_mbox.c | 143 +-- + 13 files changed, 323 insertions(+), 1239 deletions(-) + rewrite src/utility/STM32Cube_FW/app_conf_default.h (63%) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h -index c63c66e..54f824a 100644 +dissimilarity index 63% +index 2606a05..cc8c3e8 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h -@@ -1,4 +1,3 @@ +@@ -1,655 +1,259 @@ -/* USER CODE BEGIN Header */ - /** - ****************************************************************************** - * @file app_conf.h -@@ -16,94 +15,36 @@ - * - ****************************************************************************** - */ +-/** +- ****************************************************************************** +- * @file app_conf.h +- * @author MCD Application Team +- * @brief Application configuration file for STM32WPAN Middleware. +- ****************************************************************************** +- * @attention +- * +- * Copyright (c) 2020-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 APP_CONF_H - #define APP_CONF_H - - #include "hw.h" +- +-/* Define to prevent recursive inclusion -------------------------------------*/ +-#ifndef APP_CONF_H +-#define APP_CONF_H +- +-#include "hw.h" -#include "hw_conf.h" -#include "hw_if.h" - #include "ble_bufsize.h" - - /****************************************************************************** - * Application Config - ******************************************************************************/ - +-#include "ble_bufsize.h" +- +-/****************************************************************************** +- * Application Config +- ******************************************************************************/ +- -/** - * Define Secure Connections Support - */ @@ -63,16 +75,9 @@ index c63c66e..54f824a 100644 - */ -#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) -#define CFG_KEYPRESS_SUPPORTED (0x01) -+/**< generic parameters ******************************************************/ -+/* HCI related defines */ - +- -#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED -+#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 - +- -/** - * Numeric Comparison Answers - */ @@ -94,17 +99,12 @@ index c63c66e..54f824a 100644 -* Encryption root key used to derive LTK and CSRK -*/ -#define CFG_BLE_ERK {0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21, 0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21} -+#ifndef BLE_SHARED_MEM_BYTE_ORDER -+ #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST -+#endif -+#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 - - /** +- +-/** - * SMPS supply - * SMPS not used when Set to 0 - * SMPS used when Set to 1 -+ * Define Tx Power - */ +- */ -#define CFG_USE_SMPS 0 - -/* USER CODE BEGIN Generic_Parameters */ @@ -134,41 +134,218 @@ index c63c66e..54f824a 100644 -#define CFG_FW_SUBVERSION (1) -#define CFG_FW_BRANCH (0) -#define CFG_FW_BUILD (0) -+#define CFG_TX_POWER (0x18) /* -0.15dBm */ - - /****************************************************************************** - * BLE Stack -@@ -152,13 +93,15 @@ - * Prepare Write List size in terms of number of packet - * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set - */ +- +-/****************************************************************************** +- * BLE Stack +- ******************************************************************************/ +-/** +- * Maximum number of simultaneous connections that the device will support. +- * Valid values are from 1 to 8 +- */ +-#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 +- */ +-#define CFG_BLE_NUM_GATT_SERVICES 8 +- +-/** +- * Maximum number of Attributes +- * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) +- * that can be stored in the GATT database. +- * 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 +- +-/** +- * Maximum supported ATT_MTU size +- * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set +- */ +-#define CFG_BLE_MAX_ATT_MTU (156) +- +-/** +- * Size of the storage area for Attribute values +- * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: +- * - attribute value length +- * - 5, if UUID is 16 bit; 19, if UUID is 128 bit +- * - 2, if server configuration descriptor is used +- * - 2*DTM_NUM_LINK, if client configuration descriptor is used +- * - 2, if extended properties is used +- * The total amount of memory needed is the sum of the above quantities for each attribute. +- * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set +- */ +-#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) +- +-/** +- * Prepare Write List size in terms of number of packet +- * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set +- */ -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -+// #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -+#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) - - /** - * Number of allocated memory blocks - * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set - */ +- +-/** +- * Number of allocated memory blocks +- * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set +- */ -#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) -+// #define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) -+#define CFG_BLE_MBLOCK_COUNT (0x79) - - /** - * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. -@@ -241,7 +184,7 @@ - * 0: LE Power Class 2-3 - * other bits: reserved (shall be set to 0) - */ --#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_POWER_CLASS_2_3) -+#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY) - - #define CFG_BLE_MAX_COC_INITIATOR_NBR (32) - -@@ -291,340 +234,5 @@ - - #define CFG_BLE_RX_PATH_COMPENS (0) - +- +-/** +- * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. +- */ +-#define CFG_BLE_DATA_LENGTH_EXTENSION 1 +- +-/** +- * Sleep clock accuracy in Slave mode (ppm value) +- */ +-#define CFG_BLE_SLAVE_SCA 500 +- +-/** +- * Sleep clock accuracy in Master mode +- * 0 : 251 ppm to 500 ppm +- * 1 : 151 ppm to 250 ppm +- * 2 : 101 ppm to 150 ppm +- * 3 : 76 ppm to 100 ppm +- * 4 : 51 ppm to 75 ppm +- * 5 : 31 ppm to 50 ppm +- * 6 : 21 ppm to 30 ppm +- * 7 : 0 ppm to 20 ppm +- */ +-#define CFG_BLE_MASTER_SCA 0 +- +-/** +- * LsSource +- * Some information for Low speed clock mapped in bits field +- * - bit 0: 1: Calibration for the RF system wakeup clock source 0: No calibration for the RF system wakeup clock source +- * - 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) +-#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 +- +-/** +- * Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us) +- */ +-#define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) +- +-/** +- * Viterbi Mode +- * 1 : enabled +- * 0 : disabled +- */ +-#define CFG_BLE_VITERBI_MODE 1 +- +-/** +- * BLE stack Options flags to be configured with: +- * - SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY +- * - SHCI_C2_BLE_INIT_OPTIONS_LL_HOST +- * - SHCI_C2_BLE_INIT_OPTIONS_NO_SVC_CHANGE_DESC +- * - SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC +- * - SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RO +- * - SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW +- * - SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV +- * - SHCI_C2_BLE_INIT_OPTIONS_NO_EXT_ADV +- * - SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 +- * - SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2 +- * - SHCI_C2_BLE_INIT_OPTIONS_REDUC_GATTDB_NVM +- * - SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM +- * - SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_USED +- * - SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED +- * - SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_1 +- * - SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3 +- * - SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_WRITABLE +- * - SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_READONLY +- * - SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_SUPPORTED +- * - SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_NOTSUPPORTED +- * which are used to set following configuration bits: +- * (bit 0): 1: LL only +- * 0: LL + host +- * (bit 1): 1: no service change desc. +- * 0: with service change desc. +- * (bit 2): 1: device name Read-Only +- * 0: device name R/W +- * (bit 3): 1: extended advertizing supported +- * 0: extended advertizing not supported +- * (bit 4): 1: CS Algo #2 supported +- * 0: CS Algo #2 not supported +- * (bit 5): 1: Reduced GATT database in NVM +- * 0: Full GATT database in NVM +- * (bit 6): 1: GATT caching is used +- * 0: GATT caching is not used +- * (bit 7): 1: LE Power Class 1 +- * 0: LE Power Class 2-3 +- * (bit 8): 1: appearance Writable +- * 0: appearance Read-Only +- * (bit 9): 1: Enhanced ATT supported +- * 0: Enhanced ATT not supported +- * other bits: reserved (shall be set to 0) +- */ +-#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 | SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_READONLY | SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_NOTSUPPORTED) +- +-#define CFG_BLE_MAX_COC_INITIATOR_NBR (32) +- +-#define CFG_BLE_MIN_TX_POWER (-40) +- +-#define CFG_BLE_MAX_TX_POWER (6) +- +-/** +- * BLE Rx model configuration flags to be configured with: +- * - SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY +- * - SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_BLOCKER +- * which are used to set following configuration bits: +- * (bit 0): 1: agc_rssi model improved vs RF blockers +- * 0: Legacy agc_rssi model +- * other bits: reserved (shall be set to 0) +- */ +- +-#define CFG_BLE_RX_MODEL_CONFIG (SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY) +- +-/* Maximum number of advertising sets. +- * Range: 1 .. 8 with limitation: +- * This parameter is linked to CFG_BLE_MAX_ADV_DATA_LEN such as both compliant with allocated Total memory computed with BLE_EXT_ADV_BUFFER_SIZE based +- * on Max Extended advertising configuration supported. +- * 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) +- +- /* Maximum advertising data length (in bytes) +- * Range: 31 .. 1650 with limitation: +- * This parameter is linked to CFG_BLE_MAX_ADV_SET_NBR such as both compliant with allocated Total memory computed with BLE_EXT_ADV_BUFFER_SIZE based +- * on Max Extended advertising configuration supported. +- * 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) +- +- /* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. +- * Range: -1280 .. 1280 +- */ +- +-#define CFG_BLE_TX_PATH_COMPENS (0) +- +- /* RF RX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. +- * Range: -1280 .. 1280 +- */ +- +-#define CFG_BLE_RX_PATH_COMPENS (0) +- +- /* BLE core version (16-bit signed integer). +- * - SHCI_C2_BLE_INIT_BLE_CORE_5_2 +- * - SHCI_C2_BLE_INIT_BLE_CORE_5_3 +- * which are used to set: 11(5.2), 12(5.3). +- */ +- +-#define CFG_BLE_CORE_VERSION (SHCI_C2_BLE_INIT_BLE_CORE_5_3) +- -/****************************************************************************** - * Transport Layer - ******************************************************************************/ @@ -504,13 +681,272 @@ index c63c66e..54f824a 100644 - -#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR - - #endif /*APP_CONF_H */ - +-#endif /*APP_CONF_H */ +- ++/** ++ ****************************************************************************** ++ * @file app_conf_default.h ++ * @author MCD Application Team ++ * @brief Default application configuration file for STM32WPAN Middleware. ++ ****************************************************************************** ++ * @attention ++ * ++ * Copyright (c) 2020-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. ++ * ++ ****************************************************************************** ++ */ ++ ++/* Define to prevent recursive inclusion -------------------------------------*/ ++#ifndef APP_CONF_DEFAULT_H ++#define APP_CONF_DEFAULT_H ++ ++/****************************************************************************** ++ * 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 */ ++ ++/****************************************************************************** ++ * BLE Stack ++ ******************************************************************************/ ++/** ++ * Maximum number of simultaneous connections that the device will support. ++ * Valid values are from 1 to 8 ++ */ ++#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 ++ */ ++#define CFG_BLE_NUM_GATT_SERVICES 8 ++ ++/** ++ * Maximum number of Attributes ++ * (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services) ++ * that can be stored in the GATT database. ++ * 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 ++ ++/** ++ * Maximum supported ATT_MTU size ++ * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set ++ */ ++#define CFG_BLE_MAX_ATT_MTU (156) ++ ++/** ++ * Size of the storage area for Attribute values ++ * This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute: ++ * - attribute value length ++ * - 5, if UUID is 16 bit; 19, if UUID is 128 bit ++ * - 2, if server configuration descriptor is used ++ * - 2*DTM_NUM_LINK, if client configuration descriptor is used ++ * - 2, if extended properties is used ++ * The total amount of memory needed is the sum of the above quantities for each attribute. ++ * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set ++ */ ++#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) ++ ++/** ++ * Prepare Write List size in terms of number of packet ++ * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set ++ */ ++// #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) ++#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) ++ ++/** ++ * Number of allocated memory blocks ++ * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set ++ */ ++// #define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) ++#define CFG_BLE_MBLOCK_COUNT (0x79) ++ ++/** ++ * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. ++ */ ++#define CFG_BLE_DATA_LENGTH_EXTENSION 1 ++ ++/** ++ * Sleep clock accuracy in Slave mode (ppm value) ++ */ ++#define CFG_BLE_SLAVE_SCA 500 ++ ++/** ++ * Sleep clock accuracy in Master mode ++ * 0 : 251 ppm to 500 ppm ++ * 1 : 151 ppm to 250 ppm ++ * 2 : 101 ppm to 150 ppm ++ * 3 : 76 ppm to 100 ppm ++ * 4 : 51 ppm to 75 ppm ++ * 5 : 31 ppm to 50 ppm ++ * 6 : 21 ppm to 30 ppm ++ * 7 : 0 ppm to 20 ppm ++ */ ++#define CFG_BLE_MASTER_SCA 0 ++ ++/** ++ * LsSource ++ * Some information for Low speed clock mapped in bits field ++ * - bit 0: 1: Calibration for the RF system wakeup clock source 0: No calibration for the RF system wakeup clock source ++ * - 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) ++#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 ++ ++/** ++ * Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us) ++ */ ++#define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) ++ ++/** ++ * Viterbi Mode ++ * 1 : enabled ++ * 0 : disabled ++ */ ++#define CFG_BLE_VITERBI_MODE 1 ++ ++/** ++ * BLE stack Options flags to be configured with: ++ * - SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY ++ * - SHCI_C2_BLE_INIT_OPTIONS_LL_HOST ++ * - SHCI_C2_BLE_INIT_OPTIONS_NO_SVC_CHANGE_DESC ++ * - SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC ++ * - SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RO ++ * - SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW ++ * - SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV ++ * - SHCI_C2_BLE_INIT_OPTIONS_NO_EXT_ADV ++ * - SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 ++ * - SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2 ++ * - SHCI_C2_BLE_INIT_OPTIONS_REDUC_GATTDB_NVM ++ * - SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM ++ * - SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_USED ++ * - SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED ++ * - SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_1 ++ * - SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3 ++ * - SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_WRITABLE ++ * - SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_READONLY ++ * - SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_SUPPORTED ++ * - SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_NOTSUPPORTED ++ * which are used to set following configuration bits: ++ * (bit 0): 1: LL only ++ * 0: LL + host ++ * (bit 1): 1: no service change desc. ++ * 0: with service change desc. ++ * (bit 2): 1: device name Read-Only ++ * 0: device name R/W ++ * (bit 3): 1: extended advertizing supported ++ * 0: extended advertizing not supported ++ * (bit 4): 1: CS Algo #2 supported ++ * 0: CS Algo #2 not supported ++ * (bit 5): 1: Reduced GATT database in NVM ++ * 0: Full GATT database in NVM ++ * (bit 6): 1: GATT caching is used ++ * 0: GATT caching is not used ++ * (bit 7): 1: LE Power Class 1 ++ * 0: LE Power Class 2-3 ++ * (bit 8): 1: appearance Writable ++ * 0: appearance Read-Only ++ * (bit 9): 1: Enhanced ATT supported ++ * 0: Enhanced ATT not supported ++ * other bits: reserved (shall be set to 0) ++ */ ++#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY) ++ ++#define CFG_BLE_MAX_COC_INITIATOR_NBR (32) ++ ++#define CFG_BLE_MIN_TX_POWER (-40) ++ ++#define CFG_BLE_MAX_TX_POWER (6) ++ ++/** ++ * BLE Rx model configuration flags to be configured with: ++ * - SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY ++ * - SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_BLOCKER ++ * which are used to set following configuration bits: ++ * (bit 0): 1: agc_rssi model improved vs RF blockers ++ * 0: Legacy agc_rssi model ++ * other bits: reserved (shall be set to 0) ++ */ ++ ++#define CFG_BLE_RX_MODEL_CONFIG (SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY) ++ ++/* Maximum number of advertising sets. ++ * Range: 1 .. 8 with limitation: ++ * This parameter is linked to CFG_BLE_MAX_ADV_DATA_LEN such as both compliant with allocated Total memory computed with BLE_EXT_ADV_BUFFER_SIZE based ++ * on Max Extended advertising configuration supported. ++ * 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) ++ ++ /* Maximum advertising data length (in bytes) ++ * Range: 31 .. 1650 with limitation: ++ * This parameter is linked to CFG_BLE_MAX_ADV_SET_NBR such as both compliant with allocated Total memory computed with BLE_EXT_ADV_BUFFER_SIZE based ++ * on Max Extended advertising configuration supported. ++ * 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) ++ ++ /* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. ++ * Range: -1280 .. 1280 ++ */ ++ ++#define CFG_BLE_TX_PATH_COMPENS (0) ++ ++ /* RF RX Path Compensation Value (16-bit signed integer). Units: 0.1 dB. ++ * Range: -1280 .. 1280 ++ */ ++ ++#define CFG_BLE_RX_PATH_COMPENS (0) ++ ++ /* BLE core version (16-bit signed integer). ++ * - SHCI_C2_BLE_INIT_BLE_CORE_5_2 ++ * - SHCI_C2_BLE_INIT_BLE_CORE_5_3 ++ * which are used to set: 11(5.2), 12(5.3). ++ */ ++ ++#define CFG_BLE_CORE_VERSION (SHCI_C2_BLE_INIT_BLE_CORE_5_3) ++ ++#endif /* APP_CONF_DEFAULT_H */ diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h -index 0f0f419..247573b 100644 +index 4269fa4..cea5da8 100644 --- a/src/utility/STM32Cube_FW/ble_bufsize.h +++ b/src/utility/STM32Cube_FW/ble_bufsize.h -@@ -75,17 +75,24 @@ +@@ -75,6 +75,13 @@ ((pw) + MAX(BLE_MEM_BLOCK_X_MTU(mtu, n_link), \ BLE_MBLOCKS_SECURE_CONNECTIONS)) @@ -523,21 +959,7 @@ index 0f0f419..247573b 100644 + /* * BLE_FIXED_BUFFER_SIZE_BYTES: -- * A part of the RAM, is dinamically allocated by initilizing all the pointers -+ * A part of the RAM, is dynamically allocated by initializing all the pointers - * defined in a global context variable "mem_alloc_ctx_p". - * This initialization is made in the Dynamic_allocator functions, which -- * assing a portion of RAM given by the external application to the above -+ * assign a portion of RAM given by the external application to the above - * mentioned "global pointers". - * - * The size of this Dynamic RAM is made of 2 main components: - * - a part that is parameters-dependent (num of links, GATT buffers, ...), -- * and which value is explicited by the following macro; -+ * and which value is defined by the following macro; - * - a part, that may be considered "fixed", i.e. independent from the above - * mentioned parameters. - */ + * A part of the RAM, is dynamically allocated by initializing all the pointers diff --git a/src/utility/STM32Cube_FW/hw.h b/src/utility/STM32Cube_FW/hw.h index 503fa2c..fcf0451 100644 --- a/src/utility/STM32Cube_FW/hw.h @@ -591,12 +1013,19 @@ index 503fa2c..fcf0451 100644 } #endif diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c -index fd620b8..7b9be81 100644 +index fd620b8..0c1868f 100644 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ b/src/utility/STM32Cube_FW/hw_ipcc.c -@@ -18,8 +18,9 @@ +@@ -1,4 +1,3 @@ +-/* USER CODE BEGIN Header */ + /** + ****************************************************************************** + * @file hw_ipcc.c +@@ -16,10 +15,10 @@ + * + ****************************************************************************** */ - /* USER CODE END Header */ +-/* USER CODE END Header */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ @@ -605,7 +1034,7 @@ index fd620b8..7b9be81 100644 #include "mbox_def.h" /* Global variables ---------------------------------------------------------*/ -@@ -56,34 +57,17 @@ static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ); +@@ -56,34 +55,17 @@ static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ); static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void ); #endif @@ -626,7 +1055,7 @@ index fd620b8..7b9be81 100644 * INTERRUPT HANDLER ******************************************************************************/ -void HW_IPCC_Rx_Handler( void ) -+void IPCC_C1_RX_IRQHandler(void) ++void IPCC_C1_RX_IRQHandler( void ) { if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL )) { @@ -641,7 +1070,7 @@ index fd620b8..7b9be81 100644 #ifdef THREAD_WB else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL )) { -@@ -114,16 +98,6 @@ void HW_IPCC_Rx_Handler( void ) +@@ -114,16 +96,6 @@ void HW_IPCC_Rx_Handler( void ) HW_IPCC_LLD_BLE_ReceiveM0CmdHandler(); } #endif /* LLD_TESTS_WB */ @@ -658,7 +1087,7 @@ index fd620b8..7b9be81 100644 else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL )) { HW_IPCC_BLE_EvtHandler(); -@@ -132,22 +106,14 @@ void HW_IPCC_Rx_Handler( void ) +@@ -132,22 +104,14 @@ void HW_IPCC_Rx_Handler( void ) { HW_IPCC_TRACES_EvtHandler(); } @@ -667,7 +1096,7 @@ index fd620b8..7b9be81 100644 } -void HW_IPCC_Tx_Handler( void ) -+void IPCC_C1_TX_IRQHandler(void) ++void IPCC_C1_TX_IRQHandler( void ) { if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) { @@ -682,7 +1111,7 @@ index fd620b8..7b9be81 100644 #ifdef THREAD_WB else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) { -@@ -157,12 +123,6 @@ void HW_IPCC_Tx_Handler( void ) +@@ -157,12 +121,6 @@ void HW_IPCC_Tx_Handler( void ) #ifdef LLD_TESTS_WB // No TX handler for LLD tests #endif /* LLD_TESTS_WB */ @@ -695,35 +1124,112 @@ index fd620b8..7b9be81 100644 else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL )) { HW_IPCC_MM_FreeBufHandler(); -@@ -171,9 +131,8 @@ void HW_IPCC_Tx_Handler( void ) +@@ -171,8 +129,6 @@ void HW_IPCC_Tx_Handler( void ) { HW_IPCC_BLE_AclDataEvtHandler(); } - - return; } -+ /****************************************************************************** * GENERAL - ******************************************************************************/ -@@ -264,8 +223,8 @@ static void HW_IPCC_BLE_AclDataEvtHandler( void ) - return; +@@ -204,8 +160,6 @@ void HW_IPCC_Enable( void ) + __SEV( ); /* Set the internal event flag and send an event to the CPU2 */ + __WFE( ); /* Clear the internal event flag */ + LL_PWR_EnableBootC2( ); +- +- return; } --__weak void HW_IPCC_BLE_AclDataAckNot( void ){}; --__weak void HW_IPCC_BLE_RxEvtNot( void ){}; -+__WEAK void HW_IPCC_BLE_AclDataAckNot( void ){}; -+__WEAK void HW_IPCC_BLE_RxEvtNot( void ){}; + void HW_IPCC_Init( void ) +@@ -217,8 +171,6 @@ void HW_IPCC_Init( void ) + + HAL_NVIC_EnableIRQ(IPCC_C1_RX_IRQn); + HAL_NVIC_EnableIRQ(IPCC_C1_TX_IRQn); +- +- return; + } /****************************************************************************** - * SYSTEM -@@ -303,56 +262,8 @@ static void HW_IPCC_SYS_EvtHandler( void ) - return; +@@ -227,15 +179,11 @@ void HW_IPCC_Init( void ) + void HW_IPCC_BLE_Init( void ) + { + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_BLE_EVENT_CHANNEL ); +- +- return; + } + + void HW_IPCC_BLE_SendCmd( void ) + { + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_BLE_CMD_CHANNEL ); +- +- return; + } + + static void HW_IPCC_BLE_EvtHandler( void ) +@@ -243,16 +191,12 @@ static void HW_IPCC_BLE_EvtHandler( void ) + HW_IPCC_BLE_RxEvtNot(); + + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_BLE_EVENT_CHANNEL ); +- +- return; + } + + void HW_IPCC_BLE_SendAclData( void ) + { + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); +- +- return; + } + + static void HW_IPCC_BLE_AclDataEvtHandler( void ) +@@ -260,8 +204,6 @@ static void HW_IPCC_BLE_AclDataEvtHandler( void ) + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); + + HW_IPCC_BLE_AclDataAckNot(); +- +- return; + } + + __weak void HW_IPCC_BLE_AclDataAckNot( void ){}; +@@ -273,16 +215,12 @@ __weak void HW_IPCC_BLE_RxEvtNot( void ){}; + void HW_IPCC_SYS_Init( void ) + { + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL ); +- +- return; + } + + void HW_IPCC_SYS_SendCmd( void ) + { + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); +- +- return; + } + + static void HW_IPCC_SYS_CmdEvtHandler( void ) +@@ -290,8 +228,6 @@ static void HW_IPCC_SYS_CmdEvtHandler( void ) + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); + + HW_IPCC_SYS_CmdEvtNot(); +- +- return; } --__weak void HW_IPCC_SYS_CmdEvtNot( void ){}; --__weak void HW_IPCC_SYS_EvtNot( void ){}; + static void HW_IPCC_SYS_EvtHandler( void ) +@@ -299,61 +235,11 @@ static void HW_IPCC_SYS_EvtHandler( void ) + HW_IPCC_SYS_EvtNot(); + + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL ); - +- return; + } + + __weak void HW_IPCC_SYS_CmdEvtNot( void ){}; + __weak void HW_IPCC_SYS_EvtNot( void ){}; + -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ @@ -771,25 +1277,139 @@ index fd620b8..7b9be81 100644 -__weak void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ){}; -__weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){}; -#endif -+__WEAK void HW_IPCC_SYS_CmdEvtNot( void ){}; -+__WEAK void HW_IPCC_SYS_EvtNot( void ){}; - +- /****************************************************************************** * THREAD -@@ -424,9 +335,9 @@ static void HW_IPCC_THREAD_CliNotEvtHandler( void ) - return; + ******************************************************************************/ +@@ -393,8 +279,6 @@ void HW_IPCC_THREAD_CliSendAck( void ) + { + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); +- +- return; } --__weak void HW_IPCC_OT_CmdEvtNot( void ){}; --__weak void HW_IPCC_CLI_CmdEvtNot( void ){}; --__weak void HW_IPCC_THREAD_EvtNot( void ){}; -+__WEAK void HW_IPCC_OT_CmdEvtNot( void ){}; -+__WEAK void HW_IPCC_CLI_CmdEvtNot( void ){}; -+__WEAK void HW_IPCC_THREAD_EvtNot( void ){}; + static void HW_IPCC_OT_CmdEvtHandler( void ) +@@ -402,8 +286,6 @@ static void HW_IPCC_OT_CmdEvtHandler( void ) + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); - #endif /* THREAD_WB */ + HW_IPCC_OT_CmdEvtNot(); +- +- return; + } -@@ -548,74 +459,6 @@ void HW_IPCC_LLD_BLE_SendRspAck( void ) + static void HW_IPCC_THREAD_NotEvtHandler( void ) +@@ -411,8 +293,6 @@ static void HW_IPCC_THREAD_NotEvtHandler( void ) + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); + + HW_IPCC_THREAD_EvtNot(); +- +- return; + } + + static void HW_IPCC_THREAD_CliNotEvtHandler( void ) +@@ -420,8 +300,6 @@ static void HW_IPCC_THREAD_CliNotEvtHandler( void ) + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); + + HW_IPCC_THREAD_CliEvtNot(); +- +- return; + } + + __weak void HW_IPCC_OT_CmdEvtNot( void ){}; +@@ -438,7 +316,6 @@ void HW_IPCC_LLDTESTS_Init( void ) + { + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); +- return; + } + + void HW_IPCC_LLDTESTS_SendCliCmd( void ) +@@ -451,28 +328,24 @@ static void HW_IPCC_LLDTESTS_ReceiveCliRspHandler( void ) + { + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); + HW_IPCC_LLDTESTS_ReceiveCliRsp(); +- return; + } + + void HW_IPCC_LLDTESTS_SendCliRspAck( void ) + { + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); +- return; + } + + static void HW_IPCC_LLDTESTS_ReceiveM0CmdHandler( void ) + { + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); + HW_IPCC_LLDTESTS_ReceiveM0Cmd(); +- return; + } + + void HW_IPCC_LLDTESTS_SendM0CmdAck( void ) + { + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); +- return; + } + __weak void HW_IPCC_LLDTESTS_ReceiveCliRsp( void ){}; + __weak void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void ){}; +@@ -486,13 +359,11 @@ void HW_IPCC_LLD_BLE_Init( void ) + { + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); +- return; + } + + void HW_IPCC_LLD_BLE_SendCliCmd( void ) + { + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CLI_CMD_CHANNEL ); +- return; + } + + /*static void HW_IPCC_LLD_BLE_ReceiveCliRspHandler( void ) +@@ -506,21 +377,18 @@ void HW_IPCC_LLD_BLE_SendCliRspAck( void ) + { + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL ); +- return; + } + + static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void ) + { + //LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); + HW_IPCC_LLD_BLE_ReceiveM0Cmd(); +- return; + } + + void HW_IPCC_LLD_BLE_SendM0CmdAck( void ) + { + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); + //LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); +- return; + } + __weak void HW_IPCC_LLD_BLE_ReceiveCliRsp( void ){}; + __weak void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ){}; +@@ -529,93 +397,22 @@ __weak void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ){}; + void HW_IPCC_LLD_BLE_SendCmd( void ) + { + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CMD_CHANNEL ); +- return; + } + + static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ) + { + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); + HW_IPCC_LLD_BLE_ReceiveRsp(); +- return; + } + + void HW_IPCC_LLD_BLE_SendRspAck( void ) + { + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); +- return; + } #endif /* LLD_BLE_WB */ @@ -864,12 +1484,33 @@ index fd620b8..7b9be81 100644 /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ -@@ -666,4 +509,5 @@ static void HW_IPCC_TRACES_EvtHandler( void ) - return; +@@ -632,8 +429,6 @@ void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) ) + + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); + } +- +- return; + } + + static void HW_IPCC_MM_FreeBufHandler( void ) +@@ -643,8 +438,6 @@ static void HW_IPCC_MM_FreeBufHandler( void ) + FreeBufCb(); + + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); +- +- return; + } + + /****************************************************************************** +@@ -662,8 +455,7 @@ static void HW_IPCC_TRACES_EvtHandler( void ) + HW_IPCC_TRACES_EvtNot(); + + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_TRACES_CHANNEL ); +- +- return; } --__weak void HW_IPCC_TRACES_EvtNot( void ){}; -+__WEAK void HW_IPCC_TRACES_EvtNot( void ){}; + __weak void HW_IPCC_TRACES_EvtNot( void ){}; +#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h index 68b71f9..0c974f8 100644 @@ -965,7 +1606,7 @@ index 68b71f9..0c974f8 100644 #endif /*__MBOX_H */ diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c -index 472a108..a847522 100644 +index 301db76..a847522 100644 --- a/src/utility/STM32Cube_FW/shci.c +++ b/src/utility/STM32Cube_FW/shci.c @@ -16,7 +16,7 @@ @@ -1027,14 +1668,13 @@ index 472a108..a847522 100644 SHCI_CmdStatus_t SHCI_C2_Reinit( void ) { /** -@@ -739,4 +703,4 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) +@@ -739,3 +703,4 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } -- +#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h -index 102089e..6b6ffd1 100644 +index 7ca9021..a0f1e4d 100644 --- a/src/utility/STM32Cube_FW/shci.h +++ b/src/utility/STM32Cube_FW/shci.h @@ -49,7 +49,6 @@ extern "C" { @@ -1045,15 +1685,6 @@ index 102089e..6b6ffd1 100644 } SCHI_SystemErrCode_t; #define SHCI_EVTCODE ( 0xFF ) -@@ -102,7 +101,7 @@ extern "C" { - - /** - * SHCI_SUB_EVT_THREAD_NVM_RAM_UPDATE -- * This notifies the CPU1 which part of the OT NVM RAM has been updated so that only the modified -+ * This notifies the CPU1 which part of the 'OT NVM RAM' has been updated so that only the modified - * section could be written in Flash/NVM - * StartAddress : Start address of the section that has been modified - * Size : Size (in bytes) of the section that has been modified @@ -216,9 +215,7 @@ extern "C" { SHCI_OCF_C2_FLASH_STORE_DATA, SHCI_OCF_C2_FLASH_ERASE_DATA, @@ -1064,7 +1695,34 @@ index 102089e..6b6ffd1 100644 SHCI_OCF_C2_LLD_TESTS_INIT, SHCI_OCF_C2_EXTPA_CONFIG, SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, -@@ -648,8 +645,6 @@ extern "C" { +@@ -436,7 +433,7 @@ extern "C" { + * PrWriteListSize + * NOTE: This parameter is ignored by the CPU2 when the parameter "Options" is set to "LL_only" ( see Options description in that structure ) + * +- * Maximum number of supported “prepare write request” ++ * Maximum number of supported "prepare write request" + * - Min value: given by the macro DEFAULT_PREP_WRITE_LIST_SIZE + * - Max value: a value higher than the minimum required can be specified, but it is not recommended + */ +@@ -503,7 +500,7 @@ extern "C" { + * MaxConnEventLength + * This parameter determines the maximum duration of a slave connection event. When this duration is reached the slave closes + * the current connections event (whatever is the CE_length parameter specified by the master in HCI_CREATE_CONNECTION HCI command), +- * expressed in units of 625/256 µs (~2.44 µs) ++ * expressed in units of 625/256 µs (~2.44 µs) + * - Min value: 0 (if 0 is specified, the master and slave perform only a single TX-RX exchange per connection event) + * - Max value: 1638400 (4000 ms). A higher value can be specified (max 0xFFFFFFFF) but results in a maximum connection time + * of 4000 ms as specified. In this case the parameter is not applied, and the predicted CE length calculated on slave is not shortened +@@ -512,7 +509,7 @@ extern "C" { + + /** + * HsStartupTime +- * Startup time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 µs (~2.44 µs). ++ * Startup time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 µs (~2.44 µs). + * - Min value: 0 + * - Max value: 820 (~2 ms). A higher value can be specified, but the value that implemented in stack is forced to ~2 ms + */ +@@ -678,8 +675,6 @@ extern "C" { { uint8_t thread_config; uint8_t ble_config; @@ -1073,7 +1731,7 @@ index 102089e..6b6ffd1 100644 } SHCI_C2_DEBUG_TracesConfig_t; typedef PACKED_STRUCT -@@ -713,8 +708,6 @@ extern "C" { +@@ -743,8 +738,6 @@ extern "C" { { BLE_ENABLE, THREAD_ENABLE, @@ -1082,7 +1740,7 @@ index 102089e..6b6ffd1 100644 } SHCI_C2_CONCURRENT_Mode_Param_t; /** No response parameters*/ -@@ -737,18 +730,13 @@ extern "C" { +@@ -767,18 +760,13 @@ extern "C" { { BLE_IP, THREAD_IP, @@ -1101,7 +1759,7 @@ index 102089e..6b6ffd1 100644 #define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) #define SHCI_OPCODE_C2_BLE_LLD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_LLD_INIT) -@@ -856,7 +844,7 @@ extern "C" { +@@ -893,7 +881,7 @@ extern "C" { #define FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD (0xA94656B9) /* @@ -1110,7 +1768,7 @@ index 102089e..6b6ffd1 100644 * MB_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) * each of those coded on 32 bits as shown on the table below: * -@@ -912,9 +900,6 @@ extern "C" { +@@ -949,9 +937,6 @@ extern "C" { #define INFO_STACK_TYPE_BLE_HCI_EXT_ADV 0x07 #define INFO_STACK_TYPE_THREAD_FTD 0x10 #define INFO_STACK_TYPE_THREAD_MTD 0x11 @@ -1120,7 +1778,7 @@ index 102089e..6b6ffd1 100644 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 #define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 #define INFO_STACK_TYPE_802154_LLD_TESTS 0x60 -@@ -923,12 +908,7 @@ extern "C" { +@@ -960,12 +945,7 @@ extern "C" { #define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 #define INFO_STACK_TYPE_BLE_RLV 0x64 #define INFO_STACK_TYPE_802154_RLV 0x65 @@ -1133,7 +1791,7 @@ index 102089e..6b6ffd1 100644 typedef struct { /** -@@ -1102,7 +1082,7 @@ typedef struct { +@@ -1139,7 +1119,7 @@ typedef struct { * @brief Starts the LLD tests CLI * * @param param_size : Nb of bytes @@ -1142,7 +1800,7 @@ index 102089e..6b6ffd1 100644 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ); -@@ -1112,19 +1092,10 @@ typedef struct { +@@ -1149,20 +1129,11 @@ typedef struct { * @brief Starts the LLD tests BLE * * @param param_size : Nb of bytes @@ -1151,7 +1809,7 @@ index 102089e..6b6ffd1 100644 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ); -- + - /** - * SHCI_C2_ZIGBEE_Init - * @brief Starts the Zigbee Stack @@ -1160,10 +1818,11 @@ index 102089e..6b6ffd1 100644 - * @retval Status - */ - SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ); - +- /** * SHCI_C2_DEBUG_Init -@@ -1200,16 +1171,6 @@ typedef struct { + * @brief Starts the Traces +@@ -1237,16 +1208,6 @@ typedef struct { */ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn); @@ -1181,7 +1840,7 @@ index 102089e..6b6ffd1 100644 * SHCI_GetWirelessFwInfo * @brief This function read back the informations relative to the wireless binary loaded. diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c -index ddb3a02..d1a448d 100644 +index 449b8b1..b3cee00 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -16,12 +16,13 @@ @@ -1199,42 +1858,116 @@ index ddb3a02..d1a448d 100644 /* Private typedef -----------------------------------------------------------*/ typedef enum -@@ -168,6 +169,20 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl - return; +@@ -70,8 +71,6 @@ void shci_init(void(* UserEvtRx)(void* pData), void* pConf) + shci_register_io_bus (&shciContext.io); + + TlInit((TL_CmdPacket_t *)(((SHCI_TL_HciInitConf_t *)pConf)->p_cmdbuffer)); +- +- return; } + void shci_user_evt_proc(void) +@@ -127,8 +126,6 @@ void shci_user_evt_proc(void) + shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); + } + +- +- return; + } + + void shci_resume_flow( void ) +@@ -140,8 +137,6 @@ void shci_resume_flow( void ) + * be called + */ + shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); +- +- return; + } + + void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payload, TL_EvtPacket_t * p_rsp ) +@@ -164,8 +159,20 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl + memcpy( &(p_rsp->evtserial), pCmdBuffer, ((TL_EvtSerial_t*)pCmdBuffer)->evt.plen + TL_EVT_HDR_SIZE ); + + Cmd_SetStatus(SHCI_TL_CmdAvailable); ++} ++ +void shci_notify_asynch_evt(void *pdata) +{ + UNUSED(pdata); + /* Need to parse data in future version */ + shci_user_evt_proc(); +} -+ + +- return; +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 ) +@@ -190,8 +197,6 @@ static void TlInit( TL_CmdPacket_t * p_cmdbuffer ) + Conf.IoBusCallBackUserEvt = TlUserEvtReceived; + shciContext.io.Init(&Conf); + } +- +- return; + } + + static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus) +@@ -212,24 +217,18 @@ static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus) + StatusNotCallBackFunction( SHCI_TL_CmdAvailable ); + } + } +- +- return; + } + + static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt) { -@@ -252,4 +267,4 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) - return; + (void)(shcievt); + shci_cmd_resp_release(0); /**< Notify the application the Cmd response has been received */ +- +- return; + } + + static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) + { + LST_insert_tail(&SHciAsynchEventQueue, (tListNode *)shcievt); + shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); /**< Notify the application a full HCI event has been received */ +- +- return; + } + + /* Weak implementation ----------------------------------------------------------------*/ +@@ -239,8 +238,6 @@ __WEAK void shci_cmd_resp_wait(uint32_t timeout) + + CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; + while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); +- +- return; } + __WEAK void shci_cmd_resp_release(uint32_t flag) +@@ -248,7 +245,5 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) + (void)flag; + + CmdRspStatusFlag = SHCI_TL_CMD_RESP_RELEASE; +- +- return; + } - +#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h -index b47b804..5a2b2a5 100644 +index f407bb9..5a2b2a5 100644 --- a/src/utility/STM32Cube_FW/stm32_wpan_common.h +++ b/src/utility/STM32Cube_FW/stm32_wpan_common.h @@ -25,19 +25,9 @@ extern "C" { #endif --#if defined ( __CC_ARM ) +-#if defined ( __CC_ARM )||defined (__ARMCC_VERSION) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline @@ -1285,7 +2018,7 @@ index b47b804..5a2b2a5 100644 #ifdef __cplusplus } diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c -index 4c92864..77dec64 100644 +index 4c92864..9892441 100644 --- a/src/utility/STM32Cube_FW/stm_list.c +++ b/src/utility/STM32Cube_FW/stm_list.c @@ -16,13 +16,13 @@ @@ -1305,7 +2038,7 @@ index 4c92864..77dec64 100644 /****************************************************************************** * Function Definitions -@@ -33,10 +33,10 @@ void LST_init_head (tListNode * listHead) +@@ -33,20 +33,20 @@ void LST_init_head (tListNode * listHead) listHead->prev = listHead; } @@ -1318,6 +2051,18 @@ index 4c92864..77dec64 100644 primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ + if(listHead->next == listHead) + { +- return_value = TRUE; ++ return_value = true; + } + else + { +- return_value = FALSE; ++ return_value = false; + } + __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ + @@ -204,3 +204,4 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node) __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ @@ -1346,10 +2091,10 @@ index b7c3254..769c211 100644 void LST_insert_head (tListNode * listHead, tListNode * node); diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h -index 2124d26..678769c 100644 +index c199bb2..982bb58 100644 --- a/src/utility/STM32Cube_FW/tl.h +++ b/src/utility/STM32Cube_FW/tl.h -@@ -199,19 +199,6 @@ typedef struct +@@ -202,19 +202,6 @@ typedef struct uint8_t *p_BleLldM0CmdBuffer; } TL_BLE_LLD_Config_t; @@ -1369,7 +2114,7 @@ index 2124d26..678769c 100644 /** * @brief Contain the BLE HCI Init Configuration * @{ -@@ -305,26 +292,6 @@ void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); +@@ -308,26 +295,6 @@ void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); void TL_TRACES_Init( void ); void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ); @@ -1397,7 +2142,7 @@ index 2124d26..678769c 100644 } /* extern "C" */ #endif diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c -index 4112429..a9abb18 100644 +index fcd7766..a9abb18 100644 --- a/src/utility/STM32Cube_FW/tl_mbox.c +++ b/src/utility/STM32Cube_FW/tl_mbox.c @@ -16,6 +16,7 @@ @@ -1575,12 +2320,11 @@ index 4112429..a9abb18 100644 /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ -@@ -846,4 +710,4 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) +@@ -846,3 +710,4 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } -- +#endif /* STM32WBxx */ -- -2.33.0.windows.1 +2.38.0.windows.1 diff --git a/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch b/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch index 326b767e..5f7502df 100644 --- a/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch +++ b/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch @@ -1,27 +1,26 @@ -From 979f153a4e6d5d616ddea616bcd732e32cb1773c Mon Sep 17 00:00:00 2001 -From: Alexandre Bourdiol -Date: Tue, 30 Aug 2022 13:19:36 +0200 +From e12c9c97eec7eacb648720fc65adc2a3897ec257 Mon Sep 17 00:00:00 2001 +From: Frederic Pillon +Date: Mon, 12 Dec 2022 17:17:48 +0100 Subject: [PATCH 2/3] fix: include a timeout when waiting for the cmd_resp -Signed-off-by: Alexandre Bourdiol +Signed-off-by: Frederic Pillon --- - src/utility/STM32Cube_FW/shci_tl.c | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) + src/utility/STM32Cube_FW/shci_tl.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c -index d1a448d..678de84 100644 +index b3cee00..1abd1be 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c -@@ -20,6 +20,8 @@ - /* Includes ------------------------------------------------------------------*/ - #include "stm32_wpan_common.h" - -+#include -+ +@@ -23,6 +23,7 @@ #include "stm_list.h" #include "shci_tl.h" #include "stm32_def.h" -@@ -250,11 +252,12 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) ++#include "wiring_time.h" + + /* Private typedef -----------------------------------------------------------*/ + typedef enum +@@ -234,10 +235,12 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { @@ -29,15 +28,14 @@ index d1a448d..678de84 100644 - CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; - while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); -- + for (unsigned long start = millis(); (millis() - start) < timeout;) { + if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { + break; + } + } - return; } + __WEAK void shci_cmd_resp_release(uint32_t flag) -- -2.33.0.windows.1 +2.38.0.windows.1 diff --git a/extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h.patch b/extras/STM32Cube_FW/0003-chore-add-support-for-customize-app_conf_default.h.patch similarity index 58% rename from extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h.patch rename to extras/STM32Cube_FW/0003-chore-add-support-for-customize-app_conf_default.h.patch index 33b69e55..a93713f2 100644 --- a/extras/STM32Cube_FW/0003-Added-support-for-custom-app_conf.h.patch +++ b/extras/STM32Cube_FW/0003-chore-add-support-for-customize-app_conf_default.h.patch @@ -1,54 +1,29 @@ -From d3ae98b9073e5f1e48efb32b1ef4d318814228fe Mon Sep 17 00:00:00 2001 -From: Alexandre Bourdiol -Date: Tue, 30 Aug 2022 13:31:31 +0200 -Subject: [PATCH 3/3] Added support for custom app_conf.h +From d7d18d20b957f52810315147d671c1976a18c1d2 Mon Sep 17 00:00:00 2001 +From: Frederic Pillon +Date: Mon, 12 Dec 2022 17:29:27 +0100 +Subject: [PATCH 3/3] chore: add support for customize app_conf_default.h -Signed-off-by: Alexandre Bourdiol +Signed-off-by: Frederic Pillon --- - src/utility/STM32Cube_FW/app_conf_default.h | 71 ++++++++++++++------- - 1 file changed, 47 insertions(+), 24 deletions(-) + src/utility/STM32Cube_FW/app_conf_default.h | 58 +++++++++++++++------ + 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h -index 54f824a..91672ac 100644 +index cc8c3e8..57f1027 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h -@@ -1,8 +1,8 @@ - /** - ****************************************************************************** -- * @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 - * -@@ -17,11 +17,8 @@ - */ - - /* Define to prevent recursive inclusion -------------------------------------*/ --#ifndef APP_CONF_H --#define APP_CONF_H -- --#include "hw.h" --#include "ble_bufsize.h" -+#ifndef APP_CONF_DEFAULT_H -+#define APP_CONF_DEFAULT_H - - /****************************************************************************** - * Application Config -@@ -44,7 +41,9 @@ +@@ -41,7 +41,9 @@ /** * Define Tx Power */ -#define CFG_TX_POWER (0x18) /* -0.15dBm */ +#ifndef CFG_TX_POWER -+ #define CFG_TX_POWER (0x18) /* -0.15dBm */ ++ #define CFG_TX_POWER (0x18) /* -0.15dBm */ +#endif /****************************************************************************** * BLE Stack -@@ -53,13 +52,17 @@ +@@ -50,13 +52,17 @@ * Maximum number of simultaneous connections that the device will support. * Valid values are from 1 to 8 */ @@ -68,7 +43,7 @@ index 54f824a..91672ac 100644 /** * Maximum number of Attributes -@@ -68,13 +71,17 @@ +@@ -65,13 +71,17 @@ * 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 */ @@ -83,12 +58,12 @@ index 54f824a..91672ac 100644 */ -#define CFG_BLE_MAX_ATT_MTU (156) +#ifndef CFG_BLE_MAX_ATT_MTU -+ #define CFG_BLE_MAX_ATT_MTU (156) ++ #define CFG_BLE_MAX_ATT_MTU (156) +#endif /** * Size of the storage area for Attribute values -@@ -87,14 +94,18 @@ +@@ -84,14 +94,18 @@ * The total amount of memory needed is the sum of the above quantities for each attribute. * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ @@ -104,18 +79,18 @@ index 54f824a..91672ac 100644 // #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) +#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE -+ #define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) ++ #define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) +#endif /** * Number of allocated memory blocks -@@ -106,12 +117,16 @@ +@@ -103,12 +117,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 ++ #define CFG_BLE_DATA_LENGTH_EXTENSION 1 +#endif /** @@ -123,35 +98,35 @@ index 54f824a..91672ac 100644 */ -#define CFG_BLE_SLAVE_SCA 500 +#ifndef CFG_BLE_SLAVE_SCA -+ #define CFG_BLE_SLAVE_SCA 500 ++ #define CFG_BLE_SLAVE_SCA 500 +#endif /** * Sleep clock accuracy in Master mode -@@ -124,7 +139,9 @@ +@@ -121,7 +139,9 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#define CFG_BLE_MASTER_SCA 0 +#ifndef CFG_BLE_MASTER_SCA -+ #define CFG_BLE_MASTER_SCA 0 ++ #define CFG_BLE_MASTER_SCA 0 +#endif /** * LsSource -@@ -132,21 +149,27 @@ - * - bit 0: 1: Calibration for the RF system wakeup clock source 0: No calibration for the RF system wakeup clock source - * - bit 1: 1: STM32W5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module +@@ -130,21 +150,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_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_MOD5MM_DEV) +- #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_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_OTHER_DEV) -+#ifndef CFG_BLE_LSE_SOURCE +- #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_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_MOD5MM_DEV) ++ #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_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_OTHER_DEV) ++ #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 @@ -160,7 +135,7 @@ index 54f824a..91672ac 100644 */ -#define CFG_BLE_HSE_STARTUP_TIME 0x148 +#ifndef CFG_BLE_HSE_STARTUP_TIME -+ #define CFG_BLE_HSE_STARTUP_TIME 0x148 ++ #define CFG_BLE_HSE_STARTUP_TIME 0x148 +#endif /** @@ -168,18 +143,11 @@ index 54f824a..91672ac 100644 */ -#define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) +#ifndef CFG_BLE_MAX_CONN_EVENT_LENGTH -+ #define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) ++ #define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) +#endif /** * Viterbi Mode -@@ -234,5 +257,5 @@ - - #define CFG_BLE_RX_PATH_COMPENS (0) - --#endif /*APP_CONF_H */ -+#endif /* APP_CONF_DEFAULT_H */ - -- -2.33.0.windows.1 +2.38.0.windows.1 From 2d60f4511b08f8ffa4cc2414a57aa12b96337208 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 13 Dec 2022 15:34:50 +0100 Subject: [PATCH 43/58] chore: update STM32Cube_FW from Cube version v1.15.0 Signed-off-by: Frederic Pillon --- src/utility/STM32Cube_FW/README.md | 4 +- src/utility/STM32Cube_FW/app_conf_default.h | 524 ++++++++++++++++--- src/utility/STM32Cube_FW/ble_bufsize.h | 37 +- src/utility/STM32Cube_FW/hw.h | 28 +- src/utility/STM32Cube_FW/hw_ipcc.c | 184 ++++++- src/utility/STM32Cube_FW/mbox_def.h | 34 ++ src/utility/STM32Cube_FW/shci.c | 39 +- src/utility/STM32Cube_FW/shci.h | 96 +++- src/utility/STM32Cube_FW/shci_tl.c | 29 +- src/utility/STM32Cube_FW/stm32_wpan_common.h | 39 +- src/utility/STM32Cube_FW/stm_list.c | 11 +- src/utility/STM32Cube_FW/stm_list.h | 4 +- src/utility/STM32Cube_FW/tl.h | 46 +- src/utility/STM32Cube_FW/tl_mbox.c | 143 ++++- 14 files changed, 1048 insertions(+), 170 deletions(-) diff --git a/src/utility/STM32Cube_FW/README.md b/src/utility/STM32Cube_FW/README.md index c9af001e..69041d4c 100644 --- a/src/utility/STM32Cube_FW/README.md +++ b/src/utility/STM32Cube_FW/README.md @@ -1,6 +1,6 @@ ## Source -[STMicroelectronics/STM32CubeWB Release v1.14.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.14.0) -- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.14.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) +[STMicroelectronics/STM32CubeWB Release vv1.15.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/vv1.15.0) +- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/vv1.15.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h index 91672ac9..2606a059 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -1,8 +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 * @@ -15,35 +16,94 @@ * ****************************************************************************** */ +/* 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 + +#include "hw.h" +#include "hw_conf.h" +#include "hw_if.h" +#include "ble_bufsize.h" /****************************************************************************** * Application Config ******************************************************************************/ -/**< generic parameters ******************************************************/ -/* HCI related defines */ +/** + * Define Secure Connections Support + */ +#define CFG_SECURE_NOT_SUPPORTED (0x00) +#define CFG_SECURE_OPTIONAL (0x01) +#define CFG_SECURE_MANDATORY (0x02) -#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 +#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL -#ifndef BLE_SHARED_MEM_BYTE_ORDER - #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST -#endif -#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 +/** + * Define Keypress Notification Support + */ +#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) +#define CFG_KEYPRESS_SUPPORTED (0x01) + +#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED /** - * Define Tx Power + * Numeric Comparison Answers */ -#ifndef CFG_TX_POWER - #define CFG_TX_POWER (0x18) /* -0.15dBm */ -#endif +#define YES (0x01) +#define NO (0x00) + +/** + * Device name configuration for Generic Access Service + */ +#define CFG_GAP_DEVICE_NAME "TEMPLATE" +#define CFG_GAP_DEVICE_NAME_LENGTH (8) + +/** +* Identity root key used to derive LTK and CSRK +*/ +#define CFG_BLE_IRK {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0} + +/** +* Encryption root key used to derive LTK and CSRK +*/ +#define CFG_BLE_ERK {0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21, 0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21} + +/** + * SMPS supply + * SMPS not used when Set to 0 + * SMPS used when Set to 1 + */ +#define CFG_USE_SMPS 0 + +/* USER CODE BEGIN Generic_Parameters */ +/* USER CODE END Generic_Parameters */ + +/**< specific parameters */ +/*****************************************************/ + +/* USER CODE BEGIN Specific_Parameters */ +#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler + +/* USER CODE END Specific_Parameters */ + +/****************************************************************************** + * Information Table + * + * Version + * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version + * [4:7] = branch - 0: Mass Market - x: ... + * [8:15] = Subversion + * [16:23] = Version minor + * [24:31] = Version major + * + ******************************************************************************/ +#define CFG_FW_MAJOR_VERSION (0) +#define CFG_FW_MINOR_VERSION (0) +#define CFG_FW_SUBVERSION (1) +#define CFG_FW_BRANCH (0) +#define CFG_FW_BUILD (0) /****************************************************************************** * BLE Stack @@ -52,17 +112,13 @@ * Maximum number of simultaneous connections that the device will support. * Valid values are from 1 to 8 */ -#ifndef CFG_BLE_NUM_LINK - #define CFG_BLE_NUM_LINK 8 -#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 - #define CFG_BLE_NUM_GATT_SERVICES 8 -#endif +#define CFG_BLE_NUM_GATT_SERVICES 8 /** * Maximum number of Attributes @@ -71,17 +127,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 */ -#ifndef CFG_BLE_NUM_GATT_ATTRIBUTES - #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 -#endif +#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 /** * Maximum supported ATT_MTU size * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#ifndef CFG_BLE_MAX_ATT_MTU - #define CFG_BLE_MAX_ATT_MTU (156) -#endif +#define CFG_BLE_MAX_ATT_MTU (156) /** * Size of the storage area for Attribute values @@ -94,39 +146,29 @@ * The total amount of memory needed is the sum of the above quantities for each attribute. * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE - #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) -#endif +#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) /** * Prepare Write List size in terms of number of packet * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -// #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE - #define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) -#endif +#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) /** * Number of allocated memory blocks * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -// #define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) -#define CFG_BLE_MBLOCK_COUNT (0x79) +#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) /** * 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 Slave mode (ppm value) */ -#ifndef CFG_BLE_SLAVE_SCA - #define CFG_BLE_SLAVE_SCA 500 -#endif +#define CFG_BLE_SLAVE_SCA 500 /** * Sleep clock accuracy in Master mode @@ -139,37 +181,30 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#ifndef CFG_BLE_MASTER_SCA - #define CFG_BLE_MASTER_SCA 0 -#endif +#define CFG_BLE_MASTER_SCA 0 /** * LsSource * Some information for Low speed clock mapped in bits field * - bit 0: 1: Calibration for the RF system wakeup clock source 0: No calibration for the RF system wakeup clock source - * - bit 1: 1: STM32W5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module - */ -#ifndef CFG_BLE_LSE_SOURCE - #if defined(STM32WB5Mxx) - #define CFG_BLE_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_MOD5MM_DEV) - #else - #define CFG_BLE_LSE_SOURCE (SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB | SHCI_C2_BLE_INIT_CFG_BLE_LSE_OTHER_DEV) - #endif + * - 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) #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 Slave 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 @@ -190,8 +225,16 @@ * - SHCI_C2_BLE_INIT_OPTIONS_NO_EXT_ADV * - SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 * - SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2 + * - SHCI_C2_BLE_INIT_OPTIONS_REDUC_GATTDB_NVM + * - SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM + * - SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_USED + * - SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED * - SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_1 * - SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3 + * - SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_WRITABLE + * - SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_READONLY + * - SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_SUPPORTED + * - SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_NOTSUPPORTED * which are used to set following configuration bits: * (bit 0): 1: LL only * 0: LL + host @@ -203,11 +246,19 @@ * 0: extended advertizing not supported * (bit 4): 1: CS Algo #2 supported * 0: CS Algo #2 not supported + * (bit 5): 1: Reduced GATT database in NVM + * 0: Full GATT database in NVM + * (bit 6): 1: GATT caching is used + * 0: GATT caching is not used * (bit 7): 1: LE Power Class 1 * 0: LE Power Class 2-3 + * (bit 8): 1: appearance Writable + * 0: appearance Read-Only + * (bit 9): 1: Enhanced ATT supported + * 0: Enhanced ATT not supported * other bits: reserved (shall be set to 0) */ -#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY) +#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 | SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_READONLY | SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_NOTSUPPORTED) #define CFG_BLE_MAX_COC_INITIATOR_NBR (32) @@ -257,5 +308,348 @@ #define CFG_BLE_RX_PATH_COMPENS (0) -#endif /* APP_CONF_DEFAULT_H */ + /* BLE core version (16-bit signed integer). + * - SHCI_C2_BLE_INIT_BLE_CORE_5_2 + * - SHCI_C2_BLE_INIT_BLE_CORE_5_3 + * which are used to set: 11(5.2), 12(5.3). + */ + +#define CFG_BLE_CORE_VERSION (SHCI_C2_BLE_INIT_BLE_CORE_5_3) + +/****************************************************************************** + * Transport Layer + ******************************************************************************/ +/** + * Queue length of BLE Event + * This parameter defines the number of asynchronous events that can be stored in the HCI layer before + * being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer + * is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large + * enough to store all asynchronous events received in between. + * When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events + * between the HCI command and its event. + * This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small, + * the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting + * for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate + * to the application a HCI command did not receive its command event within 30s (Default HCI Timeout). + */ +#define CFG_TLBLE_EVT_QUEUE_LENGTH 5 +/** + * This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element + * allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager. + * It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will + * never be used) + * It shall be at least 4 to receive the command status event in one frame. + * The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced + * further depending on the application. + */ +#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */ + +#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE ) +/****************************************************************************** + * UART interfaces + ******************************************************************************/ + +/** + * Select UART interfaces + */ +#define CFG_UART_GUI hw_uart1 +#define CFG_DEBUG_TRACE_UART 0 +/****************************************************************************** + * USB interface + ******************************************************************************/ + +/** + * Enable/Disable USB interface + */ +#define CFG_USB_INTERFACE_ENABLE 0 + +/****************************************************************************** + * IPCC interface + ******************************************************************************/ + +/** + * The IPCC is dedicated to the communication between the CPU2 and the CPU1 + * and shall not be modified by the application + * The two following definitions shall not be modified + */ +#define HAL_IPCC_TX_IRQHandler(...) HW_IPCC_Tx_Handler( ) +#define HAL_IPCC_RX_IRQHandler(...) HW_IPCC_Rx_Handler( ) + +/****************************************************************************** + * Low Power + ******************************************************************************/ +/** + * When set to 1, the low power mode is enable + * When set to 0, the device stays in RUN mode + */ +#define CFG_LPM_SUPPORTED 1 + +/****************************************************************************** + * RTC interface + ******************************************************************************/ +#define HAL_RTCEx_WakeUpTimerIRQHandler(...) HW_TS_RTC_Wakeup_Handler( ) + +/****************************************************************************** + * Timer Server + ******************************************************************************/ +/** + * CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer. + * The lower is the value, the better is the power consumption and the accuracy of the timerserver + * The higher is the value, the finest is the granularity + * + * CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to output + * clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding + * the wakeup timer. A lower clock speed would impact the accuracy of the timer server. + * + * CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC. + * When the 1Hz calendar clock is required, it shall be sets according to other settings + * When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE) + * + * CFG_RTCCLK_DIVIDER_CONF: + * Shall be set to either 0,2,4,8,16 + * When set to either 2,4,8,16, the 1Hhz calendar is supported + * When set to 0, the user sets its own configuration + * + * The following settings are computed with LSI as input to the RTC + */ + +#define CFG_RTCCLK_DIVIDER_CONF 0 + +#if (CFG_RTCCLK_DIVIDER_CONF == 0) +/** + * Custom configuration + * It does not support 1Hz calendar + * It divides the RTC CLK by 16 + */ + +#define CFG_RTCCLK_DIV (16) +#define CFG_RTC_WUCKSEL_DIVIDER (0) +#define CFG_RTC_ASYNCH_PRESCALER (0x0F) +#define CFG_RTC_SYNCH_PRESCALER (0x7FFF) + +#else + +#if (CFG_RTCCLK_DIVIDER_CONF == 2) +/** + * It divides the RTC CLK by 2 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (3) +#endif + +#if (CFG_RTCCLK_DIVIDER_CONF == 4) +/** + * It divides the RTC CLK by 4 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (2) +#endif + +#if (CFG_RTCCLK_DIVIDER_CONF == 8) +/** + * It divides the RTC CLK by 8 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (1) +#endif + +#if (CFG_RTCCLK_DIVIDER_CONF == 16) +/** + * It divides the RTC CLK by 16 + */ +#define CFG_RTC_WUCKSEL_DIVIDER (0) +#endif + +#define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF +#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) +#define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 ) + +#endif + +/** tick timer values */ +#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE ) +#define CFG_TS_TICK_VAL_PS DIVR( ((uint64_t)CFG_RTCCLK_DIV * 1e12), (uint64_t)LSE_VALUE ) + +typedef enum +{ + CFG_TIM_PROC_ID_ISR, + /* USER CODE BEGIN CFG_TimProcID_t */ + + /* USER CODE END CFG_TimProcID_t */ +} CFG_TimProcID_t; + +/****************************************************************************** + * Debug + ******************************************************************************/ +/** + * When set, this resets some hw resources to set the device in the same state than the power up + * The FW resets only register that may prevent the FW to run properly + * + * This shall be set to 0 in a final product + * + */ +#define CFG_HW_RESET_BY_FW 1 + +/** + * keep debugger enabled while in any low power mode when set to 1 + * should be set to 0 in production + */ +#define CFG_DEBUGGER_SUPPORTED 0 + +/** + * When set to 1, the traces are enabled in the BLE services + */ +#define CFG_DEBUG_BLE_TRACE 0 + +/** + * Enable or Disable traces in application + */ +#define CFG_DEBUG_APP_TRACE 0 + +#if (CFG_DEBUG_APP_TRACE != 0) +#define APP_DBG_MSG PRINT_MESG_DBG +#else +#define APP_DBG_MSG PRINT_NO_MESG +#endif + +#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) ) +#define CFG_DEBUG_TRACE 1 +#endif + +#if (CFG_DEBUG_TRACE != 0) +#undef CFG_LPM_SUPPORTED +#undef CFG_DEBUGGER_SUPPORTED +#define CFG_LPM_SUPPORTED 0 +#define CFG_DEBUGGER_SUPPORTED 1 +#endif + +/** + * When CFG_DEBUG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number + * When CFG_DEBUG_TRACE_LIGHT is set to 1, only the debug message is output + * + * When both are set to 0, no trace are output + * When both are set to 1, CFG_DEBUG_TRACE_FULL is selected + */ +#define CFG_DEBUG_TRACE_LIGHT 0 +#define CFG_DEBUG_TRACE_FULL 0 + +#if (( CFG_DEBUG_TRACE != 0 ) && ( CFG_DEBUG_TRACE_LIGHT == 0 ) && (CFG_DEBUG_TRACE_FULL == 0)) +#undef CFG_DEBUG_TRACE_FULL +#undef CFG_DEBUG_TRACE_LIGHT +#define CFG_DEBUG_TRACE_FULL 0 +#define CFG_DEBUG_TRACE_LIGHT 1 +#endif + +#if ( CFG_DEBUG_TRACE == 0 ) +#undef CFG_DEBUG_TRACE_FULL +#undef CFG_DEBUG_TRACE_LIGHT +#define CFG_DEBUG_TRACE_FULL 0 +#define CFG_DEBUG_TRACE_LIGHT 0 +#endif + +/** + * When not set, the traces is looping on sending the trace over UART + */ +#define DBG_TRACE_USE_CIRCULAR_QUEUE 1 + +/** + * max buffer Size to queue data traces and max data trace allowed. + * Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined + */ +#define DBG_TRACE_MSG_QUEUE_SIZE 4096 +#define MAX_DBG_TRACE_MSG_SIZE 1024 + +/* USER CODE BEGIN Defines */ +#define CFG_LED_SUPPORTED 1 +#define CFG_BUTTON_SUPPORTED 1 + +#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler +#define PUSH_BUTTON_SW2_EXTI_IRQHandler EXTI0_IRQHandler +#define PUSH_BUTTON_SW3_EXTI_IRQHandler EXTI1_IRQHandler +/* USER CODE END Defines */ + +/****************************************************************************** + * Scheduler + ******************************************************************************/ + +/** + * These are the lists of task id registered to the scheduler + * Each task id shall be in the range [0:31] + * This mechanism allows to implement a generic code in the API TL_BLE_HCI_StatusNot() to comply with + * the requirement that a HCI/ACI command shall never be sent if there is already one pending + */ + +/**< Add in that list all tasks that may send a ACI/HCI command */ +typedef enum +{ + CFG_TASK_BLE_HCI_CMD_ID, + CFG_TASK_SYS_HCI_CMD_ID, + CFG_TASK_HCI_ACL_DATA_ID, + CFG_TASK_SYS_LOCAL_CMD_ID, + CFG_TASK_TX_TO_HOST_ID, + /* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */ + CFG_TASK_SW1_BUTTON_PUSHED_ID, + CFG_TASK_SW2_BUTTON_PUSHED_ID, + CFG_TASK_SW3_BUTTON_PUSHED_ID, + /* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */ + CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */ +} CFG_Task_Id_With_HCI_Cmd_t; + +/**< Add in that list all tasks that never send a ACI/HCI command */ +typedef enum +{ + CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */ + CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID, + /* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */ + + /* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */ + CFG_LAST_TASK_ID_WITH_NO_HCICMD /**< Shall be LAST in the list */ +} CFG_Task_Id_With_NO_HCI_Cmd_t; + +#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITH_NO_HCICMD + +/** + * This is the list of priority required by the application + * Each Id shall be in the range 0..31 + */ +typedef enum +{ + CFG_SCH_PRIO_0, + /* USER CODE BEGIN CFG_SCH_Prio_Id_t */ + + /* USER CODE END CFG_SCH_Prio_Id_t */ +} CFG_SCH_Prio_Id_t; + +/** + * This is a bit mapping over 32bits listing all events id supported in the application + */ +typedef enum +{ + CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID, + /* USER CODE BEGIN CFG_IdleEvt_Id_t */ + + /* USER CODE END CFG_IdleEvt_Id_t */ +} CFG_IdleEvt_Id_t; + +/****************************************************************************** + * LOW POWER + ******************************************************************************/ +/** + * Supported requester to the MCU Low Power Manager - can be increased up to 32 + * It list a bit mapping of all user of the Low Power Manager + */ +typedef enum +{ + CFG_LPM_APP, + CFG_LPM_APP_BLE, + /* USER CODE BEGIN CFG_LPM_Id_t */ + + /* USER CODE END CFG_LPM_Id_t */ +} CFG_LPM_Id_t; + +/****************************************************************************** + * OTP manager + ******************************************************************************/ +#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE + +#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR + +#endif /*APP_CONF_H */ diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h index 247573be..4269fa43 100644 --- a/src/utility/STM32Cube_FW/ble_bufsize.h +++ b/src/utility/STM32Cube_FW/ble_bufsize.h @@ -75,16 +75,9 @@ ((pw) + MAX(BLE_MEM_BLOCK_X_MTU(mtu, n_link), \ BLE_MBLOCKS_SECURE_CONNECTIONS)) -/* - * BLE_DEFAULT_MBLOCKS_COUNT: default memory blocks count - */ -#define BLE_DEFAULT_MBLOCKS_COUNT(n_link) \ - BLE_MBLOCKS_CALC(BLE_DEFAULT_PREP_WRITE_LIST_SIZE, \ - BLE_DEFAULT_MAX_ATT_MTU, n_link) - /* * BLE_FIXED_BUFFER_SIZE_BYTES: - * A part of the RAM, is dynamically allocated by initializing all the pointers + * A part of the RAM, is dynamically allocated by initializing all the pointers * defined in a global context variable "mem_alloc_ctx_p". * This initialization is made in the Dynamic_allocator functions, which * assign a portion of RAM given by the external application to the above @@ -92,39 +85,39 @@ * * The size of this Dynamic RAM is made of 2 main components: * - a part that is parameters-dependent (num of links, GATT buffers, ...), - * and which value is defined by the following macro; + * and which value is made explicit by the following macro; * - a part, that may be considered "fixed", i.e. independent from the above * mentioned parameters. */ #if (BEACON_ONLY != 0) -#define BLE_FIXED_BUFFER_SIZE_BYTES 4076 /* Beacon only */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 4092 /* Beacon only */ #elif (LL_ONLY_BASIC != 0) -#define BLE_FIXED_BUFFER_SIZE_BYTES 5692 /* LL only Basic*/ +#define BLE_FIXED_BUFFER_SIZE_BYTES 5788 /* LL only Basic*/ #elif (LL_ONLY != 0) -#define BLE_FIXED_BUFFER_SIZE_BYTES 5940 /* LL only Full */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 6036 /* LL only Full */ #elif (SLAVE_ONLY != 0) -#define BLE_FIXED_BUFFER_SIZE_BYTES 6204 /* Peripheral only */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 6292 /* Peripheral only */ #elif (BASIC_FEATURES != 0) -#define BLE_FIXED_BUFFER_SIZE_BYTES 6532 /* Basic Features */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 6624 /* Basic Features */ #else -#define BLE_FIXED_BUFFER_SIZE_BYTES 7056 /* Full stack */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 7144 /* Full stack */ #endif /* * BLE_PER_LINK_SIZE_BYTES: additional memory size used per link */ #if (BEACON_ONLY != 0) -#define BLE_PER_LINK_SIZE_BYTES 128 /* Beacon only */ +#define BLE_PER_LINK_SIZE_BYTES 112 /* Beacon only */ #elif (LL_ONLY_BASIC != 0) -#define BLE_PER_LINK_SIZE_BYTES 260 /* LL only Basic */ +#define BLE_PER_LINK_SIZE_BYTES 244 /* LL only Basic */ #elif (LL_ONLY != 0) -#define BLE_PER_LINK_SIZE_BYTES 260 /* LL only Full */ +#define BLE_PER_LINK_SIZE_BYTES 244 /* LL only Full */ #elif (SLAVE_ONLY != 0) -#define BLE_PER_LINK_SIZE_BYTES 392 /* Peripheral only */ +#define BLE_PER_LINK_SIZE_BYTES 336 /* Peripheral only */ #elif (BASIC_FEATURES != 0) -#define BLE_PER_LINK_SIZE_BYTES 440 /* Basic Features */ +#define BLE_PER_LINK_SIZE_BYTES 412 /* Basic Features */ #else -#define BLE_PER_LINK_SIZE_BYTES 444 /* Full stack */ +#define BLE_PER_LINK_SIZE_BYTES 424 /* Full stack */ #endif /* @@ -155,7 +148,7 @@ * Valid values are from 31 to 1650. */ #define BLE_EXT_ADV_BUFFER_SIZE(set_nbr, data_len) \ - (2304 + ((892 + (DIVC(data_len, 207) * 244)) * (set_nbr))) + (2512 + ((892 + (DIVC(data_len, 207) * 244)) * (set_nbr))) /* * BLE_TOTAL_BUFFER_SIZE_GATT: this macro returns the amount of memory, diff --git a/src/utility/STM32Cube_FW/hw.h b/src/utility/STM32Cube_FW/hw.h index fcf04517..503fa2ca 100644 --- a/src/utility/STM32Cube_FW/hw.h +++ b/src/utility/STM32Cube_FW/hw.h @@ -26,21 +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 ); + void HW_IPCC_Rx_Handler( void ); + void HW_IPCC_Tx_Handler( void ); void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); @@ -87,6 +80,23 @@ extern "C" { void HW_IPCC_TRACES_Init( void ); void HW_IPCC_TRACES_EvtNot( void ); + void HW_IPCC_MAC_802_15_4_Init( void ); + void HW_IPCC_MAC_802_15_4_SendCmd( void ); + void HW_IPCC_MAC_802_15_4_SendAck( void ); + void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ); + void HW_IPCC_MAC_802_15_4_EvtNot( void ); + + void HW_IPCC_ZIGBEE_Init( void ); + + void HW_IPCC_ZIGBEE_SendM4RequestToM0(void); /* M4 Request to M0 */ + void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void); /* Request ACK from M0 */ + + void HW_IPCC_ZIGBEE_RecvM0NotifyToM4(void); /* M0 Notify to M4 */ + void HW_IPCC_ZIGBEE_SendM4AckToM0Notify(void); /* Notify ACK from M4 */ + void HW_IPCC_ZIGBEE_RecvM0RequestToM4(void); /* M0 Request to M4 */ + void HW_IPCC_ZIGBEE_SendM4AckToM0Request(void); /* Request ACK from M4 */ + + #ifdef __cplusplus } #endif diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c index 7b9be81a..fd620b85 100644 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ b/src/utility/STM32Cube_FW/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 ---------------------------------------------------------*/ @@ -57,17 +56,34 @@ static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ); static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void ); #endif +#ifdef MAC_802_15_4_WB +static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ); +static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ); +#endif + +#ifdef ZIGBEE_WB +static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ); +static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ); +static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ); +#endif + /* Public function definition -----------------------------------------------*/ /****************************************************************************** * INTERRUPT HANDLER ******************************************************************************/ -void IPCC_C1_RX_IRQHandler(void) +void HW_IPCC_Rx_Handler( void ) { if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL )) { HW_IPCC_SYS_EvtHandler(); } +#ifdef MAC_802_15_4_WB + else if (HW_IPCC_RX_PENDING( HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL )) + { + HW_IPCC_MAC_802_15_4_NotEvtHandler(); + } +#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL )) { @@ -98,6 +114,16 @@ void IPCC_C1_RX_IRQHandler(void) HW_IPCC_LLD_BLE_ReceiveM0CmdHandler(); } #endif /* LLD_TESTS_WB */ +#ifdef ZIGBEE_WB + else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL )) + { + HW_IPCC_ZIGBEE_StackNotifEvtHandler(); + } + else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL )) + { + HW_IPCC_ZIGBEE_StackM0RequestHandler(); + } +#endif /* ZIGBEE_WB */ else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL )) { HW_IPCC_BLE_EvtHandler(); @@ -106,14 +132,22 @@ void IPCC_C1_RX_IRQHandler(void) { HW_IPCC_TRACES_EvtHandler(); } + + return; } -void IPCC_C1_TX_IRQHandler(void) +void HW_IPCC_Tx_Handler( void ) { if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) { HW_IPCC_SYS_CmdEvtHandler(); } +#ifdef MAC_802_15_4_WB + else if (HW_IPCC_TX_PENDING( HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL )) + { + HW_IPCC_MAC_802_15_4_CmdEvtHandler(); + } +#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) { @@ -123,6 +157,12 @@ void IPCC_C1_TX_IRQHandler(void) #ifdef LLD_TESTS_WB // No TX handler for LLD tests #endif /* LLD_TESTS_WB */ +#ifdef ZIGBEE_WB + if (HW_IPCC_TX_PENDING( HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL )) + { + HW_IPCC_ZIGBEE_CmdEvtHandler(); + } +#endif /* ZIGBEE_WB */ else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL )) { HW_IPCC_MM_FreeBufHandler(); @@ -131,8 +171,9 @@ void IPCC_C1_TX_IRQHandler(void) { HW_IPCC_BLE_AclDataEvtHandler(); } -} + return; +} /****************************************************************************** * GENERAL ******************************************************************************/ @@ -223,8 +264,8 @@ static void HW_IPCC_BLE_AclDataEvtHandler( void ) return; } -__WEAK void HW_IPCC_BLE_AclDataAckNot( void ){}; -__WEAK void HW_IPCC_BLE_RxEvtNot( void ){}; +__weak void HW_IPCC_BLE_AclDataAckNot( void ){}; +__weak void HW_IPCC_BLE_RxEvtNot( void ){}; /****************************************************************************** * SYSTEM @@ -262,8 +303,56 @@ static void HW_IPCC_SYS_EvtHandler( void ) return; } -__WEAK void HW_IPCC_SYS_CmdEvtNot( void ){}; -__WEAK void HW_IPCC_SYS_EvtNot( void ){}; +__weak void HW_IPCC_SYS_CmdEvtNot( void ){}; +__weak void HW_IPCC_SYS_EvtNot( void ){}; + +/****************************************************************************** + * MAC 802.15.4 + ******************************************************************************/ +#ifdef MAC_802_15_4_WB +void HW_IPCC_MAC_802_15_4_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + + return; +} + +void HW_IPCC_MAC_802_15_4_SendCmd( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + + return; +} + +void HW_IPCC_MAC_802_15_4_SendAck( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + + return; +} + +static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ) +{ + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); + + HW_IPCC_MAC_802_15_4_CmdEvtNot(); + + return; +} + +static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); + + HW_IPCC_MAC_802_15_4_EvtNot(); + + return; +} +__weak void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ){}; +__weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){}; +#endif /****************************************************************************** * THREAD @@ -335,9 +424,9 @@ static void HW_IPCC_THREAD_CliNotEvtHandler( void ) return; } -__WEAK void HW_IPCC_OT_CmdEvtNot( void ){}; -__WEAK void HW_IPCC_CLI_CmdEvtNot( void ){}; -__WEAK void HW_IPCC_THREAD_EvtNot( void ){}; +__weak void HW_IPCC_OT_CmdEvtNot( void ){}; +__weak void HW_IPCC_CLI_CmdEvtNot( void ){}; +__weak void HW_IPCC_THREAD_EvtNot( void ){}; #endif /* THREAD_WB */ @@ -459,6 +548,74 @@ void HW_IPCC_LLD_BLE_SendRspAck( void ) #endif /* LLD_BLE_WB */ +/****************************************************************************** + * ZIGBEE + ******************************************************************************/ +#ifdef ZIGBEE_WB +void HW_IPCC_ZIGBEE_Init( void ) +{ + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + + return; +} + +void HW_IPCC_ZIGBEE_SendM4RequestToM0( void ) +{ + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + + return; +} + +void HW_IPCC_ZIGBEE_SendM4AckToM0Notify( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + + return; +} + +static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ) +{ + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); + + HW_IPCC_ZIGBEE_RecvAppliAckFromM0(); + + return; +} + +static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); + + HW_IPCC_ZIGBEE_RecvM0NotifyToM4(); + + return; +} + +static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ) +{ + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + + HW_IPCC_ZIGBEE_RecvM0RequestToM4(); + + return; +} + +void HW_IPCC_ZIGBEE_SendM4AckToM0Request( void ) +{ + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); + + return; +} + +__weak void HW_IPCC_ZIGBEE_RecvAppliAckFromM0( void ){}; +__weak void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ){}; +__weak void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ){}; +#endif /* ZIGBEE_WB */ + /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -509,5 +666,4 @@ static void HW_IPCC_TRACES_EvtHandler( void ) return; } -__WEAK void HW_IPCC_TRACES_EvtNot( void ){}; -#endif /* STM32WBxx */ +__weak void HW_IPCC_TRACES_EvtNot( void ){}; diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h index 0c974f8f..68b71f9c 100644 --- a/src/utility/STM32Cube_FW/mbox_def.h +++ b/src/utility/STM32Cube_FW/mbox_def.h @@ -106,6 +106,12 @@ extern "C" { uint8_t *m0cmd_buffer; } MB_BleLldTable_t; + typedef struct + { + uint8_t *notifM0toM4_buffer; + uint8_t *appliCmdM4toM0_buffer; + uint8_t *requestM0toM4_buffer; + } MB_ZigbeeTable_t; /** * msg * [0:7] = cmd/evt @@ -133,6 +139,13 @@ extern "C" { uint8_t *traces_queue; } MB_TracesTable_t; + typedef struct + { + uint8_t *p_cmdrsp_buffer; + uint8_t *p_notack_buffer; + uint8_t *evt_queue; + } MB_Mac_802_15_4_t; + typedef struct { MB_DeviceInfoTable_t *p_device_info_table; @@ -141,6 +154,8 @@ extern "C" { MB_SysTable_t *p_sys_table; MB_MemManagerTable_t *p_mem_manager_table; MB_TracesTable_t *p_traces_table; + MB_Mac_802_15_4_t *p_mac_802_15_4_table; + MB_ZigbeeTable_t *p_zigbee_table; MB_LldTestsTable_t *p_lld_tests_table; MB_BleLldTable_t *p_ble_lld_table; } MB_RefTable_t; @@ -184,6 +199,15 @@ typedef struct * | | * |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------| * | | + * | (ZIGBEE) | + * |----HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL------------>| + * | | + * |----HW_IPCC_ZIGBEE_CMD_CLI_CHANNEL-------------->| + * | | + * |<---HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL-------| + * | | + * |<---HW_IPCC_ZIGBEE_CLI_NOTIF_ACK_CHANNEL---------| + * | | * | (THREAD) | * |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->| * | | @@ -207,6 +231,11 @@ typedef struct * | | * |<---HW_IPCC_BLE_LLD_M0_CMD_CHANNEL---------------| * | | + * | (MAC) | + * |----HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL-------->| + * | | + * |<---HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL| + * | | * | (BUFFER) | * |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>| * | | @@ -224,6 +253,8 @@ typedef struct #define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4 #define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 @@ -235,6 +266,8 @@ typedef struct #define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL LL_IPCC_CHANNEL_3 +#define HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_BLE_LLD_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4 @@ -242,5 +275,6 @@ typedef struct #define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_BLE_LLD_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_BLE_LLD_RSP_CHANNEL LL_IPCC_CHANNEL_5 +#define HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL LL_IPCC_CHANNEL_5 #endif /*__MBOX_H */ diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c index a8475222..301db76d 100644 --- a/src/utility/STM32Cube_FW/shci.c +++ b/src/utility/STM32Cube_FW/shci.c @@ -16,7 +16,7 @@ ****************************************************************************** */ -#if defined(STM32WBxx) + /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -352,6 +352,24 @@ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ) return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } +SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_ZIGBEE_INIT, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ) { /** @@ -509,6 +527,24 @@ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t Fla return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } +SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ) +{ + /** + * Buffer is large enough to hold command complete without payload + */ + uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; + TL_EvtPacket_t * p_rsp; + + p_rsp = (TL_EvtPacket_t *)local_buffer; + + shci_send( SHCI_OPCODE_C2_MAC_802_15_4_INIT, + 0, + 0, + p_rsp ); + + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); +} + SHCI_CmdStatus_t SHCI_C2_Reinit( void ) { /** @@ -703,4 +739,3 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h index 040baced..7ca90210 100644 --- a/src/utility/STM32Cube_FW/shci.h +++ b/src/utility/STM32Cube_FW/shci.h @@ -49,6 +49,7 @@ extern "C" { ERR_BLE_INIT = 0, /* This event is currently not reported by the CPU2 */ ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the CPU1 to control the Thread stack is unknown */ + ERR_ZIGBEE_UNKNOWN_CMD = 200, /* The command send by the CPU1 to control the Zigbee stack is unknown */ } SCHI_SystemErrCode_t; #define SHCI_EVTCODE ( 0xFF ) @@ -101,7 +102,7 @@ extern "C" { /** * SHCI_SUB_EVT_THREAD_NVM_RAM_UPDATE - * This notifies the CPU1 which part of the 'OT NVM RAM' has been updated so that only the modified + * This notifies the CPU1 which part of the OT NVM RAM has been updated so that only the modified * section could be written in Flash/NVM * StartAddress : Start address of the section that has been modified * Size : Size (in bytes) of the section that has been modified @@ -215,7 +216,9 @@ extern "C" { SHCI_OCF_C2_FLASH_STORE_DATA, SHCI_OCF_C2_FLASH_ERASE_DATA, SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, + SHCI_OCF_C2_MAC_802_15_4_INIT, SHCI_OCF_C2_REINIT, + SHCI_OCF_C2_ZIGBEE_INIT, SHCI_OCF_C2_LLD_TESTS_INIT, SHCI_OCF_C2_EXTPA_CONFIG, SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, @@ -492,6 +495,7 @@ extern "C" { * Some information for Low speed clock mapped in bits field * - bit 0: 1: Calibration for the RF system wakeup clock source 0: No calibration for the RF system wakeup clock source * - bit 1: 1: STM32W5M Module device 0: Other devices as STM32WBxx SOC, STM32WB1M module + * - bit 2: 1: HSE/1024 Clock config 0: LSE Clock config */ uint8_t LsSource; @@ -529,7 +533,11 @@ extern "C" { * - bit 2: 1: device name Read-Only 0: device name R/W * - bit 3: 1: extended advertizing supported 0: extended advertizing not supported * - bit 4: 1: CS Algo #2 supported 0: CS Algo #2 not supported - * - bit 7: 1: LE Power Class 1 0: LE Power Classes 2-3 + * - bit 5: 1: Reduced GATT database in NVM 0: Full GATT database in NVM + * - bit 6: 1: GATT caching is used 0: GATT caching is not used + * - bit 7: 1: LE Power Class 1 0: LE Power Classe 2-3 + * - bit 8: 1: appearance Writable 0: appearance Read-Only + * - bit 9: 1: Enhanced ATT supported 0: Enhanced ATT not supported * - other bits: reserved ( shall be set to 0) */ uint8_t Options; @@ -591,6 +599,11 @@ extern "C" { */ int16_t rx_path_compens; + /* BLE core specification version (8-bit unsigned integer). + * values as: 11(5.2), 12(5.3) + */ + uint8_t ble_core_version; + } SHCI_C2_Ble_Init_Cmd_Param_t; typedef PACKED_STRUCT{ @@ -618,22 +631,42 @@ extern "C" { #define SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 (1<<4) #define SHCI_C2_BLE_INIT_OPTIONS_NO_CS_ALGO2 (0<<4) +#define SHCI_C2_BLE_INIT_OPTIONS_REDUC_GATTDB_NVM (1<<5) +#define SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM (0<<5) + +#define SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_USED (1<<6) +#define SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED (0<<6) + #define SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_1 (1<<7) #define SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3 (0<<7) +#define SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_WRITABLE (1<<8) +#define SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_READONLY (0<<8) + +#define SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_SUPPORTED (1<<9) +#define SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_NOTSUPPORTED (0<<9) + /** * RX models configuration */ #define SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_LEGACY (0<<0) #define SHCI_C2_BLE_INIT_RX_MODEL_AGC_RSSI_BLOCKER (1<<0) + /** + * BLE core version + */ +#define SHCI_C2_BLE_INIT_BLE_CORE_5_2 11 +#define SHCI_C2_BLE_INIT_BLE_CORE_5_3 12 + /** * LsSource information */ -#define SHCI_C2_BLE_INIT_CFG_BLE_LSE_NOCALIB (0<<0) -#define SHCI_C2_BLE_INIT_CFG_BLE_LSE_CALIB (1<<0) -#define SHCI_C2_BLE_INIT_CFG_BLE_LSE_OTHER_DEV (0<<1) -#define SHCI_C2_BLE_INIT_CFG_BLE_LSE_MOD5MM_DEV (1<<1) +#define SHCI_C2_BLE_INIT_CFG_BLE_LS_NOCALIB (0<<0) +#define SHCI_C2_BLE_INIT_CFG_BLE_LS_CALIB (1<<0) +#define SHCI_C2_BLE_INIT_CFG_BLE_LS_OTHER_DEV (0<<1) +#define SHCI_C2_BLE_INIT_CFG_BLE_LS_MOD5MM_DEV (1<<1) +#define SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_LSE (0<<2) +#define SHCI_C2_BLE_INIT_CFG_BLE_LS_CLK_HSE_1024 (1<<2) #define SHCI_OPCODE_C2_THREAD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_THREAD_INIT) /** No command parameters */ @@ -645,6 +678,8 @@ extern "C" { { uint8_t thread_config; uint8_t ble_config; + uint8_t mac_802_15_4_config; + uint8_t zigbee_config; } SHCI_C2_DEBUG_TracesConfig_t; typedef PACKED_STRUCT @@ -708,6 +743,8 @@ extern "C" { { BLE_ENABLE, THREAD_ENABLE, + ZIGBEE_ENABLE, + MAC_ENABLE, } SHCI_C2_CONCURRENT_Mode_Param_t; /** No response parameters*/ @@ -730,13 +767,18 @@ extern "C" { { BLE_IP, THREAD_IP, + ZIGBEE_IP, } SHCI_C2_FLASH_Ip_t; /** No response parameters*/ #define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) +#define SHCI_OPCODE_C2_MAC_802_15_4_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_MAC_802_15_4_INIT) + #define SHCI_OPCODE_C2_REINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_REINIT) +#define SHCI_OPCODE_C2_ZIGBEE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_ZIGBEE_INIT) + #define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) #define SHCI_OPCODE_C2_BLE_LLD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_LLD_INIT) @@ -784,6 +826,7 @@ extern "C" { uint32_t BleNvmRamAddress; uint32_t ThreadNvmRamAddress; uint16_t RevisionID; + uint16_t DeviceID; } SHCI_C2_CONFIG_Cmd_Param_t; #define SHCI_OPCODE_C2_802_15_4_DEINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_802_15_4_DEINIT) @@ -801,6 +844,12 @@ extern "C" { #define SHCI_C2_CONFIG_CUT2_1 (0x2001) #define SHCI_C2_CONFIG_CUT2_2 (0x2003) +/** + * Device ID + */ +#define SHCI_C2_CONFIG_STM32WB55xx (0x495) +#define SHCI_C2_CONFIG_STM32WB15xx (0x494) + /** * Config1 * Each definition below may be added together to build the Config1 value @@ -844,7 +893,7 @@ extern "C" { #define FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD (0xA94656B9) /* - * At startup, the information relative to the wireless binary are stored in RAM through a structure defined by + * At startup, the informations relative to the wireless binary are stored in RAM trough a structure defined by * MB_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) * each of those coded on 32 bits as shown on the table below: * @@ -900,6 +949,9 @@ extern "C" { #define INFO_STACK_TYPE_BLE_HCI_EXT_ADV 0x07 #define INFO_STACK_TYPE_THREAD_FTD 0x10 #define INFO_STACK_TYPE_THREAD_MTD 0x11 +#define INFO_STACK_TYPE_ZIGBEE_FFD 0x30 +#define INFO_STACK_TYPE_ZIGBEE_RFD 0x31 +#define INFO_STACK_TYPE_MAC 0x40 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 #define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 #define INFO_STACK_TYPE_802154_LLD_TESTS 0x60 @@ -908,7 +960,12 @@ extern "C" { #define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 #define INFO_STACK_TYPE_BLE_RLV 0x64 #define INFO_STACK_TYPE_802154_RLV 0x65 +#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_STATIC 0x70 +#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_STATIC 0x71 +#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_DYNAMIC 0x78 +#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_DYNAMIC 0x79 #define INFO_STACK_TYPE_RLV 0x80 +#define INFO_STACK_TYPE_BLE_MAC_STATIC 0x90 typedef struct { /** @@ -1082,7 +1139,7 @@ typedef struct { * @brief Starts the LLD tests CLI * * @param param_size : Nb of bytes - * @param p_param : pointer with data to give from M4 to M0 + * @param p_param : pointeur with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ); @@ -1092,11 +1149,20 @@ typedef struct { * @brief Starts the LLD tests BLE * * @param param_size : Nb of bytes - * @param p_param : pointer with data to give from M4 to M0 + * @param p_param : pointeur with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ); + /** + * SHCI_C2_ZIGBEE_Init + * @brief Starts the Zigbee Stack + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ); + /** * SHCI_C2_DEBUG_Init * @brief Starts the Traces @@ -1171,9 +1237,19 @@ typedef struct { */ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn); + + /** + * SHCI_C2_MAC_802_15_4_Init + * @brief Starts the MAC 802.15.4 on M0 + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ); + /** * SHCI_GetWirelessFwInfo - * @brief This function read back the information relative to the wireless binary loaded. + * @brief This function read back the informations relative to the wireless binary loaded. * Refer yourself to MB_WirelessFwInfoTable_t structure to get the significance * of the different parameters returned. * @param pWirelessInfo : Pointer to WirelessFwInfo_t. diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index 678de84d..449b8b16 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -16,15 +16,12 @@ ****************************************************************************** */ -#if defined(STM32WBxx) + /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" -#include - #include "stm_list.h" #include "shci_tl.h" -#include "stm32_def.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,12 +235,11 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { + (void)timeout; + CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; - for (unsigned long start = millis(); (millis() - start) < timeout;) { - if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { - break; - } - } + while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); + return; } @@ -270,4 +252,3 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) return; } -#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h index 5a2b2a55..f407bb98 100644 --- a/src/utility/STM32Cube_FW/stm32_wpan_common.h +++ b/src/utility/STM32Cube_FW/stm32_wpan_common.h @@ -25,9 +25,19 @@ extern "C" { #endif -#define __ASM __asm /*!< asm keyword for GNU Compiler */ -#define __INLINE inline /*!< inline keyword for GNU Compiler */ -#define __STATIC_INLINE static inline +#if defined ( __CC_ARM )||defined (__ARMCC_VERSION) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline +#endif #include #include @@ -130,8 +140,29 @@ extern "C" { /* ----------------------------------- * * Packed usage (compiler dependent) * * ----------------------------------- */ +#undef PACKED__ #undef PACKED_STRUCT -#define PACKED_STRUCT struct __packed + +#if defined ( __CC_ARM ) + #if defined ( __GNUC__ ) + /* GNU extension */ + #define PACKED__ __attribute__((packed)) + #define PACKED_STRUCT struct PACKED__ + #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050U) + #define PACKED__ __attribute__((packed)) + #define PACKED_STRUCT struct PACKED__ + #else + #define PACKED__(TYPE) __packed TYPE + #define PACKED_STRUCT PACKED__(struct) + #endif +#elif defined ( __GNUC__ ) + #define PACKED__ __attribute__((packed)) + #define PACKED_STRUCT struct PACKED__ +#elif defined (__ICCARM__) + #define PACKED_STRUCT __packed struct +#else + #define PACKED_STRUCT __packed struct +#endif #ifdef __cplusplus } diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c index 77dec64f..4c928647 100644 --- a/src/utility/STM32Cube_FW/stm_list.c +++ b/src/utility/STM32Cube_FW/stm_list.c @@ -16,13 +16,13 @@ ****************************************************************************** */ -#if defined(STM32WBxx) + /****************************************************************************** * Include Files ******************************************************************************/ +#include "utilities_common.h" + #include "stm_list.h" -#include "cmsis_gcc.h" -#include "stm32_wpan_common.h" /****************************************************************************** * Function Definitions @@ -33,10 +33,10 @@ void LST_init_head (tListNode * listHead) listHead->prev = listHead; } -bool LST_is_empty (tListNode * listHead) +uint8_t LST_is_empty (tListNode * listHead) { uint32_t primask_bit; - bool return_value; + uint8_t return_value; primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ @@ -204,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/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h index 769c2113..b7c3254c 100644 --- a/src/utility/STM32Cube_FW/stm_list.h +++ b/src/utility/STM32Cube_FW/stm_list.h @@ -21,8 +21,6 @@ #define _STM_LIST_H_ /* Includes ------------------------------------------------------------------*/ -#include "stdint.h" -#include "stdbool.h" #include "stm32_wpan_common.h" typedef PACKED_STRUCT _tListNode { @@ -32,7 +30,7 @@ typedef PACKED_STRUCT _tListNode { void LST_init_head (tListNode * listHead); -bool LST_is_empty (tListNode * listHead); +uint8_t LST_is_empty (tListNode * listHead); void LST_insert_head (tListNode * listHead, tListNode * node); diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h index 678769cb..c199bb21 100644 --- a/src/utility/STM32Cube_FW/tl.h +++ b/src/utility/STM32Cube_FW/tl.h @@ -84,29 +84,32 @@ typedef PACKED_STRUCT } TL_CsEvt_t; /** - * This the payload of TL_Evt_t for a command complete event + * This the payload of TL_Evt_t for a command complete event, only used a pointer */ typedef PACKED_STRUCT { uint8_t numcmd; uint16_t cmdcode; - uint8_t payload[1]; + uint8_t payload[255]; } TL_CcEvt_t; /** - * This the payload of TL_Evt_t for an asynchronous event + * This the payload of TL_Evt_t for an asynchronous event, only used a pointer */ typedef PACKED_STRUCT { uint16_t subevtcode; - uint8_t payload[1]; + uint8_t payload[255]; } TL_AsynchEvt_t; +/** + * This the payload of TL_Evt_t, only used a pointer + */ typedef PACKED_STRUCT { uint8_t evtcode; uint8_t plen; - uint8_t payload[1]; + uint8_t payload[255]; } TL_Evt_t; typedef PACKED_STRUCT @@ -199,6 +202,19 @@ typedef struct uint8_t *p_BleLldM0CmdBuffer; } TL_BLE_LLD_Config_t; +typedef struct +{ + uint8_t *p_Mac_802_15_4_CmdRspBuffer; + uint8_t *p_Mac_802_15_4_NotAckBuffer; +} TL_MAC_802_15_4_Config_t; + +typedef struct +{ + uint8_t *p_ZigbeeOtCmdRspBuffer; + uint8_t *p_ZigbeeNotAckBuffer; + uint8_t *p_ZigbeeNotifRequestBuffer; +} TL_ZIGBEE_Config_t; + /** * @brief Contain the BLE HCI Init Configuration * @{ @@ -292,6 +308,26 @@ void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); void TL_TRACES_Init( void ); void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ); +/****************************************************************************** + * MAC 802.15.4 + ******************************************************************************/ +void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ); +void TL_MAC_802_15_4_SendCmd( void ); +void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); +void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ); +void TL_MAC_802_15_4_SendAck ( void ); + +/****************************************************************************** + * ZIGBEE + ******************************************************************************/ +void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ); +void TL_ZIGBEE_SendM4RequestToM0( void ); +void TL_ZIGBEE_SendM4AckToM0Notify ( void ); +void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ); +void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); +void TL_ZIGBEE_M0RequestReceived(TL_EvtPacket_t * Otbuffer ); +void TL_ZIGBEE_SendM4AckToM0Request(void); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c index a9abb181..fcd7766d 100644 --- a/src/utility/STM32Cube_FW/tl_mbox.c +++ b/src/utility/STM32Cube_FW/tl_mbox.c @@ -16,7 +16,6 @@ ****************************************************************************** */ -#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -52,13 +51,15 @@ 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; +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; /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue; PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)]; -PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode EvtQueue; -PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode SystemEvtQueue; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode EvtQueue; +PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode SystemEvtQueue; static tListNode LocalFreeBufQueue; @@ -96,6 +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; + TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; + TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; HW_IPCC_Init(); return; @@ -449,6 +452,139 @@ void TL_BLE_LLD_SendRspAck( void ) } #endif /* BLE_LLD_WB */ +#ifdef MAC_802_15_4_WB +/****************************************************************************** + * MAC 802.15.4 + ******************************************************************************/ +void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ) +{ + MB_Mac_802_15_4_t * p_mac_802_15_4_table; + + p_mac_802_15_4_table = TL_RefTable.p_mac_802_15_4_table; + + p_mac_802_15_4_table->p_cmdrsp_buffer = p_Config->p_Mac_802_15_4_CmdRspBuffer; + p_mac_802_15_4_table->p_notack_buffer = p_Config->p_Mac_802_15_4_NotAckBuffer; + + HW_IPCC_MAC_802_15_4_Init(); + + return; +} + +void TL_MAC_802_15_4_SendCmd( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; + + HW_IPCC_MAC_802_15_4_SendCmd(); + + return; +} + +void TL_MAC_802_15_4_SendAck ( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_MAC_802_15_4_SendAck(); + + return; +} + +void HW_IPCC_MAC_802_15_4_CmdEvtNot(void) +{ + TL_MAC_802_15_4_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer) ); + + return; +} + +void HW_IPCC_MAC_802_15_4_EvtNot( void ) +{ + TL_MAC_802_15_4_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer) ); + + return; +} + +__WEAK void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; +__WEAK void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){}; +#endif + +#ifdef ZIGBEE_WB +/****************************************************************************** + * ZIGBEE + ******************************************************************************/ +void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ) +{ + MB_ZigbeeTable_t * p_zigbee_table; + + p_zigbee_table = TL_RefTable.p_zigbee_table; + p_zigbee_table->appliCmdM4toM0_buffer = p_Config->p_ZigbeeOtCmdRspBuffer; + p_zigbee_table->notifM0toM4_buffer = p_Config->p_ZigbeeNotAckBuffer; + p_zigbee_table->requestM0toM4_buffer = p_Config->p_ZigbeeNotifRequestBuffer; + + HW_IPCC_ZIGBEE_Init(); + + return; +} + +/* Zigbee M4 to M0 Request */ +void TL_ZIGBEE_SendM4RequestToM0( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4RequestToM0(); + + return; +} + +/* Used to receive an ACK from the M0 */ +void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void) +{ + TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) ); + + return; +} + +/* Zigbee notification from M0 to M4 */ +void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ) +{ + TL_ZIGBEE_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer) ); + + return; +} + +/* Send an ACK to the M0 for a Notification */ +void TL_ZIGBEE_SendM4AckToM0Notify ( void ) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4AckToM0Notify(); + + return; +} + +/* Zigbee M0 to M4 Request */ +void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ) +{ + TL_ZIGBEE_M0RequestReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer) ); + + return; +} + +/* Send an ACK to the M0 for a Request */ +void TL_ZIGBEE_SendM4AckToM0Request(void) +{ + ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; + + HW_IPCC_ZIGBEE_SendM4AckToM0Request(); + + return; +} + + +__WEAK void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; +__WEAK void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){}; +#endif + + + /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -710,4 +846,3 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } -#endif /* STM32WBxx */ From 70812b4e3a184585354f979472a75a648266f53f Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 12 Dec 2022 17:15:26 +0100 Subject: [PATCH 44/58] chore: clean up and adapt STM32Cube_FW sources for STM32duino Signed-off-by: Frederic Pillon --- src/utility/STM32Cube_FW/app_conf_default.h | 442 +------------------ src/utility/STM32Cube_FW/ble_bufsize.h | 7 + src/utility/STM32Cube_FW/hw.h | 28 +- src/utility/STM32Cube_FW/hw_ipcc.c | 218 +-------- src/utility/STM32Cube_FW/mbox_def.h | 34 -- src/utility/STM32Cube_FW/shci.c | 39 +- src/utility/STM32Cube_FW/shci.h | 51 +-- src/utility/STM32Cube_FW/shci_tl.c | 37 +- src/utility/STM32Cube_FW/stm32_wpan_common.h | 39 +- src/utility/STM32Cube_FW/stm_list.c | 15 +- src/utility/STM32Cube_FW/stm_list.h | 4 +- src/utility/STM32Cube_FW/tl.h | 33 -- src/utility/STM32Cube_FW/tl_mbox.c | 143 +----- 13 files changed, 87 insertions(+), 1003 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h index 2606a059..cc8c3e89 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -1,9 +1,8 @@ -/* 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 * @@ -16,94 +15,33 @@ * ****************************************************************************** */ -/* USER CODE END Header */ /* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef APP_CONF_H -#define APP_CONF_H - -#include "hw.h" -#include "hw_conf.h" -#include "hw_if.h" -#include "ble_bufsize.h" +#ifndef APP_CONF_DEFAULT_H +#define APP_CONF_DEFAULT_H /****************************************************************************** * Application Config ******************************************************************************/ -/** - * Define Secure Connections Support - */ -#define CFG_SECURE_NOT_SUPPORTED (0x00) -#define CFG_SECURE_OPTIONAL (0x01) -#define CFG_SECURE_MANDATORY (0x02) - -#define CFG_SC_SUPPORT CFG_SECURE_OPTIONAL - -/** - * Define Keypress Notification Support - */ -#define CFG_KEYPRESS_NOT_SUPPORTED (0x00) -#define CFG_KEYPRESS_SUPPORTED (0x01) - -#define CFG_KEYPRESS_NOTIFICATION_SUPPORT CFG_KEYPRESS_NOT_SUPPORTED +/**< generic parameters ******************************************************/ +/* HCI related defines */ -/** - * Numeric Comparison Answers - */ -#define YES (0x01) -#define NO (0x00) +#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 -/** - * Device name configuration for Generic Access Service - */ -#define CFG_GAP_DEVICE_NAME "TEMPLATE" -#define CFG_GAP_DEVICE_NAME_LENGTH (8) - -/** -* Identity root key used to derive LTK and CSRK -*/ -#define CFG_BLE_IRK {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0} - -/** -* Encryption root key used to derive LTK and CSRK -*/ -#define CFG_BLE_ERK {0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21, 0xFE, 0xDC, 0xBA, 0x09, 0x87, 0x65, 0x43, 0x21} +#ifndef BLE_SHARED_MEM_BYTE_ORDER + #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST +#endif +#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 /** - * SMPS supply - * SMPS not used when Set to 0 - * SMPS used when Set to 1 + * Define Tx Power */ -#define CFG_USE_SMPS 0 - -/* USER CODE BEGIN Generic_Parameters */ -/* USER CODE END Generic_Parameters */ - -/**< specific parameters */ -/*****************************************************/ - -/* USER CODE BEGIN Specific_Parameters */ -#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler - -/* USER CODE END Specific_Parameters */ - -/****************************************************************************** - * Information Table - * - * Version - * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version - * [4:7] = branch - 0: Mass Market - x: ... - * [8:15] = Subversion - * [16:23] = Version minor - * [24:31] = Version major - * - ******************************************************************************/ -#define CFG_FW_MAJOR_VERSION (0) -#define CFG_FW_MINOR_VERSION (0) -#define CFG_FW_SUBVERSION (1) -#define CFG_FW_BRANCH (0) -#define CFG_FW_BUILD (0) +#define CFG_TX_POWER (0x18) /* -0.15dBm */ /****************************************************************************** * BLE Stack @@ -152,13 +90,15 @@ * Prepare Write List size in terms of number of packet * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +// #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) +#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) /** * Number of allocated memory blocks * This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) +// #define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK)) +#define CFG_BLE_MBLOCK_COUNT (0x79) /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. @@ -258,7 +198,7 @@ * 0: Enhanced ATT not supported * other bits: reserved (shall be set to 0) */ -#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 | SHCI_C2_BLE_INIT_OPTIONS_APPEARANCE_READONLY | SHCI_C2_BLE_INIT_OPTIONS_ENHANCED_ATT_NOTSUPPORTED) +#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY) #define CFG_BLE_MAX_COC_INITIATOR_NBR (32) @@ -316,340 +256,4 @@ #define CFG_BLE_CORE_VERSION (SHCI_C2_BLE_INIT_BLE_CORE_5_3) -/****************************************************************************** - * Transport Layer - ******************************************************************************/ -/** - * Queue length of BLE Event - * This parameter defines the number of asynchronous events that can be stored in the HCI layer before - * being reported to the application. When a command is sent to the BLE core coprocessor, the HCI layer - * is waiting for the event with the Num_HCI_Command_Packets set to 1. The receive queue shall be large - * enough to store all asynchronous events received in between. - * When CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE is set to 27, this allow to store three 255 bytes long asynchronous events - * between the HCI command and its event. - * This parameter depends on the value given to CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE. When the queue size is to small, - * the system may hang if the queue is full with asynchronous events and the HCI layer is still waiting - * for a CC/CS event, In that case, the notification TL_BLE_HCI_ToNot() is called to indicate - * to the application a HCI command did not receive its command event within 30s (Default HCI Timeout). - */ -#define CFG_TLBLE_EVT_QUEUE_LENGTH 5 -/** - * This parameter should be set to fit most events received by the HCI layer. It defines the buffer size of each element - * allocated in the queue of received events and can be used to optimize the amount of RAM allocated by the Memory Manager. - * It should not exceed 255 which is the maximum HCI packet payload size (a greater value is a lost of memory as it will - * never be used) - * It shall be at least 4 to receive the command status event in one frame. - * The default value is set to 27 to allow receiving an event of MTU size in a single buffer. This value maybe reduced - * further depending on the application. - */ -#define CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE 255 /**< Set to 255 with the memory manager and the mailbox */ - -#define TL_BLE_EVENT_FRAME_SIZE ( TL_EVT_HDR_SIZE + CFG_TLBLE_MOST_EVENT_PAYLOAD_SIZE ) -/****************************************************************************** - * UART interfaces - ******************************************************************************/ - -/** - * Select UART interfaces - */ -#define CFG_UART_GUI hw_uart1 -#define CFG_DEBUG_TRACE_UART 0 -/****************************************************************************** - * USB interface - ******************************************************************************/ - -/** - * Enable/Disable USB interface - */ -#define CFG_USB_INTERFACE_ENABLE 0 - -/****************************************************************************** - * IPCC interface - ******************************************************************************/ - -/** - * The IPCC is dedicated to the communication between the CPU2 and the CPU1 - * and shall not be modified by the application - * The two following definitions shall not be modified - */ -#define HAL_IPCC_TX_IRQHandler(...) HW_IPCC_Tx_Handler( ) -#define HAL_IPCC_RX_IRQHandler(...) HW_IPCC_Rx_Handler( ) - -/****************************************************************************** - * Low Power - ******************************************************************************/ -/** - * When set to 1, the low power mode is enable - * When set to 0, the device stays in RUN mode - */ -#define CFG_LPM_SUPPORTED 1 - -/****************************************************************************** - * RTC interface - ******************************************************************************/ -#define HAL_RTCEx_WakeUpTimerIRQHandler(...) HW_TS_RTC_Wakeup_Handler( ) - -/****************************************************************************** - * Timer Server - ******************************************************************************/ -/** - * CFG_RTC_WUCKSEL_DIVIDER: This sets the RTCCLK divider to the wakeup timer. - * The lower is the value, the better is the power consumption and the accuracy of the timerserver - * The higher is the value, the finest is the granularity - * - * CFG_RTC_ASYNCH_PRESCALER: This sets the asynchronous prescaler of the RTC. It should as high as possible ( to output - * clock as low as possible) but the output clock should be equal or higher frequency compare to the clock feeding - * the wakeup timer. A lower clock speed would impact the accuracy of the timer server. - * - * CFG_RTC_SYNCH_PRESCALER: This sets the synchronous prescaler of the RTC. - * When the 1Hz calendar clock is required, it shall be sets according to other settings - * When the 1Hz calendar clock is not needed, CFG_RTC_SYNCH_PRESCALER should be set to 0x7FFF (MAX VALUE) - * - * CFG_RTCCLK_DIVIDER_CONF: - * Shall be set to either 0,2,4,8,16 - * When set to either 2,4,8,16, the 1Hhz calendar is supported - * When set to 0, the user sets its own configuration - * - * The following settings are computed with LSI as input to the RTC - */ - -#define CFG_RTCCLK_DIVIDER_CONF 0 - -#if (CFG_RTCCLK_DIVIDER_CONF == 0) -/** - * Custom configuration - * It does not support 1Hz calendar - * It divides the RTC CLK by 16 - */ - -#define CFG_RTCCLK_DIV (16) -#define CFG_RTC_WUCKSEL_DIVIDER (0) -#define CFG_RTC_ASYNCH_PRESCALER (0x0F) -#define CFG_RTC_SYNCH_PRESCALER (0x7FFF) - -#else - -#if (CFG_RTCCLK_DIVIDER_CONF == 2) -/** - * It divides the RTC CLK by 2 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (3) -#endif - -#if (CFG_RTCCLK_DIVIDER_CONF == 4) -/** - * It divides the RTC CLK by 4 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (2) -#endif - -#if (CFG_RTCCLK_DIVIDER_CONF == 8) -/** - * It divides the RTC CLK by 8 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (1) -#endif - -#if (CFG_RTCCLK_DIVIDER_CONF == 16) -/** - * It divides the RTC CLK by 16 - */ -#define CFG_RTC_WUCKSEL_DIVIDER (0) -#endif - -#define CFG_RTCCLK_DIV CFG_RTCCLK_DIVIDER_CONF -#define CFG_RTC_ASYNCH_PRESCALER (CFG_RTCCLK_DIV - 1) -#define CFG_RTC_SYNCH_PRESCALER (DIVR( LSE_VALUE, (CFG_RTC_ASYNCH_PRESCALER+1) ) - 1 ) - -#endif - -/** tick timer values */ -#define CFG_TS_TICK_VAL DIVR( (CFG_RTCCLK_DIV * 1000000), LSE_VALUE ) -#define CFG_TS_TICK_VAL_PS DIVR( ((uint64_t)CFG_RTCCLK_DIV * 1e12), (uint64_t)LSE_VALUE ) - -typedef enum -{ - CFG_TIM_PROC_ID_ISR, - /* USER CODE BEGIN CFG_TimProcID_t */ - - /* USER CODE END CFG_TimProcID_t */ -} CFG_TimProcID_t; - -/****************************************************************************** - * Debug - ******************************************************************************/ -/** - * When set, this resets some hw resources to set the device in the same state than the power up - * The FW resets only register that may prevent the FW to run properly - * - * This shall be set to 0 in a final product - * - */ -#define CFG_HW_RESET_BY_FW 1 - -/** - * keep debugger enabled while in any low power mode when set to 1 - * should be set to 0 in production - */ -#define CFG_DEBUGGER_SUPPORTED 0 - -/** - * When set to 1, the traces are enabled in the BLE services - */ -#define CFG_DEBUG_BLE_TRACE 0 - -/** - * Enable or Disable traces in application - */ -#define CFG_DEBUG_APP_TRACE 0 - -#if (CFG_DEBUG_APP_TRACE != 0) -#define APP_DBG_MSG PRINT_MESG_DBG -#else -#define APP_DBG_MSG PRINT_NO_MESG -#endif - -#if ( (CFG_DEBUG_BLE_TRACE != 0) || (CFG_DEBUG_APP_TRACE != 0) ) -#define CFG_DEBUG_TRACE 1 -#endif - -#if (CFG_DEBUG_TRACE != 0) -#undef CFG_LPM_SUPPORTED -#undef CFG_DEBUGGER_SUPPORTED -#define CFG_LPM_SUPPORTED 0 -#define CFG_DEBUGGER_SUPPORTED 1 -#endif - -/** - * When CFG_DEBUG_TRACE_FULL is set to 1, the trace are output with the API name, the file name and the line number - * When CFG_DEBUG_TRACE_LIGHT is set to 1, only the debug message is output - * - * When both are set to 0, no trace are output - * When both are set to 1, CFG_DEBUG_TRACE_FULL is selected - */ -#define CFG_DEBUG_TRACE_LIGHT 0 -#define CFG_DEBUG_TRACE_FULL 0 - -#if (( CFG_DEBUG_TRACE != 0 ) && ( CFG_DEBUG_TRACE_LIGHT == 0 ) && (CFG_DEBUG_TRACE_FULL == 0)) -#undef CFG_DEBUG_TRACE_FULL -#undef CFG_DEBUG_TRACE_LIGHT -#define CFG_DEBUG_TRACE_FULL 0 -#define CFG_DEBUG_TRACE_LIGHT 1 -#endif - -#if ( CFG_DEBUG_TRACE == 0 ) -#undef CFG_DEBUG_TRACE_FULL -#undef CFG_DEBUG_TRACE_LIGHT -#define CFG_DEBUG_TRACE_FULL 0 -#define CFG_DEBUG_TRACE_LIGHT 0 -#endif - -/** - * When not set, the traces is looping on sending the trace over UART - */ -#define DBG_TRACE_USE_CIRCULAR_QUEUE 1 - -/** - * max buffer Size to queue data traces and max data trace allowed. - * Only Used if DBG_TRACE_USE_CIRCULAR_QUEUE is defined - */ -#define DBG_TRACE_MSG_QUEUE_SIZE 4096 -#define MAX_DBG_TRACE_MSG_SIZE 1024 - -/* USER CODE BEGIN Defines */ -#define CFG_LED_SUPPORTED 1 -#define CFG_BUTTON_SUPPORTED 1 - -#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler -#define PUSH_BUTTON_SW2_EXTI_IRQHandler EXTI0_IRQHandler -#define PUSH_BUTTON_SW3_EXTI_IRQHandler EXTI1_IRQHandler -/* USER CODE END Defines */ - -/****************************************************************************** - * Scheduler - ******************************************************************************/ - -/** - * These are the lists of task id registered to the scheduler - * Each task id shall be in the range [0:31] - * This mechanism allows to implement a generic code in the API TL_BLE_HCI_StatusNot() to comply with - * the requirement that a HCI/ACI command shall never be sent if there is already one pending - */ - -/**< Add in that list all tasks that may send a ACI/HCI command */ -typedef enum -{ - CFG_TASK_BLE_HCI_CMD_ID, - CFG_TASK_SYS_HCI_CMD_ID, - CFG_TASK_HCI_ACL_DATA_ID, - CFG_TASK_SYS_LOCAL_CMD_ID, - CFG_TASK_TX_TO_HOST_ID, - /* USER CODE BEGIN CFG_Task_Id_With_HCI_Cmd_t */ - CFG_TASK_SW1_BUTTON_PUSHED_ID, - CFG_TASK_SW2_BUTTON_PUSHED_ID, - CFG_TASK_SW3_BUTTON_PUSHED_ID, - /* USER CODE END CFG_Task_Id_With_HCI_Cmd_t */ - CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */ -} CFG_Task_Id_With_HCI_Cmd_t; - -/**< Add in that list all tasks that never send a ACI/HCI command */ -typedef enum -{ - CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */ - CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID, - /* USER CODE BEGIN CFG_Task_Id_With_NO_HCI_Cmd_t */ - - /* USER CODE END CFG_Task_Id_With_NO_HCI_Cmd_t */ - CFG_LAST_TASK_ID_WITH_NO_HCICMD /**< Shall be LAST in the list */ -} CFG_Task_Id_With_NO_HCI_Cmd_t; - -#define CFG_TASK_NBR CFG_LAST_TASK_ID_WITH_NO_HCICMD - -/** - * This is the list of priority required by the application - * Each Id shall be in the range 0..31 - */ -typedef enum -{ - CFG_SCH_PRIO_0, - /* USER CODE BEGIN CFG_SCH_Prio_Id_t */ - - /* USER CODE END CFG_SCH_Prio_Id_t */ -} CFG_SCH_Prio_Id_t; - -/** - * This is a bit mapping over 32bits listing all events id supported in the application - */ -typedef enum -{ - CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID, - /* USER CODE BEGIN CFG_IdleEvt_Id_t */ - - /* USER CODE END CFG_IdleEvt_Id_t */ -} CFG_IdleEvt_Id_t; - -/****************************************************************************** - * LOW POWER - ******************************************************************************/ -/** - * Supported requester to the MCU Low Power Manager - can be increased up to 32 - * It list a bit mapping of all user of the Low Power Manager - */ -typedef enum -{ - CFG_LPM_APP, - CFG_LPM_APP_BLE, - /* USER CODE BEGIN CFG_LPM_Id_t */ - - /* USER CODE END CFG_LPM_Id_t */ -} CFG_LPM_Id_t; - -/****************************************************************************** - * OTP manager - ******************************************************************************/ -#define CFG_OTP_BASE_ADDRESS OTP_AREA_BASE - -#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR - -#endif /*APP_CONF_H */ - +#endif /* APP_CONF_DEFAULT_H */ diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h index 4269fa43..cea5da84 100644 --- a/src/utility/STM32Cube_FW/ble_bufsize.h +++ b/src/utility/STM32Cube_FW/ble_bufsize.h @@ -75,6 +75,13 @@ ((pw) + MAX(BLE_MEM_BLOCK_X_MTU(mtu, n_link), \ BLE_MBLOCKS_SECURE_CONNECTIONS)) +/* + * BLE_DEFAULT_MBLOCKS_COUNT: default memory blocks count + */ +#define BLE_DEFAULT_MBLOCKS_COUNT(n_link) \ + BLE_MBLOCKS_CALC(BLE_DEFAULT_PREP_WRITE_LIST_SIZE, \ + BLE_DEFAULT_MAX_ATT_MTU, n_link) + /* * BLE_FIXED_BUFFER_SIZE_BYTES: * A part of the RAM, is dynamically allocated by initializing all the pointers diff --git a/src/utility/STM32Cube_FW/hw.h b/src/utility/STM32Cube_FW/hw.h index 503fa2ca..fcf04517 100644 --- a/src/utility/STM32Cube_FW/hw.h +++ b/src/utility/STM32Cube_FW/hw.h @@ -26,14 +26,21 @@ 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 ); void HW_IPCC_BLE_Init( void ); void HW_IPCC_BLE_SendCmd( void ); @@ -80,23 +87,6 @@ extern "C" { void HW_IPCC_TRACES_Init( void ); void HW_IPCC_TRACES_EvtNot( void ); - void HW_IPCC_MAC_802_15_4_Init( void ); - void HW_IPCC_MAC_802_15_4_SendCmd( void ); - void HW_IPCC_MAC_802_15_4_SendAck( void ); - void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ); - void HW_IPCC_MAC_802_15_4_EvtNot( void ); - - void HW_IPCC_ZIGBEE_Init( void ); - - void HW_IPCC_ZIGBEE_SendM4RequestToM0(void); /* M4 Request to M0 */ - void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void); /* Request ACK from M0 */ - - void HW_IPCC_ZIGBEE_RecvM0NotifyToM4(void); /* M0 Notify to M4 */ - void HW_IPCC_ZIGBEE_SendM4AckToM0Notify(void); /* Notify ACK from M4 */ - void HW_IPCC_ZIGBEE_RecvM0RequestToM4(void); /* M0 Request to M4 */ - void HW_IPCC_ZIGBEE_SendM4AckToM0Request(void); /* Request ACK from M4 */ - - #ifdef __cplusplus } #endif diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c index fd620b85..0c1868f6 100644 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ b/src/utility/STM32Cube_FW/hw_ipcc.c @@ -1,4 +1,3 @@ -/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file hw_ipcc.c @@ -16,10 +15,10 @@ * ****************************************************************************** */ -/* USER CODE END Header */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ -#include "app_common.h" +#include "hw.h" #include "mbox_def.h" /* Global variables ---------------------------------------------------------*/ @@ -56,34 +55,17 @@ static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ); static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void ); #endif -#ifdef MAC_802_15_4_WB -static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ); -static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ); -#endif - -#ifdef ZIGBEE_WB -static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ); -static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ); -static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ); -#endif - /* Public function definition -----------------------------------------------*/ /****************************************************************************** * INTERRUPT HANDLER ******************************************************************************/ -void HW_IPCC_Rx_Handler( void ) +void IPCC_C1_RX_IRQHandler( void ) { if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL )) { HW_IPCC_SYS_EvtHandler(); } -#ifdef MAC_802_15_4_WB - else if (HW_IPCC_RX_PENDING( HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL )) - { - HW_IPCC_MAC_802_15_4_NotEvtHandler(); - } -#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL )) { @@ -114,16 +96,6 @@ void HW_IPCC_Rx_Handler( void ) HW_IPCC_LLD_BLE_ReceiveM0CmdHandler(); } #endif /* LLD_TESTS_WB */ -#ifdef ZIGBEE_WB - else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL )) - { - HW_IPCC_ZIGBEE_StackNotifEvtHandler(); - } - else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL )) - { - HW_IPCC_ZIGBEE_StackM0RequestHandler(); - } -#endif /* ZIGBEE_WB */ else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL )) { HW_IPCC_BLE_EvtHandler(); @@ -132,22 +104,14 @@ void HW_IPCC_Rx_Handler( void ) { HW_IPCC_TRACES_EvtHandler(); } - - return; } -void HW_IPCC_Tx_Handler( void ) +void IPCC_C1_TX_IRQHandler( void ) { if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) { HW_IPCC_SYS_CmdEvtHandler(); } -#ifdef MAC_802_15_4_WB - else if (HW_IPCC_TX_PENDING( HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL )) - { - HW_IPCC_MAC_802_15_4_CmdEvtHandler(); - } -#endif /* MAC_802_15_4_WB */ #ifdef THREAD_WB else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) { @@ -157,12 +121,6 @@ void HW_IPCC_Tx_Handler( void ) #ifdef LLD_TESTS_WB // No TX handler for LLD tests #endif /* LLD_TESTS_WB */ -#ifdef ZIGBEE_WB - if (HW_IPCC_TX_PENDING( HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL )) - { - HW_IPCC_ZIGBEE_CmdEvtHandler(); - } -#endif /* ZIGBEE_WB */ else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL )) { HW_IPCC_MM_FreeBufHandler(); @@ -171,8 +129,6 @@ void HW_IPCC_Tx_Handler( void ) { HW_IPCC_BLE_AclDataEvtHandler(); } - - return; } /****************************************************************************** * GENERAL @@ -204,8 +160,6 @@ void HW_IPCC_Enable( void ) __SEV( ); /* Set the internal event flag and send an event to the CPU2 */ __WFE( ); /* Clear the internal event flag */ LL_PWR_EnableBootC2( ); - - return; } void HW_IPCC_Init( void ) @@ -217,8 +171,6 @@ void HW_IPCC_Init( void ) HAL_NVIC_EnableIRQ(IPCC_C1_RX_IRQn); HAL_NVIC_EnableIRQ(IPCC_C1_TX_IRQn); - - return; } /****************************************************************************** @@ -227,15 +179,11 @@ void HW_IPCC_Init( void ) void HW_IPCC_BLE_Init( void ) { LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_BLE_EVENT_CHANNEL ); - - return; } void HW_IPCC_BLE_SendCmd( void ) { LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_BLE_CMD_CHANNEL ); - - return; } static void HW_IPCC_BLE_EvtHandler( void ) @@ -243,16 +191,12 @@ static void HW_IPCC_BLE_EvtHandler( void ) HW_IPCC_BLE_RxEvtNot(); LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_BLE_EVENT_CHANNEL ); - - return; } void HW_IPCC_BLE_SendAclData( void ) { LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); - - return; } static void HW_IPCC_BLE_AclDataEvtHandler( void ) @@ -260,8 +204,6 @@ static void HW_IPCC_BLE_AclDataEvtHandler( void ) LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); HW_IPCC_BLE_AclDataAckNot(); - - return; } __weak void HW_IPCC_BLE_AclDataAckNot( void ){}; @@ -273,16 +215,12 @@ __weak void HW_IPCC_BLE_RxEvtNot( void ){}; void HW_IPCC_SYS_Init( void ) { LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL ); - - return; } void HW_IPCC_SYS_SendCmd( void ) { LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); - - return; } static void HW_IPCC_SYS_CmdEvtHandler( void ) @@ -290,8 +228,6 @@ static void HW_IPCC_SYS_CmdEvtHandler( void ) LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); HW_IPCC_SYS_CmdEvtNot(); - - return; } static void HW_IPCC_SYS_EvtHandler( void ) @@ -299,61 +235,11 @@ static void HW_IPCC_SYS_EvtHandler( void ) HW_IPCC_SYS_EvtNot(); LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL ); - - return; } __weak void HW_IPCC_SYS_CmdEvtNot( void ){}; __weak void HW_IPCC_SYS_EvtNot( void ){}; -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -#ifdef MAC_802_15_4_WB -void HW_IPCC_MAC_802_15_4_Init( void ) -{ - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -void HW_IPCC_MAC_802_15_4_SendCmd( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - - return; -} - -void HW_IPCC_MAC_802_15_4_SendAck( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - return; -} - -static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void ) -{ - LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ); - - HW_IPCC_MAC_802_15_4_CmdEvtNot(); - - return; -} - -static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ); - - HW_IPCC_MAC_802_15_4_EvtNot(); - - return; -} -__weak void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ){}; -__weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){}; -#endif - /****************************************************************************** * THREAD ******************************************************************************/ @@ -393,8 +279,6 @@ void HW_IPCC_THREAD_CliSendAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); - - return; } static void HW_IPCC_OT_CmdEvtHandler( void ) @@ -402,8 +286,6 @@ static void HW_IPCC_OT_CmdEvtHandler( void ) LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); HW_IPCC_OT_CmdEvtNot(); - - return; } static void HW_IPCC_THREAD_NotEvtHandler( void ) @@ -411,8 +293,6 @@ static void HW_IPCC_THREAD_NotEvtHandler( void ) LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); HW_IPCC_THREAD_EvtNot(); - - return; } static void HW_IPCC_THREAD_CliNotEvtHandler( void ) @@ -420,8 +300,6 @@ static void HW_IPCC_THREAD_CliNotEvtHandler( void ) LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); HW_IPCC_THREAD_CliEvtNot(); - - return; } __weak void HW_IPCC_OT_CmdEvtNot( void ){}; @@ -438,7 +316,6 @@ void HW_IPCC_LLDTESTS_Init( void ) { LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); - return; } void HW_IPCC_LLDTESTS_SendCliCmd( void ) @@ -451,28 +328,24 @@ static void HW_IPCC_LLDTESTS_ReceiveCliRspHandler( void ) { LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); HW_IPCC_LLDTESTS_ReceiveCliRsp(); - return; } void HW_IPCC_LLDTESTS_SendCliRspAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ); - return; } static void HW_IPCC_LLDTESTS_ReceiveM0CmdHandler( void ) { LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); HW_IPCC_LLDTESTS_ReceiveM0Cmd(); - return; } void HW_IPCC_LLDTESTS_SendM0CmdAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ); - return; } __weak void HW_IPCC_LLDTESTS_ReceiveCliRsp( void ){}; __weak void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void ){}; @@ -486,13 +359,11 @@ void HW_IPCC_LLD_BLE_Init( void ) { LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); - return; } void HW_IPCC_LLD_BLE_SendCliCmd( void ) { LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CLI_CMD_CHANNEL ); - return; } /*static void HW_IPCC_LLD_BLE_ReceiveCliRspHandler( void ) @@ -506,21 +377,18 @@ void HW_IPCC_LLD_BLE_SendCliRspAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL ); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL ); - return; } static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void ) { //LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); HW_IPCC_LLD_BLE_ReceiveM0Cmd(); - return; } void HW_IPCC_LLD_BLE_SendM0CmdAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); //LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ); - return; } __weak void HW_IPCC_LLD_BLE_ReceiveCliRsp( void ){}; __weak void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ){}; @@ -529,93 +397,22 @@ __weak void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ){}; void HW_IPCC_LLD_BLE_SendCmd( void ) { LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CMD_CHANNEL ); - return; } static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void ) { LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); HW_IPCC_LLD_BLE_ReceiveRsp(); - return; } void HW_IPCC_LLD_BLE_SendRspAck( void ) { LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL ); - return; } #endif /* LLD_BLE_WB */ -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -#ifdef ZIGBEE_WB -void HW_IPCC_ZIGBEE_Init( void ) -{ - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - - return; -} - -void HW_IPCC_ZIGBEE_SendM4RequestToM0( void ) -{ - LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); - LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); - - return; -} - -void HW_IPCC_ZIGBEE_SendM4AckToM0Notify( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - - return; -} - -static void HW_IPCC_ZIGBEE_CmdEvtHandler( void ) -{ - LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ); - - HW_IPCC_ZIGBEE_RecvAppliAckFromM0(); - - return; -} - -static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ); - - HW_IPCC_ZIGBEE_RecvM0NotifyToM4(); - - return; -} - -static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void ) -{ - LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - - HW_IPCC_ZIGBEE_RecvM0RequestToM4(); - - return; -} - -void HW_IPCC_ZIGBEE_SendM4AckToM0Request( void ) -{ - LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ); - - return; -} - -__weak void HW_IPCC_ZIGBEE_RecvAppliAckFromM0( void ){}; -__weak void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ){}; -__weak void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ){}; -#endif /* ZIGBEE_WB */ - /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -632,8 +429,6 @@ void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) ) LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); } - - return; } static void HW_IPCC_MM_FreeBufHandler( void ) @@ -643,8 +438,6 @@ static void HW_IPCC_MM_FreeBufHandler( void ) FreeBufCb(); LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); - - return; } /****************************************************************************** @@ -662,8 +455,7 @@ static void HW_IPCC_TRACES_EvtHandler( void ) HW_IPCC_TRACES_EvtNot(); LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_TRACES_CHANNEL ); - - return; } __weak void HW_IPCC_TRACES_EvtNot( void ){}; +#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h index 68b71f9c..0c974f8f 100644 --- a/src/utility/STM32Cube_FW/mbox_def.h +++ b/src/utility/STM32Cube_FW/mbox_def.h @@ -106,12 +106,6 @@ extern "C" { uint8_t *m0cmd_buffer; } MB_BleLldTable_t; - typedef struct - { - uint8_t *notifM0toM4_buffer; - uint8_t *appliCmdM4toM0_buffer; - uint8_t *requestM0toM4_buffer; - } MB_ZigbeeTable_t; /** * msg * [0:7] = cmd/evt @@ -139,13 +133,6 @@ extern "C" { uint8_t *traces_queue; } MB_TracesTable_t; - typedef struct - { - uint8_t *p_cmdrsp_buffer; - uint8_t *p_notack_buffer; - uint8_t *evt_queue; - } MB_Mac_802_15_4_t; - typedef struct { MB_DeviceInfoTable_t *p_device_info_table; @@ -154,8 +141,6 @@ extern "C" { MB_SysTable_t *p_sys_table; MB_MemManagerTable_t *p_mem_manager_table; MB_TracesTable_t *p_traces_table; - MB_Mac_802_15_4_t *p_mac_802_15_4_table; - MB_ZigbeeTable_t *p_zigbee_table; MB_LldTestsTable_t *p_lld_tests_table; MB_BleLldTable_t *p_ble_lld_table; } MB_RefTable_t; @@ -199,15 +184,6 @@ typedef struct * | | * |<---HW_IPCC_SYSTEM_EVENT_CHANNEL-----------------| * | | - * | (ZIGBEE) | - * |----HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL------------>| - * | | - * |----HW_IPCC_ZIGBEE_CMD_CLI_CHANNEL-------------->| - * | | - * |<---HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL-------| - * | | - * |<---HW_IPCC_ZIGBEE_CLI_NOTIF_ACK_CHANNEL---------| - * | | * | (THREAD) | * |----HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL----------->| * | | @@ -231,11 +207,6 @@ typedef struct * | | * |<---HW_IPCC_BLE_LLD_M0_CMD_CHANNEL---------------| * | | - * | (MAC) | - * |----HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL-------->| - * | | - * |<---HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL| - * | | * | (BUFFER) | * |----HW_IPCC_MM_RELEASE_BUFFER_CHANNE------------>| * | | @@ -253,8 +224,6 @@ typedef struct #define HW_IPCC_BLE_CMD_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_MM_RELEASE_BUFFER_CHANNEL LL_IPCC_CHANNEL_4 #define HW_IPCC_THREAD_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL LL_IPCC_CHANNEL_5 @@ -266,8 +235,6 @@ typedef struct #define HW_IPCC_BLE_EVENT_CHANNEL LL_IPCC_CHANNEL_1 #define HW_IPCC_SYSTEM_EVENT_CHANNEL LL_IPCC_CHANNEL_2 #define HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL LL_IPCC_CHANNEL_3 -#define HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_LLDTESTS_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_BLE_LLD_M0_CMD_CHANNEL LL_IPCC_CHANNEL_3 #define HW_IPCC_TRACES_CHANNEL LL_IPCC_CHANNEL_4 @@ -275,6 +242,5 @@ typedef struct #define HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_BLE_LLD_CLI_RSP_CHANNEL LL_IPCC_CHANNEL_5 #define HW_IPCC_BLE_LLD_RSP_CHANNEL LL_IPCC_CHANNEL_5 -#define HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL LL_IPCC_CHANNEL_5 #endif /*__MBOX_H */ diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c index 301db76d..a8475222 100644 --- a/src/utility/STM32Cube_FW/shci.c +++ b/src/utility/STM32Cube_FW/shci.c @@ -16,7 +16,7 @@ ****************************************************************************** */ - +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" @@ -352,24 +352,6 @@ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ) return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t * p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send( SHCI_OPCODE_C2_ZIGBEE_INIT, - 0, - 0, - p_rsp ); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); -} - SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ) { /** @@ -527,24 +509,6 @@ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t Fla return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ) -{ - /** - * Buffer is large enough to hold command complete without payload - */ - uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t * p_rsp; - - p_rsp = (TL_EvtPacket_t *)local_buffer; - - shci_send( SHCI_OPCODE_C2_MAC_802_15_4_INIT, - 0, - 0, - p_rsp ); - - return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); -} - SHCI_CmdStatus_t SHCI_C2_Reinit( void ) { /** @@ -739,3 +703,4 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) return (SHCI_Success); } +#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h index 7ca90210..a0f1e4d2 100644 --- a/src/utility/STM32Cube_FW/shci.h +++ b/src/utility/STM32Cube_FW/shci.h @@ -49,7 +49,6 @@ extern "C" { ERR_BLE_INIT = 0, /* This event is currently not reported by the CPU2 */ ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the CPU1 to control the Thread stack is unknown */ - ERR_ZIGBEE_UNKNOWN_CMD = 200, /* The command send by the CPU1 to control the Zigbee stack is unknown */ } SCHI_SystemErrCode_t; #define SHCI_EVTCODE ( 0xFF ) @@ -216,9 +215,7 @@ extern "C" { SHCI_OCF_C2_FLASH_STORE_DATA, SHCI_OCF_C2_FLASH_ERASE_DATA, SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, - SHCI_OCF_C2_MAC_802_15_4_INIT, SHCI_OCF_C2_REINIT, - SHCI_OCF_C2_ZIGBEE_INIT, SHCI_OCF_C2_LLD_TESTS_INIT, SHCI_OCF_C2_EXTPA_CONFIG, SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, @@ -436,7 +433,7 @@ extern "C" { * PrWriteListSize * NOTE: This parameter is ignored by the CPU2 when the parameter "Options" is set to "LL_only" ( see Options description in that structure ) * - * Maximum number of supported “prepare write request” + * Maximum number of supported "prepare write request" * - Min value: given by the macro DEFAULT_PREP_WRITE_LIST_SIZE * - Max value: a value higher than the minimum required can be specified, but it is not recommended */ @@ -503,7 +500,7 @@ extern "C" { * MaxConnEventLength * This parameter determines the maximum duration of a slave connection event. When this duration is reached the slave closes * the current connections event (whatever is the CE_length parameter specified by the master in HCI_CREATE_CONNECTION HCI command), - * expressed in units of 625/256 µs (~2.44 µs) + * expressed in units of 625/256 µs (~2.44 µs) * - Min value: 0 (if 0 is specified, the master and slave perform only a single TX-RX exchange per connection event) * - Max value: 1638400 (4000 ms). A higher value can be specified (max 0xFFFFFFFF) but results in a maximum connection time * of 4000 ms as specified. In this case the parameter is not applied, and the predicted CE length calculated on slave is not shortened @@ -512,7 +509,7 @@ extern "C" { /** * HsStartupTime - * Startup time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 µs (~2.44 µs). + * Startup time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 µs (~2.44 µs). * - Min value: 0 * - Max value: 820 (~2 ms). A higher value can be specified, but the value that implemented in stack is forced to ~2 ms */ @@ -678,8 +675,6 @@ extern "C" { { uint8_t thread_config; uint8_t ble_config; - uint8_t mac_802_15_4_config; - uint8_t zigbee_config; } SHCI_C2_DEBUG_TracesConfig_t; typedef PACKED_STRUCT @@ -743,8 +738,6 @@ extern "C" { { BLE_ENABLE, THREAD_ENABLE, - ZIGBEE_ENABLE, - MAC_ENABLE, } SHCI_C2_CONCURRENT_Mode_Param_t; /** No response parameters*/ @@ -767,18 +760,13 @@ extern "C" { { BLE_IP, THREAD_IP, - ZIGBEE_IP, } SHCI_C2_FLASH_Ip_t; /** No response parameters*/ #define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) -#define SHCI_OPCODE_C2_MAC_802_15_4_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_MAC_802_15_4_INIT) - #define SHCI_OPCODE_C2_REINIT (( SHCI_OGF << 10) + SHCI_OCF_C2_REINIT) -#define SHCI_OPCODE_C2_ZIGBEE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_ZIGBEE_INIT) - #define SHCI_OPCODE_C2_LLD_TESTS_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_TESTS_INIT) #define SHCI_OPCODE_C2_BLE_LLD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_LLD_INIT) @@ -893,7 +881,7 @@ extern "C" { #define FUS_DEVICE_INFO_TABLE_VALIDITY_KEYWORD (0xA94656B9) /* - * At startup, the informations relative to the wireless binary are stored in RAM trough a structure defined by + * At startup, the information relative to the wireless binary are stored in RAM through a structure defined by * MB_WirelessFwInfoTable_t.This structure contains 4 fields (Version,MemorySize, Stack_info and a reserved part) * each of those coded on 32 bits as shown on the table below: * @@ -949,9 +937,6 @@ extern "C" { #define INFO_STACK_TYPE_BLE_HCI_EXT_ADV 0x07 #define INFO_STACK_TYPE_THREAD_FTD 0x10 #define INFO_STACK_TYPE_THREAD_MTD 0x11 -#define INFO_STACK_TYPE_ZIGBEE_FFD 0x30 -#define INFO_STACK_TYPE_ZIGBEE_RFD 0x31 -#define INFO_STACK_TYPE_MAC 0x40 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 #define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 #define INFO_STACK_TYPE_802154_LLD_TESTS 0x60 @@ -960,12 +945,7 @@ extern "C" { #define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 #define INFO_STACK_TYPE_BLE_RLV 0x64 #define INFO_STACK_TYPE_802154_RLV 0x65 -#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_STATIC 0x70 -#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_STATIC 0x71 -#define INFO_STACK_TYPE_BLE_ZIGBEE_FFD_DYNAMIC 0x78 -#define INFO_STACK_TYPE_BLE_ZIGBEE_RFD_DYNAMIC 0x79 #define INFO_STACK_TYPE_RLV 0x80 -#define INFO_STACK_TYPE_BLE_MAC_STATIC 0x90 typedef struct { /** @@ -1139,7 +1119,7 @@ typedef struct { * @brief Starts the LLD tests CLI * * @param param_size : Nb of bytes - * @param p_param : pointeur with data to give from M4 to M0 + * @param p_param : pointer with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ); @@ -1149,20 +1129,11 @@ typedef struct { * @brief Starts the LLD tests BLE * * @param param_size : Nb of bytes - * @param p_param : pointeur with data to give from M4 to M0 + * @param p_param : pointer with data to give from M4 to M0 * @retval Status */ SHCI_CmdStatus_t SHCI_C2_BLE_LLD_Init( uint8_t param_size, uint8_t * p_param ); - /** - * SHCI_C2_ZIGBEE_Init - * @brief Starts the Zigbee Stack - * - * @param None - * @retval Status - */ - SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void ); - /** * SHCI_C2_DEBUG_Init * @brief Starts the Traces @@ -1237,16 +1208,6 @@ typedef struct { */ SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn); - - /** - * SHCI_C2_MAC_802_15_4_Init - * @brief Starts the MAC 802.15.4 on M0 - * - * @param None - * @retval Status - */ - SHCI_CmdStatus_t SHCI_C2_MAC_802_15_4_Init( void ); - /** * SHCI_GetWirelessFwInfo * @brief This function read back the informations relative to the wireless binary loaded. diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index 449b8b16..b3cee004 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -16,12 +16,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 @@ -70,8 +71,6 @@ void shci_init(void(* UserEvtRx)(void* pData), void* pConf) shci_register_io_bus (&shciContext.io); TlInit((TL_CmdPacket_t *)(((SHCI_TL_HciInitConf_t *)pConf)->p_cmdbuffer)); - - return; } void shci_user_evt_proc(void) @@ -127,8 +126,6 @@ void shci_user_evt_proc(void) shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); } - - return; } void shci_resume_flow( void ) @@ -140,8 +137,6 @@ void shci_resume_flow( void ) * be called */ shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); - - return; } void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payload, TL_EvtPacket_t * p_rsp ) @@ -164,8 +159,20 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl memcpy( &(p_rsp->evtserial), pCmdBuffer, ((TL_EvtSerial_t*)pCmdBuffer)->evt.plen + TL_EVT_HDR_SIZE ); Cmd_SetStatus(SHCI_TL_CmdAvailable); +} + +void shci_notify_asynch_evt(void *pdata) +{ + UNUSED(pdata); + /* Need to parse data in future version */ + shci_user_evt_proc(); +} - return; +void shci_register_io_bus(tSHciIO *fops) +{ + /* Register IO bus services */ + fops->Init = TL_SYS_Init; + fops->Send = TL_SYS_SendCmd; } /* Private functions ---------------------------------------------------------*/ @@ -190,8 +197,6 @@ static void TlInit( TL_CmdPacket_t * p_cmdbuffer ) Conf.IoBusCallBackUserEvt = TlUserEvtReceived; shciContext.io.Init(&Conf); } - - return; } static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus) @@ -212,24 +217,18 @@ static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus) StatusNotCallBackFunction( SHCI_TL_CmdAvailable ); } } - - return; } static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt) { (void)(shcievt); shci_cmd_resp_release(0); /**< Notify the application the Cmd response has been received */ - - return; } static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) { LST_insert_tail(&SHciAsynchEventQueue, (tListNode *)shcievt); shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); /**< Notify the application a full HCI event has been received */ - - return; } /* Weak implementation ----------------------------------------------------------------*/ @@ -239,8 +238,6 @@ __WEAK void shci_cmd_resp_wait(uint32_t timeout) CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); - - return; } __WEAK void shci_cmd_resp_release(uint32_t flag) @@ -248,7 +245,5 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) (void)flag; CmdRspStatusFlag = SHCI_TL_CMD_RESP_RELEASE; - - return; } - +#endif /* STM32WBxx */ diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h index f407bb98..5a2b2a55 100644 --- a/src/utility/STM32Cube_FW/stm32_wpan_common.h +++ b/src/utility/STM32Cube_FW/stm32_wpan_common.h @@ -25,19 +25,9 @@ extern "C" { #endif -#if defined ( __CC_ARM )||defined (__ARMCC_VERSION) - #define __ASM __asm /*!< asm keyword for ARM Compiler */ - #define __INLINE __inline /*!< inline keyword for ARM Compiler */ - #define __STATIC_INLINE static __inline -#elif defined ( __ICCARM__ ) - #define __ASM __asm /*!< asm keyword for IAR Compiler */ - #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ - #define __STATIC_INLINE static inline -#elif defined ( __GNUC__ ) - #define __ASM __asm /*!< asm keyword for GNU Compiler */ - #define __INLINE inline /*!< inline keyword for GNU Compiler */ - #define __STATIC_INLINE static inline -#endif +#define __ASM __asm /*!< asm keyword for GNU Compiler */ +#define __INLINE inline /*!< inline keyword for GNU Compiler */ +#define __STATIC_INLINE static inline #include #include @@ -140,29 +130,8 @@ extern "C" { /* ----------------------------------- * * Packed usage (compiler dependent) * * ----------------------------------- */ -#undef PACKED__ #undef PACKED_STRUCT - -#if defined ( __CC_ARM ) - #if defined ( __GNUC__ ) - /* GNU extension */ - #define PACKED__ __attribute__((packed)) - #define PACKED_STRUCT struct PACKED__ - #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050U) - #define PACKED__ __attribute__((packed)) - #define PACKED_STRUCT struct PACKED__ - #else - #define PACKED__(TYPE) __packed TYPE - #define PACKED_STRUCT PACKED__(struct) - #endif -#elif defined ( __GNUC__ ) - #define PACKED__ __attribute__((packed)) - #define PACKED_STRUCT struct PACKED__ -#elif defined (__ICCARM__) - #define PACKED_STRUCT __packed struct -#else - #define PACKED_STRUCT __packed struct -#endif +#define PACKED_STRUCT struct __packed #ifdef __cplusplus } diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c index 4c928647..98924414 100644 --- a/src/utility/STM32Cube_FW/stm_list.c +++ b/src/utility/STM32Cube_FW/stm_list.c @@ -16,13 +16,13 @@ ****************************************************************************** */ - +#if defined(STM32WBxx) /****************************************************************************** * Include Files ******************************************************************************/ -#include "utilities_common.h" - #include "stm_list.h" +#include "cmsis_gcc.h" +#include "stm32_wpan_common.h" /****************************************************************************** * Function Definitions @@ -33,20 +33,20 @@ void LST_init_head (tListNode * listHead) listHead->prev = listHead; } -uint8_t LST_is_empty (tListNode * listHead) +bool LST_is_empty (tListNode * listHead) { uint32_t primask_bit; - uint8_t return_value; + bool return_value; primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ if(listHead->next == listHead) { - return_value = TRUE; + return_value = true; } else { - return_value = FALSE; + return_value = false; } __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ @@ -204,3 +204,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/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h index b7c3254c..769c2113 100644 --- a/src/utility/STM32Cube_FW/stm_list.h +++ b/src/utility/STM32Cube_FW/stm_list.h @@ -21,6 +21,8 @@ #define _STM_LIST_H_ /* Includes ------------------------------------------------------------------*/ +#include "stdint.h" +#include "stdbool.h" #include "stm32_wpan_common.h" typedef PACKED_STRUCT _tListNode { @@ -30,7 +32,7 @@ typedef PACKED_STRUCT _tListNode { void LST_init_head (tListNode * listHead); -uint8_t LST_is_empty (tListNode * listHead); +bool LST_is_empty (tListNode * listHead); void LST_insert_head (tListNode * listHead, tListNode * node); diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h index c199bb21..982bb586 100644 --- a/src/utility/STM32Cube_FW/tl.h +++ b/src/utility/STM32Cube_FW/tl.h @@ -202,19 +202,6 @@ typedef struct uint8_t *p_BleLldM0CmdBuffer; } TL_BLE_LLD_Config_t; -typedef struct -{ - uint8_t *p_Mac_802_15_4_CmdRspBuffer; - uint8_t *p_Mac_802_15_4_NotAckBuffer; -} TL_MAC_802_15_4_Config_t; - -typedef struct -{ - uint8_t *p_ZigbeeOtCmdRspBuffer; - uint8_t *p_ZigbeeNotAckBuffer; - uint8_t *p_ZigbeeNotifRequestBuffer; -} TL_ZIGBEE_Config_t; - /** * @brief Contain the BLE HCI Init Configuration * @{ @@ -308,26 +295,6 @@ void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); void TL_TRACES_Init( void ); void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ); -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ); -void TL_MAC_802_15_4_SendCmd( void ); -void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); -void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ); -void TL_MAC_802_15_4_SendAck ( void ); - -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ); -void TL_ZIGBEE_SendM4RequestToM0( void ); -void TL_ZIGBEE_SendM4AckToM0Notify ( void ); -void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ); -void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); -void TL_ZIGBEE_M0RequestReceived(TL_EvtPacket_t * Otbuffer ); -void TL_ZIGBEE_SendM4AckToM0Request(void); - #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c index fcd7766d..a9abb181 100644 --- a/src/utility/STM32Cube_FW/tl_mbox.c +++ b/src/utility/STM32Cube_FW/tl_mbox.c @@ -16,6 +16,7 @@ ****************************************************************************** */ +#if defined(STM32WBxx) /* Includes ------------------------------------------------------------------*/ #include "stm32_wpan_common.h" #include "hw.h" @@ -51,15 +52,13 @@ 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; -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; /**< tables */ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue; PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode TracesEvtQueue; PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t CsBuffer[sizeof(TL_PacketHeader_t) + TL_EVT_HDR_SIZE + sizeof(TL_CsEvt_t)]; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode EvtQueue; -PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode SystemEvtQueue; +PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode EvtQueue; +PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode SystemEvtQueue; static tListNode LocalFreeBufQueue; @@ -97,8 +96,6 @@ 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; - TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table; - TL_RefTable.p_zigbee_table = &TL_Zigbee_Table; HW_IPCC_Init(); return; @@ -452,139 +449,6 @@ void TL_BLE_LLD_SendRspAck( void ) } #endif /* BLE_LLD_WB */ -#ifdef MAC_802_15_4_WB -/****************************************************************************** - * MAC 802.15.4 - ******************************************************************************/ -void TL_MAC_802_15_4_Init( TL_MAC_802_15_4_Config_t *p_Config ) -{ - MB_Mac_802_15_4_t * p_mac_802_15_4_table; - - p_mac_802_15_4_table = TL_RefTable.p_mac_802_15_4_table; - - p_mac_802_15_4_table->p_cmdrsp_buffer = p_Config->p_Mac_802_15_4_CmdRspBuffer; - p_mac_802_15_4_table->p_notack_buffer = p_Config->p_Mac_802_15_4_NotAckBuffer; - - HW_IPCC_MAC_802_15_4_Init(); - - return; -} - -void TL_MAC_802_15_4_SendCmd( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; - - HW_IPCC_MAC_802_15_4_SendCmd(); - - return; -} - -void TL_MAC_802_15_4_SendAck ( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_MAC_802_15_4_SendAck(); - - return; -} - -void HW_IPCC_MAC_802_15_4_CmdEvtNot(void) -{ - TL_MAC_802_15_4_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_cmdrsp_buffer) ); - - return; -} - -void HW_IPCC_MAC_802_15_4_EvtNot( void ) -{ - TL_MAC_802_15_4_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_mac_802_15_4_table->p_notack_buffer) ); - - return; -} - -__WEAK void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; -__WEAK void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){}; -#endif - -#ifdef ZIGBEE_WB -/****************************************************************************** - * ZIGBEE - ******************************************************************************/ -void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config ) -{ - MB_ZigbeeTable_t * p_zigbee_table; - - p_zigbee_table = TL_RefTable.p_zigbee_table; - p_zigbee_table->appliCmdM4toM0_buffer = p_Config->p_ZigbeeOtCmdRspBuffer; - p_zigbee_table->notifM0toM4_buffer = p_Config->p_ZigbeeNotAckBuffer; - p_zigbee_table->requestM0toM4_buffer = p_Config->p_ZigbeeNotifRequestBuffer; - - HW_IPCC_ZIGBEE_Init(); - - return; -} - -/* Zigbee M4 to M0 Request */ -void TL_ZIGBEE_SendM4RequestToM0( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendM4RequestToM0(); - - return; -} - -/* Used to receive an ACK from the M0 */ -void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void) -{ - TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) ); - - return; -} - -/* Zigbee notification from M0 to M4 */ -void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ) -{ - TL_ZIGBEE_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer) ); - - return; -} - -/* Send an ACK to the M0 for a Notification */ -void TL_ZIGBEE_SendM4AckToM0Notify ( void ) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendM4AckToM0Notify(); - - return; -} - -/* Zigbee M0 to M4 Request */ -void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ) -{ - TL_ZIGBEE_M0RequestReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer) ); - - return; -} - -/* Send an ACK to the M0 for a Request */ -void TL_ZIGBEE_SendM4AckToM0Request(void) -{ - ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; - - HW_IPCC_ZIGBEE_SendM4AckToM0Request(); - - return; -} - - -__WEAK void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; -__WEAK void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){}; -#endif - - - /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ @@ -846,3 +710,4 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer) return; } +#endif /* STM32WBxx */ From a3c689a99506126587dfd7285c4b198db4a790e5 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 12 Dec 2022 17:17:48 +0100 Subject: [PATCH 45/58] fix: include a timeout when waiting for the cmd_resp Signed-off-by: Frederic Pillon --- src/utility/STM32Cube_FW/shci_tl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index b3cee004..1abd1be9 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -23,6 +23,7 @@ #include "stm_list.h" #include "shci_tl.h" #include "stm32_def.h" +#include "wiring_time.h" /* Private typedef -----------------------------------------------------------*/ typedef enum @@ -234,10 +235,12 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) /* Weak implementation ----------------------------------------------------------------*/ __WEAK void shci_cmd_resp_wait(uint32_t timeout) { - (void)timeout; - CmdRspStatusFlag = SHCI_TL_CMD_RESP_WAIT; - while(CmdRspStatusFlag != SHCI_TL_CMD_RESP_RELEASE); + for (unsigned long start = millis(); (millis() - start) < timeout;) { + if (CmdRspStatusFlag == SHCI_TL_CMD_RESP_RELEASE) { + break; + } + } } __WEAK void shci_cmd_resp_release(uint32_t flag) From fb82a698e41bd8e75507e6886e7b03e71d0e53c8 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 12 Dec 2022 17:29:27 +0100 Subject: [PATCH 46/58] chore: add support for customize app_conf_default.h Signed-off-by: Frederic Pillon --- src/utility/STM32Cube_FW/app_conf_default.h | 58 +++++++++++++++------ 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h index cc8c3e89..57f1027e 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -41,7 +41,9 @@ /** * Define Tx Power */ -#define CFG_TX_POWER (0x18) /* -0.15dBm */ +#ifndef CFG_TX_POWER + #define CFG_TX_POWER (0x18) /* -0.15dBm */ +#endif /****************************************************************************** * BLE Stack @@ -50,13 +52,17 @@ * 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 + #define CFG_BLE_NUM_LINK 8 +#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 + #define CFG_BLE_NUM_GATT_SERVICES 8 +#endif /** * Maximum number of Attributes @@ -65,13 +71,17 @@ * 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 + #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#endif /** * Maximum supported ATT_MTU size * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#define CFG_BLE_MAX_ATT_MTU (156) +#ifndef CFG_BLE_MAX_ATT_MTU + #define CFG_BLE_MAX_ATT_MTU (156) +#endif /** * Size of the storage area for Attribute values @@ -84,14 +94,18 @@ * The total amount of memory needed is the sum of the above quantities for each attribute. * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) +#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE + #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) +#endif /** * Prepare Write List size in terms of number of packet * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ // #define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) +#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE + #define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) +#endif /** * Number of allocated memory blocks @@ -103,12 +117,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 Slave mode (ppm value) */ -#define CFG_BLE_SLAVE_SCA 500 +#ifndef CFG_BLE_SLAVE_SCA + #define CFG_BLE_SLAVE_SCA 500 +#endif /** * Sleep clock accuracy in Master mode @@ -121,7 +139,9 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ -#define CFG_BLE_MASTER_SCA 0 +#ifndef CFG_BLE_MASTER_SCA + #define CFG_BLE_MASTER_SCA 0 +#endif /** * LsSource @@ -130,21 +150,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 Slave 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 45e49a6ab86ceb9c1a1cc69e411f552a75b26c18 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 13 Dec 2022 10:16:08 +0100 Subject: [PATCH 47/58] chore: rename CFG_BLE_LSE_SOURCE to CFG_BLE_LS_SOURCE Signed-off-by: Frederic Pillon --- src/utility/HCISharedMemTransport.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/HCISharedMemTransport.cpp b/src/utility/HCISharedMemTransport.cpp index e8c422c9..4e2ed2cf 100644 --- a/src/utility/HCISharedMemTransport.cpp +++ b/src/utility/HCISharedMemTransport.cpp @@ -644,7 +644,7 @@ int HCISharedMemTransportClass::stm32wb_start_ble(void) CFG_BLE_MAX_ATT_MTU, CFG_BLE_SLAVE_SCA, CFG_BLE_MASTER_SCA, - CFG_BLE_LSE_SOURCE, + CFG_BLE_LS_SOURCE, CFG_BLE_MAX_CONN_EVENT_LENGTH, CFG_BLE_HSE_STARTUP_TIME, CFG_BLE_VITERBI_MODE, From 23e7407673113b849b598ab0ec592dc5cdd55090 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 13 Dec 2022 10:48:35 +0100 Subject: [PATCH 48/58] chore: add new field initalizer for SHCI_C2_Ble_Init_Cmd_Packet_t Signed-off-by: Frederic Pillon --- src/utility/HCISharedMemTransport.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utility/HCISharedMemTransport.cpp b/src/utility/HCISharedMemTransport.cpp index 4e2ed2cf..e51b5fa6 100644 --- a/src/utility/HCISharedMemTransport.cpp +++ b/src/utility/HCISharedMemTransport.cpp @@ -654,11 +654,11 @@ int HCISharedMemTransportClass::stm32wb_start_ble(void) CFG_BLE_MIN_TX_POWER, CFG_BLE_MAX_TX_POWER, CFG_BLE_RX_MODEL_CONFIG, - CFG_BLE_MAX_ADV_SET_NBR, - CFG_BLE_MAX_ADV_DATA_LEN, - CFG_BLE_TX_PATH_COMPENS, - CFG_BLE_RX_PATH_COMPENS - + CFG_BLE_MAX_ADV_SET_NBR, + CFG_BLE_MAX_ADV_DATA_LEN, + CFG_BLE_TX_PATH_COMPENS, + CFG_BLE_RX_PATH_COMPENS, + CFG_BLE_CORE_VERSION }; /** * Starts the BLE Stack on CPU2 From 731440bb7d96cbad541b60f73392739484a406e9 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 15 Dec 2022 10:51:31 +0100 Subject: [PATCH 49/58] doc: reference STM32WBxx Signed-off-by: Frederic Pillon --- README.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3a0691ab..2413f5c2 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,21 @@ # STM32duinoBLE -This library is a fork of ArduinoBLE library to add the support of SPBTLE-RF and SPBTLE-1S BLE modules. -It was successfully tested with the X-NUCLEO-IDB05A2 or X-NUCLEO-IDB05A1 or X-NUCLEO-BNRG2A1 expansion board and a NUCLEO-F401RE -or NUCLEO-L476RG or NUCLEO-L053R8, with B-L475E-IOT01A and with STEVAL-MKSBOX1V1. -In order to use this library with STEVAL-MKSBOX1V1, you need to update the firmware of the SPBTLE-1S BLE module -mounted on that board as described in the following wiki page: - +This library is a fork of ArduinoBLE library to add the support of STM32WBxx, SPBTLE-RF and SPBTLE-1S BLE modules. +It was successfully tested with the P-NUCELO_WB55RG, STM32WB5MM-DK, X-NUCLEO-IDB05A2 or X-NUCLEO-IDB05A1 or +X-NUCLEO-BNRG2A1 expansion board and a NUCLEO-F401RE or NUCLEO-L476RG or NUCLEO-L053R8, with B-L475E-IOT01A +and with STEVAL-MKSBOX1V1. + + - In order to use this library with SM32WBxx series, you need to update the STM32WB Copro Wireless Binaries +with stm32wbxx_BLE_HCILayer_fw.bin depending of your mcu: +https://github.com/STMicroelectronics/STM32CubeWB/tree/master/Projects/STM32WB_Copro_Wireless_Binaries + Each subdirectories contains binaries and Release_Notes.html which explain how to update it. + + - In order to use this library with STEVAL-MKSBOX1V1, you need to update the firmware of the SPBTLE-1S BLE module +mounted on that board as described in the following wiki page: https://github.com/stm32duino/wiki/wiki/STM32duinoBLE#stm32duinoble-with-steval_mksbox1v1 -In order to use this library with X-NUCLEO-BNRG2A1, you need to update the firmware of the BLUENRG-M2SP BLE module -mounted on that expansion board as described in the following wiki page: - +- In order to use this library with X-NUCLEO-BNRG2A1, you need to update the firmware of the BLUENRG-M2SP BLE module +mounted on that expansion board as described in the following wiki page: https://github.com/stm32duino/wiki/wiki/STM32duinoBLE#stm32duinoble-with-x-nucleo-bnrg2a1 For more information about ArduinoBLE library please visit the official web page at: From 9b49cd60f423b3f1bd545acf959ffda19ae1961c Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 15 Dec 2022 10:52:49 +0100 Subject: [PATCH 50/58] fix: allows space at the end of line of markdown files Signed-off-by: Frederic Pillon --- .editorconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.editorconfig b/.editorconfig index c9b76fd6..c7bf2228 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,6 +5,9 @@ indent_style = space indent_size = 2 trim_trailing_whitespace = true +[*.md] +trim_trailing_whitespace = false + [*.sh] # like -i=2 indent_style = space From daa84754ced0f6f9d8d2aad8c05eedb2ea8eea00 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 15 Dec 2022 11:01:08 +0100 Subject: [PATCH 51/58] ci(codespell): skip STM32Cube_FW directory Signed-off-by: Frederic Pillon --- .github/workflows/codespell.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index 5ea11f42..744a6d2e 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -24,4 +24,5 @@ jobs: check_hidden: true # In the event of a false positive, add the word in all lower case to this file: # ignore_words_file: ./extras/codespell-ignore-words-list.txt - path: src + skip: src/utility/STM32Cube_FW + path: src From 0fe8e71a68e537f84acb1b580f61292f5a631467 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 9 Jan 2023 10:33:24 +0100 Subject: [PATCH 52/58] chore: update app_conf default for STM32WB15xx Signed-off-by: Frederic Pillon --- src/utility/STM32Cube_FW/app_conf_default.h | 32 +++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h index 57f1027e..35cad34f 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -53,16 +53,24 @@ * 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 /** * 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 /** * Maximum number of Attributes @@ -72,7 +80,11 @@ * so this parameters should be 9 plus the number of user Attributes */ #ifndef CFG_BLE_NUM_GATT_ATTRIBUTES - #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#ifdef STM32WB15xx + #define CFG_BLE_NUM_GATT_ATTRIBUTES 30 +#else + #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 +#endif #endif /** @@ -95,8 +107,12 @@ * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ #ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE +#ifdef STM32WB15xx + #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1290) +#else #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) #endif +#endif /** * Prepare Write List size in terms of number of packet @@ -250,8 +266,11 @@ * on Max Extended advertising configuration supported. * 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: @@ -259,8 +278,11 @@ * on Max Extended advertising configuration supported. * 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 From 40dd5bd39392dfac0c4bb90ee7797e0817563461 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 9 Jan 2023 10:36:33 +0100 Subject: [PATCH 53/58] chore: update examples to support Nucleo WB15CC Will be available within stm32 core version higher than 2.4.0. Signed-off-by: Frederic Pillon --- README.md | 6 +++--- examples/Central/LedControl/LedControl.ino | 2 +- examples/Central/PeripheralExplorer/PeripheralExplorer.ino | 2 +- examples/Central/Scan/Scan.ino | 2 +- examples/Central/ScanCallback/ScanCallback.ino | 2 +- examples/Central/SensorTagButton/SensorTagButton.ino | 2 +- examples/Peripheral/ButtonLED/ButtonLED.ino | 2 +- examples/Peripheral/CallbackLED/CallbackLED.ino | 2 +- examples/Peripheral/LED/LED.ino | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2413f5c2..b6e9de98 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # STM32duinoBLE This library is a fork of ArduinoBLE library to add the support of STM32WBxx, SPBTLE-RF and SPBTLE-1S BLE modules. -It was successfully tested with the P-NUCELO_WB55RG, STM32WB5MM-DK, X-NUCLEO-IDB05A2 or X-NUCLEO-IDB05A1 or -X-NUCLEO-BNRG2A1 expansion board and a NUCLEO-F401RE or NUCLEO-L476RG or NUCLEO-L053R8, with B-L475E-IOT01A -and with STEVAL-MKSBOX1V1. +It was successfully tested with the NUCLEO-WB15CC, P-NUCELO_WB55RG, STM32WB5MM-DK, X-NUCLEO-IDB05A2 or +X-NUCLEO-IDB05A1 or X-NUCLEO-BNRG2A1 expansion board and a NUCLEO-F401RE or NUCLEO-L476RG or NUCLEO-L053R8, +with B-L475E-IOT01A and with STEVAL-MKSBOX1V1. - In order to use this library with SM32WBxx series, you need to update the STM32WB Copro Wireless Binaries with stm32wbxx_BLE_HCILayer_fw.bin depending of your mcu: diff --git a/examples/Central/LedControl/LedControl.ino b/examples/Central/LedControl/LedControl.ino index d0f73383..d3450e6d 100644 --- a/examples/Central/LedControl/LedControl.ino +++ b/examples/Central/LedControl/LedControl.ino @@ -43,7 +43,7 @@ BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif const int buttonPin = PC13; // set buttonPin to digital pin PC13 -#elif defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Central/PeripheralExplorer/PeripheralExplorer.ino b/examples/Central/PeripheralExplorer/PeripheralExplorer.ino index ea8b3b24..79ae6618 100644 --- a/examples/Central/PeripheralExplorer/PeripheralExplorer.ino +++ b/examples/Central/PeripheralExplorer/PeripheralExplorer.ino @@ -40,7 +40,7 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Central/Scan/Scan.ino b/examples/Central/Scan/Scan.ino index bd22c65e..edbef56f 100644 --- a/examples/Central/Scan/Scan.ino +++ b/examples/Central/Scan/Scan.ino @@ -37,7 +37,7 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Central/ScanCallback/ScanCallback.ino b/examples/Central/ScanCallback/ScanCallback.ino index dbc2536e..798cc326 100644 --- a/examples/Central/ScanCallback/ScanCallback.ino +++ b/examples/Central/ScanCallback/ScanCallback.ino @@ -39,7 +39,7 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Central/SensorTagButton/SensorTagButton.ino b/examples/Central/SensorTagButton/SensorTagButton.ino index 1831b172..4b3557ac 100644 --- a/examples/Central/SensorTagButton/SensorTagButton.ino +++ b/examples/Central/SensorTagButton/SensorTagButton.ino @@ -41,7 +41,7 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Peripheral/ButtonLED/ButtonLED.ino b/examples/Peripheral/ButtonLED/ButtonLED.ino index f12adb50..0a84b6ac 100644 --- a/examples/Peripheral/ButtonLED/ButtonLED.ino +++ b/examples/Peripheral/ButtonLED/ButtonLED.ino @@ -44,7 +44,7 @@ BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif const int buttonPin = PC13; // set buttonPin to digital pin PC13 -#elif defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Peripheral/CallbackLED/CallbackLED.ino b/examples/Peripheral/CallbackLED/CallbackLED.ino index 363d804b..45632e4f 100644 --- a/examples/Peripheral/CallbackLED/CallbackLED.ino +++ b/examples/Peripheral/CallbackLED/CallbackLED.ino @@ -42,7 +42,7 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); diff --git a/examples/Peripheral/LED/LED.ino b/examples/Peripheral/LED/LED.ino index 48de79d7..9dd92e4d 100644 --- a/examples/Peripheral/LED/LED.ino +++ b/examples/Peripheral/LED/LED.ino @@ -40,7 +40,7 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -#elif defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) +#elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); From 3a116161880f2578617536a76fac0b2ded9fc5b3 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 9 Jan 2023 11:04:22 +0100 Subject: [PATCH 54/58] chore(examples): use USER_BTN if defined Signed-off-by: Frederic Pillon --- examples/Central/LedControl/LedControl.ino | 16 ++++++---------- examples/Central/Scan/Scan.ino | 1 - examples/Central/ScanCallback/ScanCallback.ino | 1 - .../Central/SensorTagButton/SensorTagButton.ino | 3 +-- examples/Peripheral/ButtonLED/ButtonLED.ino | 16 ++++++---------- examples/Peripheral/CallbackLED/CallbackLED.ino | 3 +-- examples/Peripheral/LED/LED.ino | 1 - 7 files changed, 14 insertions(+), 27 deletions(-) diff --git a/examples/Central/LedControl/LedControl.ino b/examples/Central/LedControl/LedControl.ino index d3450e6d..7c090f79 100644 --- a/examples/Central/LedControl/LedControl.ino +++ b/examples/Central/LedControl/LedControl.ino @@ -16,6 +16,12 @@ #include +#ifdef USER_BTN +const int buttonPin = USER_BTN; // set buttonPin to on-board user button +#else +const int buttonPin = PC13; // set buttonPin to digital pin PC13 */ +#endif + #if defined(ARDUINO_STEVAL_MKBOXPRO) /* STEVAL-MKBOXPRO */ SPIClass SpiHCI(PA7, PA6, PA5); @@ -24,7 +30,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000 BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 #elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); @@ -33,7 +38,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PG1; // set buttonPin to digital pin PG1 #elif defined(ARDUINO_B_L475E_IOT01A) || defined(ARDUINO_B_L4S5I_IOT01A) /* B-L475E-IOT01A1 or B_L4S5I_IOT01A */ SPIClass SpiHCI(PC12, PC11, PC10); @@ -42,14 +46,12 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 #elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC4; // set buttonPin to digital pin PC4 #else /* Shield IDB05A2 with SPI clock on D3 */ SPIClass SpiHCI(D11, D12, D3); @@ -58,7 +60,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SP BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 /* Shield IDB05A2 with SPI clock on D13 */ /*#define SpiHCI SPI HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); @@ -66,7 +67,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SP BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 */ /* Shield IDB05A1 with SPI clock on D3 */ /*SPIClass SpiHCI(D11, D12, D3); HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); @@ -74,7 +74,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 */ /* Shield IDB05A1 with SPI clock on D13 */ /*#define SpiHCI SPI HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); @@ -82,7 +81,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 */ /* Shield BNRG2A1 with SPI clock on D3 */ /*SPIClass SpiHCI(D11, D12, D3); HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); @@ -90,7 +88,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 */ /* Shield BNRG2A1 with SPI clock on D13 */ /*#define SpiHCI SPI HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); @@ -98,7 +95,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 */ #endif // variables for button diff --git a/examples/Central/Scan/Scan.ino b/examples/Central/Scan/Scan.ino index edbef56f..2010b31d 100644 --- a/examples/Central/Scan/Scan.ino +++ b/examples/Central/Scan/Scan.ino @@ -20,7 +20,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000 BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 #elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); diff --git a/examples/Central/ScanCallback/ScanCallback.ino b/examples/Central/ScanCallback/ScanCallback.ino index 798cc326..e4067a45 100644 --- a/examples/Central/ScanCallback/ScanCallback.ino +++ b/examples/Central/ScanCallback/ScanCallback.ino @@ -22,7 +22,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000 BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 #elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); diff --git a/examples/Central/SensorTagButton/SensorTagButton.ino b/examples/Central/SensorTagButton/SensorTagButton.ino index 4b3557ac..d4c740cc 100644 --- a/examples/Central/SensorTagButton/SensorTagButton.ino +++ b/examples/Central/SensorTagButton/SensorTagButton.ino @@ -24,7 +24,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000 BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 #elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); @@ -216,7 +215,7 @@ void monitorSensorTagButtons(BLEDevice peripheral) { if (simpleKeyCharacteristic.valueUpdated()) { // yes, get the value, characteristic is 1 byte so use byte value byte value = 0; - + simpleKeyCharacteristic.readValue(value); if (value & 0x01) { diff --git a/examples/Peripheral/ButtonLED/ButtonLED.ino b/examples/Peripheral/ButtonLED/ButtonLED.ino index 0a84b6ac..91dfcb2a 100644 --- a/examples/Peripheral/ButtonLED/ButtonLED.ino +++ b/examples/Peripheral/ButtonLED/ButtonLED.ino @@ -17,6 +17,12 @@ #include +#ifdef USER_BTN +const int buttonPin = USER_BTN; // set buttonPin to on-board user button +#else +const int buttonPin = PC13; // set buttonPin to digital pin PC13 */ +#endif + #if defined(ARDUINO_STEVAL_MKBOXPRO) /* STEVAL-MKBOXPRO */ SPIClass SpiHCI(PA7, PA6, PA5); @@ -25,7 +31,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000 BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 #elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); @@ -34,7 +39,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_1S, PD0, PD4, PA8, 1000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PG1; // set buttonPin to digital pin PG1 #elif defined(ARDUINO_B_L475E_IOT01A) || defined(ARDUINO_B_L4S5I_IOT01A) /* B-L475E-IOT01A1 or B_L4S5I_IOT01A */ SPIClass SpiHCI(PC12, PC11, PC10); @@ -43,14 +47,12 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, PD13, PE6, PA8, 8000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 #elif defined(ARDUINO_NUCLEO_WB15CC) || defined(ARDUINO_P_NUCLEO_WB55RG) || defined(ARDUINO_STM32WB5MM_DK) HCISharedMemTransportClass HCISharedMemTransport; #if !defined(FAKE_BLELOCALDEVICE) BLELocalDevice BLEObj(&HCISharedMemTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC4; // set buttonPin to digital pin PC4 #else /* Shield IDB05A2 with SPI clock on D3 */ SPIClass SpiHCI(D11, D12, D3); @@ -59,7 +61,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SP BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 /* Shield IDB05A2 with SPI clock on D13 */ /*#define SpiHCI SPI HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); @@ -67,7 +68,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SP BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 */ /* Shield IDB05A1 with SPI clock on D3 */ /*SPIClass SpiHCI(D11, D12, D3); HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); @@ -75,7 +75,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 */ /* Shield IDB05A1 with SPI clock on D13 */ /*#define SpiHCI SPI HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); @@ -83,7 +82,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 */ /* Shield BNRG2A1 with SPI clock on D3 */ /*SPIClass SpiHCI(D11, D12, D3); HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); @@ -91,7 +89,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 */ /* Shield BNRG2A1 with SPI clock on D13 */ /*#define SpiHCI SPI HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); @@ -99,7 +96,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 */ #endif const int ledPin = LED_BUILTIN; // set ledPin to on-board LED diff --git a/examples/Peripheral/CallbackLED/CallbackLED.ino b/examples/Peripheral/CallbackLED/CallbackLED.ino index 45632e4f..4177a44d 100644 --- a/examples/Peripheral/CallbackLED/CallbackLED.ino +++ b/examples/Peripheral/CallbackLED/CallbackLED.ino @@ -25,7 +25,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000 BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 #elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); @@ -103,7 +102,7 @@ const int ledPin = LED_BUILTIN; // pin to use for the LED void setup() { Serial.begin(115200); while (!Serial); - + pinMode(ledPin, OUTPUT); // use the LED pin as an output // begin initialization diff --git a/examples/Peripheral/LED/LED.ino b/examples/Peripheral/LED/LED.ino index 9dd92e4d..487c4287 100644 --- a/examples/Peripheral/LED/LED.ino +++ b/examples/Peripheral/LED/LED.ino @@ -23,7 +23,6 @@ HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_LP, PA2, PB11, PD4, 1000000 BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif -const int buttonPin = PC13; // set buttonPin to digital pin PC13 #elif defined(ARDUINO_STEVAL_MKSBOX1V1) /* STEVAL-MKSBOX1V1 */ SPIClass SpiHCI(PC3, PD3, PD1); From ceb1e6258a8ec86a56f2b3aea273d2a67a927569 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 9 Jan 2023 11:12:06 +0100 Subject: [PATCH 55/58] fix(examples): aligned comments between all examples Signed-off-by: Frederic Pillon --- examples/Central/LedControl/LedControl.ino | 60 +++++++++---------- .../PeripheralExplorer/PeripheralExplorer.ino | 60 +++++++++---------- examples/Central/Scan/Scan.ino | 60 +++++++++---------- .../Central/ScanCallback/ScanCallback.ino | 60 +++++++++---------- .../SensorTagButton/SensorTagButton.ino | 60 +++++++++---------- examples/Peripheral/ButtonLED/ButtonLED.ino | 60 +++++++++---------- .../Peripheral/CallbackLED/CallbackLED.ino | 60 +++++++++---------- examples/Peripheral/LED/LED.ino | 60 +++++++++---------- 8 files changed, 240 insertions(+), 240 deletions(-) diff --git a/examples/Central/LedControl/LedControl.ino b/examples/Central/LedControl/LedControl.ino index 7c090f79..09939cde 100644 --- a/examples/Central/LedControl/LedControl.ino +++ b/examples/Central/LedControl/LedControl.ino @@ -61,40 +61,40 @@ BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif /* Shield IDB05A2 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif #endif // variables for button diff --git a/examples/Central/PeripheralExplorer/PeripheralExplorer.ino b/examples/Central/PeripheralExplorer/PeripheralExplorer.ino index 79ae6618..09e204f6 100644 --- a/examples/Central/PeripheralExplorer/PeripheralExplorer.ino +++ b/examples/Central/PeripheralExplorer/PeripheralExplorer.ino @@ -55,40 +55,40 @@ BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif /* Shield IDB05A2 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif #endif void setup() { diff --git a/examples/Central/Scan/Scan.ino b/examples/Central/Scan/Scan.ino index 2010b31d..14ea9f13 100644 --- a/examples/Central/Scan/Scan.ino +++ b/examples/Central/Scan/Scan.ino @@ -51,40 +51,40 @@ BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif /* Shield IDB05A2 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif #endif void setup() { diff --git a/examples/Central/ScanCallback/ScanCallback.ino b/examples/Central/ScanCallback/ScanCallback.ino index e4067a45..199b8a34 100644 --- a/examples/Central/ScanCallback/ScanCallback.ino +++ b/examples/Central/ScanCallback/ScanCallback.ino @@ -53,40 +53,40 @@ BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif /* Shield IDB05A2 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif #endif void setup() { diff --git a/examples/Central/SensorTagButton/SensorTagButton.ino b/examples/Central/SensorTagButton/SensorTagButton.ino index d4c740cc..6a097c70 100644 --- a/examples/Central/SensorTagButton/SensorTagButton.ino +++ b/examples/Central/SensorTagButton/SensorTagButton.ino @@ -55,40 +55,40 @@ BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif /* Shield IDB05A2 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif #endif void setup() { diff --git a/examples/Peripheral/ButtonLED/ButtonLED.ino b/examples/Peripheral/ButtonLED/ButtonLED.ino index 91dfcb2a..3163cf6a 100644 --- a/examples/Peripheral/ButtonLED/ButtonLED.ino +++ b/examples/Peripheral/ButtonLED/ButtonLED.ino @@ -62,40 +62,40 @@ BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif /* Shield IDB05A2 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif #endif const int ledPin = LED_BUILTIN; // set ledPin to on-board LED diff --git a/examples/Peripheral/CallbackLED/CallbackLED.ino b/examples/Peripheral/CallbackLED/CallbackLED.ino index 4177a44d..5b416fbb 100644 --- a/examples/Peripheral/CallbackLED/CallbackLED.ino +++ b/examples/Peripheral/CallbackLED/CallbackLED.ino @@ -56,40 +56,40 @@ BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif /* Shield IDB05A2 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif #endif BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // create service diff --git a/examples/Peripheral/LED/LED.ino b/examples/Peripheral/LED/LED.ino index 487c4287..32cbfc9f 100644 --- a/examples/Peripheral/LED/LED.ino +++ b/examples/Peripheral/LED/LED.ino @@ -54,40 +54,40 @@ BLELocalDevice BLEObj(&HCISpiTransport); BLELocalDevice& BLE = BLEObj; #endif /* Shield IDB05A2 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M0, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield IDB05A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, SPBTLE_RF, A1, A0, D7, 8000000, SPI_MODE0); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D3 */ -/*SPIClass SpiHCI(D11, D12, D3); -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// SPIClass SpiHCI(D11, D12, D3); +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif /* Shield BNRG2A1 with SPI clock on D13 */ -/*#define SpiHCI SPI -HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); -#if !defined(FAKE_BLELOCALDEVICE) -BLELocalDevice BLEObj(&HCISpiTransport); -BLELocalDevice& BLE = BLEObj; -#endif */ +// #define SpiHCI SPI +// HCISpiTransportClass HCISpiTransport(SpiHCI, BLUENRG_M2SP, A1, A0, D7, 1000000, SPI_MODE1); +// #if !defined(FAKE_BLELOCALDEVICE) +// BLELocalDevice BLEObj(&HCISpiTransport); +// BLELocalDevice& BLE = BLEObj; +// #endif #endif BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service From ce6cc8fa0691b983917d7638e32b32da838a51dc Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 9 Jan 2023 11:31:16 +0100 Subject: [PATCH 56/58] fix: regenerate STM32Cube_FW patches due to STM32WB15xx support addition Signed-off-by: Frederic Pillon --- ...nd-adapt-STM32Cube_FW-sources-for-ST.patch | 2 +- ...imeout-when-waiting-for-the-cmd_resp.patch | 2 +- ...ort-for-customize-app_conf_default.h.patch | 66 +++++++++++++++---- 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch b/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch index 8b9ba87d..171554eb 100644 --- a/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch +++ b/extras/STM32Cube_FW/0001-chore-clean-up-and-adapt-STM32Cube_FW-sources-for-ST.patch @@ -1,4 +1,4 @@ -From f72f61b2a895a9f02a338c600af1de239939b357 Mon Sep 17 00:00:00 2001 +From 70812b4e3a184585354f979472a75a648266f53f Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 12 Dec 2022 17:15:26 +0100 Subject: [PATCH 1/3] chore: clean up and adapt STM32Cube_FW sources for diff --git a/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch b/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch index 5f7502df..81ac67fd 100644 --- a/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch +++ b/extras/STM32Cube_FW/0002-fix-include-a-timeout-when-waiting-for-the-cmd_resp.patch @@ -1,4 +1,4 @@ -From e12c9c97eec7eacb648720fc65adc2a3897ec257 Mon Sep 17 00:00:00 2001 +From a3c689a99506126587dfd7285c4b198db4a790e5 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 12 Dec 2022 17:17:48 +0100 Subject: [PATCH 2/3] fix: include a timeout when waiting for the cmd_resp diff --git a/extras/STM32Cube_FW/0003-chore-add-support-for-customize-app_conf_default.h.patch b/extras/STM32Cube_FW/0003-chore-add-support-for-customize-app_conf_default.h.patch index a93713f2..a10fa6e7 100644 --- a/extras/STM32Cube_FW/0003-chore-add-support-for-customize-app_conf_default.h.patch +++ b/extras/STM32Cube_FW/0003-chore-add-support-for-customize-app_conf_default.h.patch @@ -1,15 +1,15 @@ -From d7d18d20b957f52810315147d671c1976a18c1d2 Mon Sep 17 00:00:00 2001 +From 81472cc135126cb46701a058647de2cf82160fb9 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 12 Dec 2022 17:29:27 +0100 Subject: [PATCH 3/3] chore: add support for customize app_conf_default.h Signed-off-by: Frederic Pillon --- - src/utility/STM32Cube_FW/app_conf_default.h | 58 +++++++++++++++------ - 1 file changed, 42 insertions(+), 16 deletions(-) + src/utility/STM32Cube_FW/app_conf_default.h | 88 ++++++++++++++++----- + 1 file changed, 68 insertions(+), 20 deletions(-) diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h -index cc8c3e8..57f1027 100644 +index cc8c3e8..35cad34 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -41,7 +41,9 @@ @@ -23,13 +23,17 @@ index cc8c3e8..57f1027 100644 /****************************************************************************** * BLE Stack -@@ -50,13 +52,17 @@ +@@ -50,13 +52,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 /** @@ -38,18 +42,26 @@ index cc8c3e8..57f1027 100644 */ -#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 -@@ -65,13 +71,17 @@ +@@ -65,13 +79,21 @@ * 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 -+ #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 ++#ifdef STM32WB15xx ++ #define CFG_BLE_NUM_GATT_ATTRIBUTES 30 ++#else ++ #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 ++#endif +#endif /** @@ -63,13 +75,17 @@ index cc8c3e8..57f1027 100644 /** * Size of the storage area for Attribute values -@@ -84,14 +94,18 @@ +@@ -84,14 +106,22 @@ * The total amount of memory needed is the sum of the above quantities for each attribute. * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set */ -#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) +#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE ++#ifdef STM32WB15xx ++ #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1290) ++#else + #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) ++#endif +#endif /** @@ -84,7 +100,7 @@ index cc8c3e8..57f1027 100644 /** * Number of allocated memory blocks -@@ -103,12 +117,16 @@ +@@ -103,12 +133,16 @@ /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. */ @@ -103,7 +119,7 @@ index cc8c3e8..57f1027 100644 /** * Sleep clock accuracy in Master mode -@@ -121,7 +139,9 @@ +@@ -121,7 +155,9 @@ * 6 : 21 ppm to 30 ppm * 7 : 0 ppm to 20 ppm */ @@ -114,7 +130,7 @@ index cc8c3e8..57f1027 100644 /** * LsSource -@@ -130,21 +150,27 @@ +@@ -130,21 +166,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 */ @@ -148,6 +164,34 @@ index cc8c3e8..57f1027 100644 /** * Viterbi Mode +@@ -224,8 +266,11 @@ + * on Max Extended advertising configuration supported. + * 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: +@@ -233,8 +278,11 @@ + * on Max Extended advertising configuration supported. + * 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 -- 2.38.0.windows.1 From b5a70eb5cab31e4f768310157c2e25da0c582c13 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 9 Jan 2023 11:49:52 +0100 Subject: [PATCH 57/58] chore(examples): update circuit description Signed-off-by: Frederic Pillon --- examples/Central/LedControl/LedControl.ino | 12 +++++++++++- .../PeripheralExplorer/PeripheralExplorer.ino | 12 +++++++++++- examples/Central/Scan/Scan.ino | 12 +++++++++++- examples/Central/ScanCallback/ScanCallback.ino | 12 +++++++++++- examples/Central/SensorTagButton/SensorTagButton.ino | 12 +++++++++++- examples/Peripheral/ButtonLED/ButtonLED.ino | 12 +++++++++++- examples/Peripheral/CallbackLED/CallbackLED.ino | 12 +++++++++++- examples/Peripheral/LED/LED.ino | 12 +++++++++++- 8 files changed, 88 insertions(+), 8 deletions(-) diff --git a/examples/Central/LedControl/LedControl.ino b/examples/Central/LedControl/LedControl.ino index 09939cde..13768360 100644 --- a/examples/Central/LedControl/LedControl.ino +++ b/examples/Central/LedControl/LedControl.ino @@ -6,7 +6,17 @@ it will remotely control the BLE Peripheral's LED, when the button is pressed or released. The circuit: - - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - Boards with integrated BLE or Nucleo board plus one of BLE X-Nucleo shield:: + - B-L475E-IOT01A1 + - B_L4S5I_IOT01A + - STEVAL-MKBOXPRO + - STEVAL-MKSBOX1V1, + - NUCLEO-WB15CC + - P-NUCLEO-WB55RG + - STM32WB5MM-DK + - X-NUCLEO-IDB05A2 + - X-NUCLEO-IDB05A1 + - X-NUCLEO-BNRG2A1 You can use it with another board that is compatible with this library and the Peripherals -> LED example. diff --git a/examples/Central/PeripheralExplorer/PeripheralExplorer.ino b/examples/Central/PeripheralExplorer/PeripheralExplorer.ino index 09e204f6..52da33ca 100644 --- a/examples/Central/PeripheralExplorer/PeripheralExplorer.ino +++ b/examples/Central/PeripheralExplorer/PeripheralExplorer.ino @@ -5,7 +5,17 @@ is found. Then connects, and discovers + prints all the peripheral's attributes. The circuit: - - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - Boards with integrated BLE or Nucleo board plus one of BLE X-Nucleo shield:: + - B-L475E-IOT01A1 + - B_L4S5I_IOT01A + - STEVAL-MKBOXPRO + - STEVAL-MKSBOX1V1, + - NUCLEO-WB15CC + - P-NUCLEO-WB55RG + - STM32WB5MM-DK + - X-NUCLEO-IDB05A2 + - X-NUCLEO-IDB05A1 + - X-NUCLEO-BNRG2A1 You can use it with another board that is compatible with this library and the Peripherals -> LED example. diff --git a/examples/Central/Scan/Scan.ino b/examples/Central/Scan/Scan.ino index 14ea9f13..cc7275fd 100644 --- a/examples/Central/Scan/Scan.ino +++ b/examples/Central/Scan/Scan.ino @@ -5,7 +5,17 @@ address, local name, advertised service UUID's. The circuit: - - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - Boards with integrated BLE or Nucleo board plus one of BLE X-Nucleo shield:: + - B-L475E-IOT01A1 + - B_L4S5I_IOT01A + - STEVAL-MKBOXPRO + - STEVAL-MKSBOX1V1, + - NUCLEO-WB15CC + - P-NUCLEO-WB55RG + - STM32WB5MM-DK + - X-NUCLEO-IDB05A2 + - X-NUCLEO-IDB05A1 + - X-NUCLEO-BNRG2A1 This example code is in the public domain. */ diff --git a/examples/Central/ScanCallback/ScanCallback.ino b/examples/Central/ScanCallback/ScanCallback.ino index 199b8a34..f2ca6d6c 100644 --- a/examples/Central/ScanCallback/ScanCallback.ino +++ b/examples/Central/ScanCallback/ScanCallback.ino @@ -7,7 +7,17 @@ reported for every single advertisement it makes. The circuit: - - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - Boards with integrated BLE or Nucleo board plus one of BLE X-Nucleo shield:: + - B-L475E-IOT01A1 + - B_L4S5I_IOT01A + - STEVAL-MKBOXPRO + - STEVAL-MKSBOX1V1, + - NUCLEO-WB15CC + - P-NUCLEO-WB55RG + - STM32WB5MM-DK + - X-NUCLEO-IDB05A2 + - X-NUCLEO-IDB05A1 + - X-NUCLEO-BNRG2A1 This example code is in the public domain. */ diff --git a/examples/Central/SensorTagButton/SensorTagButton.ino b/examples/Central/SensorTagButton/SensorTagButton.ino index 6a097c70..75ccf254 100644 --- a/examples/Central/SensorTagButton/SensorTagButton.ino +++ b/examples/Central/SensorTagButton/SensorTagButton.ino @@ -8,7 +8,17 @@ outputted to the Serial Monitor when one is pressed. The circuit: - - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - Boards with integrated BLE or Nucleo board plus one of BLE X-Nucleo shield:: + - B-L475E-IOT01A1 + - B_L4S5I_IOT01A + - STEVAL-MKBOXPRO + - STEVAL-MKSBOX1V1, + - NUCLEO-WB15CC + - P-NUCLEO-WB55RG + - STM32WB5MM-DK + - X-NUCLEO-IDB05A2 + - X-NUCLEO-IDB05A1 + - X-NUCLEO-BNRG2A1 - TI SensorTag This example code is in the public domain. diff --git a/examples/Peripheral/ButtonLED/ButtonLED.ino b/examples/Peripheral/ButtonLED/ButtonLED.ino index 3163cf6a..8d014ade 100644 --- a/examples/Peripheral/ButtonLED/ButtonLED.ino +++ b/examples/Peripheral/ButtonLED/ButtonLED.ino @@ -6,7 +6,17 @@ represents the state of the button. The circuit: - - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - Boards with integrated BLE or Nucleo board plus one of BLE X-Nucleo shield:: + - B-L475E-IOT01A1 + - B_L4S5I_IOT01A + - STEVAL-MKBOXPRO + - STEVAL-MKSBOX1V1, + - NUCLEO-WB15CC + - P-NUCLEO-WB55RG + - STM32WB5MM-DK + - X-NUCLEO-IDB05A2 + - X-NUCLEO-IDB05A1 + - X-NUCLEO-BNRG2A1 You can use a generic BLE central app, like LightBlue (iOS and Android) or nRF Connect (Android), to interact with the services and characteristics diff --git a/examples/Peripheral/CallbackLED/CallbackLED.ino b/examples/Peripheral/CallbackLED/CallbackLED.ino index 5b416fbb..5f3e6d97 100644 --- a/examples/Peripheral/CallbackLED/CallbackLED.ino +++ b/examples/Peripheral/CallbackLED/CallbackLED.ino @@ -6,7 +6,17 @@ library are used. The circuit: - - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - Boards with integrated BLE or Nucleo board plus one of BLE X-Nucleo shield:: + - B-L475E-IOT01A1 + - B_L4S5I_IOT01A + - STEVAL-MKBOXPRO + - STEVAL-MKSBOX1V1, + - NUCLEO-WB15CC + - P-NUCLEO-WB55RG + - STM32WB5MM-DK + - X-NUCLEO-IDB05A2 + - X-NUCLEO-IDB05A1 + - X-NUCLEO-BNRG2A1 You can use a generic BLE central app, like LightBlue (iOS and Android) or nRF Connect (Android), to interact with the services and characteristics diff --git a/examples/Peripheral/LED/LED.ino b/examples/Peripheral/LED/LED.ino index 32cbfc9f..1ce9ea81 100644 --- a/examples/Peripheral/LED/LED.ino +++ b/examples/Peripheral/LED/LED.ino @@ -5,7 +5,17 @@ characteristic to control an LED. The circuit: - - STEVAL-MKBOXPRO, STEVAL-MKSBOX1V1, B-L475E-IOT01A1, B_L4S5I_IOT01A, or a Nucleo board plus the X-NUCLEO-IDB05A2 or the X-NUCLEO-IDB05A1 or the X-NUCLEO-BNRG2A1 + - Boards with integrated BLE or Nucleo board plus one of BLE X-Nucleo shield:: + - B-L475E-IOT01A1 + - B_L4S5I_IOT01A + - STEVAL-MKBOXPRO + - STEVAL-MKSBOX1V1, + - NUCLEO-WB15CC + - P-NUCLEO-WB55RG + - STM32WB5MM-DK + - X-NUCLEO-IDB05A2 + - X-NUCLEO-IDB05A1 + - X-NUCLEO-BNRG2A1 You can use a generic BLE central app, like LightBlue (iOS and Android) or nRF Connect (Android), to interact with the services and characteristics From 616f2fb58d0a3acd6d61762c19759501852c31b4 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 9 Jan 2023 11:54:49 +0100 Subject: [PATCH 58/58] chore: bump library version Warning: not aligned with ArduinoBLE one Signed-off-by: Frederic Pillon --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index e9f8de55..e36e566c 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=STM32duinoBLE -version=1.2.1 +version=1.2.2 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. pFad - Phonifier reborn

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

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


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy