From 6a6c5505cfe72d11d42979324ff4f98aef4c6af0 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 1 Dec 2021 10:21:53 +0100 Subject: [PATCH 01/12] 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 02/12] 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 03/12] 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 04/12] 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 05/12] 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 06/12] 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 07/12] 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 08/12] 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 09/12] 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 10/12] 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 11/12] 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 12/12] 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****/