diff --git a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/mbox_def.h b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/mbox_def.h
index efd22fc08d..1741a8c3d1 100644
--- a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/mbox_def.h
+++ b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/mbox_def.h
@@ -100,11 +100,17 @@ extern "C" {
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 *loggingM0toM4_buffer;
+ uint8_t *requestM0toM4_buffer;
} MB_ZigbeeTable_t;
/**
* msg
@@ -151,6 +157,7 @@ extern "C" {
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
@@ -194,6 +201,13 @@ extern "C" {
* | |
* |<---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-------->|
* | |
@@ -221,6 +235,8 @@ extern "C" {
#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 */
@@ -230,10 +246,13 @@ extern "C" {
#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_ZIGBEE_APPLI_LOGGING_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/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci.c b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci.c
index 9641098405..78bab2f5c5 100644
--- a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci.c
+++ b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci.c
@@ -298,6 +298,24 @@ SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param )
return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
}
+SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init( uint8_t param_size, uint8_t * p_param )
+{
+ /**
+ * 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_ZIGBEE_Init( void )
{
/**
@@ -315,6 +333,7 @@ SHCI_CmdStatus_t SHCI_C2_ZIGBEE_Init( void )
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 )
{
/**
@@ -494,6 +513,27 @@ SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_numbe
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]);
+}
+
/**
* Local System COMMAND
* These commands are NOT sent to the CPU2
diff --git a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci.h b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci.h
index 308c1d143a..68246847a1 100644
--- a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci.h
+++ b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci.h
@@ -137,7 +137,9 @@ extern "C" {
SHCI_OCF_C2_REINIT,
SHCI_OCF_C2_ZIGBEE_INIT,
SHCI_OCF_C2_LLD_TESTS_INIT,
- SHCI_OCF_C2_EXTPA_CONFIG
+ SHCI_OCF_C2_EXTPA_CONFIG,
+ SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL,
+ SHCI_OCF_C2_LLD_BLE_INIT
} SHCI_OCF_t;
#define SHCI_OPCODE_C2_FUS_GET_STATE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_GET_STATE)
@@ -296,6 +298,20 @@ extern "C" {
#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;
@@ -352,6 +368,8 @@ extern "C" {
#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
@@ -375,6 +393,16 @@ extern "C" {
/** 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*/
+
/* Exported type --------------------------------------------------------*/
typedef MB_WirelessFwInfoTable_t SHCI_WirelessFwInfoTable_t;
@@ -427,16 +455,21 @@ typedef MB_WirelessFwInfoTable_t SHCI_WirelessFwInfoTable_t;
#define INFO_STACK_TYPE_MASK 0x000000ff
#define INFO_STACK_TYPE_NONE 0
-#define INFO_STACK_TYPE_BLE_STANDARD 0x1
-#define INFO_STACK_TYPE_BLE_HCI 0x2
+#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 0x30
+#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_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
typedef struct {
@@ -587,6 +620,16 @@ typedef struct {
*/
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
@@ -706,6 +749,18 @@ typedef struct {
*/
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);
#ifdef __cplusplus
}
diff --git a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci_tl.c b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci_tl.c
index bfe48f6db0..0318446db3 100644
--- a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci_tl.c
+++ b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci_tl.c
@@ -24,8 +24,40 @@
#include "stm_list.h"
#include "shci_tl.h"
+#include "mbed_toolchain.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
@@ -38,10 +70,10 @@
/**
* START of Section SYSTEM_DRIVER_CONTEXT
*/
-static tListNode SHciAsynchEventQueue;
-static volatile SHCI_TL_CmdStatus_t SHCICmdStatus;
-static TL_CmdPacket_t *pCmdBuffer;
-SHCI_TL_UserEventFlowStatus_t SHCI_TL_UserEventFlow;
+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
*/
@@ -49,11 +81,16 @@ SHCI_TL_UserEventFlowStatus_t SHCI_TL_UserEventFlow;
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)
@@ -91,6 +128,8 @@ void shci_user_evt_proc(void)
{
LST_remove_head ( &SHciAsynchEventQueue, (tListNode **)&phcievtbuffer );
+ OutputEvtTrace(phcievtbuffer);
+
if (shciContext.UserEvtRx != NULL)
{
UserEvtRxParam.pckt = phcievtbuffer;
@@ -147,6 +186,8 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl
memcpy(pCmdBuffer->cmdserial.cmd.payload, p_cmd_payload, len_cmd_payload );
+ OutputCmdTrace(pCmdBuffer);
+
shciContext.io.Send(0,0);
shci_cmd_resp_wait(SHCI_TL_DEFAULT_TIMEOUT);
@@ -157,6 +198,8 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl
*/
memcpy( &(p_rsp->evtserial), pCmdBuffer, ((TL_EvtSerial_t*)pCmdBuffer)->evt.plen + TL_EVT_HDR_SIZE );
+ OutputRspTrace(p_rsp);
+
Cmd_SetStatus(SHCI_TL_CmdAvailable);
return;
@@ -226,3 +269,85 @@ static void TlUserEvtReceived(TL_EvtPacket_t *shcievt)
return;
}
+static void OutputCmdTrace(TL_CmdPacket_t *pCmdBuffer)
+{
+ TL_SHCI_CMD_DBG_MSG("sys cmd: 0x%04X", pCmdBuffer->cmdserial.cmd.cmdcode);
+
+ if(pCmdBuffer->cmdserial.cmd.plen != 0)
+ {
+ TL_SHCI_CMD_DBG_MSG(" payload:");
+ TL_SHCI_CMD_DBG_BUF(pCmdBuffer->cmdserial.cmd.payload, pCmdBuffer->cmdserial.cmd.plen, "");
+ }
+ TL_SHCI_CMD_DBG_MSG("\r\n");
+
+ return;
+}
+
+static void OutputRspTrace(TL_EvtPacket_t *p_rsp)
+{
+ switch(p_rsp->evtserial.evt.evtcode)
+ {
+ case TL_BLEEVT_CC_OPCODE:
+ TL_SHCI_CMD_DBG_MSG("sys rsp: 0x%02X", p_rsp->evtserial.evt.evtcode);
+ TL_SHCI_CMD_DBG_MSG(" cmd opcode: 0x%02X", ((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->cmdcode);
+ TL_SHCI_CMD_DBG_MSG(" status: 0x%02X", ((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]);
+ if((p_rsp->evtserial.evt.plen-4) != 0)
+ {
+ TL_SHCI_CMD_DBG_MSG(" payload:");
+ TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1], p_rsp->evtserial.evt.plen-4, "");
+ }
+ break;
+
+ default:
+ TL_SHCI_CMD_DBG_MSG("unknown sys rsp received: %02X", p_rsp->evtserial.evt.evtcode);
+ break;
+ }
+
+ TL_SHCI_CMD_DBG_MSG("\r\n");
+
+ return;
+}
+
+static void OutputEvtTrace(TL_EvtPacket_t *phcievtbuffer)
+{
+ if(phcievtbuffer->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE)
+ {
+ TL_SHCI_EVT_DBG_MSG("unknown sys evt received: %02X", phcievtbuffer->evtserial.evt.evtcode);
+ }
+ else
+ {
+ TL_SHCI_EVT_DBG_MSG("sys evt: 0x%02X", phcievtbuffer->evtserial.evt.evtcode);
+ TL_SHCI_EVT_DBG_MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(phcievtbuffer->evtserial.evt.payload))->subevtcode);
+ if((phcievtbuffer->evtserial.evt.plen-2) != 0)
+ {
+ TL_SHCI_EVT_DBG_MSG(" payload:");
+ TL_SHCI_EVT_DBG_BUF(((TL_AsynchEvt_t*)(phcievtbuffer->evtserial.evt.payload))->payload, phcievtbuffer->evtserial.evt.plen-2, "");
+ }
+ }
+
+ TL_SHCI_EVT_DBG_MSG("\r\n");
+
+ return;
+}
+
+/* Weak implementation ----------------------------------------------------------------*/
+MBED_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;
+}
+
+MBED_WEAK void shci_cmd_resp_release(uint32_t flag)
+{
+ (void)flag;
+
+ CmdRspStatusFlag = SHCI_TL_CMD_RESP_RELEASE;
+
+ return;
+}
+
+
diff --git a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci_tl.h b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci_tl.h
index 3e4b2a271f..3fbc492f1c 100644
--- a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci_tl.h
+++ b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/shci_tl.h
@@ -120,12 +120,13 @@ void shci_resume_flow(void);
/**
- * @brief This function is called when an System HCO Command is sent and the response
- * is waited from the CPU2.
- * The application shall implement a mechanism to not return from this function
- * until the waited event is received.
- * This is notified to the application with shci_cmd_resp_release().
+ * @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
@@ -133,8 +134,12 @@ void shci_resume_flow(void);
void shci_cmd_resp_wait(uint32_t timeout);
/**
- * @brief This function is called when an System HCI command is sent and the response is
- * received from the CPU2.
+ * @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
diff --git a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/stm32_wpan_common.h b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/stm32_wpan_common.h
index aabac95d69..ddf22a0152 100644
--- a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/stm32_wpan_common.h
+++ b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/stm32_wpan_common.h
@@ -70,10 +70,10 @@ extern "C" {
* Some useful macro definitions *
* -------------------------------- */
#undef MAX
-#define MAX( x, y ) (((x)>(y))?(x):(y))
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#undef MIN
-#define MIN( x, y ) (((x)<(y))?(x):(y))
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#undef MODINC
#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END
@@ -120,6 +120,7 @@ extern "C" {
/* -------------------------------- *
* Section attribute *
* -------------------------------- */
+#undef PLACE_IN_SECTION
#define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
/* ----------------------------------- *
@@ -129,8 +130,13 @@ extern "C" {
#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__
diff --git a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/tl.h b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/tl.h
index a5a395ac26..e5fac41374 100644
--- a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/tl.h
+++ b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/tl.h
@@ -57,6 +57,7 @@ extern "C" {
#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)
@@ -192,6 +193,12 @@ typedef struct
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;
@@ -202,7 +209,7 @@ typedef struct
{
uint8_t *p_ZigbeeOtCmdRspBuffer;
uint8_t *p_ZigbeeNotAckBuffer;
- uint8_t *p_ZigbeeLoggingBuffer;
+ uint8_t *p_ZigbeeNotifRequestBuffer;
} TL_ZIGBEE_Config_t;
/**
@@ -274,6 +281,18 @@ 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
******************************************************************************/
@@ -299,12 +318,12 @@ void TL_MAC_802_15_4_SendAck ( void );
* ZIGBEE
******************************************************************************/
void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config );
-void TL_ZIGBEE_SendAppliCmdToM0( void );
-void TL_ZIGBEE_SendAckAfterAppliNotifFromM0 ( void );
+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_LoggingReceived(TL_EvtPacket_t * Otbuffer );
-void TL_ZIGBEE_SendAckAfterAppliLoggingFromM0 ( void );
+void TL_ZIGBEE_M0RequestReceived(TL_EvtPacket_t * Otbuffer );
+void TL_ZIGBEE_SendM4AckToM0Request(void);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/tl_mbox.c b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/tl_mbox.c
index 5a15b3c1c5..ada2951a53 100644
--- a/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/tl_mbox.c
+++ b/features/FEATURE_BLE/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/tl_mbox.c
@@ -4,17 +4,17 @@
* @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
- *
- ******************************************************************************
+ * @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
+ *
+ ******************************************************************************
*/
@@ -22,10 +22,27 @@
#include "stm32_wpan_common.h"
#include "hw.h"
+#include "mbed_toolchain.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 ------------------------------------------------------------*/
@@ -37,6 +54,7 @@ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_DeviceInfoTable_t TL_DeviceInfoTa
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleTable_t TL_BleTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ThreadTable_t TL_ThreadTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_LldTestsTable_t TL_LldTestsTable;
+PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_LldBleTable_t TL_LldBleTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_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;
@@ -61,6 +79,7 @@ static void (* SYS_EVT_IoBusCallBackFunction) (TL_EvtPacket_t *phcievt);
/* Global variables ----------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
static void SendFreeBuf( void );
+static void OutputMemReleaseTrace(TL_EvtPacket_t * phcievt);
/* Public Functions Definition ------------------------------------------------------*/
@@ -81,6 +100,7 @@ void TL_Init( void )
TL_RefTable.p_ble_table = &TL_BleTable;
TL_RefTable.p_thread_table = &TL_ThreadTable;
TL_RefTable.p_lld_tests_table = &TL_LldTestsTable;
+ TL_RefTable.p_lld_ble_table = &TL_LldBleTable;
TL_RefTable.p_sys_table = &TL_SysTable;
TL_RefTable.p_mem_manager_table = &TL_MemManagerTable;
TL_RefTable.p_traces_table = &TL_TracesTable;
@@ -91,7 +111,6 @@ void TL_Init( void )
return;
}
-
/******************************************************************************
* BLE
******************************************************************************/
@@ -122,7 +141,7 @@ 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();
@@ -148,7 +167,7 @@ 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();
@@ -293,9 +312,9 @@ void HW_IPCC_THREAD_CliEvtNot( void )
return;
}
-void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
-void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer ){};
-void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer ){};
+MBED_WEAK void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
+MBED_WEAK void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer ){};
+MBED_WEAK void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer ){};
#endif /* THREAD_WB */
@@ -346,10 +365,81 @@ void TL_LLDTESTS_SendM0CmdAck( void )
return;
}
-void TL_LLDTESTS_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ){};
-void TL_LLDTESTS_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ){};
+MBED_WEAK void TL_LLDTESTS_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ){};
+MBED_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;
+}
+
+MBED_WEAK void TL_LLD_BLE_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ){};
+MBED_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
@@ -400,8 +490,8 @@ void HW_IPCC_MAC_802_15_4_EvtNot( void )
return;
}
-void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
-void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){};
+MBED_WEAK void TL_MAC_802_15_4_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
+MBED_WEAK void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){};
#endif
#ifdef ZIGBEE_WB
@@ -410,75 +500,75 @@ void TL_MAC_802_15_4_NotReceived( TL_EvtPacket_t * Notbuffer ){};
******************************************************************************/
void TL_ZIGBEE_Init( TL_ZIGBEE_Config_t *p_Config )
{
+ MB_ZigbeeTable_t * p_zigbee_table;
- 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;
- 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->loggingM0toM4_buffer = p_Config->p_ZigbeeLoggingBuffer;
-
- HW_IPCC_ZIGBEE_Init();
+ HW_IPCC_ZIGBEE_Init();
return;
}
-void TL_ZIGBEE_SendAppliCmdToM0( void )
+/* 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_SendAppliCmd();
-
- return;
-}
-
-/* Send an ACK to the M0 */
-void TL_ZIGBEE_SendAckAfterAppliNotifFromM0 ( void )
-{
- ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
-
- HW_IPCC_ZIGBEE_SendAppliCmdAck();
+ HW_IPCC_ZIGBEE_SendM4RequestToM0();
return;
}
/* Used to receive an ACK from the M0 */
-void HW_IPCC_ZIGBEE_AppliCmdNotification(void)
+void HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void)
{
TL_ZIGBEE_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->appliCmdM4toM0_buffer) );
return;
}
-/* Zigbee callback */
-void HW_IPCC_ZIGBEE_AppliAsyncEvtNotification( void )
+/* 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;
}
-/* Zigbee logging */
-void HW_IPCC_ZIGBEE_AppliAsyncLoggingNotification( void )
+/* Send an ACK to the M0 for a Notification */
+void TL_ZIGBEE_SendM4AckToM0Notify ( void )
{
- TL_ZIGBEE_LoggingReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->loggingM0toM4_buffer) );
+ ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->notifM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
+
+ HW_IPCC_ZIGBEE_SendM4AckToM0Notify();
return;
}
-/* Send a Logging ACK to the M0 */
-void TL_ZIGBEE_SendAckAfterAppliLoggingFromM0 ( void )
+/* Zigbee M0 to M4 Request */
+void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void )
{
- ((TL_CmdPacket_t *)(TL_RefTable.p_zigbee_table->loggingM0toM4_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE;
+ TL_ZIGBEE_M0RequestReceived( (TL_EvtPacket_t*)(TL_RefTable.p_zigbee_table->requestM0toM4_buffer) );
- HW_IPCC_ZIGBEE_SendLoggingAck();
+ 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;
}
-void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
-void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){};
+MBED_WEAK void TL_ZIGBEE_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){};
+MBED_WEAK void TL_ZIGBEE_NotReceived( TL_EvtPacket_t * Notbuffer ){};
#endif
@@ -510,6 +600,8 @@ void TL_MM_EvtDone(TL_EvtPacket_t * phcievt)
{
LST_insert_tail(&LocalFreeBufQueue, (tListNode *)phcievt);
+ OutputMemReleaseTrace(phcievt);
+
HW_IPCC_MM_SendFreeBuf( SendFreeBuf );
return;
@@ -528,6 +620,38 @@ static void SendFreeBuf( void )
return;
}
+static void OutputMemReleaseTrace(TL_EvtPacket_t * phcievt)
+{
+ switch(phcievt->evtserial.evt.evtcode)
+ {
+ case TL_BLEEVT_CS_OPCODE:
+ TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode);
+ TL_MM_DBG__MSG(" cmd opcode: 0x%04X", ((TL_CsEvt_t*)(phcievt->evtserial.evt.payload))->cmdcode);
+ TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt);
+ break;
+
+ case TL_BLEEVT_CC_OPCODE:
+ TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode);
+ TL_MM_DBG__MSG(" cmd opcode: 0x%04X", ((TL_CcEvt_t*)(phcievt->evtserial.evt.payload))->cmdcode);
+ TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt);
+ break;
+
+ case TL_BLEEVT_VS_OPCODE:
+ TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode);
+ TL_MM_DBG__MSG(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(phcievt->evtserial.evt.payload))->subevtcode);
+ TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt);
+ break;
+
+ default:
+ TL_MM_DBG__MSG("mm evt released: 0x%02X", phcievt->evtserial.evt.evtcode);
+ TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt);
+ break;
+ }
+
+ TL_MM_DBG__MSG("\r\n");
+
+ return;
+}
/******************************************************************************
* TRACES
@@ -556,9 +680,9 @@ void HW_IPCC_TRACES_EvtNot(void)
return;
}
-void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt )
+MBED_WEAK void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt )
{
- (void)(hcievt);
+ (void)(hcievt);
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/app_conf.h b/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/app_conf.h
index 8f24b0ca64..e3512fa5f2 100644
--- a/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/app_conf.h
+++ b/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/app_conf.h
@@ -19,8 +19,8 @@
/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __APP_CONFIG_H
-#define __APP_CONFIG_H
+#ifndef APP_CONF_H
+#define APP_CONF_H
#include "hw.h"
#include "hw_conf.h"
@@ -28,9 +28,93 @@
// #include "hw_if.h" // MBED
/******************************************************************************
- * Transparent Mode Config
+ * Application Config
******************************************************************************/
+/**< generic parameters ******************************************************/
+
+/**
+ * Define Tx Power
+ */
+#define CFG_TX_POWER (0x18) /**< 0dbm */
+
+/**
+ * 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 (0)
+#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
*/
@@ -41,24 +125,23 @@
*/
#define CFG_BLE_ERK {0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21,0xfe,0xdc,0xba,0x09,0x87,0x65,0x43,0x21}
-/**< specific parameters *//*****************************************************/
-/******************************************************************************
- * Information Table
- *
- * Version
- * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version
- * [4:7] = branch - 0: Mass Market - x: ...
- * [8:15] = Subversion
- * [16:23] = Version minor
- * [24:31] = Version major
- *
- ******************************************************************************/
-#define CFG_FW_MAJOR_VERSION (0)
-#define CFG_FW_MINOR_VERSION (0)
-#define CFG_FW_SUBVERSION (1)
-#define CFG_FW_BRANCH (0)
-#define CFG_FW_BUILD (0)
+/* 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
@@ -183,7 +266,6 @@
* 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.
@@ -197,7 +279,6 @@
#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
******************************************************************************/
@@ -205,10 +286,8 @@
/**
* Select UART interfaces
*/
-#define CFG_UART_GUI hw_uart1
-#define DBG_TRACE_UART_CFG hw_lpuart1
-#define CFG_CONSOLE_MENU
-
+#define CFG_DEBUG_TRACE_UART hw_uart1
+#define CFG_CONSOLE_MENU 0
/******************************************************************************
* USB interface
******************************************************************************/
@@ -304,7 +383,7 @@
typedef enum
{
- CFG_TIM_PROC_ID_ISR,
+ CFG_TIM_PROC_ID_ISR,
} CFG_TimProcID_t;
/******************************************************************************
@@ -317,10 +396,7 @@ typedef enum
* This shall be set to 0 in a final product
*
*/
-#define CFG_HW_RESET_BY_FW 1
-
-#define CFG_LED_SUPPORTED 1
-#define CFG_BUTTON_SUPPORTED 1
+#define CFG_HW_RESET_BY_FW 1
/**
* keep debugger enabled while in any low power mode when set to 1
@@ -336,18 +412,7 @@ typedef enum
/**
* Enable or Disable traces in application
*/
-#define CFG_DEBUG_APP_TRACE 0
-
-
-#if defined ( __CC_ARM ) /* Keil */
-#undef CFG_DEBUG_BLE_TRACE
-#undef CFG_DEBUG_APP_TRACE
-#undef CFG_LPM_SUPPORTED
-#define CFG_DEBUG_BLE_TRACE 0
-#define CFG_DEBUG_APP_TRACE 0
-#define CFG_LPM_SUPPORTED 0
-#endif
-
+#define CFG_DEBUG_APP_TRACE 0
#if (CFG_DEBUG_APP_TRACE != 0)
#define APP_DBG_MSG PRINT_MESG_DBG
@@ -367,6 +432,51 @@ typedef enum
#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 1
+#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
+
+#define PUSH_BUTTON_SW1_EXTI_IRQHandler EXTI4_IRQHandler
+#define PUSH_BUTTON_SW2_EXTI_IRQHandler EXTI0_IRQHandler
+#define PUSH_BUTTON_SW3_EXTI_IRQHandler EXTI1_IRQHandler
+/* USER CODE END Defines */
+
/******************************************************************************
* Scheduler
******************************************************************************/
@@ -381,11 +491,9 @@ typedef enum
/**< 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,
+ CFG_TASK_ADV_UPDATE_ID,
+ CFG_TASK_MEAS_REQ_ID,
+ CFG_TASK_HCI_ASYNCH_EVT_ID,
CFG_LAST_TASK_ID_WITH_HCICMD, /**< Shall be LAST in the list */
} CFG_Task_Id_With_HCI_Cmd_t;
@@ -394,9 +502,7 @@ typedef enum
typedef enum
{
CFG_FIRST_TASK_ID_WITH_NO_HCICMD = CFG_LAST_TASK_ID_WITH_HCICMD - 1, /**< Shall be FIRST in the list */
-
- CFG_TASK_VCP_SEND_DATA_ID,
- CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID,
+ CFG_TASK_SYSTEM_HCI_ASYNCH_EVT_ID,
CFG_LAST_TASK_ID_WITHO_NO_HCICMD /**< Shall be LAST in the list */
} CFG_Task_Id_With_NO_HCI_Cmd_t;
@@ -409,7 +515,6 @@ typedef enum
typedef enum
{
CFG_SCH_PRIO_0,
- CFG_SCH_PRIO_1,
CFG_PRIO_NBR,
} CFG_SCH_Prio_Id_t;
@@ -418,6 +523,7 @@ typedef enum
*/
typedef enum
{
+ CFG_IDLEEVT_HCI_CMD_EVT_RSP_ID,
CFG_IDLEEVT_SYSTEM_HCI_CMD_EVT_RSP_ID,
} CFG_IdleEvt_Id_t;
@@ -431,6 +537,7 @@ typedef enum
typedef enum
{
CFG_LPM_APP,
+ CFG_LPM_APP_BLE,
} CFG_LPM_Id_t;
/******************************************************************************
diff --git a/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/hw.h b/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/hw.h
index 1010296475..879fa6de54 100644
--- a/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/hw.h
+++ b/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/hw.h
@@ -58,6 +58,7 @@ extern "C" {
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 );
@@ -65,9 +66,21 @@ extern "C" {
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 );
@@ -76,13 +89,13 @@ extern "C" {
void HW_IPCC_ZIGBEE_Init( void );
- void HW_IPCC_ZIGBEE_SendAppliCmd(void);
- void HW_IPCC_ZIGBEE_AppliCmdNotification(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_AppliAsyncEvtNotification(void);
- void HW_IPCC_ZIGBEE_SendAppliCmdAck(void);
- void HW_IPCC_ZIGBEE_AppliAsyncLoggingNotification( void );
- void HW_IPCC_ZIGBEE_SendLoggingAck(void);
+ 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/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/system_stm32wbxx.c b/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/system_stm32wbxx.c
index f79f7cbe29..b1270ea0b3 100644
--- a/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/system_stm32wbxx.c
+++ b/targets/TARGET_STM/TARGET_STM32WB/STM32Cube_FW/system_stm32wbxx.c
@@ -161,7 +161,7 @@
const uint32_t MSIRangeTable[16UL] = {100000UL, 200000UL, 400000UL, 800000UL, 1000000UL, 2000000UL, \
4000000UL, 8000000UL, 16000000UL, 24000000UL, 32000000UL, 48000000UL, 0UL, 0UL, 0UL, 0UL}; /* 0UL values are incorrect cases */
-#if defined(STM32WB55xx)
+#if defined(STM32WB55xx) || defined(STM32WB5Mxx) || defined(STM32WB35xx)
const uint32_t SmpsPrescalerTable[4UL][6UL]={{1UL,3UL,2UL,2UL,1UL,2UL}, \
{2UL,6UL,4UL,3UL,2UL,4UL}, \
{4UL,12UL,8UL,6UL,4UL,8UL}, \
@@ -224,7 +224,7 @@ void SystemInit(void)
/* Reset PLLCFGR register */
RCC->PLLCFGR = 0x22041000U;
-#if defined(STM32WB55xx)
+#if defined(STM32WB55xx) || defined(STM32WB5Mxx)
/* Reset PLLSAI1CFGR register */
RCC->PLLSAI1CFGR = 0x22041000U;
#endif