BLE streaming of sensor data working

This commit is contained in:
ggw
2026-04-30 18:14:35 -05:00
parent b6e40323e3
commit 42f91eb075
107 changed files with 39837 additions and 35 deletions
File diff suppressed because it is too large Load Diff
+81
View File
@@ -0,0 +1,81 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file App/app_ble.h
* @author MCD Application Team
* @brief Header for ble application
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef APP_BLE_H
#define APP_BLE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "hci_tl.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
typedef enum
{
APP_BLE_IDLE,
APP_BLE_FAST_ADV,
APP_BLE_LP_ADV,
APP_BLE_SCAN,
APP_BLE_LP_CONNECTING,
APP_BLE_CONNECTED_SERVER,
APP_BLE_CONNECTED_CLIENT
} APP_BLE_ConnStatus_t;
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* External variables --------------------------------------------------------*/
/* USER CODE BEGIN EV */
/* USER CODE END EV */
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
/* USER CODE END EM */
/* Exported functions ---------------------------------------------*/
void APP_BLE_Init(void);
APP_BLE_ConnStatus_t APP_BLE_Get_Server_Connection_Status(void);
/* USER CODE BEGIN EF */
/* USER CODE END EF */
#ifdef __cplusplus
}
#endif
#endif /*APP_BLE_H */
@@ -0,0 +1,65 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file ble_conf.h
* @author MCD Application Team
* @brief Configuration file for BLE Middleware.
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef BLE_CONF_H
#define BLE_CONF_H
#include "app_conf.h"
/******************************************************************************
*
* BLE SERVICES CONFIGURATION
* blesvc
*
******************************************************************************/
/**
* This setting shall be set to '1' if the device needs to support the Peripheral Role
* In the MS configuration, both BLE_CFG_PERIPHERAL and BLE_CFG_CENTRAL shall be set to '1'
*/
#define BLE_CFG_PERIPHERAL 1
/**
* This setting shall be set to '1' if the device needs to support the Central Role
* In the MS configuration, both BLE_CFG_PERIPHERAL and BLE_CFG_CENTRAL shall be set to '1'
*/
#define BLE_CFG_CENTRAL 0
/**
* There is one handler per service enabled
* Note: There is no handler for the Device Information Service
*
* This shall take into account all registered handlers
* (from either the provided services or the custom services)
*/
#define BLE_CFG_SVC_MAX_NBR_CB 7
#define BLE_CFG_CLT_MAX_NBR_CB 0
/******************************************************************************
* GAP Service - Appearance
******************************************************************************/
#define BLE_CFG_UNKNOWN_APPEARANCE (0)
#define BLE_CFG_HR_SENSOR_APPEARANCE (832)
#define BLE_CFG_GAP_APPEARANCE (BLE_CFG_UNKNOWN_APPEARANCE)
#endif /*BLE_CONF_H */
@@ -0,0 +1,198 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file App/ble_dbg_conf.h
* @author MCD Application Team
* @brief Debug configuration file for BLE Middleware.
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef BLE_DBG_CONF_H
#define BLE_DBG_CONF_H
/**
* Enable or Disable traces from BLE
*/
#define BLE_DBG_APP_EN 0
#define BLE_DBG_DIS_EN 0
#define BLE_DBG_HRS_EN 0
#define BLE_DBG_SVCCTL_EN 0
#define BLE_DBG_BLS_EN 0
#define BLE_DBG_HTS_EN 0
#define BLE_DBG_P2P_STM_EN 0
/**
* Macro definition
*/
#if (BLE_DBG_APP_EN != 0)
#define BLE_DBG_APP_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_APP_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_DIS_EN != 0)
#define BLE_DBG_DIS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_DIS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_HRS_EN != 0)
#define BLE_DBG_HRS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_HRS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_P2P_STM_EN != 0)
#define BLE_DBG_P2P_STM_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_P2P_STM_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_TEMPLATE_STM_EN != 0)
#define BLE_DBG_TEMPLATE_STM_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_TEMPLATE_STM_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_EDS_STM_EN != 0)
#define BLE_DBG_EDS_STM_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_EDS_STM_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_LBS_STM_EN != 0)
#define BLE_DBG_LBS_STM_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_LBS_STM_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_SVCCTL_EN != 0)
#define BLE_DBG_SVCCTL_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_SVCCTL_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_CTS_EN != 0)
#define BLE_DBG_CTS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_CTS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_HIDS_EN != 0)
#define BLE_DBG_HIDS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_HIDS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_PASS_EN != 0)
#define BLE_DBG_PASS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_PASS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_BLS_EN != 0)
#define BLE_DBG_BLS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_BLS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_HTS_EN != 0)
#define BLE_DBG_HTS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_HTS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_ANS_EN != 0)
#define BLE_DBG_ANS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_ANS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_ESS_EN != 0)
#define BLE_DBG_ESS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_ESS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_GLS_EN != 0)
#define BLE_DBG_GLS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_GLS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_BAS_EN != 0)
#define BLE_DBG_BAS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_BAS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_RTUS_EN != 0)
#define BLE_DBG_RTUS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_RTUS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_HPS_EN != 0)
#define BLE_DBG_HPS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_HPS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_TPS_EN != 0)
#define BLE_DBG_TPS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_TPS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_LLS_EN != 0)
#define BLE_DBG_LLS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_LLS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_IAS_EN != 0)
#define BLE_DBG_IAS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_IAS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_WSS_EN != 0)
#define BLE_DBG_WSS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_WSS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_LNS_EN != 0)
#define BLE_DBG_LNS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_LNS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_SCPS_EN != 0)
#define BLE_DBG_SCPS_MSG PRINT_MESG_DBG
#else
#define BLE_DBG_SCPS_MSG PRINT_NO_MESG
#endif
#if (BLE_DBG_DTS_EN != 0)
#define BLE_DBG_DTS_MSG PRINT_MESG_DBG
#define BLE_DBG_DTS_BUF PRINT_LOG_BUFF_DBG
#else
#define BLE_DBG_DTS_MSG PRINT_NO_MESG
#define BLE_DBG_DTS_BUF PRINT_NO_MESG
#endif
#endif /*BLE_DBG_CONF_H */
@@ -0,0 +1,234 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file App/custom_app.c
* @author MCD Application Team
* @brief Custom Example Application (Server)
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "app_common.h"
#include "dbg_trace.h"
#include "ble.h"
#include "custom_app.h"
#include "custom_stm.h"
#include "stm32_seq.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdbool.h>
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
typedef struct
{
/* readwriteArr */
uint8_t Arrread_Notification_Status;
/* USER CODE BEGIN CUSTOM_APP_Context_t */
/* USER CODE END CUSTOM_APP_Context_t */
uint16_t ConnectionHandle;
} Custom_App_Context_t;
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private defines ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macros -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/**
* START of Section BLE_APP_CONTEXT
*/
static Custom_App_Context_t Custom_App_Context;
/**
* END of Section BLE_APP_CONTEXT
*/
uint8_t UpdateCharData[512];
uint8_t NotifyCharData[512];
uint16_t Connection_Handle;
/* USER CODE BEGIN PV */
extern volatile bool do_notify;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/* readwriteArr */
static void Custom_Arrread_Update_Char(void);
static void Custom_Arrread_Send_Notification(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Functions Definition ------------------------------------------------------*/
void Custom_STM_App_Notification(Custom_STM_App_Notification_evt_t *pNotification)
{
/* USER CODE BEGIN CUSTOM_STM_App_Notification_1 */
/* USER CODE END CUSTOM_STM_App_Notification_1 */
switch (pNotification->Custom_Evt_Opcode)
{
/* USER CODE BEGIN CUSTOM_STM_App_Notification_Custom_Evt_Opcode */
/* USER CODE END CUSTOM_STM_App_Notification_Custom_Evt_Opcode */
/* readwriteArr */
case CUSTOM_STM_ARRWRITE_WRITE_EVT:
/* USER CODE BEGIN CUSTOM_STM_ARRWRITE_WRITE_EVT */
/* USER CODE END CUSTOM_STM_ARRWRITE_WRITE_EVT */
break;
case CUSTOM_STM_ARRREAD_NOTIFY_ENABLED_EVT:
/* USER CODE BEGIN CUSTOM_STM_ARRREAD_NOTIFY_ENABLED_EVT */
do_notify = true;
/* USER CODE END CUSTOM_STM_ARRREAD_NOTIFY_ENABLED_EVT */
break;
case CUSTOM_STM_ARRREAD_NOTIFY_DISABLED_EVT:
/* USER CODE BEGIN CUSTOM_STM_ARRREAD_NOTIFY_DISABLED_EVT */
do_notify = false;
/* USER CODE END CUSTOM_STM_ARRREAD_NOTIFY_DISABLED_EVT */
break;
case CUSTOM_STM_NOTIFICATION_COMPLETE_EVT:
/* USER CODE BEGIN CUSTOM_STM_NOTIFICATION_COMPLETE_EVT */
/* USER CODE END CUSTOM_STM_NOTIFICATION_COMPLETE_EVT */
break;
default:
/* USER CODE BEGIN CUSTOM_STM_App_Notification_default */
/* USER CODE END CUSTOM_STM_App_Notification_default */
break;
}
/* USER CODE BEGIN CUSTOM_STM_App_Notification_2 */
/* USER CODE END CUSTOM_STM_App_Notification_2 */
return;
}
void Custom_APP_Notification(Custom_App_ConnHandle_Not_evt_t *pNotification)
{
/* USER CODE BEGIN CUSTOM_APP_Notification_1 */
/* USER CODE END CUSTOM_APP_Notification_1 */
switch (pNotification->Custom_Evt_Opcode)
{
/* USER CODE BEGIN CUSTOM_APP_Notification_Custom_Evt_Opcode */
/* USER CODE END P2PS_CUSTOM_Notification_Custom_Evt_Opcode */
case CUSTOM_CONN_HANDLE_EVT :
/* USER CODE BEGIN CUSTOM_CONN_HANDLE_EVT */
/* USER CODE END CUSTOM_CONN_HANDLE_EVT */
break;
case CUSTOM_DISCON_HANDLE_EVT :
/* USER CODE BEGIN CUSTOM_DISCON_HANDLE_EVT */
/* USER CODE END CUSTOM_DISCON_HANDLE_EVT */
break;
default:
/* USER CODE BEGIN CUSTOM_APP_Notification_default */
/* USER CODE END CUSTOM_APP_Notification_default */
break;
}
/* USER CODE BEGIN CUSTOM_APP_Notification_2 */
/* USER CODE END CUSTOM_APP_Notification_2 */
return;
}
void Custom_APP_Init(void)
{
/* USER CODE BEGIN CUSTOM_APP_Init */
/* USER CODE END CUSTOM_APP_Init */
return;
}
/* USER CODE BEGIN FD */
/* USER CODE END FD */
/*************************************************************
*
* LOCAL FUNCTIONS
*
*************************************************************/
/* readwriteArr */
__USED void Custom_Arrread_Update_Char(void) /* Property Read */
{
uint8_t updateflag = 0;
/* USER CODE BEGIN Arrread_UC_1*/
/* USER CODE END Arrread_UC_1*/
if (updateflag != 0)
{
Custom_STM_App_Update_Char(CUSTOM_STM_ARRREAD, (uint8_t *)UpdateCharData);
}
/* USER CODE BEGIN Arrread_UC_Last*/
/* USER CODE END Arrread_UC_Last*/
return;
}
void Custom_Arrread_Send_Notification(void) /* Property Notification */
{
uint8_t updateflag = 0;
/* USER CODE BEGIN Arrread_NS_1*/
/* USER CODE END Arrread_NS_1*/
if (updateflag != 0)
{
Custom_STM_App_Update_Char(CUSTOM_STM_ARRREAD, (uint8_t *)NotifyCharData);
}
/* USER CODE BEGIN Arrread_NS_Last*/
/* USER CODE END Arrread_NS_Last*/
return;
}
/* USER CODE BEGIN FD_LOCAL_FUNCTIONS*/
/* USER CODE END FD_LOCAL_FUNCTIONS*/
@@ -0,0 +1,78 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file App/custom_app.h
* @author MCD Application Team
* @brief Header for custom_app.c module
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef CUSTOM_APP_H
#define CUSTOM_APP_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
typedef enum
{
CUSTOM_CONN_HANDLE_EVT,
CUSTOM_DISCON_HANDLE_EVT,
} Custom_App_Opcode_Notification_evt_t;
typedef struct
{
Custom_App_Opcode_Notification_evt_t Custom_Evt_Opcode;
uint16_t ConnectionHandle;
} Custom_App_ConnHandle_Not_evt_t;
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* External variables --------------------------------------------------------*/
/* USER CODE BEGIN EV */
/* USER CODE END EV */
/* Exported macros ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
/* USER CODE END EM */
/* Exported functions ---------------------------------------------*/
void Custom_APP_Init(void);
void Custom_APP_Notification(Custom_App_ConnHandle_Not_evt_t *pNotification);
/* USER CODE BEGIN EF */
/* USER CODE END EF */
#ifdef __cplusplus
}
#endif
#endif /* CUSTOM_APP_H */
@@ -0,0 +1,655 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file App/custom_stm.c
* @author MCD Application Team
* @brief Custom Example Service.
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "common_blesvc.h"
#include "custom_stm.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
typedef struct{
uint16_t CustomReadwritearrHdle; /**< readwriteArr handle */
uint16_t CustomArrwriteHdle; /**< arrWrite handle */
uint16_t CustomArrreadHdle; /**< arrRead handle */
/* USER CODE BEGIN Context */
/* Place holder for Characteristic Descriptors Handle*/
/* USER CODE END Context */
}CustomContext_t;
extern uint16_t Connection_Handle;
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private defines -----------------------------------------------------------*/
#define UUID_128_SUPPORTED 1
#if (UUID_128_SUPPORTED == 1)
#define BM_UUID_LENGTH UUID_TYPE_128
#else
#define BM_UUID_LENGTH UUID_TYPE_16
#endif
#define BM_REQ_CHAR_SIZE (3)
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macros ------------------------------------------------------------*/
#define CHARACTERISTIC_DESCRIPTOR_ATTRIBUTE_OFFSET 2
#define CHARACTERISTIC_VALUE_ATTRIBUTE_OFFSET 1
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
uint16_t SizeArrwrite = 1;
uint16_t SizeArrread = 128;
/**
* START of Section BLE_DRIVER_CONTEXT
*/
static CustomContext_t CustomContext;
/**
* END of Section BLE_DRIVER_CONTEXT
*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
static SVCCTL_EvtAckStatus_t Custom_STM_Event_Handler(void *pckt);
static tBleStatus Generic_STM_App_Update_Char_Ext(uint16_t ConnectionHandle, uint16_t ServiceHandle, uint16_t CharHandle, uint16_t CharValueLen, uint8_t *pPayload);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Functions Definition ------------------------------------------------------*/
/* USER CODE BEGIN PFD */
/* USER CODE END PFD */
/* Private functions ----------------------------------------------------------*/
#define COPY_UUID_128(uuid_struct, uuid_15, uuid_14, uuid_13, uuid_12, uuid_11, uuid_10, uuid_9, uuid_8, uuid_7, uuid_6, uuid_5, uuid_4, uuid_3, uuid_2, uuid_1, uuid_0) \
do {\
uuid_struct[0] = uuid_0; uuid_struct[1] = uuid_1; uuid_struct[2] = uuid_2; uuid_struct[3] = uuid_3; \
uuid_struct[4] = uuid_4; uuid_struct[5] = uuid_5; uuid_struct[6] = uuid_6; uuid_struct[7] = uuid_7; \
uuid_struct[8] = uuid_8; uuid_struct[9] = uuid_9; uuid_struct[10] = uuid_10; uuid_struct[11] = uuid_11; \
uuid_struct[12] = uuid_12; uuid_struct[13] = uuid_13; uuid_struct[14] = uuid_14; uuid_struct[15] = uuid_15; \
}while(0)
#define COPY_READWRITEARR_UUID(uuid_struct) COPY_UUID_128(uuid_struct,0x00,0x00,0x00,0x00,0xcc,0x7a,0x48,0x2a,0x98,0x4a,0x7f,0x2e,0xd5,0xb3,0xe5,0x8f)
#define COPY_ARRWRITE_UUID(uuid_struct) COPY_UUID_128(uuid_struct,0x00,0x00,0x00,0x00,0x8e,0x22,0x45,0x41,0x9d,0x4c,0x21,0xed,0xae,0x82,0xed,0x19)
#define COPY_ARRREAD_UUID(uuid_struct) COPY_UUID_128(uuid_struct,0x00,0x00,0x00,0x01,0x8e,0x22,0x45,0x41,0x9d,0x4c,0x21,0xed,0xae,0x82,0xed,0x19)
/* USER CODE BEGIN PF */
/* USER CODE END PF */
/**
* @brief Event handler
* @param Event: Address of the buffer holding the Event
* @retval Ack: Return whether the Event has been managed or not
*/
static SVCCTL_EvtAckStatus_t Custom_STM_Event_Handler(void *Event)
{
SVCCTL_EvtAckStatus_t return_value;
hci_event_pckt *event_pckt;
evt_blecore_aci *blecore_evt;
aci_gatt_attribute_modified_event_rp0 *attribute_modified;
aci_gatt_notification_complete_event_rp0 *notification_complete;
Custom_STM_App_Notification_evt_t Notification;
/* USER CODE BEGIN Custom_STM_Event_Handler_1 */
/* USER CODE END Custom_STM_Event_Handler_1 */
return_value = SVCCTL_EvtNotAck;
event_pckt = (hci_event_pckt *)(((hci_uart_pckt*)Event)->data);
switch (event_pckt->evt)
{
case HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE:
blecore_evt = (evt_blecore_aci*)event_pckt->data;
switch (blecore_evt->ecode)
{
case ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE:
/* USER CODE BEGIN EVT_BLUE_GATT_ATTRIBUTE_MODIFIED_BEGIN */
/* USER CODE END EVT_BLUE_GATT_ATTRIBUTE_MODIFIED_BEGIN */
attribute_modified = (aci_gatt_attribute_modified_event_rp0*)blecore_evt->data;
if (attribute_modified->Attr_Handle == (CustomContext.CustomArrreadHdle + CHARACTERISTIC_DESCRIPTOR_ATTRIBUTE_OFFSET))
{
return_value = SVCCTL_EvtAckFlowEnable;
/* USER CODE BEGIN CUSTOM_STM_Service_1_Char_2 */
/* USER CODE END CUSTOM_STM_Service_1_Char_2 */
switch (attribute_modified->Attr_Data[0])
{
/* USER CODE BEGIN CUSTOM_STM_Service_1_Char_2_attribute_modified */
/* USER CODE END CUSTOM_STM_Service_1_Char_2_attribute_modified */
/* Disabled Notification management */
case (!(COMSVC_Notification)):
/* USER CODE BEGIN CUSTOM_STM_Service_1_Char_2_Disabled_BEGIN */
/* USER CODE END CUSTOM_STM_Service_1_Char_2_Disabled_BEGIN */
Notification.Custom_Evt_Opcode = CUSTOM_STM_ARRREAD_NOTIFY_DISABLED_EVT;
Custom_STM_App_Notification(&Notification);
/* USER CODE BEGIN CUSTOM_STM_Service_1_Char_2_Disabled_END */
/* USER CODE END CUSTOM_STM_Service_1_Char_2_Disabled_END */
break;
/* Enabled Notification management */
case COMSVC_Notification:
/* USER CODE BEGIN CUSTOM_STM_Service_1_Char_2_COMSVC_Notification_BEGIN */
/* USER CODE END CUSTOM_STM_Service_1_Char_2_COMSVC_Notification_BEGIN */
Notification.Custom_Evt_Opcode = CUSTOM_STM_ARRREAD_NOTIFY_ENABLED_EVT;
Custom_STM_App_Notification(&Notification);
/* USER CODE BEGIN CUSTOM_STM_Service_1_Char_2_COMSVC_Notification_END */
/* USER CODE END CUSTOM_STM_Service_1_Char_2_COMSVC_Notification_END */
break;
default:
/* USER CODE BEGIN CUSTOM_STM_Service_1_Char_2_default */
/* USER CODE END CUSTOM_STM_Service_1_Char_2_default */
break;
}
} /* if (attribute_modified->Attr_Handle == (CustomContext.CustomArrreadHdle + CHARACTERISTIC_DESCRIPTOR_ATTRIBUTE_OFFSET))*/
else if (attribute_modified->Attr_Handle == (CustomContext.CustomArrwriteHdle + CHARACTERISTIC_VALUE_ATTRIBUTE_OFFSET))
{
return_value = SVCCTL_EvtAckFlowEnable;
/* USER CODE BEGIN CUSTOM_STM_Service_1_Char_1_ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE */
/* USER CODE END CUSTOM_STM_Service_1_Char_1_ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE */
} /* if (attribute_modified->Attr_Handle == (CustomContext.CustomArrwriteHdle + CHARACTERISTIC_VALUE_ATTRIBUTE_OFFSET))*/
/* USER CODE BEGIN EVT_BLUE_GATT_ATTRIBUTE_MODIFIED_END */
/* USER CODE END EVT_BLUE_GATT_ATTRIBUTE_MODIFIED_END */
break;
case ACI_GATT_READ_PERMIT_REQ_VSEVT_CODE :
/* USER CODE BEGIN EVT_BLUE_GATT_READ_PERMIT_REQ_BEGIN */
/* USER CODE END EVT_BLUE_GATT_READ_PERMIT_REQ_BEGIN */
/* USER CODE BEGIN EVT_BLUE_GATT_READ_PERMIT_REQ_END */
/* USER CODE END EVT_BLUE_GATT_READ_PERMIT_REQ_END */
break;
case ACI_GATT_WRITE_PERMIT_REQ_VSEVT_CODE:
/* USER CODE BEGIN EVT_BLUE_GATT_WRITE_PERMIT_REQ_BEGIN */
/* USER CODE END EVT_BLUE_GATT_WRITE_PERMIT_REQ_BEGIN */
/* USER CODE BEGIN EVT_BLUE_GATT_WRITE_PERMIT_REQ_END */
/* USER CODE END EVT_BLUE_GATT_WRITE_PERMIT_REQ_END */
break;
case ACI_GATT_NOTIFICATION_COMPLETE_VSEVT_CODE:
{
/* USER CODE BEGIN EVT_BLUE_GATT_NOTIFICATION_COMPLETE_BEGIN */
/* USER CODE END EVT_BLUE_GATT_NOTIFICATION_COMPLETE_BEGIN */
notification_complete = (aci_gatt_notification_complete_event_rp0*)blecore_evt->data;
Notification.Custom_Evt_Opcode = CUSTOM_STM_NOTIFICATION_COMPLETE_EVT;
Notification.AttrHandle = notification_complete->Attr_Handle;
Custom_STM_App_Notification(&Notification);
/* USER CODE BEGIN EVT_BLUE_GATT_NOTIFICATION_COMPLETE_END */
/* USER CODE END EVT_BLUE_GATT_NOTIFICATION_COMPLETE_END */
break;
}
/* USER CODE BEGIN BLECORE_EVT */
/* USER CODE END BLECORE_EVT */
default:
/* USER CODE BEGIN EVT_DEFAULT */
/* USER CODE END EVT_DEFAULT */
break;
}
/* USER CODE BEGIN EVT_VENDOR*/
/* USER CODE END EVT_VENDOR*/
break; /* HCI_VENDOR_SPECIFIC_DEBUG_EVT_CODE */
/* USER CODE BEGIN EVENT_PCKT_CASES*/
/* USER CODE END EVENT_PCKT_CASES*/
default:
/* USER CODE BEGIN EVENT_PCKT*/
/* USER CODE END EVENT_PCKT*/
break;
}
/* USER CODE BEGIN Custom_STM_Event_Handler_2 */
/* USER CODE END Custom_STM_Event_Handler_2 */
return(return_value);
}/* end Custom_STM_Event_Handler */
/* Public functions ----------------------------------------------------------*/
/**
* @brief Service initialization
* @param None
* @retval None
*/
void SVCCTL_InitCustomSvc(void)
{
Char_UUID_t uuid;
tBleStatus ret = BLE_STATUS_INVALID_PARAMS;
uint8_t max_attr_record;
/* USER CODE BEGIN SVCCTL_InitCustomSvc_1 */
/* USER CODE END SVCCTL_InitCustomSvc_1 */
/**
* Register the event handler to the BLE controller
*/
SVCCTL_RegisterSvcHandler(Custom_STM_Event_Handler);
/**
* readwriteArr
*
* Max_Attribute_Records = 1 + 2*2 + 1*no_of_char_with_notify_or_indicate_property + 1*no_of_char_with_broadcast_property
* service_max_attribute_record = 1 for readwriteArr +
* 2 for arrWrite +
* 2 for arrRead +
* 1 for arrRead configuration descriptor +
* = 6
*
* This value doesn't take into account number of descriptors manually added
* In case of descriptors added, please update the max_attr_record value accordingly in the next SVCCTL_InitService User Section
*/
max_attr_record = 6;
/* USER CODE BEGIN SVCCTL_InitService1 */
/* max_attr_record to be updated if descriptors have been added */
/* USER CODE END SVCCTL_InitService1 */
COPY_READWRITEARR_UUID(uuid.Char_UUID_128);
ret = aci_gatt_add_service(UUID_TYPE_128,
(Service_UUID_t *) &uuid,
PRIMARY_SERVICE,
max_attr_record,
&(CustomContext.CustomReadwritearrHdle));
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : aci_gatt_add_service command: readwriteArr, error code: 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: aci_gatt_add_service command: readwriteArr , handle = 0x%04x \n\r", CustomContext.CustomReadwritearrHdle);
}
/**
* arrWrite
*/
COPY_ARRWRITE_UUID(uuid.Char_UUID_128);
ret = aci_gatt_add_char(CustomContext.CustomReadwritearrHdle,
UUID_TYPE_128, &uuid,
SizeArrwrite,
CHAR_PROP_WRITE,
ATTR_PERMISSION_NONE,
GATT_NOTIFY_ATTRIBUTE_WRITE,
0x10,
CHAR_VALUE_LEN_CONSTANT,
&(CustomContext.CustomArrwriteHdle));
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : aci_gatt_add_char command : ARRWRITE, error code: 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: aci_gatt_add_char command : ARRWRITE , handle = 0x%04x \n\r", CustomContext.CustomArrwriteHdle);
}
/* USER CODE BEGIN SVCCTL_Init_Service1_Char1 */
/* Place holder for Characteristic Descriptors */
/* USER CODE END SVCCTL_Init_Service1_Char1 */
/**
* arrRead
*/
COPY_ARRREAD_UUID(uuid.Char_UUID_128);
ret = aci_gatt_add_char(CustomContext.CustomReadwritearrHdle,
UUID_TYPE_128, &uuid,
SizeArrread,
CHAR_PROP_NOTIFY,
ATTR_PERMISSION_NONE,
GATT_DONT_NOTIFY_EVENTS,
0x10,
CHAR_VALUE_LEN_CONSTANT,
&(CustomContext.CustomArrreadHdle));
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : aci_gatt_add_char command : ARRREAD, error code: 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: aci_gatt_add_char command : ARRREAD , handle = 0x%04x \n\r", CustomContext.CustomArrreadHdle);
}
/* USER CODE BEGIN SVCCTL_Init_Service1_Char2 */
/* Place holder for Characteristic Descriptors */
/* USER CODE END SVCCTL_Init_Service1_Char2 */
/* USER CODE BEGIN SVCCTL_InitCustomSvc_2 */
/* USER CODE END SVCCTL_InitCustomSvc_2 */
return;
}
/**
* @brief Characteristic update
* @param CharOpcode: Characteristic identifier
* @param Service_Instance: Instance of the service to which the characteristic belongs
*
*/
tBleStatus Custom_STM_App_Update_Char(Custom_STM_Char_Opcode_t CharOpcode, uint8_t *pPayload)
{
tBleStatus ret = BLE_STATUS_INVALID_PARAMS;
/* USER CODE BEGIN Custom_STM_App_Update_Char_1 */
/* USER CODE END Custom_STM_App_Update_Char_1 */
switch (CharOpcode)
{
case CUSTOM_STM_ARRWRITE:
ret = aci_gatt_update_char_value(CustomContext.CustomReadwritearrHdle,
CustomContext.CustomArrwriteHdle,
0, /* charValOffset */
SizeArrwrite, /* charValueLen */
(uint8_t *) pPayload);
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : aci_gatt_update_char_value ARRWRITE command, result : 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: aci_gatt_update_char_value ARRWRITE command\n\r");
}
/* USER CODE BEGIN CUSTOM_STM_App_Update_Service_1_Char_1*/
/* USER CODE END CUSTOM_STM_App_Update_Service_1_Char_1*/
break;
case CUSTOM_STM_ARRREAD:
ret = aci_gatt_update_char_value(CustomContext.CustomReadwritearrHdle,
CustomContext.CustomArrreadHdle,
0, /* charValOffset */
SizeArrread, /* charValueLen */
(uint8_t *) pPayload);
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : aci_gatt_update_char_value ARRREAD command, result : 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: aci_gatt_update_char_value ARRREAD command\n\r");
}
/* USER CODE BEGIN CUSTOM_STM_App_Update_Service_1_Char_2*/
/* USER CODE END CUSTOM_STM_App_Update_Service_1_Char_2*/
break;
default:
break;
}
/* USER CODE BEGIN Custom_STM_App_Update_Char_2 */
/* USER CODE END Custom_STM_App_Update_Char_2 */
return ret;
}
/**
* @brief Characteristic update
* @param CharOpcode: Characteristic identifier
* @param pPayload: Characteristic value
* @param size: Length of the characteristic value in octets
*
*/
tBleStatus Custom_STM_App_Update_Char_Variable_Length(Custom_STM_Char_Opcode_t CharOpcode, uint8_t *pPayload, uint8_t size)
{
tBleStatus ret = BLE_STATUS_INVALID_PARAMS;
/* USER CODE BEGIN Custom_STM_App_Update_Char_Variable_Length_1 */
/* USER CODE END Custom_STM_App_Update_Char_Variable_Length_1 */
switch (CharOpcode)
{
case CUSTOM_STM_ARRWRITE:
ret = aci_gatt_update_char_value(CustomContext.CustomReadwritearrHdle,
CustomContext.CustomArrwriteHdle,
0, /* charValOffset */
size, /* charValueLen */
(uint8_t *) pPayload);
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : aci_gatt_update_char_value ARRWRITE command, result : 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: aci_gatt_update_char_value ARRWRITE command\n\r");
}
/* USER CODE BEGIN Custom_STM_App_Update_Char_Variable_Length_Service_1_Char_1*/
/* USER CODE END Custom_STM_App_Update_Char_Variable_Length_Service_1_Char_1*/
break;
case CUSTOM_STM_ARRREAD:
ret = aci_gatt_update_char_value(CustomContext.CustomReadwritearrHdle,
CustomContext.CustomArrreadHdle,
0, /* charValOffset */
size, /* charValueLen */
(uint8_t *) pPayload);
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : aci_gatt_update_char_value ARRREAD command, result : 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: aci_gatt_update_char_value ARRREAD command\n\r");
}
/* USER CODE BEGIN Custom_STM_App_Update_Char_Variable_Length_Service_1_Char_2*/
/* USER CODE END Custom_STM_App_Update_Char_Variable_Length_Service_1_Char_2*/
break;
default:
break;
}
/* USER CODE BEGIN Custom_STM_App_Update_Char_Variable_Length_2 */
/* USER CODE END Custom_STM_App_Update_Char_Variable_Length_2 */
return ret;
}
/**
* @brief Characteristic update
* @param Connection_Handle
* @param CharOpcode: Characteristic identifier
* @param pPayload: Characteristic value
*
*/
tBleStatus Custom_STM_App_Update_Char_Ext(uint16_t Connection_Handle, Custom_STM_Char_Opcode_t CharOpcode, uint8_t *pPayload)
{
tBleStatus ret = BLE_STATUS_INVALID_PARAMS;
/* USER CODE BEGIN Custom_STM_App_Update_Char_Ext_1 */
/* USER CODE END Custom_STM_App_Update_Char_Ext_1 */
switch (CharOpcode)
{
case CUSTOM_STM_ARRWRITE:
/* USER CODE BEGIN Updated_Length_Service_1_Char_1*/
/* USER CODE END Updated_Length_Service_1_Char_1*/
ret = Generic_STM_App_Update_Char_Ext(Connection_Handle, CustomContext.CustomReadwritearrHdle, CustomContext.CustomArrwriteHdle, SizeArrwrite, pPayload);
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : Generic_STM_App_Update_Char_Ext command, result : 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: Generic_STM_App_Update_Char_Ext command\n\r");
}
break;
case CUSTOM_STM_ARRREAD:
/* USER CODE BEGIN Updated_Length_Service_1_Char_2*/
/* USER CODE END Updated_Length_Service_1_Char_2*/
ret = Generic_STM_App_Update_Char_Ext(Connection_Handle, CustomContext.CustomReadwritearrHdle, CustomContext.CustomArrreadHdle, SizeArrread, pPayload);
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : Generic_STM_App_Update_Char_Ext command, result : 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: Generic_STM_App_Update_Char_Ext command\n\r");
}
break;
default:
break;
}
/* USER CODE BEGIN Custom_STM_App_Update_Char_Ext_2 */
/* USER CODE END Custom_STM_App_Update_Char_Ext_2 */
return ret;
}
static tBleStatus Generic_STM_App_Update_Char_Ext(uint16_t ConnectionHandle, uint16_t ServiceHandle, uint16_t CharHandle, uint16_t CharValueLen, uint8_t *pPayload)
{
tBleStatus ret = BLE_STATUS_INVALID_PARAMS;
ret = aci_gatt_update_char_value_ext(ConnectionHandle,
ServiceHandle,
CharHandle,
0, /* update type:0 do not notify, 1 notify, 2 indicate */
CharValueLen, /* charValueLen */
0, /* value offset */
243, /* value length */
(uint8_t *) pPayload);
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : aci_gatt_update_char_value_ext command, part 1, result : 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: aci_gatt_update_char_value_ext command, part 1\n\r");
}
/* USER CODE BEGIN Custom_STM_App_Update_Char_Ext_Service_1_Char_1*/
if (CharValueLen-243<=243)
{
ret = aci_gatt_update_char_value_ext(ConnectionHandle,
ServiceHandle,
CharHandle,
1, /* update type:0 do not notify, 1 notify, 2 indicate */
CharValueLen, /* charValueLen */
243, /* value offset */
CharValueLen-243, /* value length */
(uint8_t *) ((pPayload)+243));
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : aci_gatt_update_char_value_ext command, part 2, result : 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: aci_gatt_update_char_value_ext command, part 2\n\r");
}
}
else
{
ret = aci_gatt_update_char_value_ext(ConnectionHandle,
ServiceHandle,
CharHandle,
0, /* update type:0 do not notify, 1 notify, 2 indicate */
CharValueLen, /* charValueLen */
243, /* value offset */
243, /* value length */
(uint8_t *) ((pPayload)+243));
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : aci_gatt_update_char_value_ext command, part 3, result : 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: aci_gatt_update_char_value_ext command, part 3\n\r");
}
ret = aci_gatt_update_char_value_ext(ConnectionHandle,
ServiceHandle,
CharHandle,
1, /* update type:0 do not notify, 1 notify, 2 indicate */
CharValueLen, /* charValueLen */
243+243, /* value offset */
CharValueLen-243-243, /* value length */
(uint8_t *) ((pPayload)+243+243));
if (ret != BLE_STATUS_SUCCESS)
{
APP_DBG_MSG(" Fail : aci_gatt_update_char_value_ext command, part 4, result : 0x%x \n\r", ret);
}
else
{
APP_DBG_MSG(" Success: aci_gatt_update_char_value_ext command, part 4\n\r");
}
}
return ret;
}
@@ -0,0 +1,105 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file App/custom_stm.h
* @author MCD Application Team
* @brief Header for custom_stm.c module.
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef CUSTOM_STM_H
#define CUSTOM_STM_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
typedef enum
{
/* readwriteArr */
CUSTOM_STM_ARRWRITE,
CUSTOM_STM_ARRREAD,
} Custom_STM_Char_Opcode_t;
typedef enum
{
/* arrWrite */
CUSTOM_STM_ARRWRITE_WRITE_EVT,
/* arrRead */
CUSTOM_STM_ARRREAD_NOTIFY_ENABLED_EVT,
CUSTOM_STM_ARRREAD_NOTIFY_DISABLED_EVT,
CUSTOM_STM_NOTIFICATION_COMPLETE_EVT,
CUSTOM_STM_BOOT_REQUEST_EVT
} Custom_STM_Opcode_evt_t;
typedef struct
{
uint8_t * pPayload;
uint8_t Length;
} Custom_STM_Data_t;
typedef struct
{
Custom_STM_Opcode_evt_t Custom_Evt_Opcode;
Custom_STM_Data_t DataTransfered;
uint16_t ConnectionHandle;
uint8_t ServiceInstance;
uint16_t AttrHandle;
} Custom_STM_App_Notification_evt_t;
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
extern uint16_t SizeArrwrite;
extern uint16_t SizeArrread;
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* External variables --------------------------------------------------------*/
/* USER CODE BEGIN EV */
/* USER CODE END EV */
/* Exported macros -----------------------------------------------------------*/
/* USER CODE BEGIN EM */
/* USER CODE END EM */
/* Exported functions ------------------------------------------------------- */
void SVCCTL_InitCustomSvc(void);
void Custom_STM_App_Notification(Custom_STM_App_Notification_evt_t *pNotification);
tBleStatus Custom_STM_App_Update_Char(Custom_STM_Char_Opcode_t CharOpcode, uint8_t *pPayload);
tBleStatus Custom_STM_App_Update_Char_Variable_Length(Custom_STM_Char_Opcode_t CharOpcode, uint8_t *pPayload, uint8_t size);
tBleStatus Custom_STM_App_Update_Char_Ext(uint16_t Connection_Handle, Custom_STM_Char_Opcode_t CharOpcode, uint8_t *pPayload);
/* USER CODE BEGIN EF */
/* USER CODE END EF */
#ifdef __cplusplus
}
#endif
#endif /*CUSTOM_STM_H */
@@ -0,0 +1,41 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file App/template_server_app.h
* @author MCD Application Team
* @brief Header for p2p_server_app.c module
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* USER CODE BEGIN UserCode */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef TEMPLATE_SERVER_APP_H
#define TEMPLATE_SERVER_APP_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void TEMPLATE_APP_Init( void );
#ifdef __cplusplus
}
#endif
#endif /*P2P_SERVER_APP_H */
@@ -0,0 +1,133 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file App/tl_dbg_conf.h
* @author MCD Application Team
* @brief Debug configuration file for stm32wpan transport layer interface.
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef TL_DBG_CONF_H
#define TL_DBG_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
/* USER CODE BEGIN Tl_Conf */
/* Includes ------------------------------------------------------------------*/
#include "app_conf.h" /* required as some configuration used in dbg_trace.h are set there */
#include "dbg_trace.h"
#include "hw_if.h"
/**
* Enable or Disable traces
* The raw data output is the hci binary packet format as specified by the BT specification *
*/
#define TL_SHCI_CMD_DBG_EN 0 /* Reports System commands sent to CPU2 and the command response */
#define TL_SHCI_CMD_DBG_RAW_EN 0 /* Reports raw data System commands sent to CPU2 and the command response */
#define TL_SHCI_EVT_DBG_EN 0 /* Reports System Asynchronous Events received from CPU2 */
#define TL_SHCI_EVT_DBG_RAW_EN 0 /* Reports raw data System Asynchronous Events received from CPU2 */
#define TL_HCI_CMD_DBG_EN 0 /* Reports BLE command sent to CPU2 and the command response */
#define TL_HCI_CMD_DBG_RAW_EN 0 /* Reports raw data BLE command sent to CPU2 and the command response */
#define TL_HCI_EVT_DBG_EN 0 /* Reports BLE Asynchronous Events received from CPU2 */
#define TL_HCI_EVT_DBG_RAW_EN 0 /* Reports raw data BLE Asynchronous Events received from CPU2 */
#define TL_MM_DBG_EN 0 /* Reports the information of the buffer released to CPU2 */
/**
* Macro definition
*/
/**
* System Transport Layer
*/
#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_CMD_DBG_RAW_EN != 0)
#define TL_SHCI_CMD_DBG_RAW(_PDATA_, _SIZE_) HW_UART_Transmit(hw_uart1, (uint8_t*)_PDATA_, _SIZE_, (~0))
#else
#define TL_SHCI_CMD_DBG_RAW(...)
#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
#if (TL_SHCI_EVT_DBG_RAW_EN != 0)
#define TL_SHCI_EVT_DBG_RAW(_PDATA_, _SIZE_) HW_UART_Transmit(hw_uart1, (uint8_t*)_PDATA_, _SIZE_, (~0))
#else
#define TL_SHCI_EVT_DBG_RAW(...)
#endif
/**
* BLE Transport Layer
*/
#if (TL_HCI_CMD_DBG_EN != 0)
#define TL_HCI_CMD_DBG_MSG PRINT_MESG_DBG
#define TL_HCI_CMD_DBG_BUF PRINT_LOG_BUFF_DBG
#else
#define TL_HCI_CMD_DBG_MSG(...)
#define TL_HCI_CMD_DBG_BUF(...)
#endif
#if (TL_HCI_CMD_DBG_RAW_EN != 0)
#define TL_HCI_CMD_DBG_RAW(_PDATA_, _SIZE_) HW_UART_Transmit(hw_uart1, (uint8_t*)_PDATA_, _SIZE_, (~0))
#else
#define TL_HCI_CMD_DBG_RAW(...)
#endif
#if (TL_HCI_EVT_DBG_EN != 0)
#define TL_HCI_EVT_DBG_MSG PRINT_MESG_DBG
#define TL_HCI_EVT_DBG_BUF PRINT_LOG_BUFF_DBG
#else
#define TL_HCI_EVT_DBG_MSG(...)
#define TL_HCI_EVT_DBG_BUF(...)
#endif
#if (TL_HCI_EVT_DBG_RAW_EN != 0)
#define TL_HCI_EVT_DBG_RAW(_PDATA_, _SIZE_) HW_UART_Transmit(hw_uart1, (uint8_t*)_PDATA_, _SIZE_, (~0))
#else
#define TL_HCI_EVT_DBG_RAW(...)
#endif
/**
* Memory Manager - Released buffer tracing
*/
#if (TL_MM_DBG_EN != 0)
#define TL_MM_DBG_MSG PRINT_MESG_DBG
#else
#define TL_MM_DBG_MSG(...)
#endif
/* USER CODE END Tl_Conf */
#ifdef __cplusplus
}
#endif
#endif /*TL_DBG_CONF_H */
@@ -0,0 +1,780 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file Target/hw_ipcc.c
* @author MCD Application Team
* @brief Hardware IPCC source file for STM32WPAN Middleware.
******************************************************************************
* @attention
*
* Copyright (c) 2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "app_common.h"
#include "mbox_def.h"
#include "utilities_conf.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 ------------------------------------------------------------*/
#if ( (STM32WB15xx != 0) && (CFG_LPM_STANDBY_SUPPORTED != 0) )
#define HW_IPCC_SET_FLAG_CHX(x) HW_IPCC_SetFlagCHx(x)
#else
#define HW_IPCC_SET_FLAG_CHX(x) LL_C1_IPCC_SetFlag_CHx(IPCC, x)
#endif
/* 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 LLD_TESTS_WB
static void HW_IPCC_LLDTESTS_ReceiveCliRspHandler( void );
static void HW_IPCC_LLDTESTS_ReceiveM0CmdHandler( void );
#endif
#ifdef LLD_BLE_WB
/*static void HW_IPCC_LLD_BLE_ReceiveCliRspHandler( void );*/
static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void );
static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void );
#endif
#ifdef MAC_802_15_4_WB
static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void );
static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void );
#endif
#ifdef ZIGBEE_WB
static void HW_IPCC_ZIGBEE_CmdEvtHandler( void );
static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void );
static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void );
#endif
#if ( (STM32WB15xx != 0) && (CFG_LPM_STANDBY_SUPPORTED != 0) )
static void IPCC_Wakeup_CPU2(void);
static void HW_IPCC_SetFlagCHx(uint32_t Channel);
#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 LLD_TESTS_WB
else if (HW_IPCC_RX_PENDING( HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ))
{
HW_IPCC_LLDTESTS_ReceiveCliRspHandler();
}
else if (HW_IPCC_RX_PENDING( HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ))
{
HW_IPCC_LLDTESTS_ReceiveM0CmdHandler();
}
#endif /* LLD_TESTS_WB */
#ifdef LLD_BLE_WB
else if (HW_IPCC_RX_PENDING( HW_IPCC_LLD_BLE_RSP_CHANNEL ))
{
HW_IPCC_LLD_BLE_ReceiveRspHandler();
}
else if (HW_IPCC_RX_PENDING( HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ))
{
HW_IPCC_LLD_BLE_ReceiveM0CmdHandler();
}
#endif /* LLD_TESTS_WB */
#ifdef ZIGBEE_WB
else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ))
{
HW_IPCC_ZIGBEE_StackNotifEvtHandler();
}
else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ))
{
HW_IPCC_ZIGBEE_StackM0RequestHandler();
}
#endif /* ZIGBEE_WB */
else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL ))
{
HW_IPCC_BLE_EvtHandler();
}
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 LLD_TESTS_WB
// No TX handler for LLD tests
#endif /* LLD_TESTS_WB */
#ifdef ZIGBEE_WB
if (HW_IPCC_TX_PENDING( HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ))
{
HW_IPCC_ZIGBEE_CmdEvtHandler();
}
#endif /* ZIGBEE_WB */
else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ))
{
HW_IPCC_MM_FreeBufHandler();
}
else if (HW_IPCC_TX_PENDING( HW_IPCC_HCI_ACL_DATA_CHANNEL ))
{
HW_IPCC_BLE_AclDataEvtHandler();
}
return;
}
/******************************************************************************
* GENERAL
******************************************************************************/
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
*/
LL_EXTI_EnableRisingTrig_32_63( LL_EXTI_LINE_41 );
/* It is required to have at least a system clock cycle before a SEV after LL_EXTI_EnableRisingTrig_32_63() */
LL_C2_EXTI_EnableEvent_32_63( LL_EXTI_LINE_41 );
/**
* In case the SBSFU is implemented, it may have already set the C2BOOT bit to startup the CPU2.
* 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;
}
#if(CFG_LPM_STANDBY_SUPPORTED != 0)
static void IPCC_Wakeup_CPU2(void)
{
/**
* When the device is out of standby, it is required to use the EXTI mechanism to wakeup CPU2
*/
LL_EXTI_EnableRisingTrig_32_63( LL_EXTI_LINE_41 );
/* It is required to have at least a system clock cycle before a SEV after LL_EXTI_EnableRisingTrig_32_63() */
LL_C2_EXTI_EnableEvent_32_63( LL_EXTI_LINE_41 );
__SEV( ); /* Set the internal event flag and send an event to the CPU2 */
__WFE( ); /* Clear the internal event flag */
return;
}
static void HW_IPCC_SetFlagCHx(uint32_t Channel)
{
IPCC_Wakeup_CPU2();
LL_C1_IPCC_SetFlag_CHx(IPCC, Channel);
return;
}
#endif
/******************************************************************************
* BLE
******************************************************************************/
void HW_IPCC_BLE_Init( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_BLE_EVENT_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
void HW_IPCC_BLE_SendCmd( void )
{
HW_IPCC_SET_FLAG_CHX( 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 )
{
HW_IPCC_SET_FLAG_CHX( HW_IPCC_HCI_ACL_DATA_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
static void HW_IPCC_BLE_AclDataEvtHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_BLE_AclDataAckNot();
return;
}
__weak void HW_IPCC_BLE_AclDataAckNot( void ){};
__weak void HW_IPCC_BLE_RxEvtNot( void ){};
/******************************************************************************
* SYSTEM
******************************************************************************/
void HW_IPCC_SYS_Init( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
void HW_IPCC_SYS_SendCmd( void )
{
HW_IPCC_SET_FLAG_CHX( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
static void HW_IPCC_SYS_CmdEvtHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_SYS_CmdEvtNot();
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 )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
void HW_IPCC_MAC_802_15_4_SendCmd( void )
{
HW_IPCC_SET_FLAG_CHX( HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
void HW_IPCC_MAC_802_15_4_SendAck( void )
{
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_MAC_802_15_4_CmdEvtNot();
return;
}
static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_MAC_802_15_4_EvtNot();
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 )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL );
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
void HW_IPCC_OT_SendCmd( void )
{
HW_IPCC_SET_FLAG_CHX( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
void HW_IPCC_CLI_SendCmd( void )
{
HW_IPCC_SET_FLAG_CHX( 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 );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
void HW_IPCC_THREAD_CliSendAck( void )
{
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
static void HW_IPCC_OT_CmdEvtHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_OT_CmdEvtNot();
return;
}
static void HW_IPCC_THREAD_NotEvtHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_THREAD_EvtNot();
return;
}
static void HW_IPCC_THREAD_CliNotEvtHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_THREAD_CliEvtNot();
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 */
/******************************************************************************
* LLD TESTS
******************************************************************************/
#ifdef LLD_TESTS_WB
void HW_IPCC_LLDTESTS_Init( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL );
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
void HW_IPCC_LLDTESTS_SendCliCmd( void )
{
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL );
return;
}
static void HW_IPCC_LLDTESTS_ReceiveCliRspHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_LLDTESTS_ReceiveCliRsp();
return;
}
void HW_IPCC_LLDTESTS_SendCliRspAck( void )
{
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
static void HW_IPCC_LLDTESTS_ReceiveM0CmdHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_LLDTESTS_ReceiveM0Cmd();
return;
}
void HW_IPCC_LLDTESTS_SendM0CmdAck( void )
{
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
__weak void HW_IPCC_LLDTESTS_ReceiveCliRsp( void ){};
__weak void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void ){};
#endif /* LLD_TESTS_WB */
/******************************************************************************
* LLD BLE
******************************************************************************/
#ifdef LLD_BLE_WB
void HW_IPCC_LLD_BLE_Init( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL );
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
void HW_IPCC_LLD_BLE_SendCliCmd( void )
{
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CLI_CMD_CHANNEL );
return;
}
/*static void HW_IPCC_LLD_BLE_ReceiveCliRspHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_LLD_BLE_ReceiveCliRsp();
return;
}*/
void HW_IPCC_LLD_BLE_SendCliRspAck( void )
{
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void )
{
//LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL );
HW_IPCC_LLD_BLE_ReceiveM0Cmd();
return;
}
void HW_IPCC_LLD_BLE_SendM0CmdAck( void )
{
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL );
//LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL );
return;
}
__weak void HW_IPCC_LLD_BLE_ReceiveCliRsp( void ){};
__weak void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ){};
/* Transparent Mode */
void HW_IPCC_LLD_BLE_SendCmd( void )
{
LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CMD_CHANNEL );
return;
}
static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_LLD_BLE_ReceiveRsp();
return;
}
void HW_IPCC_LLD_BLE_SendRspAck( void )
{
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
#endif /* LLD_BLE_WB */
/******************************************************************************
* ZIGBEE
******************************************************************************/
#ifdef ZIGBEE_WB
void HW_IPCC_ZIGBEE_Init( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL );
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
void HW_IPCC_ZIGBEE_SendM4RequestToM0( void )
{
HW_IPCC_SET_FLAG_CHX( HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
void HW_IPCC_ZIGBEE_SendM4AckToM0Notify( void )
{
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
static void HW_IPCC_ZIGBEE_CmdEvtHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_ZIGBEE_RecvAppliAckFromM0();
return;
}
static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_ZIGBEE_RecvM0NotifyToM4();
return;
}
static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
HW_IPCC_ZIGBEE_RecvM0RequestToM4();
return;
}
void HW_IPCC_ZIGBEE_SendM4AckToM0Request( void )
{
LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL );
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
return;
}
__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;
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
}
else
{
cb();
HW_IPCC_SET_FLAG_CHX( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
}
return;
}
static void HW_IPCC_MM_FreeBufHandler( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
FreeBufCb();
HW_IPCC_SET_FLAG_CHX( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
return;
}
/******************************************************************************
* TRACES
******************************************************************************/
void HW_IPCC_TRACES_Init( void )
{
UTILS_ENTER_CRITICAL_SECTION();
LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_TRACES_CHANNEL );
UTILS_EXIT_CRITICAL_SECTION();
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 ){};