diff --git a/README.md b/README.md index b2d48b13..3a0691ab 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,9 @@ https://github.com/arduino-libraries/ArduinoBLE # Configuration STM32Cube_WPAN has several configuration options, which are set in the `app_conf.h`. This package has a default configuration named `app_conf_default.h`. -The user can include the file `app_conf_custom.h` to customize the ble application. Options wrapped in `#ifndef, #endif` in `app_conf_default.h` can be overwritten. Additional options can be added. +The user can include the file `app_conf_custom.h` to customize the BLE application. +Options wrapped in `#ifndef`, `#endif` in `app_conf_default.h` can be overwritten. +Additional options can be added. ## License diff --git a/src/utility/STM32Cube_FW/app_conf.h b/src/utility/STM32Cube_FW/app_conf.h index 888c91a0..3246393f 100644 --- a/src/utility/STM32Cube_FW/app_conf.h +++ b/src/utility/STM32Cube_FW/app_conf.h @@ -9,12 +9,12 @@ #ifndef APP_CONF_H #define APP_CONF_H -#include "ble_bufsize.h" #include "hw.h" +#include "ble_bufsize.h" #if __has_include("app_conf_custom.h") -#include "app_conf_custom.h" + #include "app_conf_custom.h" #endif #include "app_conf_default.h" -#endif /* APP_CONF_H */ \ No newline at end of file +#endif /* APP_CONF_H */ diff --git a/src/utility/STM32Cube_FW/app_conf_default.h b/src/utility/STM32Cube_FW/app_conf_default.h index 58c9f5bb..e870c321 100644 --- a/src/utility/STM32Cube_FW/app_conf_default.h +++ b/src/utility/STM32Cube_FW/app_conf_default.h @@ -34,7 +34,7 @@ #define HCI_RESET 0x0C03 #ifndef BLE_SHARED_MEM_BYTE_ORDER -#define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST + #define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST #endif #define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128 @@ -42,7 +42,7 @@ * Define Tx Power */ #ifndef CFG_TX_POWER -#define CFG_TX_POWER (0x18) /* -0.15dBm */ + #define CFG_TX_POWER (0x18) /* -0.15dBm */ #endif /****************************************************************************** @@ -53,7 +53,7 @@ * Valid values are from 1 to 8 */ #ifndef CFG_BLE_NUM_LINK -#define CFG_BLE_NUM_LINK 8 + #define CFG_BLE_NUM_LINK 8 #endif /** @@ -62,7 +62,7 @@ * services */ #ifndef CFG_BLE_NUM_GATT_SERVICES -#define CFG_BLE_NUM_GATT_SERVICES 8 + #define CFG_BLE_NUM_GATT_SERVICES 8 #endif /** @@ -72,14 +72,14 @@ * added automatically during device initialization so this parameters should be 9 plus the number of user Attributes */ #ifndef CFG_BLE_NUM_GATT_ATTRIBUTES -#define CFG_BLE_NUM_GATT_ATTRIBUTES 68 + #define CFG_BLE_NUM_GATT_ATTRIBUTES 68 #endif /** * Maximum supported ATT_MTU size */ #ifndef CFG_BLE_MAX_ATT_MTU -#define CFG_BLE_MAX_ATT_MTU (156) + #define CFG_BLE_MAX_ATT_MTU (156) #endif /** @@ -94,7 +94,7 @@ * The total amount of memory needed is the sum of the above quantities for each attribute. */ #ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE -#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) + #define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344) #endif /** @@ -102,7 +102,7 @@ */ //#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU) #ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE -#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) + #define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A) #endif /** @@ -111,21 +111,21 @@ //#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, // CFG_BLE_NUM_LINK)) #ifndef CFG_BLE_MBLOCK_COUNT -#define CFG_BLE_MBLOCK_COUNT (0x79) + #define CFG_BLE_MBLOCK_COUNT (0x79) #endif /** * Enable or disable the Extended Packet length feature. Valid values are 0 or 1. */ #ifndef CFG_BLE_DATA_LENGTH_EXTENSION -#define CFG_BLE_DATA_LENGTH_EXTENSION 1 + #define CFG_BLE_DATA_LENGTH_EXTENSION 1 #endif /** * Sleep clock accuracy in Slave mode (ppm value) */ #ifndef CFG_BLE_SLAVE_SCA -#define CFG_BLE_SLAVE_SCA 500 + #define CFG_BLE_SLAVE_SCA 500 #endif /** @@ -140,7 +140,7 @@ * 7 : 0 ppm to 20 ppm */ #ifndef CFG_BLE_MASTER_SCA -#define CFG_BLE_MASTER_SCA 0 + #define CFG_BLE_MASTER_SCA 0 #endif /** @@ -149,21 +149,21 @@ * 0 : external crystal ( no calibration ) */ #ifndef CFG_BLE_LSE_SOURCE -#define CFG_BLE_LSE_SOURCE 0 + #define CFG_BLE_LSE_SOURCE 0 #endif /** * Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us) */ #ifndef CFG_BLE_HSE_STARTUP_TIME -#define CFG_BLE_HSE_STARTUP_TIME 0x148 + #define CFG_BLE_HSE_STARTUP_TIME 0x148 #endif /** * Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us) */ #ifndef CFG_BLE_MAX_CONN_EVENT_LENGTH -#define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) + #define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF) #endif /** diff --git a/src/utility/STM32Cube_FW/ble_bufsize.h b/src/utility/STM32Cube_FW/ble_bufsize.h index 2961cd99..8930e401 100644 --- a/src/utility/STM32Cube_FW/ble_bufsize.h +++ b/src/utility/STM32Cube_FW/ble_bufsize.h @@ -90,35 +90,35 @@ /* * BLE_FIXED_BUFFER_SIZE_BYTES: - * A part of the RAM, is dynamically allocated by initializing all the pointers + * A part of the RAM, is dynamically allocated by initializing all the pointers * defined in a global context variable "mem_alloc_ctx_p". - * This initialization is made in the Dynamic_allocator functions, which + * This initialization is made in the Dynamic_allocator functions, which * assign a portion of RAM given by the external application to the above * mentioned "global pointers". * - * The size of this Dynamic RAM is made of 2 main components: + * The size of this Dynamic RAM is made of 2 main components: * - a part that is parameters-dependent (num of links, GATT buffers, ...), * and which value is defined by the following macro; * - a part, that may be considered "fixed", i.e. independent from the above * mentioned parameters. */ #if (SLAVE_ONLY == 0) && (LL_ONLY == 0) - #define BLE_FIXED_BUFFER_SIZE_BYTES 6960 /* Full stack */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 6960 /* Full stack */ #elif SLAVE_ONLY == 0 - #define BLE_FIXED_BUFFER_SIZE_BYTES 6256 /* LL only */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 6256 /* LL only */ #else - #define BLE_FIXED_BUFFER_SIZE_BYTES 6696 /* Slave only */ +#define BLE_FIXED_BUFFER_SIZE_BYTES 6696 /* Slave only */ #endif /* * BLE_PER_LINK_SIZE_BYTES: additional memory size used per link */ #if (SLAVE_ONLY == 0) && (LL_ONLY == 0) - #define BLE_PER_LINK_SIZE_BYTES 380 /* Full stack */ +#define BLE_PER_LINK_SIZE_BYTES 380 /* Full stack */ #elif SLAVE_ONLY == 0 - #define BLE_PER_LINK_SIZE_BYTES 196 /* LL only */ +#define BLE_PER_LINK_SIZE_BYTES 196 /* LL only */ #else - #define BLE_PER_LINK_SIZE_BYTES 332 /* Slave only */ +#define BLE_PER_LINK_SIZE_BYTES 332 /* Slave only */ #endif /* diff --git a/src/utility/STM32Cube_FW/hw.h b/src/utility/STM32Cube_FW/hw.h index 09b12aff..a94bec9c 100644 --- a/src/utility/STM32Cube_FW/hw.h +++ b/src/utility/STM32Cube_FW/hw.h @@ -26,7 +26,7 @@ extern "C" { #endif -/* Includes ------------------------------------------------------------------*/ + /* Includes ------------------------------------------------------------------*/ #include "stm32_def.h" #include "stm32wbxx_ll_bus.h" #include "stm32wbxx_ll_exti.h" @@ -37,56 +37,56 @@ extern "C" { #include "stm32wbxx_ll_utils.h" #include "stm32wbxx_ll_pwr.h" -/****************************************************************************** - * HW IPCC - ******************************************************************************/ -void HW_IPCC_Enable(void); -void HW_IPCC_Init(void); - -void HW_IPCC_BLE_Init(void); -void HW_IPCC_BLE_SendCmd(void); -void HW_IPCC_MM_SendFreeBuf(void (*cb)(void)); -void HW_IPCC_BLE_RxEvtNot(void); -void HW_IPCC_BLE_SendAclData(void); -void HW_IPCC_BLE_AclDataAckNot(void); - -void HW_IPCC_SYS_Init(void); -void HW_IPCC_SYS_SendCmd(void); -void HW_IPCC_SYS_CmdEvtNot(void); -void HW_IPCC_SYS_EvtNot(void); - -void HW_IPCC_THREAD_Init(void); -void HW_IPCC_OT_SendCmd(void); -void HW_IPCC_CLI_SendCmd(void); -void HW_IPCC_THREAD_SendAck(void); -void HW_IPCC_OT_CmdEvtNot(void); -void HW_IPCC_CLI_CmdEvtNot(void); -void HW_IPCC_THREAD_EvtNot(void); -void HW_IPCC_THREAD_CliSendAck(void); -void HW_IPCC_THREAD_CliEvtNot(void); - - -void HW_IPCC_LLDTESTS_Init(void); -void HW_IPCC_LLDTESTS_SendCliCmd(void); -void HW_IPCC_LLDTESTS_ReceiveCliRsp(void); -void HW_IPCC_LLDTESTS_SendCliRspAck(void); -void HW_IPCC_LLDTESTS_ReceiveM0Cmd(void); -void HW_IPCC_LLDTESTS_SendM0CmdAck(void); - - -void HW_IPCC_LLD_BLE_Init(void); -void HW_IPCC_LLD_BLE_SendCliCmd(void); -void HW_IPCC_LLD_BLE_ReceiveCliRsp(void); -void HW_IPCC_LLD_BLE_SendCliRspAck(void); -void HW_IPCC_LLD_BLE_ReceiveM0Cmd(void); -void HW_IPCC_LLD_BLE_SendM0CmdAck(void); -void HW_IPCC_LLD_BLE_SendCmd(void); -void HW_IPCC_LLD_BLE_ReceiveRsp(void); -void HW_IPCC_LLD_BLE_SendRspAck(void); - - -void HW_IPCC_TRACES_Init(void); -void HW_IPCC_TRACES_EvtNot(void); + /****************************************************************************** + * HW IPCC + ******************************************************************************/ + void HW_IPCC_Enable( void ); + void HW_IPCC_Init( void ); + + void HW_IPCC_BLE_Init( void ); + void HW_IPCC_BLE_SendCmd( void ); + void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) ); + void HW_IPCC_BLE_RxEvtNot( void ); + void HW_IPCC_BLE_SendAclData( void ); + void HW_IPCC_BLE_AclDataAckNot( void ); + + void HW_IPCC_SYS_Init( void ); + void HW_IPCC_SYS_SendCmd( void ); + void HW_IPCC_SYS_CmdEvtNot( void ); + void HW_IPCC_SYS_EvtNot( void ); + + void HW_IPCC_THREAD_Init( void ); + void HW_IPCC_OT_SendCmd( void ); + void HW_IPCC_CLI_SendCmd( void ); + void HW_IPCC_THREAD_SendAck( void ); + void HW_IPCC_OT_CmdEvtNot( void ); + void HW_IPCC_CLI_CmdEvtNot( void ); + void HW_IPCC_THREAD_EvtNot( void ); + void HW_IPCC_THREAD_CliSendAck( void ); + void HW_IPCC_THREAD_CliEvtNot( void ); + + + void HW_IPCC_LLDTESTS_Init( void ); + void HW_IPCC_LLDTESTS_SendCliCmd( void ); + void HW_IPCC_LLDTESTS_ReceiveCliRsp( void ); + void HW_IPCC_LLDTESTS_SendCliRspAck( void ); + void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void ); + void HW_IPCC_LLDTESTS_SendM0CmdAck( void ); + + + void HW_IPCC_LLD_BLE_Init( void ); + void HW_IPCC_LLD_BLE_SendCliCmd( void ); + void HW_IPCC_LLD_BLE_ReceiveCliRsp( void ); + void HW_IPCC_LLD_BLE_SendCliRspAck( void ); + void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ); + void HW_IPCC_LLD_BLE_SendM0CmdAck( void ); + void HW_IPCC_LLD_BLE_SendCmd( void ); + void HW_IPCC_LLD_BLE_ReceiveRsp( void ); + void HW_IPCC_LLD_BLE_SendRspAck( void ); + + + void HW_IPCC_TRACES_Init( void ); + void HW_IPCC_TRACES_EvtNot( void ); #ifdef __cplusplus } diff --git a/src/utility/STM32Cube_FW/hw_ipcc.c b/src/utility/STM32Cube_FW/hw_ipcc.c index 925075f8..658aadb4 100644 --- a/src/utility/STM32Cube_FW/hw_ipcc.c +++ b/src/utility/STM32Cube_FW/hw_ipcc.c @@ -29,20 +29,20 @@ /* Private macros ------------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ -static void (*FreeBufCb)(void); +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); +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); +static void HW_IPCC_OT_CmdEvtHandler( void ); +static void HW_IPCC_THREAD_NotEvtHandler( void ); +static void HW_IPCC_THREAD_CliNotEvtHandler( void ); #endif /* Public function definition -----------------------------------------------*/ @@ -50,41 +50,54 @@ static void HW_IPCC_TRACES_EvtHandler(void); /****************************************************************************** * INTERRUPT HANDLER ******************************************************************************/ - void IPCC_C1_RX_IRQHandler(void) { - if (HW_IPCC_RX_PENDING(HW_IPCC_SYSTEM_EVENT_CHANNEL)) { - HW_IPCC_SYS_EvtHandler(); + if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL )) + { + HW_IPCC_SYS_EvtHandler(); } #ifdef THREAD_WB - else if (HW_IPCC_RX_PENDING(HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL)) { + 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)) { + } + else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL )) + { HW_IPCC_THREAD_CliNotEvtHandler(); } #endif /* THREAD_WB */ - else if (HW_IPCC_RX_PENDING(HW_IPCC_BLE_EVENT_CHANNEL)) { + 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)) { + } + else if (HW_IPCC_RX_PENDING( HW_IPCC_TRACES_CHANNEL )) + { HW_IPCC_TRACES_EvtHandler(); } } void IPCC_C1_TX_IRQHandler(void) { - if (HW_IPCC_TX_PENDING(HW_IPCC_SYSTEM_CMD_RSP_CHANNEL)) { + if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) + { HW_IPCC_SYS_CmdEvtHandler(); } #ifdef THREAD_WB - else if (HW_IPCC_TX_PENDING(HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL)) { + else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL )) + { HW_IPCC_OT_CmdEvtHandler(); } #endif /* THREAD_WB */ - else if (HW_IPCC_TX_PENDING(HW_IPCC_SYSTEM_CMD_RSP_CHANNEL)) { + else if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL )) + { HW_IPCC_SYS_CmdEvtHandler(); - } else if (HW_IPCC_TX_PENDING(HW_IPCC_MM_RELEASE_BUFFER_CHANNEL)) { + } + 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)) { + } + else if (HW_IPCC_TX_PENDING( HW_IPCC_HCI_ACL_DATA_CHANNEL )) + { HW_IPCC_BLE_AclDataEvtHandler(); } } @@ -92,7 +105,7 @@ void IPCC_C1_TX_IRQHandler(void) /****************************************************************************** * GENERAL ******************************************************************************/ -void HW_IPCC_Enable(void) +void HW_IPCC_Enable( void ) { /** * Such as IPCC IP available to the CPU2, it is required to keep the IPCC clock running @@ -103,8 +116,8 @@ void HW_IPCC_Enable(void) /** * When the device is out of standby, it is required to use the EXTI mechanism to wakeup CPU2 */ - LL_C2_EXTI_EnableEvent_32_63(LL_EXTI_LINE_41); - LL_EXTI_EnableRisingTrig_32_63(LL_EXTI_LINE_41); + LL_C2_EXTI_EnableEvent_32_63( LL_EXTI_LINE_41 ); + LL_EXTI_EnableRisingTrig_32_63( LL_EXTI_LINE_41 ); /** * In case the SBSFU is implemented, it may have already set the C2BOOT bit to startup the CPU2. @@ -115,19 +128,19 @@ void HW_IPCC_Enable(void) * 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(); + __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) +void HW_IPCC_Init( void ) { - LL_AHB3_GRP1_EnableClock(LL_AHB3_GRP1_PERIPH_IPCC); + LL_AHB3_GRP1_EnableClock( LL_AHB3_GRP1_PERIPH_IPCC ); - LL_C1_IPCC_EnableIT_RXO(IPCC); - LL_C1_IPCC_EnableIT_TXF(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); @@ -138,188 +151,191 @@ void HW_IPCC_Init(void) /****************************************************************************** * BLE ******************************************************************************/ -void HW_IPCC_BLE_Init(void) +void HW_IPCC_BLE_Init( void ) { - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_BLE_EVENT_CHANNEL); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_BLE_EVENT_CHANNEL ); return; } -void HW_IPCC_BLE_SendCmd(void) +void HW_IPCC_BLE_SendCmd( void ) { - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_BLE_CMD_CHANNEL); + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_BLE_CMD_CHANNEL ); return; } -static void HW_IPCC_BLE_EvtHandler(void) +static void HW_IPCC_BLE_EvtHandler( void ) { HW_IPCC_BLE_RxEvtNot(); - LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_BLE_EVENT_CHANNEL); + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_BLE_EVENT_CHANNEL ); return; } -void HW_IPCC_BLE_SendAclData(void) +void HW_IPCC_BLE_SendAclData( void ) { - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL); - LL_C1_IPCC_EnableTransmitChannel(IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL); + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); return; } -static void HW_IPCC_BLE_AclDataEvtHandler(void) +static void HW_IPCC_BLE_AclDataEvtHandler( void ) { - LL_C1_IPCC_DisableTransmitChannel(IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL); + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL ); HW_IPCC_BLE_AclDataAckNot(); return; } -__WEAK void HW_IPCC_BLE_AclDataAckNot(void) {}; -__WEAK void HW_IPCC_BLE_RxEvtNot(void) {}; +__WEAK void HW_IPCC_BLE_AclDataAckNot( void ){}; +__WEAK void HW_IPCC_BLE_RxEvtNot( void ){}; /****************************************************************************** * SYSTEM ******************************************************************************/ -void HW_IPCC_SYS_Init(void) +void HW_IPCC_SYS_Init( void ) { - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL ); return; } -void HW_IPCC_SYS_SendCmd(void) +void HW_IPCC_SYS_SendCmd( void ) { - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL); - LL_C1_IPCC_EnableTransmitChannel(IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL); + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); return; } -static void HW_IPCC_SYS_CmdEvtHandler(void) +static void HW_IPCC_SYS_CmdEvtHandler( void ) { - LL_C1_IPCC_DisableTransmitChannel(IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL); + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ); HW_IPCC_SYS_CmdEvtNot(); return; } -static void HW_IPCC_SYS_EvtHandler(void) +static void HW_IPCC_SYS_EvtHandler( void ) { HW_IPCC_SYS_EvtNot(); - LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL); + 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) {}; +__WEAK void HW_IPCC_SYS_CmdEvtNot( void ){}; +__WEAK void HW_IPCC_SYS_EvtNot( void ){}; /****************************************************************************** * THREAD ******************************************************************************/ #ifdef THREAD_WB -void HW_IPCC_THREAD_Init(void) +void HW_IPCC_THREAD_Init( void ) { - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL); - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); return; } -void HW_IPCC_OT_SendCmd(void) +void HW_IPCC_OT_SendCmd( void ) { - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL); - LL_C1_IPCC_EnableTransmitChannel(IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL); + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); return; } -void HW_IPCC_CLI_SendCmd(void) +void HW_IPCC_CLI_SendCmd( void ) { - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_THREAD_CLI_CMD_CHANNEL); + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_CMD_CHANNEL ); return; } -void HW_IPCC_THREAD_SendAck(void) +void HW_IPCC_THREAD_SendAck( void ) { - LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL); - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL); + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); return; } -void HW_IPCC_THREAD_CliSendAck(void) +void HW_IPCC_THREAD_CliSendAck( void ) { - LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL); - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL); + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); return; } -static void HW_IPCC_OT_CmdEvtHandler(void) +static void HW_IPCC_OT_CmdEvtHandler( void ) { - LL_C1_IPCC_DisableTransmitChannel(IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL); + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ); HW_IPCC_OT_CmdEvtNot(); return; } -static void HW_IPCC_THREAD_NotEvtHandler(void) +static void HW_IPCC_THREAD_NotEvtHandler( void ) { - LL_C1_IPCC_DisableReceiveChannel(IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL); + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ); HW_IPCC_THREAD_EvtNot(); return; } -static void HW_IPCC_THREAD_CliNotEvtHandler(void) +static void HW_IPCC_THREAD_CliNotEvtHandler( void ) { - LL_C1_IPCC_DisableReceiveChannel(IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL); + LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ); HW_IPCC_THREAD_CliEvtNot(); return; } -__WEAK void HW_IPCC_OT_CmdEvtNot(void) {}; -__WEAK void HW_IPCC_CLI_CmdEvtNot(void) {}; -__WEAK void HW_IPCC_THREAD_EvtNot(void) {}; +__WEAK void HW_IPCC_OT_CmdEvtNot( void ){}; +__WEAK void HW_IPCC_CLI_CmdEvtNot( void ){}; +__WEAK void HW_IPCC_THREAD_EvtNot( void ){}; #endif /* THREAD_WB */ /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ -void HW_IPCC_MM_SendFreeBuf(void (*cb)(void)) +void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) ) { - if (LL_C1_IPCC_IsActiveFlag_CHx(IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL)) { + if ( LL_C1_IPCC_IsActiveFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ) ) + { FreeBufCb = cb; - LL_C1_IPCC_EnableTransmitChannel(IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL); - } else { + LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); + } + else + { cb(); - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL); + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); } return; } -static void HW_IPCC_MM_FreeBufHandler(void) +static void HW_IPCC_MM_FreeBufHandler( void ) { - LL_C1_IPCC_DisableTransmitChannel(IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL); + LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); FreeBufCb(); - LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL); + LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ); return; } @@ -327,22 +343,22 @@ static void HW_IPCC_MM_FreeBufHandler(void) /****************************************************************************** * TRACES ******************************************************************************/ -void HW_IPCC_TRACES_Init(void) +void HW_IPCC_TRACES_Init( void ) { - LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_TRACES_CHANNEL); + LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_TRACES_CHANNEL ); return; } -static void HW_IPCC_TRACES_EvtHandler(void) +static void HW_IPCC_TRACES_EvtHandler( void ) { HW_IPCC_TRACES_EvtNot(); - LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_TRACES_CHANNEL); + LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_TRACES_CHANNEL ); return; } -__WEAK void HW_IPCC_TRACES_EvtNot(void) {}; +__WEAK void HW_IPCC_TRACES_EvtNot( void ){}; #endif /* STM32WBxx */ /******************* (C) COPYRIGHT 2019 STMicroelectronics *****END OF FILE****/ diff --git a/src/utility/STM32Cube_FW/mbox_def.h b/src/utility/STM32Cube_FW/mbox_def.h index d5a7d46b..6bddf696 100644 --- a/src/utility/STM32Cube_FW/mbox_def.h +++ b/src/utility/STM32Cube_FW/mbox_def.h @@ -28,109 +28,121 @@ extern "C" { #include "stm32_wpan_common.h" -/** - * This file shall be identical between the CPU1 and the CPU2 - */ - -/** - ********************************************************************************* - * TABLES - ********************************************************************************* - */ - -/** - * Version - * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version - * [4:7] = branch - 0: Mass Market - x: ... - * [8:15] = Subversion - * [16:23] = Version minor - * [24:31] = Version major - * - * Memory Size - * [0:7] = Flash ( Number of 4k sector) - * [8:15] = Reserved ( Shall be set to 0 - may be used as flash extension ) - * [16:23] = SRAM2b ( Number of 1k sector) - * [24:31] = SRAM2a ( Number of 1k sector) - */ -typedef PACKED_STRUCT { - uint32_t Version; -} MB_SafeBootInfoTable_t; - -typedef PACKED_STRUCT { - uint32_t Version; - uint32_t MemorySize; - uint32_t FusInfo; -} MB_FusInfoTable_t; - -typedef PACKED_STRUCT { - uint32_t Version; - uint32_t MemorySize; - uint32_t InfoStack; - uint32_t Reserved; -} MB_WirelessFwInfoTable_t; - -typedef struct { - MB_SafeBootInfoTable_t SafeBootInfoTable; - MB_FusInfoTable_t FusInfoTable; - MB_WirelessFwInfoTable_t WirelessFwInfoTable; -} MB_DeviceInfoTable_t; - -typedef struct { - uint8_t *pcmd_buffer; - uint8_t *pcs_buffer; - uint8_t *pevt_queue; - uint8_t *phci_acl_data_buffer; -} MB_BleTable_t; - -typedef struct { - uint8_t *notack_buffer; - uint8_t *clicmdrsp_buffer; - uint8_t *otcmdrsp_buffer; -} MB_ThreadTable_t; - -typedef struct { - uint8_t *clicmdrsp_buffer; - uint8_t *m0cmd_buffer; -} MB_LldTestsTable_t; - -typedef struct { - uint8_t *cmdrsp_buffer; - uint8_t *m0cmd_buffer; -} MB_LldBleTable_t; - -/** - * msg - * [0:7] = cmd/evt - * [8:31] = Reserved - */ -typedef struct { - uint8_t *pcmd_buffer; - uint8_t *sys_queue; -} MB_SysTable_t; - -typedef struct { - uint8_t *spare_ble_buffer; - uint8_t *spare_sys_buffer; - uint8_t *blepool; - uint32_t blepoolsize; - uint8_t *pevt_free_buffer_queue; - uint8_t *traces_evt_pool; - uint32_t tracespoolsize; -} MB_MemManagerTable_t; - -typedef struct { - uint8_t *traces_queue; -} MB_TracesTable_t; - -typedef struct { - MB_DeviceInfoTable_t *p_device_info_table; - MB_BleTable_t *p_ble_table; - MB_ThreadTable_t *p_thread_table; - MB_SysTable_t *p_sys_table; - MB_MemManagerTable_t *p_mem_manager_table; - MB_TracesTable_t *p_traces_table; - MB_LldTestsTable_t *p_lld_tests_table; - MB_LldBleTable_t *p_lld_ble_table; + /** + * This file shall be identical between the CPU1 and the CPU2 + */ + + /** + ********************************************************************************* + * TABLES + ********************************************************************************* + */ + + /** + * Version + * [0:3] = Build - 0: Untracked - 15:Released - x: Tracked version + * [4:7] = branch - 0: Mass Market - x: ... + * [8:15] = Subversion + * [16:23] = Version minor + * [24:31] = Version major + * + * Memory Size + * [0:7] = Flash ( Number of 4k sector) + * [8:15] = Reserved ( Shall be set to 0 - may be used as flash extension ) + * [16:23] = SRAM2b ( Number of 1k sector) + * [24:31] = SRAM2a ( Number of 1k sector) + */ + typedef PACKED_STRUCT + { + uint32_t Version; + } MB_SafeBootInfoTable_t; + + typedef PACKED_STRUCT + { + uint32_t Version; + uint32_t MemorySize; + uint32_t FusInfo; + } MB_FusInfoTable_t; + + typedef PACKED_STRUCT + { + uint32_t Version; + uint32_t MemorySize; + uint32_t InfoStack; + uint32_t Reserved; + } MB_WirelessFwInfoTable_t; + + typedef struct + { + MB_SafeBootInfoTable_t SafeBootInfoTable; + MB_FusInfoTable_t FusInfoTable; + MB_WirelessFwInfoTable_t WirelessFwInfoTable; + } MB_DeviceInfoTable_t; + + typedef struct + { + uint8_t *pcmd_buffer; + uint8_t *pcs_buffer; + uint8_t *pevt_queue; + uint8_t *phci_acl_data_buffer; + } MB_BleTable_t; + + typedef struct + { + uint8_t *notack_buffer; + uint8_t *clicmdrsp_buffer; + uint8_t *otcmdrsp_buffer; + } MB_ThreadTable_t; + + typedef struct + { + uint8_t *clicmdrsp_buffer; + uint8_t *m0cmd_buffer; + } MB_LldTestsTable_t; + + typedef struct + { + uint8_t *cmdrsp_buffer; + uint8_t *m0cmd_buffer; + } MB_LldBleTable_t; + + /** + * msg + * [0:7] = cmd/evt + * [8:31] = Reserved + */ + typedef struct + { + uint8_t *pcmd_buffer; + uint8_t *sys_queue; + } MB_SysTable_t; + + typedef struct + { + uint8_t *spare_ble_buffer; + uint8_t *spare_sys_buffer; + uint8_t *blepool; + uint32_t blepoolsize; + uint8_t *pevt_free_buffer_queue; + uint8_t *traces_evt_pool; + uint32_t tracespoolsize; + } MB_MemManagerTable_t; + + typedef struct + { + uint8_t *traces_queue; + } MB_TracesTable_t; + + typedef struct + { + MB_DeviceInfoTable_t *p_device_info_table; + MB_BleTable_t *p_ble_table; + MB_ThreadTable_t *p_thread_table; + MB_SysTable_t *p_sys_table; + MB_MemManagerTable_t *p_mem_manager_table; + MB_TracesTable_t *p_traces_table; + MB_LldTestsTable_t *p_lld_tests_table; + MB_LldBleTable_t *p_lld_ble_table; } MB_RefTable_t; #ifdef __cplusplus diff --git a/src/utility/STM32Cube_FW/shci.c b/src/utility/STM32Cube_FW/shci.c index d23157f2..b848dd85 100644 --- a/src/utility/STM32Cube_FW/shci.c +++ b/src/utility/STM32Cube_FW/shci.c @@ -6,11 +6,11 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2019 STMicroelectronics. + *

© 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 + * 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 * @@ -38,413 +38,419 @@ * C2 COMMAND * These commands are sent to the CPU2 */ -uint8_t SHCI_C2_FUS_GetState(SHCI_FUS_GetState_ErrorCode_t *p_error_code) +uint8_t SHCI_C2_FUS_GetState( SHCI_FUS_GetState_ErrorCode_t *p_error_code ) { /** * A command status event + payload has the same size than the expected command complete */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE + 1]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_FUS_GET_STATE, - 0, - 0, - p_rsp); + shci_send( SHCI_OPCODE_C2_FUS_GET_STATE, + 0, + 0, + p_rsp ); - if (p_error_code != 0) { - *p_error_code = (SHCI_FUS_GetState_ErrorCode_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[1]); + if(p_error_code != 0) + { + *p_error_code = (SHCI_FUS_GetState_ErrorCode_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1]); } - return (((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade(uint32_t fw_src_add, uint32_t fw_dest_add) +SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade( uint32_t fw_src_add, uint32_t fw_dest_add ) { /** * TL_BLEEVT_CS_BUFFER_SIZE is 15 bytes so it is large enough to hold the 8 bytes of command parameters * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; uint32_t *p_cmd; uint8_t cmd_length; - p_cmd = (uint32_t *)local_buffer; + p_cmd = (uint32_t*)local_buffer; cmd_length = 0; - if (fw_src_add != 0) { + if(fw_src_add != 0) + { *p_cmd = fw_src_add; cmd_length += 4; } - if (fw_dest_add != 0) { - *(p_cmd + 1) = fw_dest_add; + if(fw_dest_add != 0) + { + *(p_cmd+1) = fw_dest_add; cmd_length += 4; } p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_FUS_FW_UPGRADE, - cmd_length, - local_buffer, - p_rsp); + shci_send( SHCI_OPCODE_C2_FUS_FW_UPGRADE, + cmd_length, + local_buffer, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete(void) +SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete( void ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_FUS_FW_DELETE, - 0, - 0, - p_rsp); + shci_send( SHCI_OPCODE_C2_FUS_FW_DELETE, + 0, + 0, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey(SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t *pParam) +SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t *pParam ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_FUS_UPDATE_AUTH_KEY, - sizeof(SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t), - (uint8_t *)pParam, - p_rsp); + shci_send( SHCI_OPCODE_C2_FUS_UPDATE_AUTH_KEY, + sizeof( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t ), + (uint8_t*)pParam, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey(void) +SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey( void ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_FUS_LOCK_AUTH_KEY, - 0, - 0, - p_rsp); + shci_send( SHCI_OPCODE_C2_FUS_LOCK_AUTH_KEY, + 0, + 0, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey(SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *pParam, uint8_t *p_key_index) +SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey( SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *pParam, uint8_t *p_key_index ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE + 1]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; uint8_t local_payload_len; - if (pParam->KeyType == KEYTYPE_ENCRYPTED) { + if(pParam->KeyType == KEYTYPE_ENCRYPTED) + { /** * When the key is encrypted, the 12 bytes IV Key is included in the payload as well * The IV key is always 12 bytes */ local_payload_len = pParam->KeySize + 2 + 12; - } else { + } + else + { local_payload_len = pParam->KeySize + 2; } p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_FUS_STORE_USR_KEY, - local_payload_len, - (uint8_t *)pParam, - p_rsp); + shci_send( SHCI_OPCODE_C2_FUS_STORE_USR_KEY, + local_payload_len , + (uint8_t*)pParam, + p_rsp ); - *p_key_index = (((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[1]); + *p_key_index = (((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1]); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey(uint8_t key_index) +SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey( uint8_t key_index ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; local_buffer[0] = key_index; - shci_send(SHCI_OPCODE_C2_FUS_LOAD_USR_KEY, - 1, - local_buffer, - p_rsp); + shci_send( SHCI_OPCODE_C2_FUS_LOAD_USR_KEY, + 1, + local_buffer, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_FUS_StartWs(void) +SHCI_CmdStatus_t SHCI_C2_FUS_StartWs( void ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_FUS_START_WS, - 0, - 0, - p_rsp); + shci_send( SHCI_OPCODE_C2_FUS_START_WS, + 0, + 0, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey(uint8_t key_index) +SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey( uint8_t key_index ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; local_buffer[0] = key_index; - shci_send(SHCI_OPCODE_C2_FUS_LOCK_USR_KEY, - 1, - local_buffer, - p_rsp); + shci_send( SHCI_OPCODE_C2_FUS_LOCK_USR_KEY, + 1, + local_buffer, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_BLE_Init(SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket) +SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_BLE_INIT, - sizeof(SHCI_C2_Ble_Init_Cmd_Param_t), - (uint8_t *)&pCmdPacket->Param, - p_rsp); + shci_send( SHCI_OPCODE_C2_BLE_INIT, + sizeof( SHCI_C2_Ble_Init_Cmd_Param_t ), + (uint8_t*)&pCmdPacket->Param, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_THREAD_Init(void) +SHCI_CmdStatus_t SHCI_C2_THREAD_Init( void ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_THREAD_INIT, - 0, - 0, - p_rsp); + shci_send( SHCI_OPCODE_C2_THREAD_INIT, + 0, + 0, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init(uint8_t param_size, uint8_t *p_param) +SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + 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); + 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]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init(uint8_t param_size, uint8_t *p_param) +SHCI_CmdStatus_t SHCI_C2_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; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_LLD_BLE_INIT, - param_size, - p_param, - p_rsp); + shci_send( SHCI_OPCODE_C2_LLD_BLE_INIT, + param_size, + p_param, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + 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) +SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_DEBUG_INIT, - sizeof(SHCI_C2_DEBUG_init_Cmd_Param_t), - (uint8_t *)&pCmdPacket->Param, - p_rsp); + shci_send( SHCI_OPCODE_C2_DEBUG_INIT, + sizeof( SHCI_C2_DEBUG_init_Cmd_Param_t ), + (uint8_t*)&pCmdPacket->Param, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity(SHCI_EraseActivity_t erase_activity) +SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity( SHCI_EraseActivity_t erase_activity ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; local_buffer[0] = erase_activity; - shci_send(SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY, - 1, - local_buffer, - p_rsp); + shci_send( SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY, + 1, + local_buffer, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode(SHCI_C2_CONCURRENT_Mode_Param_t Mode) +SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mode ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; local_buffer[0] = Mode; - shci_send(SHCI_OPCODE_C2_CONCURRENT_SET_MODE, - 1, - local_buffer, - p_rsp); + shci_send( SHCI_OPCODE_C2_CONCURRENT_SET_MODE, + 1, + local_buffer, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData(SHCI_C2_FLASH_Ip_t Ip) +SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; local_buffer[0] = Ip; - shci_send(SHCI_OPCODE_C2_FLASH_STORE_DATA, - 1, - local_buffer, - p_rsp); + shci_send( SHCI_OPCODE_C2_FLASH_STORE_DATA, + 1, + local_buffer, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData(SHCI_C2_FLASH_Ip_t Ip) +SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData( SHCI_C2_FLASH_Ip_t Ip ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; local_buffer[0] = Ip; - shci_send(SHCI_OPCODE_C2_FLASH_ERASE_DATA, - 1, - local_buffer, - p_rsp); + shci_send( SHCI_OPCODE_C2_FLASH_ERASE_DATA, + 1, + local_buffer, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower(SHCI_C2_FLASH_Ip_t Ip, uint8_t FlagRadioLowPowerOn) +SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; local_buffer[0] = Ip; local_buffer[1] = FlagRadioLowPowerOn; - shci_send(SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER, - 2, - local_buffer, - p_rsp); + shci_send( SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER, + 2, + local_buffer, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } -SHCI_CmdStatus_t SHCI_C2_Reinit(void) +SHCI_CmdStatus_t SHCI_C2_Reinit( void ) { /** * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_REINIT, - 0, - 0, - p_rsp); + shci_send( SHCI_OPCODE_C2_REINIT, + 0, + 0, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_number, uint8_t gpio_polarity, uint8_t gpio_status) @@ -454,21 +460,21 @@ SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_numbe * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; - ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t *)local_buffer)->gpio_port = gpio_port; - ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t *)local_buffer)->gpio_pin_number = gpio_pin_number; - ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t *)local_buffer)->gpio_polarity = gpio_polarity; - ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t *)local_buffer)->gpio_status = gpio_status; + ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_port = gpio_port; + ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_pin_number = gpio_pin_number; + ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_polarity = gpio_polarity; + ((SHCI_C2_EXTPA_CONFIG_Cmd_Param_t*)local_buffer)->gpio_status = gpio_status; - shci_send(SHCI_OPCODE_C2_EXTPA_CONFIG, - 8, - local_buffer, - p_rsp); + shci_send( SHCI_OPCODE_C2_EXTPA_CONFIG, + 8, + local_buffer, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + 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) @@ -478,18 +484,18 @@ SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONT * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + 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); + 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]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket) @@ -498,16 +504,16 @@ SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket) * Buffer is large enough to hold command complete without payload */ uint8_t local_buffer[TL_BLEEVT_CS_BUFFER_SIZE]; - TL_EvtPacket_t *p_rsp; + TL_EvtPacket_t * p_rsp; p_rsp = (TL_EvtPacket_t *)local_buffer; - shci_send(SHCI_OPCODE_C2_CONFIG, - sizeof(SHCI_C2_CONFIG_Cmd_Param_t), - (uint8_t *)pCmdPacket, - p_rsp); + shci_send( SHCI_OPCODE_C2_CONFIG, + sizeof(SHCI_C2_CONFIG_Cmd_Param_t), + (uint8_t*)pCmdPacket, + p_rsp ); - return (SHCI_CmdStatus_t)(((TL_CcEvt_t *)(p_rsp->evtserial.evt.payload))->payload[0]); + return (SHCI_CmdStatus_t)(((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[0]); } @@ -516,16 +522,16 @@ SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket) * These commands are NOT sent to the CPU2 */ -SHCI_CmdStatus_t SHCI_GetWirelessFwInfo(WirelessFwInfo_t *pWirelessInfo) +SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ) { uint32_t ipccdba = 0; - MB_RefTable_t *p_RefTable = NULL; + MB_RefTable_t * p_RefTable = NULL; uint32_t version = 0; uint32_t memorySize = 0; uint32_t infoStack = 0; - ipccdba = READ_BIT(FLASH->IPCCBR, FLASH_IPCCBR_IPCCDBA); - p_RefTable = (MB_RefTable_t *)((ipccdba << 2) + SRAM2A_BASE); + ipccdba = READ_BIT( FLASH->IPCCBR, FLASH_IPCCBR_IPCCDBA ); + p_RefTable = (MB_RefTable_t*)((ipccdba<<2) + SRAM2A_BASE); /** * Retrieve the WirelessFwInfoTable diff --git a/src/utility/STM32Cube_FW/shci.h b/src/utility/STM32Cube_FW/shci.h index 35227c76..11c53ced 100644 --- a/src/utility/STM32Cube_FW/shci.h +++ b/src/utility/STM32Cube_FW/shci.h @@ -6,11 +6,11 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2019 STMicroelectronics. + *

© 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 + * 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 * @@ -26,254 +26,264 @@ extern "C" { #endif -/* Includes ------------------------------------------------------------------*/ + /* Includes ------------------------------------------------------------------*/ #include "mbox_def.h" /* Requested to expose the MB_WirelessFwInfoTable_t structure */ -/* Exported types ------------------------------------------------------------*/ - -/* SYSTEM EVENT */ -typedef enum { - WIRELESS_FW_RUNNING = 0x00, - RSS_FW_RUNNING = 0x01, -} SHCI_SysEvt_Ready_Rsp_t; - -/* ERROR CODES - * - * These error codes are detected on M0 side and are send back to the M4 via a system - * notification message. It is up to the application running on M4 to manage these errors - * - * These errors can be generated by all layers (low level driver, stack, framework infrastructure, etc..) - */ -typedef enum { - ERR_BLE_INIT = 0, - ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ - ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the M4 to control the Thread stack is unknown */ -} SCHI_SystemErrCode_t; + /* Exported types ------------------------------------------------------------*/ + + /* SYSTEM EVENT */ + typedef enum + { + WIRELESS_FW_RUNNING = 0x00, + RSS_FW_RUNNING = 0x01, + } SHCI_SysEvt_Ready_Rsp_t; + + /* ERROR CODES + * + * These error codes are detected on M0 side and are send back to the M4 via a system + * notification message. It is up to the application running on M4 to manage these errors + * + * These errors can be generated by all layers (low level driver, stack, framework infrastructure, etc..) + */ + typedef enum + { + ERR_BLE_INIT = 0, + ERR_THREAD_LLD_FATAL_ERROR = 125, /* The LLD driver used on 802_15_4 detected a fatal error */ + ERR_THREAD_UNKNOWN_CMD = 126, /* The command send by the M4 to control the Thread stack is unknown */ + } SCHI_SystemErrCode_t; #define SHCI_EVTCODE ( 0xFF ) #define SHCI_SUB_EVT_CODE_BASE ( 0x9200 ) -/** - * THE ORDER SHALL NOT BE CHANGED TO GUARANTEE COMPATIBILITY WITH THE CPU1 DEFINITION - */ -typedef enum { - SHCI_SUB_EVT_CODE_READY = SHCI_SUB_EVT_CODE_BASE, - SHCI_SUB_EVT_ERROR_NOTIF, - SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE, - SHCI_SUB_EVT_OT_NVM_RAM_UPDATE, - SHCI_SUB_EVT_NVM_START_WRITE, - SHCI_SUB_EVT_NVM_END_WRITE, - SHCI_SUB_EVT_NVM_START_ERASE, - SHCI_SUB_EVT_NVM_END_ERASE, -} SHCI_SUB_EVT_CODE_t; + /** + * THE ORDER SHALL NOT BE CHANGED TO GUARANTEE COMPATIBILITY WITH THE CPU1 DEFINITION + */ + typedef enum + { + SHCI_SUB_EVT_CODE_READY = SHCI_SUB_EVT_CODE_BASE, + SHCI_SUB_EVT_ERROR_NOTIF, + SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE, + SHCI_SUB_EVT_OT_NVM_RAM_UPDATE, + SHCI_SUB_EVT_NVM_START_WRITE, + SHCI_SUB_EVT_NVM_END_WRITE, + SHCI_SUB_EVT_NVM_START_ERASE, + SHCI_SUB_EVT_NVM_END_ERASE, + } SHCI_SUB_EVT_CODE_t; -/** - * SHCI_SUB_EVT_CODE_READY - * This notifies the CPU1 that the CPU2 is now ready to receive commands - * It reports as well which firmware is running on CPU2 : The wireless stack of the FUS (previously named RSS) - */ -typedef PACKED_STRUCT{ - SHCI_SysEvt_Ready_Rsp_t sysevt_ready_rsp; -} SHCI_C2_Ready_Evt_t; + /** + * SHCI_SUB_EVT_CODE_READY + * This notifies the CPU1 that the CPU2 is now ready to receive commands + * It reports as well which firmware is running on CPU2 : The wireless stack of the FUS (previously named RSS) + */ + typedef PACKED_STRUCT{ + SHCI_SysEvt_Ready_Rsp_t sysevt_ready_rsp; + } SHCI_C2_Ready_Evt_t; -/** - * SHCI_SUB_EVT_ERROR_NOTIF - * This reports to the CPU1 some error form the CPU2 - */ -typedef PACKED_STRUCT{ - SCHI_SystemErrCode_t errorCode; -} SHCI_C2_ErrorNotif_Evt_t; + /** + * SHCI_SUB_EVT_ERROR_NOTIF + * This reports to the CPU1 some error form the CPU2 + */ + typedef PACKED_STRUCT{ + SCHI_SystemErrCode_t errorCode; + } SHCI_C2_ErrorNotif_Evt_t; -/** - * SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE - * This notifies the CPU1 which part of the BLE NVM RAM has been updated so that only the modified - * section could be written in Flash/NVM - * StartAddress : Start address of the section that has been modified - * Size : Size (in bytes) of the section that has been modified - */ -typedef PACKED_STRUCT{ - uint32_t StartAddress; - uint32_t Size; -} SHCI_C2_BleNvmRamUpdate_Evt_t; + /** + * SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE + * This notifies the CPU1 which part of the BLE NVM RAM has been updated so that only the modified + * section could be written in Flash/NVM + * StartAddress : Start address of the section that has been modified + * Size : Size (in bytes) of the section that has been modified + */ + typedef PACKED_STRUCT{ + uint32_t StartAddress; + uint32_t Size; + } SHCI_C2_BleNvmRamUpdate_Evt_t; -/** - * SHCI_SUB_EVT_OT_NVM_RAM_UPDATE - * This notifies the CPU1 which part of the 'OT NVM RAM' has been updated so that only the modified - * section could be written in Flash/NVM - * StartAddress : Start address of the section that has been modified - * Size : Size (in bytes) of the section that has been modified - */ -typedef PACKED_STRUCT{ - uint32_t StartAddress; - uint32_t Size; -} SHCI_C2_OtNvmRamUpdate_Evt_t; + /** + * SHCI_SUB_EVT_OT_NVM_RAM_UPDATE + * This notifies the CPU1 which part of the 'OT NVM RAM' has been updated so that only the modified + * section could be written in Flash/NVM + * StartAddress : Start address of the section that has been modified + * Size : Size (in bytes) of the section that has been modified + */ + typedef PACKED_STRUCT{ + uint32_t StartAddress; + uint32_t Size; + } SHCI_C2_OtNvmRamUpdate_Evt_t; -/** - * SHCI_SUB_EVT_NVM_START_WRITE - * This notifies the CPU1 that the CPU2 has started a write procedure in Flash - * NumberOfWords : The number of 64bits data the CPU2 needs to write in Flash. - * For each 64bits data, the algorithm as described in AN5289 is executed. - * When this number is reported to 0, it means the Number of 64bits to be written - * was unknown when the procedure has started. - * When all data are written, the SHCI_SUB_EVT_NVM_END_WRITE event is reported - */ -typedef PACKED_STRUCT{ - uint32_t NumberOfWords; -} SHCI_C2_NvmStartWrite_Evt_t; + /** + * SHCI_SUB_EVT_NVM_START_WRITE + * This notifies the CPU1 that the CPU2 has started a write procedure in Flash + * NumberOfWords : The number of 64bits data the CPU2 needs to write in Flash. + * For each 64bits data, the algorithm as described in AN5289 is executed. + * When this number is reported to 0, it means the Number of 64bits to be written + * was unknown when the procedure has started. + * When all data are written, the SHCI_SUB_EVT_NVM_END_WRITE event is reported + */ + typedef PACKED_STRUCT{ + uint32_t NumberOfWords; + } SHCI_C2_NvmStartWrite_Evt_t; -/** - * SHCI_SUB_EVT_NVM_END_WRITE - * This notifies the CPU1 that the CPU2 has written all expected data in Flash - */ + /** + * SHCI_SUB_EVT_NVM_END_WRITE + * This notifies the CPU1 that the CPU2 has written all expected data in Flash + */ -/** - * SHCI_SUB_EVT_NVM_START_ERASE - * This notifies the CPU1 that the CPU2 has started a erase procedure in Flash - * NumberOfSectors : The number of sectors the CPU2 needs to erase in Flash. - * For each sector, the algorithm as described in AN5289 is executed. - * When this number is reported to 0, it means the Number of sectors to be erased - * was unknown when the procedure has started. - * When all sectors are erased, the SHCI_SUB_EVT_NVM_END_ERASE event is reported - */ -typedef PACKED_STRUCT{ - uint32_t NumberOfSectors; -} SHCI_C2_NvmStartErase_Evt_t; + /** + * SHCI_SUB_EVT_NVM_START_ERASE + * This notifies the CPU1 that the CPU2 has started a erase procedure in Flash + * NumberOfSectors : The number of sectors the CPU2 needs to erase in Flash. + * For each sector, the algorithm as described in AN5289 is executed. + * When this number is reported to 0, it means the Number of sectors to be erased + * was unknown when the procedure has started. + * When all sectors are erased, the SHCI_SUB_EVT_NVM_END_ERASE event is reported + */ + typedef PACKED_STRUCT{ + uint32_t NumberOfSectors; + } SHCI_C2_NvmStartErase_Evt_t; -/** - * SHCI_SUB_EVT_NVM_END_ERASE - * This notifies the CPU1 that the CPU2 has erased all expected flash sectors - */ + /** + * SHCI_SUB_EVT_NVM_END_ERASE + * This notifies the CPU1 that the CPU2 has erased all expected flash sectors + */ -/* SYSTEM COMMAND */ -typedef PACKED_STRUCT { - uint32_t MetaData[3]; -} SHCI_Header_t; - -typedef enum { - SHCI_Success = 0x00, - SHCI_UNKNOWN_CMD = 0x01, - SHCI_ERR_UNSUPPORTED_FEATURE = 0x11, - SHCI_ERR_INVALID_HCI_CMD_PARAMS = 0x12, - SHCI_FUS_CMD_NOT_SUPPORTED = 0xFF, -} SHCI_CmdStatus_t; - -typedef enum { - SHCI_8BITS = 0x01, - SHCI_16BITS = 0x02, - SHCI_32BITS = 0x04, -} SHCI_Busw_t; + /* SYSTEM COMMAND */ + typedef PACKED_STRUCT + { + uint32_t MetaData[3]; + } SHCI_Header_t; + + typedef enum + { + SHCI_Success = 0x00, + SHCI_UNKNOWN_CMD = 0x01, + SHCI_ERR_UNSUPPORTED_FEATURE = 0x11, + SHCI_ERR_INVALID_HCI_CMD_PARAMS = 0x12, + SHCI_FUS_CMD_NOT_SUPPORTED = 0xFF, + } SHCI_CmdStatus_t; + + typedef enum + { + SHCI_8BITS = 0x01, + SHCI_16BITS = 0x02, + SHCI_32BITS = 0x04, + } SHCI_Busw_t; #define SHCI_OGF ( 0x3F ) #define SHCI_OCF_BASE ( 0x50 ) -/** - * THE ORDER SHALL NOT BE CHANGED TO GUARANTEE COMPATIBILITY WITH THE CPU2 DEFINITION - */ -typedef enum { - SHCI_OCF_C2_RESERVED1 = SHCI_OCF_BASE, - SHCI_OCF_C2_RESERVED2, - SHCI_OCF_C2_FUS_GET_STATE, - SHCI_OCF_C2_FUS_RESERVED1, - SHCI_OCF_C2_FUS_FW_UPGRADE, - SHCI_OCF_C2_FUS_FW_DELETE, - SHCI_OCF_C2_FUS_UPDATE_AUTH_KEY, - SHCI_OCF_C2_FUS_LOCK_AUTH_KEY, - SHCI_OCF_C2_FUS_STORE_USR_KEY, - SHCI_OCF_C2_FUS_LOAD_USR_KEY, - SHCI_OCF_C2_FUS_START_WS, - SHCI_OCF_C2_FUS_RESERVED2, - SHCI_OCF_C2_FUS_RESERVED3, - SHCI_OCF_C2_FUS_LOCK_USR_KEY, - SHCI_OCF_C2_FUS_RESERVED5, - SHCI_OCF_C2_FUS_RESERVED6, - SHCI_OCF_C2_FUS_RESERVED7, - SHCI_OCF_C2_FUS_RESERVED8, - SHCI_OCF_C2_FUS_RESERVED9, - SHCI_OCF_C2_FUS_RESERVED10, - SHCI_OCF_C2_FUS_RESERVED11, - SHCI_OCF_C2_FUS_RESERVED12, - SHCI_OCF_C2_BLE_INIT, - SHCI_OCF_C2_THREAD_INIT, - SHCI_OCF_C2_DEBUG_INIT, - SHCI_OCF_C2_FLASH_ERASE_ACTIVITY, - SHCI_OCF_C2_CONCURRENT_SET_MODE, - SHCI_OCF_C2_FLASH_STORE_DATA, - SHCI_OCF_C2_FLASH_ERASE_DATA, - SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, - SHCI_OCF_C2_REINIT, - SHCI_OCF_C2_LLD_TESTS_INIT, - SHCI_OCF_C2_EXTPA_CONFIG, - SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, - SHCI_OCF_C2_LLD_BLE_INIT, - SHCI_OCF_C2_CONFIG, -} SHCI_OCF_t; + /** + * THE ORDER SHALL NOT BE CHANGED TO GUARANTEE COMPATIBILITY WITH THE CPU2 DEFINITION + */ + typedef enum + { + SHCI_OCF_C2_RESERVED1 = SHCI_OCF_BASE, + SHCI_OCF_C2_RESERVED2, + SHCI_OCF_C2_FUS_GET_STATE, + SHCI_OCF_C2_FUS_RESERVED1, + SHCI_OCF_C2_FUS_FW_UPGRADE, + SHCI_OCF_C2_FUS_FW_DELETE, + SHCI_OCF_C2_FUS_UPDATE_AUTH_KEY, + SHCI_OCF_C2_FUS_LOCK_AUTH_KEY, + SHCI_OCF_C2_FUS_STORE_USR_KEY, + SHCI_OCF_C2_FUS_LOAD_USR_KEY, + SHCI_OCF_C2_FUS_START_WS, + SHCI_OCF_C2_FUS_RESERVED2, + SHCI_OCF_C2_FUS_RESERVED3, + SHCI_OCF_C2_FUS_LOCK_USR_KEY, + SHCI_OCF_C2_FUS_RESERVED5, + SHCI_OCF_C2_FUS_RESERVED6, + SHCI_OCF_C2_FUS_RESERVED7, + SHCI_OCF_C2_FUS_RESERVED8, + SHCI_OCF_C2_FUS_RESERVED9, + SHCI_OCF_C2_FUS_RESERVED10, + SHCI_OCF_C2_FUS_RESERVED11, + SHCI_OCF_C2_FUS_RESERVED12, + SHCI_OCF_C2_BLE_INIT, + SHCI_OCF_C2_THREAD_INIT, + SHCI_OCF_C2_DEBUG_INIT, + SHCI_OCF_C2_FLASH_ERASE_ACTIVITY, + SHCI_OCF_C2_CONCURRENT_SET_MODE, + SHCI_OCF_C2_FLASH_STORE_DATA, + SHCI_OCF_C2_FLASH_ERASE_DATA, + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER, + SHCI_OCF_C2_REINIT, + SHCI_OCF_C2_LLD_TESTS_INIT, + SHCI_OCF_C2_EXTPA_CONFIG, + SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL, + SHCI_OCF_C2_LLD_BLE_INIT, + SHCI_OCF_C2_CONFIG, + } SHCI_OCF_t; #define SHCI_OPCODE_C2_FUS_GET_STATE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_GET_STATE) /** No command parameters */ /** Response parameters*/ -typedef enum { - FUS_STATE_NO_ERROR = 0x00, - FUS_STATE_IMG_NOT_FOUND = 0x01, - FUS_STATE_IMG_CORRUPT = 0x02, - FUS_STATE_IMG_NOT_AUTHENTIC = 0x03, - FUS_STATE_IMG_NOT_ENOUGH_SPACE = 0x04, - FUS_STATE_ERR_UNKNOWN = 0xFF, -} SHCI_FUS_GetState_ErrorCode_t; + typedef enum + { + FUS_STATE_NO_ERROR = 0x00, + FUS_STATE_IMG_NOT_FOUND = 0x01, + FUS_STATE_IMG_CORRUPT = 0x02, + FUS_STATE_IMG_NOT_AUTHENTIC = 0x03, + FUS_STATE_IMG_NOT_ENOUGH_SPACE = 0x04, + FUS_STATE_ERR_UNKNOWN = 0xFF, + } SHCI_FUS_GetState_ErrorCode_t; #define SHCI_OPCODE_C2_FUS_RESERVED1 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED1) /** No command parameters */ /** No response parameters*/ #define SHCI_OPCODE_C2_FUS_FW_UPGRADE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_FW_UPGRADE) -/** No structure for command parameters */ -/** No response parameters*/ + /** No structure for command parameters */ + /** No response parameters*/ #define SHCI_OPCODE_C2_FUS_FW_DELETE (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_FW_DELETE) /** No command parameters */ /** No response parameters*/ #define SHCI_OPCODE_C2_FUS_UPDATE_AUTH_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_UPDATE_AUTH_KEY) -typedef PACKED_STRUCT { + typedef PACKED_STRUCT{ uint8_t KeySize; uint8_t KeyData[64]; -} SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t; + } SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t; -/** No response parameters*/ + /** No response parameters*/ #define SHCI_OPCODE_C2_FUS_LOCK_AUTH_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOCK_AUTH_KEY) /** No command parameters */ /** No response parameters*/ #define SHCI_OPCODE_C2_FUS_STORE_USR_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_STORE_USR_KEY) -/** Command parameters */ -/* List of supported key type */ -enum { - KEYTYPE_NONE = 0x00, - KEYTYPE_SIMPLE = 0x01, - KEYTYPE_MASTER = 0x02, - KEYTYPE_ENCRYPTED = 0x03, -}; - -/* List of supported key size */ -enum { - KEYSIZE_16 = 16, - KEYSIZE_32 = 32, -}; - -typedef PACKED_STRUCT{ + /** Command parameters */ + /* List of supported key type */ + enum + { + KEYTYPE_NONE = 0x00, + KEYTYPE_SIMPLE = 0x01, + KEYTYPE_MASTER = 0x02, + KEYTYPE_ENCRYPTED = 0x03, + }; + + /* List of supported key size */ + enum + { + KEYSIZE_16 = 16, + KEYSIZE_32 = 32, + }; + + typedef PACKED_STRUCT{ uint8_t KeyType; uint8_t KeySize; uint8_t KeyData[32 + 12]; -} SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t; + } SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t; -/** Response parameters*/ -/** It responds a 1 byte value holding the index given for the stored key */ + /** Response parameters*/ + /** It responds a 1 byte value holding the index given for the stored key */ #define SHCI_OPCODE_C2_FUS_LOAD_USR_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOAD_USR_KEY) -/** Command parameters */ -/** 1 byte holding the key index value */ + /** Command parameters */ + /** 1 byte holding the key index value */ -/** No response parameters*/ + /** No response parameters*/ #define SHCI_OPCODE_C2_FUS_START_WS (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_START_WS) /** No command parameters */ @@ -288,10 +298,10 @@ typedef PACKED_STRUCT{ /** No response parameters*/ #define SHCI_OPCODE_C2_FUS_LOCK_USR_KEY (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_LOCK_USR_KEY) -/** Command parameters */ -/** 1 byte holding the key index value */ + /** Command parameters */ + /** 1 byte holding the key index value */ -/** No response parameters*/ + /** No response parameters*/ #define SHCI_OPCODE_C2_FUS_RESERVED5 (( SHCI_OGF << 10) + SHCI_OCF_C2_FUS_RESERVED5) /** No command parameters */ @@ -326,9 +336,9 @@ typedef PACKED_STRUCT{ /** No response parameters*/ #define SHCI_OPCODE_C2_BLE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_BLE_INIT) -/** THE ORDER SHALL NOT BE CHANGED */ -typedef PACKED_STRUCT{ - uint8_t *pBleBufferAddress; /**< NOT USED CURRENTLY */ + /** THE ORDER SHALL NOT BE CHANGED */ + typedef PACKED_STRUCT{ + uint8_t* pBleBufferAddress; /**< NOT USED CURRENTLY */ uint32_t BleBufferSize; /**< Size of the Buffer allocated in pBleBufferAddress */ uint16_t NumAttrRecord; uint16_t NumAttrServ; @@ -346,71 +356,76 @@ typedef PACKED_STRUCT{ uint8_t ViterbiEnable; uint8_t LlOnly; uint8_t HwVersion; -} SHCI_C2_Ble_Init_Cmd_Param_t; + } SHCI_C2_Ble_Init_Cmd_Param_t; -typedef PACKED_STRUCT{ - SHCI_Header_t Header; /** Does not need to be initialized by the user */ - SHCI_C2_Ble_Init_Cmd_Param_t Param; -} SHCI_C2_Ble_Init_Cmd_Packet_t; + typedef PACKED_STRUCT{ + SHCI_Header_t Header; /** Does not need to be initialized by the user */ + SHCI_C2_Ble_Init_Cmd_Param_t Param; + } SHCI_C2_Ble_Init_Cmd_Packet_t; -/** No response parameters*/ + /** No response parameters*/ #define SHCI_OPCODE_C2_THREAD_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_THREAD_INIT) /** No command parameters */ /** No response parameters*/ #define SHCI_OPCODE_C2_DEBUG_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_DEBUG_INIT) -/** Command parameters */ -typedef PACKED_STRUCT { - uint8_t thread_config; - uint8_t ble_config; -} SHCI_C2_DEBUG_TracesConfig_t; - -typedef PACKED_STRUCT { - uint8_t ble_dtb_cfg; - uint8_t reserved[3]; -} SHCI_C2_DEBUG_GeneralConfig_t; - -typedef PACKED_STRUCT{ - uint8_t *pGpioConfig; - uint8_t *pTracesConfig; - uint8_t *pGeneralConfig; - uint8_t GpioConfigSize; - uint8_t TracesConfigSize; - uint8_t GeneralConfigSize; -} SHCI_C2_DEBUG_init_Cmd_Param_t; - -typedef PACKED_STRUCT{ - SHCI_Header_t Header; /** Does not need to be initialized by the user */ - SHCI_C2_DEBUG_init_Cmd_Param_t Param; -} SHCI_C2_DEBUG_Init_Cmd_Packet_t; -/** No response parameters*/ + /** Command parameters */ + typedef PACKED_STRUCT + { + uint8_t thread_config; + uint8_t ble_config; + } SHCI_C2_DEBUG_TracesConfig_t; + + typedef PACKED_STRUCT + { + uint8_t ble_dtb_cfg; + uint8_t reserved[3]; + } SHCI_C2_DEBUG_GeneralConfig_t; + + typedef PACKED_STRUCT{ + uint8_t *pGpioConfig; + uint8_t *pTracesConfig; + uint8_t *pGeneralConfig; + uint8_t GpioConfigSize; + uint8_t TracesConfigSize; + uint8_t GeneralConfigSize; + } SHCI_C2_DEBUG_init_Cmd_Param_t; + + typedef PACKED_STRUCT{ + SHCI_Header_t Header; /** Does not need to be initialized by the user */ + SHCI_C2_DEBUG_init_Cmd_Param_t Param; + } SHCI_C2_DEBUG_Init_Cmd_Packet_t; + /** No response parameters*/ #define SHCI_OPCODE_C2_FLASH_ERASE_ACTIVITY (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_ERASE_ACTIVITY) -/** Command parameters */ -typedef enum { - ERASE_ACTIVITY_OFF = 0x00, - ERASE_ACTIVITY_ON = 0x01, -} SHCI_EraseActivity_t; + /** Command parameters */ + typedef enum + { + ERASE_ACTIVITY_OFF = 0x00, + ERASE_ACTIVITY_ON = 0x01, + } SHCI_EraseActivity_t; -/** No response parameters*/ + /** No response parameters*/ #define SHCI_OPCODE_C2_CONCURRENT_SET_MODE (( SHCI_OGF << 10) + SHCI_OCF_C2_CONCURRENT_SET_MODE) /** command parameters */ -typedef enum { - BLE_ENABLE, - THREAD_ENABLE, -} SHCI_C2_CONCURRENT_Mode_Param_t; -/** No response parameters*/ + typedef enum + { + BLE_ENABLE, + THREAD_ENABLE, + } SHCI_C2_CONCURRENT_Mode_Param_t; + /** No response parameters*/ #define SHCI_OPCODE_C2_FLASH_STORE_DATA (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_STORE_DATA) #define SHCI_OPCODE_C2_FLASH_ERASE_DATA (( SHCI_OGF << 10) + SHCI_OCF_C2_FLASH_ERASE_DATA) /** command parameters */ -typedef enum { - BLE_IP, - THREAD_IP, -} SHCI_C2_FLASH_Ip_t; -/** No response parameters*/ + typedef enum + { + BLE_IP, + THREAD_IP, + } SHCI_C2_FLASH_Ip_t; + /** No response parameters*/ #define SHCI_OPCODE_C2_RADIO_ALLOW_LOW_POWER (( SHCI_OGF << 10) + SHCI_OCF_C2_RADIO_ALLOW_LOW_POWER) @@ -421,45 +436,48 @@ typedef enum { #define SHCI_OPCODE_C2_LLD_BLE_INIT (( SHCI_OGF << 10) + SHCI_OCF_C2_LLD_BLE_INIT) #define SHCI_OPCODE_C2_EXTPA_CONFIG (( SHCI_OGF << 10) + SHCI_OCF_C2_EXTPA_CONFIG) -/** Command parameters */ -enum { - EXT_PA_ENABLED_LOW, - EXT_PA_ENABLED_HIGH, -}/* gpio_polarity */; - -enum { - EXT_PA_DISABLED, - EXT_PA_ENABLED, -}/* gpio_status */; - -typedef PACKED_STRUCT{ - uint32_t gpio_port; - uint16_t gpio_pin_number; - uint8_t gpio_polarity; - uint8_t gpio_status; -} SHCI_C2_EXTPA_CONFIG_Cmd_Param_t; - -/** No response parameters*/ + /** Command parameters */ + enum + { + EXT_PA_ENABLED_LOW, + EXT_PA_ENABLED_HIGH, + }/* gpio_polarity */; + + enum + { + EXT_PA_DISABLED, + EXT_PA_ENABLED, + }/* gpio_status */; + + typedef PACKED_STRUCT{ + uint32_t gpio_port; + uint16_t gpio_pin_number; + uint8_t gpio_polarity; + uint8_t gpio_status; + } SHCI_C2_EXTPA_CONFIG_Cmd_Param_t; + + /** No response parameters*/ #define SHCI_OPCODE_C2_SET_FLASH_ACTIVITY_CONTROL (( SHCI_OGF << 10) + SHCI_OCF_C2_SET_FLASH_ACTIVITY_CONTROL) -/** Command parameters */ -typedef enum { - FLASH_ACTIVITY_CONTROL_PES, - FLASH_ACTIVITY_CONTROL_SEM7, -} SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t; + /** Command parameters */ + typedef enum + { + FLASH_ACTIVITY_CONTROL_PES, + FLASH_ACTIVITY_CONTROL_SEM7, + }SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t; -/** No response parameters*/ + /** No response parameters*/ #define SHCI_OPCODE_C2_CONFIG (( SHCI_OGF << 10) + SHCI_OCF_C2_CONFIG) -/** Command parameters */ -typedef PACKED_STRUCT{ - uint8_t PayloadCmdSize; - uint8_t Config1; - uint8_t EvtMask1; - uint8_t Spare1; - uint32_t BleNvmRamAddress; - uint32_t ThreadNvmRamAddress; -} SHCI_C2_CONFIG_Cmd_Param_t; + /** Command parameters */ + typedef PACKED_STRUCT{ + uint8_t PayloadCmdSize; + uint8_t Config1; + uint8_t EvtMask1; + uint8_t Spare1; + uint32_t BleNvmRamAddress; + uint32_t ThreadNvmRamAddress; + } SHCI_C2_CONFIG_Cmd_Param_t; /** * PayloadCmdSize @@ -504,9 +522,9 @@ typedef PACKED_STRUCT{ #define THREAD_NVM_SRAM_SIZE (1016) -/** No response parameters*/ + /** No response parameters*/ -/* Exported type --------------------------------------------------------*/ + /* Exported type --------------------------------------------------------*/ typedef MB_WirelessFwInfoTable_t SHCI_WirelessFwInfoTable_t; @@ -564,16 +582,16 @@ typedef MB_WirelessFwInfoTable_t SHCI_WirelessFwInfoTable_t; #define INFO_STACK_TYPE_THREAD_FTD 0x10 #define INFO_STACK_TYPE_THREAD_MTD 0x11 #define INFO_STACK_TYPE_BLE_THREAD_FTD_STATIC 0x50 -#define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 +#define INFO_STACK_TYPE_BLE_THREAD_FTD_DYAMIC 0x51 #define INFO_STACK_TYPE_BLE_PHY_VALID 0x62 #define INFO_STACK_TYPE_BLE_LLD_TESTS 0x63 #define INFO_STACK_TYPE_BLE_RLV 0x64 #define INFO_STACK_TYPE_RLV 0x80 typedef struct { - /** - * Wireless Info - */ +/** + * Wireless Info + */ uint8_t VersionMajor; uint8_t VersionMinor; uint8_t VersionSub; @@ -584,16 +602,16 @@ typedef struct { uint8_t MemorySizeSram1; /*< Multiple of 1K */ uint8_t MemorySizeFlash; /*< Multiple of 4K */ uint8_t StackType; - /** - * Fus Info - */ +/** + * Fus Info + */ uint8_t FusVersionMajor; uint8_t FusVersionMinor; uint8_t FusVersionSub; uint8_t FusMemorySizeSram2B; /*< Multiple of 1K */ uint8_t FusMemorySizeSram2A; /*< Multiple of 1K */ uint8_t FusMemorySizeFlash; /*< Multiple of 4K */ -} WirelessFwInfo_t; +}WirelessFwInfo_t; /* Exported functions ------------------------------------------------------- */ @@ -604,282 +622,282 @@ typedef struct { * When any FUS command is sent after the SHCI_FUS_CMD_NOT_SUPPORTED has been received, * the CPU2 switches on the RSS ( This reboots automatically the device ) */ -/** -* SHCI_C2_FUS_GetState -* @brief Read the FUS State -* If the user is not interested by the Error code response, a null value may -* be passed as parameter -* -* @param p_rsp : return the error code when the FUS State Value = 0xFF -* @retval FUS State Values -*/ -uint8_t SHCI_C2_FUS_GetState(SHCI_FUS_GetState_ErrorCode_t *p_rsp); - -/** -* SHCI_C2_FUS_FwUpgrade -* @brief Request the FUS to install the CPU2 firmware update -* -* @param fw_src_add: Address of the firmware image location -* @param fw_dest_add: Address of the firmware destination -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade(uint32_t fw_src_add, uint32_t fw_dest_add); + /** + * SHCI_C2_FUS_GetState + * @brief Read the FUS State + * If the user is not interested by the Error code response, a null value may + * be passed as parameter + * + * @param p_rsp : return the error code when the FUS State Value = 0xFF + * @retval FUS State Values + */ + uint8_t SHCI_C2_FUS_GetState( SHCI_FUS_GetState_ErrorCode_t *p_rsp ); -/** -* SHCI_C2_FUS_FwDelete -* @brief Delete the wireless stack on CPU2 -* -* @param None -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete(void); + /** + * SHCI_C2_FUS_FwUpgrade + * @brief Request the FUS to install the CPU2 firmware update + * + * @param fw_src_add: Address of the firmware image location + * @param fw_dest_add: Address of the firmware destination + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_FwUpgrade( uint32_t fw_src_add, uint32_t fw_dest_add ); -/** -* SHCI_C2_FUS_UpdateAuthKey -* @brief Request the FUS to update the authentication key -* -* @param pCmdPacket -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey(SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t *pParam); + /** + * SHCI_C2_FUS_FwDelete + * @brief Delete the wireless stack on CPU2 + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_FwDelete( void ); -/** -* SHCI_C2_FUS_LockAuthKey -* @brief Request the FUS to prevent any future update of the authentication key -* -* @param None -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey(void); + /** + * SHCI_C2_FUS_UpdateAuthKey + * @brief Request the FUS to update the authentication key + * + * @param pCmdPacket + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_UpdateAuthKey( SHCI_C2_FUS_UpdateAuthKey_Cmd_Param_t *pParam ); -/** -* SHCI_C2_FUS_StoreUsrKey -* @brief Request the FUS to store the user key -* -* @param pParam : command parameter -* @param p_key_index : Index allocated by the FUS to the stored key -* -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey(SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *pParam, uint8_t *p_key_index); + /** + * SHCI_C2_FUS_LockAuthKey + * @brief Request the FUS to prevent any future update of the authentication key + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_LockAuthKey( void ); -/** -* SHCI_C2_FUS_LoadUsrKey -* @brief Request the FUS to load the user key into the AES -* -* @param key_index : index of the user key to load in AES1 -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey(uint8_t key_index); + /** + * SHCI_C2_FUS_StoreUsrKey + * @brief Request the FUS to store the user key + * + * @param pParam : command parameter + * @param p_key_index : Index allocated by the FUS to the stored key + * + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_StoreUsrKey( SHCI_C2_FUS_StoreUsrKey_Cmd_Param_t *pParam, uint8_t *p_key_index ); -/** -* SHCI_C2_FUS_StartWs -* @brief Request the FUS to reboot on the wireless stack -* -* @param None -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_StartWs(void); + /** + * SHCI_C2_FUS_LoadUsrKey + * @brief Request the FUS to load the user key into the AES + * + * @param key_index : index of the user key to load in AES1 + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_LoadUsrKey( uint8_t key_index ); -/** -* SHCI_C2_FUS_LockUsrKey -* @brief Request the FUS to lock the user key so that it cannot be updated later on -* -* @param key_index : index of the user key to lock -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey(uint8_t key_index); + /** + * SHCI_C2_FUS_StartWs + * @brief Request the FUS to reboot on the wireless stack + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_StartWs( void ); -/** -* SHCI_C2_BLE_Init -* @brief Provides parameters and starts the BLE Stack -* -* @param pCmdPacket : Parameters to be provided to the BLE Stack -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_BLE_Init(SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket); + /** + * SHCI_C2_FUS_LockUsrKey + * @brief Request the FUS to lock the user key so that it cannot be updated later on + * + * @param key_index : index of the user key to lock + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FUS_LockUsrKey( uint8_t key_index ); -/** -* SHCI_C2_THREAD_Init -* @brief Starts the THREAD Stack -* -* @param None -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_THREAD_Init(void); + /** + * SHCI_C2_BLE_Init + * @brief Provides parameters and starts the BLE Stack + * + * @param pCmdPacket : Parameters to be provided to the BLE Stack + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_BLE_Init( SHCI_C2_Ble_Init_Cmd_Packet_t *pCmdPacket ); -/** -* SHCI_C2_LLDTESTS_Init -* @brief Starts the LLD tests CLI -* -* @param param_size : Nb of bytes -* @param p_param : pointer with data to give from M4 to M0 -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init(uint8_t param_size, uint8_t *p_param); + /** + * SHCI_C2_THREAD_Init + * @brief Starts the THREAD Stack + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_THREAD_Init( void ); -/** -* SHCI_C2_LLD_BLE_Init -* @brief Starts the LLD tests CLI -* -* @param param_size : Nb of bytes -* @param p_param : pointer with data to give from M4 to M0 -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init(uint8_t param_size, uint8_t *p_param); + /** + * SHCI_C2_LLDTESTS_Init + * @brief Starts the LLD tests CLI + * + * @param param_size : Nb of bytes + * @param p_param : pointer with data to give from M4 to M0 + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_LLDTESTS_Init( uint8_t param_size, uint8_t * p_param ); -/** -* SHCI_C2_DEBUG_Init -* @brief Starts the Traces -* -* @param None -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_DEBUG_Init(SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket); + /** + * SHCI_C2_LLD_BLE_Init + * @brief Starts the LLD tests CLI + * + * @param param_size : Nb of bytes + * @param p_param : pointer with data to give from M4 to M0 + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_LLD_BLE_Init( uint8_t param_size, uint8_t * p_param ); + + /** + * SHCI_C2_DEBUG_Init + * @brief Starts the Traces + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_DEBUG_Init( SHCI_C2_DEBUG_Init_Cmd_Packet_t *pCmdPacket ); -/** -* SHCI_C2_FLASH_EraseActivity -* @brief Provides the information of the start and the end of a flash erase window on the CPU1 -* -* @param erase_activity: Start/End of erase activity -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity(SHCI_EraseActivity_t erase_activity); + /** + * SHCI_C2_FLASH_EraseActivity + * @brief Provides the information of the start and the end of a flash erase window on the CPU1 + * + * @param erase_activity: Start/End of erase activity + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FLASH_EraseActivity( SHCI_EraseActivity_t erase_activity ); -/** -* SHCI_C2_CONCURRENT_SetMode -* @brief Enable/Disable Thread on CPU2 (M0+) -* -* @param Mode: BLE or Thread enable flag -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode(SHCI_C2_CONCURRENT_Mode_Param_t Mode); + /** + * SHCI_C2_CONCURRENT_SetMode + * @brief Enable/Disable Thread on CPU2 (M0+) + * + * @param Mode: BLE or Thread enable flag + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_CONCURRENT_SetMode( SHCI_C2_CONCURRENT_Mode_Param_t Mode ); -/** -* SHCI_C2_FLASH_StoreData -* @brief Store Data in Flash -* -* @param Ip: BLE or THREAD -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData(SHCI_C2_FLASH_Ip_t Ip); + /** + * SHCI_C2_FLASH_StoreData + * @brief Store Data in Flash + * + * @param Ip: BLE or THREAD + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FLASH_StoreData( SHCI_C2_FLASH_Ip_t Ip ); -/** -* SHCI_C2_FLASH_EraseData -* @brief Erase Data in Flash -* -* @param Ip: BLE or THREAD -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData(SHCI_C2_FLASH_Ip_t Ip); + /** + * SHCI_C2_FLASH_EraseData + * @brief Erase Data in Flash + * + * @param Ip: BLE or THREAD + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_FLASH_EraseData( SHCI_C2_FLASH_Ip_t Ip ); -/** -* SHCI_C2_RADIO_AllowLowPower -* @brief Allow or forbid IP_radio (802_15_4 or BLE) to enter in low power mode. -* -* @param Ip: BLE or 802_15_5 -* @param FlagRadioLowPowerOn: True or false -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower(SHCI_C2_FLASH_Ip_t Ip, uint8_t FlagRadioLowPowerOn); + /** + * SHCI_C2_RADIO_AllowLowPower + * @brief Allow or forbid IP_radio (802_15_4 or BLE) to enter in low power mode. + * + * @param Ip: BLE or 802_15_5 + * @param FlagRadioLowPowerOn: True or false + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_RADIO_AllowLowPower( SHCI_C2_FLASH_Ip_t Ip,uint8_t FlagRadioLowPowerOn); -/** - * SHCI_GetWirelessFwInfo - * @brief This function read back the information relative to the wireless binary loaded. - * Refer yourself to SHCI_WirelessFwInfoTable_t structure to get the significance - * of the different parameters returned. - * @param pWirelessInfo : Pointer to WirelessFwInfo_t. - * - * @retval SHCI_Success - */ -SHCI_CmdStatus_t SHCI_GetWirelessFwInfo(WirelessFwInfo_t *pWirelessInfo); + /** + * SHCI_GetWirelessFwInfo + * @brief This function read back the information relative to the wireless binary loaded. + * Refer yourself to SHCI_WirelessFwInfoTable_t structure to get the significance + * of the different parameters returned. + * @param pWirelessInfo : Pointer to WirelessFwInfo_t. + * + * @retval SHCI_Success + */ + SHCI_CmdStatus_t SHCI_GetWirelessFwInfo( WirelessFwInfo_t* pWirelessInfo ); -/** -* SHCI_C2_Reinit -* @brief This is required to allow the CPU1 to fake a set C2BOOT when it has already been set. -* In order to fake a C2BOOT, the CPU1 shall : -* - Send SHCI_C2_Reinit() -* - call SEV instruction -* WARNING: -* This function is intended to be used by the SBSFU -* -* @param None -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_Reinit(void); + /** + * SHCI_C2_Reinit + * @brief This is required to allow the CPU1 to fake a set C2BOOT when it has already been set. + * In order to fake a C2BOOT, the CPU1 shall : + * - Send SHCI_C2_Reinit() + * - call SEV instruction + * WARNING: + * This function is intended to be used by the SBSFU + * + * @param None + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_Reinit( void ); -/** -* SHCI_C2_ExtpaConfig -* @brief Send the Ext PA configuration -* When the CPU2 receives the command, it controls the Ext PA as requested by the configuration -* This configures only which IO is used to enable/disable the ExtPA and the associated polarity -* This command has no effect on the other IO that is used to control the mode of the Ext PA (Rx/Tx) -* -* @param gpio_port: GPIOx where x can be (A..F) to select the GPIO peripheral for STM32WBxx family -* @param gpio_pin_number: This parameter can be one of GPIO_PIN_x (= LL_GPIO_PIN_x) where x can be (0..15). -* @param gpio_polarity: This parameter can be either -* - EXT_PA_ENABLED_LOW: ExtPA is enabled when GPIO is low -* - EXT_PA_ENABLED_HIGH: ExtPA is enabled when GPIO is high -* @param gpio_status: This parameter can be either -* - EXT_PA_DISABLED: Stop driving the ExtPA -* - EXT_PA_ENABLED: Drive the ExtPA according to radio activity -* (ON before the Event and OFF at the end of the event) -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_number, uint8_t gpio_polarity, uint8_t gpio_status); + /** + * SHCI_C2_ExtpaConfig + * @brief Send the Ext PA configuration + * When the CPU2 receives the command, it controls the Ext PA as requested by the configuration + * This configures only which IO is used to enable/disable the ExtPA and the associated polarity + * This command has no effect on the other IO that is used to control the mode of the Ext PA (Rx/Tx) + * + * @param gpio_port: GPIOx where x can be (A..F) to select the GPIO peripheral for STM32WBxx family + * @param gpio_pin_number: This parameter can be one of GPIO_PIN_x (= LL_GPIO_PIN_x) where x can be (0..15). + * @param gpio_polarity: This parameter can be either + * - EXT_PA_ENABLED_LOW: ExtPA is enabled when GPIO is low + * - EXT_PA_ENABLED_HIGH: ExtPA is enabled when GPIO is high + * @param gpio_status: This parameter can be either + * - EXT_PA_DISABLED: Stop driving the ExtPA + * - EXT_PA_ENABLED: Drive the ExtPA according to radio activity + * (ON before the Event and OFF at the end of the event) + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_ExtpaConfig(uint32_t gpio_port, uint16_t gpio_pin_number, uint8_t gpio_polarity, uint8_t gpio_status); -/** -* SHCI_C2_SetFlashActivityControl -* @brief Set the mechanism to be used on CPU2 to prevent the CPU1 to either write or erase in flash -* -* @param Source: It can be one of the following list -* - FLASH_ACTIVITY_CONTROL_PES : The CPU2 set the PES bit to prevent the CPU1 to either read or write in flash -* - FLASH_ACTIVITY_CONTROL_SEM7 : The CPU2 gets the semaphore 7 to prevent the CPU1 to either read or write in flash. -* This requires the CPU1 to first get semaphore 7 before erasing or writing the flash. -* -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t Source); + /** + * SHCI_C2_SetFlashActivityControl + * @brief Set the mechanism to be used on CPU2 to prevent the CPU1 to either write or erase in flash + * + * @param Source: It can be one of the following list + * - FLASH_ACTIVITY_CONTROL_PES : The CPU2 set the PES bit to prevent the CPU1 to either read or write in flash + * - FLASH_ACTIVITY_CONTROL_SEM7 : The CPU2 gets the semaphore 7 to prevent the CPU1 to either read or write in flash. + * This requires the CPU1 to first get semaphore 7 before erasing or writing the flash. + * + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_SetFlashActivityControl(SHCI_C2_SET_FLASH_ACTIVITY_CONTROL_Source_t Source); -/** -* SHCI_C2_Config -* @brief Send the system configuration to the CPU2 -* -* @param pCmdPacket: address of the buffer holding following parameters -* uint8_t PayloadCmdSize : Size of the payload - shall be SHCI_C2_CONFIG_PAYLOAD_CMD_SIZE -* uint8_t Config1 : -* - bit0 : 0 - BLE NVM Data data are flushed in internal secure flash -* 1 - BLE NVM Data are written in SRAM cache pointed by BleNvmRamAddress -* - bit1 : 0 - THREAD NVM Data data are flushed in internal secure flash -* 1 - THREAD NVM Data are written in SRAM cache pointed by ThreadNvmRamAddress -* - bit2 to bit7 : Unused, shall be set to 0 -* uint8_t EvtMask1 : -* When a bit is set to 0, the event is not reported -* bit0 : Asynchronous Event with Sub Evt Code 0x9201 (= SHCI_SUB_EVT_ERROR_NOTIF) -* ... -* bit31 : Asynchronous Event with Sub Evt Code 0x9220 -* uint8_t Spare1 : Unused, shall be set to 0 -* uint32_t BleNvmRamAddress : -* Only considered when Config1.bit0 = 1 -* When set to 0, data are kept in internal SRAM on CPU2 -* Otherwise, data are copied in the cache pointed by BleNvmRamAddress -* The size of the buffer shall be BLE_NVM_SRAM_SIZE (number of 32bits) -* The buffer shall be allocated in SRAM2 -* uint32_t ThreadNvmRamAddress : -* Only considered when Config1.bit1 = 1 -* When set to 0, data are kept in internal SRAM on CPU2 -* Otherwise, data are copied in the cache pointed by ThreadNvmRamAddress -* The size of the buffer shall be THREAD_NVM_SRAM_SIZE (number of 32bits) -* The buffer shall be allocated in SRAM2 -* -* Please check macro definition to be used for this function -* They are defined in this file next to the definition of SHCI_OPCODE_C2_CONFIG -* -* @retval Status -*/ -SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket); + /** + * SHCI_C2_Config + * @brief Send the system configuration to the CPU2 + * + * @param pCmdPacket: address of the buffer holding following parameters + * uint8_t PayloadCmdSize : Size of the payload - shall be SHCI_C2_CONFIG_PAYLOAD_CMD_SIZE + * uint8_t Config1 : + * - bit0 : 0 - BLE NVM Data data are flushed in internal secure flash + * 1 - BLE NVM Data are written in SRAM cache pointed by BleNvmRamAddress + * - bit1 : 0 - THREAD NVM Data data are flushed in internal secure flash + * 1 - THREAD NVM Data are written in SRAM cache pointed by ThreadNvmRamAddress + * - bit2 to bit7 : Unused, shall be set to 0 + * uint8_t EvtMask1 : + * When a bit is set to 0, the event is not reported + * bit0 : Asynchronous Event with Sub Evt Code 0x9201 (= SHCI_SUB_EVT_ERROR_NOTIF) + * ... + * bit31 : Asynchronous Event with Sub Evt Code 0x9220 + * uint8_t Spare1 : Unused, shall be set to 0 + * uint32_t BleNvmRamAddress : + * Only considered when Config1.bit0 = 1 + * When set to 0, data are kept in internal SRAM on CPU2 + * Otherwise, data are copied in the cache pointed by BleNvmRamAddress + * The size of the buffer shall be BLE_NVM_SRAM_SIZE (number of 32bits) + * The buffer shall be allocated in SRAM2 + * uint32_t ThreadNvmRamAddress : + * Only considered when Config1.bit1 = 1 + * When set to 0, data are kept in internal SRAM on CPU2 + * Otherwise, data are copied in the cache pointed by ThreadNvmRamAddress + * The size of the buffer shall be THREAD_NVM_SRAM_SIZE (number of 32bits) + * The buffer shall be allocated in SRAM2 + * + * Please check macro definition to be used for this function + * They are defined in this file next to the definition of SHCI_OPCODE_C2_CONFIG + * + * @retval Status + */ + SHCI_CmdStatus_t SHCI_C2_Config(SHCI_C2_CONFIG_Cmd_Param_t *pCmdPacket); -#ifdef __cplusplus + #ifdef __cplusplus } #endif diff --git a/src/utility/STM32Cube_FW/shci_tl.c b/src/utility/STM32Cube_FW/shci_tl.c index c2d7589e..8d4d4ff4 100644 --- a/src/utility/STM32Cube_FW/shci_tl.c +++ b/src/utility/STM32Cube_FW/shci_tl.c @@ -6,11 +6,11 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2019 STMicroelectronics. + *

© 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 + * 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 * @@ -32,28 +32,29 @@ * 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" +#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 +#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(...) +#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 +#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(...) +#define TL_SHCI_EVT_DBG_MSG(...) +#define TL_SHCI_EVT_DBG_BUF(...) #endif /* Private typedef -----------------------------------------------------------*/ -typedef enum { +typedef enum +{ SHCI_TL_CMD_RESP_RELEASE, SHCI_TL_CMD_RESP_WAIT, } SHCI_TL_CmdRespStatus_t; @@ -79,7 +80,7 @@ PLACE_IN_SECTION("SYSTEM_DRIVER_CONTEXT") SHCI_TL_UserEventFlowStatus_t SHCI_TL_ */ static tSHciContext shciContext; -static void (* StatusNotCallBackFunction)(SHCI_TL_CmdStatus_t status); +static void (* StatusNotCallBackFunction) (SHCI_TL_CmdStatus_t status); static volatile SHCI_TL_CmdRespStatus_t CmdRspStatusFlag; @@ -87,18 +88,18 @@ static volatile SHCI_TL_CmdRespStatus_t CmdRspStatusFlag; 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 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) +void shci_init(void(* UserEvtRx)(void* pData), void* pConf) { StatusNotCallBackFunction = ((SHCI_TL_HciInitConf_t *)pConf)->StatusNotCallBack; shciContext.UserEvtRx = UserEvtRx; - shci_register_io_bus(&shciContext.io); + shci_register_io_bus (&shciContext.io); TlInit((TL_CmdPacket_t *)(((SHCI_TL_HciInitConf_t *)pConf)->p_cmdbuffer)); @@ -124,38 +125,47 @@ void shci_user_evt_proc(void) * It is more secure to use LST_remove_head()/LST_insert_head() compare to LST_get_next_node()/LST_remove_node() * in case the user overwrite the header where the next/prev pointers are located */ - if ((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable)) { - LST_remove_head(&SHciAsynchEventQueue, (tListNode **)&phcievtbuffer); + if((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable)) + { + LST_remove_head ( &SHciAsynchEventQueue, (tListNode **)&phcievtbuffer ); OutputEvtTrace(phcievtbuffer); - if (shciContext.UserEvtRx != NULL) { + if (shciContext.UserEvtRx != NULL) + { UserEvtRxParam.pckt = phcievtbuffer; UserEvtRxParam.status = SHCI_TL_UserEventFlow_Enable; shciContext.UserEvtRx((void *)&UserEvtRxParam); SHCI_TL_UserEventFlow = UserEvtRxParam.status; - } else { + } + else + { SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable; } - if (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable) { - TL_MM_EvtDone(phcievtbuffer); - } else { + if(SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable) + { + TL_MM_EvtDone( phcievtbuffer ); + } + else + { /** * put back the event in the queue */ - LST_insert_head(&SHciAsynchEventQueue, (tListNode *)phcievtbuffer); + LST_insert_head ( &SHciAsynchEventQueue, (tListNode *)phcievtbuffer ); } } - if ((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable)) { - shci_notify_asynch_evt((void *) &SHciAsynchEventQueue); + if((LST_is_empty(&SHciAsynchEventQueue) == FALSE) && (SHCI_TL_UserEventFlow != SHCI_TL_UserEventFlow_Disable)) + { + shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); } + return; } -void shci_resume_flow(void) +void shci_resume_flow( void ) { SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable; @@ -163,23 +173,23 @@ void shci_resume_flow(void) * It is better to go through the background process as it is not sure from which context this API may * be called */ - shci_notify_asynch_evt((void *) &SHciAsynchEventQueue); + shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); return; } -void shci_send(uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t *p_cmd_payload, TL_EvtPacket_t *p_rsp) +void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payload, TL_EvtPacket_t * p_rsp ) { Cmd_SetStatus(SHCI_TL_CmdBusy); pCmdBuffer->cmdserial.cmd.cmdcode = cmd_code; pCmdBuffer->cmdserial.cmd.plen = len_cmd_payload; - memcpy(pCmdBuffer->cmdserial.cmd.payload, p_cmd_payload, len_cmd_payload); + memcpy(pCmdBuffer->cmdserial.cmd.payload, p_cmd_payload, len_cmd_payload ); OutputCmdTrace(pCmdBuffer); - shciContext.io.Send(0, 0); + shciContext.io.Send(0,0); shci_cmd_resp_wait(SHCI_TL_DEFAULT_TIMEOUT); @@ -187,7 +197,7 @@ void shci_send(uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t *p_cmd_payloa * The command complete of a system command does not have the header * It starts immediately with the evtserial field */ - memcpy(&(p_rsp->evtserial), pCmdBuffer, ((TL_EvtSerial_t *)pCmdBuffer)->evt.plen + TL_EVT_HDR_SIZE); + memcpy( &(p_rsp->evtserial), pCmdBuffer, ((TL_EvtSerial_t*)pCmdBuffer)->evt.plen + TL_EVT_HDR_SIZE ); OutputRspTrace(p_rsp); @@ -211,20 +221,21 @@ void shci_register_io_bus(tSHciIO *fops) } /* Private functions ---------------------------------------------------------*/ -static void TlInit(TL_CmdPacket_t *p_cmdbuffer) +static void TlInit( TL_CmdPacket_t * p_cmdbuffer ) { TL_SYS_InitConf_t Conf; pCmdBuffer = p_cmdbuffer; - LST_init_head(&SHciAsynchEventQueue); + LST_init_head (&SHciAsynchEventQueue); Cmd_SetStatus(SHCI_TL_CmdAvailable); SHCI_TL_UserEventFlow = SHCI_TL_UserEventFlow_Enable; /* Initialize low level driver */ - if (shciContext.io.Init) { + if (shciContext.io.Init) + { Conf.p_cmdbuffer = (uint8_t *)p_cmdbuffer; Conf.IoBusCallBackCmdEvt = TlCmdEvtReceived; @@ -237,15 +248,20 @@ static void TlInit(TL_CmdPacket_t *p_cmdbuffer) static void Cmd_SetStatus(SHCI_TL_CmdStatus_t shcicmdstatus) { - if (shcicmdstatus == SHCI_TL_CmdBusy) { - if (StatusNotCallBackFunction != 0) { - StatusNotCallBackFunction(SHCI_TL_CmdBusy); + if(shcicmdstatus == SHCI_TL_CmdBusy) + { + if(StatusNotCallBackFunction != 0) + { + StatusNotCallBackFunction( SHCI_TL_CmdBusy ); } SHCICmdStatus = SHCI_TL_CmdBusy; - } else { + } + else + { SHCICmdStatus = SHCI_TL_CmdAvailable; - if (StatusNotCallBackFunction != 0) { - StatusNotCallBackFunction(SHCI_TL_CmdAvailable); + if(StatusNotCallBackFunction != 0) + { + StatusNotCallBackFunction( SHCI_TL_CmdAvailable ); } } @@ -263,7 +279,7 @@ static void TlCmdEvtReceived(TL_EvtPacket_t *shcievt) static void TlUserEvtReceived(TL_EvtPacket_t *shcievt) { LST_insert_tail(&SHciAsynchEventQueue, (tListNode *)shcievt); - shci_notify_asynch_evt((void *) &SHciAsynchEventQueue); /**< Notify the application a full HCI event has been received */ + shci_notify_asynch_evt((void*) &SHciAsynchEventQueue); /**< Notify the application a full HCI event has been received */ return; } @@ -272,7 +288,8 @@ 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) { + 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, ""); } @@ -283,14 +300,16 @@ static void OutputCmdTrace(TL_CmdPacket_t *pCmdBuffer) static void OutputRspTrace(TL_EvtPacket_t *p_rsp) { - switch (p_rsp->evtserial.evt.evtcode) { + 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(" 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, ""); + TL_SHCI_CMD_DBG_BUF(&((TL_CcEvt_t*)(p_rsp->evtserial.evt.payload))->payload[1], p_rsp->evtserial.evt.plen-4, ""); } break; @@ -306,14 +325,18 @@ static void OutputRspTrace(TL_EvtPacket_t *p_rsp) static void OutputEvtTrace(TL_EvtPacket_t *phcievtbuffer) { - if (phcievtbuffer->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) { + if(phcievtbuffer->evtserial.evt.evtcode != TL_BLEEVT_VS_OPCODE) + { TL_SHCI_EVT_DBG_MSG("unknown sys evt received: %02X", phcievtbuffer->evtserial.evt.evtcode); - } else { + } + 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(" 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_BUF(((TL_AsynchEvt_t*)(phcievtbuffer->evtserial.evt.payload))->payload, phcievtbuffer->evtserial.evt.plen-2, ""); } } @@ -344,4 +367,3 @@ __WEAK void shci_cmd_resp_release(uint32_t flag) } #endif /* STM32WBxx */ - diff --git a/src/utility/STM32Cube_FW/shci_tl.h b/src/utility/STM32Cube_FW/shci_tl.h index f6cc8043..3fbc492f 100644 --- a/src/utility/STM32Cube_FW/shci_tl.h +++ b/src/utility/STM32Cube_FW/shci_tl.h @@ -6,11 +6,11 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2019 STMicroelectronics. + *

© 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 + * 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 * @@ -28,12 +28,14 @@ extern "C" { #include "tl.h" /* Exported defines -----------------------------------------------------------*/ -typedef enum { +typedef enum +{ SHCI_TL_UserEventFlow_Disable, SHCI_TL_UserEventFlow_Enable, } SHCI_TL_UserEventFlowStatus_t; -typedef enum { +typedef enum +{ SHCI_TL_CmdBusy, SHCI_TL_CmdAvailable } SHCI_TL_CmdStatus_t; @@ -42,15 +44,16 @@ typedef enum { * @brief Structure used to manage the BUS IO operations. * All the structure fields will point to functions defined at user level. * @{ - */ -typedef struct { - int32_t (* Init)(void *pConf); /**< Pointer to SHCI TL function for the IO Bus initialization */ - int32_t (* DeInit)(void); /**< Pointer to SHCI TL function for the IO Bus de-initialization */ - int32_t (* Reset)(void); /**< Pointer to SHCI TL function for the IO Bus reset */ - int32_t (* Receive)(uint8_t *, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data reception */ - int32_t (* Send)(uint8_t *, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data transmission */ - int32_t (* DataAck)(uint8_t *, uint16_t *len); /**< Pointer to SHCI TL function for the IO Bus data ack reception */ - int32_t (* GetTick)(void); /**< Pointer to BSP function for getting the HAL time base timestamp */ + */ +typedef struct +{ + int32_t (* Init) (void* pConf); /**< Pointer to SHCI TL function for the IO Bus initialization */ + int32_t (* DeInit) (void); /**< Pointer to SHCI TL function for the IO Bus de-initialization */ + int32_t (* Reset) (void); /**< Pointer to SHCI TL function for the IO Bus reset */ + int32_t (* Receive) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data reception */ + int32_t (* Send) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data transmission */ + int32_t (* DataAck) (uint8_t*, uint16_t* len); /**< Pointer to SHCI TL function for the IO Bus data ack reception */ + int32_t (* GetTick) (void); /**< Pointer to BSP function for getting the HAL time base timestamp */ } tSHciIO; /** * @} @@ -60,19 +63,22 @@ typedef struct { * @brief Contain the SHCI context * @{ */ -typedef struct { +typedef struct +{ tSHciIO io; /**< Manage the BUS IO operations */ - void (* UserEvtRx)(void *pData); /**< User System events callback function pointer */ + void (* UserEvtRx) (void * pData); /**< User System events callback function pointer */ } tSHciContext; -typedef struct { +typedef struct +{ SHCI_TL_UserEventFlowStatus_t status; TL_EvtPacket_t *pckt; } tSHCI_UserEvtRxParam; -typedef struct { +typedef struct +{ uint8_t *p_cmdbuffer; - void (* StatusNotCallBack)(SHCI_TL_CmdStatus_t status); + void (* StatusNotCallBack) (SHCI_TL_CmdStatus_t status); } SHCI_TL_HciInitConf_t; /** @@ -85,14 +91,14 @@ typedef struct { * @param : p_rsp_status = Address of the full buffer holding the command complete event * @retval : None */ -void shci_send(uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t *p_cmd_payload, TL_EvtPacket_t *p_rsp_status); - +void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payload, TL_EvtPacket_t * p_rsp_status ); + /** * @brief Register IO bus services. * @param fops The SHCI IO structure managing the IO BUS * @retval None */ -void shci_register_io_bus(tSHciIO *fops); +void shci_register_io_bus(tSHciIO* fops); /** * @brief Interrupt service routine that must be called when the system channel @@ -101,10 +107,10 @@ void shci_register_io_bus(tSHciIO *fops); * @param pdata Packet or event pointer * @retval None */ -void shci_notify_asynch_evt(void *pdata); +void shci_notify_asynch_evt(void* pdata); /** - * @brief This function resume the User Event Flow which has been stopped on return + * @brief This function resume the User Event Flow which has been stopped on return * from UserEvtRx() when the User Event has not been processed. * * @param None @@ -160,7 +166,7 @@ void shci_user_evt_proc(void); * @param pConf: Configuration structure pointer * @retval None */ -void shci_init(void(* UserEvtRx)(void *pData), void *pConf); +void shci_init(void(* UserEvtRx)(void* pData), void* pConf); #ifdef __cplusplus } diff --git a/src/utility/STM32Cube_FW/stm32_wpan_common.h b/src/utility/STM32Cube_FW/stm32_wpan_common.h index 12f1a583..93e909ca 100644 --- a/src/utility/STM32Cube_FW/stm32_wpan_common.h +++ b/src/utility/STM32Cube_FW/stm32_wpan_common.h @@ -37,9 +37,9 @@ extern "C" { #include #include "cmsis_compiler.h" -/* -------------------------------- * - * Basic definitions * - * -------------------------------- */ + /* -------------------------------- * + * Basic definitions * + * -------------------------------- */ #undef NULL #define NULL 0U @@ -50,9 +50,9 @@ extern "C" { #undef TRUE #define TRUE (!0U) -/* -------------------------------- * - * Critical Section definition * - * -------------------------------- */ + /* -------------------------------- * + * Critical Section definition * + * -------------------------------- */ #undef BACKUP_PRIMASK #define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK() @@ -62,18 +62,18 @@ extern "C" { #undef RESTORE_PRIMASK #define RESTORE_PRIMASK() __set_PRIMASK(primask_bit) -/* -------------------------------- * - * Macro delimiters * - * -------------------------------- */ + /* -------------------------------- * + * Macro delimiters * + * -------------------------------- */ #undef M_BEGIN #define M_BEGIN do { #undef M_END #define M_END } while(0) -/* -------------------------------- * - * Some useful macro definitions * - * -------------------------------- */ + /* -------------------------------- * + * Some useful macro definitions * + * -------------------------------- */ #undef MAX #define MAX(a, b) (((a) > (b)) ? (a) : (b)) diff --git a/src/utility/STM32Cube_FW/stm_list.c b/src/utility/STM32Cube_FW/stm_list.c index 509b2b57..6e802a07 100644 --- a/src/utility/STM32Cube_FW/stm_list.c +++ b/src/utility/STM32Cube_FW/stm_list.c @@ -6,11 +6,11 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2019 STMicroelectronics. + *

© 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 + * 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 * @@ -26,24 +26,27 @@ #include "stm32_wpan_common.h" /****************************************************************************** - * Function Definitions + * Function Definitions ******************************************************************************/ -void LST_init_head(tListNode *listHead) +void LST_init_head (tListNode * listHead) { listHead->next = listHead; listHead->prev = listHead; } -bool LST_is_empty(tListNode *listHead) +bool LST_is_empty (tListNode * listHead) { uint32_t primask_bit; bool return_value; primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ - if (listHead->next == listHead) { + if(listHead->next == listHead) + { return_value = TRUE; - } else { + } + else + { return_value = FALSE; } __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ @@ -51,7 +54,7 @@ bool LST_is_empty(tListNode *listHead) return return_value; } -void LST_insert_head(tListNode *listHead, tListNode *node) +void LST_insert_head (tListNode * listHead, tListNode * node) { uint32_t primask_bit; @@ -67,7 +70,7 @@ void LST_insert_head(tListNode *listHead, tListNode *node) } -void LST_insert_tail(tListNode *listHead, tListNode *node) +void LST_insert_tail (tListNode * listHead, tListNode * node) { uint32_t primask_bit; @@ -83,7 +86,7 @@ void LST_insert_tail(tListNode *listHead, tListNode *node) } -void LST_remove_node(tListNode *node) +void LST_remove_node (tListNode * node) { uint32_t primask_bit; @@ -97,7 +100,7 @@ void LST_remove_node(tListNode *node) } -void LST_remove_head(tListNode *listHead, tListNode **node) +void LST_remove_head (tListNode * listHead, tListNode ** node ) { uint32_t primask_bit; @@ -105,13 +108,13 @@ void LST_remove_head(tListNode *listHead, tListNode **node) __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ *node = listHead->next; - LST_remove_node(listHead->next); + LST_remove_node (listHead->next); __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } -void LST_remove_tail(tListNode *listHead, tListNode **node) +void LST_remove_tail (tListNode * listHead, tListNode ** node ) { uint32_t primask_bit; @@ -119,13 +122,13 @@ void LST_remove_tail(tListNode *listHead, tListNode **node) __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ *node = listHead->prev; - LST_remove_node(listHead->prev); + LST_remove_node (listHead->prev); __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } -void LST_insert_node_after(tListNode *node, tListNode *ref_node) +void LST_insert_node_after (tListNode * node, tListNode * ref_node) { uint32_t primask_bit; @@ -141,7 +144,7 @@ void LST_insert_node_after(tListNode *node, tListNode *ref_node) } -void LST_insert_node_before(tListNode *node, tListNode *ref_node) +void LST_insert_node_before (tListNode * node, tListNode * ref_node) { uint32_t primask_bit; @@ -157,17 +160,18 @@ void LST_insert_node_before(tListNode *node, tListNode *ref_node) } -int LST_get_size(tListNode *listHead) +int LST_get_size (tListNode * listHead) { int size = 0; - tListNode *temp; + tListNode * temp; uint32_t primask_bit; primask_bit = __get_PRIMASK(); /**< backup PRIMASK bit */ __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ temp = listHead->next; - while (temp != listHead) { + while (temp != listHead) + { size++; temp = temp->next; } @@ -177,7 +181,7 @@ int LST_get_size(tListNode *listHead) return (size); } -void LST_get_next_node(tListNode *ref_node, tListNode **node) +void LST_get_next_node (tListNode * ref_node, tListNode ** node) { uint32_t primask_bit; @@ -190,7 +194,7 @@ void LST_get_next_node(tListNode *ref_node, tListNode **node) } -void LST_get_prev_node(tListNode *ref_node, tListNode **node) +void LST_get_prev_node (tListNode * ref_node, tListNode ** node) { uint32_t primask_bit; @@ -202,5 +206,4 @@ void LST_get_prev_node(tListNode *ref_node, tListNode **node) __set_PRIMASK(primask_bit); /**< Restore PRIMASK bit*/ } -#endif /* STM32WBxx */ - +#endif /* STM32WBxx */ \ No newline at end of file diff --git a/src/utility/STM32Cube_FW/stm_list.h b/src/utility/STM32Cube_FW/stm_list.h index 885b50c1..529eeddb 100644 --- a/src/utility/STM32Cube_FW/stm_list.h +++ b/src/utility/STM32Cube_FW/stm_list.h @@ -6,11 +6,11 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2019 STMicroelectronics. + *

© 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 + * 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 * @@ -20,47 +20,39 @@ #ifndef _STM_LIST_H_ #define _STM_LIST_H_ +#include "stm32_wpan_common.h" /* Includes ------------------------------------------------------------------*/ - +#include "stdint.h" #include "stdbool.h" -#include "stm32_wpan_common.h" -#ifdef __cplusplus -extern "C" { -#endif - -typedef PACKED_STRUCT _tListNode { - struct _tListNode *next; - struct _tListNode *prev; +typedef PACKED_STRUCT _tListNode { + struct _tListNode * next; + struct _tListNode * prev; } tListNode; -void LST_init_head(tListNode *listHead); - -bool LST_is_empty(tListNode *listHead); +void LST_init_head (tListNode * listHead); -void LST_insert_head(tListNode *listHead, tListNode *node); +bool LST_is_empty (tListNode * listHead); -void LST_insert_tail(tListNode *listHead, tListNode *node); +void LST_insert_head (tListNode * listHead, tListNode * node); -void LST_remove_node(tListNode *node); +void LST_insert_tail (tListNode * listHead, tListNode * node); -void LST_remove_head(tListNode *listHead, tListNode **node); +void LST_remove_node (tListNode * node); -void LST_remove_tail(tListNode *listHead, tListNode **node); +void LST_remove_head (tListNode * listHead, tListNode ** node ); -void LST_insert_node_after(tListNode *node, tListNode *ref_node); +void LST_remove_tail (tListNode * listHead, tListNode ** node ); -void LST_insert_node_before(tListNode *node, tListNode *ref_node); +void LST_insert_node_after (tListNode * node, tListNode * ref_node); -int LST_get_size(tListNode *listHead); +void LST_insert_node_before (tListNode * node, tListNode * ref_node); -void LST_get_next_node(tListNode *ref_node, tListNode **node); +int LST_get_size (tListNode * listHead); -void LST_get_prev_node(tListNode *ref_node, tListNode **node); +void LST_get_next_node (tListNode * ref_node, tListNode ** node); -#ifdef __cplusplus -} -#endif +void LST_get_prev_node (tListNode * ref_node, tListNode ** node); #endif /* _STM_LIST_H_ */ diff --git a/src/utility/STM32Cube_FW/tl.h b/src/utility/STM32Cube_FW/tl.h index f8abf288..4741599d 100644 --- a/src/utility/STM32Cube_FW/tl.h +++ b/src/utility/STM32Cube_FW/tl.h @@ -64,7 +64,8 @@ extern "C" { /* Exported types ------------------------------------------------------------*/ /**< Packet header */ -typedef PACKED_STRUCT { +typedef PACKED_STRUCT +{ uint32_t *next; uint32_t *prev; } TL_PacketHeader_t; @@ -76,7 +77,8 @@ typedef PACKED_STRUCT { /** * This the payload of TL_Evt_t for a command status event */ -typedef PACKED_STRUCT { +typedef PACKED_STRUCT +{ uint8_t status; uint8_t numcmd; uint16_t cmdcode; @@ -85,7 +87,8 @@ typedef PACKED_STRUCT { /** * This the payload of TL_Evt_t for a command complete event */ -typedef PACKED_STRUCT { +typedef PACKED_STRUCT +{ uint8_t numcmd; uint16_t cmdcode; uint8_t payload[1]; @@ -94,18 +97,21 @@ typedef PACKED_STRUCT { /** * This the payload of TL_Evt_t for an asynchronous event */ -typedef PACKED_STRUCT { +typedef PACKED_STRUCT +{ uint16_t subevtcode; uint8_t payload[1]; } TL_AsynchEvt_t; -typedef PACKED_STRUCT { +typedef PACKED_STRUCT +{ uint8_t evtcode; uint8_t plen; uint8_t payload[1]; } TL_Evt_t; -typedef PACKED_STRUCT { +typedef PACKED_STRUCT +{ uint8_t type; TL_Evt_t evt; } TL_EvtSerial_t; @@ -118,7 +124,8 @@ typedef PACKED_STRUCT { * include the header and shall use TL_EvtPacket_t format. Only the command response format on the * system channel is different. */ -typedef PACKED_STRUCT { +typedef PACKED_STRUCT +{ TL_PacketHeader_t header; TL_EvtSerial_t evtserial; } TL_EvtPacket_t; @@ -127,18 +134,21 @@ typedef PACKED_STRUCT { * Command type */ -typedef PACKED_STRUCT { +typedef PACKED_STRUCT +{ uint16_t cmdcode; uint8_t plen; uint8_t payload[255]; } TL_Cmd_t; -typedef PACKED_STRUCT { +typedef PACKED_STRUCT +{ uint8_t type; TL_Cmd_t cmd; } TL_CmdSerial_t; -typedef PACKED_STRUCT { +typedef PACKED_STRUCT +{ TL_PacketHeader_t header; TL_CmdSerial_t cmdserial; } TL_CmdPacket_t; @@ -146,19 +156,22 @@ typedef PACKED_STRUCT { /***************************************************************************************** * HCI ACL DATA type */ -typedef PACKED_STRUCT { +typedef PACKED_STRUCT +{ uint8_t type; uint16_t handle; uint16_t length; uint8_t acl_data[1]; } TL_AclDataSerial_t; -typedef PACKED_STRUCT { +typedef PACKED_STRUCT +{ TL_PacketHeader_t header; TL_AclDataSerial_t AclDataSerial; } TL_AclDataPacket_t; -typedef struct { +typedef struct +{ uint8_t *p_BleSpareEvtBuffer; uint8_t *p_SystemSpareEvtBuffer; uint8_t *p_AsynchEvtPool; @@ -167,40 +180,33 @@ typedef struct { uint32_t TracesEvtPoolSize; } TL_MM_Config_t; -typedef struct { +typedef struct +{ uint8_t *p_ThreadOtCmdRspBuffer; uint8_t *p_ThreadCliRspBuffer; uint8_t *p_ThreadNotAckBuffer; } TL_TH_Config_t; -typedef struct { +typedef struct +{ uint8_t *p_LldTestsCliCmdRspBuffer; uint8_t *p_LldTestsM0CmdBuffer; } TL_LLD_tests_Config_t; -typedef struct { +typedef struct +{ uint8_t *p_LldBleCmdRspBuffer; uint8_t *p_LldBleM0CmdBuffer; } TL_LLD_BLE_Config_t; -typedef struct { - uint8_t *p_Mac_802_15_4_CmdRspBuffer; - uint8_t *p_Mac_802_15_4_NotAckBuffer; -} TL_MAC_802_15_4_Config_t; - -typedef struct { - uint8_t *p_ZigbeeOtCmdRspBuffer; - uint8_t *p_ZigbeeNotAckBuffer; - uint8_t *p_ZigbeeNotifRequestBuffer; -} TL_ZIGBEE_Config_t; - /** * @brief Contain the BLE HCI Init Configuration * @{ */ -typedef struct { - void (* IoBusEvtCallBack)(TL_EvtPacket_t *phcievt); - void (* IoBusAclDataTxAck)(void); +typedef struct +{ + void (* IoBusEvtCallBack) ( TL_EvtPacket_t *phcievt ); + void (* IoBusAclDataTxAck) ( void ); uint8_t *p_cmdbuffer; uint8_t *p_AclDataBuffer; } TL_BLE_InitConf_t; @@ -209,9 +215,10 @@ typedef struct { * @brief Contain the SYSTEM HCI Init Configuration * @{ */ -typedef struct { - void (* IoBusCallBackCmdEvt)(TL_EvtPacket_t *phcievt); - void (* IoBusCallBackUserEvt)(TL_EvtPacket_t *phcievt); +typedef struct +{ + void (* IoBusCallBackCmdEvt) (TL_EvtPacket_t *phcievt); + void (* IoBusCallBackUserEvt) (TL_EvtPacket_t *phcievt); uint8_t *p_cmdbuffer; } TL_SYS_InitConf_t; @@ -223,67 +230,67 @@ typedef struct { /****************************************************************************** * GENERAL ******************************************************************************/ -void TL_Enable(void); -void TL_Init(void); +void TL_Enable( void ); +void TL_Init( void ); /****************************************************************************** * BLE ******************************************************************************/ -int32_t TL_BLE_Init(void *pConf); -int32_t TL_BLE_SendCmd(uint8_t *buffer, uint16_t size); -int32_t TL_BLE_SendAclData(uint8_t *buffer, uint16_t size); +int32_t TL_BLE_Init( void* pConf ); +int32_t TL_BLE_SendCmd( uint8_t* buffer, uint16_t size ); +int32_t TL_BLE_SendAclData( uint8_t* buffer, uint16_t size ); /****************************************************************************** * SYSTEM ******************************************************************************/ -int32_t TL_SYS_Init(void *pConf); -int32_t TL_SYS_SendCmd(uint8_t *buffer, uint16_t size); +int32_t TL_SYS_Init( void* pConf ); +int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size ); /****************************************************************************** * THREAD ******************************************************************************/ -void TL_THREAD_Init(TL_TH_Config_t *p_Config); -void TL_OT_SendCmd(void); -void TL_CLI_SendCmd(void); -void TL_OT_CmdEvtReceived(TL_EvtPacket_t *Otbuffer); -void TL_THREAD_NotReceived(TL_EvtPacket_t *Notbuffer); -void TL_THREAD_SendAck(void); -void TL_THREAD_CliSendAck(void); -void TL_THREAD_CliNotReceived(TL_EvtPacket_t *Notbuffer); +void TL_THREAD_Init( TL_TH_Config_t *p_Config ); +void TL_OT_SendCmd( void ); +void TL_CLI_SendCmd( void ); +void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ); +void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer ); +void TL_THREAD_SendAck ( void ); +void TL_THREAD_CliSendAck ( void ); +void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer ); /****************************************************************************** * LLD TESTS ******************************************************************************/ -void TL_LLDTESTS_Init(TL_LLD_tests_Config_t *p_Config); -void TL_LLDTESTS_SendCliCmd(void); -void TL_LLDTESTS_ReceiveCliRsp(TL_CmdPacket_t *Notbuffer); -void TL_LLDTESTS_SendCliRspAck(void); -void TL_LLDTESTS_ReceiveM0Cmd(TL_CmdPacket_t *Notbuffer); -void TL_LLDTESTS_SendM0CmdAck(void); +void TL_LLDTESTS_Init( TL_LLD_tests_Config_t *p_Config ); +void TL_LLDTESTS_SendCliCmd( void ); +void TL_LLDTESTS_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ); +void TL_LLDTESTS_SendCliRspAck( void ); +void TL_LLDTESTS_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ); +void TL_LLDTESTS_SendM0CmdAck( void ); /****************************************************************************** * LLD BLE ******************************************************************************/ -void TL_LLD_BLE_Init(TL_LLD_BLE_Config_t *p_Config); -void TL_LLD_BLE_SendCliCmd(void); -void TL_LLD_BLE_ReceiveCliRsp(TL_CmdPacket_t *Notbuffer); -void TL_LLD_BLE_SendCliRspAck(void); -void TL_LLD_BLE_ReceiveM0Cmd(TL_CmdPacket_t *Notbuffer); -void TL_LLD_BLE_SendM0CmdAck(void); -void TL_LLD_BLE_SendCmd(void); -void TL_LLD_BLE_ReceiveRsp(TL_CmdPacket_t *Notbuffer); -void TL_LLD_BLE_SendRspAck(void); +void TL_LLD_BLE_Init( TL_LLD_BLE_Config_t *p_Config ); +void TL_LLD_BLE_SendCliCmd( void ); +void TL_LLD_BLE_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ); +void TL_LLD_BLE_SendCliRspAck( void ); +void TL_LLD_BLE_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ); +void TL_LLD_BLE_SendM0CmdAck( void ); +void TL_LLD_BLE_SendCmd( void ); +void TL_LLD_BLE_ReceiveRsp( TL_CmdPacket_t * Notbuffer ); +void TL_LLD_BLE_SendRspAck( void ); /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ -void TL_MM_Init(TL_MM_Config_t *p_Config); -void TL_MM_EvtDone(TL_EvtPacket_t *hcievt); +void TL_MM_Init( TL_MM_Config_t *p_Config ); +void TL_MM_EvtDone( TL_EvtPacket_t * hcievt ); /****************************************************************************** * TRACES ******************************************************************************/ -void TL_TRACES_Init(void); -void TL_TRACES_EvtReceived(TL_EvtPacket_t *hcievt); +void TL_TRACES_Init( void ); +void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ); #ifdef __cplusplus } /* extern "C" */ diff --git a/src/utility/STM32Cube_FW/tl_mbox.c b/src/utility/STM32Cube_FW/tl_mbox.c index a235493d..8b579d5b 100644 --- a/src/utility/STM32Cube_FW/tl_mbox.c +++ b/src/utility/STM32Cube_FW/tl_mbox.c @@ -31,14 +31,14 @@ * 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" +#include "app_conf.h" +#include "dbg_trace.h" #endif #if (TL_MM_DBG_EN != 0) - #define TL_MM_DBG__MSG PRINT_MESG_DBG +#define TL_MM_DBG__MSG PRINT_MESG_DBG #else - #define TL_MM_DBG__MSG(...) +#define TL_MM_DBG__MSG(...) #endif /* Private typedef -----------------------------------------------------------*/ @@ -66,23 +66,23 @@ PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static tListNode SystemEvtQueue; static tListNode LocalFreeBufQueue; -static void (* BLE_IoBusEvtCallBackFunction)(TL_EvtPacket_t *phcievt); -static void (* BLE_IoBusAclDataTxAck)(void); -static void (* SYS_CMD_IoBusCallBackFunction)(TL_EvtPacket_t *phcievt); -static void (* SYS_EVT_IoBusCallBackFunction)(TL_EvtPacket_t *phcievt); +static void (* BLE_IoBusEvtCallBackFunction) (TL_EvtPacket_t *phcievt); +static void (* BLE_IoBusAclDataTxAck) ( void ); +static void (* SYS_CMD_IoBusCallBackFunction) (TL_EvtPacket_t *phcievt); +static void (* SYS_EVT_IoBusCallBackFunction) (TL_EvtPacket_t *phcievt); /* Global variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ -static void SendFreeBuf(void); -static void OutputMemReleaseTrace(TL_EvtPacket_t *phcievt); +static void SendFreeBuf( void ); +static void OutputMemReleaseTrace(TL_EvtPacket_t * phcievt); /* Public Functions Definition ------------------------------------------------------*/ /****************************************************************************** * GENERAL ******************************************************************************/ -void TL_Enable(void) +void TL_Enable( void ) { HW_IPCC_Enable(); @@ -90,7 +90,7 @@ void TL_Enable(void) } -void TL_Init(void) +void TL_Init( void ) { TL_RefTable.p_device_info_table = &TL_DeviceInfoTable; TL_RefTable.p_ble_table = &TL_BleTable; @@ -100,7 +100,6 @@ void TL_Init(void) TL_RefTable.p_sys_table = &TL_SysTable; TL_RefTable.p_mem_manager_table = &TL_MemManagerTable; TL_RefTable.p_traces_table = &TL_TracesTable; - HW_IPCC_Init(); return; @@ -109,20 +108,20 @@ void TL_Init(void) /****************************************************************************** * BLE ******************************************************************************/ -int32_t TL_BLE_Init(void *pConf) +int32_t TL_BLE_Init( void* pConf ) { - MB_BleTable_t *p_bletable; + MB_BleTable_t * p_bletable; TL_BLE_InitConf_t *pInitHciConf = (TL_BLE_InitConf_t *) pConf; - LST_init_head(&EvtQueue); + LST_init_head (&EvtQueue); p_bletable = TL_RefTable.p_ble_table; p_bletable->pcmd_buffer = pInitHciConf->p_cmdbuffer; p_bletable->phci_acl_data_buffer = pInitHciConf->p_AclDataBuffer; - p_bletable->pcs_buffer = (uint8_t *)CsBuffer; - p_bletable->pevt_queue = (uint8_t *)&EvtQueue; + p_bletable->pcs_buffer = (uint8_t*)CsBuffer; + p_bletable->pevt_queue = (uint8_t*)&EvtQueue; HW_IPCC_BLE_Init(); @@ -132,12 +131,12 @@ int32_t TL_BLE_Init(void *pConf) return 0; } -int32_t TL_BLE_SendCmd(uint8_t *buffer, uint16_t size) +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; + ((TL_CmdPacket_t*)(TL_RefTable.p_ble_table->pcmd_buffer))->cmdserial.type = TL_BLECMD_PKT_TYPE; HW_IPCC_BLE_SendCmd(); @@ -148,8 +147,9 @@ void HW_IPCC_BLE_RxEvtNot(void) { TL_EvtPacket_t *phcievt; - while (LST_is_empty(&EvtQueue) == FALSE) { - LST_remove_head(&EvtQueue, (tListNode **)&phcievt); + while(LST_is_empty(&EvtQueue) == FALSE) + { + LST_remove_head (&EvtQueue, (tListNode **)&phcievt); BLE_IoBusEvtCallBackFunction(phcievt); } @@ -157,7 +157,7 @@ void HW_IPCC_BLE_RxEvtNot(void) return; } -int32_t TL_BLE_SendAclData(uint8_t *buffer, uint16_t size) +int32_t TL_BLE_SendAclData( uint8_t* buffer, uint16_t size ) { (void)(buffer); (void)(size); @@ -171,7 +171,7 @@ int32_t TL_BLE_SendAclData(uint8_t *buffer, uint16_t size) void HW_IPCC_BLE_AclDataAckNot(void) { - BLE_IoBusAclDataTxAck(); + BLE_IoBusAclDataTxAck( ); return; } @@ -179,16 +179,16 @@ void HW_IPCC_BLE_AclDataAckNot(void) /****************************************************************************** * SYSTEM ******************************************************************************/ -int32_t TL_SYS_Init(void *pConf) +int32_t TL_SYS_Init( void* pConf ) { - MB_SysTable_t *p_systable; + MB_SysTable_t * p_systable; TL_SYS_InitConf_t *pInitHciConf = (TL_SYS_InitConf_t *) pConf; - LST_init_head(&SystemEvtQueue); + LST_init_head (&SystemEvtQueue); p_systable = TL_RefTable.p_sys_table; p_systable->pcmd_buffer = pInitHciConf->p_cmdbuffer; - p_systable->sys_queue = (uint8_t *)&SystemEvtQueue; + p_systable->sys_queue = (uint8_t*)&SystemEvtQueue; HW_IPCC_SYS_Init(); @@ -198,7 +198,7 @@ int32_t TL_SYS_Init(void *pConf) return 0; } -int32_t TL_SYS_SendCmd(uint8_t *buffer, uint16_t size) +int32_t TL_SYS_SendCmd( uint8_t* buffer, uint16_t size ) { (void)(buffer); (void)(size); @@ -212,18 +212,19 @@ int32_t TL_SYS_SendCmd(uint8_t *buffer, uint16_t size) void HW_IPCC_SYS_CmdEvtNot(void) { - SYS_CMD_IoBusCallBackFunction((TL_EvtPacket_t *)(TL_RefTable.p_sys_table->pcmd_buffer)); + SYS_CMD_IoBusCallBackFunction( (TL_EvtPacket_t*)(TL_RefTable.p_sys_table->pcmd_buffer) ); return; } -void HW_IPCC_SYS_EvtNot(void) +void HW_IPCC_SYS_EvtNot( void ) { TL_EvtPacket_t *p_evt; - while (LST_is_empty(&SystemEvtQueue) == FALSE) { - LST_remove_head(&SystemEvtQueue, (tListNode **)&p_evt); - SYS_EVT_IoBusCallBackFunction(p_evt); + while(LST_is_empty(&SystemEvtQueue) == FALSE) + { + LST_remove_head (&SystemEvtQueue, (tListNode **)&p_evt); + SYS_EVT_IoBusCallBackFunction( p_evt ); } return; @@ -233,9 +234,9 @@ void HW_IPCC_SYS_EvtNot(void) * THREAD ******************************************************************************/ #ifdef THREAD_WB -void TL_THREAD_Init(TL_TH_Config_t *p_Config) +void TL_THREAD_Init( TL_TH_Config_t *p_Config ) { - MB_ThreadTable_t *p_thread_table; + MB_ThreadTable_t * p_thread_table; p_thread_table = TL_RefTable.p_thread_table; @@ -248,7 +249,7 @@ void TL_THREAD_Init(TL_TH_Config_t *p_Config) return; } -void TL_OT_SendCmd(void) +void TL_OT_SendCmd( void ) { ((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->otcmdrsp_buffer))->cmdserial.type = TL_OTCMD_PKT_TYPE; @@ -257,7 +258,7 @@ void TL_OT_SendCmd(void) return; } -void TL_CLI_SendCmd(void) +void TL_CLI_SendCmd( void ) { ((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->clicmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; @@ -266,7 +267,7 @@ void TL_CLI_SendCmd(void) return; } -void TL_THREAD_SendAck(void) +void TL_THREAD_SendAck ( void ) { ((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; @@ -275,7 +276,7 @@ void TL_THREAD_SendAck(void) return; } -void TL_THREAD_CliSendAck(void) +void TL_THREAD_CliSendAck ( void ) { ((TL_CmdPacket_t *)(TL_RefTable.p_thread_table->notack_buffer))->cmdserial.type = TL_OTACK_PKT_TYPE; @@ -286,28 +287,28 @@ void TL_THREAD_CliSendAck(void) void HW_IPCC_OT_CmdEvtNot(void) { - TL_OT_CmdEvtReceived((TL_EvtPacket_t *)(TL_RefTable.p_thread_table->otcmdrsp_buffer)); + TL_OT_CmdEvtReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->otcmdrsp_buffer) ); return; } -void HW_IPCC_THREAD_EvtNot(void) +void HW_IPCC_THREAD_EvtNot( void ) { - TL_THREAD_NotReceived((TL_EvtPacket_t *)(TL_RefTable.p_thread_table->notack_buffer)); + TL_THREAD_NotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->notack_buffer) ); return; } -void HW_IPCC_THREAD_CliEvtNot(void) +void HW_IPCC_THREAD_CliEvtNot( void ) { - TL_THREAD_CliNotReceived((TL_EvtPacket_t *)(TL_RefTable.p_thread_table->clicmdrsp_buffer)); + TL_THREAD_CliNotReceived( (TL_EvtPacket_t*)(TL_RefTable.p_thread_table->clicmdrsp_buffer) ); return; } -__WEAK void TL_OT_CmdEvtReceived(TL_EvtPacket_t *Otbuffer) {}; -__WEAK void TL_THREAD_NotReceived(TL_EvtPacket_t *Notbuffer) {}; -__WEAK void TL_THREAD_CliNotReceived(TL_EvtPacket_t *Notbuffer) {}; +__WEAK void TL_OT_CmdEvtReceived( TL_EvtPacket_t * Otbuffer ){}; +__WEAK void TL_THREAD_NotReceived( TL_EvtPacket_t * Notbuffer ){}; +__WEAK void TL_THREAD_CliNotReceived( TL_EvtPacket_t * Notbuffer ){}; #endif /* THREAD_WB */ @@ -315,9 +316,9 @@ __WEAK void TL_THREAD_CliNotReceived(TL_EvtPacket_t *Notbuffer) {}; * LLD TESTS ******************************************************************************/ #ifdef LLD_TESTS_WB -void TL_LLDTESTS_Init(TL_LLD_tests_Config_t *p_Config) +void TL_LLDTESTS_Init( TL_LLD_tests_Config_t *p_Config ) { - MB_LldTestsTable_t *p_lld_tests_table; + MB_LldTestsTable_t * p_lld_tests_table; p_lld_tests_table = TL_RefTable.p_lld_tests_table; p_lld_tests_table->clicmdrsp_buffer = p_Config->p_LldTestsCliCmdRspBuffer; @@ -326,49 +327,49 @@ void TL_LLDTESTS_Init(TL_LLD_tests_Config_t *p_Config) return; } -void TL_LLDTESTS_SendCliCmd(void) +void TL_LLDTESTS_SendCliCmd( void ) { ((TL_CmdPacket_t *)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer))->cmdserial.type = TL_CLICMD_PKT_TYPE; HW_IPCC_LLDTESTS_SendCliCmd(); return; } -void HW_IPCC_LLDTESTS_ReceiveCliRsp(void) +void HW_IPCC_LLDTESTS_ReceiveCliRsp( void ) { - TL_LLDTESTS_ReceiveCliRsp((TL_CmdPacket_t *)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer)); + TL_LLDTESTS_ReceiveCliRsp( (TL_CmdPacket_t*)(TL_RefTable.p_lld_tests_table->clicmdrsp_buffer) ); return; } -void TL_LLDTESTS_SendCliRspAck(void) +void TL_LLDTESTS_SendCliRspAck( void ) { HW_IPCC_LLDTESTS_SendCliRspAck(); return; } -void HW_IPCC_LLDTESTS_ReceiveM0Cmd(void) +void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void ) { - TL_LLDTESTS_ReceiveM0Cmd((TL_CmdPacket_t *)(TL_RefTable.p_lld_tests_table->m0cmd_buffer)); + TL_LLDTESTS_ReceiveM0Cmd( (TL_CmdPacket_t*)(TL_RefTable.p_lld_tests_table->m0cmd_buffer) ); return; } -void TL_LLDTESTS_SendM0CmdAck(void) +void TL_LLDTESTS_SendM0CmdAck( void ) { HW_IPCC_LLDTESTS_SendM0CmdAck(); return; } -__WEAK void TL_LLDTESTS_ReceiveCliRsp(TL_CmdPacket_t *Notbuffer) {}; -__WEAK void TL_LLDTESTS_ReceiveM0Cmd(TL_CmdPacket_t *Notbuffer) {}; +__WEAK void TL_LLDTESTS_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ){}; +__WEAK void TL_LLDTESTS_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ){}; #endif /* LLD_TESTS_WB */ /****************************************************************************** * LLD BLE ******************************************************************************/ -#ifdef LLD_BLE_WB -void TL_LLD_BLE_Init(TL_LLD_BLE_Config_t *p_Config) +#ifdef LLD_BLE_WB +void TL_LLD_BLE_Init( TL_LLD_BLE_Config_t *p_Config ) { - MB_LldBleTable_t *p_lld_ble_table; + 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; @@ -377,56 +378,56 @@ void TL_LLD_BLE_Init(TL_LLD_BLE_Config_t *p_Config) return; } -void TL_LLD_BLE_SendCliCmd(void) +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) +void HW_IPCC_LLD_BLE_ReceiveCliRsp( void ) { - TL_LLD_BLE_ReceiveCliRsp((TL_CmdPacket_t *)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer)); + TL_LLD_BLE_ReceiveCliRsp( (TL_CmdPacket_t*)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer) ); return; } -void TL_LLD_BLE_SendCliRspAck(void) +void TL_LLD_BLE_SendCliRspAck( void ) { HW_IPCC_LLD_BLE_SendCliRspAck(); return; } -void HW_IPCC_LLD_BLE_ReceiveM0Cmd(void) +void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ) { - TL_LLD_BLE_ReceiveM0Cmd((TL_CmdPacket_t *)(TL_RefTable.p_lld_ble_table->m0cmd_buffer)); + TL_LLD_BLE_ReceiveM0Cmd( (TL_CmdPacket_t*)(TL_RefTable.p_lld_ble_table->m0cmd_buffer) ); return; } -void TL_LLD_BLE_SendM0CmdAck(void) +void TL_LLD_BLE_SendM0CmdAck( void ) { HW_IPCC_LLD_BLE_SendM0CmdAck(); return; } -__WEAK void TL_LLD_BLE_ReceiveCliRsp(TL_CmdPacket_t *Notbuffer) {}; -__WEAK void TL_LLD_BLE_ReceiveM0Cmd(TL_CmdPacket_t *Notbuffer) {}; +__WEAK void TL_LLD_BLE_ReceiveCliRsp( TL_CmdPacket_t * Notbuffer ){}; +__WEAK void TL_LLD_BLE_ReceiveM0Cmd( TL_CmdPacket_t * Notbuffer ){}; /* Transparent Mode */ -void TL_LLD_BLE_SendCmd(void) +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) +void HW_IPCC_LLD_BLE_ReceiveRsp( void ) { - TL_LLD_BLE_ReceiveRsp((TL_CmdPacket_t *)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer)); + TL_LLD_BLE_ReceiveRsp( (TL_CmdPacket_t*)(TL_RefTable.p_lld_ble_table->cmdrsp_buffer) ); return; } -void TL_LLD_BLE_SendRspAck(void) +void TL_LLD_BLE_SendRspAck( void ) { HW_IPCC_LLD_BLE_SendRspAck(); return; @@ -436,18 +437,18 @@ void TL_LLD_BLE_SendRspAck(void) /****************************************************************************** * MEMORY MANAGER ******************************************************************************/ -void TL_MM_Init(TL_MM_Config_t *p_Config) +void TL_MM_Init( TL_MM_Config_t *p_Config ) { - static MB_MemManagerTable_t *p_mem_manager_table; + static MB_MemManagerTable_t * p_mem_manager_table; - LST_init_head(&FreeBufQueue); - LST_init_head(&LocalFreeBufQueue); + LST_init_head (&FreeBufQueue); + LST_init_head (&LocalFreeBufQueue); p_mem_manager_table = TL_RefTable.p_mem_manager_table; p_mem_manager_table->blepool = p_Config->p_AsynchEvtPool; p_mem_manager_table->blepoolsize = p_Config->AsynchEvtPoolSize; - p_mem_manager_table->pevt_free_buffer_queue = (uint8_t *)&FreeBufQueue; + p_mem_manager_table->pevt_free_buffer_queue = (uint8_t*)&FreeBufQueue; p_mem_manager_table->spare_ble_buffer = p_Config->p_BleSpareEvtBuffer; p_mem_manager_table->spare_sys_buffer = p_Config->p_SystemSpareEvtBuffer; p_mem_manager_table->traces_evt_pool = p_Config->p_TracesEvtPool; @@ -456,47 +457,49 @@ void TL_MM_Init(TL_MM_Config_t *p_Config) return; } -void TL_MM_EvtDone(TL_EvtPacket_t *phcievt) +void TL_MM_EvtDone(TL_EvtPacket_t * phcievt) { LST_insert_tail(&LocalFreeBufQueue, (tListNode *)phcievt); OutputMemReleaseTrace(phcievt); - HW_IPCC_MM_SendFreeBuf(SendFreeBuf); + HW_IPCC_MM_SendFreeBuf( SendFreeBuf ); return; } -static void SendFreeBuf(void) +static void SendFreeBuf( void ) { tListNode *p_node; - while (FALSE == LST_is_empty(&LocalFreeBufQueue)) { - LST_remove_head(&LocalFreeBufQueue, (tListNode **)&p_node); - LST_insert_tail((tListNode *)(TL_RefTable.p_mem_manager_table->pevt_free_buffer_queue), p_node); + while ( FALSE == LST_is_empty (&LocalFreeBufQueue) ) + { + LST_remove_head( &LocalFreeBufQueue, (tListNode **)&p_node ); + LST_insert_tail( (tListNode*)(TL_RefTable.p_mem_manager_table->pevt_free_buffer_queue), p_node ); } return; } -static void OutputMemReleaseTrace(TL_EvtPacket_t *phcievt) +static void OutputMemReleaseTrace(TL_EvtPacket_t * phcievt) { - switch (phcievt->evtserial.evt.evtcode) { + 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(" 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(" 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(" subevtcode: 0x%04X", ((TL_AsynchEvt_t*)(phcievt->evtserial.evt.payload))->subevtcode); TL_MM_DBG__MSG(" buffer addr: 0x%08X", phcievt); break; @@ -514,11 +517,11 @@ static void OutputMemReleaseTrace(TL_EvtPacket_t *phcievt) /****************************************************************************** * TRACES ******************************************************************************/ -void TL_TRACES_Init(void) +void TL_TRACES_Init( void ) { - LST_init_head(&TracesEvtQueue); + LST_init_head (&TracesEvtQueue); - TL_RefTable.p_traces_table->traces_queue = (uint8_t *)&TracesEvtQueue; + TL_RefTable.p_traces_table->traces_queue = (uint8_t*)&TracesEvtQueue; HW_IPCC_TRACES_Init(); @@ -529,17 +532,19 @@ void HW_IPCC_TRACES_EvtNot(void) { TL_EvtPacket_t *phcievt; - while (LST_is_empty(&TracesEvtQueue) == FALSE) { - LST_remove_head(&TracesEvtQueue, (tListNode **)&phcievt); - TL_TRACES_EvtReceived(phcievt); + while(LST_is_empty(&TracesEvtQueue) == FALSE) + { + LST_remove_head (&TracesEvtQueue, (tListNode **)&phcievt); + TL_TRACES_EvtReceived( phcievt ); } return; } -__WEAK void TL_TRACES_EvtReceived(TL_EvtPacket_t *hcievt) +__WEAK void TL_TRACES_EvtReceived( TL_EvtPacket_t * hcievt ) { (void)(hcievt); } + #endif /* STM32WBxx */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/