Skip to content

Commit

Permalink
chore: adapt STM32_WPAN sources
Browse files Browse the repository at this point in the history
Signed-off-by: Frederic Pillon <[email protected]>
  • Loading branch information
fpistm committed Jan 11, 2024
1 parent 20174a8 commit e1874c7
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 12 deletions.
49 changes: 41 additions & 8 deletions src/utility/STM32_WPAN/app_conf_default.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file app_conf.h
* @file app_conf_default.h
* @author MCD Application Team
* @brief Application configuration file for STM32WPAN Middleware.
* @brief Default application configuration file for STM32WPAN Middleware.
******************************************************************************
* @attention
*
Expand All @@ -19,18 +19,40 @@
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef APP_CONF_H
#define APP_CONF_H
#ifndef APP_CONF_DEFAULT_H
#define APP_CONF_DEFAULT_H

#if 0
#include "hw.h"
#include "hw_conf.h"
#include "hw_if.h"
#include "ble_bufsize.h"
#endif

/******************************************************************************
* Application Config
******************************************************************************/

/**< generic parameters ******************************************************/
/* HCI related defines */

#define ACI_HAL_SET_TX_POWER_LEVEL 0xFC0F
#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C
#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D
#define MAX_HCI_ACL_PACKET_SIZE (sizeof(TL_PacketHeader_t) + 5 + 251)
#define HCI_RESET 0x0C03

#ifndef BLE_SHARED_MEM_BYTE_ORDER
#define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST
#endif
#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128

/**
* Define Tx Power
*/
#define CFG_TX_POWER (0x18) /* -0.15dBm */

#if 0
/**
* Define Secure Connections Support
*/
Expand Down Expand Up @@ -104,6 +126,7 @@
#define CFG_FW_SUBVERSION (1)
#define CFG_FW_BRANCH (0)
#define CFG_FW_BUILD (0)
#endif

/******************************************************************************
* BLE Stack
Expand Down Expand Up @@ -250,7 +273,7 @@
* 0: LE Power Class 2-3
* other bits: complete with Options_extension flag
*/
#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_HOST | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3)
#define CFG_BLE_OPTIONS (SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY | SHCI_C2_BLE_INIT_OPTIONS_WITH_SVC_CHANGE_DESC | SHCI_C2_BLE_INIT_OPTIONS_DEVICE_NAME_RW | SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV | SHCI_C2_BLE_INIT_OPTIONS_CS_ALGO2 | SHCI_C2_BLE_INIT_OPTIONS_FULL_GATTDB_NVM | SHCI_C2_BLE_INIT_OPTIONS_GATT_CACHING_NOTUSED | SHCI_C2_BLE_INIT_OPTIONS_POWER_CLASS_2_3)

/**
* BLE stack Options_extension flags to be configured with:
Expand Down Expand Up @@ -292,7 +315,11 @@
* This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set
*/

#define CFG_BLE_MAX_ADV_SET_NBR (8)
#if defined(STM32WB15xx)
#define CFG_BLE_MAX_ADV_SET_NBR (3)
#else
#define CFG_BLE_MAX_ADV_SET_NBR (8)
#endif

/* Maximum advertising data length (in bytes)
* Range: 31 .. 1650 with limitation:
Expand All @@ -301,7 +328,11 @@
* This parameter is considered by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_EXT_ADV flag set
*/

#define CFG_BLE_MAX_ADV_DATA_LEN (207)
#if defined(STM32WB15xx)
#define CFG_BLE_MAX_ADV_DATA_LEN (414)
#else
#define CFG_BLE_MAX_ADV_DATA_LEN (207)
#endif

/* RF TX Path Compensation Value (16-bit signed integer). Units: 0.1 dB.
* Range: -1280 .. 1280
Expand All @@ -324,6 +355,7 @@

#define CFG_BLE_CORE_VERSION (SHCI_C2_BLE_INIT_BLE_CORE_5_4)

#if 0
/******************************************************************************
* Transport Layer
******************************************************************************/
Expand Down Expand Up @@ -659,4 +691,5 @@ typedef enum

#define CFG_OTP_END_ADRESS OTP_AREA_END_ADDR

#endif /*APP_CONF_H */
#endif
#endif /*APP_CONF_DEFAULT_H */
13 changes: 11 additions & 2 deletions src/utility/STM32_WPAN/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,23 @@ extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32_def.h"
#include "stm32wbxx_ll_bus.h"
#include "stm32wbxx_ll_exti.h"
#include "stm32wbxx_ll_system.h"
#include "stm32wbxx_ll_rcc.h"
#include "stm32wbxx_ll_ipcc.h"
#include "stm32wbxx_ll_cortex.h"
#include "stm32wbxx_ll_utils.h"
#include "stm32wbxx_ll_pwr.h"

/******************************************************************************
* HW IPCC
******************************************************************************/
void HW_IPCC_Enable( void );
void HW_IPCC_Init( void );
void HW_IPCC_Rx_Handler( void );
void HW_IPCC_Tx_Handler( void );
#define HW_IPCC_Rx_Handler IPCC_C1_RX_IRQHandler
#define HW_IPCC_Tx_Handler IPCC_C1_TX_IRQHandler

void HW_IPCC_BLE_Init( void );
void HW_IPCC_BLE_SendCmd( void );
Expand Down
4 changes: 3 additions & 1 deletion src/utility/STM32_WPAN/hw_ipcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
*/
/* USER CODE END Header */

#if defined(STM32WBxx)
/* Includes ------------------------------------------------------------------*/
#include "app_common.h"
#include "hw.h"
#include "mbox_def.h"

/* Global variables ---------------------------------------------------------*/
Expand Down Expand Up @@ -667,3 +668,4 @@ static void HW_IPCC_TRACES_EvtHandler( void )
}

__weak void HW_IPCC_TRACES_EvtNot( void ){};
#endif /* STM32WBxx */
2 changes: 2 additions & 0 deletions src/utility/STM32_WPAN/shci.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/


#if defined(STM32WBxx)
/* Includes ------------------------------------------------------------------*/
#include "stm32_wpan_common.h"

Expand Down Expand Up @@ -759,3 +760,4 @@ SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo )

return (SHCI_Success);
}
#endif /* STM32WBxx */
17 changes: 17 additions & 0 deletions src/utility/STM32_WPAN/shci_tl.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
*/


#if defined(STM32WBxx)
/* Includes ------------------------------------------------------------------*/
#include "stm32_wpan_common.h"

#include "stm_list.h"
#include "shci_tl.h"
#include "stm32_def.h"

/* Private typedef -----------------------------------------------------------*/
typedef enum
Expand Down Expand Up @@ -168,6 +170,20 @@ void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payl
return;
}

void shci_notify_asynch_evt(void *pdata)
{
UNUSED(pdata);
/* Need to parse data in future version */
shci_user_evt_proc();
}

void shci_register_io_bus(tSHciIO *fops)
{
/* Register IO bus services */
fops->Init = TL_SYS_Init;
fops->Send = TL_SYS_SendCmd;
}

/* Private functions ---------------------------------------------------------*/
static void TlInit( TL_CmdPacket_t * p_cmdbuffer )
{
Expand Down Expand Up @@ -250,3 +266,4 @@ __WEAK void shci_cmd_resp_release(uint32_t flag)

return;
}
#endif /* STM32WBxx */
6 changes: 5 additions & 1 deletion src/utility/STM32_WPAN/stm_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
*/


#if defined(STM32WBxx)
/******************************************************************************
* Include Files
******************************************************************************/
#include "utilities_common.h"
#include "stdint.h"
#include "cmsis_gcc.h"
#include "stm32_wpan_common.h"

#include "stm_list.h"

Expand Down Expand Up @@ -204,3 +207,4 @@ void LST_get_prev_node (tListNode * ref_node, tListNode ** node)

__set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/
}
#endif /* STM32WBxx */
6 changes: 6 additions & 0 deletions src/utility/STM32_WPAN/tl_mbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
******************************************************************************
*/

#if defined(STM32WBxx)
/* Includes ------------------------------------------------------------------*/
#include "stm32_wpan_common.h"
#include "hw.h"
Expand Down Expand Up @@ -51,8 +52,10 @@ PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_BleLldTable_t TL_BleLldTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_SysTable_t TL_SysTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_MemManagerTable_t TL_MemManagerTable;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_TracesTable_t TL_TracesTable;
#if 0
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_Mac_802_15_4_t TL_Mac_802_15_4_Table;
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static MB_ZigbeeTable_t TL_Zigbee_Table;
#endif

/**< tables */
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static tListNode FreeBufQueue;
Expand Down Expand Up @@ -97,8 +100,10 @@ void TL_Init( void )
TL_RefTable.p_sys_table = &TL_SysTable;
TL_RefTable.p_mem_manager_table = &TL_MemManagerTable;
TL_RefTable.p_traces_table = &TL_TracesTable;
#if 0
TL_RefTable.p_mac_802_15_4_table = &TL_Mac_802_15_4_Table;
TL_RefTable.p_zigbee_table = &TL_Zigbee_Table;
#endif
HW_IPCC_Init();

return;
Expand Down Expand Up @@ -846,3 +851,4 @@ static void OutputDbgTrace(TL_MB_PacketType_t packet_type, uint8_t* buffer)

return;
}
#endif /* STM32WBxx */

0 comments on commit e1874c7

Please sign in to comment.