diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 32212fc22..ff3a2cc72 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -7,6 +7,8 @@ if(CONFIG_HAS_STM32LIB) add_subdirectory_ifdef(CONFIG_BT_STM32_IPM stm32wb) - add_subdirectory_ifdef(CONFIG_BT_STM32WBA stm32wba) + if(CONFIG_BT_STM32WBA OR CONFIG_IEEE802154_STM32WBA) + add_subdirectory(stm32wba) + endif() add_subdirectory_ifdef(CONFIG_BT_STM32WB0 stm32wb0) endif() diff --git a/lib/README.rst b/lib/README.rst index 865f1c77f..5389e4230 100644 --- a/lib/README.rst +++ b/lib/README.rst @@ -8,4 +8,4 @@ Available libraries: * stm32wb0: STM32WB0 BLE controller interfacing library. * stm32wba: - STM32WBA BLE controller interfacing library. + STM32WBA BLE and 802.15.4 controller interfacing libraries. diff --git a/lib/stm32wba/CMakeLists.txt b/lib/stm32wba/CMakeLists.txt index 71d1367ac..e73e66172 100644 --- a/lib/stm32wba/CMakeLists.txt +++ b/lib/stm32wba/CMakeLists.txt @@ -1,41 +1,23 @@ -# Copyright (c) 2024 STMicroelectronics +# Copyright (c) 2025 STMicroelectronics # # SPDX-License-Identifier: Apache-2.0 - -zephyr_compile_definitions( -DBLE ) - -zephyr_include_directories(BLE_TransparentMode/Core/Inc) -zephyr_include_directories(BLE_TransparentMode/STM32_WPAN/Target) -zephyr_include_directories(BLE_TransparentMode/System/Config/Debug_GPIO) -zephyr_include_directories(BLE_TransparentMode/System/Config/Log) zephyr_include_directories(Common/WPAN/Interfaces) zephyr_include_directories(Common/WPAN/Modules) zephyr_include_directories(Common/WPAN/Modules/Flash) zephyr_include_directories(Common/WPAN/Modules/RTDebug) zephyr_include_directories(Common/WPAN/Modules/Log) -zephyr_include_directories(STM32_WPAN) -zephyr_include_directories(STM32_WPAN/ble/stack/include) -zephyr_include_directories(STM32_WPAN/ble/stack/include/auto) -zephyr_include_directories(STM32_WPAN/link_layer/ll_cmd_lib/config/ble_full) -zephyr_include_directories(STM32_WPAN/link_layer/ll_cmd_lib/inc) -zephyr_include_directories(STM32_WPAN/link_layer/ll_cmd_lib/inc/_40nm_reg_files) -zephyr_include_directories(STM32_WPAN/link_layer/ll_sys/inc) +if(CONFIG_IEEE802154_STM32WBA) + zephyr_include_directories(Common/WPAN/Modules/BasicAES) +endif() zephyr_include_directories(Utilities/misc) zephyr_include_directories(Utilities/tim_serv) zephyr_include_directories(Utilities/trace/adv_trace) +zephyr_include_directories(STM32_WPAN) -zephyr_sources(BLE_TransparentMode/STM32_WPAN/Target/bpka.c) -zephyr_sources(BLE_TransparentMode/STM32_WPAN/Target/linklayer_plat.c) -zephyr_sources(BLE_TransparentMode/STM32_WPAN/Target/ll_sys_if.c) -zephyr_sources(BLE_TransparentMode/STM32_WPAN/Target/power_table.c) zephyr_sources(Common/WPAN/Modules/Log/log_module.c) zephyr_sources(Common/WPAN/Interfaces/hw_pka.c) zephyr_sources(Common/WPAN/Interfaces/hw_pka_p256.c) zephyr_sources(Common/WPAN/Modules/RTDebug/RTDebug.c) -zephyr_sources(STM32_WPAN/link_layer/ll_sys/src/ll_sys_cs.c) -zephyr_sources(STM32_WPAN/link_layer/ll_sys/src/ll_sys_dp_slp.c) -zephyr_sources(STM32_WPAN/link_layer/ll_sys/src/ll_sys_intf.c) -zephyr_sources(STM32_WPAN/link_layer/ll_sys/src/ll_sys_startup.c) if(CONFIG_FLASH) zephyr_sources(Common/WPAN/Modules/Flash/flash_manager.c) @@ -44,77 +26,105 @@ if(CONFIG_FLASH) zephyr_sources(Common/WPAN/Modules/Flash/rf_timing_synchro.c) endif() -if (CONFIG_BT_EXT_ADV - OR (CONFIG_BT_PER_ADV OR CONFIG_BT_PER_ADV_SYNC) - OR CONFIG_BT_SCA_UPDATE - OR (CONFIG_BT_DF_CTE_RX_AOA OR CONFIG_BT_CTLR_DF_ANT_SWITCH_RX OR CONFIG_BT_CTLR_DF_ANT_SWITCH_TX OR CONFIG_BT_DF_CTE_TX_AOD) - OR (CONFIG_BT_PER_ADV_SYNC_TRANSFER_RECEIVER OR CONFIG_BT_PER_ADV_SYNC_TRANSFER_SENDER OR CONFIG_BT_CTLR_SYNC_PERIODIC) - OR CONFIG_BT_ISO_UNICAST - OR CONFIG_BT_ISO_BROADCASTER - OR CONFIG_BT_ISO_SYNC_RECEIVER - OR CONFIG_BT_TRANSMIT_POWER_CONTROL - OR CONFIG_BT_SUBRATING - OR CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT - OR CONFIG_BT_EXT_ADV_CODING_SELECTION) - message(STATUS "link layer FULL lib selected") - set(BLE_LIB_TYPE "BLE_LIB_FULL") -else() - message(STATUS "link layer BASIC lib selected") - set(BLE_LIB_TYPE "BLE_LIB_BASIC") +if(CONFIG_IEEE802154_STM32WBA) + zephyr_sources(Common/WPAN/Modules/BasicAES/baes_ccm.c) + zephyr_sources(Common/WPAN/Modules/BasicAES/baes_cmac.c) + zephyr_sources(Common/WPAN/Modules/BasicAES/baes_ecb.c) endif() - -set(STM32WBA_BLE_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../zephyr/blobs/stm32wba/lib) -set(STM32WBA_BLE_LIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/STM32_WPAN/ble/stack) -set(STM32WBA_LL_LIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/STM32_WPAN/link_layer/ll_cmd_lib) - -add_library(stm32wba_ble_lib STATIC IMPORTED GLOBAL) -add_library(stm32wba_ll_lib STATIC IMPORTED GLOBAL) - -add_dependencies( - stm32wba_ble_lib - stm32wba_ll_lib -) -if (BLE_LIB_TYPE STREQUAL "BLE_LIB_BASIC") - set_target_properties( - stm32wba_ble_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_BLE_LIB_DIR}/stm32wba_ble_stack_llobasic.a - ) -elseif (BLE_LIB_TYPE STREQUAL "BLE_LIB_FULL") - set_target_properties( - stm32wba_ble_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_BLE_LIB_DIR}/stm32wba_ble_stack_llo.a +set(STM32WBA_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../zephyr/blobs/stm32wba/lib) + +# select the type of BLE library +if(CONFIG_BT_STM32WBA) + if(CONFIG_BT_EXT_ADV + OR (CONFIG_BT_PER_ADV OR CONFIG_BT_PER_ADV_SYNC) + OR CONFIG_BT_SCA_UPDATE + OR (CONFIG_BT_DF_CTE_RX_AOA OR CONFIG_BT_CTLR_DF_ANT_SWITCH_RX OR CONFIG_BT_CTLR_DF_ANT_SWITCH_TX OR CONFIG_BT_DF_CTE_TX_AOD) + OR (CONFIG_BT_PER_ADV_SYNC_TRANSFER_RECEIVER OR CONFIG_BT_PER_ADV_SYNC_TRANSFER_SENDER OR CONFIG_BT_CTLR_SYNC_PERIODIC) + OR CONFIG_BT_ISO_UNICAST + OR CONFIG_BT_ISO_BROADCASTER + OR CONFIG_BT_ISO_SYNC_RECEIVER + OR CONFIG_BT_TRANSMIT_POWER_CONTROL + OR CONFIG_BT_SUBRATING + OR CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT + OR CONFIG_BT_EXT_ADV_CODING_SELECTION) + message(STATUS "link layer FULL lib selected") + set(BLE_LIB_TYPE "BLE_LIB_FULL") + else() + message(STATUS "link layer BASIC lib selected") + set(BLE_LIB_TYPE "BLE_LIB_BASIC") + endif() + + set(STM32WBA_BLE_LIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/STM32_WPAN/ble/stack) + + add_library(stm32wba_ble_lib STATIC IMPORTED GLOBAL) + + add_dependencies( + stm32wba_ble_lib + stm32wba_ll_lib ) -endif() + if(BLE_LIB_TYPE STREQUAL "BLE_LIB_BASIC") + set_target_properties( + stm32wba_ble_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_LIB_DIR}/stm32wba_ble_stack_llobasic.a + ) + elseif(BLE_LIB_TYPE STREQUAL "BLE_LIB_FULL") + set_target_properties( + stm32wba_ble_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_LIB_DIR}/stm32wba_ble_stack_llo.a + ) + endif() + + # Setting the right Cube define according to the Zephyr configuration + if(NOT CONFIG_BT_STM32WBA_USE_TEMP_BASED_CALIB) + zephyr_compile_definitions( -DUSE_TEMPERATURE_BASED_RADIO_CALIBRATION=0 ) + endif() -# Setting the right Cube define according to the Zephyr configuration -if(NOT CONFIG_BT_STM32WBA_USE_TEMP_BASED_CALIB) - zephyr_compile_definitions( -DUSE_TEMPERATURE_BASED_RADIO_CALIBRATION=0 ) + # Using the selected version of ble lib + set_target_properties(stm32wba_ble_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_BLE_LIB_INCLUDE_DIR}) + + target_link_libraries(app PUBLIC stm32wba_ble_lib) endif() -# Selecting the proper version of link layer lib according the soc -# Checking all the soc variants and not simply relying on board name +# Selecting the proper version of link layer lib +if(CONFIG_BT_STM32WBA) + # Checking all the soc variants and not simply relying on board name + if(CONFIG_SOC_STM32WBA65XX) + message(STATUS "STM32WBA6 link layer lib selected") + if (BLE_LIB_TYPE STREQUAL "BLE_LIB_BASIC") + set(LL_LIB "WBA6_LinkLayer_BLE_Basic_lib.a") + elseif (BLE_LIB_TYPE STREQUAL "BLE_LIB_FULL") + set(LL_LIB "WBA6_LinkLayer_BLE_Full_lib.a") + endif() + endif() -if(CONFIG_SOC_STM32WBA65XX) - message(STATUS "STM32WBA6 link layer lib selected") - if (BLE_LIB_TYPE STREQUAL "BLE_LIB_BASIC") - set(LL_LIB "WBA6_LinkLayer_BLE_Basic_lib.a") - elseif (BLE_LIB_TYPE STREQUAL "BLE_LIB_FULL") - set(LL_LIB "WBA6_LinkLayer_BLE_Full_lib.a") + if(CONFIG_SOC_STM32WBA55XX OR SOC_STM32WBA52XX) + message(STATUS "STM32WBA5 link layer lib selected") + if (BLE_LIB_TYPE STREQUAL "BLE_LIB_BASIC") + set(LL_LIB "LinkLayer_BLE_Basic_lib.a") + elseif (BLE_LIB_TYPE STREQUAL "BLE_LIB_FULL") + set(LL_LIB "LinkLayer_BLE_Full_lib.a") + endif() + endif() +elseif(CONFIG_IEEE802154_STM32WBA) + if(CONFIG_SOC_STM32WBA65XX) + if(CONFIG_OPENTHREAD) + message(STATUS "WBA6_LinkLayer_Thread_lib_Zephyr.a lib selected") + set(LL_LIB "WBA6_LinkLayer_Thread_lib_Zephyr.a") + else() + message(STATUS "WBA6_LinkLayer15_4_Zephyr.a lib selected") + set(LL_LIB "WBA6_LinkLayer15_4_Zephyr.a") + endif() endif() endif() -if(CONFIG_SOC_STM32WBA55XX OR SOC_STM32WBA52XX) - message(STATUS "STM32WBA5 link layer lib selected") - if (BLE_LIB_TYPE STREQUAL "BLE_LIB_BASIC") - set(LL_LIB "LinkLayer_BLE_Basic_lib.a") - elseif (BLE_LIB_TYPE STREQUAL "BLE_LIB_FULL") - set(LL_LIB "LinkLayer_BLE_Full_lib.a") - endif() +if(CONFIG_BT_STM32WBA OR CONFIG_IEEE802154_STM32WBA) + add_library(stm32wba_ll_lib STATIC IMPORTED GLOBAL) + set(STM32WBA_LL_LIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/STM32_WPAN/link_layer/ll_cmd_lib) + set_target_properties(stm32wba_ll_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_LIB_DIR}/${LL_LIB}) + set_target_properties(stm32wba_ll_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_LL_LIB_INCLUDE_DIR}) + target_link_libraries(app PUBLIC stm32wba_ll_lib) endif() -# Using the selected version of link layer lib -set_target_properties(stm32wba_ll_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_BLE_LIB_DIR}/${LL_LIB}) -set_target_properties(stm32wba_ble_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_BLE_LIB_INCLUDE_DIR}) -set_target_properties(stm32wba_ll_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_LL_LIB_INCLUDE_DIR}) +add_subdirectory(STM32_WPAN) -target_link_libraries(app PUBLIC stm32wba_ble_lib) -target_link_libraries(app PUBLIC stm32wba_ll_lib) +add_subdirectory_ifdef(CONFIG_BT_STM32WBA ble) +add_subdirectory_ifdef(CONFIG_IEEE802154_STM32WBA IEEE802154) \ No newline at end of file diff --git a/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes.h b/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes.h new file mode 100644 index 000000000..d126478dc --- /dev/null +++ b/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes.h @@ -0,0 +1,73 @@ +/** + ****************************************************************************** + * @file baes.h + * @author MCD Application Team + * @brief This file contains the interface of the basic AES software module. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#ifndef BAES_H__ +#define BAES_H__ + +#include + +/* Basic AES module dedicated to BLE stack with the following features: + * - AES ECB encryption + * - AES CMAC computation + * + * Configuration: the file "app_common.h" is included in this module. + * It must define: + * - CFG_BAES_SW equals to 1 for software implementation + * - CFG_BAES_SW equals to 0 for use of hardware accelerator + * + * Notes: + * - only 128-bit key is supported + * - re-entrance is not supported + */ + +/* General interface */ + +extern void BAES_Reset( void ); + +/* AES ECB interface */ + +extern void BAES_EcbCrypt( const uint8_t* key, + const uint8_t* input, + uint8_t* output, + int enc ); + +/* AES CMAC interface */ + +extern void BAES_CmacSetKey( const uint8_t* key ); + +extern void BAES_CmacSetVector( const uint8_t * pIV ); + +extern void BAES_CmacCompute( const uint8_t* input, + uint32_t size, + uint8_t* output ); + +/* AES CCM interface */ + +extern int BAES_CcmCrypt( uint8_t mode, + const uint8_t* key, + uint8_t iv_length, + const uint8_t* iv, + uint16_t add_length, + const uint8_t* add, + uint16_t input_length, + const uint8_t* input, + uint8_t tag_length, + uint8_t* tag, + uint8_t* output ); + +#endif /* BAES_H__ */ diff --git a/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes_ccm.c b/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes_ccm.c new file mode 100644 index 000000000..df09866ab --- /dev/null +++ b/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes_ccm.c @@ -0,0 +1,120 @@ +/***************************************************************************** + * @file baes_ccm.c + * + * @brief This file contains the AES CCM implementation. + ***************************************************************************** + * @attention + * + * Copyright (c) 2018-2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ***************************************************************************** + */ + +#include "baes_global.h" + +/*****************************************************************************/ + +/* --------------------------------------------------------------------------- + * Byte/word manipulation macro definitions + * --------------------------------------------------------------------------- + */ + +/* Returns the least significant byte from a word */ +#define BYTE0(w) ((uint8_t)((w) >> 0)) + +/* Returns the second least significant byte from a word */ +#define BYTE1(w) ((uint8_t)((w) >> 8)) + +/* Macro to set a 16-bit word into a byte table in big endian */ +#define SET_U16_BE( b, i, v ) M_BEGIN uint16_t v_ = (uint16_t)(v); \ + uint8_t *b_ = &((uint8_t*)(b))[i]; \ + b_[1] = BYTE0(v_); \ + b_[0] = BYTE1(v_); M_END + +int BAES_CcmCrypt( uint8_t mode, + const uint8_t* key, + uint8_t iv_length, + const uint8_t* iv, + uint16_t add_length, + const uint8_t* add, + uint16_t input_length, + const uint8_t* input, + uint8_t tag_length, + uint8_t* tag, + uint8_t* output ) +{ +#if CFG_BAES_SW == 0 + + /* This implementation of AES CCM only supports HW AES and it also only + * supports the following range for input parameters: + * - tag_length: 4..16 (multiple of 2) + * - iv_length: 7..13 + * - add_length: 1..14 + */ + uint32_t left_len, b0[4], bx[4]; + uint8_t len, *b; + + /* Build B0 */ + b = (uint8_t*)b0; + memset( b0, 0, 16 ); + b[0] = (1U << 6) | (((tag_length - 2) / 2) << 3) | (14U - iv_length); + memcpy( b + 1, iv, iv_length ); + SET_U16_BE( b, 14, input_length ); + + /* Build B1 */ + b = (uint8_t*)bx; + memset( bx, 0, 16 ); + b[1] = add_length; + memcpy( b + 2, add, add_length ); + + /* Start CCM process with Init and Header phases */ + HW_AES_Enable( ); + HW_AES_InitCcm( mode, key, b0, bx ); + + /* Continue CCM process with Payload Phase */ + left_len = input_length; + while ( left_len > 0 ) + { + len = 16; + if ( left_len < 16 ) + { + len = (uint8_t)left_len; + memset( bx, 0, 16 ); + + if ( mode ) + HW_AES_SetLast( len ); + } + + memcpy( b, input, len ); + HW_AES_Crypt( bx, bx ); + memcpy( output, b, len ); + input += len; + output += len; + left_len -= len; + } + + /* End CCM process with Final Phase */ + HW_AES_EndCcm( tag_length, mode ? b : tag ); + HW_AES_Disable( ); + + /* Verification of the tag in case of decryption */ + if ( mode ) + { + uint8_t diff = 0; + for ( int i = 0; i < tag_length; i++ ) + diff |= tag[i] ^ b[i]; + + return (int)diff; + } + +#endif /* CFG_BAES_SW == 0 */ + + return 0; +} + +/*****************************************************************************/ diff --git a/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes_cmac.c b/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes_cmac.c new file mode 100644 index 000000000..5a2e31870 --- /dev/null +++ b/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes_cmac.c @@ -0,0 +1,213 @@ +/** + ****************************************************************************** + * @file baes_cmac.c + * @author MCD Application Team + * @brief This file contains the AES CMAC implementation. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#include "baes_global.h" + +/*****************************************************************************/ + +typedef struct +{ + uint32_t iv[4]; /* Temporary result/IV */ + +#if CFG_BAES_SW != 0 + + uint32_t exp_key[44]; /* Expanded AES key */ + +#endif /* CFG_BAES_SW != 0 */ + +} BAES_CMAC_t; + +/*****************************************************************************/ + +BAES_CMAC_t BAES_CMAC_var; + +/*****************************************************************************/ + +/* + * AES key roll for CMAC Mode + * + */ + +static void BAES_CmacKeyRoll( uint32_t* key ) +{ + uint32_t carry = ((key[0] >> 31) & 1) * 0x87UL; + key[0] = (key[0] << 1) | (key[1] >> 31); + key[1] = (key[1] << 1) | (key[2] >> 31); + key[2] = (key[2] << 1) | (key[3] >> 31); + key[3] = (key[3] << 1) ^ carry; +} + +/*****************************************************************************/ + +/* + * AES ECB encryption for CMAC Mode + * + */ + +static void BAES_CmacRawEncrypt( const uint32_t* input, + uint32_t* output ) +{ +#if CFG_BAES_SW == 0 + + HW_AES_Crypt( input, output ); + +#else /* CFG_BAES_SW != 0 */ + + BAES_CMAC_t *av = &BAES_CMAC_var; + + BAES_RawEncrypt( input, output, av->exp_key ); + +#endif /* CFG_BAES_SW != 0 */ +} + +/*****************************************************************************/ + +/* + * Initialization for AES-CMAC for Authentication TAG Generation. + * Must be called each time a new CMAC has to be computed. + */ + +void BAES_CmacSetKey( const uint8_t* key ) +{ + BAES_CMAC_t *av = &BAES_CMAC_var; + + /* Initialize for ECB encoding */ + +#if CFG_BAES_SW == 0 + + HW_AES_Enable( ); + HW_AES_SetKey( HW_AES_ENC, key ); + +#else /* CFG_BAES_SW != 0 */ + + uint32_t tmp[4]; + memcpy( tmp, key, 16 ); + BAES_COPY_REV( av->exp_key, tmp ); + + BAES_EncKeySchedule( av->exp_key ); + +#endif /* CFG_BAES_SW != 0 */ + + /* set IV to zero */ + av->iv[0] = av->iv[1] = av->iv[2] = av->iv[3] = 0; +} + +/* + * Initialization for AES-CMAC for Authentication TAG Generation. + * Must be called each time a new CMAC has to be computed. + */ + +void BAES_CmacSetVector( const uint8_t * pIV ) +{ + BAES_CMAC_t * av = &BAES_CMAC_var; + + // -- Update IV if exist else set to zero -- + if ( pIV != NULL ) + { memcpy( av->iv, pIV, AES_BLOCK_SIZE_BYTE ); } + else + { memset( av->iv, 0x00, AES_BLOCK_SIZE_BYTE ); } +} + +/*****************************************************************************/ + +/* + * AES Encryption in CMAC Mode + * + * This function can be called multiple times with "size" multiple of 16 and + * "output" parameter set to NULL. However, in the last call to this function, + * any positive value for "size" is allowed and the "output" parameter must not + * be NULL. + */ + +void BAES_CmacCompute( const uint8_t* input, + uint32_t size, + uint8_t* output ) +{ + BAES_CMAC_t *av = &BAES_CMAC_var; + uint32_t i; + uint32_t last_size = 0; + uint32_t tmp[4], key[4]; + const uint8_t* ptr = input; + + if ( output ) + { + /* In case of final append, compute size of last block */ + last_size = size % 16; + if ( (size != 0) && (last_size == 0) ) + last_size = 16; + size -= last_size; + } + + while ( size ) + { + /* Load the input of all blocks but the last one + and xor data with previous tag */ + memcpy( tmp, ptr, 16 ); + BAES_REV_XOR( tmp, av->iv ); + + /* Encrypt block */ + BAES_CmacRawEncrypt( tmp, av->iv ); + + /* Next block */ + ptr += 16; + size -= 16; + } + + if ( output ) + { + /* Load the input bytes left with 0 padding */ + tmp[0] = tmp[1] = tmp[2] = tmp[3] = 0; + for ( i = 0; i < last_size; i++ ) + { + BAES_OR_BYTE_BE( tmp, i, ptr[i] ); + } + + /* Compute K1 */ + key[0] = key[1] = key[2] = key[3] = 0; + BAES_CmacRawEncrypt( key, key ); + BAES_CmacKeyRoll( key ); + + /* Add padding and compute K2 if the last block is not full */ + if ( last_size < 16 ) + { + BAES_OR_BYTE_BE( tmp, last_size, 0x80 ); + BAES_CmacKeyRoll( key ); + } + + /* Xor data with previous tag and key */ + for ( i = 0; i < 4; i++ ) + { + tmp[i] ^= av->iv[i] ^ key[i]; + } + + /* Encrypt block */ + BAES_CmacRawEncrypt( tmp, av->iv ); + +#if CFG_BAES_SW == 0 + + HW_AES_Disable( ); + +#endif /* CFG_BAES_SW == 0 */ + + /* Write the tag */ + BAES_COPY_REV( tmp, av->iv ); + memcpy( output, tmp, 16 ); + } +} + +/*****************************************************************************/ diff --git a/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes_ecb.c b/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes_ecb.c new file mode 100644 index 000000000..05a26b7dc --- /dev/null +++ b/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes_ecb.c @@ -0,0 +1,89 @@ +/** + ****************************************************************************** + * @file baes_ecb.c + * @author MCD Application Team + * @brief This file contains the AES ECB functions implementation. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#include "baes_global.h" + +/*****************************************************************************/ + +void BAES_Reset( void ) +{ +#if CFG_BAES_SW == 0 + + HW_AES_Disable( ); + +#endif +} + +/*****************************************************************************/ + +void BAES_EcbCrypt( const uint8_t* key, + const uint8_t* input, + uint8_t* output, + int enc ) +{ + uint32_t tmp[4]; + +#if CFG_BAES_SW == 0 + + HW_AES_Enable( ); + HW_AES_SetKey( (enc ? (HW_AES_ENC | HW_AES_REV) : (HW_AES_DEC | HW_AES_REV)), + key ); + +#else /* CFG_BAES_SW != 0 */ + + uint32_t exp_key[44]; + + /* Retrieve all bytes from key */ + memcpy( exp_key, key, 16 ); + BAES_SWAP( exp_key ); + +#if CFG_BAES_SW_DECRYPTION != 0 + if ( !enc ) + BAES_DecKeySchedule( exp_key ); + else +#endif /* CFG_BAES_SW_DECRYPTION != 0 */ + BAES_EncKeySchedule( exp_key ); + +#endif /* CFG_BAES_SW != 0 */ + + /* Retrieve all bytes from input */ + memcpy( tmp, input, 16 ); + BAES_SWAP( tmp ); + +#if CFG_BAES_SW == 0 + + HW_AES_Crypt( tmp, tmp ); + HW_AES_Disable( ); + +#else /* CFG_BAES_SW != 0 */ + +#if CFG_BAES_SW_DECRYPTION != 0 + if ( !enc ) + BAES_RawDecrypt( tmp, tmp, exp_key ); + else +#endif /* CFG_BAES_SW_DECRYPTION != 0 */ + BAES_RawEncrypt( tmp, tmp, exp_key ); + +#endif /* CFG_BAES_SW != 0 */ + + /* Write all bytes to output */ + BAES_SWAP( tmp ); + memcpy( output, tmp, 16 ); +} + +/*****************************************************************************/ diff --git a/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes_global.h b/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes_global.h new file mode 100644 index 000000000..237712705 --- /dev/null +++ b/lib/stm32wba/Common/WPAN/Modules/BasicAES/baes_global.h @@ -0,0 +1,119 @@ +/** + ****************************************************************************** + * @file baes_global.h + * @author MCD Application Team + * @brief This file contains the internal definitions of the AES software + * module. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +#ifndef BAES_GLOBAL_H__ +#define BAES_GLOBAL_H__ + +#include "app_common.h" +#include "baes.h" + +/* Default software configuration */ +#define AES_BLOCK_SIZE_BIT 128u /* AES Size in Bits */ +#define AES_BLOCK_SIZE_BYTE 16u /* AES Size in Bytes */ +#define AES_BLOCK_SIZE_WORD 4u /* AES Size in Words */ + +#define AES_EXPANDED_KEY_SIZE 44u + +/* By default, use of AES H/W implementation instead of S/W */ +#ifndef CFG_BAES_SW +#define CFG_BAES_SW 0 +#endif + +#if CFG_BAES_SW == 1 + +/* Enables to include AES S/W decryption when set to 1 */ +#ifndef CFG_BAES_SW_DECRYPTION +#define CFG_BAES_SW_DECRYPTION 0 +#endif + +/* Choice of the AES S/W algorithm version: + * 1: slow version with 522 bytes of look-up tables + * 2: fast version with 2048 bytes of look-up tables */ +#ifndef CFG_BAES_SW_ALGORITHM +#define CFG_BAES_SW_ALGORITHM 1 +#endif + +#endif /* CFG_BAES_SW == 1 */ + +/* Internal macros */ + +/* Reverse the words in a 4-word array */ +#define BAES_SWAP( w ) \ + M_BEGIN uint32_t t_; \ + t_ = (w)[0]; (w)[0] = (w)[3]; (w)[3] = t_; \ + t_ = (w)[1]; (w)[1] = (w)[2]; (w)[2] = t_; \ + M_END + +/* Reverse the bytes and words in a 4-word array */ +#define BAES_SWAP_REV( w ) \ + M_BEGIN uint32_t t_; \ + t_ = (w)[0]; (w)[0] = __REV((w)[3]); (w)[3] = __REV(t_); \ + t_ = (w)[1]; (w)[1] = __REV((w)[2]); (w)[2] = __REV(t_); \ + M_END + +/* Reverse the words of a 4-word array and xor the result */ +#define BAES_SWAP_XOR( w, x ) \ + M_BEGIN uint32_t t_; \ + t_ = (w)[0]; (w)[0] = (w)[3] ^ ((x)[0]); (w)[3] = t_ ^ ((x)[3]); \ + t_ = (w)[1]; (w)[1] = (w)[2] ^ ((x)[1]); (w)[2] = t_ ^ ((x)[2]); \ + M_END + +/* Reverse the bytes of a 4-word array and xor the result */ +#define BAES_REV_XOR( w, x ) \ + M_BEGIN \ + (w)[0] = __REV((w)[0]) ^ ((x)[0]); (w)[1] = __REV((w)[1]) ^ ((x)[1]); \ + (w)[2] = __REV((w)[2]) ^ ((x)[2]); (w)[3] = __REV((w)[3]) ^ ((x)[3]); \ + M_END + +/* Copy and reverse the words of a 4-word array */ +#define BAES_COPY_SWAP( d, s ) \ + M_BEGIN \ + (d)[0] = (s)[3]; (d)[1] = (s)[2]; \ + (d)[2] = (s)[1]; (d)[3] = (s)[0]; \ + M_END + +/* Copy and reverse the bytes of a 4-word array */ +#define BAES_COPY_REV( d, s ) \ + M_BEGIN \ + (d)[0] = __REV((s)[0]); (d)[1] = __REV((s)[1]); \ + (d)[2] = __REV((s)[2]); (d)[3] = __REV((s)[3]); \ + M_END + +/* Modifies a byte in a word array in Big Endian */ +#define BAES_OR_BYTE_BE( w, n, b ) \ + (w)[(n)/4] |= ((uint32_t)(b)) << (8 * (3-((n)%4))) + +/* Note: BYTE0, BYTE1, BYTE2, BYTE3 and BTOW macros are also used + but they should be defined in "common.h" */ + +/* Internal functions */ + +extern void BAES_EncKeySchedule( uint32_t* p_exp_key ); + +extern void BAES_DecKeySchedule( uint32_t* p_exp_key ); + +extern void BAES_RawEncrypt( const uint32_t* p_in, + uint32_t* p_out, + const uint32_t *p_exp_key ); + +extern void BAES_RawDecrypt( const uint32_t* p_in, + uint32_t* p_out, + const uint32_t* p_exp_key ); + +#endif /* BAES_GLOBAL_H__ */ diff --git a/lib/stm32wba/IEEE802154/CMakeLists.txt b/lib/stm32wba/IEEE802154/CMakeLists.txt new file mode 100644 index 000000000..66c927611 --- /dev/null +++ b/lib/stm32wba/IEEE802154/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright (c) 2025 STMicroelectronics +# +# SPDX-License-Identifier: Apache-2.0 +zephyr_include_directories(Core/Inc) +zephyr_include_directories(System/Config/Debug_GPIO) +zephyr_include_directories(System/Config/Log) +zephyr_include_directories(STM32_WPAN/Target) + +if(CONFIG_IEEE802154_STM32WBA) + zephyr_include_directories(Inc) + if(NOT CONFIG_NET_L2_CUSTOM_IEEE802154_STM32WBA) + zephyr_include_directories(Core/Inc/802154) + endif() +endif() + +zephyr_sources(STM32_WPAN/Target/linklayer_plat.c) +zephyr_sources(STM32_WPAN/Target/ll_sys_if.c) +zephyr_sources(STM32_WPAN/Target/power_table.c) + diff --git a/lib/stm32wba/IEEE802154/Core/Inc/802154/app_conf.h b/lib/stm32wba/IEEE802154/Core/Inc/802154/app_conf.h new file mode 100644 index 000000000..0ad0c7938 --- /dev/null +++ b/lib/stm32wba/IEEE802154/Core/Inc/802154/app_conf.h @@ -0,0 +1,196 @@ +/** + ****************************************************************************** + * @file app_conf.h + * @author MCD Application Team + * @brief Application configuration file for STM32WPAN Middleware. + ****************************************************************************** + * @attention + * + * Copyright (c) 2022 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef APP_CONF_H +#define APP_CONF_H + +/* Includes ------------------------------------------------------------------*/ +#include "hw_if.h" +#include "utilities_conf.h" + +/** + * PHY preferences + */ +#define CFG_PHY_PREF (0) +#define CFG_PHY_PREF_TX (HCI_TX_PHYS_LE_2M_PREF) +#define CFG_PHY_PREF_RX (HCI_RX_PHYS_LE_2M_PREF) + +/****************************************************************************** + * Low Power + * + * When CFG_LPM_LEVEL is set to: + * - 0 : Low Power Mode is not activated, RUN mode will be used. + * - 1 : Low power active, mode selected with CFG_LPM_STDBY_SUPPORTED + * - 2 : In addition log and debug are disabled to reach lowest power figures. + * + * When CFG_LPM_STDBY_SUPPORTED is set to: + * - 2 : Stop mode 2 is used as low power mode (if supported by target) + * - 1 : Standby is used as low power mode. + * - 0 : Stop mode 1 is used as low power mode. + * + ******************************************************************************/ +#define CFG_LPM_LEVEL (0) +#define CFG_LPM_STDBY_SUPPORTED (0) + +/* Defines time to wake up from standby before radio event to meet timings */ +#define CFG_LPM_STDBY_WAKEUP_TIME (1500) + +/** + * Supported requester to the MCU Low Power Manager - can be increased up to 32 + * It list a bit mapping of all user of the Low Power Manager + */ +typedef enum +{ + CFG_LPM_APP, + CFG_LPM_LOG, + CFG_LPM_LL_DEEPSLEEP, + CFG_LPM_LL_HW_RCO_CLBR, +} CFG_LPM_Id_t; + +/***************************************************************************** +- * Logs +- * +- * Applications must call LOG_INFO_APP for logs. +- * +- * For advanced log use cases, see the log_module.h file. +- *****************************************************************************/ + +/* Configure Log display settings */ +#define CFG_LOG_INSERT_COLOR_INSIDE_THE_TRACE (0U) +#define CFG_LOG_INSERT_TIME_STAMP_INSIDE_THE_TRACE (0U) +#define CFG_LOG_INSERT_EOL_INSIDE_THE_TRACE (0U) + +#define CFG_LOG_TRACE_FIFO_SIZE (4096U) +#define CFG_LOG_TRACE_BUF_SIZE (256U) + +/* macro ensuring retrocompatibility with old applications */ +#define APP_DBG LOG_INFO_APP +#define APP_DBG_MSG LOG_INFO_APP + +/****************************************************************************** + * Debugger + * + * When CFG_DEBUGGER_LEVEL is set to: + * - 0 : No Debugger available, SWD/JTAG pins are disabled. + * - 1 : Debugger available in RUN mode only. + * - 2 : Debugger available in low power mode. + * + ******************************************************************************/ +#define CFG_DEBUGGER_LEVEL (0) + +/****************************************************************************** + * RealTime GPIO debug module configuration + ******************************************************************************/ + +#define CFG_RT_DEBUG_GPIO_MODULE (0) +#define CFG_RT_DEBUG_DTB (0) + +/****************************************************************************** + * System Clock Manager module configuration + ******************************************************************************/ + +#define CFG_SCM_SUPPORTED (0) + +/****************************************************************************** + * HW RADIO configuration + ******************************************************************************/ +/* Do not modify - must be 1 */ +#define USE_RADIO_LOW_ISR (1) + +/* Do not modify - must be 1 */ +#define NEXT_EVENT_SCHEDULING_FROM_ISR (1) + +/* Link Layer uses temperature based calibration (0 --> NO ; 1 --> YES) */ +#define USE_TEMPERATURE_BASED_RADIO_CALIBRATION (0) + +#define RADIO_INTR_NUM RADIO_IRQn /* 2.4GHz RADIO global interrupt */ +#define RADIO_INTR_PRIO_HIGH (0) /* 2.4GHz RADIO interrupt priority when radio is Active */ +#define RADIO_INTR_PRIO_LOW (5) /* 2.4GHz RADIO interrupt priority when radio is Not Active - Sleep Timer Only */ + +#if (USE_RADIO_LOW_ISR == 1) +#define RADIO_SW_LOW_INTR_NUM HASH_IRQn /* Selected interrupt vector for 2.4GHz RADIO low ISR */ +#define RADIO_SW_LOW_INTR_PRIO (14) /* 2.4GHz RADIO low ISR priority */ +#endif /* USE_RADIO_LOW_ISR */ + +/* Link Layer supported number of antennas */ +#define RADIO_NUM_OF_ANTENNAS (4) + +#define RCC_INTR_PRIO (1) /* HSERDY and PLL1RDY */ + +/* RF TX power table ID selection: + * 0 -> RF TX output level from -20 dBm to +10 dBm + * 1 -> RF TX output level from -20 dBm to +3 dBm + * 2 -> RF TX output level at +20 dBm with an external PA + */ +#define CFG_RF_TX_POWER_TABLE_ID (1) + +#define CFG_EXTERNAL_PA_ENABLE (0) + +#define CFG_BLE_AOA_AOD_ENABLE (0) +#define CFG_RADIO_NUM_OF_ANTENNAS (8) /* Link Layer supported number of antennas */ + +/* Custom LSE sleep clock accuracy to use if both conditions are met: + * - LSE is selected as Link Layer sleep clock source + * - the LSE used is different from the default one. + */ +/* Radio sleep clock LSE accuracy configuration */ +#define CFG_RADIO_LSE_SLEEP_TIMER_CUSTOM_SCA_RANGE (0x00) + +/** + * User interaction + * When CFG_LED_SUPPORTED is set, LEDs are activated if requested + * When CFG_BUTTON_SUPPORTED is set, the push button are activated if requested + */ + +#define CFG_LED_SUPPORTED (1) +#define CFG_BUTTON_SUPPORTED (1) + +/** + * Overwrite some configuration imposed by Low Power level selected. + */ +#if (CFG_LPM_LEVEL > 1) + #if CFG_LED_SUPPORTED + #undef CFG_LED_SUPPORTED + #define CFG_LED_SUPPORTED (0) + #endif /* CFG_LED_SUPPORTED */ +#endif /* CFG_LPM_LEVEL */ + +/** + * Overwrite some configuration imposed by Low Power level selected. + */ +#if (CFG_LPM_LEVEL > 1) + #if CFG_LOG_SUPPORTED + #undef CFG_LOG_SUPPORTED + #define CFG_LOG_SUPPORTED (0) + #endif /* CFG_LOG_SUPPORTED */ + #if CFG_DEBUGGER_LEVEL + #undef CFG_DEBUGGER_LEVEL + #define CFG_DEBUGGER_LEVEL (0) + #endif /* CFG_DEBUGGER_LEVEL */ +#endif /* CFG_LPM_LEVEL */ + +#if (CFG_LPM_STDBY_SUPPORTED != 0) && (CFG_LPM_LEVEL != 0) + #if CFG_LOG_SUPPORTED + #undef CFG_LOG_SUPPORTED + #define CFG_LOG_SUPPORTED (0) + #endif /* CFG_LOG_SUPPORTED */ +#endif /* (CFG_LPM_STDBY_SUPPORTED > 0) && (CFG_LPM_LEVEL != 0) */ + + +#endif /*APP_CONF_H */ diff --git a/lib/stm32wba/IEEE802154/Core/Inc/app_common.h b/lib/stm32wba/IEEE802154/Core/Inc/app_common.h new file mode 100644 index 000000000..5eccc8b18 --- /dev/null +++ b/lib/stm32wba/IEEE802154/Core/Inc/app_common.h @@ -0,0 +1,116 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file app_common.h + * @author MCD Application Team + * @brief App Common application configuration file for STM32WPAN Middleware. + ****************************************************************************** + * @attention + * + * Copyright (c) 2025 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef APP_COMMON_H +#define APP_COMMON_H + +#ifdef __cplusplus +extern "C"{ +#endif + +#include +#include +#include +#include +#include +#include + +#include "app_conf.h" +#include "hw.h" +#include "ll_sys.h" + +/* -------------------------------- * + * Basic definitions * + * -------------------------------- */ +#undef NULL +#define NULL 0 + +#undef FALSE +#define FALSE 0 + +#undef TRUE +#define TRUE (!0) + +/* -------------------------------- * + * Critical Section definition * + * -------------------------------- */ +#define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK() +#define DISABLE_IRQ() __disable_irq() +#define RESTORE_PRIMASK() __set_PRIMASK(primask_bit) + +/* -------------------------------- * + * Macro delimiters * + * -------------------------------- */ +#define M_BEGIN do { + +#define M_END } while(0) + +/* -------------------------------- * + * Some useful macro definitions * + * -------------------------------- */ +#ifndef MAX +#define MAX( x, y ) (((x)>(y))?(x):(y)) +#endif + +#ifndef MIN +#define MIN( x, y ) (((x)<(y))?(x):(y)) +#endif + +#define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END + +#define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END + +#define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END + +#define MODSUB( a, b, m ) MODADD( a, (m)-(b), m ) + +#define PAUSE( t ) M_BEGIN \ + __IO int _i; \ + for ( _i = t; _i > 0; _i -- ); \ + M_END + +#define DIVF( x, y ) ((x)/(y)) + +#define DIVC( x, y ) (((x)+(y)-1)/(y)) + +#define DIVR( x, y ) (((x)+((y)/2))/(y)) + +#define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1) + +#define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1) + +#define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END + +/* -------------------------------- * + * Compiler * + * -------------------------------- */ +#define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__))) + +#ifdef WIN32 +#define ALIGN(n) +#else +#define ALIGN(n) __attribute__((aligned(n))) +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*APP_COMMON_H */ diff --git a/lib/stm32wba/IEEE802154/Core/Inc/main.h b/lib/stm32wba/IEEE802154/Core/Inc/main.h new file mode 100644 index 000000000..2dcee4702 --- /dev/null +++ b/lib/stm32wba/IEEE802154/Core/Inc/main.h @@ -0,0 +1,90 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * @attention + * + * Copyright (c) 2025 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32wbaxx_hal.h" +#include "app_conf.h" +#include "app_common.h" + + +#include "stm32wbaxx_ll_tim.h" +#include "stm32wbaxx_ll_bus.h" +#include "stm32wbaxx_ll_cortex.h" +#include "stm32wbaxx_ll_rcc.h" +#include "stm32wbaxx_ll_system.h" +#include "stm32wbaxx_ll_utils.h" +#include "stm32wbaxx_ll_pwr.h" +#include "stm32wbaxx_ll_gpio.h" +#include "stm32wbaxx_ll_dma.h" + +#include "stm32wbaxx_ll_exti.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); +void MX_GPIO_Init(void); +void MX_ICACHE_Init(void); +void MX_RAMCFG_Init(void); +void MX_RTC_Init(void); +void MX_USART1_UART_Init(void); +void MX_RNG_Init(void); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ + +/* USER CODE BEGIN Private defines */ + +/* USER CODE END Private defines */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MAIN_H */ diff --git a/lib/stm32wba/IEEE802154/Core/Inc/utilities_conf.h b/lib/stm32wba/IEEE802154/Core/Inc/utilities_conf.h new file mode 100644 index 000000000..1192971ea --- /dev/null +++ b/lib/stm32wba/IEEE802154/Core/Inc/utilities_conf.h @@ -0,0 +1,170 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file utilities_conf.h + * @author MCD Application Team + * @brief Header for configuration file for STM32 Utilities. + ****************************************************************************** + * @attention + * + * Copyright (c) 2025 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef UTILITIES_CONF_H +#define UTILITIES_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "cmsis_compiler.h" +#include "app_conf.h" +/* definitions to be provided to "sequencer" utility */ +#include "stm32_mem.h" +/* definition and callback for tiny_vsnprintf */ +#include "stm32_tiny_vsnprintf.h" + +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ + +#define VLEVEL_OFF 0 /*!< used to set UTIL_ADV_TRACE_SetVerboseLevel() (not as message param) */ +#define VLEVEL_ALWAYS 0 /*!< used as message params, if this level is given + trace will be printed even when UTIL_ADV_TRACE_SetVerboseLevel(OFF) */ +#define VLEVEL_L 1 /*!< just essential traces */ +#define VLEVEL_M 2 /*!< functional traces */ +#define VLEVEL_H 3 /*!< all traces */ + +#define TS_OFF 0 /*!< Log without TimeStamp */ +#define TS_ON 1 /*!< Log with TimeStamp */ + +#define T_REG_OFF 0 /*!< Log without bitmask */ + +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ +/* External variables --------------------------------------------------------*/ +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/* Exported macros -----------------------------------------------------------*/ +/** + * @brief Memory placement macro + */ +#if defined(__CC_ARM) +#define UTIL_PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__), zero_init)) +#elif defined(__ICCARM__) +#define UTIL_PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__))) +#else /* __GNUC__ */ +#define UTIL_PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__))) +#endif /* __CC_ARM | __ICCARM__ | __GNUC__ */ + +/** + * @brief Memory alignment macro + */ +#undef ALIGN +#ifdef WIN32 +#define ALIGN(n) +#else +#define ALIGN(n) __attribute__((aligned(n))) +#endif /* WIN32 */ + +/** + * @brief macro used to initialize the critical section + */ +#define UTIL_SEQ_INIT_CRITICAL_SECTION( ) UTILS_INIT_CRITICAL_SECTION() + +/** + * @brief macro used to enter the critical section + */ +#define UTIL_SEQ_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION() + +/** + * @brief macro used to exit the critical section + */ +#define UTIL_SEQ_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION() + +/** + * @brief Memset utilities interface to application + */ +#define UTIL_SEQ_MEMSET8( dest, value, size ) UTIL_MEM_set_8( dest, value, size ) + +/** + * @brief macro used to initialize the critical section + */ +#define UTILS_INIT_CRITICAL_SECTION() + +/** + * @brief macro used to enter the critical section + */ +#define UTILS_ENTER_CRITICAL_SECTION() uint32_t primask_bit= __get_PRIMASK();\ + __disable_irq() + +/** + * @brief macro used to exit the critical section + */ +#define UTILS_EXIT_CRITICAL_SECTION() __set_PRIMASK(primask_bit) + +/** + * @brief macro used to enter the critical section + */ +#define UTILS_ENTER_LIMITED_CRITICAL_SECTION(x) uint32_t basepri_value= __get_BASEPRI();\ + __set_BASEPRI_MAX(x) + +/** + * @brief macro used to exit the critical section + */ +#define UTILS_EXIT_LIMITED_CRITICAL_SECTION() __set_BASEPRI(basepri_value) + +/****************************************************************************** + * trace\advanced + * the define option + * UTIL_ADV_TRACE_CONDITIONNAL shall be defined if you want use conditional function + * UTIL_ADV_TRACE_UNCHUNK_MODE shall be defined if you want use the unchunk mode + * + ******************************************************************************/ + +#define UTIL_ADV_TRACE_CONDITIONNAL /*!< not used */ +#define UTIL_ADV_TRACE_UNCHUNK_MODE /*!< not used */ +#define UTIL_ADV_TRACE_DEBUG(...) /*!< not used */ +#define UTIL_ADV_TRACE_INIT_CRITICAL_SECTION( ) UTILS_INIT_CRITICAL_SECTION() /*!< init the critical section in trace feature */ +#define UTIL_ADV_TRACE_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION() /*!< enter the critical section in trace feature */ +#define UTIL_ADV_TRACE_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION() /*!< exit the critical section in trace feature */ +#define UTIL_ADV_TRACE_TMP_BUF_SIZE (CFG_LOG_TRACE_BUF_SIZE) /*!< trace buffer size */ +#define UTIL_ADV_TRACE_TMP_MAX_TIMESTMAP_SIZE (15U) /*!< trace timestamp size */ +#define UTIL_ADV_TRACE_FIFO_SIZE (CFG_LOG_TRACE_FIFO_SIZE) /*!< trace fifo size */ +#define UTIL_ADV_TRACE_MEMSET8( dest, value, size) UTIL_MEM_set_8((dest),(value),(size)) /*!< memset utilities interface to trace feature */ +#define UTIL_ADV_TRACE_VSNPRINTF(...) vsnprintf(__VA_ARGS__) /*!< vsnprintf utilities interface to trace feature */ + +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /*UTILITIES_CONF_H */ diff --git a/lib/stm32wba/IEEE802154/Inc/stm32wba_802154_intf.h b/lib/stm32wba/IEEE802154/Inc/stm32wba_802154_intf.h new file mode 100644 index 000000000..3133c0e69 --- /dev/null +++ b/lib/stm32wba/IEEE802154/Inc/stm32wba_802154_intf.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of STMicroelectronics nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** + * @defgroup STM32WBA 802.15.4 interface + * @{ + * + */ + +#ifndef STM32WBA_802154_INTF_H_ +#define STM32WBA_802154_INTF_H_ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + /* support CSL transmitter configuration flag, RADIO TX at specific time , 1 supported , 0 not supported */ +#define STM32WBA_802154_CSL_TRANSMITTER_ENABLE CONFIG_MAC_CSL_TRANSMITTER_ENABLE +/* support of CSL receiver configuration flag, RADIO RX at specific time, 1 supported , 0 not supported */ +#define STM32WBA_802154_CSL_RECEIVER_ENABLE CONFIG_MAC_CSL_RECEIVER_ENABLE + + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32WBA_802154_INTF_H_ */ + +/** @} */ diff --git a/lib/stm32wba/IEEE802154/STM32_WPAN/Target/linklayer_plat.c b/lib/stm32wba/IEEE802154/STM32_WPAN/Target/linklayer_plat.c new file mode 100644 index 000000000..bfe0d8e65 --- /dev/null +++ b/lib/stm32wba/IEEE802154/STM32_WPAN/Target/linklayer_plat.c @@ -0,0 +1,566 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file linklayer_plat.c + * @author MCD Application Team + * @brief Source file for the linklayer plateform adaptation layer + ****************************************************************************** + * @attention + * + * Copyright (c) 2022 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + + +#include "stm32wbaxx_hal.h" +#include "stm32wbaxx_hal_conf.h" +#include "stm32wbaxx_ll_rcc.h" + +#include "app_common.h" +#include "app_conf.h" +#include "linklayer_plat.h" + +#include "log_module.h" +#ifndef __ZEPHYR__ +#if (CFG_LPM_LEVEL != 0) +#include "stm32_lpm.h" +#include "stm32_lpm_if.h" +#endif /* (CFG_LPM_LEVEL != 0) */ +#endif + + +#ifndef __ZEPHYR__ +#define max(a,b) ((a) > (b) ? a : b) + +/* 2.4GHz RADIO ISR callbacks */ +typedef void (*radio_isr_cb_t) (void); + +/* Radio critical sections */ +static uint32_t primask_bit = 0; +volatile int32_t irq_counter; +#endif /* __ZEPHYR__ */ + +/* Radio bus clock control variables */ +uint8_t AHB5_SwitchedOff; +uint32_t radio_sleep_timer_val; + +/** + * @brief Configure the necessary clock sources for the radio. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_ClockInit(void) +{ + AHB5_SwitchedOff = 0; + radio_sleep_timer_val = 0; + +#ifdef __ZEPHYR__ + LINKLAYER_PLAT_EnableBackupDomainAccess(); +#else + LL_PWR_EnableBkUpAccess(); +#endif + + /* Select LSE as Sleep CLK */ + __HAL_RCC_RADIOSLPTIM_CONFIG(RCC_RADIOSTCLKSOURCE_LSE); + +#ifdef __ZEPHYR__ + LINKLAYER_PLAT_DisableBackupDomainAccess(); +#else + LL_PWR_DisableBkUpAccess(); +#endif + + /* Enable AHB5ENR peripheral clock (bus CLK) */ + __HAL_RCC_RADIO_CLK_ENABLE(); +} +#ifndef __ZEPHYR__ +/** + * @brief Link Layer active waiting loop. + * @param delay: delay in us + * @retval None + */ +void LINKLAYER_PLAT_DelayUs(uint32_t delay) +{ + __IO register uint32_t Delay = delay * (SystemCoreClock / 1000000U); + do + { + __NOP(); + } + while (Delay --); +} + +/** + * @brief Link Layer assertion API + * @param condition: conditional statement to be checked. + * @retval None + */ +void LINKLAYER_PLAT_Assert(uint8_t condition) +{ + assert_param(condition); +} +#endif /* __ZEPHYR__ */ + +/** + * @brief Enable/disable the Link Layer active clock (baseband clock). + * @param enable: boolean value to enable (1) or disable (0) the clock. + * @retval None + */ +void LINKLAYER_PLAT_WaitHclkRdy(void) +{ + /* Wait on radio bus clock readiness if it has been turned of */ + if (AHB5_SwitchedOff == 1) + { + AHB5_SwitchedOff = 0; + while (radio_sleep_timer_val == ll_intf_cmn_get_slptmr_value()); + } +} + +/** + * @brief Notify the Link Layer platform layer the system will enter in WFI + * and AHB5 clock may be turned of regarding the 2.4Ghz radio state. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_NotifyWFIEnter(void) +{ + /* Check if Radio state will allow the AHB5 clock to be cut */ + + /* AHB5 clock will be cut in the following cases: + * - 2.4GHz radio is not in ACTIVE mode (in SLEEP or DEEPSLEEP mode). + * - RADIOSMEN and STRADIOCLKON bits are at 0. + */ + if((LL_PWR_GetRadioMode() != LL_PWR_RADIO_ACTIVE_MODE) || + ((__HAL_RCC_RADIO_IS_CLK_SLEEP_ENABLED() == 0) && (LL_RCC_RADIO_IsEnabledSleepTimerClock() == 0))) + { + AHB5_SwitchedOff = 1; + } +} + +/** + * @brief Notify the Link Layer platform layer the system exited WFI and AHB5 + * clock may be resynchronized as is may have been turned of during + * low power mode entry. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_NotifyWFIExit(void) +{ + /* Check if AHB5 clock has been turned of and needs resynchronisation */ + if (AHB5_SwitchedOff) + { + /* Read sleep register as earlier as possible */ + radio_sleep_timer_val = ll_intf_cmn_get_slptmr_value(); + } +} + +/** + * @brief Active wait on bus clock readiness. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_AclkCtrl(uint8_t enable) +{ + if(enable){ + /* Enable RADIO baseband clock (active CLK) */ + HAL_RCCEx_EnableRadioBBClock(); + + /* Polling on HSE32 activation */ + while ( LL_RCC_HSE_IsReady() == 0); + } + else + { + /* Disable RADIO baseband clock (active CLK) */ + HAL_RCCEx_DisableRadioBBClock(); + } +} + +#ifndef __ZEPHYR__ +/** + * @brief Link Layer RNG request. + * @param ptr_rnd: pointer to the variable that hosts the number. + * @param len: number of byte of anthropy to get. + * @retval None + */ +void LINKLAYER_PLAT_GetRNG(uint8_t *ptr_rnd, uint32_t len) +{ + uint32_t nb_remaining_rng = len; + uint32_t generated_rng; + + /* Get the requested RNGs (4 bytes by 4bytes) */ + while(nb_remaining_rng >= 4) + { + generated_rng = 0; + HW_RNG_Get(1, &generated_rng); + memcpy((ptr_rnd+(len-nb_remaining_rng)), &generated_rng, 4); + nb_remaining_rng -=4; + } + + /* Get the remaining number of RNGs */ + if(nb_remaining_rng>0){ + generated_rng = 0; + HW_RNG_Get(1, &generated_rng); + memcpy((ptr_rnd+(len-nb_remaining_rng)), &generated_rng, nb_remaining_rng); + } +} + +/** + * @brief Initialize Link Layer radio high priority interrupt. + * @param intr_cb: function pointer to assign for the radio high priority ISR routine. + * @retval None + */ +void LINKLAYER_PLAT_SetupRadioIT(void (*intr_cb)()) +{ + radio_callback = intr_cb; + HAL_NVIC_SetPriority((IRQn_Type) RADIO_INTR_NUM, RADIO_INTR_PRIO_HIGH, 0); + HAL_NVIC_EnableIRQ((IRQn_Type) RADIO_INTR_NUM); +} + +/** + * @brief Initialize Link Layer SW low priority interrupt. + * @param intr_cb: function pointer to assign for the SW low priority ISR routine. + * @retval None + */ +void LINKLAYER_PLAT_SetupSwLowIT(void (*intr_cb)()) +{ + low_isr_callback = intr_cb; + + HAL_NVIC_SetPriority((IRQn_Type) RADIO_SW_LOW_INTR_NUM, RADIO_SW_LOW_INTR_PRIO, 0); + HAL_NVIC_EnableIRQ((IRQn_Type) RADIO_SW_LOW_INTR_NUM); +} + +/** + * @brief Trigger the link layer SW low interrupt. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_TriggerSwLowIT(uint8_t priority) +{ + uint8_t low_isr_priority = RADIO_INTR_PRIO_LOW; + + /* Check if a SW low interrupt as already been raised. + * Nested call far radio low isr are not supported + **/ + + if(NVIC_GetActive(RADIO_SW_LOW_INTR_NUM) == 0) + { + /* No nested SW low ISR, default behavior */ + + if(priority == 0) + { + low_isr_priority = RADIO_SW_LOW_INTR_PRIO; + } + + HAL_NVIC_SetPriority((IRQn_Type) RADIO_SW_LOW_INTR_NUM, low_isr_priority, 0); + } + else + { + /* Nested call detected */ + /* No change for SW radio low interrupt priority for the moment */ + + if(priority != 0) + { + /* At the end of current SW radio low ISR, this pending SW low interrupt + * will run with RADIO_INTR_PRIO_LOW priority + **/ + radio_sw_low_isr_is_running_high_prio = 1; + } + } + + HAL_NVIC_SetPendingIRQ((IRQn_Type) RADIO_SW_LOW_INTR_NUM); +} + +/** + * @brief Enable interrupts. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_EnableIRQ(void) +{ + irq_counter = max(0,irq_counter-1); + + if(irq_counter == 0) + { + /* When irq_counter reaches 0, restore primask bit */ + __set_PRIMASK(primask_bit); + } +} + +/** + * @brief Disable interrupts. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_DisableIRQ(void) +{ + if(irq_counter == 0) + { + /* Save primask bit at first interrupt disablement */ + primask_bit= __get_PRIMASK(); + } + __disable_irq(); + irq_counter ++; +} + +/** + * @brief Enable specific interrupt group. + * @param isr_type: mask for interrupt group to enable. + * This parameter can be one of the following: + * @arg LL_HIGH_ISR_ONLY: enable link layer high priority ISR. + * @arg LL_LOW_ISR_ONLY: enable link layer SW low priority ISR. + * @arg SYS_LOW_ISR: mask interrupts for all the other system ISR with + * lower priority that link layer SW low interrupt. + * @retval None + */ +void LINKLAYER_PLAT_EnableSpecificIRQ(uint8_t isr_type) +{ + if( (isr_type & LL_HIGH_ISR_ONLY) != 0 ) + { + prio_high_isr_counter--; + if(prio_high_isr_counter == 0) + { + /* When specific counter for link layer high ISR reaches 0, interrupt is enabled */ + HAL_NVIC_EnableIRQ(RADIO_INTR_NUM); + /* USER CODE BEGIN LINKLAYER_PLAT_EnableSpecificIRQ_1 */ + + /* USER CODE END LINKLAYER_PLAT_EnableSpecificIRQ_1 */ + } + } + + if( (isr_type & LL_LOW_ISR_ONLY) != 0 ) + { + prio_low_isr_counter--; + if(prio_low_isr_counter == 0) + { + /* When specific counter for link layer SW low ISR reaches 0, interrupt is enabled */ + HAL_NVIC_EnableIRQ(RADIO_SW_LOW_INTR_NUM); + } + + } + + if( (isr_type & SYS_LOW_ISR) != 0 ) + { + prio_sys_isr_counter--; + if(prio_sys_isr_counter == 0) + { + /* Restore basepri value */ + __set_BASEPRI(local_basepri_value); + } + } +} + +/** + * @brief Disable specific interrupt group. + * @param isr_type: mask for interrupt group to disable. + * This parameter can be one of the following: + * @arg LL_HIGH_ISR_ONLY: disable link layer high priority ISR. + * @arg LL_LOW_ISR_ONLY: disable link layer SW low priority ISR. + * @arg SYS_LOW_ISR: unmask interrupts for all the other system ISR with + * lower priority that link layer SW low interrupt. + * @retval None + */ +void LINKLAYER_PLAT_DisableSpecificIRQ(uint8_t isr_type) +{ + if( (isr_type & LL_HIGH_ISR_ONLY) != 0 ) + { + prio_high_isr_counter++; + if(prio_high_isr_counter == 1) + { + /* USER CODE BEGIN LINKLAYER_PLAT_DisableSpecificIRQ_1 */ + + /* USER CODE END LINKLAYER_PLAT_DisableSpecificIRQ_1 */ + /* When specific counter for link layer high ISR value is 1, interrupt is disabled */ + HAL_NVIC_DisableIRQ(RADIO_INTR_NUM); + } + } + + if( (isr_type & LL_LOW_ISR_ONLY) != 0 ) + { + prio_low_isr_counter++; + if(prio_low_isr_counter == 1) + { + /* When specific counter for link layer SW low ISR value is 1, interrupt is disabled */ + HAL_NVIC_DisableIRQ(RADIO_SW_LOW_INTR_NUM); + } + } + + if( (isr_type & SYS_LOW_ISR) != 0 ) + { + prio_sys_isr_counter++; + if(prio_sys_isr_counter == 1) + { + /* Save basepri register value */ + local_basepri_value = __get_BASEPRI(); + + /* Mask all other interrupts with lower priority that link layer SW low ISR */ + __set_BASEPRI_MAX(RADIO_INTR_PRIO_LOW<<4); + } + } +} + +/** + * @brief Enable link layer high priority ISR only. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_EnableRadioIT(void) +{ + /* USER CODE BEGIN LINKLAYER_PLAT_EnableRadioIT_1 */ + + /* USER CODE END LINKLAYER_PLAT_EnableRadioIT_1 */ + + HAL_NVIC_EnableIRQ((IRQn_Type) RADIO_INTR_NUM); + + /* USER CODE BEGIN LINKLAYER_PLAT_EnableRadioIT_2 */ + + /* USER CODE END LINKLAYER_PLAT_EnableRadioIT_2 */ +} + +/** + * @brief Disable link layer high priority ISR only. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_DisableRadioIT(void) +{ + /* USER CODE BEGIN LINKLAYER_PLAT_DisableRadioIT_1 */ + + /* USER CODE END LINKLAYER_PLAT_DisableRadioIT_1 */ + + HAL_NVIC_DisableIRQ((IRQn_Type) RADIO_INTR_NUM); + + /* USER CODE BEGIN LINKLAYER_PLAT_DisableRadioIT_2 */ + + /* USER CODE END LINKLAYER_PLAT_DisableRadioIT_2 */ +} + +/** + * @brief Link Layer notification for radio activity start. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_StartRadioEvt(void) +{ + __HAL_RCC_RADIO_CLK_SLEEP_ENABLE(); + NVIC_SetPriority(RADIO_INTR_NUM, RADIO_INTR_PRIO_HIGH); +} + +/** + * @brief Link Layer notification for radio activity end. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_StopRadioEvt(void) +{ + __HAL_RCC_RADIO_CLK_SLEEP_DISABLE(); + NVIC_SetPriority(RADIO_INTR_NUM, RADIO_INTR_PRIO_LOW); +} + +/** + * @brief Link Layer notification for RCO calibration start. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_RCOStartClbr(void) +{ +#if (CFG_LPM_LEVEL != 0) + PWR_DisableSleepMode(); + /* Disabling stop mode prevents also from entering in standby */ + UTIL_LPM_SetStopMode(1U << CFG_LPM_LL_HW_RCO_CLBR, UTIL_LPM_DISABLE); +#endif /* (CFG_LPM_LEVEL != 0) */ +} + +/** + * @brief Link Layer notification for RCO calibration end. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_RCOStopClbr(void) +{ +#if (CFG_LPM_LEVEL != 0) + PWR_EnableSleepMode(); + UTIL_LPM_SetStopMode(1U << CFG_LPM_LL_HW_RCO_CLBR, UTIL_LPM_ENABLE); +#endif /* (CFG_LPM_LEVEL != 0) */ +} +#endif /*__ZEPHYR__*/ + +/** + * @brief Link Layer requests temperature. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_RequestTemperature(void) +{ + +} +#ifndef __ZEPHYR__ +/** + * @brief Enable RTOS context switch. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_EnableOSContextSwitch(void) +{ + /* USER CODE BEGIN LINKLAYER_PLAT_EnableOSContextSwitch_0 */ + + /* USER CODE END LINKLAYER_PLAT_EnableOSContextSwitch_0 */ + /* USER CODE BEGIN LINKLAYER_PLAT_EnableOSContextSwitch_1 */ + + /* USER CODE END LINKLAYER_PLAT_EnableOSContextSwitch_1 */ +} + +/** + * @brief Disable RTOS context switch. + * @param None + * @retval None + */ +void LINKLAYER_PLAT_DisableOSContextSwitch(void) +{ + /* USER CODE BEGIN LINKLAYER_PLAT_DisableOSContextSwitch_0 */ + + /* USER CODE END LINKLAYER_PLAT_DisableOSContextSwitch_0 */ + /* USER CODE BEGIN LINKLAYER_PLAT_DisableOSContextSwitch_1 */ + + /* USER CODE END LINKLAYER_PLAT_DisableOSContextSwitch_1 */ +} + +/** + * @brief Notify the upper layer that new Link Layer timings have been applied. + * @param evnt_timing[in]: Evnt_timing_t pointer to structure contains drift time , execution time and scheduling time + * @retval None. + */ +void LINKLAYER_PLAT_SCHLDR_TIMING_UPDATE_NOT(Evnt_timing_t * p_evnt_timing) +{ + /* USER CODE BEGIN LINKLAYER_PLAT_SCHLDR_TIMING_UPDATE_NOT_0 */ + + /* USER CODE END LINKLAYER_PLAT_SCHLDR_TIMING_UPDATE_NOT_0 */ +} + +/** + * @brief Get the ST company ID. + * @param None + * @retval Company ID + */ +uint32_t LINKLAYER_PLAT_GetSTCompanyID(void) +{ + return LL_FLASH_GetSTCompanyID(); +} + +/** + * @brief Get the Unique Device Number (UDN). + * @param None + * @retval UDN + */ +uint32_t LINKLAYER_PLAT_GetUDN(void) +{ + return LL_FLASH_GetUDN(); +} +#endif /* __ZEPHYR__ */ +/* USER CODE BEGIN LINKLAYER_PLAT 0 */ + +/* USER CODE END LINKLAYER_PLAT 0 */ diff --git a/lib/stm32wba/IEEE802154/STM32_WPAN/Target/ll_sys_if.c b/lib/stm32wba/IEEE802154/STM32_WPAN/Target/ll_sys_if.c new file mode 100644 index 000000000..fb4ac4851 --- /dev/null +++ b/lib/stm32wba/IEEE802154/STM32_WPAN/Target/ll_sys_if.c @@ -0,0 +1,214 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file ll_sys_if.c + * @author MCD Application Team + * @brief Source file for initiating system + ****************************************************************************** + * @attention + * + * Copyright (c) 2022 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +#include +#include "ll_intf.h" +#include "ll_intf_cmn.h" +#include "ll_sys.h" +#include "ll_sys_if.h" +#include "utilities_common.h" +#ifndef __ZEPHYR__ +#if (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1) +#include "temp_measurement.h" +#endif /* (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1) */ +#endif /*__ZEPHYR__*/ +/* Private defines -----------------------------------------------------------*/ +/* Radio event scheduling method - must be set at 1 */ +#define USE_RADIO_LOW_ISR (1) +#define NEXT_EVENT_SCHEDULING_FROM_ISR (1) + +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Private macros ------------------------------------------------------------*/ +/* USER CODE BEGIN PM */ + +/* USER CODE END PM */ + +/* Private constants ---------------------------------------------------------*/ +/* USER CODE BEGIN PC */ + +/* USER CODE END PC */ + +/* Private variables ---------------------------------------------------------*/ +/* USER CODE BEGIN PV */ + +/* USER CODE END PV */ + +/* Global variables ----------------------------------------------------------*/ + +/* USER CODE BEGIN GV */ + +/* USER CODE END GV */ + +/* Private functions prototypes-----------------------------------------------*/ +static void ll_sys_sleep_clock_source_selection(void); + +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* External variables --------------------------------------------------------*/ + +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +#ifndef __ZEPHYR__ +/* Functions Definition ------------------------------------------------------*/ + +/** + * @brief Link Layer background process initialization + * @param None + * @retval None + */ +void ll_sys_bg_process_init(void) +{ + /* Register Link Layer task */ + UTIL_SEQ_RegTask(1U << CFG_TASK_LINK_LAYER, UTIL_SEQ_RFU, ll_sys_bg_process); +} + +/** + * @brief Link Layer background process next iteration scheduling + * @param None + * @retval None + */ +void ll_sys_schedule_bg_process(void) +{ + UTIL_SEQ_SetTask(1U << CFG_TASK_LINK_LAYER, TASK_PRIO_LINK_LAYER); +} + +/** + * @brief Link Layer background process next iteration scheduling from ISR + * @param None + * @retval None + */ +void ll_sys_schedule_bg_process_isr(void) +{ + UTIL_SEQ_SetTask(1U << CFG_TASK_LINK_LAYER, TASK_PRIO_LINK_LAYER); +} +#endif + +/** + * @brief Link Layer configuration phase before application startup. + * @param None + * @retval None + */ +void ll_sys_config_params(void) +{ +/* USER CODE BEGIN ll_sys_config_params_0 */ + +/* USER CODE END ll_sys_config_params_0 */ + + /* Configure link layer behavior for low ISR use and next event scheduling method: + * - SW low ISR is used. + * - Next event is scheduled from ISR. + */ + ll_intf_cmn_config_ll_ctx_params(USE_RADIO_LOW_ISR, NEXT_EVENT_SCHEDULING_FROM_ISR); + /* Apply the selected link layer sleep timer source */ + ll_sys_sleep_clock_source_selection(); + +/* USER CODE BEGIN ll_sys_config_params_1 */ + +/* USER CODE END ll_sys_config_params_1 */ + +#if (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1) + /* Initialize link layer temperature measurement background task */ + ll_sys_bg_temperature_measurement_init(); + + /* Link layer IP uses temperature based calibration instead of periodic one */ + ll_intf_cmn_set_temperature_sensor_state(); +#endif /* USE_TEMPERATURE_BASED_RADIO_CALIBRATION */ + +#ifndef __ZEPHYR__ + /* Link Layer power table */ + ll_intf_cmn_select_tx_power_table(CFG_RF_TX_POWER_TABLE_ID); +#endif /*__ZEPHYR__*/ +/* USER CODE BEGIN ll_sys_config_params_2 */ + +/* USER CODE END ll_sys_config_params_2 */ +} + +#ifndef __ZEPHYR__ +#if (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1) + +/** + * @brief Link Layer temperature request background process initialization + * @param None + * @retval None + */ +void ll_sys_bg_temperature_measurement_init(void) +{ + /* Register Temperature Measurement task */ + UTIL_SEQ_RegTask(1U << CFG_TASK_TEMP_MEAS, UTIL_SEQ_RFU, TEMPMEAS_RequestTemperatureMeasurement); +} + +/** + * @brief Request backroud task processing for temperature measurement + * @param None + * @retval None + */ +void ll_sys_bg_temperature_measurement(void) +{ + static uint8_t initial_temperature_acquisition = 0; + + if(initial_temperature_acquisition == 0) + { + TEMPMEAS_RequestTemperatureMeasurement(); + initial_temperature_acquisition = 1; + } + else + { + UTIL_SEQ_SetTask(1U << CFG_TASK_TEMP_MEAS, CFG_SEQ_PRIO_0); + } +} + +#endif /* USE_TEMPERATURE_BASED_RADIO_CALIBRATION */ +#endif + +void ll_sys_sleep_clock_source_selection(void) +{ + uint16_t freq_value = 0; + uint32_t linklayer_slp_clk_src = LL_RCC_RADIOSLEEPSOURCE_NONE; + + linklayer_slp_clk_src = LL_RCC_RADIO_GetSleepTimerClockSource(); + switch(linklayer_slp_clk_src) + { + case LL_RCC_RADIOSLEEPSOURCE_LSE: + linklayer_slp_clk_src = RTC_SLPTMR; + break; + + case LL_RCC_RADIOSLEEPSOURCE_LSI: + linklayer_slp_clk_src = RCO_SLPTMR; + break; + + case LL_RCC_RADIOSLEEPSOURCE_HSE_DIV1000: + linklayer_slp_clk_src = CRYSTAL_OSCILLATOR_SLPTMR; + break; + + case LL_RCC_RADIOSLEEPSOURCE_NONE: + /* No Link Layer sleep clock source selected */ + assert_param(0); + break; + } + ll_intf_cmn_le_select_slp_clk_src((uint8_t)linklayer_slp_clk_src, &freq_value); +} + + diff --git a/lib/stm32wba/IEEE802154/STM32_WPAN/Target/ll_sys_if.h b/lib/stm32wba/IEEE802154/STM32_WPAN/Target/ll_sys_if.h new file mode 100644 index 000000000..9af998921 --- /dev/null +++ b/lib/stm32wba/IEEE802154/STM32_WPAN/Target/ll_sys_if.h @@ -0,0 +1,69 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file ll_sys_if.h + * @author MCD Application Team + * @brief Header file for initiating system + ****************************************************************************** + * @attention + * + * Copyright (c) 2022 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef LL_SYS_IF_H +#define LL_SYS_IF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ + +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* External variables --------------------------------------------------------*/ +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +#if (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1) +void ll_sys_bg_temperature_measurement(void); +#endif /* USE_TEMPERATURE_BASED_RADIO_CALIBRATION */ +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /*LL_SYS_IF_H */ diff --git a/lib/stm32wba/IEEE802154/STM32_WPAN/Target/power_table.c b/lib/stm32wba/IEEE802154/STM32_WPAN/Target/power_table.c new file mode 100644 index 000000000..8f6cd7fb9 --- /dev/null +++ b/lib/stm32wba/IEEE802154/STM32_WPAN/Target/power_table.c @@ -0,0 +1,119 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file power_table.c + * @author MCD Application Team + * @brief This file contains supported power tables + ****************************************************************************** + * @attention + * + * Copyright (c) 2025 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Includes ------------------------------------------------------------------*/ +#include "power_table.h" + +/* Private typedef -----------------------------------------------------------*/ + +/* VDD_LDO values to be written in PHY registers to select the TX_Power mode. + * g_vdd_ldo_value_1 : is to be set in PHY register address 0x63. + * g_vdd_ldo_value_2 : is to be set in PHY register address 0xEA. */ + +typedef enum _vdd_ldo_value_e { + VDD_LDO_VALUE_MAX_POWER = 0x70, + VDD_LDO_VALUE_LOW_POWER = 0x20, + VDD_LDO_VALUE_2_ID_0 = 0x00, +} vdd_ldo_value_e; + +/* Private defines -----------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ + +const power_table_entry ll_tx_power_table_max_power[] = { + {0x02, 0x02, 0x01, -20}, /* Actual_Power = -20.4 dBm */ + {0x02, 0x03, 0x01, -19}, /* Actual_Power = -19.4 dBm */ + {0x02, 0x04, 0x01, -18}, /* Actual_Power = -18.3 dBm */ + {0x02, 0x05, 0x01, -17}, /* Actual_Power = -17.3 dBm */ + {0x02, 0x06, 0x01, -16}, /* Actual_Power = -16.4 dBm */ + {0x02, 0x07, 0x01, -15}, /* Actual_Power = -15.4 dBm */ + {0x02, 0x08, 0x01, -14}, /* Actual_Power = -14.3 dBm */ + {0x02, 0x09, 0x01, -13}, /* Actual_Power = -13.3 dBm */ + {0x02, 0x0A, 0x01, -12}, /* Actual_Power = -12.3 dBm */ + {0x02, 0x0B, 0x01, -11}, /* Actual_Power = -11.4 dBm */ + {0x02, 0x0C, 0x01, -10}, /* Actual_Power = -10.4 dBm */ + {0x02, 0x0D, 0x01, -9}, /* Actual_Power = -9.5 dBm */ + {0x02, 0x0E, 0x01, -8}, /* Actual_Power = -8.4 dBm */ + {0x00, 0x0F, 0x01, -7}, /* Actual_Power = -7.5 dBm */ + {0x00, 0x10, 0x01, -6}, /* Actual_Power = -6.5 dBm */ + {0x00, 0x11, 0x01, -5}, /* Actual_Power = -5.4 dBm */ + {0x00, 0x12, 0x01, -4}, /* Actual_Power = -4.5 dBm */ + {0x00, 0x13, 0x01, -3}, /* Actual_Power = -3.5 dBm */ + {0x02, 0x14, 0x01, -2}, /* Actual_Power = -2.4 dBm */ + {0x00, 0x15, 0x01, -1}, /* Actual_Power = -1.5 dBm */ + {0x02, 0x16, 0x01, 0}, /* Actual_Power = -0.3 dBm */ + {0x00, 0x17, 0x01, 1}, /* Actual_Power = 0.9 dBm */ + {0x00, 0x18, 0x01, 2}, /* Actual_Power = 2.3 dBm */ + {0x02, 0x18, 0x01, 3}, /* Actual_Power = 2.8 dBm */ + {0x00, 0x19, 0x01, 4}, /* Actual_Power = 3.9 dBm */ + {0x02, 0x19, 0x01, 5}, /* Actual_Power = 4.8 dBm */ + {0x03, 0x19, 0x01, 6}, /* Actual_Power = 5.6 dBm */ + {0x05, 0x19, 0x01, 7}, /* Actual_Power = 6.9 dBm */ + {0x06, 0x19, 0x01, 8}, /* Actual_Power = 7.5 dBm */ + {0x08, 0x19, 0x01, 9}, /* Actual_Power = 8.5 dBm */ + {0x0D, 0x19, 0x01, 10}, /* Actual_Power = 10 dBm */ +}; + +const power_table_entry ll_tx_power_table_low_power[] = { + {0x02, 0x02, 0x01, -20}, /* Actual_Power = -20.5 dBm */ + {0x02, 0x03, 0x01, -19}, /* Actual_Power = -19.5 dBm */ + {0x00, 0x05, 0x01, -18}, /* Actual_Power = -17.9 dBm */ + {0x00, 0x06, 0x01, -17}, /* Actual_Power = -17.0 dBm */ + {0x00, 0x07, 0x01, -16}, /* Actual_Power = -16.0 dBm */ + {0x00, 0x08, 0x01, -15}, /* Actual_Power = -15.0 dBm */ + {0x00, 0x09, 0x01, -14}, /* Actual_Power = -14.1 dBm */ + {0x00, 0x0A, 0x01, -13}, /* Actual_Power = -13.1 dBm */ + {0x00, 0x0B, 0x01, -12}, /* Actual_Power = -12.2 dBm */ + {0x00, 0x0C, 0x01, -11}, /* Actual_Power = -11.3 dBm */ + {0x00, 0x0D, 0x01, -10}, /* Actual_Power = -10.4 dBm */ + {0x00, 0x0E, 0x01, -9}, /* Actual_Power = -9.4 dBm */ + {0x00, 0x0F, 0x01, -8}, /* Actual_Power = -8.3 dBm */ + {0x00, 0x10, 0x01, -7}, /* Actual_Power = -7.2 dBm */ + {0x00, 0x11, 0x01, -6}, /* Actual_Power = -6.2 dBm */ + {0x00, 0x12, 0x01, -5}, /* Actual_Power = -5.5 dBm */ + {0x00, 0x13, 0x01, -4}, /* Actual_Power = -4.5 dBm */ + {0x02, 0x14, 0x01, -3}, /* Actual_Power = -3.5 dBm */ + {0x02, 0x15, 0x01, -2}, /* Actual_Power = -2.5 dBm */ + {0x00, 0x17, 0x01, -1}, /* Actual_Power = -0.6 dBm */ + {0x02, 0x17, 0x01, 0}, /* Actual_Power = -0.4 dBm */ + {0x00, 0x18, 0x01, 1}, /* Actual_Power = 0.7 dBm */ + {0x00, 0x19, 0x01, 2}, /* Actual_Power = 2.0 dBm */ + {0x02, 0x19, 0x01, 3}, /* Actual_Power = 2.6 dBm */ +}; + +/* USER CODE BEGIN ll_tx_power_table */ + +/* USER CODE END ll_tx_power_table */ + +/* Supported TX_Power tables. */ +const power_table_id_t ll_tx_power_tables[] = { + {ll_tx_power_table_max_power, sizeof(ll_tx_power_table_max_power)/sizeof(ll_tx_power_table_max_power[0]), VDD_LDO_VALUE_MAX_POWER, VDD_LDO_VALUE_2_ID_0, 0}, + {ll_tx_power_table_low_power, sizeof(ll_tx_power_table_low_power)/sizeof(ll_tx_power_table_low_power[0]), VDD_LDO_VALUE_LOW_POWER, VDD_LDO_VALUE_2_ID_0, 1}, + /* USER CODE BEGIN ll_tx_power_tables */ + + /* USER CODE END ll_tx_power_tables */ +}; + +/* Number of supported TX_Power tables. */ +const uint8_t num_of_supported_power_tables = sizeof(ll_tx_power_tables)/sizeof(ll_tx_power_tables[0]); + +/* Functions Definition ------------------------------------------------------*/ +/* Private functions ----------------------------------------------------------*/ +/* Public functions ----------------------------------------------------------*/ diff --git a/lib/stm32wba/BLE_TransparentMode/System/Config/Debug_GPIO/debug_config.h b/lib/stm32wba/IEEE802154/System/Config/Debug_GPIO/debug_config.h similarity index 100% rename from lib/stm32wba/BLE_TransparentMode/System/Config/Debug_GPIO/debug_config.h rename to lib/stm32wba/IEEE802154/System/Config/Debug_GPIO/debug_config.h diff --git a/lib/stm32wba/BLE_TransparentMode/System/Config/Log/log_module_conf.h b/lib/stm32wba/IEEE802154/System/Config/Log/log_module_conf.h similarity index 100% rename from lib/stm32wba/BLE_TransparentMode/System/Config/Log/log_module_conf.h rename to lib/stm32wba/IEEE802154/System/Config/Log/log_module_conf.h diff --git a/lib/stm32wba/README.rst b/lib/stm32wba/README.rst index 855d8b132..ec2c2fbd7 100644 --- a/lib/stm32wba/README.rst +++ b/lib/stm32wba/README.rst @@ -1,4 +1,4 @@ -STM32WBA BLE controller interfacing library +STM32WBA BLE and IEEE802154 controller interfacing library ########################################### Origin: @@ -9,7 +9,7 @@ Status: version v1.6.0 Purpose: - This library is used on STM32WBA series to port BLE controller library in + This library is used on STM32WBA series to port BLE and IEEE802154 controller libraries in a hosting environment (Zephyr RTOS in current case). Description: @@ -22,19 +22,34 @@ Description: Middlewares/ST/STM32_WPAN/ble/stack/include/ble_std.h Middlewares/ST/STM32_WPAN/ble/stack/include/bleplat.h Middlewares/ST/STM32_WPAN/ble/stack/include/blestack.h - Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/_40nm_reg_files/DWC_ble154combo.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/_40nm_reg_files/_40nm_reg_files/DWC_ble154combo.h Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/bsp.h Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/common_types.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/dtm.h Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/event_manager.h Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/evnt_schdlr_gnrc_if.h Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/hci.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ll_error.h Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ll_intf.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/mac_host_intf.h Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/mem_intf.h Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/os_wrapper.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/platform.h Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/power_table.h Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/pta.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ral.h Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ll_intf_cmn.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/rfd_dev_config.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/crypto.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/error.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/instance.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/logging.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/radio.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/toolchain.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/types.h Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/config/ble_full/ll_fw_config.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/config/ieee_15_4_basic/ll_fw_config.h + Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/config/thread/ll_fw_config.h Middlewares/ST/STM32_WPAN/link_layer/ll_sys/inc/linklayer_plat.h Middlewares/ST/STM32_WPAN/link_layer/ll_sys/inc/ll_sys.h Middlewares/ST/STM32_WPAN/link_layer/ll_sys/src/ll_sys_cs.c @@ -48,6 +63,11 @@ Description: Projects/NUCLEO-WBA65RI/Applications/BLE/BLE_TransparentMode/Core/Inc/app_entry.h Projects/NUCLEO-WBA65RI/Applications/BLE/BLE_TransparentMode/Core/Inc/utilities_conf.h Projects/NUCLEO-WBA65RI/Applications/BLE/BLE_TransparentMode/Core/Inc/main.h + Projects/NUCLEO-WBA65RI/Applications/BLE/Zigbee_OnOff_Client_SED/Core/Inc/app_common.h + Projects/NUCLEO-WBA65RI/Applications/BLE/Zigbee_OnOff_Client_SED/Core/Inc/app_conf.h + Projects/NUCLEO-WBA65RI/Applications/BLE/Zigbee_OnOff_Client_SED/Core/Inc/app_entry.h + Projects/NUCLEO-WBA65RI/Applications/BLE/Zigbee_OnOff_Client_SED/Core/Inc/utilities_conf.h + Projects/NUCLEO-WBA65RI/Applications/BLE/Zigbee_OnOff_Client_SED/Core/Inc/main.h Projects/Common/WPAN/Modules/Flash/rf_timing_synchro.c Projects/Common/WPAN/Modules/Flash/rf_timing_synchro.h Projects/Common/WPAN/Modules/Flash/flash_driver.c @@ -70,14 +90,25 @@ Description: Projects/Common/WPAN/Interfaces/hw_pka_p256.c Projects/Common/WPAN/Modules/Log/log_module.c Projects/Common/WPAN/Modules/Log/log_module.h + Projects/Common/WPAN/Modules/BasicAES/baes.h + Projects/Common/WPAN/Modules/BasicAES/baes_ccm.c + Projects/Common/WPAN/Modules/BasicAES/baes_cmac.c + Projects/Common/WPAN/Modules/BasicAES/baes_ecb.c + Projects/Common/WPAN/Modules/BasicAES/baes_global.h Projects/NUCLEO-WBA65RI/Applications/BLE/BLE_TransparentMode/System/Config/Debug_GPIO/app_debug.h - Projects/NUCLEO-WBA65RI/Applications/BLE/BLE_TransparentMode/System/Config/Debug_GPIO/debug_config.h + Projects/NUCLEO-WBA65RI/Applications/BLE/BLE_TransparentMode/System/Config/Log/log_module_conf.h Projects/NUCLEO-WBA65RI/Applications/BLE/BLE_TransparentMode/STM32_WPAN/Target/power_table.c Projects/NUCLEO-WBA65RI/Applications/BLE/BLE_TransparentMode/STM32_WPAN/Target/bpka.c Projects/NUCLEO-WBA65RI/Applications/BLE/BLE_TransparentMode/STM32_WPAN/Target/bpka.h Projects/NUCLEO-WBA65RI/Applications/BLE/BLE_TransparentMode/STM32_WPAN/Target/linklayer_plat.c Projects/NUCLEO-WBA65RI/Applications/BLE/BLE_TransparentMode/STM32_WPAN/Target/ll_sys_if.c Projects/NUCLEO-WBA65RI/Applications/BLE/BLE_TransparentMode/STM32_WPAN/Target/ll_sys_if.h + Projects/NUCLEO-WBA65RI/Applications/BLE/Zigbee_OnOff_Client_SED/System/Config/Debug_GPIO/debug_config.h + Projects/NUCLEO-WBA65RI/Applications/BLE/Zigbee_OnOff_Client_SED/System/Config/Log/log_module_conf.h + Projects/NUCLEO-WBA65RI/Applications/BLE/Zigbee_OnOff_Client_SED/STM32_WPAN/Target/power_table.c + Projects/NUCLEO-WBA65RI/Applications/BLE/Zigbee_OnOff_Client_SED/STM32_WPAN/Target/linklayer_plat.c + Projects/NUCLEO-WBA65RI/Applications/BLE/Zigbee_OnOff_Client_SED/STM32_WPAN/Target/ll_sys_if.c + Projects/NUCLEO-WBA65RI/Applications/BLE/Zigbee_OnOff_Client_SED/STM32_WPAN/Target/ll_sys_if.h Utilities/trace/adv_trace/stm32_adv_trace.h Utilities/misc/stm32_mem.h Utilities/tim_serv/stm32_timer.h diff --git a/lib/stm32wba/STM32_WPAN/CMakeLists.txt b/lib/stm32wba/STM32_WPAN/CMakeLists.txt new file mode 100644 index 000000000..c5f66263b --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/CMakeLists.txt @@ -0,0 +1,33 @@ +# Copyright (c) 2025 STMicroelectronics +# +# SPDX-License-Identifier: Apache-2.0 +if(CONFIG_BT_STM32WBA) + zephyr_compile_definitions( -DBLE ) +endif() +if(CONFIG_IEEE802154_STM32WBA) + zephyr_compile_definitions( -DMAC ) +endif() + +if(CONFIG_BT_STM32WBA) + zephyr_include_directories(ble/stack/include) + zephyr_include_directories(ble/stack/include/auto) + zephyr_include_directories(link_layer/ll_cmd_lib/config/ble_full) +endif() +if(CONFIG_IEEE802154_STM32WBA) + zephyr_include_directories(ieee802154) + if(CONFIG_OPENTHREAD) + zephyr_include_directories(link_layer/ll_cmd_lib/config/thread) + else() + zephyr_include_directories(link_layer/ll_cmd_lib/config/ieee_15_4_basic) + endif() + zephyr_include_directories(link_layer/ll_cmd_lib/inc/ot_inc) +endif() +zephyr_include_directories(inc) +zephyr_include_directories(link_layer/ll_cmd_lib/inc) +zephyr_include_directories(link_layer/ll_cmd_lib/inc/_40nm_reg_files) +zephyr_include_directories(link_layer/ll_sys/inc) + +zephyr_sources(link_layer/ll_sys/src/ll_sys_cs.c) +zephyr_sources(link_layer/ll_sys/src/ll_sys_dp_slp.c) +zephyr_sources(link_layer/ll_sys/src/ll_sys_intf.c) +zephyr_sources(link_layer/ll_sys/src/ll_sys_startup.c) diff --git a/lib/stm32wba/STM32_WPAN/ieee802154/stm32wba_802154.h b/lib/stm32wba/STM32_WPAN/ieee802154/stm32wba_802154.h new file mode 100644 index 000000000..9986aa911 --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/ieee802154/stm32wba_802154.h @@ -0,0 +1,506 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of STMicroelectronics nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** + * @defgroup STM32WBA 802.15.4 radio driver + * @{ + * + */ + +#ifndef STM32WBA_802154_H_ +#define STM32WBA_802154_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Errors reported during the frame transmission. + */ +typedef uint8_t stm32wba_802154_ral_tx_error_t; + +#define STM32WBA_802154_RAL_TX_ERROR_NONE 0x00 // !< There is no transmit error. +#define STM32WBA_802154_RAL_TX_ERROR_BUSY_CHANNEL 0x0F // !< CCA reported busy channel before the transmission. +#define STM32WBA_802154_RAL_TX_ERROR_NO_MEM 0x03 // !< No receive buffer is available to receive an ACK. +#define STM32WBA_802154_RAL_TX_ERROR_NO_ACK 0x0E // !< ACK frame was not received during the timeout period. +#define STM32WBA_802154_RAL_TX_ERROR_ABORTED 0x0B // !< Procedure was aborted by another operation. + +/** + * @brief Possible errors during the frame reception. + */ +typedef uint8_t stm32wba_802154_ral_rx_error_t; + +#define STM32WBA_802154_RAL_RX_ERROR_NONE 0x00 // !< There is no receive error. +#define STM32WBA_802154_RAL_RX_ERROR_NO_BUFFERS 0x03 // !< Not enough buffers. + +/** + * @brief Structure with transmit request metadata for simple transmission request. + */ +typedef struct +{ + bool is_secured; // !< If the frame to be transmitted is already secured (in the sense of IEEE 802.15.4 security operations). + bool dynamic_data_is_set; // !< If dynamic data of the frame to be transmitted is set. + bool cca; // !< If the driver is to perform a CCA procedure before transmission. + int8_t tx_power; // !< Transmission power in dBm + uint8_t tx_channel; // !< Transmission channel +} stm32wba_802154_ral_transmit_metadata_t; + +/** + * @brief Structure that holds transmission result metadata. + */ +typedef struct +{ + bool is_secured; // !< If the transmitted frame was secured (in the sense of IEEE 802.15.4 security operations). + bool dynamic_data_is_set; // !< If dynamic data of the transmitted frame was set. + uint8_t * p_ack; // !< p_ack is a pointer to a buffer that contains only the received ACK payload (PSDU excluding FCS). + // If ACK was not requested or requested but not received, @ref p_ack is set to NULL. + uint8_t length; // !< Length of the received ACK payload or 0 if @ref p_ack is NULL. + int8_t power; // !< RSSI of the received frame or 0 if @ref p_ack is NULL. + uint8_t lqi; // !< LQI of the received frame or 0 if @ref p_ack is NULL. + uint64_t time; // !< Timestamp taken when the last symbol of ACK is received. If @ref p_ack is NULL, this field is set to 0, but is considered invalid. +} stm32wba_802154_ral_transmit_done_metadata_t; + +/** + * @brief Structure that holds receive result metadata. + */ +typedef struct +{ + uint8_t length; // !< Length of the received ACK payload. + int8_t power; // !< RSSI of the received frame. + uint8_t lqi; // !< LQI of the received frame. + uint64_t time; // !< Timestamp taken when the last symbol is received. + uint8_t error; // !< Error returned (if any) +} stm32wba_802154_ral_receive_done_metadata_t; + +/** + * @brief stm32wba_802154_ral_error_t - Radio Abstraction Layer error/status codes + * + * Enumerates the return codes used by the ST Radio Abstraction Layer (RAL) + * to indicate the result of API calls. Values represent success, specific + * failure conditions and transient states (for example: timeout, busy, + * invalid parameter). Callers should inspect returned stm32wba_802154_ral_error_t values + * to determine appropriate recovery or error handling actions. + */ +typedef enum stm32wba_802154_ral_error_t +{ + STM32WBA_802154_RAL_ERROR_NONE = 0, // !< No error. + STM32WBA_802154_RAL_ERROR_FAILED = -1, // !< Operational failed. + STM32WBA_802154_RAL_ERROR_DROP = -2, // !< Message was dropped. + STM32WBA_802154_RAL_ERROR_NO_BUFS = -3, // !< Insufficient buffers. + STM32WBA_802154_RAL_ERROR_BUSY = -4, // !< Service is busy and could not service the operation. + STM32WBA_802154_RAL_ERROR_INVALID_ARGS = -5, // !< Input arguments are invalid. + STM32WBA_802154_RAL_ERROR_SECURITY = -6, // !< Security checks failed. + STM32WBA_802154_RAL_ERROR_NO_ADDRESS = -7, // !< Address is not in the source match table. + STM32WBA_802154_RAL_ERROR_ABORT = -8, // !< Operation was aborted. + STM32WBA_802154_RAL_ERROR_NOT_IMPLEMENTED = -9, // !< Function or method is not implemented. + STM32WBA_802154_RAL_ERROR_INVALID_STATE = -10, // !< Cannot complete due to invalid state. + STM32WBA_802154_RAL_ERROR_NO_ACK = -11, // !< No acknowledgment was received after macMaxFrameRetries (IEEE 802.15.4-2006). + STM32WBA_802154_RAL_ERROR_CHANNEL_ACCESS_FAILURE = -12, // !< A transmission could not take place due to activity on the channel, i.e., the CSMA-CA mechanism has failed (IEEE 802.15.4-2006). + STM32WBA_802154_RAL_ERROR_FCS = -13, // !< FCS check failure while receiving. + STM32WBA_802154_RAL_ERROR_NO_FRAME_RECEIVED = -14, // !< No frame received. + STM32WBA_802154_RAL_ERROR_INVALID_SOURCE_ADDRESS = -15, // !< Received a frame from an invalid source address. + STM32WBA_802154_RAL_ERROR_DESTINATION_ADDRESS_FILTERED = -16, // !< Received a frame filtered by the destination address check. + STM32WBA_802154_RAL_ERROR_NOT_FOUND = -17, // !< The requested item could not be found. + STM32WBA_802154_RAL_ERROR_GENERIC = -18, // !< Generic error. + STM32WBA_802154_RAL_ERROR_UNKNOWN = -255 // !< Unknown error. +} stm32wba_802154_ral_error_t; + + +/** + * @brief Initializes the 802.15.4 driver. + * + * This function initializes the RADIO peripheral in the @ref RADIO_STATE_SLEEP state. + * + * @note This function is to be called once, before any other functions from this module. + * Only the functions setting the configuration can be called before this call. + */ +void stm32wba_802154_ral_init(void); + +/** + * @brief Sets the channel on which the radio is to operate. + * + * @param[in] channel Channel number (11-26). + */ +void stm32wba_802154_ral_set_channel(uint8_t channel); + +/** + * @brief Gets the channel on which the radio operates. + * + * @returns Channel number (11-26). + */ +uint8_t stm32wba_802154_ral_channel_get(void); + +/** + * @brief Sets the transmit power. + * + * @note The driver recalculates the requested value to the nearest value accepted by the hardware. + * The calculation result is rounded up. + * + * @param[in] power Transmit power in dBm. + */ +void stm32wba_802154_ral_tx_power_set(int8_t power); + +/** + * @brief Gets the currently set transmit power. + * + * @param[out] aPower Pointer to the variable where the transmit power will be stored. + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_tx_power_get(int8_t *aPower); + +/** + * @brief Gets the current time. + * + * @returns Current time in microseconds. + */ +uint64_t stm32wba_802154_ral_time_get(void); + +/** + * @brief Sets the PAN ID used by the device. + * + * @param[in] pan_id PAN ID. + * + * This function makes a copy of the PAN ID. + */ +void stm32wba_802154_ral_pan_id_set(const uint16_t pan_id); + +/** + * @brief Sets the extended address of the device. + * + * @param[in] aExtAddress Pointer to the extended address (8 bytes, little-endian). + * + * This function makes a copy of the address. + */ +void stm32wba_802154_ral_extended_address_set(const uint8_t * aExtAddress); + +/** + * @brief Sets the short address of the device. + * + * @param[in] short_address Short address. + * + * This function makes a copy of the address. + */ +void stm32wba_802154_ral_short_address_set(const uint16_t short_address); + +/** + * @brief Get the EUI 64 bits of the device. + * + * @param[in] p_eui64 Pointer to the EUI 64 bits. + * + * This function makes a copy of the address. + */ +void stm32wba_802154_ral_eui64_get(uint8_t *p_eui64); + +/** + * @brief Changes the radio state to the @ref RADIO_STATE_SLEEP state. + * + * The sleep state is the lowest power state. In this state, the radio cannot transmit or receive + * frames. It is the only state in which the driver releases the high-frequency clock and does not + * request timeslots from a radio arbiter. + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_sleep(void); + +/** + * @brief Changes the radio state to @ref RADIO_STATE_RX. + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_receive(void); + +/** + * @brief Changes the radio state to transmit. + * + * @param[in] aData Pointer to the data to be transmitted. + * @param[in] length Length of the data to be transmitted. + * @param[in] aMetadata Pointer to the metadata for the transmission. + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_transmit(uint8_t *aData, + uint8_t length, + const stm32wba_802154_ral_transmit_metadata_t *aMetadata); + +/** + * @brief Changes the radio state to energy detection. + * + * In the energy detection state, the radio detects the maximum energy for a given time. + * The result of the detection is reported to the higher layer by @ref stm32wba_802154_energy_scan_done. + * + * @note @ref stm32wba_802154_energy_scan_done can be called before this function returns a result. + * @note Performing the energy detection procedure can take longer than requested in @p aScanDuration. + * The procedure is performed only during the timeslots granted by a radio arbiter. + * It can be interrupted by other protocols using the radio hardware. If the procedure is + * interrupted, it is automatically continued and the sum of time periods during which the + * procedure is carried out is not less than the requested @p aScanDuration. + * + * @param[in] aScanDuration The duration, in milliseconds, for the channel to be scanned. + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_energy_detection(uint16_t aScanDuration); + +/** + * @brief Changes the radio state to @ref RADIO_STATE_CCA. + * + * @note @ref stm32wba_802154_cca_done can be called before this function returns a result. + * + * In the CCA state, the radio verifies if the channel is clear. The result of the verification is + * reported to the higher layer by @ref stm32wba_802154_cca_done. + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_cca(void); + +/** + * @brief Enables or disables the promiscuous radio mode. + * + * @note The promiscuous mode is disabled by default. + * + * In the promiscuous mode, the driver notifies the higher layer that it received any frame + * (regardless frame type or destination address). + * In normal mode (not promiscuous), the higher layer is not notified about ACK frames and frames + * with unknown type. Also, frames with a destination address not matching the device address are + * ignored. + * + * @param[in] enabled If the promiscuous mode is to be enabled. + */ +void stm32wba_802154_ral_promiscuous_set(bool enabled); + +/** + * @brief Configures the device as the PAN coordinator. + * + * @note That information is used for packet filtering. + * + * @param[in] enabled The radio is configured as the PAN coordinator. + */ +void stm32wba_802154_ral_pan_coord_set(bool enabled); + +/** + * @brief Enables or disables setting a pending bit in automatically transmitted ACK frames. + * + * @note Setting a pending bit in automatically transmitted ACK frames is enabled by default. + * + * The radio driver automatically sends ACK frames in response frames destined for this node with + * the ACK Request bit set. The pending bit in the ACK frame can be set or cleared regarding data + * in the indirect queue destined for the ACK destination. + * + * If setting a pending bit in ACK frames is disabled, the pending bit in every ACK frame is set. + * If setting a pending bit in ACK frames is enabled, the radio driver checks if there is data + * in the indirect queue destined for the ACK destination. If there is no such data, + * the pending bit is cleared. + * + * @note Due to the ISR latency, the radio driver might not be able to verify if there is data + * in the indirect queue before ACK is sent. In this case, the pending bit is set. + * + * @param[in] aEnable If setting a pending bit in ACK frames is enabled. + */ +void stm32wba_802154_ral_auto_pending_bit_set(bool aEnable); + +/** + * @brief Adds the short address of a peer node to the pending bit list. + * + * @note This function makes a copy of the given address. + * + * @param[in] aShortAddress The short address of the node. + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_pending_bit_for_short_addr_set(const uint16_t aShortAddress); + +/** + * @brief Adds the extended address of a peer node to the pending bit list. + * + * @note This function makes a copy of the given address. + * + * @param[in] aExtAddress Array of bytes containing the address of the node (little-endian). + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_pending_bit_for_ext_addr_set(const uint8_t * aExtAddress); + +/** + * @brief Removes short address of a peer node from the pending bit list. + * + * @param[in] aShortAddress The short address of the node. + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_pending_bit_for_short_addr_clear(const uint16_t aShortAddress); + +/** + * @brief Removes extended address of a peer node from the pending bit list. + * + * @param[in] aExtAddress Array of bytes containing the address of the node (little-endian). + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_pending_bit_for_ext_addr_clear(const uint8_t * aExtAddress); + +/** + * @brief Removes all short addresses from the pending bit list. + * + */ +void stm32wba_802154_ral_pending_bit_for_short_addr_reset(void); + +/** + * @brief Removes all extended addresses from the pending bit list. + + */ +void stm32wba_802154_ral_pending_bit_for_ext_addr_reset(void); + +/** + * @brief Sets the maximum number of frame retries. + * + * @param[in] max_retries The maximum number of frame retries. + */ +void stm32wba_802154_ral_set_max_frame_retries(uint8_t max_retries); + +/** + * @brief Enables or disables CSMA (Carrier Sense Multiple Access). + * + * @param[in] csma_en Set to 1 to enable CSMA, 0 to disable. + */ +void stm32wba_802154_ral_set_csma_en(uint8_t csma_en); + +/** + * @brief Sets the maximum number of CSMA frame retries. + * + * @param[in] max_retries The maximum number of CSMA frame retries. + */ +void stm32wba_802154_ral_set_max_csma_frame_retries(uint8_t max_retries); + +/** + * @brief Sets the minimum value of the CSMA backoff exponent. + * + * @param[in] min_be The minimum backoff exponent. + */ +void stm32wba_802154_ral_set_min_csma_be(uint8_t min_be); + +/** + * @brief Sets the maximum value of the CSMA backoff exponent. + * + * @param[in] max_be The maximum backoff exponent. + */ +void stm32wba_802154_ral_set_max_csma_be(uint8_t max_be); + +/** + * @brief Sets the maximum number of CSMA backoffs. + * + * @param[in] max_backoff The maximum number of CSMA backoffs. + */ +void stm32wba_802154_ral_set_max_csma_backoff(uint8_t max_backoff); + +/** + * @brief Gets the current CCA energy detection threshold. + * + * @param[out] cca_thr Pointer to store the current CCA energy detection threshold. + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_get_cca_energy_detect_threshold(int8_t *cca_thr); + +/** + * @brief Sets the CCA energy detection threshold. + * + * @param[in] cca_thr The CCA energy detection threshold to set. + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_set_cca_energy_detect_threshold(int8_t cca_thr); + +/** + * @brief Enables or disables continuous reception mode. + * + * @param[in] enable True to enable, false to disable. + */ +void stm32wba_802154_ral_set_continuous_reception(bool aEnable); + +/** + * @brief Enables or disables implicit broadcast mode. + * + * @param[in] enable True to enable, false to disable. + */ +void stm32wba_802154_ral_set_implicitbroadcast(bool ImplicitBroadcast); + +/** + * @brief Resets the STM32WBA radio. + * + * This function performs a reset of the radio layer, restoring it to its default state. + * It can be used to recover from unexpected states or errors. + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_radio_reset(void); + +/** + * @brief Generates random number. + * + * This function generates a random number using the specified parameters. + * + * @param[out] ptr_rnd Pointer to store the generated random number. + * @param[in] len Length of the random number to generate. + * @param[in] check_cont_rx Indicates whether to check for continuous reception. + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_mac_gen_rnd_num(uint8_t *ptr_rnd, uint16_t len, uint8_t check_cont_rx); + + +/** + * + * @brief enable/disable antenna diversity + * + * @param enable[in] : enable:1 / disable:0 + * + * @returns STM32WBA_802154_RAL_ERROR_NONE on success, or an error code on failure. + */ +stm32wba_802154_ral_error_t stm32wba_802154_ral_set_ant_div_enable(uint8_t enable); + + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32WBA_802154_H_ */ + +/** @} */ + diff --git a/lib/stm32wba/STM32_WPAN/ieee802154/stm32wba_802154_callbacks.h b/lib/stm32wba/STM32_WPAN/ieee802154/stm32wba_802154_callbacks.h new file mode 100644 index 000000000..5e053251c --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/ieee802154/stm32wba_802154_callbacks.h @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of STMicroelectronics nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +/**@file stm32wba_802154_callbacks.h + * @brief Provides function prototypes required by STM32WBA 802.15.4 Radio Driver + * + * Functions whose prototypes are defined in this file are to be implemented + * by an application using the STM32WBA 802.15.4 Radio Driver. + */ + +#ifndef STM32WBA_802154_CALLBACKS_H_ +#define STM32WBA_802154_CALLBACKS_H_ + +#include +#include + +#include "stm32wba_802154.h" + +/** + * @struct stm32wba_802154_ral_cbk_dispatch_tbl + * + * @brief structure of all callback functions used to notify 802.15.4 Zephyr driver after specific event compeletion + */ +struct stm32wba_802154_ral_cbk_dispatch_tbl{ + /** + * @brief callback function called after the end of Energy detection operation + * + * @param rssiResult The result for ED operation which is RSSI value + * + * @retval none + */ + void (*stm32wba_802154_ral_cbk_ed_scan_done)(int8_t rssiResult); + + /** + * @brief callback function called after the end of transmission operation + * + * @param p_frame Pointer to the transmitted frame. + * @param error Transmission error status of type stm32wba_802154_tx_error_t. + * Indicates whether the transmission was successful or if an + * error occurred. + * @param p_metadata Pointer to metadata of type stm32wba_802154_transmit_done_metadata_t, + * containing additional information about the transmission. + * + * @retval none + */ + void (*stm32wba_802154_ral_cbk_tx_done)(uint8_t * p_frame, stm32wba_802154_ral_tx_error_t error, const stm32wba_802154_ral_transmit_done_metadata_t *p_metadata); + + /** + * @brief callback function called after the end of Reception operation + * + * @param p_buffer Pointer to the buffer containing the received data. + * @param p_metadata Pointer to the metadata associated with the received frame. + * + * @retval none + */ + void (*stm32wba_802154_ral_cbk_rx_done)(uint8_t * p_buffer, stm32wba_802154_ral_receive_done_metadata_t *p_metadata); + + /** + * @brief callback function notifies that the CCA procedure has finished. + * + * @param[in] error If failed, reason of the failure. + * + * @retval none + */ + void (*stm32wba_802154_ral_cbk_cca_done)(uint8_t error); + + /** + * @brief callback function notifies about the start of the ACK frame transmission. + * + * @param[in] ack_fpb Frame pending bit in the ACK frame. + * @param[in] ack_seb Security enabled bit in the ACK frame. + * + * @retval none + */ + void (*stm32wba_802154_ral_cbk_tx_ack_started)(bool ack_fpb, bool ack_seb); +}; + + +/** + * @brief This function called from upper layer init function (mac_init in case of mac integration e.g. Zigbee stack) + * to register the upper layer callback functions + * + * @param ptr_cbk_dispatch_tbl pointer to callback function to be registered + * + * @retval none + * + */ +void stm32wba_802154_ral_call_back_funcs_init(struct stm32wba_802154_ral_cbk_dispatch_tbl * ptr_cbk_dispatch_tbl); + + +#endif /* STM32WBA_802154_CALLBACKS_H_ */ + +/** @} */ + diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/config/ieee_15_4_basic/ll_fw_config.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/config/ieee_15_4_basic/ll_fw_config.h new file mode 100644 index 000000000..b86618434 --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/config/ieee_15_4_basic/ll_fw_config.h @@ -0,0 +1,235 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/ll_fw_config.h#1 $*/ +/** + ******************************************************************************** + * @file ll_fw_config.h + * @brief This file contains the major configurations to the BLE controller. + ****************************************************************************** + * @copy + * Synopsys MIT License: + * Copyright (c) 2020-Present Synopsys, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of the software and + * associated documentation files (the “Software”), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. + * + * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE + * ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * */ +#ifndef INCLUDE_LL_FW_CONFIG_H +#define INCLUDE_LL_FW_CONFIG_H + +/*************************** General Configuration *********************************/ +#ifndef SUPPORT_GNRC_SCHDLR_IF +#define SUPPORT_GNRC_SCHDLR_IF 1 /* Enable\Disable event EXTRNL_GNRC in Ble event manager. Enable:1 - Disable:0 */ +#endif /* SUPPORT_GNRC_SCHDLR_IF */ + +/*************************** BLE Configuration *************************************/ +/*Configurations of BLE will apply only when BLE is enabled*/ +/* Roles configurations */ +#ifndef SUPPORT_EXPLCT_OBSERVER_ROLE +#define SUPPORT_EXPLCT_OBSERVER_ROLE 0 /* Enable\Disable Explicit observer role. Enable:1 - Disable:0 */ +#endif /* SUPPORT_EXPLCT_OBSERVER_ROLE */ + +#ifndef SUPPORT_EXPLCT_BROADCASTER_ROLE +#define SUPPORT_EXPLCT_BROADCASTER_ROLE 0 /* Enable\Disable Explicit broadcaster role. Enable:1 - Disable:0 */ +#endif /* SUPPORT_EXPLCT_BROADCASTER_ROLE */ + +#ifndef SUPPORT_MASTER_CONNECTION +#define SUPPORT_MASTER_CONNECTION 0 /* Enable\Disable Master connection role. Enable:1 - Disable:0 */ +#endif /* SUPPORT_MASTER_CONNECTION */ + +#ifndef SUPPORT_SLAVE_CONNECTION +#define SUPPORT_SLAVE_CONNECTION 0 /* Enable\Disable Slave connection role. Enable:1 - Disable:0 */ +#endif /* SUPPORT_SLAVE_CONNECTION */ + +/* Standard features configurations */ +#ifndef SUPPORT_LE_ENCRYPTION +#define SUPPORT_LE_ENCRYPTION 0 /* Enable\Disable Encryption feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_ENCRYPTION */ + +#ifndef SUPPORT_PRIVACY +#define SUPPORT_PRIVACY 0 /* Enable\Disable Privacy feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_PRIVACY */ + +#ifndef SUPPORT_LE_EXTENDED_ADVERTISING +#define SUPPORT_LE_EXTENDED_ADVERTISING 0 /* Enable\Disable Extended advertising feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_EXTENDED_ADVERTISING */ + +#ifndef SUPPORT_LE_PERIODIC_ADVERTISING +#define SUPPORT_LE_PERIODIC_ADVERTISING 0 /* Enable\Disable Periodic advertising feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_PERIODIC_ADVERTISING */ + +#ifndef SUPPORT_LE_POWER_CLASS_1 +#define SUPPORT_LE_POWER_CLASS_1 0 /* Enable\Disable Low power class 1 feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_POWER_CLASS_1 */ + +#ifndef SUPPORT_AOA_AOD +#define SUPPORT_AOA_AOD 0 /* Enable\Disable AOA_AOD feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_AOA_AOD */ + +#ifndef SUPPORT_PERIODIC_SYNC_TRANSFER +#define SUPPORT_PERIODIC_SYNC_TRANSFER 0 /* Enable\Disable PAST feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_PERIODIC_SYNC_TRANSFER */ + +#ifndef SUPPORT_SLEEP_CLOCK_ACCURCY_UPDATES +#define SUPPORT_SLEEP_CLOCK_ACCURCY_UPDATES 0 /* Enable\Disable Sleep Clock Accuracy Updates Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_SLEEP_CLOCK_ACCURCY_UPDATES */ + +#ifndef SUPPORT_CONNECTED_ISOCHRONOUS +#define SUPPORT_CONNECTED_ISOCHRONOUS 0 /* Enable\Disable Connected Isochronous Channel Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_CONNECTED_ISOCHRONOUS */ + +#ifndef SUPPORT_BRD_ISOCHRONOUS +#define SUPPORT_BRD_ISOCHRONOUS 0 /* Enable\Disable Broadcast Isochronous Channel Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_BRD_ISOCHRONOUS */ + +#ifndef SUPPORT_SYNC_ISOCHRONOUS +#define SUPPORT_SYNC_ISOCHRONOUS 0 /* Enable\Disable Broadcast Isochronous Synchronizer Channel Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_SYNC_ISOCHRONOUS */ + +#ifndef SUPPORT_LE_POWER_CONTROL +#define SUPPORT_LE_POWER_CONTROL 0 /* Enable\Disable LE Power Control Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_POWER_CONTROL */ + +#ifndef SUPPORT_CHANNEL_CLASSIFICATION +#define SUPPORT_CHANNEL_CLASSIFICATION 0 +#endif /* SUPPORT_CHANNEL_CLASSIFICATION */ + +#ifndef SUPPORT_PERIODIC_ADV_ADI +#define SUPPORT_PERIODIC_ADV_ADI 0 +#endif /* SUPPORT_PERIODIC_ADV_ADI */ + +#ifndef SUPPORT_LE_ENHANCED_CONN_UPDATE +#define SUPPORT_LE_ENHANCED_CONN_UPDATE 0 +#endif /* SUPPORT_LE_ENHANCED_CONN_UPDATE */ + +#ifndef SUPPORT_CSSA +#define SUPPORT_CSSA 0 /* Enable\Disable Coding Selection Scheme on Advertising Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_CSSA */ + +#ifndef SUPPORT_LE_PAWR_ADVERTISER_ROLE +#define SUPPORT_LE_PAWR_ADVERTISER_ROLE 0 /* Enable\Disable PAwR Advertiser role. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_PAWR_ADVERTISER_ROLE */ + +#ifndef SUPPORT_LE_PAWR_SYNC_ROLE +#define SUPPORT_LE_PAWR_SYNC_ROLE 0 /* Enable\Disable PAwR Synchronizer role. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_PAWR_SYNC_ROLE */ + +#ifndef SUPPORT_CHANNEL_SOUNDING +#define SUPPORT_CHANNEL_SOUNDING 0 /* Enable\Disable Channel Sounding Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_CHANNEL_SOUNDING */ + +#ifndef SUPPORT_FRAME_SPACE_UPDATE +#define SUPPORT_FRAME_SPACE_UPDATE 0 /* Enable\Disable Frame Space Update Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_FRAME_SPACE_UPDATE */ + +#ifndef SUPPORT_EXT_FEATURE_SET +#define SUPPORT_EXT_FEATURE_SET 0 /* Enable\Disable Extended Feature Set Exchange. Enable:1 - Disable:0 */ +#endif /* SUPPORT_EXT_FEATURE_SET */ + +#ifndef SUPPORT_ISO_UNSEG_MODE +#define SUPPORT_ISO_UNSEG_MODE 0 /* Enable\Disable Unsegmented Mode for Framed ISO PDUs. Enable: 1 - Disable: 0*/ +#endif /* SUPPORT_ISO_UNSEG_MODE */ + +#ifndef SUPPORT_LE_ADVERTISERS_MONITORING +#define SUPPORT_LE_ADVERTISERS_MONITORING 0 /* Enable\Disable Advertisers Monitoring Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_ADVERTISERS_MONITORING */ + +/* Capabilities configurations */ +#ifndef MAX_NUM_CNCRT_STAT_MCHNS +#define MAX_NUM_CNCRT_STAT_MCHNS 0 /* Set maximum number of states the controller can support */ +#endif /* MAX_NUM_CNCRT_STAT_MCHNS */ + +#ifndef USE_NON_ACCURATE_32K_SLEEP_CLK +#define USE_NON_ACCURATE_32K_SLEEP_CLK 1 /* Allow to drive the sleep clock by sources other than the default crystal oscillator source.*/ + /*LL can use crystal oscillator or RTC or RCO to drive the sleep clock.This selection is done via "DEFAULT_SLEEP_CLOCK_SOURCE" macro. */ +#endif /* USE_NON_ACCURATE_32K_SLEEP_CLK */ + +/* Non-standard features configurations */ +#ifndef NUM_OF_CTSM_EMNGR_HNDLS +#define NUM_OF_CTSM_EMNGR_HNDLS 0 /* Number of custom handles in event manager to be used for app specific needs */ +#endif /* NUM_OF_CTSM_EMNGR_HNDLS */ + +#ifndef SUPPORT_AUGMENTED_BLE_MODE +#define SUPPORT_AUGMENTED_BLE_MODE 0 /* Enable\Disable Augmented BLE Support. Enable:1 - Disable:0 */ +#endif /* SUPPORT_AUGMENTED_BLE_MODE */ + +#ifndef SUPPORT_PTA +#define SUPPORT_PTA 1 /* Enable\Disable PTA Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_PTA */ + +#ifndef SUPPORT_CONFIGURABLE_GAIN_FIX +#define SUPPORT_CONFIGURABLE_GAIN_FIX 0 /* Enable\Disable configurable gain fix support */ +#endif /* SUPPORT_CONFIGURABLE_GAIN_FIX */ + +#ifndef CHECK_ANY_MISSED_EVENT_ON_DEEP_SLEEP_EXIT +#define CHECK_ANY_MISSED_EVENT_ON_DEEP_SLEEP_EXIT 1 /* Enable\Disable calling event scheduler handler function at the end of deep sleep exit*/ +#endif /* CHECK_ANY_MISSED_EVENT_ON_DEEP_SLEEP_EXIT */ + +#ifndef LL_BASIC +#define LL_BASIC 0 +#endif /* LL_BASIC */ + +/*************************** MAC Configuration *************************************/ +/*Configurations of MAC will apply only when MAC is enabled*/ +#ifndef FFD_DEVICE_CONFIG +#define FFD_DEVICE_CONFIG 1 /* Enable\Disable FFD:1 - RFD:0 */ +#endif /* FFD_DEVICE_CONFIG */ + +#ifdef RFD_DEVICE_CONFIG +#undef FFD_DEVICE_CONFIG +#define FFD_DEVICE_CONFIG 0 /* Enable\Disable FFD:1 - RFD:0 */ +#endif + +#ifndef RAL_NUMBER_OF_INSTANCE +#define RAL_NUMBER_OF_INSTANCE 1 /* The Number of RAL instances supported */ +#endif /* RAL_NUMBER_OF_INSTANCE */ + +#ifndef MAX_NUMBER_OF_INDIRECT_DATA +#define MAX_NUMBER_OF_INDIRECT_DATA 10 /* The maximum number of supported indirect data buffers */ +#endif /* MAX_NUMBER_OF_INDIRECT_DATA */ + +#ifndef SUPPORT_OPENTHREAD_1_2 +#define SUPPORT_OPENTHREAD_1_2 0 /* Enable / disable FW parts related to new features introduced in openthread 1.2*/ +#endif /* SUPPORT_OPENTHREAD_1_2 */ + +#ifndef SUPPORT_SEC +#define SUPPORT_SEC 0 /* The MAC Security Supported : 1 - Not Supported:0 */ +#endif /* SUPPORT_SEC */ + +#ifndef RADIO_CSMA +#define RADIO_CSMA 1 /* Enable\Disable CSMA Algorithm in Radio Layer, Must be Enabled if MAC_LAYER_BUILD */ +#endif /* RADIO_CSMA */ + +#ifndef SUPPORT_ANT_DIV +#define SUPPORT_ANT_DIV 1 /* Enable/Disable Antenna Diversity Feature */ +#endif /* SUPPORT_ANT_DIV */ + +#ifndef SUPPORT_A_MAC +#define SUPPORT_A_MAC 1 +#endif /* SUPPORT_A_MAC */ +#ifndef SMPL_PRTCL_TEST_ENABLE +#define SMPL_PRTCL_TEST_ENABLE 0 +#endif /* SMPL_PRTCL_TEST_ENABLE */ + +#ifndef IEEE_EUI64_VENDOR_SPECIFIC_FUNC +#define IEEE_EUI64_VENDOR_SPECIFIC_FUNC 1 /* Comment to disable EUI-64 vendor specific function, in this case EUI-64 is not unique */ +#endif /* IEEE_EUI64_VENDOR_SPECIFIC_FUNC */ + +/*************************** Zigbee Configuration **********************************/ +#ifndef SUPPORT_ZIGBEE_PHY_CERTIFICATION +#define SUPPORT_ZIGBEE_PHY_CERTIFICATION 0 /* Enable support of hci command required to implement zigbee phy Test cases Enable:1 - Disable:0 */ +#endif /* SUPPORT_ZIGBEE_PHY_CERTIFICATION */ + +#endif /* INCLUDE_LL_FW_CONFIG_H */ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/config/thread/ll_fw_config.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/config/thread/ll_fw_config.h new file mode 100644 index 000000000..07d98acfa --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/config/thread/ll_fw_config.h @@ -0,0 +1,229 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/ll_fw_config.h#1 $*/ +/** + ******************************************************************************** + * @file ll_fw_config.h + * @brief This file contains the major configurations to the BLE controller. + ****************************************************************************** + * @copy + * Synopsys MIT License: + * Copyright (c) 2020-Present Synopsys, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of the software and + * associated documentation files (the “Software”), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. + * + * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE + * ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * */ +#ifndef INCLUDE_LL_FW_CONFIG_H +#define INCLUDE_LL_FW_CONFIG_H + +/*************************** General Configuration *********************************/ +#ifndef SUPPORT_GNRC_SCHDLR_IF +#define SUPPORT_GNRC_SCHDLR_IF 1 /* Enable\Disable event EXTRNL_GNRC in Ble event manager. Enable:1 - Disable:0 */ +#endif /* SUPPORT_GNRC_SCHDLR_IF */ + +/*************************** BLE Configuration *************************************/ +/*Configurations of BLE will apply only when BLE is enabled*/ +/* Roles configurations */ +#ifndef SUPPORT_EXPLCT_OBSERVER_ROLE +#define SUPPORT_EXPLCT_OBSERVER_ROLE 0 /* Enable\Disable Explicit observer role. Enable:1 - Disable:0 */ +#endif /* SUPPORT_EXPLCT_OBSERVER_ROLE */ + +#ifndef SUPPORT_EXPLCT_BROADCASTER_ROLE +#define SUPPORT_EXPLCT_BROADCASTER_ROLE 0 /* Enable\Disable Explicit broadcaster role. Enable:1 - Disable:0 */ +#endif /* SUPPORT_EXPLCT_BROADCASTER_ROLE */ + +#ifndef SUPPORT_MASTER_CONNECTION +#define SUPPORT_MASTER_CONNECTION 0 /* Enable\Disable Master connection role. Enable:1 - Disable:0 */ +#endif /* SUPPORT_MASTER_CONNECTION */ + +#ifndef SUPPORT_SLAVE_CONNECTION +#define SUPPORT_SLAVE_CONNECTION 0 /* Enable\Disable Slave connection role. Enable:1 - Disable:0 */ +#endif /* SUPPORT_SLAVE_CONNECTION */ + +/* Standard features configurations */ +#ifndef SUPPORT_LE_ENCRYPTION +#define SUPPORT_LE_ENCRYPTION 0 /* Enable\Disable Encryption feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_ENCRYPTION */ + +#ifndef SUPPORT_PRIVACY +#define SUPPORT_PRIVACY 0 /* Enable\Disable Privacy feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_PRIVACY */ + +#ifndef SUPPORT_LE_EXTENDED_ADVERTISING +#define SUPPORT_LE_EXTENDED_ADVERTISING 0 /* Enable\Disable Extended advertising feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_EXTENDED_ADVERTISING */ + +#ifndef SUPPORT_LE_PERIODIC_ADVERTISING +#define SUPPORT_LE_PERIODIC_ADVERTISING 0 /* Enable\Disable Periodic advertising feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_PERIODIC_ADVERTISING */ + +#ifndef SUPPORT_LE_POWER_CLASS_1 +#define SUPPORT_LE_POWER_CLASS_1 0 /* Enable\Disable Low power class 1 feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_POWER_CLASS_1 */ + +#ifndef SUPPORT_AOA_AOD +#define SUPPORT_AOA_AOD 0 /* Enable\Disable AOA_AOD feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_AOA_AOD */ + +#ifndef SUPPORT_PERIODIC_SYNC_TRANSFER +#define SUPPORT_PERIODIC_SYNC_TRANSFER 0 /* Enable\Disable PAST feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_PERIODIC_SYNC_TRANSFER */ + +#ifndef SUPPORT_SLEEP_CLOCK_ACCURCY_UPDATES +#define SUPPORT_SLEEP_CLOCK_ACCURCY_UPDATES 0 /* Enable\Disable Sleep Clock Accuracy Updates Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_SLEEP_CLOCK_ACCURCY_UPDATES */ + +#ifndef SUPPORT_CONNECTED_ISOCHRONOUS +#define SUPPORT_CONNECTED_ISOCHRONOUS 0 /* Enable\Disable Connected Isochronous Channel Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_CONNECTED_ISOCHRONOUS */ + +#ifndef SUPPORT_BRD_ISOCHRONOUS +#define SUPPORT_BRD_ISOCHRONOUS 0 /* Enable\Disable Broadcast Isochronous Channel Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_BRD_ISOCHRONOUS */ + +#ifndef SUPPORT_SYNC_ISOCHRONOUS +#define SUPPORT_SYNC_ISOCHRONOUS 0 /* Enable\Disable Broadcast Isochronous Synchronizer Channel Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_SYNC_ISOCHRONOUS */ + +#ifndef SUPPORT_LE_POWER_CONTROL +#define SUPPORT_LE_POWER_CONTROL 0 /* Enable\Disable LE Power Control Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_POWER_CONTROL */ + +#ifndef SUPPORT_CHANNEL_CLASSIFICATION +#define SUPPORT_CHANNEL_CLASSIFICATION 0 +#endif /* SUPPORT_CHANNEL_CLASSIFICATION */ + +#ifndef SUPPORT_PERIODIC_ADV_ADI +#define SUPPORT_PERIODIC_ADV_ADI 0 +#endif /* SUPPORT_PERIODIC_ADV_ADI */ + +#ifndef SUPPORT_LE_ENHANCED_CONN_UPDATE +#define SUPPORT_LE_ENHANCED_CONN_UPDATE 0 +#endif /* SUPPORT_LE_ENHANCED_CONN_UPDATE */ + +#ifndef SUPPORT_CSSA +#define SUPPORT_CSSA 0 /* Enable\Disable Coding Selection Scheme on Advertising Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_CSSA */ + +#ifndef SUPPORT_LE_PAWR_ADVERTISER_ROLE +#define SUPPORT_LE_PAWR_ADVERTISER_ROLE 0 /* Enable\Disable PAwR Advertiser role. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_PAWR_ADVERTISER_ROLE */ + +#ifndef SUPPORT_LE_PAWR_SYNC_ROLE +#define SUPPORT_LE_PAWR_SYNC_ROLE 0 /* Enable\Disable PAwR Synchronizer role. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_PAWR_SYNC_ROLE */ + +#ifndef SUPPORT_CHANNEL_SOUNDING +#define SUPPORT_CHANNEL_SOUNDING 0 /* Enable\Disable Channel Sounding Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_CHANNEL_SOUNDING */ + +#ifndef SUPPORT_FRAME_SPACE_UPDATE +#define SUPPORT_FRAME_SPACE_UPDATE 0 /* Enable\Disable Frame Space Update Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_FRAME_SPACE_UPDATE */ + +#ifndef SUPPORT_EXT_FEATURE_SET +#define SUPPORT_EXT_FEATURE_SET 0 /* Enable\Disable Extended Feature Set Exchange. Enable:1 - Disable:0 */ +#endif /* SUPPORT_EXT_FEATURE_SET */ + +#ifndef SUPPORT_ISO_UNSEG_MODE +#define SUPPORT_ISO_UNSEG_MODE 0 /* Enable\Disable Unsegmented Mode for Framed ISO PDUs. Enable: 1 - Disable: 0*/ +#endif /* SUPPORT_ISO_UNSEG_MODE */ + +#ifndef SUPPORT_LE_ADVERTISERS_MONITORING +#define SUPPORT_LE_ADVERTISERS_MONITORING 0 /* Enable\Disable Advertisers Monitoring Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_LE_ADVERTISERS_MONITORING */ + +/* Capabilities configurations */ +#ifndef MAX_NUM_CNCRT_STAT_MCHNS +#define MAX_NUM_CNCRT_STAT_MCHNS 0 /* Set maximum number of states the controller can support */ +#endif /* MAX_NUM_CNCRT_STAT_MCHNS */ + +#ifndef USE_NON_ACCURATE_32K_SLEEP_CLK +#define USE_NON_ACCURATE_32K_SLEEP_CLK 1 /* Allow to drive the sleep clock by sources other than the default crystal oscillator source.*/ + /*LL can use crystal oscillator or RTC or RCO to drive the sleep clock.This selection is done via "DEFAULT_SLEEP_CLOCK_SOURCE" macro. */ +#endif /* USE_NON_ACCURATE_32K_SLEEP_CLK */ + +/* Non-standard features configurations */ +#ifndef NUM_OF_CTSM_EMNGR_HNDLS +#define NUM_OF_CTSM_EMNGR_HNDLS 0 /* Number of custom handles in event manager to be used for app specific needs */ +#endif /* NUM_OF_CTSM_EMNGR_HNDLS */ + +#ifndef SUPPORT_AUGMENTED_BLE_MODE +#define SUPPORT_AUGMENTED_BLE_MODE 0 /* Enable\Disable Augmented BLE Support. Enable:1 - Disable:0 */ +#endif /* SUPPORT_AUGMENTED_BLE_MODE */ + +#ifndef SUPPORT_PTA +#define SUPPORT_PTA 1 /* Enable\Disable PTA Feature. Enable:1 - Disable:0 */ +#endif /* SUPPORT_PTA */ + +#ifndef SUPPORT_CONFIGURABLE_GAIN_FIX +#define SUPPORT_CONFIGURABLE_GAIN_FIX 0 /* Enable\Disable configurable gain fix support */ +#endif /* SUPPORT_CONFIGURABLE_GAIN_FIX */ + +#ifndef CHECK_ANY_MISSED_EVENT_ON_DEEP_SLEEP_EXIT +#define CHECK_ANY_MISSED_EVENT_ON_DEEP_SLEEP_EXIT 1 /* Enable\Disable calling event scheduler handler function at the end of deep sleep exit*/ +#endif /* CHECK_ANY_MISSED_EVENT_ON_DEEP_SLEEP_EXIT */ + +#ifndef LL_BASIC +#define LL_BASIC 0 +#endif /* LL_BASIC */ + +/*************************** MAC Configuration *************************************/ +/*Configurations of MAC will apply only when MAC is enabled*/ +#ifndef FFD_DEVICE_CONFIG +#define FFD_DEVICE_CONFIG 1 /* Enable\Disable FFD:1 - RFD:0 */ +#endif /* FFD_DEVICE_CONFIG */ +#ifndef RAL_NUMBER_OF_INSTANCE +#define RAL_NUMBER_OF_INSTANCE 1 /* The Number of RAL instances supported */ +#endif /* RAL_NUMBER_OF_INSTANCE */ +#ifndef MAX_NUMBER_OF_INDIRECT_DATA +#define MAX_NUMBER_OF_INDIRECT_DATA 10 /* The maximum number of supported indirect data buffers */ +#endif /* MAX_NUMBER_OF_INDIRECT_DATA */ + +#ifndef SUPPORT_OPENTHREAD_1_2 +#define SUPPORT_OPENTHREAD_1_2 1 /* Enable / disable FW parts related to new features introduced in openthread 1.2*/ +#endif /* SUPPORT_OPENTHREAD_1_2 */ + +#ifndef SUPPORT_SEC +#define SUPPORT_SEC 1 /* The MAC Security Supported : 1 - Not Supported:0 */ +#endif /* SUPPORT_SEC */ + +#ifndef RADIO_CSMA +#define RADIO_CSMA 1 /* Enable\Disable CSMA Algorithm in Radio Layer, Must be Enabled if MAC_LAYER_BUILD */ +#endif /* RADIO_CSMA */ + +#ifndef SUPPORT_ANT_DIV +#define SUPPORT_ANT_DIV 1 /* Enable/Disable Antenna Diversity Feature */ +#endif /* SUPPORT_ANT_DIV */ + +#ifndef SUPPORT_A_MAC +#define SUPPORT_A_MAC 1 +#endif /* SUPPORT_A_MAC */ + +#ifndef SMPL_PRTCL_TEST_ENABLE +#define SMPL_PRTCL_TEST_ENABLE 0 +#endif /* SMPL_PRTCL_TEST_ENABLE */ + +#ifndef IEEE_EUI64_VENDOR_SPECIFIC_FUNC +#define IEEE_EUI64_VENDOR_SPECIFIC_FUNC 1 /* Comment to disable EUI-64 vendor specific function, in this case EUI-64 is not unique */ +#endif /* IEEE_EUI64_VENDOR_SPECIFIC_FUNC */ + +/*************************** Zigbee Configuration **********************************/ +#ifndef SUPPORT_ZIGBEE_PHY_CERTIFICATION +#define SUPPORT_ZIGBEE_PHY_CERTIFICATION 0 /* Enable support of hci command required to implement zigbee phy Test cases Enable:1 - Disable:0 */ +#endif /* SUPPORT_ZIGBEE_PHY_CERTIFICATION */ + +#endif /* INCLUDE_LL_FW_CONFIG_H */ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/dtm.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/dtm.h new file mode 100644 index 000000000..06a7c9bdd --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/dtm.h @@ -0,0 +1,229 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/dtm.h#1 $*/ +/** + ******************************************************************************** + * @file dtm.h + * @brief header file for Synopsys zigbee phy testing APIs + * + * + ****************************************************************************** + * @copy + * Synopsys MIT License: + * Copyright (c) 2020-Present Synopsys, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of the software and + * associated documentation files (the “Software”), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. + * + * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE + * ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * */ + +#ifndef MAC_CONTROLLER_INC_DTM_H_ +#define MAC_CONTROLLER_INC_DTM_H_ + +/******************************************************************************************** + * Includes + *********************************************************************************************/ + +#include "ral.h" + +/*=========================================== MACROS ======================================*/ +#define aMaxSIFSFrameSize 18 +#define macMinSIFSPeriod 192 +#define macMinLIFSPeriod 640 +#define MAX_PHY_PACKET_SIZE 127 +#define macMaxIFSPeriod 1000 +#define MAX_ERROR_PER_SINGLE_TX 5 +/*============================= Enumerations ================================*/ +/** + * @brief: Current DTM State + */ +typedef enum z_dtm_mode { + Z_DTM_STOPPED = 0, + Z_DTM_TX = 1, + Z_DTM_RX = 2, + Z_DTM_TX_ACK = 3, + Z_DTM_CHECK_TX_ERROR = 4 +} z_dtm_mode_e; + +/*============================= Structures ================================*/ +/** + * @brief: type to represent the current state of DTM TX. + */ +typedef struct Tx_Info +{ + uint16_t TxTotal; // Total number of transmitted Frames (with/without errors) + uint16_t NoErr; // Number of frames that are transmitted successfully + uint16_t ErrNoAck; // Number of frames that are requesting ack and no Ack is received after transmission + uint16_t ErrOther; // Number of frames that are transmitted with errors excluding the no ack error +} TxInfo_s; + +/** + * @brief: type to represent the current state of DTM RX. + */ +typedef struct Rx_Info +{ + uint16_t RxTotal;// Total number of received Frames (with/without errors) + uint16_t NoErr; // Number of frames that are successfully received + uint16_t ErrFcs; // Number of frames that are received with invalid FCS + uint16_t ErrOther; // Number of frames that are received with errors excluding the invalid FCS error + uint8_t lqi; // LQI of the received Frame +} RxInfo_s; + +/** + * @brief: structure to store all information related to DTM. + */ +typedef struct dtmInfo_st +{ + z_dtm_mode_e curr_mode; // Current State (TX,RX,STopped) + + union{ + TxInfo_s TxInfo; // DTM information in case of TX and TX_ACK + RxInfo_s RxInfo; // DTM information in case of RX + } tx_rx_info_u; + +} dtmInfo_t; + +/** @ingroup mac_dtm +* @{ +*/ +/*=========================================== API ============================================*/ +/** + * @brief this function is used to initialize or rest DTM , it also stops the current running DTM + * @retval None. + */ +void dtmReset(void); + +/** + * @brief get the the state of DTM (running or stopped) + * @retval uin8_t . TRUE if DTM is running , + * FALSE if DTM is stopped + */ +uint8_t dtmIsEnabled(void); + + +/** + * @brief this function is used to start continuous DTM transmission with the given input parameters until the dtmStop() API is called + * @param mPsdu [in] : pointer to MAC DTM FRame including MAC header. + * @param mLength [in] : Length of the frame to be transmitted. + * @param mChannel [in] : Channel to transmit the frame on . + * @param IFS [in] : Interframe spacing in us + * @retval mac_status_enum_t. MAC error State of starting transmission + */ +mac_status_enum_t dtmStartTransmit(uint8_t * mPsdu, uint8_t mLength, uint8_t mChannel, uint16_t IFS); + +/** + * @brief this function is used to start transmission of a single DTM Frame that is requesting ACK with the given input parameters + * @param mPsdu [in] : pointer to MAC DTM FRame including MAC header. + * @param mLength [in] : Length of the frame to be transmitted. + * @param mChannel [in] : Channel to transmit the frame on . + * @param IFS [in] : Interframe spacing in us + * @retval mac_status_enum_t. MAC error State of starting transmission + */ +mac_status_enum_t dtmStartTransmitwithAck(uint8_t * mPsdu, uint8_t mLength, uint8_t mChannel, uint16_t IFS); +/** + * @brief this function is used to stop the current Running DTM (TX or RX) + * @retval mac_status_enum_t. MAC error State of stopping DTM + */ +mac_status_enum_t dtmStop(uint16_t *num_rec_pckts, uint8_t *lqi); + +/** + * @brief this function is used to start continuous DTM reception on the given channel + * @param mChannel [in] : Channel to receive on . + * @retval mac_status_enum_t. MAC error State of starting transmission + */ +mac_status_enum_t dtmStartReceive(uint8_t aChannel); + +/** + * @brief this function is used to start CCA on the given channel + * @param mChannel [in] : Channel to perform CCA on . + * @retval mac_status_enum_t. MAC error State of starting reception + */ +mac_status_enum_t dtmPerformCCA(uint8_t channel); + + +/** + * @brief get the current LQI of the last received packet + * @retval uint8_t. LQI value + */ +uint8_t dtmGetLQIValue(void); +/** + * @} + */ +/** + * @brief check if there is more DTM frames to transmit + * @retval uin8_t . TRUE Continue DTM transmission , + * FALSE Stop DTM transmission + */ +uint8_t dtmCheckMoreTx(void); + +/** + * @brief check if that dtm is in reception state + * @retval uin8_t . TRUE DTM in reception mode , + * FALSE DTM is not in reception mode + */ +uint8_t dtmCheckRxState(void); + +/** + * @brief Done function that should be called after each DTM event + * @param aFrame : [in] pointer to MAC transmitted/Received Frame. + * @param aError : [in] status error of overall transmission (success , No_ack, and other errors). + * @retval None. + */ +void dtmRadioDone(otRadioFrame *aFrame, otError aError); + +/** +* @brief check if in Z_DTM_CHECK_TX_ERROR transmission mode or not +* @param None. +* @retval uin8_t . TRUE in Z_DTM_CHECK_TX_ERROR transmission mode , +* FALSE Not in Z_DTM_CHECK_TX_ERROR transmission mode +*/ +uint8_t dtmCheckTxErrorState(void); +/** +* @brief count errors which happens in single tx in Z_DTM_CHECK_TX_ERROR transmission mode +* @param tx_error : [in] type of error to be counted for this trial +* @retval None. +*/ +void dtmCheckTxErrorCount(otError tx_error); +/** +* @brief gives stored errors and its count that happens in single tx in Z_DTM_CHECK_TX_ERROR transmission mode +* @param errors : [in] pointer to array to point to array of stored errors in Z_DTM_CHECK_TX_ERROR transmission mode +* @param error_count : [in] pointer that will have number of errors that stored in errors array +* @retval None. +*/ +void dtmTxCheckErrorCountDone(uint8_t ** errors, uint8_t *error_count); +/** +* @brief start transmission in Z_DTM_CHECK_TX_ERROR transmission mode +* @param mac_hndl : [in] MAC instance handle +* @param mPsdu : [in] pointer to tx packet +* @param mLength : [in] length of tx packet +* @param mChannel : [in] channel that packet will be sent on +* @param IFS : [in] used Inter-frame-spacing +* @param csma_en : [in] flag to indicate to apply csma in this transmission if max_csma_retry_count != 0 +* @param backoff_count_max : [in] maximum number of tx trials in every full csma trial +* @param frame_retry : [in] maximum number of trials after failure that not related to cca_failure +* @param ack_req : [in] indicate if this packet require ack or not +* @retval mac_status_enum_t. +*/ +mac_status_enum_t dtmTxSpecificErrorCount(uint32_t mac_hndl, uint8_t * mPsdu, uint8_t mLength, uint8_t mChannel, uint16_t IFS, + uint8_t csma_en, uint8_t backoff_count_max, uint8_t frame_retry, uint8_t ack_req); + +/** +* @brief reset tx_check_err_arr array and its counter for Z_DTM_CHECK_TX_ERROR mode +* @param None. +* @retval None. +*/ +void dtmTxErrorCountReset(void); + +#endif /* MAC_CONTROLLER_INC_DTM_H_ */ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ll_error.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ll_error.h new file mode 100644 index 000000000..330c2c8ca --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ll_error.h @@ -0,0 +1,226 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/ll_error.h#1 $*/ +/** + ******************************************************************************** + * @file error.h + * @brief This file contains error defines across BLE FW LL. + ****************************************************************************** + * @copy + * Synopsys MIT License: + * Copyright (c) 2020-Present Synopsys, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of the software and + * associated documentation files (the “Software”), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. + * + * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE + * ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * */ + +/* Define to prevent recursive inclusion -------------------------------------*/ + +#ifndef ERROR_H_ +#define ERROR_H_ + +typedef enum _HW_ERROR_CODES +{ + HW_ERROR_CODE_UNDEFINED_ERROR, + HW_ERROR_CODE_BL_SEARCH, /* this error code indicates an issue while searching in the HW Black list */ + HW_ERROR_CODE_RL_SEARCH, /* this error code indicates an issue while searching in the HW Resolving list */ + HW_ERROR_CODE_WL_SEARCH, /* this error code indicates an issue while searching in the HW White list */ + HW_ERROR_CODE_PDU_PARSING, /* this error code indicates an issue while Parsing PDU */ + HW_ERROR_CODE_PDU_RECEIVING, /* this error code indicates an unexpected PDU type received */ + HW_ERROR_CODE_SM_UPDATE, /* this error code indicates an update in the state machine */ + HW_ERROR_CODE_UNREGISTERING_EVENT, /* this error code indicates an issue while unregistering an event */ + HW_ERROR_CODE_STARTING_CONNECTION, /* this error code indicates an issue while starting a connection */ + HW_ERROR_CODE_MEMORY_EXCEEDED, /* this error code indicates an issue in allocating */ + HW_ERROR_CODE_UNEXPECTED_ADV_STATE /* this error code indicates unexpected adv state */ +}HW_ERROR_CODES; + +/* Includes ---------------------------------------------------------------------*/ + +/* Exported Defines -----------------------------------------------------------*/ +#ifndef SUCCESS +#define SUCCESS 0x00 +#endif +#define UNKNOWN_HCI_COMMAND 0x01 +#define UNKNOWN_CONNECTION_IDENTIF 0x02 +#define HARDWARE_FAILURE 0x03 +#define PAGE_TIMEOUT 0x04 +#define AUTHENTICATION_FAILURE 0x05 +#define PIN_OR_KEY_MISSING 0x06 +#define MEMORY_CAPACITY_EXCEEDED 0x07 +#define CONNECTION_TIMEOUT 0x08 +#define CONNECTION_LIMIT_EXCEEDED 0x09 +#define SYNCHRONOUS_CONNECTION_LIMIT_TO_A_DEVICE_EXCEEDED 0x0A +#define ACL_CONNECTION_ALREADY_EXISTS 0x0B +#define COMMAND_DISALLOWED 0x0C +#define CONNECTION_REJECTED_DUE_TO_LIMITED_RESOURCES 0x0D +#define CONNECTION_REJECTED_DUE_TO_SECURITY_REASONS 0x0E +#define CONNECTION_REJECTED_DUE_TO_UNACCEPTABLE_BD_ADDR 0x0F +#define CONNECTION_ACCEPT_TIMEOUT_EXCEEDED 0x10 +#define UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE 0x11 +#define INVALID_HCI_COMMAND_PARAMETERS 0x12 +#define REMOTE_USER_TERMINATED_CONNECTION 0x13 +#define REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_LOW_RESOURCES 0x14 +#define REMOTE_DEVICE_TERMINATED_CONNECTION_DUE_TO_POWER_OFF 0x15 +#define CONNECTION_TERMINATED_BY_LOCAL_HOST 0x16 +#define REPEATED_ATTEMPTS 0x17 +#define PAIRING_NOT_ALLOWED 0x18 +#define UNKNOWN_LMP_PDU 0x19 +#define UNSUPPORTED_REMOTE_FEATURE 0x1A +#define SCO_OFFSET_REJECTED 0x1B +#define SCO_INTERVAL_REJECTED 0x1C +#define SCO_AIR_MODE_REJECTED 0x1D +#define INVALID_LMP_PARAMETERS_INVALID_LL_PARAMETERS 0x1E +#define UNSPECIFIED_ERROR 0x1F +#define UNSUPPORTED_LMP_PARAMETER_VALUE_UNSUPPORTED_LL_PARAMETER_VALUE 0x20 +#define ROLE_CHANGE_NOT_ALLOWED 0x21 +#define LMP_RESPONSE_TIMEOUT_LL_RESPONSE_TIMEOUT 0x22 +#define LMP_ERROR_TRANSACTION_COLLISION 0x23 +#define LMP_PDU_NOT_ALLOWED 0x24 +#define ENCRYPTION_MODE_NOT_ACCEPTABLE 0x25 +#define LINK_KEY_CANNOT_BE_CHANGED 0x26 +#define REQUESTED_QOS_NOT_SUPPORTED 0x27 +#define INSTANT_PASSED 0x28 +#define PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED 0x29 +#define DIFFERENT_TRANSACTION_COLLISION 0x2A +#define RESERVED_FOR_FUTURE_1 0x2B +#define QOS_UNACCEPTABLE_PARAMETER 0x2C +#define QOS_REJECTED 0x2D +#define CHANNEL_ASSESSMENT_NOT_SUPPORTED 0x2E +#define INSUFFICIENT_SECURITY 0x2F +#define PARAMETER_OUT_OF_MANDATORY_RANGE 0x30 +#define RESERVED_FOR_FUTURE_2 0x31 +#define ROLE_SWITCH_PENDING 0x32 +#define RESERVED_FOR_FUTURE_3 0x33 +#define RESERVED_SLOT_VIOLATION 0x34 +#define ROLE_SWITCH_FAILED 0x35 +#define EXTENDED_INQUIRY_RESPONSE_TOO_LARGE 0x36 +#define SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST 0x37 +#define HOST_BUSY_PAIRING 0x38 +#define CONNECTION_REJECTED_DUE_TO_NO_SUITABLE_CHANNEL_FOUND 0x39 +#define CONTROLLER_BUSY 0x3A +#define UNACCEPTABLE_CONNECTION_PARAMETERS 0x3B +#define DIRECTED_ADVERTISING_TIMEOUT 0x3C +#define CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE 0x3D +#define CONNECTION_FAILED_TO_BE_ESTABLISHED 0x3E +#define SYNCHRONIZATION_TIMEOUT 0X3E +#define MAC_CONNECTION_FAILED 0x3F +#define COARSE_CLOCK_ADJUSTMENT_REJECTED_BUT_WILL_TRY_TO_ADJUST_USING_CLOCK_DRAGGING 0x40 + +#define UNKNOWN_ADVERTISING_IDENTIFIER 0x42 +#define LIMIT_REACHED 0x43 +#define OPERATION_CANCELLED_BY_HOST 0x44 +#define PACKET_TOO_LONG 0x45 +#define TOO_LATE 0x46 +#define INSUFFICIENT_CHANNELS 0x48 +#if SUPPORT_BLE + +#if ((MAX_NUM_CNCRT_STAT_MCHNS > 1) && !((SUPPORT_MASTER_CONNECTION) || (SUPPORT_SLAVE_CONNECTION)||(SUPPORT_LE_EXTENDED_ADVERTISING))) +#error define at least either master or slave role +#endif + +#if (SUPPORT_MASTER_CONNECTION || SUPPORT_SLAVE_CONNECTION || SUPPORT_LE_EXTENDED_ADVERTISING) && (MAX_NUM_CNCRT_STAT_MCHNS == 0) +#error define at least one state machine in order to support slave or master role or extended advertising +#endif /* SUPPORT_MASTER_CONNECTION || SUPPORT_SLAVE_CONNECTION */ + +#if ((SUPPORT_LE_ENCRYPTION) && (!SUPPORT_MASTER_CONNECTION && !SUPPORT_SLAVE_CONNECTION)) +#error Encryption feature shall be enabled only when the master role or slave role is enabled +#endif /* #error */ + +#if ((SUPPORT_LE_PERIODIC_ADVERTISING) && (!SUPPORT_LE_EXTENDED_ADVERTISING)) +#error Since controller supports periodic advertising feature, then it shall support Extended advertising feature +#endif /* #error */ + +#if (SUPPORT_PERIODIC_SYNC_TRANSFER && (!SUPPORT_MASTER_CONNECTION && !SUPPORT_SLAVE_CONNECTION)) +#error Sending PAST IND shall be enabled only when the master role or slave role is enabled +#endif /* #error */ + +#if (SUPPORT_PERIODIC_SYNC_TRANSFER && (!SUPPORT_LE_PERIODIC_ADVERTISING)) +#error Sending PAST IND shall be enabled only when the Periodic ADV is enabled +#endif /* #error */ + +#if ((SUPPORT_LE_POWER_CONTROL) && (!SUPPORT_MASTER_CONNECTION && !SUPPORT_SLAVE_CONNECTION)) +#error LE Power Control feature shall be enabled only when the master role or slave role is enabled +#endif /* #error */ + +#if ((SUPPORT_AOA_AOD) && (!SUPPORT_MASTER_CONNECTION && !SUPPORT_SLAVE_CONNECTION && !SUPPORT_LE_PERIODIC_ADVERTISING)) +#error CTE feature shall be enabled only when the master role or slave role or periodic advertising is enabled +#endif /* #error */ + +#if ((SUPPORT_BRD_ISOCHRONOUS || SUPPORT_SYNC_ISOCHRONOUS) && (!SUPPORT_LE_PERIODIC_ADVERTISING)) +#error Broadcast Isochronous feature shall be enabled only when periodic advertisng is enabled +#endif /* #error */ + +#if ((SUPPORT_CONNECTED_ISOCHRONOUS) && (!SUPPORT_MASTER_CONNECTION && !SUPPORT_SLAVE_CONNECTION)) +#error Connection Isochronous feature shall be enabled when at least one the master role or slave role is enabled +#endif /* #error */ + +#if (SUPPORT_PERIODIC_ADV_ADI && (!SUPPORT_LE_PERIODIC_ADVERTISING)) +#error Periodic Advertising ADI feature shall be enabled only when periodic advertisng is enabled +#endif /* #error */ + +#if ((SUPPORT_CHANNEL_CLASSIFICATION) && (!SUPPORT_MASTER_CONNECTION && !SUPPORT_SLAVE_CONNECTION)) +#error Channel Classification feature shall be enabled only when the master role or slave role is enabled +#endif /* #error */ + +#if (SUPPORT_LE_ENHANCED_CONN_UPDATE) && (!SUPPORT_MASTER_CONNECTION && !SUPPORT_SLAVE_CONNECTION) +#error "LE Enhanced Connection Update(subrating) enabled only if master or slave enabled" +#endif /* #error */ + +#if ((SUPPORT_CSSA) && (!SUPPORT_LE_EXTENDED_ADVERTISING)) +#error If controller supports Code Scheme selection feature , then it shall support Extended advertising feature +#endif /* ((SUPPORT_CSSA) && (!SUPPORT_LE_EXTENDED_ADVERTISING)) */ + +#if ((SUPPORT_LE_PAWR_ADVERTISER_ROLE) && (!SUPPORT_PERIODIC_SYNC_TRANSFER || !SUPPORT_EXPLCT_BROADCASTER_ROLE)) +#error PAWR feature shall be enabled only if PAST transmitter feature is enabled +#endif /* #error */ + +#if ((SUPPORT_LE_PAWR_SYNC_ROLE) && (!SUPPORT_PERIODIC_SYNC_TRANSFER || !SUPPORT_EXPLCT_OBSERVER_ROLE)) +#error PAWR feature shall be enabled only if PAST recipient feature is enabled +#endif /* #error */ + +#if ((SUPPORT_FRAME_SPACE_UPDATE) && (!SUPPORT_MASTER_CONNECTION && !SUPPORT_SLAVE_CONNECTION)) +#error Frame Space update feature shall be enabled only when the master role or slave role is enabled +#endif /* #error */ + +#if ((SUPPORT_FRAME_SPACE_UPDATE) && (!SUPPORT_EXT_FEATURE_SET)) +#error Frame Space update feature shall be enabled only when the extended feature set is enabled. +#endif /* #error */ + +#if (SUPPORT_CHANNEL_SOUNDING && (!SUPPORT_MASTER_CONNECTION && !SUPPORT_SLAVE_CONNECTION)) +#error Channel Sounding feature can be enabled only if the master role or slave role is enabled +#endif /* #error */ + +#if (SUPPORT_EXT_FEATURE_SET && (!SUPPORT_MASTER_CONNECTION && !SUPPORT_SLAVE_CONNECTION)) +#error Extended Feature Set Exchange feature can be enabled only if the master role or slave role is enabled +#endif /* #error */ + +#if ((SUPPORT_LE_ADVERTISERS_MONITORING) && (!SUPPORT_EXPLCT_OBSERVER_ROLE)) +#error Advertisers Monitoring feature can be enabled when the device is an observer. +#endif /* ((SUPPORT_LE_ADVERTISERS_MONITORING) && (!SUPPORT_EXPLCT_OBSERVER_ROLE)) */ + +#if ((SUPPORT_PHY_SHUTDOWN_MODE) && !(defined(PHY_40nm_3_60_a_tc) || defined(PHY_40nm_3_00_a) || defined(PHY_40nm_3_40_a))) +#error Phy Shutdown feature is only supported on PHY_40nm_3_60_a_tc, PHY_40nm_3_00_a and PHY_40nm_3_40_a +#endif /* ((SUPPORT_PHY_SHUTDOWN_MODE) && !(defined(PHY_40nm_3_60_a_tc) || defined(PHY_40nm_3_00_a) || defined(PHY_40nm_3_40_a))) */ + +/* Exported macros ------------------------------------------------------------*/ + +/* Exported types -------------------------------------------------------------*/ + +/* Exported functions ---------------------------------------------------------*/ +#endif /* SUPPORT_BLE */ +#endif /* ERROR_H_ */ + +/******************* (C) (C) COPYRIGHT 2024 SYNOPSYS, INC. *****END OF FILE****/ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/mac_host_intf.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/mac_host_intf.h new file mode 100644 index 000000000..812b586c2 --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/mac_host_intf.h @@ -0,0 +1,1636 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/mac_host_intf.h#1 $*/ +/** + ******************************************************************************** + * @file mac_host_intf.h + * @brief The file include description for the MAC services interface and call backs , + * MAC layer provide software implementation for 802.15.4 standard primitives + * + ****************************************************************************** + * @copy + * Synopsys MIT License: + * Copyright (c) 2020-Present Synopsys, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of the software and + * associated documentation files (the “Software”), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. + * + * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE + * ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * */ + +#ifndef INCLUDE_MAC_HOST_INTF_H_ +#define INCLUDE_MAC_HOST_INTF_H_ +#include "common_types.h" +#include "ll_fw_config.h" +#include "rfd_dev_config.h" +#include "error.h" +#include "stdint.h" +/*==================================== MACROS =======================================*/ +/* Size in octets of frame counter used in security processing */ +#define FRM_CNTR_SIZE 4 +/* Size in octets of key src in case of key id mode 2 used in security processing */ +#define KEY_SRC_SIZE_MOD_2 4 +/* Size in octets of key src in case of key id mode 3 used in security processing */ +#define KEY_SRC_SIZE_MOD_3 8 +/* Security Key ID Modes */ +#define MODE_ZERO 0 +#define MODE_ONE 1 +#define MODE_TWO 2 +#define MODE_THREE 3 + +/**security parameters */ +#if SUPPORT_SEC +#define KEY_SOURCE_SIZE 8 +#define KEY_ID_LOOKUP_DSCRP_LIST_SIZE 3 +#define MAX_NUM_OF_DEVICES_USE_KEY 8 +#define KEY_USAGE_LIST_SIZE 5 +#define KEY_SIZE 16 +#define MAC_KEY_TBL_STRUCT_SIZE_PLUS_OVERHEAD (sizeof(key_dscrp_st_t) + 7) /*adding 7 bytes for header parameters ( 1 opcode + 2 length + 1 mac_handle + 1 pib_attributes + 1 pib_attribute_index + 1 pib_attribute_length )*/ +#endif /*SUPPORT_SEC */ + + +/* The maximum number of octets that can be transmitted in the MAC Payload field (MAX_PHY_PACKET_SIZE MIN_PDU_OVERHEAD)*/ +#define MAX_MAC_SAFE_PAYLOAD_SIZE 118 +#define MAX_HDR_IE_SIZE 3 +/* EB payload IE length = 19 + 2 = 21 octets + * Tx power IE length = 6 octets */ +#define MAX_ZIGBEE_EB_IE_LEN 27 // maximum allowed IE Size for Enhanced Beacon +/* + * False vendor specific IE: 5 octets without any vendor specific info only OUI + * False MLME nested: 3 for our testing + * used for zigbee certification + * */ +#define MAX_ADDITIONAL_ZIGBEE_PYLDIE_SIZE 8 +/* Rejoin IE = 12 + 3 hdr = 15 octets + * Tx power IE length = 1 + 3 hdr octets + * Vendor specific IE hdr = 5 octets + * */ +#define MAX_ZIGBEE_EBR_IE_LEN (20 + MAX_ADDITIONAL_ZIGBEE_PYLDIE_SIZE) + + +#define MAX_BEACON_FRAME_PENDING_ADDRESSES 7 +/** + * @brief Enumeration representing any error codes that could result from calling a MAC API + **/ +typedef enum { + BEACON_LOSS = 0xE0, + CHANNEL_ACCESS_FAILURE = 0xE1, + COUNTER_ERROR = 0xDB, + DENIED = 0xE2, + DISABLE_TRX_FAILURE = 0xE3, + SECURITY_ERROR = 0xE4, + FRAME_TOO_LONG = 0xE5, + IMPROPER_KEY_TYPE = 0xDC, + IMPROPER_SECURITY_LEVEL = 0xDD, + INVALID_ADDRESS = 0xF5, + INVALID_GTS = 0xE6, + INVALID_HANDLE = 0xE7, + INVALID_INDEX = 0xF9, + INVALID_PARAMETER = 0xE8, + NO_ACK = 0xE9, + NO_BEACON = 0xEA, + NO_DATA = 0xEB, + NO_SHORT_ADDRESS = 0xEC, + ON_TIME_TOO_LONG = 0xF6, + OUT_OF_CAP = 0xED, + PAN_ID_CONFLICT = 0xEE, + PAST_TIME = 0xF7, + READ_ONLY = 0xFB, + REALIGNMENT = 0xEF, + SCAN_IN_PROGRESS = 0xFC, + SUPERFRAME_OVERLAP = 0xFD, + TRACKING_OFF = 0xF8, + TRANSACTION_EXPIRED = 0xF0, + TRANSACTION_OVERFLOW = 0xF1, + TX_ACTIVE = 0xF2, + UNAVAILABLE_KEY = 0xF3, + UNSUPPORTED_ATTRIBUTE = 0xF4, + UNSUPPORTED_LEGACY = 0xDE, + UNSUPPORTED_SECURITY = 0xDF, + MAC_LIMIT_REACHED = 0xFA, + UNAVAILABLE_DEVICE, + UNAVAILABLE_SECURITY_LEVEL, + RANGING_NOT_SUPPORTED, + INTERNAL_ERROR, + CONDITINALLY_PASSED, + MAC_STATUS_SUCCESS = 0, +} mac_status_enum_t; + +/* MAC PIBs IDs */ +typedef enum { + ACK_WAIT_DUR_ID = 0x40, + ASSOC_PAN_COORD_ID = 0x56, + ASSOC_PERMIT_ID = 0x41, + AUTO_REQ_ID = 0x42, + BEACON_PAY_ID = 0x45, + BECON_PAY_LEN_ID = 0x46, + BEACON_ORDER_ID = 0x47, + BEACON_TX_TIME_ID = 0x48, + BSN_ID = 0x49, + COORD_EXT_ADDR_ID = 0x4A, + COORD_SHRT_ADDR_ID = 0x4B, + DSN_ID = 0x4C, + MAX_BE_ID = 0x57, + MAX_CSMA_ID = 0x4E, + MAX_FRAME_WAIT_TIME_ID = 0x58, + MAX_FRAME_RETRY_ID = 0x59, + MIN_BE_ID = 0x4F, + PAN_ID_ID = 0x50, + PROMIS_MODE_ID = 0x51, + RSP_WAIT_TIME_ID = 0x5A, + RX_WHEN_IDLE_ID = 0x52, + SEC_ENABLED_ID = 0X5D, + SHORT_ADDR_ID = 0X53, + SUPER_FRAME_ORD_ID = 0X54, + SYNC_SYMB_OFFS_ID = 0X5B, + TIME_STAMP_SUPP_ID = 0X5C, + PERSISTEN_TIME_ID = 0X55, + PHY_CHANNEL_ID = 0x00, + PHY_CHANNEL_SUPPORTED = 0x01, + PHY_CCA_MODE = 0x03, + PHY_CURRENT_PAGE = 0x04, + PHY_MAX_FRAME_DUR = 0x05, + PHY_SHR_DUR = 0x06, + PHY_SYMBOLS_PER_OCTET = 0x07, + KEY_TBL_ID = 0x71, + DEVICE_TBL_ID = 0x73, + SEC_LVL_TBL_ID = 0x75, + FRM_CNTR_ID = 0x77, + AUTO_REQ_SEC_LVL_ID = 0x78, + AUTO_REQ_KEY_MODE_ID = 0x79, + AUTO_REQ_KEY_SRC_ID = 0x7A, + AUTO_REQ_KEY_INDX_ID = 0x7B, + DFLT_KEY_SRC_ID = 0x7C, + PAN_COORD_EXT_ADDR_ID = 0x7D, + PAN_COORD_SHRT_ADDR_ID = 0x7E, + /* for the sake of testing used only for customization for setting ext address instead of random by the + * values of the security test vectors */ + CUSTOM_IEEE_EXTD_ADDRS = 0x7F, + EB_HDR_IE_LIST_ID = 0x80, + EB_PYLD_IE_LIST_ID = 0x81, + EB_FLTR_Enbld_ID = 0x82, + EBSN_ID = 0x83, + EB_AUTO_SA_ID = 0x84, + EBR_PRMT_JOIN_ID = 0x85, + EBR_FLTRS_ID = 0x86, + EBR_LQ_ID = 0x87, + EBR_PRCNT_FLTR_ID = 0x88, + EBR_AUTO_RSPND_ID = 0x89, + MAX_FULL_CSMA_FRAME_RETRY_ID = 0x8A, + IMPLICIT_BROADCAST_ID = 0x8B, + MIB_JOINING_IEEE_LIST_ID = 0xA0, + MIB_JOINING_POLICY_ID = 0xA1, + MIB_EXPIRY_INTRVL_ID = 0xA2, + MIB_EXPIRY_INTRVL_COUNTDOWN_ID = 0xA3 +} mac_pib_id; + +/** + * @brief enum represents device address mode defined in 802.15.4 std + **/ +typedef enum { + NO_ADDRS, + RESERVED, + SHORT_ADDRS_16, + EXT_ADDRS_64, + NOT_USED =0xFF +} mac_addrs_mode_enum_t; + +/** + * @brief enum represents scanning types defined in 802.15.4 std + **/ +typedef enum { + ED_SCAN, MAC_ACTIV_SCAN, MAC_PASS_SCAN, ORPH_SCAN, ENHANCED_ACTIV_SCAN +} scn_type_t; + +/** + * @brief enum represents Beacon Frame types defined in 802.15.4 std + **/ +typedef enum { + NORMAL_BEACON = 0x00, ENHANCED_BEACON = 0x01 +} bcon_typ_t; + +typedef enum { + ASSOC_REQ = 0x01, + ASSOC_RSP = 0x02, + DISASSOC_NOTF = 0x03, + DATA_REQ = 0x04, + PAN_ID_CONF_NOTF = 0x05, + ORPH_NOTF = 0x06, + BEACON_REQ = 0x07, + COORD_REALIGN = 0x08 +} mac_cmd_frm_t; + +/** + * @brief enum represents Frame types defined in 802.15.4 std + **/ +typedef enum { + BEACON = 0x00, DATA = 0x01, ACK = 0x02, COMMAND = 0x03, FT_RESERVED = 0x04, FT_MULTIPURPOSE = 0x5, FT_FRAK = 0x6, FT_EXTENDED = 0x7, NO_FRAME=0xFF +} mac_frm_t; + + + +/** + * @brief indicates the actual frame protection that is provided. This value can be adapted on a frame-by-frame basis and allows for + * varying levels of data authenticity (to allow minimization of security overhead in transmitted frames where required) and for + * optional data confidentiality. The cryptographic protection offered by the various security levels is shown in Table 95. + * When nontrivial protection is required, replay protection is always provided. + **/ +typedef enum security_level_enum { + no_security, + mic_32_sec_level, + mic_64_sec_level, + mic_128_sec_level, + enc_sec_level, + enc_mic_32_sec_level, + enc_mic_64_sec_level, + enc_mic_128_sec_level, + sec_lvls_num +} sec_level_enum_t; +/** + * @brief struct conatins PIB attribute data + **/ +typedef struct attr_arr_e { + uint8_t* data; + uint16_t length; +} attr_arr_t; +/** + * @brief union contains PIB attribute value [bool/ single int / octet string] + **/ +typedef union attr_value_e { + uint32_t attr_int; + uint32_t attr_bool; + attr_arr_t attr_array; +} attr_val_t; + +/** + * @brief structure represents common security parameters + **/ +typedef struct prim_sec_param_e { + uint32_t frm_cntr; + uint8_t key_src[KEY_SRC_SIZE_MOD_3]; + sec_level_enum_t sec_level; + uint8_t key_indx; + uint8_t key_id_mod; +} prim_sec_param_st; + +#if SUPPORT_SEC +typedef union _dev_addrs_un +{ + uint8_t dev_addrs_arr[EXT_ADDRESS_LENGTH]; + uint16_t shrt_addrs; + +}dev_addrs_un_t; + +/** + * @brief Security device descriptor list element structure + * + **/ +typedef struct _device_dscrp_st +{ + uint16_t device_pan_id; + uint16_t device_short_addrs; + uint8_t dev_extd_addrs_arr[EXT_ADDRESS_LENGTH]; + uint32_t incoming_frame_counter; + uint8_t exempt_min_sec_level; + uint8_t tbl_set_flag; /*TRUE means that this entry is used, FALSE means this entry not used*/ +}device_dscrp_st_t; + +typedef struct _key_id_lookup_dscrp_st +{ + uint32_t key_index ; /* allows unique identification of different keys with the same originator */ + dev_addrs_un_t un_dev_addrs; + uint16_t dev_pan_id; + uint8_t key_id_mode; /* The mode used to for this descriptor. */ + uint8_t key_src_arr[KEY_SOURCE_SIZE]; /* indicates the originator of a group key. Present only if KeyIdMode is equal to 0x02 or 0x03 */ + uint8_t enum_device_addrs_mode; //range values from mac_addrs_mode_enum_t enum (should be set to NOT_USED=0xFF when this entry isn't being used ) + +}key_id_lookup_dscrp_st_t; + +/* indicating the frame types with which this key may be used */ +typedef struct _key_usage_dscrp_st +{ + uint8_t enum_mac_frm_type; //range values from mac_frm_t enum + uint8_t enum_cmd_frm_id; //range value from mac_cmd_frm_t enum +}key_usage_dscrp_st_t; + +/** + * @brief Security key descriptor list element structure + * + **/ +typedef struct _key_dscrp_st +{ + key_id_lookup_dscrp_st_t key_id_lookup_dscrp_list[KEY_ID_LOOKUP_DSCRP_LIST_SIZE]; + device_dscrp_st_t device_dscrp_list[MAX_NUM_OF_DEVICES_USE_KEY]; + key_usage_dscrp_st_t key_usage_dscrp_st_list[KEY_USAGE_LIST_SIZE]; + uint8_t key_arr[KEY_SIZE]; + uint8_t tbl_set_flag; /*TRUE means that this entry is used, FALSE means this entry not used*/ +}key_dscrp_st_t; + +/** + * @brief enum represents Security table types that can be used in mlme-remove-sec_table + **/ +typedef enum security_tbl_enum { + MAC_SEC_LEVEL_TABLE, + MAC_DEVICE_TABLE, + MAC_KEY_TABLE, + KEY_ID_LOOKUP_DSCRP_LIST, + DEVICE_DSCRP_LIST, + KEY_USAGE_DSCRP_ST_LIST +} sec_tbl_enum_t; + +#endif /*SUPPORT_SEC */ + +/** + * @brief structure represents pan descriptor parameters + **/ +typedef struct pan_descr_e { +#if SUPPORT_SEC + /* Security Information */ + prim_sec_param_st sec_params; +#endif + uint32_t time_stamp; + /** The address of the coordinator as specified in the received beacon frame */ + uint8_t coord_addr[EXT_ADDRESS_LENGTH]; + /** The PAN ID of the coordinator as specified in the received beacon frame */ + uint16_t coord_pan_id; + /** Superframe specification */ + uint16_t super_frm_spec; + /** The coordinator addressing mode corresponding to the received beacon frame */ + uint8_t coord_addr_mod; + /** The current channel number occupied by the network */ + uint8_t logic_chanl; + /** The current channel page occupied by the network */ + uint8_t chnl_pge; + /** The LQI at which the network beacon was received */ + uint8_t link_qual; + /* Set to one if the beacon is from the PAN coordinator that is accepting GTS requests*/ + uint8_t gts_perm; + /* SUCCESS if there was no error in the security processing of the frame otherwise check error code */ + uint8_t sec_fail_status; +} pan_descr_st; + +/** + * @brief structure represents MLME-SCAN.confirm parameters + **/ +typedef struct mlme_scan_conf_param_e { + /** A list of the channels given in the request which were not scanned */ + uint32_t unscan_chnls; + /** The list of energy measurements, one for each channel searched during an ED scan */ + uint8_t* enrgy_detec_lst; + /** The list of PAN descriptors, one for each beacon found during an active or passive scan + if macAutoRequest is set to TRUE */ + pan_descr_st* pan_descr_lst; + /** Scan type */ + scn_type_t scn_type; + /** The status of the scan request */ + uint8_t status; + /** The channel page on which the scan was performed */ + uint8_t chnl_pge; + /** The number of elements returned in the appropriate result lists */ + uint8_t rslt_size; +} mlme_scn_cmf_param_st; + +/** + * @brief structure represents MLME-BEACON-NOTIFY.indication parameters + **/ +typedef struct mlme_bcon_notfy_params_e { + /** Pointer to the PANDescriptor for the received Beacon frame.*/ + pan_descr_st* pan_desc_ptr; + uint8_t addr_list [EXT_ADDRESS_LENGTH * MAX_BEACON_FRAME_PENDING_ADDRESSES + MAX_BEACON_FRAME_PENDING_ADDRESSES * EXT_ADDRESS_LENGTH] ; + /** The set of octets comprising the beacon payload to be transferred from the MAC + *sublayer entity to the next higher layer */ + uint8_t* sdu; + /** Pointer to header IEs */ + uint8_t* ptr_hdr_ie_list; + /**Pointer to payload IEs */ + uint8_t* ptr_pyld_ie_list; + /** Indicates a beacon(value 0x00) or enhanced beacon (value 0x01) was received.*/ + uint8_t bcon_type; + /** Number of header IEs */ + uint8_t hdr_ie_list_count; + /** Number of payload IEs*/ + uint8_t pyld_ie_list_count; + /** Bits (0-2) indicates Number of Short Addresses Pending , + * Bits (4-6) indicates Number of Extended Addresses Pending Bits 3,7 are reserved */ + uint8_t pend_addrs; + /** The beacon sequence number (0x00 - 0xff) */ + uint8_t bsn; + /** BSN used for Enhanced Beacon frames (0x00 - 0xff) */ + uint8_t ebsn; + /** The number of octets contained in the beacon payload of the beacon frame + * received by the MAC sublayer */ + uint8_t sdu_length; +} mlme_bcon_notfy_params_st; + +/** + * @brief structure represents pan MLME-SYNC-LOSS.indication parameters + **/ +typedef struct mlme_sync_loss_params_e { + /** Security Information */ + prim_sec_param_st sec_params; + /** The PAN ID with which the device lost synchronization or to which it was realigned.*/ + uint16_t pan_id; + /** The reason that synchronization was lost */ + uint8_t loss_reason; + /** The channel number on which the device lost synchronization or to which it was realigned */ + uint8_t chnl_num; + /** The channel page on which the device lost synchronization or to which it was realigned */ + uint8_t chnl_pge; +} mlme_sync_loss_params_st_t; + +/* MCPS-DATA.indication parameters primitive is generated by the MAC sublayer and issued to the SSCS on receipt + of a data frame at the local MAC sublayer entity */ +typedef struct { + /* Optional. The time, in symbols, at which the data were received */ + uint32_t timestamp; + /* The individual device address of the entity from which the MSDU was received.*/ + uint8_t src_addrs[EXT_ADDRESS_LENGTH]; + /* The individual device address of the entity to which the MSDU is being transferred */ + uint8_t dstn_addrs[EXT_ADDRESS_LENGTH]; + /* The 16-bit PAN identifier of the entity from which the MSDU was received. */ + uint16_t src_pan_id; + /* The 16-bit PAN identifier of the entity to which the MSDU is being transferred. */ + uint16_t dstn_pan_id; + /* The destination addressing mode for this primitive corresponding to the received MPDU. This value can take one of the + following values: + 0x00 = no address, 0x01 = reserved, 0x02 = 16-bit short address, 0x03 = 64-bit extended address. */ + mac_addrs_mode_enum_t enum_dstn_addrs_mode; + /* The source addressing mode for this primitive corresponding to the received MPDU.. This value can take one of the following values: + * 0x00 = no address, 0x01 = reserved, 0x02 = 16-bit short address, 0x03 = 64-bit extended address.*/ + mac_addrs_mode_enum_t enum_src_addrs_mode; + /* The number of octets contained in the MSDU being indicated by the MAC sublayer entity.*/ + uint8_t msdu_len; + /* The set of octets forming the MSDU being indicated by the MAC sublayer entity..*/ + uint8_t *ptr_msdu; + /* The DSN of the received data frame.*/ + uint8_t dsn; + /* link quality value */ + uint8_t mpdu_link_qlty; + /* RSSI */ + uint8_t mpdu_rssi; + /* The security level purportedly used by the received data frame */ + sec_level_enum_t enum_mcps_security_level; +#if SUPPORT_SEC + /* The mode used to identify the key purportedly used by the originator of the received frame */ + uint8_t key_id_mode; + /* The index of the key purportedly used by the originator of the received frame */ + uint8_t key_index; + /* The originator of the key purportedly used by the originator of the received frame */ + uint8_t key_src[8]; +#endif +} mcps_indicate_params_st_t; + +/* MLME Association Status */ +typedef enum mlme_assoc_status_enum { + ASSOCIATION_SUCCESS = 0x00, AT_CAPACITY = 0x01, ACCESS_DENIED = 0x02, +} mlme_assoc_status_enum_t; + +#if (FFD_DEVICE_CONFIG || RFD_SUPPORT_ASSOCIATION_IND_RSP) +/** + * @brief structure represents parameters for MLME-ASSOCIATE.indication + **/ +typedef struct mlme_assoc_ind_params_e { + prim_sec_param_st sec_params; /**< security information */ + uint8_t dev_addr[EXT_ADDRESS_LENGTH]; /**< The address of the device requesting association */ + uint8_t cap_info; /**< The operational capabilities of the device requesting association */ +} mlme_assoc_ind_param_st; + +/** + * @brief structure represents MLME-ASSOCIATE.response input parameters + **/ +typedef struct mlme_assoc_res_params_e { + uint8_t dev_addr[EXT_ADDRESS_LENGTH]; /**< The address of the device requesting association.*/ + uint16_t dev_short_addr; /**< The short address allocated by the coordinator */ + mlme_assoc_status_enum_t status; /**< The status of the association attemp */ + prim_sec_param_st sec_params; /**< Security Information */ +} mlme_assoc_res_param_st; +#endif /* (FFD_DEVICE_CONFIG || RFD_SUPPORT_ASSOCIATION_IND_RSP) */ + + +/** + * @brief structure represents MLME-ASSOCIATE.request input parameters + **/ +typedef struct mlme_assoc_req_params_e { + mac_addrs_mode_enum_t coord_addr_mod; /**< Coordinator addressing mode */ + uint8_t coord_addr[EXT_ADDRESS_LENGTH]; /**< The address of the coordinator with which to associate */ + uint16_t coord_pan_id; /**< The identifier of the PAN with which to associate */ + uint8_t chnl_pge; /**< The channel page on which to attempt association */ + uint8_t chann_num; /**< The channel number on which to attempt association */ + uint8_t capab_info; /**< Specifies the operational capabilities of the associating device */ + prim_sec_param_st sec_params; /**< Security information */ +} mlme_assoc_req_param_st; + + +/** + * @brief structure represents MLME-DISASSOCIATE.Request input parameters + **/ +typedef struct mlme_disassoc_req_params_e { + prim_sec_param_st sec_params; /**< security information */ + uint8_t dev_addr[EXT_ADDRESS_LENGTH]; /** post DIRECT_DATA_TX_EVENT event | \ Main Thread \ + *================<_ _ _ _ _================================ |. . .\ Emngr_hndl_all_events\ + * | \_ _ _ _ _ _ _ _ _ _ _ \ ---> direct_tx_evnt_cbk + * + * */ +/*=========================================================================================================*/ +/* ============================== MLME Requests ======================================================== */ +#if (FFD_DEVICE_CONFIG || RFD_SUPPORT_SEND_BEACON) +/** + * @brief beacon send request primitive. + * + * @param mac_hndl[in] : the MAC instance handle + * + * @param ptr_st_bcon_send_req_params[in]: pointer to the beacon send request parameters + * + * @retval mac_status_enum_t : status to be sent to the Host + * + * @note this function will post DIRECT_DATA_TX_EVENT event that will be handled + * when call emngr_handle_all_events to call the cbk direct_tx_evnt_cbk + */ +mac_status_enum_t mlme_bcon_send_req(uint32_t mac_hndl, + mlme_bcon_send_req_params_st_t *ptr_st_bcon_send_req_params); +#endif +/** + * @brief used by a device to request an association with a coordinator, + * mlme_assoc_cfm callback is used to inform the next higher layer + * whether its request to associate was successful or unsuccessful. + * + * @param mac_hndl[in] : the MAC instance handle + * + * @param ptr_st_assoc_req_param[in]: pointer to the association request parameters + * + * @retval mac_status_enum_t : status to be sent to the Host + * + * @note this function will post DIRECT_DATA_TX_EVENT event that will be handled + * when call emngr_handle_all_events to call the cbk direct_tx_evnt_cbk + */ +mac_status_enum_t mlme_assoc_req(uint32_t mac_hndl, + mlme_assoc_req_param_st *ptr_st_assoc_req_param); + +#if (FFD_DEVICE_CONFIG || RFD_SUPPORT_ASSOCIATION_IND_RSP) +/** + * @brief association response primitive. + * + * @param mac_hndl[in] : the MAC instance handle + * + * @param ptr_st_assoc_req_param[in]: pointer to the association request parameters + * + * @retval None + * + * @note this function will post DIRECT_DATA_TX_EVENT event that will be handled + * when call emngr_handle_all_events to call the cbk direct_tx_evnt_cbk + */ +mac_status_enum_t mlme_assoc_res(uint32_t mac_hndl, + mlme_assoc_res_param_st *ptr_st_assoc_res_param); +#endif /* (FFD_DEVICE_CONFIG || RFD_SUPPORT_ASSOCIATION_IND_RSP) */ + +/** + * @brief Request to disassociate from a PAN or used by the coordinator to disassociate a device from a PAN, + * mlme_disassoc_cfm callback will be issued with data stored in structure mlme_disassoc_cfm_params_e + * + * @param mac_hndl : [in] the MAC instance handle + * @param mlme_disassoc_req_param : [in] pointer to disassociation request primitive params + * + * @retval mac_status_enum_t : status to be sent to the Host + * + * @note this function will post DIRECT_DATA_TX_EVENT event that will be handled + * when call emngr_handle_all_events to call the cbk direct_tx_evnt_cbk + */ +mac_status_enum_t mlme_disassoc_req(uint32_t mac_hndl, + mlme_disassoc_req_param_st* mlme_disassoc_req_param); + +/** + * @brief mlme get request for accessing PIB attributes + * + * @param mac_hndl : [in] the MAC instance handle + * @param pib_attr : [in] PIB attribute ID + * @param pib_attr_indx: [in] PIB attribute index + * @param pib_attr_value: [out] PIB value + * + * @retval void + */ +void mlme_get_req(uint32_t mac_hndl, uint8_t pib_attr_id, uint8_t pib_attr_indx, + attr_val_t *pib_attr_val); + +/** + * @brief mlme reset request for reset everything + * + * @param mac_hndl : [in] the MAC instance handle + * @param set_def_pib : [in] set default PIB flag + * + * @retval void + */ +void mlme_rst_req(uint32_t mac_hndl, uint8_t set_def_pib); + +/** + * + * @brief destroy all the mac handles registered + * + * @param none + * + * @retval void + */ +void mac_destroy(void); + +/** + * + * @brief mlme scn request issued to start one of [Active/ Enhanced Active / Passive / Energy Detection / Orphan] Scan type. + * + * @param mac_hndl : [in] the MAC instance handle + * @param mlme_req_prim_params : [in] pointer to request primitive params + * + * @retval void + * + * @note this function will post DIRECT_DATA_TX_EVENT event that will be handled + * when call emngr_handle_all_events to call the cbk direct_tx_evnt_cbk + * in cases of Active/Enhanced Active/Orphan Scaning only + */ +mac_status_enum_t mlme_scn_req(uint32_t mac_hndl, + mlme_scn_req_param_st* mlme_scn_req_params); + +#if SUPPORT_SEC +/** + * + * @brief remove a mac_sec_level_table specified by pib_attr_indx + * + * @param mac_hndl : [in] the MAC instance handle + * @param tbl_type : [in] Indicate type of removed table + * @param tbl_index : [in] Indicate index of SecTable of main security attribute to be removed + * @param tbl_sub_index: [in] Indicate index of SecTable of sub security attribute to be removed. + * + * @retval void + */ +void mlme_rmv_sec_table(uint32_t mac_hndl, uint8_t tbl_type, uint8_t tbl_index, uint8_t tbl_sub_index); +#endif /*end of SUPPORT_SEC*/ +/** + * + * @brief set a value of PIB attribute + * + * @param mac_hndl : [in] the MAC instance handle + * @param pib_attr : [in] PIB attribute ID + * @param pib_attr_indx: [in] PIB attribute index + * @param pib_attr_value: [in] PIB value + * + * @retval void + */ +void mlme_set_req(uint32_t mac_hndl, uint8_t pib_attr_id, uint8_t pib_attr_indx, + attr_val_t* pib_attr_val); + +#if (FFD_DEVICE_CONFIG || RFD_SUPPORT_START_PRIM) +/** + * + * @brief MLME-START.request is used by the PAN coordinator to initiate a new PAN or to begin + * using a new superframe configuration,mlme_strt_cfm callback is called to send + * MLME-START.confirm to the upper layers + * As stated in standard the impact of new updates will be added immediately in case + * of idle state or after transmission of beacon in case a beacon prepared to be sent. + * + * @param mac_hndl : [in] the MAC instance handle + * @param mlme_req_prim_params : [in] pointer to request primitive params + * + * @retval status + */ +mac_status_enum_t mlme_strt_req(uint32_t mac_hndl, + mlme_start_req_param_st* ptr_strt_req_params); +#endif /* (FFD_DEVICE_CONFIG || RFD_SUPPORT_START_PRIM) */ + +/** + * + * @brief The MLME-POLL.request primitive prompts the device to request data from the coordinator, + * mlme_poll_cfm callback will called by MLME to send MLME-POLL.confirm to the upper layers + * + * + * @param mac_hndl[in] : the MAC instance handle + * @param ptr_st_poll_req_param[in]: pointer to the polling request parameters + * + * @retval mac_status_enum_t + * + * @note this function will post DIRECT_DATA_TX_EVENT event that will be handled + * when call emngr_handle_all_events to call the cbk direct_tx_evnt_cbk + */ +mac_status_enum_t mlme_poll_req(uint32_t mac_hndl, mlme_poll_req_param_st *ptr_st_poll_req_param); + +#if (FFD_DEVICE_CONFIG || RFD_SUPPORT_ORPHAN_IND_RSP) +/** + * @brief used to respond to orphan notification command to inform the orphan device if associatied + * about its exchanged information during association. + * + * @param mac_hndl[in] : the MAC instance handle + * @param ptr_st_orphan_rsp_param[in]: pointer to the orphan response parameters + * + * @retval mac_status_enum_t + * + * @note this function will post DIRECT_DATA_TX_EVENT event that will be handled + * when call emngr_handle_all_events to call the cbk direct_tx_evnt_cbk + */ +mac_status_enum_t mlme_orphan_rsp(uint32_t mac_hndl, mlme_orphan_rsp_st_t *ptr_st_orphan_rsp_param); +#endif /* (FFD_DEVICE_CONFIG || RFD_SUPPORT_ORPHAN_IND_RSP) */ +/* ============================== MLME APIs ========================== */ + +/**************************************************MCPS-SAP public functions*******************************************/ +/** + * @brief requests the transfer of a data SPDU (i.e., MSDU) from a local SSCS + * entity to a single peer SSCS entity. + * + * @param ptr_st_data_req_params[in] : pointer to the data request parameters + * @param mac_hndl[in] : the MAC instance handle that initiated data send request + * + * @retval mac_status_enum_t : the results of a request. + * + * @note this function will post DIRECT_DATA_TX_EVENT event that will be handled + * when call emngr_handle_all_events to call the cbk direct_tx_evnt_cbk + */ +mac_status_enum_t mcps_data_send_req(mcps_data_req_params_st_t *ptr_st_mcps_data_req_params, uint32_t mac_hndl); +#if (FFD_DEVICE_CONFIG || RFD_SUPPORT_DATA_PURGE) +/** + * @brief The MCPS-PURGE.request primitive allows the next + * higher layer to purge an MSDU from the transaction queue ,After request is completed + * mcps_purge_cfm callback is called to send MCPS-PURGE.confirm to upper layer + * + * @param mac_hndl[in] : The MAC instance handle + * @param msdu_hndl[in] : The handle of the MSDU + * + * @retval void + */ +void mcps_purge_req(uint32_t mac_hndl, uint8_t msdu_hndl); +#endif /* (FFD_DEVICE_CONFIG || RFD_SUPPORT_DATA_PURGE) */ +/** + * + * @brief enable/disable RX for a given duration + * + * @param mac_hndl : [in] the MAC instance handle + * @param RxOnDuration : [in] Duration to enable RX with it starting from the current time , 0 means disable. + * @param RangingRxControl : [in] Ranging RX control it should be set to 0 " RANGING_OFF ". + * + * @retval mac_status_enum_t : status to be sent to the Host. + */ +mac_status_enum_t mlme_rx_enable_req(uint32_t mac_hndl, + uint32_t RxOnDuration, + uint8_t RangingRxControl); +/** + * + * @brief adds new entry to the Power Control Information table or update an existing entry + * + * @param mac_hndl : [in] the MAC instance handle + * @param short_addrs : [in] Short address of the link pair to transmit the packet to. + * @param ptr_ext_addrs : [in] Pointer to Extended (IEEE) address of the link pair to transmit the packet to. + * @param tx_pwr_level : [in] Tx power level of the link pair to transmit the packet to. + * @param last_rssi_level : [in] RSSI of last packet received on the link pair + * @param nwk_negotiated : [in] Flag = 0 during the joining / rejoining process , 1 after joining/rejoining + * @param cfm_flag : [in] Flag = 1 means that cfm is to be sent / = 0 otherwise + * + * @retval mac_status_enum_t : status to be sent to the Host. + */ +mac_status_enum_t mlme_set_pwr_info_table_req(uint32_t mac_hndl, + uint16_t short_addrs, + uint8_t *ptr_ext_addrs, + int8_t tx_pwr_level, + int8_t last_rssi_level, + uint8_t nwk_negotiated, + uint8_t cfm_flag); +/** + * + * @brief primitive returns the Power Control Information entry for the link pair + * + * @param mac_hndl : [in] the MAC instance handle + * @param short_addrs : [in] Short address of the link pair. + * @param ptr_ext_addrs : [in] Pointer to Extended (IEEE) address of the link. + * + * @retval None . + */ +void mlme_get_pwr_info_table_req(uint32_t mac_hndl, mac_addrs_mode_enum_t enum_addr_mode, uint8_t *ptr_addrs); + +#if (FFD_DEVICE_CONFIG || RFD_SUPPORT_SEND_BEACON) +/** + * @brief send beacon frame + * + * @param mac_hndl [in] : the MAC instance handle + * @param enum_bcon_typ[in] : beacon type [Beacon / Enhanced Beacon] + * @param bcon_tx_pwr [in] : tx power to be added in the tx poweer IE + * @param ptr_st_bcon_send_req_params [in] : pointer to send beacon parameters + * + * @retval mac_status_enum_t + * + * @note this function will post DIRECT_DATA_TX_EVENT event that will be handled + * when call emngr_handle_all_events to call the cbk direct_tx_evnt_cbk + */ +mac_status_enum_t mlme_send_bcon_frm(uint32_t mac_hndl, bcon_typ_t enum_bcon_typ, + int8_t bcon_tx_pwr, mlme_bcon_send_req_params_st_t *ptr_st_bcon_send_req_params); +#endif +#if (SUPPORT_MAC_HCI_UART) +/** + * @fn mlme_read_ieee_ext_addr + * + * @brief read ext address + * + * @param mac_hndl[in] : the MAC instance handle + * @param ext_addr[in] : extended address + */ +void mlme_read_ieee_ext_addr(uint32_t mac_hndl, uint8_t* ext_addr); +#endif /* SUPPORT_MAC_HCI_UART */ + +#if RADIO_CSMA +/** + * + * @brief set csma enable flag + * + * @param csma_en : [in] value for csma enable flag to be set + * + * @retval None . + */ +void mac_set_csma_en(uint8_t csma_en); +#endif /*end of RADIO_CSMA*/ +/** + * + * @brief set cca enable flag + * + * @param cca_en : [in] value for cca enable flag to be set + * + * @retval None . + */ +void mac_set_cca_en(uint8_t cca_en); +/** + * @fn mac_set_cca_threshold + * + * @brief set cca threshold + * + * @param mac_hndl : [in] the MAC instance handle + * @param cca_thresold : [in] value of cca threshold that set + * + * @retval mac_status_enum_t . + */ +mac_status_enum_t mac_set_cca_threshold(uint32_t mac_hndl, int8_t cca_thresold); +/** + * @fn mac_get_cca_threshold + * + * @brief get cca threshold + * + * @param mac_hndl : [in] the MAC instance handle + * @param cca_thresold : [in] pointer to value of cca threshold + * + * @retval mac_status_enum_t . + */ +mac_status_enum_t mac_get_cca_threshold(uint32_t mac_hndl, int8_t * cca_thresold); + +#if SUPPORT_ANT_DIV +/** + * @fn mac_set_ant_div_params + * + * @brief set antenna diversity parameters + * + * @param mac_hndl : [in] the MAC instance handle + * @param ptr_ant_div_params : [in] pointer to antenna diversity params structure + * + * @retval mac_status_enum_t . + */ +mac_status_enum_t mac_set_ant_div_params(uint32_t mac_hndl, antenna_diversity_st* ptr_ant_div_params); + +/** + * @fn mac_get_ant_div_params + * + * @brief get antenna diversity parameters + * + * @param mac_hndl : [in] the MAC instance handle + * @param ptr_ant_div_params : [out] pointer to antenna diversity params structure + * + * @retval None . + */ +void mac_get_ant_div_params(uint32_t mac_hndl, antenna_diversity_st* ptr_ant_div_params); + +/** + * @fn mac_set_default_ant_id + * + * @brief set the default antenna id to be used for transmission and reception + * + * @param mac_hndl : [in] the MAC instance handle + * @param default_ant_id : [in] the antenna id to be used as default + * + * @retval mac_status_enum_t . + */ +mac_status_enum_t mac_set_ant_div_enable(uint32_t mac_hndl, uint8_t enable); + +/** + * @fn mac_set_default_ant_id + * + * @brief enable/disable antenna diversity + * + * @param mac_hndl : [in] the MAC instance handle + * @param enable : [in] enable:1 / disable:0 + * + * @retval mac_status_enum_t . + */ +mac_status_enum_t mac_set_default_ant_id(uint32_t mac_hndl, uint8_t enable); + +/** + * @fn mac_set_ant_div_rssi_threshold + * + * @brief set antenna diversity rssi threshold + * + * @param mac_hndl : [in] the MAC instance handle + * @param rssi_threshold : [in] rssi threshold to compare with during antenna diversity measurements + * + * @retval mac_status_enum_t . + */ +mac_status_enum_t mac_set_ant_div_rssi_threshold(uint32_t mac_hndl, int8_t rssi_threshold); +#endif /* SUPPORT_ANT_DIV */ +#endif /* INCLUDE_MAC_HOST_INTF_H_ */ +/** + * @} + */ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/crypto.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/crypto.h new file mode 100644 index 000000000..9dd594913 --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/crypto.h @@ -0,0 +1,768 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/ot_inc/crypto.h#1 $*/ +/* + * Copyright (c) 2021, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief + * This file includes the platform abstraction for Crypto operations. + */ + +#ifndef OPENTHREAD_PLATFORM_CRYPTO_H_ +#define OPENTHREAD_PLATFORM_CRYPTO_H_ + +#include +#include + +#include "error.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup plat-crypto + * + * @brief + * This module includes the platform abstraction for Crypto. + * + * @{ + * + */ + +/** + * Defines the key types. + * + */ +typedef enum +{ + OT_CRYPTO_KEY_TYPE_RAW, ///< Key Type: Raw Data. + OT_CRYPTO_KEY_TYPE_AES, ///< Key Type: AES. + OT_CRYPTO_KEY_TYPE_HMAC, ///< Key Type: HMAC. + OT_CRYPTO_KEY_TYPE_ECDSA, ///< Key Type: ECDSA. +} otCryptoKeyType; + +/** + * Defines the key algorithms. + * + */ +typedef enum +{ + OT_CRYPTO_KEY_ALG_VENDOR, ///< Key Algorithm: Vendor Defined. + OT_CRYPTO_KEY_ALG_AES_ECB, ///< Key Algorithm: AES ECB. + OT_CRYPTO_KEY_ALG_HMAC_SHA_256, ///< Key Algorithm: HMAC SHA-256. + OT_CRYPTO_KEY_ALG_ECDSA, ///< Key Algorithm: ECDSA. +} otCryptoKeyAlgorithm; + +/** + * Defines the key usage flags. + * + */ +enum +{ + OT_CRYPTO_KEY_USAGE_NONE = 0, ///< Key Usage: Key Usage is empty. + OT_CRYPTO_KEY_USAGE_EXPORT = 1 << 0, ///< Key Usage: Key can be exported. + OT_CRYPTO_KEY_USAGE_ENCRYPT = 1 << 1, ///< Key Usage: Encryption (vendor defined). + OT_CRYPTO_KEY_USAGE_DECRYPT = 1 << 2, ///< Key Usage: AES ECB. + OT_CRYPTO_KEY_USAGE_SIGN_HASH = 1 << 3, ///< Key Usage: Sign Hash. + OT_CRYPTO_KEY_USAGE_VERIFY_HASH = 1 << 4, ///< Key Usage: Verify Hash. +}; + +/** + * Defines the key storage types. + * + */ +typedef enum +{ + OT_CRYPTO_KEY_STORAGE_VOLATILE, ///< Key Persistence: Key is volatile. + OT_CRYPTO_KEY_STORAGE_PERSISTENT, ///< Key Persistence: Key is persistent. +} otCryptoKeyStorage; + +/** + * This datatype represents the key reference. + * + */ +typedef uint32_t otCryptoKeyRef; + +/** + * @struct otCryptoKey + * + * Represents the Key Material required for Crypto operations. + * + */ +typedef struct otCryptoKey +{ + const uint8_t *mKey; ///< Pointer to the buffer containing key. NULL indicates to use `mKeyRef`. + uint16_t mKeyLength; ///< The key length in bytes (applicable when `mKey` is not NULL). + uint32_t mKeyRef; ///< The PSA key ref (requires `mKey` to be NULL). +} otCryptoKey; + +/** + * @struct otCryptoContext + * + * Stores the context object for platform APIs. + * + */ +typedef struct otCryptoContext +{ + void *mContext; ///< Pointer to the context. + uint16_t mContextSize; ///< The length of the context in bytes. +} otCryptoContext; + +/** + * Length of SHA256 hash (in bytes). + * + */ +#define OT_CRYPTO_SHA256_HASH_SIZE 32 + +/** + * @struct otPlatCryptoSha256Hash + * + * Represents a SHA-256 hash. + * + */ +OT_TOOL_PACKED_BEGIN +struct otPlatCryptoSha256Hash +{ + uint8_t m8[OT_CRYPTO_SHA256_HASH_SIZE]; ///< Hash bytes. +} OT_TOOL_PACKED_END; + +/** + * Represents a SHA-256 hash. + * + */ +typedef struct otPlatCryptoSha256Hash otPlatCryptoSha256Hash; + +/** + * Max buffer size (in bytes) for representing the EDCSA key-pair in DER format. + * + */ +#define OT_CRYPTO_ECDSA_MAX_DER_SIZE 125 + +/** + * @struct otPlatCryptoEcdsaKeyPair + * + * Represents an ECDSA key pair (public and private keys). + * + * The key pair is stored using Distinguished Encoding Rules (DER) format (per RFC 5915). + * + */ +typedef struct otPlatCryptoEcdsaKeyPair +{ + uint8_t mDerBytes[OT_CRYPTO_ECDSA_MAX_DER_SIZE]; + uint8_t mDerLength; +} otPlatCryptoEcdsaKeyPair; + +/** + * Buffer size (in bytes) for representing the EDCSA public key. + * + */ +#define OT_CRYPTO_ECDSA_PUBLIC_KEY_SIZE 64 + +/** + * @struct otPlatCryptoEcdsaPublicKey + * + * Represents a ECDSA public key. + * + * The public key is stored as a byte sequence representation of an uncompressed curve point (RFC 6605 - sec 4). + * + */ +OT_TOOL_PACKED_BEGIN +struct otPlatCryptoEcdsaPublicKey +{ + uint8_t m8[OT_CRYPTO_ECDSA_PUBLIC_KEY_SIZE]; +} OT_TOOL_PACKED_END; + +typedef struct otPlatCryptoEcdsaPublicKey otPlatCryptoEcdsaPublicKey; + +/** + * Buffer size (in bytes) for representing the EDCSA signature. + * + */ +#define OT_CRYPTO_ECDSA_SIGNATURE_SIZE 64 + +/** + * @struct otPlatCryptoEcdsaSignature + * + * Represents an ECDSA signature. + * + * The signature is encoded as the concatenated binary representation of two MPIs `r` and `s` which are calculated + * during signing (RFC 6605 - section 4). + * + */ +OT_TOOL_PACKED_BEGIN +struct otPlatCryptoEcdsaSignature +{ + uint8_t m8[OT_CRYPTO_ECDSA_SIGNATURE_SIZE]; +} OT_TOOL_PACKED_END; + +typedef struct otPlatCryptoEcdsaSignature otPlatCryptoEcdsaSignature; + +/** + * Max PBKDF2 SALT length: salt prefix (6) + extended panid (8) + network name (16) + * + */ +#define OT_CRYPTO_PBDKF2_MAX_SALT_SIZE 30 + +/** + * Initialize the Crypto module. + * + */ +void otPlatCryptoInit(void); + +/** + * Import a key into PSA ITS. + * + * @param[in,out] aKeyRef Pointer to the key ref to be used for crypto operations. + * @param[in] aKeyType Key Type encoding for the key. + * @param[in] aKeyAlgorithm Key algorithm encoding for the key. + * @param[in] aKeyUsage Key Usage encoding for the key (combinations of `OT_CRYPTO_KEY_USAGE_*`). + * @param[in] aKeyPersistence Key Persistence for this key + * @param[in] aKey Actual key to be imported. + * @param[in] aKeyLen Length of the key to be imported. + * + * @retval OT_ERROR_NONE Successfully imported the key. + * @retval OT_ERROR_FAILED Failed to import the key. + * @retval OT_ERROR_INVALID_ARGS @p aKey was set to NULL. + * + * @note If OT_CRYPTO_KEY_STORAGE_PERSISTENT is passed for aKeyPersistence then @p aKeyRef is input and platform + * should use the given aKeyRef and MUST not change it. + * + * If OT_CRYPTO_KEY_STORAGE_VOLATILE is passed for aKeyPersistence then @p aKeyRef is output, the initial + * value does not matter and platform API MUST update it to return the new key ref. + * + * This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + * + */ +otError otPlatCryptoImportKey(otCryptoKeyRef *aKeyRef, + otCryptoKeyType aKeyType, + otCryptoKeyAlgorithm aKeyAlgorithm, + int aKeyUsage, + otCryptoKeyStorage aKeyPersistence, + const uint8_t *aKey, + size_t aKeyLen); + +/** + * Export a key stored in PSA ITS. + * + * @param[in] aKeyRef The key ref to be used for crypto operations. + * @param[out] aBuffer Pointer to the buffer where key needs to be exported. + * @param[in] aBufferLen Length of the buffer passed to store the exported key. + * @param[out] aKeyLen Pointer to return the length of the exported key. + * + * @retval OT_ERROR_NONE Successfully exported @p aKeyRef. + * @retval OT_ERROR_FAILED Failed to export @p aKeyRef. + * @retval OT_ERROR_INVALID_ARGS @p aBuffer was NULL + * + * @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + * + */ +otError otPlatCryptoExportKey(otCryptoKeyRef aKeyRef, uint8_t *aBuffer, size_t aBufferLen, size_t *aKeyLen); + +/** + * Destroy a key stored in PSA ITS. + * + * @param[in] aKeyRef The key ref to be destroyed + * + * @retval OT_ERROR_NONE Successfully destroyed the key. + * @retval OT_ERROR_FAILED Failed to destroy the key. + * + * @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + * + */ +otError otPlatCryptoDestroyKey(otCryptoKeyRef aKeyRef); + +/** + * Check if the key ref passed has an associated key in PSA ITS. + * + * @param[in] aKeyRef The Key Ref to check. + * + * @retval TRUE There is an associated key with @p aKeyRef. + * @retval FALSE There is no associated key with @p aKeyRef. + * + * @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + * + */ +bool otPlatCryptoHasKey(otCryptoKeyRef aKeyRef); + +/** + * Initialize the HMAC operation. + * + * @param[in] aContext Context for HMAC operation. + * + * @retval OT_ERROR_NONE Successfully initialized HMAC operation. + * @retval OT_ERROR_FAILED Failed to initialize HMAC operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + * + * @note The platform driver shall point the context to the correct object such as psa_mac_operation_t or + * mbedtls_md_context_t. + * + */ +otError otPlatCryptoHmacSha256Init(otCryptoContext *aContext); + +/** + * Uninitialize the HMAC operation. + * + * @param[in] aContext Context for HMAC operation. + * + * @retval OT_ERROR_NONE Successfully uninitialized HMAC operation. + * @retval OT_ERROR_FAILED Failed to uninitialized HMAC operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + * + */ +otError otPlatCryptoHmacSha256Deinit(otCryptoContext *aContext); + +/** + * Start HMAC operation. + * + * @param[in] aContext Context for HMAC operation. + * @param[in] aKey Key material to be used for HMAC operation. + * + * @retval OT_ERROR_NONE Successfully started HMAC operation. + * @retval OT_ERROR_FAILED Failed to start HMAC operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext or @p aKey was NULL + * + */ +otError otPlatCryptoHmacSha256Start(otCryptoContext *aContext, const otCryptoKey *aKey); + +/** + * Update the HMAC operation with new input. + * + * @param[in] aContext Context for HMAC operation. + * @param[in] aBuf A pointer to the input buffer. + * @param[in] aBufLength The length of @p aBuf in bytes. + * + * @retval OT_ERROR_NONE Successfully updated HMAC with new input operation. + * @retval OT_ERROR_FAILED Failed to update HMAC operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext or @p aBuf was NULL + * + */ +otError otPlatCryptoHmacSha256Update(otCryptoContext *aContext, const void *aBuf, uint16_t aBufLength); + +/** + * Complete the HMAC operation. + * + * @param[in] aContext Context for HMAC operation. + * @param[out] aBuf A pointer to the output buffer. + * @param[in] aBufLength The length of @p aBuf in bytes. + * + * @retval OT_ERROR_NONE Successfully completed HMAC operation. + * @retval OT_ERROR_FAILED Failed to complete HMAC operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext or @p aBuf was NULL + * + */ +otError otPlatCryptoHmacSha256Finish(otCryptoContext *aContext, uint8_t *aBuf, size_t aBufLength); + +/** + * Initialise the AES operation. + * + * @param[in] aContext Context for AES operation. + * + * @retval OT_ERROR_NONE Successfully Initialised AES operation. + * @retval OT_ERROR_FAILED Failed to Initialise AES operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + * @retval OT_ERROR_NO_BUFS Cannot allocate the context. + * + * @note The platform driver shall point the context to the correct object such as psa_key_id + * or mbedtls_aes_context_t. + * + */ +otError otPlatCryptoAesInit(otCryptoContext *aContext); + +/** + * Set the key for AES operation. + * + * @param[in] aContext Context for AES operation. + * @param[out] aKey Key to use for AES operation. + * + * @retval OT_ERROR_NONE Successfully set the key for AES operation. + * @retval OT_ERROR_FAILED Failed to set the key for AES operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext or @p aKey was NULL + * + */ +otError otPlatCryptoAesSetKey(otCryptoContext *aContext, const otCryptoKey *aKey); + +/** + * Encrypt the given data. + * + * @param[in] aContext Context for AES operation. + * @param[in] aInput Pointer to the input buffer. + * @param[in] aOutput Pointer to the output buffer. + * + * @retval OT_ERROR_NONE Successfully encrypted @p aInput. + * @retval OT_ERROR_FAILED Failed to encrypt @p aInput. + * @retval OT_ERROR_INVALID_ARGS @p aContext or @p aKey or @p aOutput were NULL + * + */ +otError otPlatCryptoAesEncrypt(otCryptoContext *aContext, const uint8_t *aInput, uint8_t *aOutput); + +/** + * Free the AES context. + * + * @param[in] aContext Context for AES operation. + * + * @retval OT_ERROR_NONE Successfully freed AES context. + * @retval OT_ERROR_FAILED Failed to free AES context. + * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + * + */ +otError otPlatCryptoAesFree(otCryptoContext *aContext); + +/** + * Initialise the HKDF context. + * + * @param[in] aContext Context for HKDF operation. + * + * @retval OT_ERROR_NONE Successfully Initialised AES operation. + * @retval OT_ERROR_FAILED Failed to Initialise AES operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + * + * @note The platform driver shall point the context to the correct object such as psa_key_derivation_operation_t + * or HmacSha256::Hash + * + */ +otError otPlatCryptoHkdfInit(otCryptoContext *aContext); + +/** + * Perform HKDF Expand step. + * + * @param[in] aContext Operation context for HKDF operation. + * @param[in] aInfo Pointer to the Info sequence. + * @param[in] aInfoLength Length of the Info sequence. + * @param[out] aOutputKey Pointer to the output Key. + * @param[in] aOutputKeyLength Size of the output key buffer. + * + * @retval OT_ERROR_NONE HKDF Expand was successful. + * @retval OT_ERROR_FAILED HKDF Expand failed. + * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + * + */ +otError otPlatCryptoHkdfExpand(otCryptoContext *aContext, + const uint8_t *aInfo, + uint16_t aInfoLength, + uint8_t *aOutputKey, + uint16_t aOutputKeyLength); + +/** + * Perform HKDF Extract step. + * + * @param[in] aContext Operation context for HKDF operation. + * @param[in] aSalt Pointer to the Salt for HKDF. + * @param[in] aSaltLength Length of Salt. + * @param[in] aInputKey Pointer to the input key. + * + * @retval OT_ERROR_NONE HKDF Extract was successful. + * @retval OT_ERROR_FAILED HKDF Extract failed. + * + */ +otError otPlatCryptoHkdfExtract(otCryptoContext *aContext, + const uint8_t *aSalt, + uint16_t aSaltLength, + const otCryptoKey *aInputKey); + +/** + * Uninitialize the HKDF context. + * + * @param[in] aContext Context for HKDF operation. + * + * @retval OT_ERROR_NONE Successfully un-initialised HKDF operation. + * @retval OT_ERROR_FAILED Failed to un-initialised HKDF operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + * + */ +otError otPlatCryptoHkdfDeinit(otCryptoContext *aContext); + +/** + * Initialise the SHA-256 operation. + * + * @param[in] aContext Context for SHA-256 operation. + * + * @retval OT_ERROR_NONE Successfully initialised SHA-256 operation. + * @retval OT_ERROR_FAILED Failed to initialise SHA-256 operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + * + * + * @note The platform driver shall point the context to the correct object such as psa_hash_operation_t + * or mbedtls_sha256_context. + */ +otError otPlatCryptoSha256Init(otCryptoContext *aContext); + +/** + * Uninitialize the SHA-256 operation. + * + * @param[in] aContext Context for SHA-256 operation. + * + * @retval OT_ERROR_NONE Successfully un-initialised SHA-256 operation. + * @retval OT_ERROR_FAILED Failed to un-initialised SHA-256 operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + * + */ +otError otPlatCryptoSha256Deinit(otCryptoContext *aContext); + +/** + * Start SHA-256 operation. + * + * @param[in] aContext Context for SHA-256 operation. + * + * @retval OT_ERROR_NONE Successfully started SHA-256 operation. + * @retval OT_ERROR_FAILED Failed to start SHA-256 operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext was NULL + * + */ +otError otPlatCryptoSha256Start(otCryptoContext *aContext); + +/** + * Update SHA-256 operation with new input. + * + * @param[in] aContext Context for SHA-256 operation. + * @param[in] aBuf A pointer to the input buffer. + * @param[in] aBufLength The length of @p aBuf in bytes. + * + * @retval OT_ERROR_NONE Successfully updated SHA-256 with new input operation. + * @retval OT_ERROR_FAILED Failed to update SHA-256 operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext or @p aBuf was NULL + * + */ +otError otPlatCryptoSha256Update(otCryptoContext *aContext, const void *aBuf, uint16_t aBufLength); + +/** + * Finish SHA-256 operation. + * + * @param[in] aContext Context for SHA-256 operation. + * @param[in] aHash A pointer to the output buffer, where hash needs to be stored. + * @param[in] aHashSize The length of @p aHash in bytes. + * + * @retval OT_ERROR_NONE Successfully completed the SHA-256 operation. + * @retval OT_ERROR_FAILED Failed to complete SHA-256 operation. + * @retval OT_ERROR_INVALID_ARGS @p aContext or @p aHash was NULL + * + */ +otError otPlatCryptoSha256Finish(otCryptoContext *aContext, uint8_t *aHash, uint16_t aHashSize); + +/** + * Initialize cryptographically-secure pseudorandom number generator (CSPRNG). + * + */ +void otPlatCryptoRandomInit(void); + +/** + * Deinitialize cryptographically-secure pseudorandom number generator (CSPRNG). + * + */ +void otPlatCryptoRandomDeinit(void); + +/** + * Fills a given buffer with cryptographically secure random bytes. + * + * @param[out] aBuffer A pointer to a buffer to fill with the random bytes. + * @param[in] aSize Size of buffer (number of bytes to fill). + * + * @retval OT_ERROR_NONE Successfully filled buffer with random values. + * @retval OT_ERROR_FAILED Operation failed. + * + */ +otError otPlatCryptoRandomGet(uint8_t *aBuffer, uint16_t aSize); + +/** + * Generate and populate the output buffer with a new ECDSA key-pair. + * + * @param[out] aKeyPair A pointer to an ECDSA key-pair structure to store the generated key-pair. + * + * @retval OT_ERROR_NONE A new key-pair was generated successfully. + * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation. + * @retval OT_ERROR_NOT_CAPABLE Feature not supported. + * @retval OT_ERROR_FAILED Failed to generate key-pair. + * + */ +otError otPlatCryptoEcdsaGenerateKey(otPlatCryptoEcdsaKeyPair *aKeyPair); + +/** + * Get the associated public key from the input context. + * + * @param[in] aKeyPair A pointer to an ECDSA key-pair structure where the key-pair is stored. + * @param[out] aPublicKey A pointer to an ECDSA public key structure to store the public key. + * + * @retval OT_ERROR_NONE Public key was retrieved successfully, and @p aBuffer is updated. + * @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format). + * @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL. + * + */ +otError otPlatCryptoEcdsaGetPublicKey(const otPlatCryptoEcdsaKeyPair *aKeyPair, otPlatCryptoEcdsaPublicKey *aPublicKey); + +/** + * Calculate the ECDSA signature for a hashed message using the private key from the input context. + * + * Uses the deterministic digital signature generation procedure from RFC 6979. + * + * @param[in] aKeyPair A pointer to an ECDSA key-pair structure where the key-pair is stored. + * @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature calculation + * is stored. + * @param[out] aSignature A pointer to an ECDSA signature structure to output the calculated signature. + * + * @retval OT_ERROR_NONE The signature was calculated successfully, @p aSignature was updated. + * @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format). + * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature calculation. + * @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL. + * + */ +otError otPlatCryptoEcdsaSign(const otPlatCryptoEcdsaKeyPair *aKeyPair, + const otPlatCryptoSha256Hash *aHash, + otPlatCryptoEcdsaSignature *aSignature); + +/** + * Use the key from the input context to verify the ECDSA signature of a hashed message. + * + * @param[in] aPublicKey A pointer to an ECDSA public key structure where the public key for signature + * verification is stored. + * @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature verification + * is stored. + * @param[in] aSignature A pointer to an ECDSA signature structure where the signature value to be verified is + * stored. + * + * @retval OT_ERROR_NONE The signature was verified successfully. + * @retval OT_ERROR_SECURITY The signature is invalid. + * @retval OT_ERROR_INVALID_ARGS The key or hash is invalid. + * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature verification. + * + */ +otError otPlatCryptoEcdsaVerify(const otPlatCryptoEcdsaPublicKey *aPublicKey, + const otPlatCryptoSha256Hash *aHash, + const otPlatCryptoEcdsaSignature *aSignature); + +/** + * Calculate the ECDSA signature for a hashed message using the Key reference passed. + * + * Uses the deterministic digital signature generation procedure from RFC 6979. + * + * @param[in] aKeyRef Key Reference to the slot where the key-pair is stored. + * @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature calculation + * is stored. + * @param[out] aSignature A pointer to an ECDSA signature structure to output the calculated signature. + * + * @retval OT_ERROR_NONE The signature was calculated successfully, @p aSignature was updated. + * @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format). + * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature calculation. + * @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL. + * + * @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + * + */ +otError otPlatCryptoEcdsaSignUsingKeyRef(otCryptoKeyRef aKeyRef, + const otPlatCryptoSha256Hash *aHash, + otPlatCryptoEcdsaSignature *aSignature); + +/** + * Get the associated public key from the key reference passed. + * + * The public key is stored differently depending on the crypto backend library being used + * (OPENTHREAD_CONFIG_CRYPTO_LIB). + * + * This API must make sure to return the public key as a byte sequence representation of an + * uncompressed curve point (RFC 6605 - sec 4) + * + * @param[in] aKeyRef Key Reference to the slot where the key-pair is stored. + * @param[out] aPublicKey A pointer to an ECDSA public key structure to store the public key. + * + * @retval OT_ERROR_NONE Public key was retrieved successfully, and @p aBuffer is updated. + * @retval OT_ERROR_PARSE The key-pair DER format could not be parsed (invalid format). + * @retval OT_ERROR_INVALID_ARGS The @p aContext is NULL. + * + * @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + * + */ +otError otPlatCryptoEcdsaExportPublicKey(otCryptoKeyRef aKeyRef, otPlatCryptoEcdsaPublicKey *aPublicKey); + +/** + * Generate and import a new ECDSA key-pair at reference passed. + * + * @param[in] aKeyRef Key Reference to the slot where the key-pair is stored. + * + * @retval OT_ERROR_NONE A new key-pair was generated successfully. + * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation. + * @retval OT_ERROR_NOT_CAPABLE Feature not supported. + * @retval OT_ERROR_FAILED Failed to generate key-pair. + * + * @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + * + */ +otError otPlatCryptoEcdsaGenerateAndImportKey(otCryptoKeyRef aKeyRef); + +/** + * Use the keyref to verify the ECDSA signature of a hashed message. + * + * @param[in] aKeyRef Key Reference to the slot where the key-pair is stored. + * @param[in] aHash A pointer to a SHA-256 hash structure where the hash value for signature verification + * is stored. + * @param[in] aSignature A pointer to an ECDSA signature structure where the signature value to be verified is + * stored. + * + * @retval OT_ERROR_NONE The signature was verified successfully. + * @retval OT_ERROR_SECURITY The signature is invalid. + * @retval OT_ERROR_INVALID_ARGS The key or hash is invalid. + * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for signature verification. + * + * @note This API is only used by OT core when `OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE` is enabled. + * + */ +otError otPlatCryptoEcdsaVerifyUsingKeyRef(otCryptoKeyRef aKeyRef, + const otPlatCryptoSha256Hash *aHash, + const otPlatCryptoEcdsaSignature *aSignature); + +/** + * Perform PKCS#5 PBKDF2 using CMAC (AES-CMAC-PRF-128). + * + * @param[in] aPassword Password to use when generating key. + * @param[in] aPasswordLen Length of password. + * @param[in] aSalt Salt to use when generating key. + * @param[in] aSaltLen Length of salt. + * @param[in] aIterationCounter Iteration count. + * @param[in] aKeyLen Length of generated key in bytes. + * @param[out] aKey A pointer to the generated key. + * + * @retval OT_ERROR_NONE A new key-pair was generated successfully. + * @retval OT_ERROR_NO_BUFS Failed to allocate buffer for key generation. + * @retval OT_ERROR_NOT_CAPABLE Feature not supported. + * @retval OT_ERROR_FAILED Failed to generate key. + */ +otError otPlatCryptoPbkdf2GenerateKey(const uint8_t *aPassword, + uint16_t aPasswordLen, + const uint8_t *aSalt, + uint16_t aSaltLen, + uint32_t aIterationCounter, + uint16_t aKeyLen, + uint8_t *aKey); + +/** + * @} + * + */ + +#ifdef __cplusplus +} // end of extern "C" +#endif +#endif // OPENTHREAD_PLATFORM_CRYPTO_H_ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/error.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/error.h new file mode 100644 index 000000000..9428e38c4 --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/error.h @@ -0,0 +1,273 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/ot_inc/error.h#1 $*/ +/* + * Copyright (c) 2016, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief + * This file defines the errors used in the OpenThread. + */ + +#ifndef OPENTHREAD_ERROR_H_ +#define OPENTHREAD_ERROR_H_ + +#include "toolchain.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup api-error + * + * @brief + * This module includes error definitions used in OpenThread. + * + * @{ + * + */ + +/** + * Represents error codes used throughout OpenThread. + * + */ +typedef enum OT_MUST_USE_RESULT otError +{ + /** + * No error. + */ + OT_ERROR_NONE = 0, + + /** + * Operational failed. + */ + OT_ERROR_FAILED = 1, + + /** + * Message was dropped. + */ + OT_ERROR_DROP = 2, + + /** + * Insufficient buffers. + */ + OT_ERROR_NO_BUFS = 3, + + /** + * No route available. + */ + OT_ERROR_NO_ROUTE = 4, + + /** + * Service is busy and could not service the operation. + */ + OT_ERROR_BUSY = 5, + + /** + * Failed to parse message. + */ + OT_ERROR_PARSE = 6, + + /** + * Input arguments are invalid. + */ + OT_ERROR_INVALID_ARGS = 7, + + /** + * Security checks failed. + */ + OT_ERROR_SECURITY = 8, + + /** + * Address resolution requires an address query operation. + */ + OT_ERROR_ADDRESS_QUERY = 9, + + /** + * Address is not in the source match table. + */ + OT_ERROR_NO_ADDRESS = 10, + + /** + * Operation was aborted. + */ + OT_ERROR_ABORT = 11, + + /** + * Function or method is not implemented. + */ + OT_ERROR_NOT_IMPLEMENTED = 12, + + /** + * Cannot complete due to invalid state. + */ + OT_ERROR_INVALID_STATE = 13, + + /** + * No acknowledgment was received after macMaxFrameRetries (IEEE 802.15.4-2006). + */ + OT_ERROR_NO_ACK = 14, + + /** + * A transmission could not take place due to activity on the channel, i.e., the CSMA-CA mechanism has failed + * (IEEE 802.15.4-2006). + */ + OT_ERROR_CHANNEL_ACCESS_FAILURE = 15, + + /** + * Not currently attached to a Thread Partition. + */ + OT_ERROR_DETACHED = 16, + + /** + * FCS check failure while receiving. + */ + OT_ERROR_FCS = 17, + + /** + * No frame received. + */ + OT_ERROR_NO_FRAME_RECEIVED = 18, + + /** + * Received a frame from an unknown neighbor. + */ + OT_ERROR_UNKNOWN_NEIGHBOR = 19, + + /** + * Received a frame from an invalid source address. + */ + OT_ERROR_INVALID_SOURCE_ADDRESS = 20, + + /** + * Received a frame filtered by the address filter (allowlisted or denylisted). + */ + OT_ERROR_ADDRESS_FILTERED = 21, + + /** + * Received a frame filtered by the destination address check. + */ + OT_ERROR_DESTINATION_ADDRESS_FILTERED = 22, + + /** + * The requested item could not be found. + */ + OT_ERROR_NOT_FOUND = 23, + + /** + * The operation is already in progress. + */ + OT_ERROR_ALREADY = 24, + + /** + * The creation of IPv6 address failed. + */ + OT_ERROR_IP6_ADDRESS_CREATION_FAILURE = 26, + + /** + * Operation prevented by mode flags + */ + OT_ERROR_NOT_CAPABLE = 27, + + /** + * Coap response or acknowledgment or DNS, SNTP response not received. + */ + OT_ERROR_RESPONSE_TIMEOUT = 28, + + /** + * Received a duplicated frame. + */ + OT_ERROR_DUPLICATED = 29, + + /** + * Message is being dropped from reassembly list due to timeout. + */ + OT_ERROR_REASSEMBLY_TIMEOUT = 30, + + /** + * Message is not a TMF Message. + */ + OT_ERROR_NOT_TMF = 31, + + /** + * Received a non-lowpan data frame. + */ + OT_ERROR_NOT_LOWPAN_DATA_FRAME = 32, + + /** + * The link margin was too low. + */ + OT_ERROR_LINK_MARGIN_LOW = 34, + + /** + * Input (CLI) command is invalid. + */ + OT_ERROR_INVALID_COMMAND = 35, + + /** + * Special error code used to indicate success/error status is pending and not yet known. + * + */ + OT_ERROR_PENDING = 36, + + /** + * Request rejected. + */ + OT_ERROR_REJECTED = 37, + + /** + * The number of defined errors. + */ + OT_NUM_ERRORS, + + /** + * Generic error (should not use). + */ + OT_ERROR_GENERIC = 255, +} otError; + +/** + * Converts an otError enum into a string. + * + * @param[in] aError An otError enum. + * + * @returns A string representation of an otError. + * + */ +const char *otThreadErrorToString(otError aError); + +/** + * @} + * + */ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // OPENTHREAD_ERROR_H_ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/instance.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/instance.h new file mode 100644 index 000000000..488fe1f5d --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/instance.h @@ -0,0 +1,349 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/ot_inc/instance.h#1 $*/ +/* + * Copyright (c) 2016, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief + * This file defines the OpenThread Instance API. + */ + +#ifndef OPENTHREAD_INSTANCE_H_ +#define OPENTHREAD_INSTANCE_H_ + +#include + +#include "error.h" +#include "logging.h" +#include "toolchain.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The OpenThread API monotonic version number. + * + * This number MUST increase by one each time the contents of public OpenThread API include headers change. + * + * @note This number versions both OpenThread platform and user APIs. + * + */ +#define OPENTHREAD_API_VERSION (420) + +/** + * @addtogroup api-instance + * + * @brief + * This module includes functions that control the OpenThread Instance. + * + * @{ + * + */ + +/** + * Represents the OpenThread instance structure. + */ +typedef struct otInstance otInstance; + +/** + * Initializes the OpenThread library. + * + * Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be + * called before any other calls to OpenThread. + * + * Is available and can only be used when support for multiple OpenThread instances is enabled. + * + * @param[in] aInstanceBuffer The buffer for OpenThread to use for allocating the otInstance structure. + * @param[in,out] aInstanceBufferSize On input, the size of aInstanceBuffer. On output, if not enough space for + * otInstance, the number of bytes required for otInstance. + * + * @returns A pointer to the new OpenThread instance. + * + * @sa otInstanceFinalize + * + */ +otInstance *otInstanceInit(void *aInstanceBuffer, size_t *aInstanceBufferSize); + +/** + * Initializes the static single instance of the OpenThread library. + * + * Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be + * called before any other calls to OpenThread. + * + * Is available and can only be used when support for multiple OpenThread instances is disabled. + * + * @returns A pointer to the single OpenThread instance. + * + */ +otInstance *otInstanceInitSingle(void); + +/** + * Initializes the OpenThread instance. + * + * This function initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be + * called before any other calls to OpenThread. This method utilizes static buffer to initialize the OpenThread + * instance. + * + * This function is available and can only be used when support for multiple OpenThread static instances is + * enabled (`OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE`) + * + * @param[in] aIdx The index of the OpenThread instance to initialize. + * + * @returns A pointer to the new OpenThread instance. + * + */ +otInstance *otInstanceInitMultiple(uint8_t aIdx); + +/** + * Gets the instance identifier. + * + * The instance identifier is set to a random value when the instance is constructed, and then its value will not + * change after initialization. + * + * @returns The instance identifier. + * + */ +uint32_t otInstanceGetId(otInstance *aInstance); + +/** + * Indicates whether or not the instance is valid/initialized. + * + * The instance is considered valid if it is acquired and initialized using either `otInstanceInitSingle()` (in single + * instance case) or `otInstanceInit()` (in multi instance case). A subsequent call to `otInstanceFinalize()` causes + * the instance to be considered as uninitialized. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * @returns TRUE if the given instance is valid/initialized, FALSE otherwise. + * + */ +bool otInstanceIsInitialized(otInstance *aInstance); + +/** + * Disables the OpenThread library. + * + * Call this function when OpenThread is no longer in use. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + */ +void otInstanceFinalize(otInstance *aInstance); + +/** + * Returns the current instance uptime (in msec). + * + * Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. + * + * The uptime is given as number of milliseconds since OpenThread instance was initialized. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * @returns The uptime (number of milliseconds). + * + */ +uint64_t otInstanceGetUptime(otInstance *aInstance); + +#define OT_UPTIME_STRING_SIZE 24 ///< Recommended size for string representation of uptime. + +/** + * Returns the current instance uptime as a human-readable string. + * + * Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled. + * + * The string follows the format "::." for hours, minutes, seconds and millisecond (if uptime is + * shorter than one day) or "
d.::." (if longer than a day). + * + * If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated + * but the outputted string is always null-terminated. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[out] aBuffer A pointer to a char array to output the string. + * @param[in] aSize The size of @p aBuffer (in bytes). Recommended to use `OT_UPTIME_STRING_SIZE`. + * + */ +void otInstanceGetUptimeAsString(otInstance *aInstance, char *aBuffer, uint16_t aSize); + +#define OT_CHANGED_IP6_ADDRESS_ADDED (1U << 0) ///< IPv6 address was added +#define OT_CHANGED_IP6_ADDRESS_REMOVED (1U << 1) ///< IPv6 address was removed +#define OT_CHANGED_THREAD_ROLE (1U << 2) ///< Role (disabled, detached, child, router, leader) changed +#define OT_CHANGED_THREAD_LL_ADDR (1U << 3) ///< The link-local address changed +#define OT_CHANGED_THREAD_ML_ADDR (1U << 4) ///< The mesh-local address changed +#define OT_CHANGED_THREAD_RLOC_ADDED (1U << 5) ///< RLOC was added +#define OT_CHANGED_THREAD_RLOC_REMOVED (1U << 6) ///< RLOC was removed +#define OT_CHANGED_THREAD_PARTITION_ID (1U << 7) ///< Partition ID changed +#define OT_CHANGED_THREAD_KEY_SEQUENCE_COUNTER (1U << 8) ///< Thread Key Sequence changed +#define OT_CHANGED_THREAD_NETDATA (1U << 9) ///< Thread Network Data changed +#define OT_CHANGED_THREAD_CHILD_ADDED (1U << 10) ///< Child was added +#define OT_CHANGED_THREAD_CHILD_REMOVED (1U << 11) ///< Child was removed +#define OT_CHANGED_IP6_MULTICAST_SUBSCRIBED (1U << 12) ///< Subscribed to a IPv6 multicast address +#define OT_CHANGED_IP6_MULTICAST_UNSUBSCRIBED (1U << 13) ///< Unsubscribed from a IPv6 multicast address +#define OT_CHANGED_THREAD_CHANNEL (1U << 14) ///< Thread network channel changed +#define OT_CHANGED_THREAD_PANID (1U << 15) ///< Thread network PAN Id changed +#define OT_CHANGED_THREAD_NETWORK_NAME (1U << 16) ///< Thread network name changed +#define OT_CHANGED_THREAD_EXT_PANID (1U << 17) ///< Thread network extended PAN ID changed +#define OT_CHANGED_NETWORK_KEY (1U << 18) ///< Network key changed +#define OT_CHANGED_PSKC (1U << 19) ///< PSKc changed +#define OT_CHANGED_SECURITY_POLICY (1U << 20) ///< Security Policy changed +#define OT_CHANGED_CHANNEL_MANAGER_NEW_CHANNEL (1U << 21) ///< Channel Manager new pending Thread channel changed +#define OT_CHANGED_SUPPORTED_CHANNEL_MASK (1U << 22) ///< Supported channel mask changed +#define OT_CHANGED_COMMISSIONER_STATE (1U << 23) ///< Commissioner state changed +#define OT_CHANGED_THREAD_NETIF_STATE (1U << 24) ///< Thread network interface state changed +#define OT_CHANGED_THREAD_BACKBONE_ROUTER_STATE (1U << 25) ///< Backbone Router state changed +#define OT_CHANGED_THREAD_BACKBONE_ROUTER_LOCAL (1U << 26) ///< Local Backbone Router configuration changed +#define OT_CHANGED_JOINER_STATE (1U << 27) ///< Joiner state changed +#define OT_CHANGED_ACTIVE_DATASET (1U << 28) ///< Active Operational Dataset changed +#define OT_CHANGED_PENDING_DATASET (1U << 29) ///< Pending Operational Dataset changed +#define OT_CHANGED_NAT64_TRANSLATOR_STATE (1U << 30) ///< The state of NAT64 translator changed +#define OT_CHANGED_PARENT_LINK_QUALITY (1U << 31) ///< Parent link quality changed + +/** + * Represents a bit-field indicating specific state/configuration that has changed. See `OT_CHANGED_*` + * definitions. + * + */ +typedef uint32_t otChangedFlags; + +/** + * Pointer is called to notify certain configuration or state changes within OpenThread. + * + * @param[in] aFlags A bit-field indicating specific state that has changed. See `OT_CHANGED_*` definitions. + * @param[in] aContext A pointer to application-specific context. + * + */ +typedef void (*otStateChangedCallback)(otChangedFlags aFlags, void *aContext); + +/** + * Registers a callback to indicate when certain configuration or state changes within OpenThread. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aCallback A pointer to a function that is called with certain configuration or state changes. + * @param[in] aContext A pointer to application-specific context. + * + * @retval OT_ERROR_NONE Added the callback to the list of callbacks. + * @retval OT_ERROR_ALREADY The callback was already registered. + * @retval OT_ERROR_NO_BUFS Could not add the callback due to resource constraints. + * + */ +otError otSetStateChangedCallback(otInstance *aInstance, otStateChangedCallback aCallback, void *aContext); + +/** + * Removes a callback to indicate when certain configuration or state changes within OpenThread. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aCallback A pointer to a function that is called with certain configuration or state changes. + * @param[in] aContext A pointer to application-specific context. + * + */ +void otRemoveStateChangeCallback(otInstance *aInstance, otStateChangedCallback aCallback, void *aContext); + +/** + * Triggers a platform reset. + * + * The reset process ensures that all the OpenThread state/info (stored in volatile memory) is erased. Note that the + * `otPlatformReset` does not erase any persistent state/info saved in non-volatile memory. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + */ +void otInstanceReset(otInstance *aInstance); + +/** + * Triggers a platform reset to bootloader mode, if supported. + * + * Requires `OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE`. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * @retval OT_ERROR_NONE Reset to bootloader successfully. + * @retval OT_ERROR_BUSY Failed due to another operation is ongoing. + * @retval OT_ERROR_NOT_CAPABLE Not capable of resetting to bootloader. + * + */ +otError otInstanceResetToBootloader(otInstance *aInstance); + +/** + * Deletes all the settings stored on non-volatile memory, and then triggers a platform reset. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + */ +void otInstanceFactoryReset(otInstance *aInstance); + +/** + * Resets the internal states of the OpenThread radio stack. + * + * Callbacks and configurations are preserved. + * + * This API is only available under radio builds (`OPENTHREAD_RADIO = 1`). + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + */ +void otInstanceResetRadioStack(otInstance *aInstance); + +/** + * Erases all the OpenThread persistent info (network settings) stored on non-volatile memory. + * Erase is successful only if the device is in `disabled` state/role. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * @retval OT_ERROR_NONE All persistent info/state was erased successfully. + * @retval OT_ERROR_INVALID_STATE Device is not in `disabled` state/role. + * + */ +otError otInstanceErasePersistentInfo(otInstance *aInstance); + +/** + * Gets the OpenThread version string. + * + * @returns A pointer to the OpenThread version. + * + */ +const char *otGetVersionString(void); + +/** + * Gets the OpenThread radio version string. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * @returns A pointer to the OpenThread radio version. + * + */ +const char *otGetRadioVersionString(otInstance *aInstance); + +/** + * @} + * + */ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // OPENTHREAD_INSTANCE_H_ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/logging.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/logging.h new file mode 100644 index 000000000..7ab129026 --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/logging.h @@ -0,0 +1,187 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/ot_inc/logging.h#1 $*/ +/* + * Copyright (c) 2016, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief + * This file includes the platform abstraction for the debug log service. + */ + +#ifndef OPENTHREAD_PLATFORM_LOGGING_H_ +#define OPENTHREAD_PLATFORM_LOGGING_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup plat-logging + * + * @brief + * This module includes the platform abstraction for the debug log service. + * + * @{ + * + */ + +/** + * Log level None. + * + * @note Log Levels are defines so that embedded implementations can eliminate code at compile time via + * #if/#else/#endif. + * + */ +#define OT_LOG_LEVEL_NONE 0 + +/** + * Log level Critical. + * + * @note Log Levels are defines so that embedded implementations can eliminate code at compile time via + * #if/#else/#endif. + * + */ +#define OT_LOG_LEVEL_CRIT 1 + +/** + * Log level Warning. + * + * @note Log Levels are defines so that embedded implementations can eliminate code at compile time via + * #if/#else/#endif. + * + */ +#define OT_LOG_LEVEL_WARN 2 + +/** + * Log level Notice. + * + * @note Log Levels are defines so that embedded implementations can eliminate code at compile time via + * #if/#else/#endif. + * + */ +#define OT_LOG_LEVEL_NOTE 3 + +/** + * Log level Informational. + * + * @note Log Levels are defines so that embedded implementations can eliminate code at compile time via + * #if/#else/#endif. + * + */ +#define OT_LOG_LEVEL_INFO 4 + +/** + * Log level Debug. + * + * @note Log Levels are defines so that embedded implementations can eliminate code at compile time via + * #if/#else/#endif. + * + */ +#define OT_LOG_LEVEL_DEBG 5 + +/** + * Represents the log level. + * + */ +typedef int otLogLevel; + +/** + * Represents log regions. + * + * The support for log region is removed and instead each core module can define its own name to appended to the logs. + * However, the `otLogRegion` enumeration is still defined as before to help with platforms which we may be using it + * in their `otPlatLog()` implementation. The OT core will always emit all logs with `OT_LOG_REGION_CORE`. + * + */ +typedef enum otLogRegion +{ + OT_LOG_REGION_API = 1, ///< OpenThread API + OT_LOG_REGION_MLE = 2, ///< MLE + OT_LOG_REGION_ARP = 3, ///< EID-to-RLOC mapping. + OT_LOG_REGION_NET_DATA = 4, ///< Network Data + OT_LOG_REGION_ICMP = 5, ///< ICMPv6 + OT_LOG_REGION_IP6 = 6, ///< IPv6 + OT_LOG_REGION_TCP = 7, ///< TCP + OT_LOG_REGION_MAC = 8, ///< IEEE 802.15.4 MAC + OT_LOG_REGION_MEM = 9, ///< Memory + OT_LOG_REGION_NCP = 10, ///< NCP + OT_LOG_REGION_MESH_COP = 11, ///< Mesh Commissioning Protocol + OT_LOG_REGION_NET_DIAG = 12, ///< Network Diagnostic + OT_LOG_REGION_PLATFORM = 13, ///< Platform + OT_LOG_REGION_COAP = 14, ///< CoAP + OT_LOG_REGION_CLI = 15, ///< CLI + OT_LOG_REGION_CORE = 16, ///< OpenThread Core + OT_LOG_REGION_UTIL = 17, ///< Utility module + OT_LOG_REGION_BBR = 18, ///< Backbone Router (available since Thread 1.2) + OT_LOG_REGION_MLR = 19, ///< Multicast Listener Registration (available since Thread 1.2) + OT_LOG_REGION_DUA = 20, ///< Domain Unicast Address (available since Thread 1.2) + OT_LOG_REGION_BR = 21, ///< Border Router + OT_LOG_REGION_SRP = 22, ///< Service Registration Protocol (SRP) + OT_LOG_REGION_DNS = 23, ///< DNS +} otLogRegion; + +/** + * Outputs logs. + * + * Note that the support for log region is removed. The OT core will always emit all logs with `OT_LOG_REGION_CORE` + * as @p aLogRegion. + * + * @param[in] aLogLevel The log level. + * @param[in] aLogRegion The log region. + * @param[in] aFormat A pointer to the format string. + * @param[in] ... Arguments for the format specification. + * + */ +void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...); + +/** + * Handles OpenThread log level changes. + * + * This platform function is called whenever the OpenThread log level changes. + * This platform function is optional since an empty weak implementation has been provided. + * + * @note Only applicable when `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1`. + * + * @param[in] aLogLevel The new OpenThread log level. + * + */ +void otPlatLogHandleLevelChanged(otLogLevel aLogLevel); + +/** + * @} + * + */ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // OPENTHREAD_PLATFORM_LOGGING_H_ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/radio.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/radio.h new file mode 100644 index 000000000..b26c1b854 --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/radio.h @@ -0,0 +1,1405 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/ot_inc/radio.h#1 $*/ +/* + * Copyright (c) 2016, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief + * This file defines the radio interface for OpenThread. + * + */ + +#ifndef OPENTHREAD_PLATFORM_RADIO_H_ +#define OPENTHREAD_PLATFORM_RADIO_H_ + +#include + +#include "error.h" +#include "instance.h" +#include "crypto.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup plat-radio + * + * @brief + * This module includes the platform abstraction for radio communication. + * + * @{ + * + */ + +/** + * @defgroup radio-types Radio Types + * + * @brief + * This module includes the platform abstraction for a radio frame. + * + * @{ + * + */ + +enum +{ + OT_RADIO_FRAME_MAX_SIZE = 127, ///< aMaxPHYPacketSize (IEEE 802.15.4-2006) + OT_RADIO_FRAME_MIN_SIZE = 3, ///< Minimal size of frame FCS + CONTROL + + OT_RADIO_SYMBOLS_PER_OCTET = 2, ///< 2.4 GHz IEEE 802.15.4-2006 + OT_RADIO_BIT_RATE = 250000, ///< 2.4 GHz IEEE 802.15.4 (bits per second) + OT_RADIO_BITS_PER_OCTET = 8, ///< Number of bits per octet + + // Per IEEE 802.15.4-2015, 12.3.3 Symbol rate: + // The O-QPSK PHY symbol rate shall be 25 ksymbol/s when operating in the 868 MHz band and 62.5 ksymbol/s when + // operating in the 780 MHz, 915 MHz, 2380 MHz, or 2450 MHz band + OT_RADIO_SYMBOL_RATE = 62500, ///< The O-QPSK PHY symbol rate when operating in the 780MHz, 915MHz, 2380MHz, 2450MHz + OT_RADIO_SYMBOL_TIME = 1000000 * 1 / OT_RADIO_SYMBOL_RATE, ///< Symbol duration time in unit of microseconds + OT_RADIO_TEN_SYMBOLS_TIME = 10 * OT_RADIO_SYMBOL_TIME, ///< Time for 10 symbols in unit of microseconds + + OT_RADIO_LQI_NONE = 0, ///< LQI measurement not supported + OT_RADIO_RSSI_INVALID = 127, ///< Invalid or unknown RSSI value + OT_RADIO_POWER_INVALID = 127, ///< Invalid or unknown power value +}; + +/** + * Defines the channel page. + * + */ +enum +{ + OT_RADIO_CHANNEL_PAGE_0 = 0, ///< 2.4 GHz IEEE 802.15.4-2006 + OT_RADIO_CHANNEL_PAGE_0_MASK = (1U << OT_RADIO_CHANNEL_PAGE_0), ///< 2.4 GHz IEEE 802.15.4-2006 + OT_RADIO_CHANNEL_PAGE_2 = 2, ///< 915 MHz IEEE 802.15.4-2006 + OT_RADIO_CHANNEL_PAGE_2_MASK = (1U << OT_RADIO_CHANNEL_PAGE_2), ///< 915 MHz IEEE 802.15.4-2006 +}; + +/** + * Defines the frequency band channel range. + * + */ +enum +{ + OT_RADIO_915MHZ_OQPSK_CHANNEL_MIN = 1, ///< 915 MHz IEEE 802.15.4-2006 + OT_RADIO_915MHZ_OQPSK_CHANNEL_MAX = 10, ///< 915 MHz IEEE 802.15.4-2006 + OT_RADIO_915MHZ_OQPSK_CHANNEL_MASK = 0x3ff << OT_RADIO_915MHZ_OQPSK_CHANNEL_MIN, ///< 915 MHz IEEE 802.15.4-2006 + OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MIN = 11, ///< 2.4 GHz IEEE 802.15.4-2006 + OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MAX = 26, ///< 2.4 GHz IEEE 802.15.4-2006 + OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MASK = 0xffff << OT_RADIO_2P4GHZ_OQPSK_CHANNEL_MIN, ///< 2.4 GHz IEEE 802.15.4-2006 +}; + +/** + * Represents radio capabilities. + * + * The value is a bit-field indicating the capabilities supported by the radio. See `OT_RADIO_CAPS_*` definitions. + * + */ +typedef uint16_t otRadioCaps; + +/** + * Defines constants that are used to indicate different radio capabilities. See `otRadioCaps`. + * + */ +enum +{ + OT_RADIO_CAPS_NONE = 0, ///< Radio supports no capability. + OT_RADIO_CAPS_ACK_TIMEOUT = 1 << 0, ///< Radio supports AckTime event. + OT_RADIO_CAPS_ENERGY_SCAN = 1 << 1, ///< Radio supports Energy Scans. + OT_RADIO_CAPS_TRANSMIT_RETRIES = 1 << 2, ///< Radio supports tx retry logic with collision avoidance (CSMA). + OT_RADIO_CAPS_CSMA_BACKOFF = 1 << 3, ///< Radio supports CSMA backoff for frame transmission (but no retry). + OT_RADIO_CAPS_SLEEP_TO_TX = 1 << 4, ///< Radio supports direct transition from sleep to TX with CSMA. + OT_RADIO_CAPS_TRANSMIT_SEC = 1 << 5, ///< Radio supports tx security. + OT_RADIO_CAPS_TRANSMIT_TIMING = 1 << 6, ///< Radio supports tx at specific time. + OT_RADIO_CAPS_RECEIVE_TIMING = 1 << 7, ///< Radio supports rx at specific time. + OT_RADIO_CAPS_RX_ON_WHEN_IDLE = 1 << 8, ///< Radio supports RxOnWhenIdle handling. +}; + +#define OT_PANID_BROADCAST 0xffff ///< IEEE 802.15.4 Broadcast PAN ID + +/** + * Represents the IEEE 802.15.4 PAN ID. + * + */ +typedef uint16_t otPanId; + +/** + * Represents the IEEE 802.15.4 Short Address. + * + */ +typedef uint16_t otShortAddress; + +#define OT_EXT_ADDRESS_SIZE 8 ///< Size of an IEEE 802.15.4 Extended Address (bytes) + +/** + * Defines constants about size of header IE in ACK. + * + */ +enum +{ + OT_IE_HEADER_SIZE = 2, ///< Size of IE header in bytes. + OT_CSL_IE_SIZE = 4, ///< Size of CSL IE content in bytes. + OT_ACK_IE_MAX_SIZE = 16, ///< Max length for header IE in ACK. + OT_ENH_PROBING_IE_DATA_MAX_SIZE = 2, ///< Max length of Link Metrics data in Vendor-Specific IE. +}; + +#define CSL_IE_HEADER_BYTES_LO 0x04 ///< Fixed CSL IE header first byte +#define CSL_IE_HEADER_BYTES_HI 0x0d ///< Fixed CSL IE header second byte + +/** + * @struct otExtAddress + * + * Represents the IEEE 802.15.4 Extended Address. + * + */ +OT_TOOL_PACKED_BEGIN +struct otExtAddress +{ + uint8_t m8[OT_EXT_ADDRESS_SIZE]; ///< IEEE 802.15.4 Extended Address bytes +} OT_TOOL_PACKED_END; + +/** + * Represents the IEEE 802.15.4 Extended Address. + * + */ +typedef struct otExtAddress otExtAddress; + +#define OT_MAC_KEY_SIZE 16 ///< Size of the MAC Key in bytes. + +/** + * @struct otMacKey + * + * Represents a MAC Key. + * + */ +OT_TOOL_PACKED_BEGIN +struct otMacKey +{ + uint8_t m8[OT_MAC_KEY_SIZE]; ///< MAC Key bytes. +} OT_TOOL_PACKED_END; + +/** + * Represents a MAC Key. + * + */ +typedef struct otMacKey otMacKey; + +/** + * Represents a MAC Key Ref used by PSA. + * + */ +typedef otCryptoKeyRef otMacKeyRef; + +/** + * @struct otMacKeyMaterial + * + * Represents a MAC Key. + * + */ +typedef struct otMacKeyMaterial +{ + union + { + otMacKeyRef mKeyRef; ///< Reference to the key stored. + otMacKey mKey; ///< Key stored as literal. + } mKeyMaterial; +} otMacKeyMaterial; + +/** + * Defines constants about key types. + * + */ +typedef enum +{ + OT_KEY_TYPE_LITERAL_KEY = 0, ///< Use Literal Keys. + OT_KEY_TYPE_KEY_REF = 1, ///< Use Reference to Key. +} otRadioKeyType; + +/** + * Represents the IEEE 802.15.4 Header IE (Information Element) related information of a radio frame. + */ +typedef struct otRadioIeInfo +{ + int64_t mNetworkTimeOffset; ///< The time offset to the Thread network time. + uint8_t mTimeIeOffset; ///< The Time IE offset from the start of PSDU. + uint8_t mTimeSyncSeq; ///< The Time sync sequence. +} otRadioIeInfo; + +/** + * Represents an IEEE 802.15.4 radio frame. + */ +typedef struct otRadioFrame +{ + uint8_t *mPsdu; ///< The PSDU. + + uint16_t mLength; ///< Length of the PSDU. + uint8_t mChannel; ///< Channel used to transmit/receive the frame. + + uint8_t mRadioType; ///< Radio link type - should be ignored by radio driver. + + /** + * The union of transmit and receive information for a radio frame. + */ + union + { + /** + * Structure representing radio frame transmit information. + */ + struct + { + const otMacKeyMaterial *mAesKey; ///< The key material used for AES-CCM frame security. + otRadioIeInfo *mIeInfo; ///< The pointer to the Header IE(s) related information. + + /** + * The base time in microseconds for scheduled transmissions + * relative to the local radio clock, see `otPlatRadioGetNow` and + * `mTxDelay`. + */ + uint32_t mTxDelayBaseTime; + + /** + * The delay time in microseconds for this transmission referenced + * to `mTxDelayBaseTime`. + * + * Note: `mTxDelayBaseTime` + `mTxDelay` SHALL point to the point in + * time when the end of the SFD will be present at the local + * antenna, relative to the local radio clock. + */ + uint32_t mTxDelay; + + uint8_t mMaxCsmaBackoffs; ///< Maximum number of backoffs attempts before declaring CCA failure. + uint8_t mMaxFrameRetries; ///< Maximum number of retries allowed after a transmission failure. + + /** + * The RX channel after frame TX is done (after all frame retries - ack received, or timeout, or abort). + * + * Radio platforms can choose to fully ignore this. OT stack will make sure to call `otPlatRadioReceive()` + * with the desired RX channel after a frame TX is done and signaled in `otPlatRadioTxDone()` callback. + * Radio platforms that don't provide `OT_RADIO_CAPS_TRANSMIT_RETRIES` must always ignore this. + * + * This is intended for situations where there may be delay in interactions between OT stack and radio, as + * an example this is used in RCP/host architecture to make sure RCP switches to PAN channel more quickly. + * In particular, this can help with CSL tx to a sleepy child, where the child may use a different channel + * for CSL than the PAN channel. After frame tx, we want the radio/RCP to go back to the PAN channel + * quickly to ensure that parent does not miss tx from child afterwards, e.g., child responding to the + * earlier CSL transmitted frame from parent using PAN channel while radio still staying on CSL channel. + * + * The switch to the RX channel MUST happen after the frame TX is fully done, i.e., after all retries and + * when ack is received (when "Ack Request" flag is set on the TX frame) or ack timeout. Note that ack is + * expected on the same channel that frame is sent on. + * + */ + uint8_t mRxChannelAfterTxDone; + + /** + * Indicates whether frame counter and CSL IEs are properly updated in the header. + * + * If the platform layer does not provide `OT_RADIO_CAPS_TRANSMIT_SEC` capability, it can ignore this flag. + * + * If the platform provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability, then platform is expected to handle tx + * security processing and assignment of frame counter. In this case the following behavior is expected: + * + * When `mIsHeaderUpdated` is set, it indicates that OpenThread core has already set the frame counter and + * CSL IEs (if security is enabled) in the prepared frame. The counter is ensured to match the counter value + * from the previous attempts of the same frame. The platform should not assign or change the frame counter + * (but may still need to perform security processing depending on `mIsSecurityProcessed` flag). + * + * If `mIsHeaderUpdated` is not set, then the frame counter and key CSL IE not set in the frame by + * OpenThread core and it is the responsibility of the radio platform to assign them. The platform + * must update the frame header (assign counter and CSL IE values) before sending the frame over the air, + * however if the the transmission gets aborted and the frame is never sent over the air (e.g., channel + * access error) the platform may choose to not update the header. If the platform updates the header, + * it must also set this flag before passing the frame back from the `otPlatRadioTxDone()` callback. + * + */ + bool mIsHeaderUpdated : 1; + bool mIsARetx : 1; ///< Indicates whether the frame is a retransmission or not. + bool mCsmaCaEnabled : 1; ///< Set to true to enable CSMA-CA for this packet, false otherwise. + bool mCslPresent : 1; ///< Set to true if CSL header IE is present. + bool mIsSecurityProcessed : 1; ///< True if SubMac should skip the AES processing of this frame. + } mTxInfo; + + /** + * Structure representing radio frame receive information. + */ + struct + { + /** + * The time of the local radio clock in microseconds when the end of + * the SFD was present at the local antenna. + */ + uint64_t mTimestamp; + + uint32_t mAckFrameCounter; ///< ACK security frame counter (applicable when `mAckedWithSecEnhAck` is set). + uint8_t mAckKeyId; ///< ACK security key index (applicable when `mAckedWithSecEnhAck` is set). + int8_t mRssi; ///< Received signal strength indicator in dBm for received frames. + uint8_t mLqi; ///< Link Quality Indicator for received frames. + + // Flags + bool mAckedWithFramePending : 1; ///< This indicates if this frame was acknowledged with frame pending set. + bool mAckedWithSecEnhAck : 1; ///< This indicates if this frame was acknowledged with secured enhance ACK. + } mRxInfo; + } mInfo; +} otRadioFrame; + +/** + * Represents the state of a radio. + * Initially, a radio is in the Disabled state. + */ +typedef enum otRadioState +{ + OT_RADIO_STATE_DISABLED = 0, + OT_RADIO_STATE_SLEEP = 1, + OT_RADIO_STATE_RECEIVE = 2, + OT_RADIO_STATE_TRANSMIT = 3, + OT_RADIO_STATE_INVALID = 255, +} otRadioState; + +/** + * The following are valid radio state transitions: + * + * (Radio ON) + * +----------+ Enable() +-------+ Receive() +---------+ Transmit() +----------+ + * | |----------->| |----------->| |-------------->| | + * | Disabled | | Sleep | | Receive | | Transmit | + * | |<-----------| |<-----------| |<--------------| | + * +----------+ Disable() +-------+ Sleep() +---------+ Receive() +----------+ + * (Radio OFF) or + * signal TransmitDone + * + * During the IEEE 802.15.4 data request command the transition Sleep->Receive->Transmit + * can be shortened to direct transition from Sleep to Transmit if the platform supports + * the OT_RADIO_CAPS_SLEEP_TO_TX capability. + */ + +/** + * Represents radio coexistence metrics. + */ +typedef struct otRadioCoexMetrics +{ + uint32_t mNumGrantGlitch; ///< Number of grant glitches. + uint32_t mNumTxRequest; ///< Number of tx requests. + uint32_t mNumTxGrantImmediate; ///< Number of tx requests while grant was active. + uint32_t mNumTxGrantWait; ///< Number of tx requests while grant was inactive. + uint32_t mNumTxGrantWaitActivated; ///< Number of tx requests while grant was inactive that were ultimately granted. + uint32_t mNumTxGrantWaitTimeout; ///< Number of tx requests while grant was inactive that timed out. + uint32_t mNumTxGrantDeactivatedDuringRequest; ///< Number of tx that were in progress when grant was deactivated. + uint32_t mNumTxDelayedGrant; ///< Number of tx requests that were not granted within 50us. + uint32_t mAvgTxRequestToGrantTime; ///< Average time in usec from tx request to grant. + uint32_t mNumRxRequest; ///< Number of rx requests. + uint32_t mNumRxGrantImmediate; ///< Number of rx requests while grant was active. + uint32_t mNumRxGrantWait; ///< Number of rx requests while grant was inactive. + uint32_t mNumRxGrantWaitActivated; ///< Number of rx requests while grant was inactive that were ultimately granted. + uint32_t mNumRxGrantWaitTimeout; ///< Number of rx requests while grant was inactive that timed out. + uint32_t mNumRxGrantDeactivatedDuringRequest; ///< Number of rx that were in progress when grant was deactivated. + uint32_t mNumRxDelayedGrant; ///< Number of rx requests that were not granted within 50us. + uint32_t mAvgRxRequestToGrantTime; ///< Average time in usec from rx request to grant. + uint32_t mNumRxGrantNone; ///< Number of rx requests that completed without receiving grant. + bool mStopped; ///< Stats collection stopped due to saturation. +} otRadioCoexMetrics; + +/** + * Represents what metrics are specified to query. + * + */ +typedef struct otLinkMetrics +{ + bool mPduCount : 1; ///< Pdu count. + bool mLqi : 1; ///< Link Quality Indicator. + bool mLinkMargin : 1; ///< Link Margin. + bool mRssi : 1; ///< Received Signal Strength Indicator. + bool mReserved : 1; ///< Reserved, this is for reference device. +} otLinkMetrics; + +/** + * @} + * + */ + +/** + * @defgroup radio-config Radio Configuration + * + * @brief + * This module includes the platform abstraction for radio configuration. + * + * @{ + * + */ + +/** + * Get the radio capabilities. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @returns The radio capability bit vector (see `OT_RADIO_CAP_*` definitions). + * + */ +otRadioCaps otPlatRadioGetCaps(otInstance *aInstance); + +/** + * Get the radio version string. + * + * This is an optional radio driver platform function. If not provided by platform radio driver, OpenThread uses + * the OpenThread version instead (@sa otGetVersionString()). + * + * @param[in] aInstance The OpenThread instance structure. + * + * @returns A pointer to the OpenThread radio version. + * + */ +const char *otPlatRadioGetVersionString(otInstance *aInstance); + +/** + * Get the radio receive sensitivity value. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @returns The radio receive sensitivity value in dBm. + * + */ +int8_t otPlatRadioGetReceiveSensitivity(otInstance *aInstance); + +/** + * Gets the factory-assigned IEEE EUI-64 for this interface. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[out] aIeeeEui64 A pointer to the factory-assigned IEEE EUI-64. + * + */ +void otPlatRadioGetIeeeEui64(otInstance *aInstance, uint8_t *aIeeeEui64); + +/** + * Set the PAN ID for address filtering. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aPanId The IEEE 802.15.4 PAN ID. + * + */ +void otPlatRadioSetPanId(otInstance *aInstance, otPanId aPanId); + +/** + * Set the Extended Address for address filtering. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aExtAddress A pointer to the IEEE 802.15.4 Extended Address stored in little-endian byte order. + * + * + */ +void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aExtAddress); + +/** + * Set the Short Address for address filtering. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aShortAddress The IEEE 802.15.4 Short Address. + * + */ +void otPlatRadioSetShortAddress(otInstance *aInstance, otShortAddress aShortAddress); + +/** + * Get the radio's transmit power in dBm. + * + * @note The transmit power returned will be no larger than the power specified in the max power table for + * the current channel. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[out] aPower The transmit power in dBm. + * + * @retval OT_ERROR_NONE Successfully retrieved the transmit power. + * @retval OT_ERROR_INVALID_ARGS @p aPower was NULL. + * @retval OT_ERROR_NOT_IMPLEMENTED Transmit power configuration via dBm is not implemented. + * + */ +otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower); + +/** + * Set the radio's transmit power in dBm. + * + * @note The real transmit power will be no larger than the power specified in the max power table for + * the current channel. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aPower The transmit power in dBm. + * + * @retval OT_ERROR_NONE Successfully set the transmit power. + * @retval OT_ERROR_NOT_IMPLEMENTED Transmit power configuration via dBm is not implemented. + * + */ +otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower); + +/** + * Get the radio's CCA ED threshold in dBm measured at antenna connector per IEEE 802.15.4 - 2015 section 10.1.4. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[out] aThreshold The CCA ED threshold in dBm. + * + * @retval OT_ERROR_NONE Successfully retrieved the CCA ED threshold. + * @retval OT_ERROR_INVALID_ARGS @p aThreshold was NULL. + * @retval OT_ERROR_NOT_IMPLEMENTED CCA ED threshold configuration via dBm is not implemented. + * + */ +otError otPlatRadioGetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t *aThreshold); + +/** + * Set the radio's CCA ED threshold in dBm measured at antenna connector per IEEE 802.15.4 - 2015 section 10.1.4. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aThreshold The CCA ED threshold in dBm. + * + * @retval OT_ERROR_NONE Successfully set the transmit power. + * @retval OT_ERROR_INVALID_ARGS Given threshold is out of range. + * @retval OT_ERROR_NOT_IMPLEMENTED CCA ED threshold configuration via dBm is not implemented. + * + */ +otError otPlatRadioSetCcaEnergyDetectThreshold(otInstance *aInstance, int8_t aThreshold); + +/** + * Gets the external FEM's Rx LNA gain in dBm. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[out] aGain The external FEM's Rx LNA gain in dBm. + * + * @retval OT_ERROR_NONE Successfully retrieved the external FEM's LNA gain. + * @retval OT_ERROR_INVALID_ARGS @p aGain was NULL. + * @retval OT_ERROR_NOT_IMPLEMENTED External FEM's LNA setting is not implemented. + * + */ +otError otPlatRadioGetFemLnaGain(otInstance *aInstance, int8_t *aGain); + +/** + * Sets the external FEM's Rx LNA gain in dBm. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aGain The external FEM's Rx LNA gain in dBm. + * + * @retval OT_ERROR_NONE Successfully set the external FEM's LNA gain. + * @retval OT_ERROR_NOT_IMPLEMENTED External FEM's LNA gain setting is not implemented. + * + */ +otError otPlatRadioSetFemLnaGain(otInstance *aInstance, int8_t aGain); + +/** + * Get the status of promiscuous mode. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @retval TRUE Promiscuous mode is enabled. + * @retval FALSE Promiscuous mode is disabled. + * + */ +bool otPlatRadioGetPromiscuous(otInstance *aInstance); + +/** + * Enable or disable promiscuous mode. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aEnable TRUE to enable or FALSE to disable promiscuous mode. + * + */ +void otPlatRadioSetPromiscuous(otInstance *aInstance, bool aEnable); + +/** + * Sets the rx-on-when-idle state to the radio platform. + * + * There are a few situations that the radio can enter sleep state if the device is in rx-off-when-idle state but + * it's hard and costly for the SubMac to identify these situations and instruct the radio to enter sleep: + * + * - Finalization of a regular frame reception task, provided that: + * - The frame is received without errors and passes the filtering and it's not an spurious ACK. + * - ACK is not requested or transmission of ACK is not possible due to internal conditions. + * - Finalization of a frame transmission or transmission of an ACK frame, when ACK is not requested in the transmitted + * frame. + * - Finalization of the reception operation of a requested ACK due to: + * - ACK timeout expiration. + * - Reception of an invalid ACK or not an ACK frame. + * - Reception of the proper ACK, unless the transmitted frame was a Data Request Command and the frame pending bit + * on the received ACK is set to true. In this case the radio platform implementation SHOULD keep the receiver on + * until a determined timeout which triggers an idle period start.`OPENTHREAD_CONFIG_MAC_DATA_POLL_TIMEOUT` can be + * taken as a reference for this. + * - Finalization of a stand alone CCA task. + * - Finalization of a CCA operation with busy result during CSMA/CA procedure. + * - Finalization of an Energy Detection task. + * - Finalization of a radio reception window scheduled with `otPlatRadioReceiveAt`. + * + * If a platform supports `OT_RADIO_CAPS_RX_ON_WHEN_IDLE` it must also support `OT_RADIO_CAPS_CSMA_BACKOFF` and handle + * idle periods after CCA as described above. + * + * Upon the transition of the "RxOnWhenIdle" flag from TRUE to FALSE, the radio platform should enter sleep mode. + * If the radio is currently in receive mode, it should enter sleep mode immediately. Otherwise, it should enter sleep + * mode after the current operation is completed. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aEnable TRUE to keep radio in Receive state, FALSE to put to Sleep state during idle periods. + * + */ +void otPlatRadioSetRxOnWhenIdle(otInstance *aInstance, bool aEnable); + +/** + * Update MAC keys and key index + * + * Is used when radio provides OT_RADIO_CAPS_TRANSMIT_SEC capability. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aKeyIdMode The key ID mode. + * @param[in] aKeyId Current MAC key index. + * @param[in] aPrevKey A pointer to the previous MAC key. + * @param[in] aCurrKey A pointer to the current MAC key. + * @param[in] aNextKey A pointer to the next MAC key. + * @param[in] aKeyType Key Type used. + * + */ +void otPlatRadioSetMacKey(otInstance *aInstance, + uint8_t aKeyIdMode, + uint8_t aKeyId, + const otMacKeyMaterial *aPrevKey, + const otMacKeyMaterial *aCurrKey, + const otMacKeyMaterial *aNextKey, + otRadioKeyType aKeyType); + +/** + * Sets the current MAC frame counter value. + * + * Is used when radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aMacFrameCounter The MAC frame counter value. + * + */ +void otPlatRadioSetMacFrameCounter(otInstance *aInstance, uint32_t aMacFrameCounter); + +/** + * Sets the current MAC frame counter value only if the new given value is larger than the current value. + * + * Is used when radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * @param[in] aMacFrameCounter The MAC frame counter value. + * + */ +void otPlatRadioSetMacFrameCounterIfLarger(otInstance *aInstance, uint32_t aMacFrameCounter); + +/** + * Get the current time in microseconds referenced to a continuous monotonic + * local radio clock (64 bits width). + * + * The radio clock SHALL NOT wrap during the device's uptime. Implementations + * SHALL therefore identify and compensate for internal counter overflows. The + * clock does not have a defined epoch and it SHALL NOT introduce any continuous + * or discontinuous adjustments (e.g. leap seconds). Implementations SHALL + * compensate for any sleep times of the device. + * + * Implementations MAY choose to discipline the radio clock and compensate for + * sleep times by any means (e.g. by combining a high precision/low power RTC + * with a high resolution counter) as long as the exposed combined clock + * provides continuous monotonic microsecond resolution ticks within the + * accuracy limits announced by @ref otPlatRadioGetCslAccuracy. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * @returns The current time in microseconds. UINT64_MAX when platform does not + * support or radio time is not ready. + * + */ +uint64_t otPlatRadioGetNow(otInstance *aInstance); + +/** + * Get the bus speed in bits/second between the host and the radio chip. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * @returns The bus speed in bits/second between the host and the radio chip. + * Return 0 when the MAC and above layer and Radio layer resides on the same chip. + * + */ +uint32_t otPlatRadioGetBusSpeed(otInstance *aInstance); + +/** + * @} + * + */ + +/** + * @defgroup radio-operation Radio Operation + * + * @brief + * This module includes the platform abstraction for radio operations. + * + * @{ + * + */ + +/** + * Get current state of the radio. + * + * Is not required by OpenThread. It may be used for debugging and/or application-specific purposes. + * + * @note This function may be not implemented. It does not affect OpenThread. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @return Current state of the radio. + * + */ +otRadioState otPlatRadioGetState(otInstance *aInstance); + +/** + * Enable the radio. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @retval OT_ERROR_NONE Successfully enabled. + * @retval OT_ERROR_FAILED The radio could not be enabled. + * + */ +otError otPlatRadioEnable(otInstance *aInstance); + +/** + * Disable the radio. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @retval OT_ERROR_NONE Successfully transitioned to Disabled. + * @retval OT_ERROR_INVALID_STATE The radio was not in sleep state. + * + */ +otError otPlatRadioDisable(otInstance *aInstance); + +/** + * Check whether radio is enabled or not. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @returns TRUE if the radio is enabled, FALSE otherwise. + * + */ +bool otPlatRadioIsEnabled(otInstance *aInstance); + +/** + * Transition the radio from Receive to Sleep (turn off the radio). + * + * @param[in] aInstance The OpenThread instance structure. + * + * @retval OT_ERROR_NONE Successfully transitioned to Sleep. + * @retval OT_ERROR_BUSY The radio was transmitting. + * @retval OT_ERROR_INVALID_STATE The radio was disabled. + * + */ +otError otPlatRadioSleep(otInstance *aInstance); + +/** + * Transition the radio from Sleep to Receive (turn on the radio). + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aChannel The channel to use for receiving. + * + * @retval OT_ERROR_NONE Successfully transitioned to Receive. + * @retval OT_ERROR_INVALID_STATE The radio was disabled or transmitting. + * + */ +otError otPlatRadioReceive(otInstance *aInstance, uint8_t aChannel); + +/** + * Schedule a radio reception window at a specific time and duration. + * + * @param[in] aChannel The radio channel on which to receive. + * @param[in] aStart The receive window start time relative to the local + * radio clock, see `otPlatRadioGetNow`. The radio + * receiver SHALL be on and ready to receive the first + * symbol of a frame's SHR at the window start time. + * @param[in] aDuration The receive window duration, in microseconds, as + * measured by the local radio clock. The radio SHOULD be + * turned off (or switched to TX mode if an ACK frame + * needs to be sent) after that duration unless it is + * still actively receiving a frame. In the latter case + * the radio SHALL be kept in reception mode until frame + * reception has either succeeded or failed. + * + * @retval OT_ERROR_NONE Successfully scheduled receive window. + * @retval OT_ERROR_FAILED The receive window could not be scheduled. + */ +otError otPlatRadioReceiveAt(otInstance *aInstance, uint8_t aChannel, uint32_t aStart, uint32_t aDuration); + +/** + * The radio driver calls this method to notify OpenThread of a received frame. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aFrame A pointer to the received frame or NULL if the receive operation failed. + * @param[in] aError OT_ERROR_NONE when successfully received a frame, + * OT_ERROR_ABORT when reception was aborted and a frame was not received, + * OT_ERROR_NO_BUFS when a frame could not be received due to lack of rx buffer space. + * + */ +extern void otPlatRadioReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError); + +/** + * The radio driver calls this method to notify OpenThread diagnostics module of a received frame. + * + * Is used when diagnostics is enabled. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aFrame A pointer to the received frame or NULL if the receive operation failed. + * @param[in] aError OT_ERROR_NONE when successfully received a frame, + * OT_ERROR_ABORT when reception was aborted and a frame was not received, + * OT_ERROR_NO_BUFS when a frame could not be received due to lack of rx buffer space. + * + */ +extern void otPlatDiagRadioReceiveDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError); + +/** + * Get the radio transmit frame buffer. + * + * OpenThread forms the IEEE 802.15.4 frame in this buffer then calls `otPlatRadioTransmit()` to request transmission. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @returns A pointer to the transmit frame buffer. + * + */ +otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance); + +/** + * Begin the transmit sequence on the radio. + * + * The caller must form the IEEE 802.15.4 frame in the buffer provided by `otPlatRadioGetTransmitBuffer()` before + * requesting transmission. The channel and transmit power are also included in the otRadioFrame structure. + * + * The transmit sequence consists of: + * 1. Transitioning the radio to Transmit from one of the following states: + * - Receive if RX is on when the device is idle or OT_RADIO_CAPS_SLEEP_TO_TX is not supported + * - Sleep if RX is off when the device is idle and OT_RADIO_CAPS_SLEEP_TO_TX is supported. + * 2. Transmits the psdu on the given channel and at the given transmit power. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aFrame A pointer to the frame to be transmitted. + * + * @retval OT_ERROR_NONE Successfully transitioned to Transmit. + * @retval OT_ERROR_INVALID_STATE The radio was not in the Receive state. + * + */ +otError otPlatRadioTransmit(otInstance *aInstance, otRadioFrame *aFrame); + +/** + * The radio driver calls this method to notify OpenThread that the transmission has started. + * + * @note This function should be called by the same thread that executes all of the other OpenThread code. It should + * not be called by ISR or any other task. + * + * @param[in] aInstance A pointer to the OpenThread instance structure. + * @param[in] aFrame A pointer to the frame that is being transmitted. + * + */ +extern void otPlatRadioTxStarted(otInstance *aInstance, otRadioFrame *aFrame); + +/** + * The radio driver calls this function to notify OpenThread that the transmit operation has completed, + * providing both the transmitted frame and, if applicable, the received ack frame. + * + * When radio provides `OT_RADIO_CAPS_TRANSMIT_SEC` capability, radio platform layer updates @p aFrame + * with the security frame counter and key index values maintained by the radio. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aFrame A pointer to the frame that was transmitted. + * @param[in] aAckFrame A pointer to the ACK frame, NULL if no ACK was received. + * @param[in] aError OT_ERROR_NONE when the frame was transmitted, + * OT_ERROR_NO_ACK when the frame was transmitted but no ACK was received, + * OT_ERROR_CHANNEL_ACCESS_FAILURE tx could not take place due to activity on the channel, + * OT_ERROR_ABORT when transmission was aborted for other reasons. + * + */ +extern void otPlatRadioTxDone(otInstance *aInstance, otRadioFrame *aFrame, otRadioFrame *aAckFrame, otError aError); + +/** + * The radio driver calls this method to notify OpenThread diagnostics module that the transmission has completed. + * + * Is used when diagnostics is enabled. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aFrame A pointer to the frame that was transmitted. + * @param[in] aError OT_ERROR_NONE when the frame was transmitted, + * OT_ERROR_CHANNEL_ACCESS_FAILURE tx could not take place due to activity on the channel, + * OT_ERROR_ABORT when transmission was aborted for other reasons. + * + */ +extern void otPlatDiagRadioTransmitDone(otInstance *aInstance, otRadioFrame *aFrame, otError aError); + +/** + * Get the most recent RSSI measurement. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @returns The RSSI in dBm when it is valid. 127 when RSSI is invalid. + * + */ +int8_t otPlatRadioGetRssi(otInstance *aInstance); + +/** + * Begin the energy scan sequence on the radio. + * + * Is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aScanChannel The channel to perform the energy scan on. + * @param[in] aScanDuration The duration, in milliseconds, for the channel to be scanned. + * + * @retval OT_ERROR_NONE Successfully started scanning the channel. + * @retval OT_ERROR_BUSY The radio is performing energy scanning. + * @retval OT_ERROR_NOT_IMPLEMENTED The radio doesn't support energy scanning. + * + */ +otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration); + +/** + * The radio driver calls this method to notify OpenThread that the energy scan is complete. + * + * Is used when radio provides OT_RADIO_CAPS_ENERGY_SCAN capability. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aEnergyScanMaxRssi The maximum RSSI encountered on the scanned channel. + * + */ +extern void otPlatRadioEnergyScanDone(otInstance *aInstance, int8_t aEnergyScanMaxRssi); + +/** + * Enable/Disable source address match feature. + * + * The source address match feature controls how the radio layer decides the "frame pending" bit for acks sent in + * response to data request commands from children. + * + * If disabled, the radio layer must set the "frame pending" on all acks to data request commands. + * + * If enabled, the radio layer uses the source address match table to determine whether to set or clear the "frame + * pending" bit in an ack to a data request command. + * + * The source address match table provides the list of children for which there is a pending frame. Either a short + * address or an extended/long address can be added to the source address match table. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aEnable Enable/disable source address match feature. + * + */ +void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable); + +/** + * Add a short address to the source address match table. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aShortAddress The short address to be added. + * + * @retval OT_ERROR_NONE Successfully added short address to the source match table. + * @retval OT_ERROR_NO_BUFS No available entry in the source match table. + * + */ +otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, otShortAddress aShortAddress); + +/** + * Add an extended address to the source address match table. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aExtAddress The extended address to be added stored in little-endian byte order. + * + * @retval OT_ERROR_NONE Successfully added extended address to the source match table. + * @retval OT_ERROR_NO_BUFS No available entry in the source match table. + * + */ +otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress); + +/** + * Remove a short address from the source address match table. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aShortAddress The short address to be removed. + * + * @retval OT_ERROR_NONE Successfully removed short address from the source match table. + * @retval OT_ERROR_NO_ADDRESS The short address is not in source address match table. + * + */ +otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, otShortAddress aShortAddress); + +/** + * Remove an extended address from the source address match table. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aExtAddress The extended address to be removed stored in little-endian byte order. + * + * @retval OT_ERROR_NONE Successfully removed the extended address from the source match table. + * @retval OT_ERROR_NO_ADDRESS The extended address is not in source address match table. + * + */ +otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddress *aExtAddress); + +/** + * Clear all short addresses from the source address match table. + * + * @param[in] aInstance The OpenThread instance structure. + * + */ +void otPlatRadioClearSrcMatchShortEntries(otInstance *aInstance); + +/** + * Clear all the extended/long addresses from source address match table. + * + * @param[in] aInstance The OpenThread instance structure. + * + */ +void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance); + +/** + * Get the radio supported channel mask that the device is allowed to be on. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @returns The radio supported channel mask. + * + */ +uint32_t otPlatRadioGetSupportedChannelMask(otInstance *aInstance); + +/** + * Gets the radio preferred channel mask that the device prefers to form on. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @returns The radio preferred channel mask. + * + */ +uint32_t otPlatRadioGetPreferredChannelMask(otInstance *aInstance); + +/** + * Enable the radio coex. + * + * Is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aEnabled TRUE to enable the radio coex, FALSE otherwise. + * + * @retval OT_ERROR_NONE Successfully enabled. + * @retval OT_ERROR_FAILED The radio coex could not be enabled. + * + */ +otError otPlatRadioSetCoexEnabled(otInstance *aInstance, bool aEnabled); + +/** + * Check whether radio coex is enabled or not. + * + * Is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @returns TRUE if the radio coex is enabled, FALSE otherwise. + * + */ +bool otPlatRadioIsCoexEnabled(otInstance *aInstance); + +/** + * Get the radio coexistence metrics. + * + * Is used when feature OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE is enabled. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[out] aCoexMetrics A pointer to the coexistence metrics structure. + * + * @retval OT_ERROR_NONE Successfully retrieved the coex metrics. + * @retval OT_ERROR_INVALID_ARGS @p aCoexMetrics was NULL. + */ +otError otPlatRadioGetCoexMetrics(otInstance *aInstance, otRadioCoexMetrics *aCoexMetrics); + +/** + * Enable or disable CSL receiver. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aCslPeriod CSL period, 0 for disabling CSL. CSL period is in unit of 10 symbols. + * @param[in] aShortAddr The short source address of CSL receiver's peer. + * @param[in] aExtAddr The extended source address of CSL receiver's peer. + * + * @note Platforms should use CSL peer addresses to include CSL IE when generating enhanced acks. + * + * @retval OT_ERROR_NOT_IMPLEMENTED Radio driver doesn't support CSL. + * @retval OT_ERROR_FAILED Other platform specific errors. + * @retval OT_ERROR_NONE Successfully enabled or disabled CSL. + * + */ +otError otPlatRadioEnableCsl(otInstance *aInstance, + uint32_t aCslPeriod, + otShortAddress aShortAddr, + const otExtAddress *aExtAddr); + +/** + * Reset CSL receiver in the platform. + * + * @note Defaults to `otPlatRadioEnableCsl(aInstance,0, Mac::kShortAddrInvalid, nullptr);` + * + * @param[in] aInstance The OpenThread instance structure. + * + * @retval OT_ERROR_NOT_IMPLEMENTED Radio driver doesn't support CSL. + * @retval OT_ERROR_FAILED Other platform specific errors. + * @retval OT_ERROR_NONE Successfully disabled CSL. + * + */ +otError otPlatRadioResetCsl(otInstance *aInstance); + +/** + * Update CSL sample time in radio driver. + * + * Sample time is stored in radio driver as a copy to calculate phase when + * sending ACK with CSL IE. The CSL sample (window) of the CSL receiver extends + * before and after the sample time. The CSL sample time marks a timestamp in + * the CSL sample window when a frame should be received in "ideal conditions" + * if there would be no inaccuracy/clock-drift. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aCslSampleTime The next sample time, in microseconds. It is + * the time when the first symbol of the MHR of + * the frame is expected. + */ +void otPlatRadioUpdateCslSampleTime(otInstance *aInstance, uint32_t aCslSampleTime); + +/** + * Get the current estimated worst case accuracy (maximum ± deviation from the + * nominal frequency) of the local radio clock in units of PPM. This is the + * clock used to schedule CSL operations. + * + * @note Implementations MAY estimate this value based on current operating + * conditions (e.g. temperature). + * + * In case the implementation does not estimate the current value but returns a + * fixed value, this value MUST be the worst-case accuracy over all possible + * foreseen operating conditions (temperature, pressure, etc) of the + * implementation. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * @returns The current CSL rx/tx scheduling drift, in PPM. + * + */ +uint8_t otPlatRadioGetCslAccuracy(otInstance *aInstance); + +/** + * The fixed uncertainty (i.e. random jitter) of the arrival time of CSL + * transmissions received by this device in units of 10 microseconds. + * + * This designates the worst case constant positive or negative deviation of + * the actual arrival time of a transmission from the transmission time + * calculated relative to the local radio clock independent of elapsed time. In + * addition to uncertainty accumulated over elapsed time, the CSL channel sample + * ("RX window") must be extended by twice this deviation such that an actual + * transmission is guaranteed to be detected by the local receiver in the + * presence of random arrival time jitter. + * + * @param[in] aInstance A pointer to an OpenThread instance. + * + * @returns The CSL Uncertainty in units of 10 us. + * + */ +uint8_t otPlatRadioGetCslUncertainty(otInstance *aInstance); + +/** + * Set the max transmit power for a specific channel. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aChannel The radio channel. + * @param[in] aMaxPower The max power in dBm, passing OT_RADIO_RSSI_INVALID will disable this channel. + * + * @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented + * @retval OT_ERROR_INVALID_ARGS The specified channel is not valid. + * @retval OT_ERROR_FAILED Other platform specific errors. + * @retval OT_ERROR_NONE Successfully set max transmit power. + * + */ +otError otPlatRadioSetChannelMaxTransmitPower(otInstance *aInstance, uint8_t aChannel, int8_t aMaxPower); + +/** + * Set the region code. + * + * The radio region format is the 2-bytes ascii representation of the + * ISO 3166 alpha-2 code. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aRegionCode The radio region code. The `aRegionCode >> 8` is first ascii char + * and the `aRegionCode & 0xff` is the second ascii char. + * + * @retval OT_ERROR_FAILED Other platform specific errors. + * @retval OT_ERROR_NONE Successfully set region code. + * @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. + * + */ +otError otPlatRadioSetRegion(otInstance *aInstance, uint16_t aRegionCode); + +/** + * Get the region code. + * + * The radio region format is the 2-bytes ascii representation of the + * ISO 3166 alpha-2 code. + + * @param[in] aInstance The OpenThread instance structure. + * @param[out] aRegionCode The radio region. + * + * @retval OT_ERROR_INVALID_ARGS @p aRegionCode is nullptr. + * @retval OT_ERROR_FAILED Other platform specific errors. + * @retval OT_ERROR_NONE Successfully got region code. + * @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. + * + */ +otError otPlatRadioGetRegion(otInstance *aInstance, uint16_t *aRegionCode); + +/** + * Enable/disable or update Enhanced-ACK Based Probing in radio for a specific Initiator. + * + * After Enhanced-ACK Based Probing is configured by a specific Probing Initiator, the Enhanced-ACK sent to that + * node should include Vendor-Specific IE containing Link Metrics data. This method informs the radio to start/stop to + * collect Link Metrics data and include Vendor-Specific IE that containing the data in Enhanced-ACK sent to that + * Probing Initiator. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aLinkMetrics This parameter specifies what metrics to query. Per spec 4.11.3.4.4.6, at most 2 metrics + * can be specified. The probing would be disabled if @p `aLinkMetrics` is bitwise 0. + * @param[in] aShortAddress The short address of the Probing Initiator. + * @param[in] aExtAddress The extended source address of the Probing Initiator. @p aExtAddr MUST NOT be `NULL`. + * + * @retval OT_ERROR_NONE Successfully configured the Enhanced-ACK Based Probing. + * @retval OT_ERROR_INVALID_ARGS @p aExtAddress is `NULL`. + * @retval OT_ERROR_NOT_FOUND The Initiator indicated by @p aShortAddress is not found when trying to clear. + * @retval OT_ERROR_NO_BUFS No more Initiator can be supported. + * @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. + * + */ +otError otPlatRadioConfigureEnhAckProbing(otInstance *aInstance, + otLinkMetrics aLinkMetrics, + otShortAddress aShortAddress, + const otExtAddress *aExtAddress); + +/** + * Add a calibrated power of the specified channel to the power calibration table. + * + * @note This API is an optional radio platform API. It's up to the platform layer to implement it. + * + * The @p aActualPower is the actual measured output power when the parameters of the radio hardware modules + * are set to the @p aRawPowerSetting. + * + * The raw power setting is an opaque byte array. OpenThread doesn't define the format of the raw power setting. + * Its format is radio hardware related and it should be defined by the developers in the platform radio driver. + * For example, if the radio hardware contains both the radio chip and the FEM chip, the raw power setting can be + * a combination of the radio power register and the FEM gain value. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aChannel The radio channel. + * @param[in] aActualPower The actual power in 0.01dBm. + * @param[in] aRawPowerSetting A pointer to the raw power setting byte array. + * @param[in] aRawPowerSettingLength The length of the @p aRawPowerSetting. + * + * @retval OT_ERROR_NONE Successfully added the calibrated power to the power calibration table. + * @retval OT_ERROR_NO_BUFS No available entry in the power calibration table. + * @retval OT_ERROR_INVALID_ARGS The @p aChannel, @p aActualPower or @p aRawPowerSetting is invalid or the + * @p aActualPower already exists in the power calibration table. + * @retval OT_ERROR_NOT_IMPLEMENTED This feature is not implemented. + * + */ +otError otPlatRadioAddCalibratedPower(otInstance *aInstance, + uint8_t aChannel, + int16_t aActualPower, + const uint8_t *aRawPowerSetting, + uint16_t aRawPowerSettingLength); + +/** + * Clear all calibrated powers from the power calibration table. + * + * @note This API is an optional radio platform API. It's up to the platform layer to implement it. + * + * @param[in] aInstance The OpenThread instance structure. + * + * @retval OT_ERROR_NONE Successfully cleared all calibrated powers from the power calibration table. + * @retval OT_ERROR_NOT_IMPLEMENTED This feature is not implemented. + * + */ +otError otPlatRadioClearCalibratedPowers(otInstance *aInstance); + +/** + * Set the target power for the given channel. + * + * @note This API is an optional radio platform API. It's up to the platform layer to implement it. + * If this API is implemented, the function `otPlatRadioSetTransmitPower()` should be disabled. + * + * The radio driver should set the actual output power to be less than or equal to the target power and as close + * as possible to the target power. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aChannel The radio channel. + * @param[in] aTargetPower The target power in 0.01dBm. Passing `INT16_MAX` will disable this channel to use the + * target power. + * + * @retval OT_ERROR_NONE Successfully set the target power. + * @retval OT_ERROR_INVALID_ARGS The @p aChannel or @p aTargetPower is invalid. + * @retval OT_ERROR_NOT_IMPLEMENTED The feature is not implemented. + * + */ +otError otPlatRadioSetChannelTargetPower(otInstance *aInstance, uint8_t aChannel, int16_t aTargetPower); + +/** + * Get the raw power setting for the given channel. + * + * @note OpenThread `src/core/utils` implements a default implementation of the API `otPlatRadioAddCalibratedPower()`, + * `otPlatRadioClearCalibratedPowers()` and `otPlatRadioSetChannelTargetPower()`. This API is provided by + * the default implementation to get the raw power setting for the given channel. If the platform doesn't + * use the default implementation, it can ignore this API. + * + * Platform radio layer should parse the raw power setting based on the radio layer defined format and set the + * parameters of each radio hardware module. + * + * @param[in] aInstance The OpenThread instance structure. + * @param[in] aChannel The radio channel. + * @param[out] aRawPowerSetting A pointer to the raw power setting byte array. + * @param[in,out] aRawPowerSettingLength On input, a pointer to the size of @p aRawPowerSetting. + * On output, a pointer to the length of the raw power setting data. + * + * @retval OT_ERROR_NONE Successfully got the target power. + * @retval OT_ERROR_INVALID_ARGS The @p aChannel is invalid, @p aRawPowerSetting or @p aRawPowerSettingLength is NULL + * or @aRawPowerSettingLength is too short. + * @retval OT_ERROR_NOT_FOUND The raw power setting for the @p aChannel was not found. + * + */ +extern otError otPlatRadioGetRawPowerSetting(otInstance *aInstance, + uint8_t aChannel, + uint8_t *aRawPowerSetting, + uint16_t *aRawPowerSettingLength); + +/** + * @} + * + */ + +/** + * @} + * + */ + +#ifdef __cplusplus +} // end of extern "C" +#endif + +#endif // OPENTHREAD_PLATFORM_RADIO_H_ +/** + * @} + */ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/toolchain.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/toolchain.h new file mode 100644 index 000000000..7918f3500 --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/toolchain.h @@ -0,0 +1,316 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/ot_inc/toolchain.h#1 $*/ +/* + * Copyright (c) 2016, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @addtogroup plat-toolchain + * + * @brief + * This module defines a toolchain abstraction layer through macros. + * + * Usage: + * + * @code + * + * typedef + * OT_TOOL_PACKED_BEGIN + * struct + * { + * char mField1; + * union + * { + * char mField2; + * long mField3; + * } OT_TOOL_PACKED_FIELD; + * } OT_TOOL_PACKED_END packed_struct_t; + * + * @endcode + * + * @{ + * + */ + +#ifndef OPENTHREAD_PLATFORM_TOOLCHAIN_H_ +#define OPENTHREAD_PLATFORM_TOOLCHAIN_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @def OT_MUST_USE_RESULT + * + * Compiler-specific indication that a class or enum must be used when it is + * the return value of a function. + * + * @note This is currently only available with clang (C++17 implements it + * as attribute [[nodiscard]]). + * @note To suppress the 'unused-result' warning/error, please use the + * '-Wno-unused-result' compiler option. + * + */ +#if defined(__clang__) && (__clang_major__ >= 4 || (__clang_major__ >= 3 && __clang_minor__ >= 9)) +#define OT_MUST_USE_RESULT __attribute__((warn_unused_result)) +#else +#define OT_MUST_USE_RESULT +#endif + +/** + * @def OT_TOOL_PACKED_BEGIN + * + * Compiler-specific indication that a class or struct must be byte packed. + * + */ + +/** + * @def OT_TOOL_PACKED_FIELD + * + * Indicate to the compiler a nested struct or union to be packed + * within byte packed class or struct. + * + */ + +/** + * @def OT_TOOL_PACKED_END + * + * Compiler-specific indication at the end of a byte packed class or struct. + * + */ + +/** + * @def OT_TOOL_WEAK + * + * Compiler-specific weak symbol modifier. + * + */ + +/** + * @def OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK + * + * Specifies that a function or method takes `printf` style arguments and should be type-checked against + * a format string. + * + * Must be added after the function/method declaration. For example: + * + * `void MyPrintf(void *aObject, const char *aFormat, ...) OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(2, 3);` + * + * The two argument index values indicate format string and first argument to check against it. They start at index 1 + * for the first parameter in a function and at index 2 for the first parameter in a method. + * + * @param[in] aFmtIndex The argument index of the format string. + * @param[in] aStartIndex The argument index of the first argument to check against the format string. + * + */ + +// =========== TOOLCHAIN SELECTION : START =========== + +#if defined(__GNUC__) || defined(__clang__) || defined(__CC_ARM) || defined(__TI_ARM__) + +// https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html +// http://www.keil.com/support/man/docs/armcc/armcc_chr1359124973480.htm + +#define OT_TOOL_PACKED_BEGIN +#define OT_TOOL_PACKED_FIELD __attribute__((packed)) +#define OT_TOOL_PACKED_END __attribute__((packed)) +#define OT_TOOL_WEAK __attribute__((weak)) + +#define OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(aFmtIndex, aStartIndex) \ + __attribute__((format(printf, aFmtIndex, aStartIndex))) + +#elif defined(__ICCARM__) || defined(__ICC8051__) + +// http://supp.iar.com/FilesPublic/UPDINFO/004916/arm/doc/EWARM_DevelopmentGuide.ENU.pdf + +#include "intrinsics.h" + +#define OT_TOOL_PACKED_BEGIN __packed +#define OT_TOOL_PACKED_FIELD +#define OT_TOOL_PACKED_END +#define OT_TOOL_WEAK __weak + +#define OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(aFmtIndex, aStartIndex) + +#elif defined(__SDCC) + +// Structures are packed by default in sdcc, as it primarily targets 8-bit MCUs. + +#define OT_TOOL_PACKED_BEGIN +#define OT_TOOL_PACKED_FIELD +#define OT_TOOL_PACKED_END +#define OT_TOOL_WEAK + +#define OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(aFmtIndex, aStartIndex) + +#else + +#error "Error: No valid Toolchain specified" + +// Symbols for Doxygen + +#define OT_TOOL_PACKED_BEGIN +#define OT_TOOL_PACKED_FIELD +#define OT_TOOL_PACKED_END +#define OT_TOOL_WEAK + +#define OT_TOOL_PRINTF_STYLE_FORMAT_ARG_CHECK(aFmtIndex, aStartIndex) + +#endif + +// =========== TOOLCHAIN SELECTION : END =========== + +/** + * @def OT_UNUSED_VARIABLE + * + * Suppress unused variable warning in specific toolchains. + * + */ + +/** + * @def OT_UNREACHABLE_CODE + * + * Suppress Unreachable code warning in specific toolchains. + * + */ + +#if defined(__ICCARM__) + +#include + +#define OT_UNUSED_VARIABLE(VARIABLE) \ + do \ + { \ + if (&VARIABLE == NULL) \ + { \ + } \ + } while (false) + +#define OT_UNREACHABLE_CODE(CODE) \ + _Pragma("diag_suppress=Pe111") _Pragma("diag_suppress=Pe128") CODE _Pragma("diag_default=Pe111") \ + _Pragma("diag_default=Pe128") + +#elif defined(__CC_ARM) + +#include + +#define OT_UNUSED_VARIABLE(VARIABLE) \ + do \ + { \ + if (&VARIABLE == NULL) \ + { \ + } \ + } while (false) + +#define OT_UNREACHABLE_CODE(CODE) CODE + +#elif defined(__TI_ARM__) + +#include + +#define OT_UNUSED_VARIABLE(VARIABLE) \ + do \ + { \ + if (&VARIABLE == NULL) \ + { \ + } \ + } while (false) + +/* + * #112-D statement is unreachable + * #129-D loop is not reachable + */ +#define OT_UNREACHABLE_CODE(CODE) \ + _Pragma("diag_push") _Pragma("diag_suppress 112") _Pragma("diag_suppress 129") CODE _Pragma("diag_pop") + +#else + +#define OT_UNUSED_VARIABLE(VARIABLE) \ + do \ + { \ + (void)(VARIABLE); \ + } while (false) + +#define OT_UNREACHABLE_CODE(CODE) CODE + +#endif + +/* + * Keil and IAR compiler doesn't provide type limits for C++. + */ +#ifdef __cplusplus +#if defined(__CC_ARM) || defined(__ICCARM__) + +#ifndef UINT8_MAX +#define UINT8_MAX 0xff +#endif + +#ifndef UINT16_MAX +#define UINT16_MAX 0xffff +#endif + +#endif +#endif + +#ifdef __APPLE__ +#define OT_APPLE_IGNORE_GNU_FOLDING_CONSTANT(...) \ + _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wgnu-folding-constant\"") \ + __VA_ARGS__ _Pragma("GCC diagnostic pop") +#else +#define OT_APPLE_IGNORE_GNU_FOLDING_CONSTANT(...) __VA_ARGS__ +#endif + +/** + * @def OT_FALL_THROUGH + * + * Suppress fall through warning in specific compiler. + * + */ +#if defined(__cplusplus) && (__cplusplus >= 201703L) +#define OT_FALL_THROUGH [[fallthrough]] +#elif defined(__clang__) +#define OT_FALL_THROUGH [[clang::fallthrough]] +#elif defined(__GNUC__) && (__GNUC__ >= 7) +#define OT_FALL_THROUGH __attribute__((fallthrough)) +#else +#define OT_FALL_THROUGH \ + do \ + { \ + } while (false) /* fallthrough */ +#endif + +/** + * @} + * + */ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // OPENTHREAD_PLATFORM_TOOLCHAIN_H_ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/types.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/types.h new file mode 100644 index 000000000..ea83fe398 --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ot_inc/types.h @@ -0,0 +1,1103 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/ot_inc/types.h#1 $*/ +/* + * Copyright (c) 2016, The OpenThread Authors. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * @brief + * This file defines the types and structures used in the OpenThread library API. + */ + +#ifndef OPENTHREAD_TYPES_H_ +#define OPENTHREAD_TYPES_H_ + +#include +#include +#ifdef OTDLL +#include +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _WIN32 +#pragma warning(disable:4214) // nonstandard extension used: bit field types other than int +#ifdef _KERNEL_MODE +#include +#else +#include +#endif +#else +#ifndef CONTAINING_RECORD +/*#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Winvalid-offsetof" +#define CONTAINING_RECORD(address, type, field) \ + ((type *)((uint8_t*)(address) - offsetof(type, field))) +#pragma GCC diagnostic pop*/ +#define BASE 0x1 +#define myoffsetof(s,m) (((size_t)&(((s*)BASE)->m))-BASE) +#define CONTAINING_RECORD(address, type, field) \ + ((type *)((uint8_t*)(address) - myoffsetof(type, field))) +#endif /* CONTAINING_RECORD */ +#endif /* _WIN32 */ + +/** + * This type represents the OpenThread instance structure. + */ +typedef struct otInstance otInstance; + +#ifdef OTDLL + +/** + * This type represents the handle to the OpenThread API. + */ +typedef struct otApiInstance otApiInstance; + +/** + * This type represents a list of device GUIDs. + */ +typedef struct otDeviceList +{ + uint16_t aDevicesLength; + GUID aDevices[1]; +} otDeviceList; + +#endif + +/** + * This enumeration represents error codes used throughout OpenThread. + */ +typedef enum otError +{ + /** + * No error. + */ + OT_ERROR_NONE = 0, + + /** + * Operational failed. + */ + OT_ERROR_FAILED = 1, + + /** + * Message was dropped. + */ + OT_ERROR_DROP = 2, + + /** + * Insufficient buffers. + */ + OT_ERROR_NO_BUFS = 3, + + /** + * No route available. + */ + OT_ERROR_NO_ROUTE = 4, + + /** + * Service is busy and could not service the operation. + */ + OT_ERROR_BUSY = 5, + + /** + * Failed to parse message or arguments. + */ + OT_ERROR_PARSE = 6, + + /** + * Input arguments are invalid. + */ + OT_ERROR_INVALID_ARGS = 7, + + /** + * Security checks failed. + */ + OT_ERROR_SECURITY = 8, + + /** + * Address resolution requires an address query operation. + */ + OT_ERROR_ADDRESS_QUERY = 9, + + /** + * Address is not in the source match table. + */ + OT_ERROR_NO_ADDRESS = 10, + + /** + * Operation was aborted. + */ + OT_ERROR_ABORT = 11, + + /** + * Function or method is not implemented. + */ + OT_ERROR_NOT_IMPLEMENTED = 12, + + /** + * Cannot complete due to invalid state. + */ + OT_ERROR_INVALID_STATE = 13, + + /** + * No acknowledgment was received after macMaxFrameRetries (IEEE 802.15.4-2006). + */ + OT_ERROR_NO_ACK = 14, + + /** + * A transmission could not take place due to activity on the channel, i.e., the CSMA-CA mechanism has failed + * (IEEE 802.15.4-2006). + */ + OT_ERROR_CHANNEL_ACCESS_FAILURE = 15, + + /** + * Not currently attached to a Thread Partition. + */ + OT_ERROR_DETACHED = 16, + + /** + * FCS check failure while receiving. + */ + OT_ERROR_FCS = 17, + + /** + * No frame received. + */ + OT_ERROR_NO_FRAME_RECEIVED = 18, + + /** + * Received a frame from an unknown neighbor. + */ + OT_ERROR_UNKNOWN_NEIGHBOR = 19, + + /** + * Received a frame from an invalid source address. + */ + OT_ERROR_INVALID_SOURCE_ADDRESS = 20, + + /** + * Received a frame filtered by the whitelist. + */ + OT_ERROR_WHITELIST_FILTERED = 21, + + /** + * Received a frame filtered by the destination address check. + */ + OT_ERROR_DESTINATION_ADDRESS_FILTERED = 22, + + /** + * The requested item could not be found. + */ + OT_ERROR_NOT_FOUND = 23, + + /** + * The operation is already in progress. + */ + OT_ERROR_ALREADY = 24, + + /** + * Received a frame filtered by the blacklist. + */ + OT_ERROR_BLACKLIST_FILTERED = 25, + + /** + * The creation of IPv6 address failed. + */ + OT_ERROR_IP6_ADDRESS_CREATION_FAILURE = 26, + + /** + * Operation prevented by mode flags + */ + OT_ERROR_NOT_CAPABLE = 27, + + /** + * Coap response or acknowledgment or DNS response not received. + */ + OT_ERROR_RESPONSE_TIMEOUT = 28, + + /** + * Received a duplicated frame. + */ + OT_ERROR_DUPLICATED = 29, + + /** + * Message is being dropped from reassembly list due to timeout. + */ + OT_ERROR_REASSEMBLY_TIMEOUT = 30, + + /** + * Message is not a TMF Message. + */ + OT_ERROR_NOT_TMF = 31, + + /** + * Received a non-lowpan data frame. + */ + OT_ERROR_NOT_LOWPAN_DATA_FRAME = 32, + + /** + * A feature/functionality disabled by build-time configuration options. + */ + OT_ERROR_DISABLED_FEATURE = 33, + + /** + * Generic error (should not use). + */ + OT_ERROR_GENERIC = 255, +} otError; + +#define OT_IP6_IID_SIZE 8 ///< Size of an IPv6 Interface Identifier (bytes) + +#define OT_MASTER_KEY_SIZE 16 ///< Size of the Thread Master Key (bytes) + +/** + * Concatenated List of Type Identifiers of Other Diagnostics TLVs Used to Request or Reset Multiple Diagnostic Values. + */ +#define OT_NETWORK_DIAGNOSTIC_TYPELIST_TYPE 18 + +#define OT_NETWORK_DIAGNOSTIC_TYPELIST_MAX_ENTRIES 19 ///< Maximum Number of Other Network Diagnostic TLV Types + +/** + * @struct otMasterKey + * + * This structure represents a Thread Master Key. + * + */ +OT_TOOL_PACKED_BEGIN +struct otMasterKey +{ + uint8_t m8[OT_MASTER_KEY_SIZE]; ///< Byte values +} OT_TOOL_PACKED_END; + +/** + * This type represents a Thread Master Key. + * + */ +typedef struct otMasterKey otMasterKey; + +#define OT_NETWORK_NAME_MAX_SIZE 16 ///< Maximum size of the Thread Network Name field (bytes) + +/** + * This structure represents a Network Name. + * + */ +typedef struct otNetworkName +{ + char m8[OT_NETWORK_NAME_MAX_SIZE + 1]; ///< Byte values +} otNetworkName; + +#define OT_EXT_PAN_ID_SIZE 8 ///< Size of a Thread PAN ID (bytes) + +/** + * This structure represents an Extended PAN ID. + * + */ +typedef struct otExtendedPanId +{ + uint8_t m8[OT_EXT_PAN_ID_SIZE]; ///< Byte values +} otExtendedPanId; + +#define OT_MESH_LOCAL_PREFIX_SIZE 8 ///< Size of the Mesh Local Prefix (bytes) + +/** + * This structure represents a Mesh Local Prefix. + * + */ +typedef struct otMeshLocalPrefix +{ + uint8_t m8[OT_MESH_LOCAL_PREFIX_SIZE]; ///< Byte values +} otMeshLocalPrefix; + +#define OT_PSKC_MAX_SIZE 16 ///< Maximum size of the PSKc (bytes) + +#define OT_COMMISSIONING_PASSPHRASE_MIN_SIZE 6 ///< Minimum size of the Commissioning Passphrase +#define OT_COMMISSIONING_PASSPHRASE_MAX_SIZE 255 ///< Maximum size of the Commissioning Passphrase + +/** + * This structure represents PSKc. + * + */ +typedef struct otPSKc +{ + uint8_t m8[OT_PSKC_MAX_SIZE]; ///< Byte values +} otPSKc; + +/** + * This structure represent Security Policy. + * + */ +typedef struct otSecurityPolicy +{ + uint16_t mRotationTime; ///< The value for thrKeyRotation in units of hours + uint8_t mFlags; ///< Flags as defined in Thread 1.1 Section 8.10.1.15 +} otSecurityPolicy; + +/** + * This enumeration defines the Security Policy TLV flags. + * + */ +enum +{ + OT_SECURITY_POLICY_OBTAIN_MASTER_KEY = 1 << 7, ///< Obtaining the Master Key + OT_SECURITY_POLICY_NATIVE_COMMISSIONING = 1 << 6, ///< Native Commissioning + OT_SECURITY_POLICY_ROUTERS = 1 << 5, ///< Routers enabled + OT_SECURITY_POLICY_EXTERNAL_COMMISSIONER = 1 << 4, ///< External Commissioner allowed + OT_SECURITY_POLICY_BEACONS = 1 << 3, ///< Beacons enabled +}; + +/** + * This type represents Channel Mask Page 0. + * + */ +typedef uint32_t otChannelMaskPage0; + +/** + * This type represents the IEEE 802.15.4 PAN ID. + * + */ +typedef uint16_t otPanId; + +/** + * This type represents the IEEE 802.15.4 Short Address. + * + */ +typedef uint16_t otShortAddress; + +#define OT_EXT_ADDRESS_SIZE 8 ///< Size of an IEEE 802.15.4 Extended Address (bytes) + +/** + * This type represents the IEEE 802.15.4 Extended Address. + * + */ +typedef struct otExtAddress +{ + uint8_t m8[OT_EXT_ADDRESS_SIZE]; ///< IEEE 802.15.4 Extended Address bytes +} otExtAddress; + +#define OT_IP6_PREFIX_SIZE 8 ///< Size of an IPv6 prefix (bytes) +#define OT_IP6_ADDRESS_SIZE 16 ///< Size of an IPv6 address (bytes) + +/** + * @struct otIp6Address + * + * This structure represents an IPv6 address. + * + */ +OT_TOOL_PACKED_BEGIN +struct otIp6Address +{ + union + { + uint8_t m8[OT_IP6_ADDRESS_SIZE]; ///< 8-bit fields + uint16_t m16[OT_IP6_ADDRESS_SIZE / sizeof(uint16_t)]; ///< 16-bit fields + uint32_t m32[OT_IP6_ADDRESS_SIZE / sizeof(uint32_t)]; ///< 32-bit fields + } mFields; ///< IPv6 accessor fields +} OT_TOOL_PACKED_END; + +/** + * This type represents an IPv6 address. + * + */ +typedef struct otIp6Address otIp6Address; + +/** + * This structure represents the local and peer IPv6 socket addresses. + */ +typedef struct otMessageInfo +{ + /** + * The local IPv6 address. + */ + otIp6Address mSockAddr; + + /** + * The peer IPv6 address. + */ + otIp6Address mPeerAddr; + + /** + * The local transport-layer port. + */ + uint16_t mSockPort; + + /** + * The peer transport-layer port. + */ + uint16_t mPeerPort; + + /** + * An IPv6 interface identifier. + */ + int8_t mInterfaceId; + + /** + * The IPv6 Hop Limit. + */ + uint8_t mHopLimit; + + /** + * A pointer to link-specific information. In case @p mInterfaceId is set to OT_NETIF_INTERFACE_ID_THREAD, + * @p mLinkInfo points to @sa otThreadLinkInfo. This field is only valid for messages received from the + * Thread radio and is ignored on transmission. + */ + const void *mLinkInfo; +} otMessageInfo; + +/** + * This type points to an OpenThread message buffer. + */ +typedef struct otMessage +{ + struct otMessage *mNext; ///< A pointer to the next Message buffer. +} otMessage; + + +#define OT_PANID_BROADCAST 0xffff ///< IEEE 802.15.4 Broadcast PAN ID + +#define OT_CHANNEL_11_MASK (1 << 11) ///< Channel 11 +#define OT_CHANNEL_12_MASK (1 << 12) ///< Channel 12 +#define OT_CHANNEL_13_MASK (1 << 13) ///< Channel 13 +#define OT_CHANNEL_14_MASK (1 << 14) ///< Channel 14 +#define OT_CHANNEL_15_MASK (1 << 15) ///< Channel 15 +#define OT_CHANNEL_16_MASK (1 << 16) ///< Channel 16 +#define OT_CHANNEL_17_MASK (1 << 17) ///< Channel 17 +#define OT_CHANNEL_18_MASK (1 << 18) ///< Channel 18 +#define OT_CHANNEL_19_MASK (1 << 19) ///< Channel 19 +#define OT_CHANNEL_20_MASK (1 << 20) ///< Channel 20 +#define OT_CHANNEL_21_MASK (1 << 21) ///< Channel 21 +#define OT_CHANNEL_22_MASK (1 << 22) ///< Channel 22 +#define OT_CHANNEL_23_MASK (1 << 23) ///< Channel 23 +#define OT_CHANNEL_24_MASK (1 << 24) ///< Channel 24 +#define OT_CHANNEL_25_MASK (1 << 25) ///< Channel 25 +#define OT_CHANNEL_26_MASK (1 << 26) ///< Channel 26 + +#define OT_CHANNEL_ALL 0xffffffff ///< All channels + +#define OT_STEERING_DATA_MAX_LENGTH 16 ///< Max steering data length (bytes) + +/** + * This structure represents the steering data. + * + */ +typedef struct otSteeringData +{ + uint8_t mLength; ///< Length of steering data (bytes) + uint8_t m8[OT_STEERING_DATA_MAX_LENGTH]; ///< Byte values +} otSteeringData; + +/** + * This struct represents a received IEEE 802.15.4 Beacon. + * + */ +typedef struct otActiveScanResult +{ + otExtAddress mExtAddress; ///< IEEE 802.15.4 Extended Address + otNetworkName mNetworkName; ///< Thread Network Name + otExtendedPanId mExtendedPanId; ///< Thread Extended PAN ID + otSteeringData mSteeringData; ///< Steering Data + uint16_t mPanId; ///< IEEE 802.15.4 PAN ID + uint16_t mJoinerUdpPort; ///< Joiner UDP Port + uint8_t mChannel; ///< IEEE 802.15.4 Channel + int8_t mRssi; ///< RSSI (dBm) + uint8_t mLqi; ///< LQI + unsigned int mVersion : 4; ///< Version + bool mIsNative : 1; ///< Native Commissioner flag + bool mIsJoinable : 1; ///< Joining Permitted flag +} otActiveScanResult; + +/** + * This struct represents an energy scan result. + * + */ +typedef struct otEnergyScanResult +{ + uint8_t mChannel; ///< IEEE 802.15.4 Channel + int8_t mMaxRssi; ///< The max RSSI (dBm) +} otEnergyScanResult; + +/** + * This structure represents an Active or Pending Operational Dataset. + * + */ +typedef struct otOperationalDataset +{ + uint64_t mActiveTimestamp; ///< Active Timestamp + uint64_t mPendingTimestamp; ///< Pending Timestamp + otMasterKey mMasterKey; ///< Network Master Key + otNetworkName mNetworkName; ///< Network Name + otExtendedPanId mExtendedPanId; ///< Extended PAN ID + otMeshLocalPrefix mMeshLocalPrefix; ///< Mesh Local Prefix + uint32_t mDelay; ///< Delay Timer + otPanId mPanId; ///< PAN ID + uint16_t mChannel; ///< Channel + otPSKc mPSKc; ///< PSKc + otSecurityPolicy mSecurityPolicy; ///< Security Policy + otChannelMaskPage0 mChannelMaskPage0; ///< Channel Mask Page 0 + + bool mIsActiveTimestampSet : 1; ///< TRUE if Active Timestamp is set, FALSE otherwise. + bool mIsPendingTimestampSet : 1; ///< TRUE if Pending Timestamp is set, FALSE otherwise. + bool mIsMasterKeySet : 1; ///< TRUE if Network Master Key is set, FALSE otherwise. + bool mIsNetworkNameSet : 1; ///< TRUE if Network Name is set, FALSE otherwise. + bool mIsExtendedPanIdSet : 1; ///< TRUE if Extended PAN ID is set, FALSE otherwise. + bool mIsMeshLocalPrefixSet : 1; ///< TRUE if Mesh Local Prefix is set, FALSE otherwise. + bool mIsDelaySet : 1; ///< TRUE if Delay Timer is set, FALSE otherwise. + bool mIsPanIdSet : 1; ///< TRUE if PAN ID is set, FALSE otherwise. + bool mIsChannelSet : 1; ///< TRUE if Channel is set, FALSE otherwise. + bool mIsPSKcSet : 1; ///< TRUE if PSKc is set, FALSE otherwise. + bool mIsSecurityPolicySet : 1; ///< TRUE if Security Policy is set, FALSE otherwise. + bool mIsChannelMaskPage0Set : 1; ///< TRUE if Channel Mask Page 0 is set, FALSE otherwise. +} otOperationalDataset; + +/** + * This structure represents a Commissioning Dataset. + * + */ +typedef struct otCommissioningDataset +{ + uint16_t mLocator; ///< Border Router RLOC16 + uint16_t mSessionId; ///< Commissioner Session Id + otSteeringData mSteeringData; ///< Steering Data + uint16_t mJoinerUdpPort; ///< Joiner UDP Port + + bool mIsLocatorSet : 1; ///< TRUE if Border Router RLOC16 is set, FALSE otherwise. + bool mIsSessionIdSet: 1; ///< TRUE if Commissioner Session Id is set, FALSE otherwise. + bool mIsSteeringDataSet : 1; ///< TRUE if Steering Data is set, FALSE otherwise. + bool mIsJoinerUdpPortSet : 1; ///< TRUE if Joiner UDP Port is set, FALSE otherwise. +} otCommissioningDataset; + +/** + * This enumeration represents meshcop TLV types. + * + */ +typedef enum otMeshcopTlvType +{ + OT_MESHCOP_TLV_CHANNEL = 0, ///< meshcop Channel TLV + OT_MESHCOP_TLV_PANID = 1, ///< meshcop Pan Id TLV + OT_MESHCOP_TLV_EXTPANID = 2, ///< meshcop Extended Pan Id TLV + OT_MESHCOP_TLV_NETWORKNAME = 3, ///< meshcop Network Name TLV + OT_MESHCOP_TLV_PSKC = 4, ///< meshcop PSKc TLV + OT_MESHCOP_TLV_MASTERKEY = 5, ///< meshcop Network Master Key TLV + OT_MESHCOP_TLV_NETWORK_KEY_SEQUENCE = 6, ///< meshcop Network Key Sequence TLV + OT_MESHCOP_TLV_MESHLOCALPREFIX = 7, ///< meshcop Mesh Local Prefix TLV + OT_MESHCOP_TLV_STEERING_DATA = 8, ///< meshcop Steering Data TLV + OT_MESHCOP_TLV_BORDER_AGENT_RLOC = 9, ///< meshcop Border Agent Locator TLV + OT_MESHCOP_TLV_COMMISSIONER_ID = 10, ///< meshcop Commissioner ID TLV + OT_MESHCOP_TLV_COMM_SESSION_ID = 11, ///< meshcop Commissioner Session ID TLV + OT_MESHCOP_TLV_SECURITYPOLICY = 12, ///< meshcop Security Policy TLV + OT_MESHCOP_TLV_GET = 13, ///< meshcop Get TLV + OT_MESHCOP_TLV_ACTIVETIMESTAMP = 14, ///< meshcop Active Timestamp TLV + OT_MESHCOP_TLV_STATE = 16, ///< meshcop State TLV + OT_MESHCOP_TLV_JOINER_DTLS = 17, ///< meshcop Joiner DTLS Encapsulation TLV + OT_MESHCOP_TLV_JOINER_UDP_PORT = 18, ///< meshcop Joiner UDP Port TLV + OT_MESHCOP_TLV_JOINER_IID = 19, ///< meshcop Joiner IID TLV + OT_MESHCOP_TLV_JOINER_RLOC = 20, ///< meshcop Joiner Router Locator TLV + OT_MESHCOP_TLV_JOINER_ROUTER_KEK = 21, ///< meshcop Joiner Router KEK TLV + OT_MESHCOP_TLV_PROVISIONING_URL = 32, ///< meshcop Provisioning URL TLV + OT_MESHCOP_TLV_VENDOR_NAME_TLV = 33, ///< meshcop Vendor Name TLV + OT_MESHCOP_TLV_VENDOR_MODEL_TLV = 34, ///< meshcop Vendor Model TLV + OT_MESHCOP_TLV_VENDOR_SW_VERSION_TLV = 35, ///< meshcop Vendor SW Version TLV + OT_MESHCOP_TLV_VENDOR_DATA_TLV = 36, ///< meshcop Vendor Data TLV + OT_MESHCOP_TLV_VENDOR_STACK_VERSION_TLV = 37, ///< meshcop Vendor Stack Version TLV + OT_MESHCOP_TLV_PENDINGTIMESTAMP = 51, ///< meshcop Pending Timestamp TLV + OT_MESHCOP_TLV_DELAYTIMER = 52, ///< meshcop Delay Timer TLV + OT_MESHCOP_TLV_CHANNELMASK = 53, ///< meshcop Channel Mask TLV + OT_MESHCOP_TLV_COUNT = 54, ///< meshcop Count TLV + OT_MESHCOP_TLV_PERIOD = 55, ///< meshcop Period TLV + OT_MESHCOP_TLV_SCAN_DURATION = 56, ///< meshcop Scan Duration TLV + OT_MESHCOP_TLV_ENERGY_LIST = 57, ///< meshcop Energy List TLV + OT_MESHCOP_TLV_DISCOVERYREQUEST = 128, ///< meshcop Discovery Request TLV + OT_MESHCOP_TLV_DISCOVERYRESPONSE = 129, ///< meshcop Discovery Response TLV +} otMeshcopTlvType; + +/** + * This structure represents an MLE Link Mode configuration. + */ +OT_TOOL_ALIGN(4) +typedef struct otLinkModeConfig +{ + /** + * 1, if the sender has its receiver on when not transmitting. 0, otherwise. + */ + bool mRxOnWhenIdle : 1; + + /** + * 1, if the sender will use IEEE 802.15.4 to secure all data requests. 0, otherwise. + */ + bool mSecureDataRequests : 1; + + /** + * 1, if the sender is an FFD. 0, otherwise. + */ + bool mDeviceType : 1; + + /** + * 1, if the sender requires the full Network Data. 0, otherwise. + */ + bool mNetworkData : 1; +} otLinkModeConfig; + +/** + * This enumeration represents flags that indicate what configuration or state has changed within OpenThread. + * + */ +enum +{ + OT_CHANGED_IP6_ADDRESS_ADDED = 1 << 0, ///< IPv6 address was added + OT_CHANGED_IP6_ADDRESS_REMOVED = 1 << 1, ///< IPv6 address was removed + OT_CHANGED_THREAD_ROLE = 1 << 2, ///< Role (disabled, detached, child, router, leader) changed + OT_CHANGED_THREAD_LL_ADDR = 1 << 3, ///< The link-local address changed + OT_CHANGED_THREAD_ML_ADDR = 1 << 4, ///< The mesh-local address changed + OT_CHANGED_THREAD_RLOC_ADDED = 1 << 5, ///< RLOC was added + OT_CHANGED_THREAD_RLOC_REMOVED = 1 << 6, ///< RLOC was removed + OT_CHANGED_THREAD_PARTITION_ID = 1 << 7, ///< Partition ID changed + OT_CHANGED_THREAD_KEY_SEQUENCE_COUNTER = 1 << 8, ///< Thread Key Sequence changed + OT_CHANGED_THREAD_NETDATA = 1 << 9, ///< Thread Network Data changed + OT_CHANGED_THREAD_CHILD_ADDED = 1 << 10, ///< Child was added + OT_CHANGED_THREAD_CHILD_REMOVED = 1 << 11, ///< Child was removed + OT_CHANGED_IP6_MULTICAST_SUBSRCRIBED = 1 << 12, ///< Subscribed to a IPv6 multicast address + OT_CHANGED_IP6_MULTICAST_UNSUBSRCRIBED = 1 << 13, ///< Unsubscribed from a IPv6 multicast address +}; + +/** + * This structure represents an IPv6 prefix. + */ +typedef struct otIp6Prefix +{ + otIp6Address mPrefix; ///< The IPv6 prefix. + uint8_t mLength; ///< The IPv6 prefix length. +} otIp6Prefix; + +#define OT_NETWORK_DATA_ITERATOR_INIT 0 ///< Initializer for otNetworkDataIterator. + +typedef uint16_t otNetworkDataIterator; ///< Used to iterate through Network Data information. + +/** + * This structure represents a Border Router configuration. + */ +typedef struct otBorderRouterConfig +{ + /** + * The IPv6 prefix. + */ + otIp6Prefix mPrefix; + + /** + * A 2-bit signed integer indicating router preference as defined in RFC 4291. + */ + int mPreference : 2; + + /** + * TRUE, if @p mPrefix is preferred. FALSE, otherwise. + */ + bool mPreferred : 1; + + /** + * TRUE, if @p mPrefix should be used for address autoconfiguration. FALSE, otherwise. + */ + bool mSlaac : 1; + + /** + * TRUE, if this border router is a DHCPv6 Agent that supplies IPv6 address configuration. FALSE, otherwise. + */ + bool mDhcp : 1; + + /** + * TRUE, if this border router is a DHCPv6 Agent that supplies other configuration data. FALSE, otherwise. + */ + bool mConfigure : 1; + + /** + * TRUE, if this border router is a default route for @p mPrefix. FALSE, otherwise. + */ + bool mDefaultRoute : 1; + + /** + * TRUE, if this prefix is considered on-mesh. FALSE, otherwise. + */ + bool mOnMesh : 1; + + /** + * TRUE, if this configuration is considered Stable Network Data. FALSE, otherwise. + */ + bool mStable : 1; + + /** + * The Border Agent Rloc. + */ + uint16_t mRloc16; +} otBorderRouterConfig; + +/** + * This structure represents an External Route configuration. + */ +typedef struct otExternalRouteConfig +{ + /** + * The prefix for the off-mesh route. + */ + otIp6Prefix mPrefix; + + /** + * The Rloc associated with the external route entry. + * + * This value is ignored when adding an external route. For any added route the device's Rloc will be used. + */ + uint16_t mRloc16; + + /** + * A 2-bit signed integer indicating router preference as defined in RFC 4291. + */ + int mPreference : 2; + + /** + * TRUE, if this configuration is considered Stable Network Data. FALSE, otherwise. + */ + bool mStable : 1; + + /** + * TRUE if the external route entry's next hop is this device itself (i.e., the route was added earlier by this + * device). FALSE otherwise. + * + * This value is ignored when adding an external route. For any added route the next hop is this device. + */ + bool mNextHopIsThisDevice : 1; + +} otExternalRouteConfig; + +/** + * Defines valid values for member mPreference in otExternalRouteConfig and otBorderRouterConfig. + */ +typedef enum otRoutePreference +{ + OT_ROUTE_PREFERENCE_LOW = -1, ///< Low route preference. + OT_ROUTE_PREFERENCE_MED = 0, ///< Medium route preference. + OT_ROUTE_PREFERENCE_HIGH = 1, ///< High route preference. +} otRoutePreference; + +/** + * Used to indicate no fixed received signal strength was set + */ +#define OT_MAC_FILTER_FIXED_RSS_DISABLED 127 + +#define OT_MAC_FILTER_ITERATOR_INIT 0 ///< Initializer for otMacFilterIterator. + +typedef uint8_t otMacFilterIterator; ///< Used to iterate through mac filter entries. + +/** + * Defines address mode of the mac filter. + */ +typedef enum otMacFilterAddressMode +{ + OT_MAC_FILTER_ADDRESS_MODE_DISABLED, ///< Address filter is disabled. + OT_MAC_FILTER_ADDRESS_MODE_WHITELIST, ///< Whitelist address filter mode is enabled. + OT_MAC_FILTER_ADDRESS_MODE_BLACKLIST, ///< Blacklist address filter mode is enabled. +} otMacFilterAddressMode; + +/** + * This structure represents a Mac Filter entry. + * + */ +typedef struct otMacFilterEntry +{ + otExtAddress mExtAddress; ///< IEEE 802.15.4 Extended Address + int8_t mRssIn; ///< Received signal strength + bool mFiltered; ///< Indicates whether or not this entry is filtered. +} otMacFilterEntry; + +/** + * Represents a Thread device role. + */ +typedef enum +{ + OT_DEVICE_ROLE_DISABLED = 0, ///< The Thread stack is disabled. + OT_DEVICE_ROLE_DETACHED = 1, ///< Not currently participating in a Thread network/partition. + OT_DEVICE_ROLE_CHILD = 2, ///< The Thread Child role. + OT_DEVICE_ROLE_ROUTER = 3, ///< The Thread Router role. + OT_DEVICE_ROLE_LEADER = 4, ///< The Thread Leader role. +} otDeviceRole; + +/** + * This structure holds diagnostic information for a neighboring Thread node + * + */ +typedef struct +{ + otExtAddress mExtAddress; ///< IEEE 802.15.4 Extended Address + uint32_t mAge; ///< Time last heard + uint16_t mRloc16; ///< RLOC16 + uint32_t mLinkFrameCounter; ///< Link Frame Counter + uint32_t mMleFrameCounter; ///< MLE Frame Counter + uint8_t mLinkQualityIn; ///< Link Quality In + int8_t mAverageRssi; ///< Average RSSI + int8_t mLastRssi; ///< Last observed RSSI + bool mRxOnWhenIdle : 1; ///< rx-on-when-idle + bool mSecureDataRequest : 1; ///< Secure Data Requests + bool mFullFunction : 1; ///< Full Function Device + bool mFullNetworkData : 1; ///< Full Network Data + bool mIsChild : 1; ///< Is the neighbor a child +} otNeighborInfo; + +#define OT_NEIGHBOR_INFO_ITERATOR_INIT 0 ///< Initializer for otNeighborInfoIterator. + +typedef int16_t otNeighborInfoIterator; ///< Used to iterate through neighbor table. + +/** + * This structure holds diagnostic information for a Thread Child + * + */ +typedef struct +{ + otExtAddress mExtAddress; ///< IEEE 802.15.4 Extended Address + uint32_t mTimeout; ///< Timeout + uint32_t mAge; ///< Time last heard + uint16_t mRloc16; ///< RLOC16 + uint16_t mChildId; ///< Child ID + uint8_t mNetworkDataVersion; ///< Network Data Version + uint8_t mLinkQualityIn; ///< Link Quality In + int8_t mAverageRssi; ///< Average RSSI + int8_t mLastRssi; ///< Last observed RSSI + bool mRxOnWhenIdle : 1; ///< rx-on-when-idle + bool mSecureDataRequest : 1; ///< Secure Data Requests + bool mFullFunction : 1; ///< Full Function Device + bool mFullNetworkData : 1; ///< Full Network Data +} otChildInfo; + +/** + * This structure holds diagnostic information for a Thread Router + * + */ +OT_TOOL_ALIGN(4) +typedef struct +{ + otExtAddress mExtAddress; ///< IEEE 802.15.4 Extended Address + uint16_t mRloc16; ///< RLOC16 + uint8_t mRouterId; ///< Router ID + uint8_t mNextHop; ///< Next hop to router + uint8_t mPathCost; ///< Path cost to router + uint8_t mLinkQualityIn; ///< Link Quality In + uint8_t mLinkQualityOut; ///< Link Quality Out + uint8_t mAge; ///< Time last heard + bool mAllocated : 1; ///< Router ID allocated or not + bool mLinkEstablished : 1; ///< Link established with Router ID or not +} otRouterInfo; + +/** + * This structure represents an EID cache entry. + * + */ +typedef struct otEidCacheEntry +{ + otIp6Address mTarget; ///< Target + otShortAddress mRloc16; ///< RLOC16 + bool mValid : 1; ///< Indicates whether or not the cache entry is valid +} otEidCacheEntry; + +/** + * This structure represents the Thread Leader Data. + * + */ +typedef struct otLeaderData +{ + uint32_t mPartitionId; ///< Partition ID + uint8_t mWeighting; ///< Leader Weight + uint8_t mDataVersion; ///< Full Network Data Version + uint8_t mStableDataVersion; ///< Stable Network Data Version + uint8_t mLeaderRouterId; ///< Leader Router ID +} otLeaderData; + +/** + * This structure represents the MAC layer counters. + */ +typedef struct otMacCounters +{ + uint32_t mTxTotal; ///< The total number of transmissions. + uint32_t mTxUnicast; ///< The total number of unicast transmissions. + uint32_t mTxBroadcast; ///< The total number of broadcast transmissions. + uint32_t mTxAckRequested; ///< The number of transmissions with ack request. + uint32_t mTxAcked; ///< The number of transmissions that were acked. + uint32_t mTxNoAckRequested; ///< The number of transmissions without ack request. + uint32_t mTxData; ///< The number of transmitted data. + uint32_t mTxDataPoll; ///< The number of transmitted data poll. + uint32_t mTxBeacon; ///< The number of transmitted beacon. + uint32_t mTxBeaconRequest; ///< The number of transmitted beacon request. + uint32_t mTxOther; ///< The number of transmitted other types of frames. + uint32_t mTxRetry; ///< The number of retransmission times. + uint32_t mTxErrCca; ///< The number of CCA failure times. + uint32_t mTxErrAbort; ///< The number of frame transmission failures due to abort error. + uint32_t mRxTotal; ///< The total number of received packets. + uint32_t mRxUnicast; ///< The total number of unicast packets received. + uint32_t mRxBroadcast; ///< The total number of broadcast packets received. + uint32_t mRxData; ///< The number of received data. + uint32_t mRxDataPoll; ///< The number of received data poll. + uint32_t mRxBeacon; ///< The number of received beacon. + uint32_t mRxBeaconRequest; ///< The number of received beacon request. + uint32_t mRxOther; ///< The number of received other types of frames. + uint32_t mRxWhitelistFiltered; ///< The number of received packets filtered by whitelist. + uint32_t mRxDestAddrFiltered; ///< The number of received packets filtered by destination check. + uint32_t mRxDuplicated; ///< The number of received duplicated packets. + uint32_t mRxErrNoFrame; ///< The number of received packets that do not contain contents. + uint32_t mRxErrUnknownNeighbor; ///< The number of received packets from unknown neighbor. + uint32_t mRxErrInvalidSrcAddr; ///< The number of received packets whose source address is invalid. + uint32_t mRxErrSec; ///< The number of received packets with security error. + uint32_t mRxErrFcs; ///< The number of received packets with FCS error. + uint32_t mRxErrOther; ///< The number of received packets with other error. +} otMacCounters; + +/** + * This structure represents the IP level counters + */ +typedef struct otIpCounters +{ + uint32_t mTxSuccess; ///< The number of IPv6 packets successfully transmitted. + uint32_t mRxSuccess; ///< The number of IPv6 packets successfully received. + uint32_t mTxFailure; ///< The number of IPv6 packets failed to transmit. + uint32_t mRxFailure; ///< The number of IPv6 packets failed to receive. +} otIpCounters; + +/** + * This structure represents the message buffer information. + */ +typedef struct otBufferInfo +{ + uint16_t mTotalBuffers; ///< The number of buffers in the pool. + uint16_t mFreeBuffers; ///< The number of free message buffers. + uint16_t m6loSendMessages; ///< The number of messages in the 6lo send queue. + uint16_t m6loSendBuffers; ///< The number of buffers in the 6lo send queue. + uint16_t m6loReassemblyMessages; ///< The number of messages in the 6LoWPAN reassembly queue. + uint16_t m6loReassemblyBuffers; ///< The number of buffers in the 6LoWPAN reassembly queue. + uint16_t mIp6Messages; ///< The number of messages in the IPv6 send queue. + uint16_t mIp6Buffers; ///< The number of buffers in the IPv6 send queue. + uint16_t mMplMessages; ///< The number of messages in the MPL send queue. + uint16_t mMplBuffers; ///< The number of buffers in the MPL send queue. + uint16_t mMleMessages; ///< The number of messages in the MLE send queue. + uint16_t mMleBuffers; ///< The number of buffers in the MLE send queue. + uint16_t mArpMessages; ///< The number of messages in the ARP send queue. + uint16_t mArpBuffers; ///< The number of buffers in the ARP send queue. + uint16_t mCoapMessages; ///< The number of messages in the CoAP send queue. + uint16_t mCoapBuffers; ///< The number of buffers in the CoAP send queue. + uint16_t mCoapSecureMessages; ///< The number of messages in the CoAP secure send queue. + uint16_t mCoapSecureBuffers; ///< The number of buffers in the CoAP secure send queue. +} otBufferInfo; + +/** + * This structure represents an IPv6 network interface unicast address. + * + */ +typedef struct otNetifAddress +{ + otIp6Address mAddress; ///< The IPv6 unicast address. + uint8_t mPrefixLength; ///< The Prefix length. + bool mPreferred : 1; ///< TRUE if the address is preferred, FALSE otherwise. + bool mValid : 1; ///< TRUE if the address is valid, FALSE otherwise. + bool mScopeOverrideValid : 1; ///< TRUE if the mScopeOverride value is valid, FALSE otherwise. + unsigned int mScopeOverride : 4; ///< The IPv6 scope of this address. + bool mRloc : 1; ///< TRUE if the address is an RLOC, FALSE otherwise. + struct otNetifAddress *mNext; ///< A pointer to the next network interface address. +} otNetifAddress; + +/** + * This structure represents an IPv6 network interface multicast address. + * + */ +typedef struct otNetifMulticastAddress +{ + otIp6Address mAddress; ///< The IPv6 multicast address. + struct otNetifMulticastAddress *mNext; ///< A pointer to the next network interface multicast address. +} otNetifMulticastAddress; + +/** + * This enumeration represents the list of allowable values for an InterfaceId. + */ +typedef enum otNetifInterfaceId +{ + OT_NETIF_INTERFACE_ID_THREAD = 1, ///< The Thread Network interface ID. +} otNetifInterfaceId; + +/** + * This structure represents data used by Semantically Opaque IID Generator. + * + */ +typedef struct +{ + uint8_t *mInterfaceId; ///< String of bytes representing interface ID. Like "eth0" or "wlan0". + uint8_t mInterfaceIdLength; ///< Length of interface ID string. + + uint8_t *mNetworkId; ///< Network ID (or name). Can be null if mNetworkIdLength is 0. + uint8_t mNetworkIdLength; ///< Length of Network ID string. + + uint8_t mDadCounter; ///< Duplicate address detection counter. + + uint8_t *mSecretKey; ///< Secret key used to create IID. Cannot be null. + uint16_t mSecretKeyLength; ///< Secret key length in bytes. Should be at least 16 bytes == 128 bits. +} otSemanticallyOpaqueIidGeneratorData; + +/** + * This structure represents an IPv6 socket address. + */ +typedef struct otSockAddr +{ + otIp6Address mAddress; ///< An IPv6 address. + uint16_t mPort; ///< A transport-layer port. + int8_t mScopeId; ///< An IPv6 scope identifier. +} otSockAddr; + +/** + * This structure represents link-specific information for messages received from the Thread radio. + * + */ +typedef struct otThreadLinkInfo +{ + uint16_t mPanId; ///< Source PAN ID + uint8_t mChannel; ///< 802.15.4 Channel + int8_t mRss; ///< Received Signal Strength in dBm. + uint8_t mLqi; ///< Link Quality Indicator for a received message. + bool mLinkSecurity; ///< Indicates whether or not link security is enabled. +} otThreadLinkInfo; + +#ifdef OTDLL + +/** + * This function pointer is called to notify addition and removal of OpenThread devices. + * + * @param[in] aAdded A flag indicating if the device was added or removed. + * @param[in] aDeviceGuid A GUID indicating which device state changed. + * @param[in] aContext A pointer to application-specific context. + * + */ +typedef void (OTCALL *otDeviceAvailabilityChangedCallback)(bool aAdded, const GUID *aDeviceGuid, void *aContext); + +#endif // OTDLL + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // OPENTHREAD_TYPES_H_ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/platform.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/platform.h new file mode 100644 index 000000000..a893acac3 --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/platform.h @@ -0,0 +1,556 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/platform.h#1 $*/ +/** + ******************************************************************************** + * @file platform.h + * @brief this file include all helper functions in radio.c which is not described in Openthread + * + * + ****************************************************************************** + * @copy + * Synopsys MIT License: + * Copyright (c) 2020-Present Synopsys, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of the software and + * associated documentation files (the “Software”), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. + * + * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE + * ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * */ + + +#ifndef INCLUDE_PLATFORM_H_ +#define INCLUDE_PLATFORM_H_ + +#include "radio.h" +#include "common_types.h" + +/*==================================== MACROS =======================================*/ +/* + * The following macros are used for testing purpose only + */ +#define RADIO_TEST 0 +#define ACK_FRAME_TYPE 0x2 +#define MAC_ACK_WAIT 864 +#define ACK_LNGTH 5 +/******************************************************************************************//** + * Enums + *********************************************************************************************/ +/** + * @enum radio_state_enum_t + * @brief the states of the Radio event it is used for coexistence + * + */ +typedef enum _radio_evnt_type_enum +{ + TX_PCKT_STATE, ///< Sending packet (not ACK) + TX_ACK_STATE, ///< Sending ACK + RX_PCKT_STATE, ///< Receiving packet (not ACK) + RX_ACK_STATE, ///< Receiving Ack + RADIO_ED, ///< Energy detection + RADIO_SLEEP_STATE, ///< Sleep state + RADIO_DISABLED_STATE,///< Disable state +#if(SUPPORT_COEXISTENCE) + TX_AT_STATE , ///< Tx at specific time + RX_AT_STATE , ///< Rx at specific time +#endif /* SUPPORT_COEXISTENCE */ + +}radio_event_enum_t; +/******************************************************************************************//** + * Structures + *********************************************************************************************/ +/** @ingroup systm_layer +* @{ +*/ +/** + * @struct mac_cbk_dispatch_tbl + * + * @brief structure of all callback functions used to notify mac layer after specific event compeletion + */ +struct mac_cbk_dispatch_tbl{ + /** + * @brief callback function called after the end of Energy detection operation + * + * @param aInstance: radio instance + * @param aEnergyScanMaxRssi: the result for ED operation which is RSSI value + * + * @retval none + * + * @note This function is called after handling SM_DONE event in ral through a sequence of calls + * ral_sm_done() -> ral_ed_scan_done() -> callback + */ + void (*mac_ed_scan_done)(otInstance *aInstance, int8_t aEnergyScanMaxRssi); + /** + * @brief callback function called after the end of transmission operation + * + * @param aInstance: radio instance + * @param aFrame: pointer to the transmitted frame + * @param aAckFrame: pointer to the received ack frame (in case of AR bit is detected in aFrame) + * @param aError: Error code if happens in Transmission + * + * @retval none + * @note This function is called after handling SM_DONE event in ral through a sequence of calls + * ral_sm_done() -> ral_tx_done() -> callback + */ + void (*mac_tx_done)(otInstance *aInstance, otRadioFrame *aFrame, otRadioFrame *aAckFrame, otError aError); + /** + * @brief callback function called after the end of Reception operation + * + * @param aInstance: radio instance + * @param aFrame: pointer to the received frame + * @param aError: Error code if happens in transmission + * + * @retval none + * @note This function is called after handling SM_DONE event in ral through a sequence of calls + * ral_sm_done() -> ral_rx_done() -> callback + */ + void (*mac_rx_done)(otInstance *aInstance, otRadioFrame *aFrame, otError aError); + /** + * @brief callback function called after successful start of transmission in ral + * + * @param aInstance: radio instance + * @param aFrame: pointer to the transmitted frame + * @param aError: Error code if happens in transmission + * + * @retval none + * @note This function is called after calling proc_radio_tx which is called with calling of otplatRadioTransmit + * in case of no error returned. These errors may be (CCA channel access failure, ral busy due to ongoing transmission ...etc ) + */ + void (*mac_tx_strtd)(otInstance *aInstance, otRadioFrame *aFrame); + + void (*mac_frm_updtd)(otInstance *aInstance, otRadioFrame *aFrame); + +}; +/** + * @} + * + */ +/******************************************************************************************//** + * APIs + *********************************************************************************************/ +/** @ingroup systm_layer_cmn_proc +* @{ +*/ +/** + * @brief this function is used to initialize radio layer including registeration for ral callbacks, + * some filter configurations, some automatic configurations like auto_sleep and auto_ack...etc + * + * @retval none + */ +void radio_init(void); +/** + * @brief This function called from upper layer init function (mac_init in case of mac integration e.g. Zigbee stack) + * to register the upper layer callback functions + * + * @param ptr_cbk_dispatch_tbl: pointer to callback function to be registered + * + * @retval none + * + */ +void radio_call_back_funcs_init(struct mac_cbk_dispatch_tbl * ptr_cbk_dispatch_tbl); +/** + * @} + * + */ + +void otDispatch_tbl_init(otInstance *sInstance); +/** + * @} + * + */ + +/** @ingroup systm_layer_enc +* @{ +*/ +/** + * @brief This function is used to encrypt frame pointed to by ptr_pckt + * + * @param ptr_pckt: pointer to the frame to be encrypted + * @param ptr_session_key: pointer to used session key + * @param ptr_ccm_nonce: pointer to the nonce + * @param mic_len: mic length + * @param ad_len: a data length + * @param md_len: m data length + * + * @retval status of the encryption process + * + */ +uint32_t radio_encrypt_pckts( uint8_t *ptr_pckt, + const uint8_t *ptr_session_key, + uint8_t *ptr_ccm_nonce, + uint32_t mic_len, + uint32_t ad_len, + uint32_t md_len); +/** + * @} + * + */ +/** @ingroup systm_layer_cmn_config +* @{ +*/ +/** + * @brief This function is used to configure automatic ack response by ral layer + * including AIFS, ack frame timeout.. etc + * + * @param auto_ack_state: Enabled or disabled + * + * @retval otError status of configuration + * + */ +otError radio_set_auto_Ack_state(uint8_t auto_ack_state); +/** + * @} + * + */ +/** @ingroup systm_layer_cmn_proc +* @{ +*/ +/** + * @fn uint32_t radio_reset() + * @brief This API is used to reset radio layer operation which in turns stop all running operations + */ +uint32_t radio_reset(void); +/** + * @} + * + */ +/** + * @fn proc_radio_rcv(uint8_t aChannel, uint32_t duration) + * @brief This API is used to control ral setup for reception. + * @param aChannel: channel to receive on + * @param duration: reception duration in microsecond , 0 means receive forever + */ +otError proc_radio_rcv(uint8_t aChannel ,uint32_t duration); +/** + * @fn otError proc_radio_tx(otRadioFrame *aFrame, ble_time_t* strt_time) + * @brief This API is used to control ral setup for transmission based on CCA procedure. + * @param aFrame: pointer to the Tx frame + * @param strt_time: pointer to Tx request time + */ +otError proc_radio_tx(otRadioFrame *aFrame , ble_time_t* strt_time); +/** + * @fn otError proc_radio_ed(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) + * @brief This API is used to control ral setup for energy scan. + */ +otError proc_radio_ed(uint8_t aScanChannel, uint16_t aScanDuration); +/** @ingroup systm_layer_cmn_config +* @{ +*/ +/** + * @fn void setPANcoordinator (uint8_t aEnable) + * @brief This API is used to set Pan coordinator role in HW to be used while applying MAC 802.15.4 filter policies. + */ +void setPANcoordinator(uint8_t aEnable); +/** + * @fn void setContRecp (uint8_t aEnable) + * @brief This API is used to notify ral layer of rx on when idle state. + */ +void setContRecp(uint8_t aEnable); +/** + * @fn void enableScanFilters(otInstance *aInstance) + * @brief This API is used to disable filter policy while performing scan. + */ +void enableScanFilters(otInstance *aInstance); +/** + * @fn void disableScanFilters(otInstance *aInstance) + * @brief This API is used to restore filter policy after the scan is complete. + */ +void disableScanFilters(otInstance *aInstance); + +/** + * @} + * + */ +/** @ingroup systm_layer_cmn_proc +* @{ +*/ +/** + * @brief get the latest LQI value + * @retval uint8_t. LQI value + */ +uint8_t radio_GetLQIValue(void); +/** + * @} + * + */ +#if RADIO_CSMA +/** @ingroup systm_layer_cmn_config +* @{ +*/ +/** + * @fn void set_min_csma_be(uint8_t value) + * @brief This API is used to set min csma backoff exponent + * @param value: value for minimum csma backoff exponent + * + * @retval none + */ +void set_min_csma_be(uint8_t value); +/** + * @fn void set_max_csma_be(uint8_t value) + * @brief This API is used to set max csma backoff exponent + * @param value: value for maximum csma backoff exponent + * + * @retval none + */ +void set_max_csma_be(uint8_t value); +/** + * @fn void set_max_csma_backoff(uint8_t value) + * @brief This API is used to set max csma backoff counter + * @param value: value for maximum csma backoff counter + * + * @retval none + */ +void set_max_csma_backoff(uint8_t value); +/** + * @fn void set_max_full_csma_frm_retries(uint8_t value) + * @brief This API is used to set custom max full csma frame retries + * @param value: value for maximum full csma retrials + * + * @retval none + */ +void set_max_full_csma_frm_retries(uint8_t value); +#endif /*end of RADIO_CSMA*/ +/** + * @fn void set_max_frm_retries(uint8_t value) + * @brief This API is used to set max frame retries + * @param value: value for maximum frame retries + * + * @retval none + */ +void set_max_frm_retries(uint8_t value); +/** + * @} + * + */ +/** @ingroup systm_layer_cmn_proc +* @{ +*/ +/** + * @fn uint32_t mac_gen_rnd_num(uint8_t *ptr_rnd, uint8_t len, uint8_t check_cont_rx) + * @brief This API is used to generate random number + * + * @param ptr_rnd : Pointer to the output random bytes . + * @param len : Number of required random bytes. + * @param check_cont_rx : this flag is set to check continuous reception . + */ +uint32_t mac_gen_rnd_num(uint8_t *ptr_rnd, uint16_t len, uint8_t check_cont_rx); +/** + * @} + * + */ +/** @ingroup systm_layer_enc +* @{ +*/ +/** + * @brief This function is used to decrypt frame pointed to by ptr_pckt + * + * @param ptr_pckt: pointer to the frame to be encrypted + * @param ptr_session_key: pointer to used session key + * @param ptr_ccm_nonce: pointer to the nonce + * @param mic_len: mic length + * @param ad_len: a data length + * @param md_len: m data length + * + * @retval status of the decryption process + * + */ +uint32_t radio_decrypt_pckts( uint8_t *ptr_pckt, + uint8_t *ptr_session_key, + uint8_t *ptr_ccm_nonce, + uint32_t mic_len, + uint32_t ad_len, + uint32_t md_len); +/** + * @} + * + */ +/** + * @fn void radio_mac_rx_done( otRadioFrame *aFrame, otError aError) + * @brief This API is used to call mac Radio rx done callback after end of reception. + * @param aFrame: pointer to the received frame + * @param aError: reception error + */ +void radio_mac_rx_done(otRadioFrame *aFrame, otError aError); + +#if (SUPPORT_ENH_ACK_LINK_METRICS_PROBING_OT_1_2) +/** + * This method set the Link Metrics noise floor value needed to calculate the link margine + * + * @param[in] noise_floor The noise floor used by Link Metrics. It should be set to the platform's + * noise floor (measured noise floor, receiver sensitivity or a constant). + * + */ +void radio_link_metrics_set_noise_floor(int8_t noise_floor); +#endif +#if(SUPPORT_OPENTHREAD_1_2 && CONFIG_MAC_CSL_TRANSMITTER_ENABLE) +/** + * @fn void radio_mac_tx_done_error( otRadioFrame *aFrame, otError aError) + * @brief This API is used to call mac Radio tx done + * @param tx_frame: pointer to the Tx frame + * @param aError: Tx error + */ +void radio_mac_tx_done_error(otRadioFrame * tx_frame,otError aError); +#endif /*(SUPPORT_OPENTHREAD_1_2 && CONFIG_MAC_CSL_TRANSMITTER_ENABLE)*/ +#if !SUPPORT_COEXISTENCE +/*##### Random Number Generation Group #####*/ +/** @ingroup rnd_gen_functions + * @{ + */ + /** + * @brief Request new random number. + * + * @param ptr_rnd : Pointer to the output random bytes . + * @param len : Number of required random bytes. + * + * @retval Status. + */ + uint32_t platform_gen_rnd_num( + uint8_t *ptr_rnd, + uint32_t len); +/** @} +*/ +/** + * + * @brief A common wrapper for BLE-ECB and MAC-CCM security modes + * + * @param ptr_pckt : Pointer to the data buffer (variable length + * in case of CCM mode, 16 bytes in case of ECB mode). The resulting + * Encrypted/Decrypted data overwrites this buffer. + * @param ptr_key[in] : Pointer to the security key buffer (16 bytes). + * @param ptr_nonce[in] : Pointer to the security nonce buffer (13 bytes + * in case of CCM mode, a Null pointer in case of ECB mode). + * @param mic_len[in] : Length of MIC, supported values are 0, 4, 6, + * 8, 10, 12, 14, and 16 in case of CCM, 0 only in case of ECB. + * @param ad_len[in] : Length of Data to be authenticated. + * @param md_len[in] : Length of Data to be encrypted. + * @param key_endian[in] : Represents the format of the security key. + * @param data_endian[in] : Represents the endian format of the data. + * @param security_mode[in]: Hardware security mode. + * @retval Status + */ +uint32_t platform_crypto(uint8_t *ptr_pckt, const uint8_t *ptr_key, + uint8_t *ptr_nonce, uint32_t mic_len, uint32_t ad_len, uint32_t md_len, + crypto_endian_enum_t key_endian, crypto_endian_enum_t data_endian, + security_mode_enum_t security_mode); + +/** + * + * @brief radio function that will be called to run periodic calibration if tempature has changed + * + * @retval Nonr + */ +void radio_run_phy_clbr_on_temp_change(void); +#endif /*!SUPPORT_COEXISTENCE*/ + +#if (!SUPPORT_COEXISTENCE) +/** + * + * @brief enable or disable LinkLayer Deep sleep mode + * + * @param dp_slp_mode : @ref DEEP_SLEEP_ENABLE enable deep sleep mode ,@ref DEEP_SLEEP_DISABLE go back to sleep mode + * + * @retval Status . + */ +otError radio_set_dp_slp_mode(dpslp_state_e dp_slp_mode); +#endif /*end of (!SUPPORT_COEXISTENCE)*/ +#if SUPPORT_MAC_PHY_CONT_TESTING_CMDS +/** + * + * @brief set the phy continuous modulation and continuous wave modes upon enable + * + * @param type[in] : the type of the modulation (0: modulation, 1: wave) + * @param enable_mode[in] : if true then enable the selected mode otherwise disable it + * @param chnl_num[in] : channel number to be used in modulation (range: 0 to 15) + * @param pwr[in] : The used power in dBm. + * @retval Status + */ +otError platform_zigbee_set_phy_cont_modul_mode(uint8_t type, uint8_t enable_mode, uint8_t chnl_num, int8_t pwr); +#endif /*end of SUPPORT_MAC_PHY_CONT_TESTING_CMDS */ +#if SUPPORT_ANT_DIV +/** + * + * @brief set antenna diversity parameters + * + * @param aInstance[in] : radio instance + * @param ptr_ant_div_params[in] : pointer to antenna diversity params structure + * @retval Status + */ +otError radio_set_ant_div_params(otInstance *aInstance, antenna_diversity_st* ptr_ant_div_params); + +/** + * + * @brief get antenna diversity parameters + * + * @param aInstance[in] : radio instance + * @param ptr_ant_div_params[out] : pointer to antenna diversity params structure + * @retval None + */ +void radio_get_ant_div_params(otInstance *aInstance, antenna_diversity_st* ptr_ant_div_params); + +/** + * + * @brief enable/disable antenna diversity + * + * @param aInstance[in] : radio instance + * @param enable[in] : enable:1 / disable:0 + * @retval Status + */ +otError radio_set_ant_div_enable(otInstance *aInstance, uint8_t enable); + +/** + * + * @brief set the default antenna id to be used for transmission and reception + * + * @param aInstance[in] : radio instance + * @param default_ant_id[in] : default antenna id + * @retval Status + */ +otError radio_set_default_ant_id(otInstance *aInstance, uint8_t default_ant_id); + +/** + * + * @brief set antenna diversity rssi threshold + * + * @param aInstance[in] : radio instance + * @param rssi_threshold[in] : rssi threshold to compare with during antenna diversity measurements + * @retval Status + */ +otError radio_set_ant_div_rssi_threshold(otInstance *aInstance, int8_t rssi_threshold); +#endif /* SUPPORT_ANT_DIV */ + +#if SUPPORT_CONFIGURABLE_GAIN_FIX +/** + * @brief initialize rssi gain fix region and select resistor measured percentage that affects pre-emphasis sequence. + * + * @param[in] region_0x1f_val: absolute gain fix for region 0x1F in dbm. + * @param[in] region_0x0f_val: absolute gain fix for region 0x0F in dbm. + * @param[in] region_0x0b_val: absolute gain fix for region 0x0B in dbm. + * @param[in] region_0x09_val: absolute gain fix for region 0x09 in dbm. + * @param[in] r_msur_percent: percentage of the measured resistor value that will be used + * to select the update values in pre-emphasis sequence (range: 0 to 99). + * + * @retval NONE + */ +void radio_gain_fix_init( + uint8_t region_0x1f_val, uint8_t region_0x0f_val, + uint8_t region_0x0b_val, uint8_t region_0x09_val, + uint8_t r_msur_percent); + +#endif /* SUPPORT_CONFIGURABLE_GAIN_FIX */ + +#endif /* INCLUDE_PLATFORM_H_ */ +/** + * @} + * + */ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ral.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ral.h new file mode 100644 index 000000000..afc029237 --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/ral.h @@ -0,0 +1,1543 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/ral.h#1 $*/ +/** + ******************************************************************************** + * @file ral.h + * @brief The file include description for the RAL (Radio Abstraction Layer) interfaces and call backs, + * RAL provides functionalities to start, stop and manage different types of events [Transmission - Reception - Energy scanning]. + * + * + * + ****************************************************************************** + * @copy + * Synopsys MIT License: + * Copyright (c) 2020-Present Synopsys, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of the software and + * associated documentation files (the “Software”), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. + * + * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE + * ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * */ + +#ifndef INCLUDE_RAL_H_ +#define INCLUDE_RAL_H_ + +#include "common_types.h" +#include "os_wrapper.h" +#include "mac_host_intf.h" +#include "instance.h" +#include "radio.h" +#if SUPPORT_ENH_ACK_LINK_METRICS_PROBING_OT_1_2 +#include "platform.h" +#endif +/* Defines */ +/* @brief: An index used in multi-instance for specifying which instance to perform operation on */ +typedef uint8_t ral_instance_t; +/* @brief: Defined for each ral event to identify event's current state + * + * + * ral event allocation + * ============== + *ral_add_tx_fifo() _ _ _ = RAL_IDLE = + * ============== + * + * ============== + * _ _(Requires ack)_ _ _ _ _ _ _= RAL_RX_ACK = + * ral event allocation / ============== + * ============= / + * ral_start_tx() _ _ _ _ = RAL_TX_PKT =_ _ ral_isr()_ _/ + * ============= \ + * \ ============== + * \_ _(Doesn't require ack)_ _ _ _= RAL_TX_PKT = + * ============== + * + * ============== + * _ _(Requires ack)_ _ _ _ _ _ _= RAL_TX_ACK = + * ral event allocation / ============== + * ============= / + * ral_start_rx() _ _ _ _ = RAL_RX_PKT =_ _ ral_isr()_ _/ + * ============= \ + * \ ============== + * \_ _(Doesn't require ack)_ _ _ _= RAL_RX_PKT = + * ============== + * ral event allocation + * ============== + *ral_ed_scan() _ _ _ _ _ = RAL_ED = + * ============== + * + * + * + * */ +typedef enum ral_event_state_enum { + RAL_IDLE, + RAL_RX_PKT, + RAL_TX_PKT, + RAL_RX_ACK, + RAL_TX_ACK, + RAL_ED +} ral_event_state_enum_t; +/* @brief: used for ral configuration assignment */ +typedef enum ral_state_enum { + RAL_DISABLE = 0, + RAL_ENABLE = 1 +} ral_state_enum_t; + +/* @brief: Error codes defined in ral casted to Openthread codes in radio */ +typedef enum ral_error_enum { + RAL_ERROR_NONE = 0, + RAL_ERROR_FAILED = 1, + RAL_ERROR_DROP = 2, + RAL_ERROR_NO_BUFS = 3, + RAL_ERROR_BUSY = 5, + RAL_ERROR_INVALID_PARAMETERS = 7, + RAL_ERROR_SECURITY = 8, + RAL_ERROR_NO_ADDRESS = 10, + RAL_ERROR_ABORT = 11, + RAL_ERROR_NOT_SUPPORTED = 12, + RAL_ERROR_INVALID_STATE = 13, + RAL_ERROR_NO_ACK = 14, + RAL_ERROR_CCA_FAILURE = 15, + RAL_ERROR_FCS = 17, + RAL_ERROR_NO_FRAME_RECEIVED = 18, + RAL_ERROR_INVALID_SOURCE_ADDRESS = 20, + RAL_ERROR_DESTINATION_ADDRESS_FILTERED = 22, + RAL_ERROR_TIMER_ISR = 23, +#if SUPPORT_ENH_ACK_LINK_METRICS_PROBING_OT_1_2 + RAL_ERROR_LINK_METRICS_INVALID_ARGS, + RAL_ERROR_LINK_METRICS_NOT_FOUND, + RAL_ERROR_LINK_METRICS_NO_BUF, +#endif /* SUPPORT_ENH_ACK_LINK_METRICS_PROBING_OT_1_2 */ +#if SUPPORT_ANT_DIV + RAL_ERROR_AD_NOT_IN_CONFIG_STATE, +#endif /* SUPPORT_ANT_DIV */ + RAL_ERROR_GENERIC = 255 +} ral_error_enum_t; + +/* @brief: Define power states for ral where: + * + * RAL_POWER_SLEEP: power state of the ral when not executing any event. + * RAL_POWER_ACTIVE: power state of the ral before starting of any event. + * */ +typedef enum ral_power_state_enum { + RAL_POWER_SLEEP, + RAL_POWER_ACTIVE +} ral_power_state_enum_t; + +/* @brief: Define new TX retry type: + * + * CONTINUE_CSMA_RETRY: continue of CSMA retry from csma_backoff_count. + * START_NEW_FULL_TX_RETRY: start new TX retry from frm_retries_count. + * */ +typedef enum tx_new_retry_enum { + CONTINUE_CSMA_RETRY, + START_NEW_FULL_TX_RETRY +}tx_new_retry_enum_t; + +/* @brief: Define pkt source for transmission when call ral_start_tx() to be added properly in ral pkt. + * + * RAL_SOURCE_PACKET: used in case of single packet transmission mode the pkt is passed in ral_start_tx() and then copied to the allocated event. + * + * */ +typedef enum ral_pkt_src_enum { +#if SUPPORT_A_MAC +/* RAL_SOURCE_FIFO: this mode is defined only for A_MAC. And used in case of burst transmission each packet is copied to a ral event using ral_add_tx_fifo(). + * all ral events linked to each other in a linked list which is attached to the ral instance initialized by the application. + */ + RAL_SOURCE_FIFO, +#endif + RAL_SOURCE_PACKET +} ral_pkt_src_enum_t; +/* @brief: Define type of acknowledgment packet used in MAC 802.15.4.*/ +typedef enum ral_ack_type_enum { + RAL_NO_ACK, +#if SUPPORT_A_MAC + RAL_ACK_CUSTOM, +#endif + RAL_ACK_MAC +} ral_ack_type_enum_t; +/* @brief: Define ral time structure that contains fine and base */ +typedef ble_time_t ral_time_st; + +/** + * @struct ral_pkt_st + * @brief ral packet structure + * + * This structure contains the parameters of the sent/received ral packet + * + */ +typedef struct _ral_pkt_st { + uint8_t * ptr_pyld; /* pointer to packet */ + ral_time_st time_stamp; /* exact time in which the packet transmitted/received */ + uint16_t pyld_len; /* packet length */ + uint8_t channel; /* channel at which the packet will be transmitted */ + uint8_t rxchannelaftertxdone; /* The RX channel after frame TX is done (after all frame retries - ack received, or timeout, or abort).*/ + union + { + struct + { + ral_pkt_src_enum_t pkt_src; /* source of transmitted packet */ +#if SUPPORT_RADIO_SECURITY_OT_1_2 + uint8_t *sec_key; /* pointer to the security key used in sec processing */ + uint8_t is_sec_proc_by_radio; /* flag to mark if security processed by radio or not*/ +#endif + int8_t tx_power; /* power of transmitted packet */ + uint8_t last_tx_pkt; /* last transmitted packet flag */ + uint8_t csl_frame; /* True only if the current TX frame is a CSL frame */ + } tx_info; + + struct + { +#if SUPPORT_RADIO_SECURITY_OT_1_2 + uint32_t ack_frm_cntr; /* frame counter used for secured Enhanced ack */ + uint8_t ack_key_id; /* key index used for secured Enhanced ack */ + uint8_t is_sec_enh_ack; /* flag to mark usage of secured Enhanced ack */ +#endif + int8_t rssi; /* received signal strength indicator */ + uint8_t lqi; /* link quality indicator */ + uint8_t ackFrmPending; /* This indicates if this frame was acknowledged with frame pending set */ + } rx_info; + } tx_rx_u; +} ral_pkt_st; + +/** + * @struct ral_evnt_info_st + * @brief event information for RAL + * + * This structure contains the full information of the transmitted/received event + */ +typedef struct _ral_evnt_info_st{ + struct _ral_evnt_info_st * ptr_nxt_evnt; /* pointer to next event, used in case of FIFO transmission */ + union + { + struct + { + ral_pkt_st * ptr_pkt; /* pointer to data packet */ + ral_pkt_st * ptr_ack_pkt; /* pointer to ack packet used by this event */ + } pkt_info; + struct + { + uint32_t ed_scn_durn; /* Energy detection scan duration */ + int8_t ed_max_rssi; /* Energy detection max rssi value */ + } ed_info; + } ral_evnt_info_u; + uint32_t ral_status_mask; /* HW error mask of the received packet */ + ral_instance_t ral_instance; /* ral identifier of this event */ + ral_event_state_enum_t event_state; /* event type */ + ral_error_enum_t evnt_error; /* event error passed to higher layers */ +#if (SUPPORT_PTA) + uint8_t tx_pta_counter; /* Either the PTA Tx or Rx reject counter depending on the packet type */ + uint8_t rx_pta_counter; /* Either the PTA Tx or Rx reject counter depending on the packet type */ +#endif /* SUPPORT_PTA */ +} ral_evnt_info_st; + +/** + * @struct ral_mac_fltr_confg_st + * @brief MAC filteration parameters + * + * MAC filteration parameters used by HW to filter received packets. + * Used only by MAC 802.15.4 + * */ +typedef struct _ral_mac_fltr_confg_st { + uint8_t ext_addr[EXT_ADDRESS_LENGTH]; /* the device extended address to compare the received address with */ + uint16_t short_addr; /* the device short address to compare the received address with */ + uint16_t pan_id; /* the device pan id to compare the received pan id in the packet with */ + ral_state_enum_t mac_fltr_state; /* MAC filter state. If disabled so the promiscuous mode is enabled */ + uint8_t mac_implicit_broadcast; /* MAC ImplictBoradcast PIB that is set in MAC layer */ + uint8_t is_pan_coord; /* the first bit used to determine if the device is pan coordinator or not + the second bit is indicating if this instance is currently performing scanning or not */ +} ral_mac_fltr_confg_st; + +/** + * @struct ral_ack_rspnd_fltr_confg_st + * @brief filter before sending ack configuration + * + * this structure contains the parameters used to filter the received packet. + * and respond to this packet with ack or not + * */ +typedef struct _ral_ack_rspnd_fltr_confg_st { +#if SUPPORT_A_MAC + uint8_t * ptr_comp_value; /* Pointer to value to be compared with received data */ + uint8_t byte_index; /* Position of the byte start to be compared in the received data */ + uint8_t byte_len; /* Number of bytes to be compared in the received data */ +#endif + ral_state_enum_t ack_fltr_state; /* Enable/Disable packet filtration before sending ack */ +} ral_ack_rspnd_fltr_confg_st; +/** + * @struct ral_ack_req_confg_st + * @brief ack request bit configuration + * + * this structure contains information of ack request bit configuration + * */ +typedef struct _ral_ack_req_confg_st { + ral_state_enum_t ack_req_bit_state; /* Enable/Disable Ack request bit check */ + uint8_t byte_index; /* Byte index of Ack request bit in tx/rx packet */ + uint8_t bit_index; /* Bit index of Ack request bit in tx/rx packet */ +} ral_ack_req_confg_st; + +/** + * @struct ral_auto_ack_confg_st + * @brief RAL ack data + * + * this structure contains the parameters of the acknowledgment configuration. + * Configure of the received ack (in case of transmission) or configure the transmitted ack (in case of data reception) + * */ +typedef struct _ral_auto_ack_confg_st { + ral_ack_rspnd_fltr_confg_st rspnd_fltr_confg; /* Contains configured filters applied to received packet to determine whether to send ack or not */ + ral_ack_req_confg_st ack_req_confg; /* Contains configured ack request bit configuration*/ + uint16_t auto_tx_ack_turnaround; /*time in micro second between rcvd packet and tx ack */ + uint16_t auto_rx_ack_turnaround; /*time in micro second between tx packet and rcvd ack */ + uint16_t auto_rx_ack_timeout; /*timeout in microseconds to wait for rcvd ack*/ + uint16_t auto_rx_enh_ack_timeout; /*timeout in microseconds to wait for rcvd enhanced ack*/ + ral_ack_type_enum_t ack_type; /*ACK type*/ + ral_state_enum_t auto_tx_ack_state; /*Enable/Disable automatic transmitted ack*/ + ral_state_enum_t auto_rx_ack_state; /*Enable/Disable automatic rcvd ack*/ +} ral_auto_ack_confg_st; + +#if SUPPORT_A_MAC +typedef struct _ral_a_mac_params_st { + ral_auto_ack_confg_st auto_ack_config; + uint16_t ifs; + ral_phy_rate_enum_t phy_rate; +}ral_a_mac_params_st; +#endif /*SUPPORT_A_MAC*/ +/** + * @struct ral_coex_info_st + * @brief RAL event infomration in case of coexistence + * */ +typedef struct _ral_coex_info_st { + void * evnt_hndl; /* pointer to RAL event handle given from event scheduler after registration */ + ble_time_t grant_end_time; /* end time in sleep timer steps of grant given from event scheduler */ +} ral_coex_info_st; + +#if SUPPORT_ENH_ACK_LINK_METRICS_PROBING_OT_1_2 || CONFIG_MAC_CSL_RECEIVER_ENABLE +/** + * @struct mac_address_st + * @brief structure carrying information about address and address mode of a device + * */ +typedef struct mac_address_{ + uint8_t * ptr_address; + mac_addrs_mode_enum_t address_mode; +} mac_address_st; + +#if SUPPORT_ENH_ACK_LINK_METRICS_PROBING_OT_1_2 +/** + * @struct link_metrics_info_st + * @brief RAL Copy of radio otLinkMetrics structure + * */ +typedef struct link_metrics_info_ +{ + uint8_t mPduCount : 1; ///< Pdu count. + uint8_t mLqi : 1; ///< Link Quality Indicator. + uint8_t mLinkMargin : 1; ///< Link Margin. + uint8_t mRssi : 1; ///< Received Signal Strength Indicator. + uint8_t mReserved : 1; ///< Reserved, this is for reference device. +} link_metrics_info_st; + +typedef struct link_metric_data_info_st_* p_link_metric_data_info_st; +/** + * @struct link_metric_data_info_st + * @brief Link metrics initiator node + * */ +typedef struct link_metric_data_info_st_{ + + p_link_metric_data_info_st ptr_nxt_node; + // Initiator Info + struct{ + uint8_t extended_address[EXT_ADDRESS_LENGTH]; + uint16_t short_address; + } initiator_address_field_st; + link_metrics_info_st initiator_link_metrics; + +} link_metric_data_info_st; +#endif // SUPPORT_ENH_ACK_LINK_METRICS_PROBING_OT_1_2 +#endif // SUPPORT_ENH_ACK_LINK_METRICS_PROBING_OT_1_2 || CONFIG_MAC_CSL_RECEIVER_ENABLE + +/* Callback API */ +/** + * @struct ral_cbk_dispatch_tbl_st + * @brief call back functions + * + * This structure contains pointer to call back functions which should be called in ISR after Tx/Rx/ED is done + * */ +typedef struct _ral_cbk_dispatch_tbl_st { + void (*ral_tx_done)(ral_instance_t ral_instance, ral_pkt_st * ptr_tx_pkt, ral_pkt_st * ptr_ack_pkt, ral_error_enum_t tx_error); + void (*ral_rx_done)(ral_instance_t ral_instance, ral_pkt_st * ptr_rx_pkt, ral_error_enum_t rx_error); + void (*ral_ed_scan_done)(ral_instance_t ral_instance, uint32_t scan_durn, int8_t max_rssi); +#if (!SUPPORT_COEXISTENCE) + void (*ral_resume_rx_after_tmr_err)(void); +#endif /*end of (!SUPPORT_COEXISTENCE)*/ +#if SUPPORT_A_MAC + /*This callback will be called when device receives packet that require custom ack*/ + void (*ral_configure_custom_ack)(ral_instance_t ral_instance, uint8_t *ptr_ack_pkt, uint16_t*ack_len,uint8_t * ptr_rx_pkt); +#endif /*end of SUPPORT_A_MAC*/ +} ral_cbk_dispatch_tbl_st; +/* Definition for hardware control flags */ +//-------------------------------------------- +/* + * Tx PHY Rate: + * 0:125k + * 1:250k + * 2:1M + * 3:2M + * + * */ +#define DEFAULT_PHY_RATE 1 +/* : + * */ +#define DEFAULT_PHY_TX_LOWLTNCY 0 +/* : + * */ +#define DEFAULT_PHY_RX_LOWLTNCY 0 +/* + * Bypass CRC check [used for testing purpose] + * 1'b1 : Bypassing CRC check on the received packet. + * 1'b0 : perform CRC check on the received packet. + * */ +#define DEFAULT_TXPP_BYPASS_CRC 0 +/* : + * */ +#define DEFAULT_SCAN_BCN 0 +/* + * Packet processor configuration + * 1'b1 : RX PP will discard packet when mac_prmsicsmode is FALSE and generate error flags + * 1'b0 : RX PP will not discard packet when mac_prmiscsmode is FALSE and will only generate error flags + * */ +#define DEFAULT_DROP_ON_ERR 1 +/* +* PAN Coordinator identifier (used in third-level filtering when only source PAN ID is present in the received packet): +* 1'b1 - The device is PAN coordinator +* 1'b0 - The device is not PAN coordinator + * + * */ +#define DEFAULT_PANCOORD 0 +/* +* Indicates whether frames without a destination PAN ID and a destination address are to treated +* as though they are addressed to the broadcast PAN ID and broadcast short address. + * + * */ +#define DEFAULT_MACIMPLICITBROADCAST 0 +/* : + * */ +#define DEFAULT_MACGRPRXMODE 0 +/* + * MAC Promiscuous Mode - Indication of whether the MAC sublayer is in a promiscuous (receive all) mode. + * A value of TRUE indicates that the MAC sublayer accepts all frames received from the PHY. + * Shall be used for reception second-level filtering requirements + * */ +#define DEFAULT_MAC_PRMISCMOD 0 +//-------------------------------------------- +/*@enum + *@breif: enumerator that defines bit shift amount for control flags used to configure HW + * */ +enum control_flags_shift { + PHY_RATE_SHIFT, + PHY_TX_LOWLTNCY_SHIFT=2, + PHY_RX_LOWLTNCY_SHIFT, + TXPP_BYPASS_CRC_SHIFT, + SCAN_BCN_SHIFT, + DROP_ON_ERR_SHIFT, + PANCOORD_SHIFT, + MACIMPLICITBROADCAST_SHIFT, + MACGRPRXMODE_SHIFT, + MAC_PRMISCMOD_SHIFT, + VDDH_PA_SHIFT, + EPA_DISABLE_SHIFT = 15 +}; +/*@enum + *@breif: enumerator that defines bit shift amount for errors returned after event completion + * */ +enum error_flags_shift{ + TIMEOUT_FLAG_SHIFT = 2, /* bit location for timeout flag reception error */ + ADDMODE_ERR_SHIFT, /* bit location for Address Mode reception error. asserted when either of the following is asserted (dstaddr_err,srcpanid_err,dstpanid_err)*/ + RX_ERR_SHIFT, /* bit location for rx operation error. asserted when either rx_err or ppdu_err is asserted */ + PPDU_ERR_SHIFT, /* bit location for PPDU reception error. asserted when any of the following is asserted + (ack_err, crc_err,dstaddr_err,srcpanid_err,dstpanid_err,frmvrsn_err,frmtype_err,frmlngth_err)*/ + FRMLNGTH_ERR_SHIFT, /* bit location for Frame Length reception error. Asserted when received frame length is one of the reserved values mac_prmiscmode=0 and + decoded MAC header indicates MAC frame longer than received frame length*/ + FRMTYPE_ERR_SHIFT, /* bit location for Frame type reception error asserted when received frame type is one of the reserved values. + Available only when mac_prmiscmode=0 */ + FRMVRSN_ERR_SHIFT, /* bit location for Frame version reception error asserted when received frame version is neither 2'b00 not 2'b01. + Available only when mac_prmiscmode=0 */ + DSTPANID_ERR_SHIFT, /* bit location for Destination PAN ID reception error. Available only when mac_prmiscmode=0 */ + SRCPANID_ERR_SHIFT, /* bit location for Source PAN ID reception error. Available only when mac_prmiscmode=0 */ + ACK_OK_SHIFT, /* bit location for Acknowledgment received correctly flag */ + ACK_ERR_SHIFT, /* bit location for Acknowledgment received with errors flag */ + CRC_ERR_SHIFT, /* bit location for CRC error indicator flag*/ + DSTADDR_ERR_SHIFT, /* bit location for Destination Address reception error. Available only when mac_prmiscmode=0 */ + SEC_ERR_SHIFT = 30 /* bit location for security processing error occurred in case of secured Enhanced Ack */ +}; + + +/* Start of frame delimiter length as defined in OQPSK phy in MAC 802.15.4 std*/ +#define DEFAULT_MAC_SFD_LENGTH 1 +/* Preample length as defined in OQPSK phy in MAC 802.15.4 std*/ +#define DEFAULT_MAC_PREAMBLE_LENGTH 4 +/* Start of frame delimiter value as defined in OQPSK phy in MAC 802.15.4 std*/ +#define DEFAULT_MAC_SFD_VALUE 0xA7 +/* Preample value as defined in OQPSK phy in MAC 802.15.4 std*/ +#define DEFAULT_MAC_PEAMBLE_VALUE 0x0 + +#if(SUPPORT_A_MAC) +/* 1M preamble and SFD used only in A_MAC */ +/* Custom start of frame delimiter length used in 1M phy_rate*/ +#define DEFAULT_A_MAC_SFD_LENGTH_1M 4 +/* Custom preample length used in 1M phy rate*/ +#define DEFAULT_A_MAC_PREAMBLE_LENGTH_1M 1 +/* Custom start of frame delimiter value used in 1M phy_rate*/ +#define DEFAULT_A_MAC_SFD_VALUE_1M 0x71764129 +/* Custom preample value used in 1M phy rate*/ +#define DEFAULT_A_MAC_PEAMBLE_VALUE_1M 0xAA + +/* 2M preamble and SFD used only in A_MAC */ +/* Custom start of frame delimiter length used in 2M phy_rate*/ +#define DEFAULT_A_MAC_SFD_LENGTH_2M 4 +/* Custom preample length used in 2M phy rate*/ +#define DEFAULT_A_MAC_PREAMBLE_LENGTH_2M 2 +/* Custom start of frame delimiter value used in 2M phy_rate*/ +#define DEFAULT_A_MAC_SFD_VALUE_2M 0x71764129 +/* Custom preample value used in 2M phy rate*/ +#define DEFAULT_A_MAC_PEAMBLE_VALUE_2M 0xAAAA +#endif + +/* Bitfield sizes defined for MAC descriptor */ +#define MAC_SFD_VALUE_SIZE 32 +#define MAC_PREAMBLE_VAL_SIZE 32 +#define MAC_PANID_SIZE 16 +#define MAC_SHORTADDR_SIZE 16 +#define EUI64ADD_LSW_SIZE 32 +#define EUI64ADD_MSW_SIZE 32 +#define MAC_EXTADDR_LSW_SIZE 32 +#define MAC_EXTADDR_MSW_SIZE 32 +#define ERROR_FLAGS_SIZE 15 +#define RX_FRAME_LEN_SIZE 7 +#define DEBUG_PORTS_SIZE 5 +#define POINTER_TO_CURRENT_TX_SIZE 16 +#define POINTER_TO_CURRENT_RX_SIZE 16 +#define FRMLNGTH_SIZE 7 +#define MAC_SFD_LEN_SIZE 3 +#define MAC_PREAMBLE_LEN_SIZE 3 +#define SEQNUM_SIZE 8 +#define TX_MAC_LATENCY_SIZE 6 +#define CONTROL_FLAGS_SIZE 16 +#define PHY_DRV_SEQ_STRT_ADDR_SIZE 7 +#define PHY_DRV_SEQ_END_ADDR_SIZE 7 +#define PHY_DRV_RSSI_VALUE_SIZE 16 +#define PHY_DRV_LQI_VALUE_SIZE 8 +/* + * @struct + * @brief: contains Hardware descriptor fields that: + * 1- required to be filled before start of event. + * 2- need to be checked after the end of event. + * */ +typedef struct llhwc_mac_evnt_info_mem_st { + uint32_t mac_sfd_value :MAC_SFD_VALUE_SIZE; /* Start of frame delimiter value used by serializer and deserializer*/ + uint32_t mac_preamble_val :MAC_PREAMBLE_VAL_SIZE; /* Preamble value used by serializer */ + uint32_t mac_panid :MAC_PANID_SIZE; /* The identifier of the PAN on which the device is operating.used for third-level filtering */ + uint32_t mac_shortaddr :MAC_SHORTADDR_SIZE; /* The address that the device uses to communicate in the PAN.used for fourth-level filtering */ + uint32_t eui64add_LSW :EUI64ADD_LSW_SIZE; /* Least significant word for EUI Extended address defined in 2015 */ + uint32_t eui64add_MSW :EUI64ADD_MSW_SIZE; /* Most significant word for EUI Extended address defined in 2015 */ + uint32_t mac_extaddr_LSW :MAC_EXTADDR_LSW_SIZE; /* Least significant word for device Extended address */ + uint32_t mac_extaddr_MSW :MAC_EXTADDR_MSW_SIZE; /* Most significant word for device Extended address */ + uint32_t error_flags :ERROR_FLAGS_SIZE; /* Error flags set by hardware to indicate filteration errors*/ + uint32_t :1; + uint32_t rx_frm_len :RX_FRAME_LEN_SIZE; /* length of the received frame */ + uint32_t debug_ports :DEBUG_PORTS_SIZE; /* debugging ports defined for ST */ + uint32_t :4; + uint32_t rssi_out :PHY_DRV_RSSI_VALUE_SIZE; + uint32_t LQI :PHY_DRV_LQI_VALUE_SIZE; + uint32_t :8; + uint32_t frmlngth :FRMLNGTH_SIZE; /* length of the transmitted MAC frame */ + uint32_t :1; + uint32_t mac_sfd_len :MAC_SFD_LEN_SIZE; /* SFD length: 1 octet */ + uint32_t mac_preamble_len :MAC_PREAMBLE_LEN_SIZE; /* Preamble length: 4 octets */ + uint32_t :2; + uint32_t seqnum :SEQNUM_SIZE; /* Sequence number compared against sequence number extracted from mac header of a received ACK frame*/ + uint32_t tx_latency :TX_MAC_LATENCY_SIZE; /* This field sets the required time for the TX path to flush the last bit on the air */ + uint32_t :2; + uint32_t control_flags :CONTROL_FLAGS_SIZE; /* Flags used to Enable/Disable features in HW */ + uint32_t phy_drv_seq_strt_addr :PHY_DRV_SEQ_STRT_ADDR_SIZE;/* pointer to start address for sequencer ram */ + uint32_t :1; + uint32_t phy_drv_seq_end_addr :PHY_DRV_SEQ_END_ADDR_SIZE;/* pointer to end address for sequencer ram */ + uint32_t :1; + uint32_t Pointer_To_current_TX :POINTER_TO_CURRENT_TX_SIZE; /* pointer to the packet in shared memory to be transmitted */ + uint32_t Pointer_To_current_RX :POINTER_TO_CURRENT_RX_SIZE; /* pointer to shared memory place at which the packet will be received */ + +}llhwc_mac_evnt_info_mem_t; +#if SUPPORT_RADIO_SECURITY_OT_1_2 +typedef struct sec_update_desc_st_{ + uint8_t * ptr_key; + uint32_t frm_cntr; + uint32_t hdr_len; + uint8_t mic_len; + uint8_t sec_lvl; +} sec_update_desc_st; +#endif +/* + * brief: pointer to mac descriptor + * */ +extern llhwc_mac_evnt_info_mem_t* g_mac_event_info; + +/** @ingroup ral_intf_cmn +* @{ +*/ +/* Generic APIs ----------------------------------------------------------------------------------- */ +/** + * + * + * @brief radio abstraction layer initialize + * + * @param ptr_cbk_dispatch_tbl : [in] pointer to callbacks dispatch table + * + * @retval ral instance associated to this context that should be used with any ral interface + */ +ral_instance_t ral_init(ral_cbk_dispatch_tbl_st * ptr_cbk_dispatch_tbl); + +/** + * + * + * @brief ral power switch either sleep or active + * + * @param ral_instance : [in] ral instance + * @param power_state : [in] new power state + * @param ptr_coex_info : [in] pointer to current coexistence parameters + * + * @retval RAL_ERROR_NONE if power state changed successfully + */ +ral_error_enum_t ral_power_switch(ral_instance_t ral_instance, + ral_power_state_enum_t power_state, ral_coex_info_st * ptr_coex_info); + +/** + * + * + * @brief get current power state + * + * @param ral_instance : [in] ral instance + * + * @retval current power state RAL_POWER_SLEEP or RAL_POWER_ACTIVE + */ +ral_power_state_enum_t ral_get_power_state(ral_instance_t ral_instance); + +/** + * + * + * @brief get current event state and current channel if not idle + * + * @param curr_ral_instance : [out] current ral instance if not idle + * @param curr_event_channel : [out] current event channel if not idle + * + * @retval current event state RX, TX, ED, IDLE + */ +ral_event_state_enum_t ral_get_current_event_state(ral_instance_t * curr_ral_instance, uint8_t * curr_event_channel); + +#if SUPPORT_ANT_DIV +/** + * @fn ral_set_ant_div_params + * + * @brief set antenna diversity feature parameters + * + * @param ral_instance : [in] used ral instance + * @param ptr_ant_div_params : [in] pointer to antenna diversity parameters structure + * + * @retval RAL_ERROR_NONE if antenna diversity parameters are set correctly + */ +ral_error_enum_t ral_set_ant_div_params(ral_instance_t ral_instance, antenna_diversity_st* ptr_ant_div_params); + +/** + * @fn ral_get_ant_div_params + * + * @brief get antenna diversity feature parameters + * + * @param ral_instance : [in] used ral instance + * @param ptr_ant_div_params : [out] pointer to antenna diversity parameters structure + * + * @retval None + */ +void ral_get_ant_div_params(ral_instance_t ral_instance, antenna_diversity_st* ptr_ant_div_params); + +/** + * @fn ral_set_ant_div_enable + * + * @brief enable/disable antenna diversity + * + * @param ral_instance : [in] used ral instance + * @param enable : [in] enable:1 / disable:0 + * + * @retval RAL_ERROR_NONE if antenna diversity is enabled/disabled correctly + */ +ral_error_enum_t ral_set_ant_div_enable(ral_instance_t ral_instance, uint8_t enable); + +/** + * @fn ral_set_default_ant_id + * + * @brief set the default antenna id to be used for transmission and reception + * + * @param ral_instance : [in] used ral instance + * @param default_ant_id : [in] the antenna id to be used as default + * + * @retval RAL_ERROR_NONE if default antenna ID is set correctly + */ +ral_error_enum_t ral_set_default_ant_id(ral_instance_t ral_instance, uint8_t default_ant_id); + +/** + * @fn ral_set_ant_div_rssi_threshold + * + * @brief set antenna diversity rssi threshold + * + * @param ral_instance : [in] used ral instance + * @param rssi_threshold : [in] rssi threshold to compare with during antenna diversity measurements + * + * @retval RAL_ERROR_NONE if antenna diversity RSSI threshold is set correctly + */ +ral_error_enum_t ral_set_ant_div_rssi_threshold(ral_instance_t ral_instance, int8_t rssi_threshold); +#endif /* SUPPORT_ANT_DIV */ + +/** + * @} + */ +#if((!SUPPORT_COEXISTENCE && DEFAULT_PHY_CALIBRATION_PERIOD)) +/** + * + * + * @brief Execute PHY periodic calibration + * + * + * @retval NONE + */ +void ral_exec_phy_prdc_clbr(void); +#endif +/** @ingroup ral_intf_cmn +* @{ +*/ +#if SUPPORT_MAC +#if SUPPORT_A_MAC +/** + * + * + * @brief set phy rate for transmission/reception + * + * @param ral_instance : [in] used ral instance + * @param phy_rate : [in] new phy rate [1M/2M/256K/125K] + * + * @retval RAL_ERROR_NONE if phy rate changed successfully + */ +ral_error_enum_t ral_set_rate(ral_instance_t ral_instance, ral_phy_rate_enum_t phy_rate); +/** + * + * @brief set minimum interframe spacing between successive transmission/reception + * + * @param ral_instance : [in] used ral instance + * @param min_ifs : [in] new minimum interframe spacing in microsecond + * + * @retval None. + */ +void ral_set_min_ifs(ral_instance_t ral_instance, uint16_t min_ifs); +#endif + + +/** + * + * + * @brief set interframe spacing between successive transmission/reception + * + * @param ral_instance : [in] used ral instance + * @param ifs : [in] new interframe spacing in microsecond + * + * @retval RAL_ERROR_NONE if interframe spacing changed successfully + */ +#if SUPPORT_A_MAC +ral_error_enum_t ral_set_ifs(ral_instance_t ral_instance, uint16_t ifs); +#else +#if SUPPORT_ZIGBEE_PHY_CERTIFICATION +ral_error_enum_t ral_set_ifs(ral_instance_t ral_instance, uint16_t ifs); +#endif /* SUPPORT_ZIGBEE_PHY_CERTIFICATION */ +#endif +#endif +/** + * @} + */ +/** @ingroup ral_intf_tx +* @{ +*/ +/* Transmission APIs ----------------------------------------------------------------------------------- */ +/** + * + * + * @brief start packet transmission + * This function responsible for preparation for transmission of a packet by allocating and preparing a new ral event/ral pkt to be executed by HW. + * After completion of the Transmission event or if stop operation ral_tx_done() will be called carrying the status of event. + * + * @param ral_instance : [in] ral instance + * @param pkt_src : [in] transmission packet source, FIFO based or Packet based + * @param ptr_pkt : [in] pointer to transmitted packet if packet source is Packet based only + * @param ptr_start_time : [in] pointer to start time structure which contains start time of transmission + * if NULL function will use the current time get from llhwc_slptmr_get + * @param periodic_interval : [in] periodic interval in microsecond, 0 means not periodic + * @param ptr_coex_info : [in] pointer to current coexistence parameters + * + * @retval RAL_ERROR_NONE if transmission started successfully + * RAL_ERROR_INVALID_PARAMETERS if the passed parameters doesn't make sense e.g. starting fifo mode but ptr_fifo_head = NULL + * RAL_ERROR_BUSY if there is a transmission event that already started and not ended yet + * + * @note: ral_tx_done won't be called unless emngr_handle_all_events() is called to call ral_sm_done which will call the ral_tx_done call back + * + */ +ral_error_enum_t ral_start_tx(ral_instance_t ral_instance, ral_pkt_src_enum_t pkt_src, ral_pkt_st * ptr_pkt, + ral_time_st * ptr_start_time, uint32_t periodic_interval, ral_coex_info_st * ptr_coex_info); + +/** + * + * + * @brief abort current transmission + * This function is used for testing purpose + * + * @param ral_instance : [in] ral instance + * + * @retval RAL_ERROR_NONE if transmission aborted successfully + */ +ral_error_enum_t ral_abort_tx(ral_instance_t ral_instance); + +#if SUPPORT_A_MAC +/** + * + * + * @brief add packet to transmission FIFO + * + * @param ral_instance : [in] ral instance + * @param ptr_pkt : [in] pointer to input packet allocated by user application + * + * @retval RAL_ERROR_NONE if packet added to FIFO successfully + */ +ral_error_enum_t ral_add_tx_fifo(ral_instance_t ral_instance, ral_pkt_st * ptr_pkt); + +/** + * @brief flush current transmission FIFO + * + * @param ral_instance : [in] ral instance + * + * @retval RAL_ERROR_NONE if FIFO flushed successfully + */ +ral_error_enum_t ral_flush_fifo(ral_instance_t ral_instance); +#endif + +/** + * @brief get transmission packet to prepare data in before starting transmission + * must be used in case of packet transmission mode, The packet is allocated from TX/RX shared memory. + * + * @param ral_instance : [in] ral instance + * + * @retval pointer to allocated ral packet + */ +ral_pkt_st * ral_get_tx_buf(ral_instance_t ral_instance); +/** + * @} + */ +/** @ingroup ral_intf_ed +* @{ +*/ +/** + * @brief perform Clear Channel Assessment on selected channel + * + * @param channel : [in] channel to perform CCA on. + * @param ptr_coex_info : [in] pointer to current coexistence parameters + * @param energyThreshold : [in] the minimum value of RSSI to mark the channel busy , + * it used only in case of phy 2.00a_tc. defined by cca_change_threshold_seq for other phys. + * @param ral_instance : [in] ral instance + * @retval RAL_ERROR_NONE if no traffic on air, RAL_ERROR_CCA_FAILURE otherwise + */ +ral_error_enum_t ral_perform_cca(uint8_t channel, ral_coex_info_st * ptr_coex_info, int8_t energyThreshold + , ral_instance_t ral_instance +); +/** + * @} + */ +/** @ingroup ral_intf_rx +* @{ +*/ +/* Reception APIs ----------------------------------------------------------------------------------- */ +/** + * @brief start packet reception + * This function responsible for preparation for reception of a packet by allocating and preparing a new ral event/ral pkt to be executed by HW. + * After completion of the Reception event or if stop operation ral_rx_done() will be called carrying the status of event and the packet received. + * + * + * @param ral_instance : [in] ral instance + * @param rx_channel : [in] channel to receive on + * @param ptr_start_time : [in] pointer to start time structure which contains start time of reception + * @param timeout : [in] timeout of reception in microsecond from the start of reception + * @param periodic_interval : [in] periodic interval in microsecond, 0 means not periodic + * @param ptr_coex_info : [in] pointer to current coexistence parameters + * + * @retval RAL_ERROR_NONE if reception started successfully + * RAL_ERROR_INVALID_PARAMETERS if the passed parameters doesn't make sense e.g. if the reception channel out of MAC band + * RAL_ERROR_BUSY if there is a transmission event that already started and not ended yet + * + * @note: ral_rx_done won't be called unless emngr_handle_all_events() is called to call ral_sm_done which will call the ral_rx_done call back + */ +ral_error_enum_t ral_start_rx(ral_instance_t ral_instance, uint8_t rx_channel, ral_time_st * ptr_start_time, + uint32_t timeout, uint32_t periodic_interval, ral_coex_info_st * ptr_coex_info); + +/** + * @brief abort current reception + * This function is used for tseting purpose + * + * @param ral_instance : [in] ral instance + * + * @retval RAL_ERROR_NONE if reception aborted successfully + */ +ral_error_enum_t ral_abort_rx(ral_instance_t ral_instance); +/** + * @} + */ +/** @ingroup ral_intf_cmn +* @{ +*/ +/** + * @brief set automatic continuous reception after each event state + * + * @param ral_instance : [in] ral instance + * @param cont_recp_state : [in] continuous reception state, Enable or Disable + * Enable: means that when no transmission device will always receive + * + * @retval RAL_ERROR_NONE if new state saved successfully + */ +ral_error_enum_t ral_set_cont_recp_state(ral_instance_t ral_instance, ral_state_enum_t cont_recp_state); + +/** + * @brief This function used to Enable/Disable automatic switching to sleep mode after finish each event. + * set automatic sleep after each event state in case of continuous reception is disabled as if enabled + * ral shall schedule reception event from ral_isr() using active timer + * + * @param ral_instance : [in] ral instance + * @param auto_sleep_state : [in] automatic sleep state, Enable or Disable + * + * @retval RAL_ERROR_NONE if new state saved successfully + */ +ral_error_enum_t ral_set_auto_sleep_state(ral_instance_t ral_instance, ral_state_enum_t auto_sleep_state); +/** + * @brief This function used to get the state of automatic switching to sleep mode + * + * @param ral_instance : [in] ral instance + * + * @retval automatic sleep state, Enable or Disable + */ +ral_state_enum_t ral_get_auto_sleep_state(ral_instance_t ral_instance); +/** + * @brief configure mac filter in rtl while reception. + * when filter is disabled means reception in promiscuous mode. + * + * @param ral_instance : [in] ral instance + * @param ptr_mac_fltr_confg : [in] pointer to mac filter configuration + * + * @retval RAL_ERROR_NONE if new configuration saved successfully + */ +ral_error_enum_t ral_confg_mac_fltr(ral_instance_t ral_instance, ral_mac_fltr_confg_st * ptr_mac_fltr_confg); +/** + * @brief configure mac filter in scan mode + * + * + * @param ral_instance : [in] ral instance + * @param Enable : [in] set or clear scan mode + * + * @retval RAL_ERROR_NONE if new configuration saved successfully + */ +ral_error_enum_t ral_set_scan_filter(ral_instance_t ral_instance, uint8_t Enable); + +/* Auto Acknowledge APIs ----------------------------------------------------------------------------------- */ +/** + * @brief configure automatic ack after packet transmission/reception + * + * @param ral_instance : [in] ral instance + * @param ptr_auto_ack_confg : [in] pointer to new automatic ack configuration + * + * @retval RAL_ERROR_NONE if new configuration saved successfully + */ +ral_error_enum_t ral_confg_auto_ack(ral_instance_t ral_instance, ral_auto_ack_confg_st * ptr_auto_ack_confg); + +/** + * @brief temporary pause/resume automatic ack state only after transmission/reception + * this function is used for testing and custom purposes. + * + * @param ral_instance : [in] ral instance + * @param auto_tx_ack_state : [in] new state of automatic ack transmission + * @param auto_rx_ack_state : [in] new state of automatic ack reception + * + * @retval RAL_ERROR_NONE if new configuration saved successfully + */ +ral_error_enum_t ral_pause_auto_ack(ral_instance_t ral_instance, ral_state_enum_t auto_tx_ack_state, ral_state_enum_t auto_rx_ack_state); +/** + * @} + */ + +/** + * @brief set enhanced ack Header IE data + * + * @param ral_instance : [in] ral instance + * @param ptr_hdr_ie : [in] pointer to header IE data to be included in enhanced ack + * @param hdr_ie_len : [in] header IE data length + * + * @retval RAL_ERROR_NONE if new configuration saved successfully + */ +ral_error_enum_t ral_set_enh_ack_hdr_ie(ral_instance_t ral_instance, uint8_t * ptr_hdr_ie, uint8_t hdr_ie_len); + + +/** @ingroup ral_intf_cmn +* @{ +*/ +/** + * @brief Enable/Disable source address match feature. + * If disabled, the ral must set the "frame pending" on all acks to data request commands. + * If enabled, the ral uses the source address match table to determine whether to set or clear the + * "frame pending" bit in an ack to a data request command. + * + * @param ral_instance : [in] ral instance + * @param src_match_state : [in] source address match state + * + * @retval void + */ +void ral_set_src_match_state(ral_instance_t ral_instance, ral_state_enum_t src_match_state); + +/** + * @brief Add a short address to the source address match table + * + * @param ral_instance : [in] ral instance + * @param short_address : [in] short address to be added + * + * @retval RAL_ERROR_NONE if added successfully + */ +ral_error_enum_t ral_add_src_match_short(ral_instance_t ral_instance, const uint16_t short_address); + +/** + * @brief Add an extended address to the source address match table + * + * @param ral_instance : [in] ral instance + * @param ptr_ext_addr : [in] pointer to extended address to be added + * + * @retval RAL_ERROR_NONE if added successfully + */ +ral_error_enum_t ral_add_src_match_ext(ral_instance_t ral_instance, const uint8_t * ptr_ext_addr); + +/** + * @brief Remove a short address from the source address match table + * + * @param ral_instance : [in] ral instance + * @param short_address : [in] short address to be removed + * + * @retval RAL_ERROR_NONE if removed successfully + */ +ral_error_enum_t ral_clr_src_match_short(ral_instance_t ral_instance, const uint16_t short_address); + +/** + * @brief Remove an extended address from the source address match table + * + * @param ral_instance : [in] ral instance + * @param ptr_ext_addr : [in] pointer to extended address to be removed + * + * @retval RAL_ERROR_NONE if removed successfully + */ +ral_error_enum_t ral_clr_src_match_ext(ral_instance_t ral_instance, const uint8_t * ptr_ext_addr); + +/** + * @brief Remove all short addresses from the source address match table + * + * @param ral_instance : [in] used ral instance + * + * @retval void + */ +void ral_clr_all_src_match_short(ral_instance_t ral_instance); + +/** + * @brief Remove all extended addresses from the source address match table + * + * @param ral_instance : [in] used ral instance + * + * @retval void + */ +void ral_clr_all_src_match_ext(ral_instance_t ral_instance); +/** + * @} + */ +/* Energy Detect API ----------------------------------------------------------------------------------- */ +/** @ingroup ral_intf_ed +* @{ +*/ +/** + * + * @brief This function is used to terminate the ED + + * @retval None + * + */ +void ral_reset_ed(void); +/** + * @brief start energy detection scan on specific channel, + * ral_ed_scan_done callback is called to notify upper layer that the energy scan is complete. + * + * @param ral_instance : [in] ral instance + * @param scan_channel : [in] The channel to perform the energy scan on + * @param scan_duration : [in] scan duration in microsecond + * @param ptr_coex_info : [in] pointer to current coexistence parameters + * + * @retval RAL_ERROR_NONE if energy detection scanning started successfully + * + * @note: ral_ed_scan_done won't be called unless emngr_handle_all_events() is called to call ral_sm_done_cbk which will call ral_ed_scan_done + */ +ral_error_enum_t ral_ed_scan(ral_instance_t ral_instance, uint8_t scan_channel, uint32_t scan_duration, + ral_coex_info_st * ptr_coex_info); +/** + * @} + */ +#if SUPPORT_ZIGBEE_PHY_CERTIFICATION +/** + * @brief get the current LQI of the last received packet + * @param last_rssi : [in] RSSI of the last received packet + * @retval uint8_t. LQI value + */ +uint8_t ral_dtmGetLQIValue(int8_t last_rssi); +#endif /*SUPPORT_ZIGBEE_PHY_CERTIFICATION*/ + +/** + * + * @brief This function is used check whether the ral is about to transmit ack or not + * it will return true only if the state machine dine interrupt is set and the frame header is parsed and it indicates that the ack is requested + * @retval 1: Ack is about to be transmitted + * @retval 0: No Ack is to be transmitted + * + */ +uint8_t ral_is_about_to_transmit_ack(void); +/** + * + * @brief This function is used start the triggering of pre tx sequence from sequence ram as early as possible to save time in case of transmitting ack + + * @retval None + * + */ +void ral_early_perpare_phy_to_tx_ack(void); +/** + * + * @brief This function is the phy driver isr handler in case of mac event , + it is used restore the phy state after triggering of the pre interpact sequence from sequence ram + + * @retval None + * + */ +void ral_handle_phy_driver_isr(void); +#if SUPPORT_RADIO_SECURITY_OT_1_2 +/** + * @brief This function is used to update frame counter sustained in ral instance + * This function is called only in case of radio support OT_RADIO_CAPS_TRANSMIT_SEC + * is called from otPlatRadioSetMacFrameCounter() + * + * @param instance : Ral instance + * @param mac_frm_cntr : frame counter passed by upper layers + * + * @retval None + */ +void ral_update_mac_frm_cntr(ral_instance_t instance, uint32_t mac_frm_cntr); +/** + * @brief This function is used to update frame counter sustained in ral instance only if the new value larger than the old one + * This function is called only in case of radio support OT_RADIO_CAPS_TRANSMIT_SEC + * is called from otPlatRadioSetMacFrameCounterIfLarger() + * + * @param instance : Ral instance + * @param mac_frm_cntr : frame counter passed by upper layers + * + * @retval None + */ +void ral_update_larger_mac_frm_cntr(ral_instance_t instance, uint32_t mac_frm_cntr); +/** + * @brief This function is used to update keys and keyId sustained in ral instance + * This function is called only in case of radio support OT_RADIO_CAPS_TRANSMIT_SEC + * is called from otPlatRadioSetMacKey() + * + * @param instance : Ral instance + * @param aKeyId : Key index is used for comparison in case of keyId mode '1' + * To select between different keys. + * ------------ + * for example: + * ------------ + * if keyId (key index) equivalent to the received in MHR + * Then the used key is the current key. + * + * But if it isn't equivalent due to any connected neighbor's key index + * mismatch the key generator in upper layers shall be notified to take action + * based on the relation between the different key index + * + * ------------ + * for example: + * ----------- + * if keyId (key index) less than the received in MHR. this means that the + * communicating device has already generate a new key and started to rotate keys. + * so the next key is the key that shall be used in this situation. + * + * This kind of process synchronization beside another timing triggered events for + * new key generation and rotation allows a difference of only one between keyIds. + * + * see thread specification under security section subsection of "Key Rotation" + * + * @param aPrevKey : key used in case of keyid of received MHR less than the keyid sustained by ral_instance by one. + * @param aCurrKey : key used in case of keyid of received MHR equivalent to the keyid sustained by ral_instance. + * @param aNextKey : key used in case of keyid of received MHR greater than the keyid sustained by ral_instance by one. + * + * @retval None + */ +void ral_update_mac_keys( ral_instance_t instance, + uint8_t aKeyId, + const uint8_t *aPrevKey, + const uint8_t *aCurrKey, + const uint8_t *aNextKey ); +/** + * @brief This function is used to get the current key of an instance + * This function is called only in case of radio support OT_RADIO_CAPS_TRANSMIT_SEC + * + * @param instance : Ral instance + * + * @retval uint8_t* : pointer to the current key + */ +const otMacKeyMaterial * ral_get_inst_curr_key(ral_instance_t ral_instance); +/** + * @brief This function is used to get the previous key of an instance + * This function is called only in case of radio support OT_RADIO_CAPS_TRANSMIT_SEC + * + * @param instance : Ral instance + * + * @retval uint8_t* : pointer to the previous key sustained by ral layer + */ +uint8_t * ral_get_inst_prev_key(ral_instance_t ral_instance); +/** + * @brief This function is used to get the frame counter of an instance + * This function is called only in case of radio support OT_RADIO_CAPS_TRANSMIT_SEC + * + * @param instance : Ral instance + * + * @retval uint32_t : frame counter value sustained by ral layer + */ +uint32_t ral_get_inst_frm_cntr(ral_instance_t ral_instance); +/** + * @brief This function is used to get the key index of an instance + * This function is called only in case of radio support OT_RADIO_CAPS_TRANSMIT_SEC + * + * @param instance : Ral instance + * + * @retval uint8_t : key index sustained by ral layer + */ +uint8_t ral_get_inst_keyId(ral_instance_t ral_instance); + +#endif /*SUPPORT_RADIO_SECURITY_OT_1_2*/ +#if SUPPORT_ENH_ACK_LINK_METRICS_PROBING_OT_1_2 +/** + * @brief This function is used to configure [remove / add / modify] initiator device. + * + * @param short_addr :[in] mac_address_st carries address and adress mode for initiator + * @param ptr_ext_addr :[in] pointer to the matching node + * @param link_metrics :[in] pointer to the matching node + * + * @retval ral_error_enum_t : status + * RAL_ERROR_NONE : successfully configured. + * RAL_ERROR_LINK_METRICS_INVALID_ARGS : in case of ptr_ext_addr NULL. + * RAL_ERROR_LINK_METRICS_NOT_FOUND : in case of remove non-existing node. + * RAL_ERROR_LINK_METRICS_NO_BUF : in case of not enough supported nodes. + */ +ral_error_enum_t ral_config_enh_ack_probing(uint16_t short_addr, const uint8_t * ptr_ext_addr, void* link_metrics); +/** + * This method set the Link Metrics noise floor value needed to calculate the link margine + * + * @param[in] noise_floor The noise floor used by Link Metrics. It should be set to the platform's + * noise floor (measured noise floor, receiver sensitivity or a constant). + * + */ +void ral_link_metrics_set_noise_floor(int8_t noise_floor); +#endif /*SUPPORT_ENH_ACK_LINK_METRICS_PROBING_OT_1_2*/ +/** + * @brief set the value of the openthread base time. this value will be subtracted from all timing values sent / received to openthread + * @param [in] : base time value + * @retval None + */ + +void ral_set_ot_base_slp_time_value(uint32_t time); +/** + * @brief get the value of the openthread base time, the value nay be set through @ref ral_set_ot_base_slp_time_value + * @param None + * @retval uint64_t. base time value + */ + +uint64_t ral_get_ot_base_slp_time_value(void); +/** + * @brief Convert the value of sleep timer to openthread time + * @param time [in] : sleep timer value to be converted to openthread time + * @note if openthread is not integrated, @ref ral_ot_base_slp_time is set to zero, no conversion will take place + * @retval uint64_t. the converted time value + */ + +uint64_t ral_cnvert_slp_tim_to_ot_tim(uint32_t time); +/** + * @brief Convert the value of openthread time to sleep timer value + * @param time [in] : openthread time value to be converted to sleep timer + * @note if openthread is not integrated, @ref ral_ot_base_slp_time is set to zero, no conversion will take place + * @retval uint32_t. the converted time value + */ + +uint32_t ral_cnvert_ot_tim_to_slp_tim(uint64_t time); + +#if SUPPORT_OPENTHREAD_1_2 +/** + * @brief Convert the microsecond time to the proper value the should be set for teh sleep timer to start the event + * @param curr_time [in] : current sleep timer value to be converted to openthread time + * @param base_time [in] : base time in microsecond to be be converted + * @param delay_time [in] : microsecond delay from the base time + * @retval uint32_t. the converted sleep timer set point to be used in setting active timer + */ +uint32_t ral_cnvrt_req_time_to_set_point(uint32_t curr_time, uint32_t base_tim , uint32_t delay_time); +#if CONFIG_MAC_CSL_RECEIVER_ENABLE +/** + * @brief set CSL receiver parameters to enable/ Disable CSL. + * + * @param ral_instance : [in] ral instance + * @param cslPeriod : [in] CSL period to be included in CSL header IE or , 0 to disable CSL + * @param csl_short_addr : [in] The short source address of CSL receiver's peer. + * @param ptr_csl_ext_addr : [in] pointer to the parent extended address + * + * @retval None + * + */ +void ral_set_csl_rcv_param(ral_instance_t ral_instance, uint32_t cslPeriod ,uint16_t csl_short_addr, uint8_t* ptr_csl_ext_addr); +/** + * @brief set CSL receiver next sample time to be used in calculating phase. the sample time points to the time of he next sample window + * + * @param ral_instance : [in] ral instance + * @param cslSampleTime : [in] the lsb part of sample time in us + * + * @retval None + * + */ +void ral_set_csl_sample_time(ral_instance_t ral_instance, uint32_t cslSampleTime); +/** + * @brief check whether the RAL is receiving within the CSL sample window + * + * @param None + * + * @retval uint8_t TRUE 1 if the receiving in CSL window + * @retval uint8_t FALSE 0 if not receiving in CSL windoe + * + */ +uint8_t ral_is_rcv_in_csl_smple_wndw(void); +/** + * @brief check and add CSL header ie to any outgoing frame if csl receiver is enabled. + * + * @param ral_instance : [in] ral instance + * @param frame_ptr : [in] pointer the frame to be transmitted , either enhanced ack or any other frame. + * @param ie_index : [in,out] index of there first byte of CSL header IE. if the CSL header IE will be included , It will be incremented with the length of csl header ie + * @param data_ptr : [in] data pointer it point to the parent address in case of enhanced ack , and frame total length for TX frames + * @param enh_ack_flag : [in] flag to indicate whether enhanced ack or new Tx Frame + * @param addr_mode : [in] if enhanced ack then indicate the parent address is short or extendded + * + * @retval None + * + */ +void ral_hndl_csl_hdr_ie(ral_instance_t ral_instance, uint8_t *frame_ptr,uint8_t *ie_index, uint8_t * data_ptr , uint8_t enh_ack_flag, uint8_t addr_mode); +#endif /*CONFIG_MAC_CSL_RECEIVER_ENABLE*/ +#endif /* SUPPORT_OPENTHREAD_1_2 */ +/** + * @brief Set the CCA Energy Detection threshold in phy + * + * @param threshold : the CCA Energy Detection threshold value to be set + * + * @retval OT_ERROR_NONE if the the threshold is successfully set + * @retval OT_ERROR_FAILED if the given value is out of range + * + */ +otError ral_set_cca_ed_threshold(int8_t threshold); +/** + * @brief Get the CCA Energy Detection threshold in phy + * + * @param None. + * + * @retval int8_t CCA Energy Detection threshold value + * + */ +int8_t ral_get_cca_ed_threshold(void); +#if (SUPPORT_COEXISTENCE) +/** + * @brief radio csma error callback. + * + * @param tx_error : [in] status error returned from this transmission + * + * @retval None + * + */ +void radio_coex_tx_error_cbk(uint32_t error); +#endif /*end of (SUPPORT_COEXISTENCE)*/ +#if (RADIO_CSMA) &&(!SUPPORT_COEXISTENCE) +/** + * @brief set maximum time to start csma + * + * @param rx_timeout : [in] rx timeout time when there's RX while waiting csma backoff delay to fire (value in slp_tmr) + * @param max_csma_delay : [in] max start time to start csma in slp_tmr + * + * @retval None + * + */ +void ral_set_csma_time( +#if ENHANCED_RX_WHILE_CSMA_BACKOFF_DELAY + ble_time_t rx_timeout, +#endif /*end of ENHANCED_RX_WHILE_CSMA_BACKOFF_DELAY*/ + ble_time_t max_csma_delay); +#endif /*end of (RADIO_CSMA) &&(!SUPPORT_COEXISTENCE)*/ +/** + * @brief flag indication used to handle frame pending bit in ACK of all packets (set to true) or for ACK of data request command only (set to false) + * + * @param hndle_frm_pending_bit_for_acks : [in] TRUE means handle pending frame bit in ACK for all frame types, FALSE means handle frame pending bit in ACK for data request command only + * + * @retval None + * + */ +void ral_set_frm_pend_bit_for_acks(uint8_t hndle_frm_pending_bit_for_acks); + +#if RADIO_CSMA +/** + * + * @brief set csma enable flag + * + * @param csma_en : [in] value for csma enable flag to be set + * + * @retval None . + */ +void radio_set_csma_en(uint8_t csma_en); +/** + * + * @brief get csma enable flag + * + * @param None + * + * @retval uint8_t csma enable flag . + */ +uint8_t radio_get_csma_en(void); +#endif /*end of RADIO_CSMA*/ +/** + * + * @brief set cca enable flag + * + * @param cca_en : [in] value for cca enable flag to be set + * + * @retval None . + */ +void radio_set_cca_en(uint8_t cca_en); +/** + * + * @brief get cca enable flag + * + * @param None + * + * @retval uint8_t cca enable flag . + */ +uint8_t radio_get_cca_en(void); +/** + * + * @brief set pending TX retry flags + * + * @param evnt_type : [in] type of new retry (CONTINUE_CSMA_RETRY , START_NEW_FULL_TX_RETRY) + * @param radio_error : [in] error returned from previous TX trial + * + * @retval None . + */ +void radio_set_tx_retry_pending(tx_new_retry_enum_t evnt_type, otError radio_error); +/** + * + * @brief handle pending tx retry event + * + * @param None + * + * @retval None . + */ +void radio_handle_pnding_tx_retry_event(void); +/** + * + * @brief check if there's pending TX retry waiting to be executed + * + * @param None + * + * @retval uint8_t value of pending_tx_retry_flag . + */ +uint8_t radio_is_tx_retry_event_pending(void); +/** + * + * @brief Set MAC implicit boradcast PIB from MAC layer to be used in filteration + * + * @param ImplicitBroadcast: [in] Value for MAC implicit boradcast PIB to be set + * + * @retval None . + */ +void radio_set_implicitbroadcast(uint8_t ImplicitBroadcast); +/** + * + * @brief Set MAC implicit boradcast PIB from radio layer to be used in filteration + * + * @param ImplicitBroadcast: [in] Value for MAC implicit boradcast PIB to be set + * + * @retval None . + */ +void ral_set_implicitbroadcast(ral_instance_t ral_instance, uint8_t ImplicitBroadcast); +/** + * @fn ed_timer_hndl + * + * @brief energy detection timer event handle + * + * @param ptr_info : [in] pointer to current ral context + * + * @retval void + */ +void ed_timer_hndl(void* ptr_info); + +#if SUPPORT_MAC_PHY_CONT_TESTING_CMDS +/** + * + * @brief set the phy continuous modulation and continuous wave modes + * upon enable, if the selected mode is already enabled and likewise + * in disabling, the change will take no effect + * + * @param ral_instance : [in] ral instance + * + * @param type[in] : the type of the modulation (0: modulation, 1: wave) + * + * @param enable_mode[in] : if true then enable the selected mode otherwise disable it + * + * @param chnl_num[in] : channel number to be used in modulation (range: 0 to 15) + * + * @param tx_pwr[in] : The used power in dBm. + * + * @retval Status + */ +void ral_phy_set_zigbee_phy_cont_test_mode(ral_instance_t instance, uint8_t type, uint8_t enable_mode, uint8_t chnl_num, int8_t tx_pwr); +#endif /*end of SUPPORT_MAC_PHY_CONT_TESTING_CMDS */ + +#if SUPPORT_A_MAC +/** + * + * @fn ral_get_a_mac_params + * + * @brief get parameters used in augmented MAC (IFS, phy_rate, auto_ACK_config) + * + * @param ral_instance : [in] ral instance + * + * @param a_mac_params : [out] current augmented MAC parameters + * + * @retval Status + */ +ral_error_enum_t ral_get_a_mac_params(ral_instance_t ral_instance,ral_a_mac_params_st* a_mac_params); +#endif /*SUPPORT_A_MAC*/ + +#endif /* INCLUDE_RAL_H_ */ +/** + * @} + */ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/rfd_dev_config.h b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/rfd_dev_config.h new file mode 100644 index 000000000..e91073abc --- /dev/null +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_cmd_lib/inc/rfd_dev_config.h @@ -0,0 +1,54 @@ +/*$Id: //dwh/bluetooth/DWC_ble154combo/firmware/rel/2.00a-lca01/firmware/public_inc/rfd_dev_config.h#1 $*/ +/** + ******************************************************************************** + * @file rfd_dev_config.h + * @brief Configurations for reduced function device and full function device + * + * + ****************************************************************************** + * @copy + * Synopsys MIT License: + * Copyright (c) 2020-Present Synopsys, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of the software and + * associated documentation files (the “Software”), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial + * portions of the Software. + * + * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE + * ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * */ + + +#ifndef MAC_CONTROLLER_INC_RFD_DEV_CONFIG_H_ +#define MAC_CONTROLLER_INC_RFD_DEV_CONFIG_H_ + +#include "ll_fw_config.h" + + +#if (!FFD_DEVICE_CONFIG) /* RFD Device Configuration */ + +#define RFD_SUPPORT_ACTIVE_SCAN 1 /* Enable\Disable :RFD supports Active Scanning Enable:1 - Disable:0 */ +#define RFD_SUPPORT_ENERGY_DETECT 1 /* Enable\Disable :RFD supports Energy Detection Enable:1 - Disable:0 */ +#define RFD_SUPPORT_DATA_PURGE 0 /* Enable\Disable :RFD supports Data Purge Primitive Enable:1 - Disable:0 */ +#define RFD_SUPPORT_ASSOCIATION_IND_RSP 0 /* Enable\Disable :RFD supports Association Indication and Response Primitives Enable:1 - Disable:0 */ +#define RFD_SUPPORT_ORPHAN_IND_RSP 1 /* Enable\Disable :RFD supports Orphan Indication and Response Primitives Enable:1 - Disable:0 */ +#define RFD_SUPPORT_START_PRIM 1 /* Enable\Disable :RFD supports Start Primitive Enable:1 - Disable:0 */ +#define RFD_SUPPORT_PROMISCUOUS_MODE 1 /* Enable\Disable :RFD supports Promiscuous Mode Enable:1 - Disable:0 */ +#define RFD_SUPPORT_SEND_BEACON 1 /* Enable\Disable :RFD supports Sending Beacons if Coordinator Enable:1 - Disable:0 */ +#define RFD_SUPPORT_PANID_CONFLICT_RSLN 1 /* Enable\Disable :RFD supports Pan Id conflict detection and resolution Enable:1 - Disable:0 */ + +#endif + + +#endif /* MAC_CONTROLLER_INC_RFD_DEV_CONFIG_H_ */ diff --git a/lib/stm32wba/STM32_WPAN/link_layer/ll_sys/src/ll_sys_startup.c b/lib/stm32wba/STM32_WPAN/link_layer/ll_sys/src/ll_sys_startup.c index 4c8f071dc..09828ba5a 100644 --- a/lib/stm32wba/STM32_WPAN/link_layer/ll_sys/src/ll_sys_startup.c +++ b/lib/stm32wba/STM32_WPAN/link_layer/ll_sys/src/ll_sys_startup.c @@ -21,11 +21,12 @@ #include "ll_intf.h" #include "ll_sys_startup.h" #include "common_types.h" +#if defined(CONFIG_NET_L2_CUSTOM_IEEE802154_STM32WBA) #if defined(MAC) && (SUPPORT_OPENTHREAD_1_2 == 0) /* Projects with MAC Layer (i.e. 15.4 except Thread) */ #include "st_mac_802_15_4_sap.h" #endif /* MAC */ - +#endif /* CONFIG_NET_L2_CUSTOM_IEEE802154_STM32WBA */ /** * @brief Missed HCI event flag */ @@ -58,6 +59,7 @@ void ll_sys_ble_cntrl_init(hst_cbk hostCallback) ll_sys_dependencies_init(); } #endif /* BLE */ +#if defined(CONFIG_NET_L2_CUSTOM_IEEE802154_STM32WBA) #if defined(MAC) && (SUPPORT_OPENTHREAD_1_2 == 0) /** * @brief Initialize the Link Layer IP 802.15.4 MAC controller @@ -70,7 +72,7 @@ void ll_sys_mac_cntrl_init(void) ll_sys_dependencies_init(); } #endif /* MAC */ - +#endif /* CONFIG_NET_L2_CUSTOM_IEEE802154_STM32WBA */ /** * @brief Start the Link Layer IP in OpenThread configuration * @param None diff --git a/lib/stm32wba/ble/CMakeLists.txt b/lib/stm32wba/ble/CMakeLists.txt new file mode 100644 index 000000000..511b14e4e --- /dev/null +++ b/lib/stm32wba/ble/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) 2025 STMicroelectronics +# +# SPDX-License-Identifier: Apache-2.0 +zephyr_include_directories(Core/Inc) +zephyr_include_directories(STM32_WPAN/Target) +zephyr_include_directories(System/Config/Debug_GPIO) +zephyr_include_directories(System/Config/Log) +zephyr_sources(STM32_WPAN/Target/bpka.c) +zephyr_sources(STM32_WPAN/Target/linklayer_plat.c) +zephyr_sources(STM32_WPAN/Target/ll_sys_if.c) +zephyr_sources(STM32_WPAN/Target/power_table.c) \ No newline at end of file diff --git a/lib/stm32wba/BLE_TransparentMode/Core/Inc/app_common.h b/lib/stm32wba/ble/Core/Inc/app_common.h similarity index 100% rename from lib/stm32wba/BLE_TransparentMode/Core/Inc/app_common.h rename to lib/stm32wba/ble/Core/Inc/app_common.h diff --git a/lib/stm32wba/BLE_TransparentMode/Core/Inc/app_conf.h b/lib/stm32wba/ble/Core/Inc/app_conf.h similarity index 100% rename from lib/stm32wba/BLE_TransparentMode/Core/Inc/app_conf.h rename to lib/stm32wba/ble/Core/Inc/app_conf.h diff --git a/lib/stm32wba/BLE_TransparentMode/Core/Inc/main.h b/lib/stm32wba/ble/Core/Inc/main.h similarity index 100% rename from lib/stm32wba/BLE_TransparentMode/Core/Inc/main.h rename to lib/stm32wba/ble/Core/Inc/main.h diff --git a/lib/stm32wba/BLE_TransparentMode/Core/Inc/utilities_conf.h b/lib/stm32wba/ble/Core/Inc/utilities_conf.h similarity index 100% rename from lib/stm32wba/BLE_TransparentMode/Core/Inc/utilities_conf.h rename to lib/stm32wba/ble/Core/Inc/utilities_conf.h diff --git a/lib/stm32wba/BLE_TransparentMode/STM32_WPAN/Target/bpka.c b/lib/stm32wba/ble/STM32_WPAN/Target/bpka.c similarity index 100% rename from lib/stm32wba/BLE_TransparentMode/STM32_WPAN/Target/bpka.c rename to lib/stm32wba/ble/STM32_WPAN/Target/bpka.c diff --git a/lib/stm32wba/BLE_TransparentMode/STM32_WPAN/Target/bpka.h b/lib/stm32wba/ble/STM32_WPAN/Target/bpka.h similarity index 100% rename from lib/stm32wba/BLE_TransparentMode/STM32_WPAN/Target/bpka.h rename to lib/stm32wba/ble/STM32_WPAN/Target/bpka.h diff --git a/lib/stm32wba/BLE_TransparentMode/STM32_WPAN/Target/linklayer_plat.c b/lib/stm32wba/ble/STM32_WPAN/Target/linklayer_plat.c similarity index 100% rename from lib/stm32wba/BLE_TransparentMode/STM32_WPAN/Target/linklayer_plat.c rename to lib/stm32wba/ble/STM32_WPAN/Target/linklayer_plat.c diff --git a/lib/stm32wba/BLE_TransparentMode/STM32_WPAN/Target/ll_sys_if.c b/lib/stm32wba/ble/STM32_WPAN/Target/ll_sys_if.c similarity index 100% rename from lib/stm32wba/BLE_TransparentMode/STM32_WPAN/Target/ll_sys_if.c rename to lib/stm32wba/ble/STM32_WPAN/Target/ll_sys_if.c diff --git a/lib/stm32wba/BLE_TransparentMode/STM32_WPAN/Target/ll_sys_if.h b/lib/stm32wba/ble/STM32_WPAN/Target/ll_sys_if.h similarity index 100% rename from lib/stm32wba/BLE_TransparentMode/STM32_WPAN/Target/ll_sys_if.h rename to lib/stm32wba/ble/STM32_WPAN/Target/ll_sys_if.h diff --git a/lib/stm32wba/BLE_TransparentMode/STM32_WPAN/Target/power_table.c b/lib/stm32wba/ble/STM32_WPAN/Target/power_table.c similarity index 100% rename from lib/stm32wba/BLE_TransparentMode/STM32_WPAN/Target/power_table.c rename to lib/stm32wba/ble/STM32_WPAN/Target/power_table.c diff --git a/lib/stm32wba/ble/System/Config/Debug_GPIO/debug_config.h b/lib/stm32wba/ble/System/Config/Debug_GPIO/debug_config.h new file mode 100644 index 000000000..e8a83448c --- /dev/null +++ b/lib/stm32wba/ble/System/Config/Debug_GPIO/debug_config.h @@ -0,0 +1,801 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file debug_config.h + * @author MCD Application Team + * @brief Real Time Debug module general configuration file + ****************************************************************************** + * @attention + * + * Copyright (c) 2023 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ +#ifndef DEBUG_CONFIG_H +#define DEBUG_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "app_conf.h" + +#if(CFG_RT_DEBUG_GPIO_MODULE == 1) + +/***********************************/ +/** Debug configuration selection **/ +/***********************************/ +/* Debug configuration for System purpose */ +#define USE_RT_DEBUG_CONFIGURATION_SYSTEM (0) + +/* Debug configuration for BLE purpose */ +#define USE_RT_DEBUG_CONFIGURATION_BLE (0) + +/* Debug configuration for MAC purpose */ +#define USE_RT_DEBUG_CONFIGURATION_MAC (0) + +/* Debug configuration for COEX purpose */ +#define USE_RT_DEBUG_CONFIGURATION_COEX (0) + +/*********************************/ +/** GPIO debug signal selection **/ +/*********************************/ + +/* System clock manager - System clock config */ +#define USE_RT_DEBUG_SCM_SYSTEM_CLOCK_CONFIG (0) +#define GPIO_DEBUG_SCM_SYSTEM_CLOCK_CONFIG {GPIOA, GPIO_PIN_12} + +/* System clock manager - Setup */ +#define USE_RT_DEBUG_SCM_SETUP (0) +#define GPIO_DEBUG_SCM_SETUP {GPIOA, GPIO_PIN_5} + +/* System clock manager - HSE RDY interrupt handling */ +#define USE_RT_DEBUG_SCM_HSERDY_ISR (0) +#define GPIO_DEBUG_SCM_HSERDY_ISR {GPIOA, GPIO_PIN_15} + +#define USE_RT_DEBUG_ADC_ACTIVATION (0) +#define GPIO_DEBUG_ADC_ACTIVATION {GPIOB, GPIO_PIN_4} + +#define USE_RT_DEBUG_ADC_DEACTIVATION (0) +#define GPIO_DEBUG_ADC_DEACTIVATION {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADC_TEMPERATURE_ACQUISITION (0) +#define GPIO_DEBUG_ADC_TEMPERATURE_ACQUISITION {GPIOB, GPIO_PIN_8} + +#define USE_RT_DEBUG_RNG_ENABLE (0) +#define GPIO_DEBUG_RNG_ENABLE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RNG_DISABLE (0) +#define GPIO_DEBUG_RNG_DISABLE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RNG_GEN_RAND_NUM (0) +#define GPIO_DEBUG_RNG_GEN_RAND_NUM {GPIOB, GPIO_PIN_12} + +#define USE_RT_DEBUG_LOW_POWER_STOP_MODE_ENTER (0) +#define GPIO_DEBUG_LOW_POWER_STOP_MODE_ENTER {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LOW_POWER_STOP_MODE_EXIT (0) +#define GPIO_DEBUG_LOW_POWER_STOP_MODE_EXIT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LOW_POWER_STOP_MODE_ACTIVE (0) +#define GPIO_DEBUG_LOW_POWER_STOP_MODE_ACTIVE {GPIOB, GPIO_PIN_3} + +#define USE_RT_DEBUG_LOW_POWER_STOP2_MODE_ENTER (0) +#define GPIO_DEBUG_LOW_POWER_STOP2_MODE_ENTER {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LOW_POWER_STOP2_MODE_EXIT (0) +#define GPIO_DEBUG_LOW_POWER_STOP2_MODE_EXIT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LOW_POWER_STOP2_MODE_ACTIVE (0) +#define GPIO_DEBUG_LOW_POWER_STOP2_MODE_ACTIVE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_ENTER (0) +#define GPIO_DEBUG_LOW_POWER_STANDBY_MODE_ENTER {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_EXIT (0) +#define GPIO_DEBUG_LOW_POWER_STANDBY_MODE_EXIT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_ACTIVE (0) +#define GPIO_DEBUG_LOW_POWER_STANDBY_MODE_ACTIVE {GPIOB, GPIO_PIN_15} + +#define USE_RT_DEBUG_HCI_READ_DONE (0) +#define GPIO_DEBUG_HCI_READ_DONE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_HCI_RCVD_CMD (0) +#define GPIO_DEBUG_HCI_RCVD_CMD {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_HCI_WRITE_DONE (0) +#define GPIO_DEBUG_HCI_WRITE_DONE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_SCHDLR_EVNT_UPDATE (0) +#define GPIO_DEBUG_SCHDLR_EVNT_UPDATE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_SCHDLR_TIMER_SET (0) +#define GPIO_DEBUG_SCHDLR_TIMER_SET {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_SCHDLR_PHY_CLBR_TIMER (0) +#define GPIO_DEBUG_SCHDLR_PHY_CLBR_TIMER {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_SCHDLR_EVNT_SKIPPED (0) +#define GPIO_DEBUG_SCHDLR_EVNT_SKIPPED {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_SCHDLR_HNDL_NXT_TRACE (0) +#define GPIO_DEBUG_SCHDLR_HNDL_NXT_TRACE {GPIOA, GPIO_PIN_12} + +#define USE_RT_DEBUG_ACTIVE_SCHDLR_NEAR_DETEDTED (0) +#define GPIO_DEBUG_ACTIVE_SCHDLR_NEAR_DETEDTED {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ACTIVE_SCHDLR_NEAR_GAP_CHECK (0) +#define GPIO_DEBUG_ACTIVE_SCHDLR_NEAR_GAP_CHECK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ACTIVE_SCHDLR_NEAR_TIME_CHECK (0) +#define GPIO_DEBUG_ACTIVE_SCHDLR_NEAR_TIME_CHECK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ACTIVE_SCHDLR_NEAR_TRACE (0) +#define GPIO_DEBUG_ACTIVE_SCHDLR_NEAR_TRACE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_SCHDLR_EVNT_RGSTR (0) +#define GPIO_DEBUG_SCHDLR_EVNT_RGSTR {GPIOB, GPIO_PIN_8} + +#define USE_RT_DEBUG_SCHDLR_ADD_CONFLICT_Q (0) +#define GPIO_DEBUG_SCHDLR_ADD_CONFLICT_Q {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_SCHDLR_HNDL_MISSED_EVNT (0) +#define GPIO_DEBUG_SCHDLR_HNDL_MISSED_EVNT {GPIOA, GPIO_PIN_5} + +#define USE_RT_DEBUG_SCHDLR_UNRGSTR_EVNT (0) +#define GPIO_DEBUG_SCHDLR_UNRGSTR_EVNT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_SCHDLR_EXEC_EVNT_TRACE (0) +#define GPIO_DEBUG_SCHDLR_EXEC_EVNT_TRACE {GPIOA, GPIO_PIN_15} + +#define USE_RT_DEBUG_SCHDLR_EXEC_EVNT_PROFILE (0) +#define GPIO_DEBUG_SCHDLR_EXEC_EVNT_PROFILE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_SCHDLR_EXEC_EVNT_ERROR (0) +#define GPIO_DEBUG_SCHDLR_EXEC_EVNT_ERROR {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_SCHDLR_EXEC_EVNT_WINDOW_WIDENING (0) +#define GPIO_DEBUG_SCHDLR_EXEC_EVNT_WINDOW_WIDENING {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_CMN_CLR_ISR (0) +#define GPIO_DEBUG_LLHWC_CMN_CLR_ISR {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLWCC_CMN_HG_ISR (0) +#define GPIO_DEBUG_LLWCC_CMN_HG_ISR {GPIOA, GPIO_PIN_15} + +#define USE_RT_DEBUG_LLHWC_CMN_LW_ISR (0) +#define GPIO_DEBUG_LLHWC_CMN_LW_ISR {GPIOA, GPIO_PIN_12} + +#define USE_RT_DEBUG_LLHWC_CMN_CLR_TIMER_ERROR (0) +#define GPIO_DEBUG_LLHWC_CMN_CLR_TIMER_ERROR {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_LL_ISR (0) +#define GPIO_DEBUG_LLHWC_LL_ISR {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_SPLTMR_SET (0) +#define GPIO_DEBUG_LLHWC_SPLTMR_SET {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_SPLTMR_GET (0) +#define GPIO_DEBUG_LLHWC_SPLTMR_GET {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_LOW_ISR (0) +#define GPIO_DEBUG_LLHWC_LOW_ISR {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_STOP_SCN (0) +#define GPIO_DEBUG_LLHWC_STOP_SCN {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_WAIT_ENVT_ON_AIR (0) +#define GPIO_DEBUG_LLHWC_WAIT_ENVT_ON_AIR {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_SET_CONN_EVNT_PARAM (0) +#define GPIO_DEBUG_LLHWC_SET_CONN_EVNT_PARAM {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_POST_EVNT (0) +#define GPIO_DEBUG_POST_EVNT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_HNDL_ALL_EVNTS (0) +#define GPIO_DEBUG_HNDL_ALL_EVNTS {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PROCESS_EVNT (0) +#define GPIO_DEBUG_PROCESS_EVNT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PROCESS_ISO_DATA (0) +#define GPIO_DEBUG_PROCESS_ISO_DATA {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ALLOC_TX_ISO_EMPTY_PKT (0) +#define GPIO_DEBUG_ALLOC_TX_ISO_EMPTY_PKT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_BIG_FREE_EMPTY_PKTS (0) +#define GPIO_DEBUG_BIG_FREE_EMPTY_PKTS {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RECOMBINE_UNFRMD_DATA_OK (0) +#define GPIO_DEBUG_RECOMBINE_UNFRMD_DATA_OK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RECOMBINE_UNFRMD_DATA_CRC (0) +#define GPIO_DEBUG_RECOMBINE_UNFRMD_DATA_CRC {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RECOMBINE_UNFRMD_DATA_NoRX (0) +#define GPIO_DEBUG_RECOMBINE_UNFRMD_DATA_NoRX {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RECOMBINE_UNFRMD_DATA_TRACE (0) +#define GPIO_DEBUG_RECOMBINE_UNFRMD_DATA_TRACE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ISO_HNDL_SDU (0) +#define GPIO_DEBUG_ISO_HNDL_SDU {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LL_INTF_INIT (0) +#define GPIO_DEBUG_LL_INTF_INIT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_DATA_TO_CNTRLR (0) +#define GPIO_DEBUG_DATA_TO_CNTRLR {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_FREE_LL_PKT_HNDLR (0) +#define GPIO_DEBUG_FREE_LL_PKT_HNDLR {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PHY_INIT_CLBR_TRACE (0) +#define GPIO_DEBUG_PHY_INIT_CLBR_TRACE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PHY_RUNTIME_CLBR_TRACE (0) +#define GPIO_DEBUG_PHY_RUNTIME_CLBR_TRACE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PHY_CLBR_ISR (0) +#define GPIO_DEBUG_PHY_CLBR_ISR {GPIOB, GPIO_PIN_3} + +#define USE_RT_DEBUG_PHY_INIT_CLBR_SINGLE_CH (0) +#define GPIO_DEBUG_PHY_INIT_CLBR_SINGLE_CH {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PHY_CLBR_STRTD (0) +#define GPIO_DEBUG_PHY_CLBR_STRTD {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PHY_CLBR_EXEC (0) +#define GPIO_DEBUG_PHY_CLBR_EXEC {GPIOB, GPIO_PIN_4} + +#define USE_RT_DEBUG_RCO_STRT_STOP_RUNTIME_CLBR_ACTV (0) +#define GPIO_DEBUG_RCO_STRT_STOP_RUNTIME_CLBR_ACTV {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RCO_STRT_STOP_RUNTIME_RCO_CLBR (0) +#define GPIO_DEBUG_RCO_STRT_STOP_RUNTIME_RCO_CLBR {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_STRT_STOP_RUNTIME_RCO_CLBR_SWT (0) +#define GPIO_DEBUG_STRT_STOP_RUNTIME_RCO_CLBR_SWT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_STRT_STOP_RUNTIME_RCO_CLBR_TRACE (0) +#define GPIO_DEBUG_STRT_STOP_RUNTIME_RCO_CLBR_TRACE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RCO_ISR_TRACE (0) +#define GPIO_DEBUG_RCO_ISR_TRACE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RCO_ISR_COMPENDATE (0) +#define GPIO_DEBUG_RCO_ISR_COMPENDATE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RAL_STRT_TX (0) +#define GPIO_DEBUG_RAL_STRT_TX {GPIOA, GPIO_PIN_5} + +#define USE_RT_DEBUG_RAL_ISR_TIMER_ERROR (0) +#define GPIO_DEBUG_RAL_ISR_TIMER_ERROR {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RAL_ISR_TRACE (0) +#define GPIO_DEBUG_RAL_ISR_TRACE {GPIOB, GPIO_PIN_3} + +#define USE_RT_DEBUG_RAL_STOP_OPRTN (0) +#define GPIO_DEBUG_RAL_STOP_OPRTN {GPIOB, GPIO_PIN_8} + +#define USE_RT_DEBUG_RAL_STRT_RX (0) +#define GPIO_DEBUG_RAL_STRT_RX {GPIOB, GPIO_PIN_12} + +#define USE_RT_DEBUG_RAL_DONE_CLBK_TX (0) +#define GPIO_DEBUG_RAL_DONE_CLBK_TX {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RAL_DONE_CLBK_RX (0) +#define GPIO_DEBUG_RAL_DONE_CLBK_RX {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RAL_DONE_CLBK_ED (0) +#define GPIO_DEBUG_RAL_DONE_CLBK_ED {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RAL_ED_SCAN (0) +#define GPIO_DEBUG_RAL_ED_SCAN {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ERROR_MEM_CAP_EXCED (0) +#define GPIO_DEBUG_ERROR_MEM_CAP_EXCED {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ERROR_COMMAND_DISALLOWED (0) +#define GPIO_DEBUG_ERROR_COMMAND_DISALLOWED {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PTA_INIT (0) +#define GPIO_DEBUG_PTA_INIT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PTA_EN (0) +#define GPIO_DEBUG_PTA_EN {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_PTA_SET_EN (0) +#define GPIO_DEBUG_LLHWC_PTA_SET_EN {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_PTA_SET_PARAMS (0) +#define GPIO_DEBUG_LLHWC_PTA_SET_PARAMS {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_COEX_STRT_ON_IDLE (0) +#define GPIO_DEBUG_COEX_STRT_ON_IDLE {GPIOB, GPIO_PIN_15} + +#define USE_RT_DEBUG_COEX_ASK_FOR_AIR (0) +#define GPIO_DEBUG_COEX_ASK_FOR_AIR {GPIOB, GPIO_PIN_3} + +#define USE_RT_DEBUG_COEX_TIMER_EVNT_CLBK (0) +#define GPIO_DEBUG_COEX_TIMER_EVNT_CLBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_COEX_STRT_ONE_SHOT (0) +#define GPIO_DEBUG_COEX_STRT_ONE_SHOT {GPIOA, GPIO_PIN_5} + +#define USE_RT_DEBUG_COEX_FORCE_STOP_RX (0) +#define GPIO_DEBUG_COEX_FORCE_STOP_RX {GPIOB, GPIO_PIN_12} + +#define USE_RT_DEBUG_LLHWC_ADV_DONE (0) +#define GPIO_DEBUG_LLHWC_ADV_DONE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_SCN_DONE (0) +#define GPIO_DEBUG_LLHWC_SCN_DONE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_INIT_DONE (0) +#define GPIO_DEBUG_LLHWC_INIT_DONE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_CONN_DONE (0) +#define GPIO_DEBUG_LLHWC_CONN_DONE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_CIG_DONE (0) +#define GPIO_DEBUG_LLHWC_CIG_DONE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_BIG_DONE (0) +#define GPIO_DEBUG_LLHWC_BIG_DONE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_OS_TMR_CREATE (0) +#define GPIO_DEBUG_OS_TMR_CREATE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_TIMEOUT_CBK (0) +#define GPIO_DEBUG_ADV_EXT_TIMEOUT_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_SCN_DUR_CBK (0) +#define GPIO_DEBUG_ADV_EXT_SCN_DUR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_SCN_PERIOD_CBK (0) +#define GPIO_DEBUG_ADV_EXT_SCN_PERIOD_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_PRDC_SCN_TIMEOUT_CBK (0) +#define GPIO_DEBUG_ADV_EXT_PRDC_SCN_TIMEOUT_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_BIS_SYNC_TIMEOUT_TMR_CBK (0) +#define GPIO_DEBUG_BIS_SYNC_TIMEOUT_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_BIS_TERM_TMR_CBK (0) +#define GPIO_DEBUG_BIS_TERM_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_BIS_TST_MODE_CBK (0) +#define GPIO_DEBUG_BIS_TST_MODE_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_BIS_TST_MODE_TMR_CBK (0) +#define GPIO_DEBUG_BIS_TST_MODE_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ISO_POST_TMR_CBK (0) +#define GPIO_DEBUG_ISO_POST_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ISO_TST_MODE_TMR_CBK (0) +#define GPIO_DEBUG_ISO_TST_MODE_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_CONN_POST_TMR_CBK (0) +#define GPIO_DEBUG_CONN_POST_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_EVNT_SCHDLR_TMR_CBK (0) +#define GPIO_DEBUG_EVNT_SCHDLR_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_HCI_POST_TMR_CBK (0) +#define GPIO_DEBUG_HCI_POST_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLCP_POST_TMR_CBK (0) +#define GPIO_DEBUG_LLCP_POST_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_ENRGY_DETECT_CBK (0) +#define GPIO_DEBUG_LLHWC_ENRGY_DETECT_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PRVCY_POST_TMR_CBK (0) +#define GPIO_DEBUG_PRVCY_POST_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ANT_PRPR_TMR_CBK (0) +#define GPIO_DEBUG_ANT_PRPR_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_COEX_TMR_FRC_STOP_AIR_GRANT_CBK (0) +#define GPIO_DEBUG_COEX_TMR_FRC_STOP_AIR_GRANT_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_MLME_RX_EN_TMR_CBK (0) +#define GPIO_DEBUG_MLME_RX_EN_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_MLME_GNRC_TMR_CBK (0) +#define GPIO_DEBUG_MLME_GNRC_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_MIB_JOIN_LST_TMR_CBK (0) +#define GPIO_DEBUG_MIB_JOIN_LST_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_MLME_PWR_PRES_TMR_CBK (0) +#define GPIO_DEBUG_MLME_PWR_PRES_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PRESISTENCE_TMR_CBK (0) +#define GPIO_DEBUG_PRESISTENCE_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RADIO_PHY_PRDC_CLBK_TMR_CBK (0) +#define GPIO_DEBUG_RADIO_PHY_PRDC_CLBK_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RADIO_CSMA_TMR_CBK (0) +#define GPIO_DEBUG_RADIO_CSMA_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RADIO_CSL_RCV_TMR_CBK (0) +#define GPIO_DEBUG_RADIO_CSL_RCV_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ED_TMR_CBK (0) +#define GPIO_DEBUG_ED_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_DIO_EXT_TMR_CBK (0) +#define GPIO_DEBUG_DIO_EXT_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RCO_CLBR_TMR_CBK (0) +#define GPIO_DEBUG_RCO_CLBR_TMR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_MNGR_ADV_CBK (0) +#define GPIO_DEBUG_ADV_EXT_MNGR_ADV_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_MNGR_SCN_CBK (0) +#define GPIO_DEBUG_ADV_EXT_MNGR_SCN_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_MNGR_SCN_ERR_CBK (0) +#define GPIO_DEBUG_ADV_EXT_MNGR_SCN_ERR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_MNGR_PRDC_SCN_CBK (0) +#define GPIO_DEBUG_ADV_EXT_MNGR_PRDC_SCN_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_MNGR_PRDC_SCN_ERR_CBK (0) +#define GPIO_DEBUG_ADV_EXT_MNGR_PRDC_SCN_ERR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_BIG_ADV_CBK (0) +#define GPIO_DEBUG_BIG_ADV_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_BIG_ADV_ERR_CBK (0) +#define GPIO_DEBUG_BIG_ADV_ERR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_BIG_SYNC_CBK (0) +#define GPIO_DEBUG_BIG_SYNC_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_BIG_SYNC_ERR_CBK (0) +#define GPIO_DEBUG_BIG_SYNC_ERR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ISO_CIS_PKT_TRNSM_RECEIVED_CBK (0) +#define GPIO_DEBUG_ISO_CIS_PKT_TRNSM_RECEIVED_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ISO_CIG_ERR_CBK (0) +#define GPIO_DEBUG_ISO_CIG_ERR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_CONN_PKT_TRNSM_RECEIVED_CBK (0) +#define GPIO_DEBUG_CONN_PKT_TRNSM_RECEIVED_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PRDC_CLBR_EXTRL_CBK (0) +#define GPIO_DEBUG_PRDC_CLBR_EXTRL_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PTR_PRDC_ADV_SYNC_CBK (0) +#define GPIO_DEBUG_PTR_PRDC_ADV_SYNC_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_NCONN_SCN_CBK (0) +#define GPIO_DEBUG_NCONN_SCN_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_NCONN_ADV_CBK (0) +#define GPIO_DEBUG_NCONN_ADV_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_NCONN_INIT_CBK (0) +#define GPIO_DEBUG_NCONN_INIT_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ANT_RADIO_CMPLT_EVNT_CBK (0) +#define GPIO_DEBUG_ANT_RADIO_CMPLT_EVNT_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ANT_STACK_EVNT_CBK (0) +#define GPIO_DEBUG_ANT_STACK_EVNT_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_PROCESS_TMOUT_EVNT_CBK (0) +#define GPIO_DEBUG_ADV_EXT_PROCESS_TMOUT_EVNT_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_MNGR_SCN_DUR_EVNT (0) +#define GPIO_DEBUG_ADV_EXT_MNGR_SCN_DUR_EVNT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_MNGR_SCN_PERIODIC_EVNT (0) +#define GPIO_DEBUG_ADV_EXT_MNGR_SCN_PERIODIC_EVNT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_MNGR_PRDC_SCN_TMOUT_EVNT (0) +#define GPIO_DEBUG_ADV_EXT_MNGR_PRDC_SCN_TMOUT_EVNT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ADV_EXT_MNGR_PRDC_SCN_CNCEL_EVNT (0) +#define GPIO_DEBUG_ADV_EXT_MNGR_PRDC_SCN_CNCEL_EVNT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_BIS_MNGR_BIG_TERM_CBK (0) +#define GPIO_DEBUG_BIS_MNGR_BIG_TERM_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_BIS_MNGR_SYNC_TMOUT_CBK (0) +#define GPIO_DEBUG_BIS_MNGR_SYNC_TMOUT_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ISOAL_MNGR_SDU_GEN (0) +#define GPIO_DEBUG_ISOAL_MNGR_SDU_GEN {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_ISO_MNGR_CIS_PROCESS_EVNT_CBK (0) +#define GPIO_DEBUG_ISO_MNGR_CIS_PROCESS_EVNT_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_CONN_MNGR_PROCESS_EVNT_CLBK (0) +#define GPIO_DEBUG_CONN_MNGR_PROCESS_EVNT_CLBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_CONN_MNGR_UPDT_CONN_PARAM_CBK (0) +#define GPIO_DEBUG_CONN_MNGR_UPDT_CONN_PARAM_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_EVNT_SCHDLR_HW_EVNT_CMPLT (0) +#define GPIO_DEBUG_EVNT_SCHDLR_HW_EVNT_CMPLT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_HCI_EVENT_HNDLR (0) +#define GPIO_DEBUG_HCI_EVENT_HNDLR {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_MLME_TMRS_CBK (0) +#define GPIO_DEBUG_MLME_TMRS_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_DIRECT_TX_EVNT_CBK (0) +#define GPIO_DEBUG_DIRECT_TX_EVNT_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_INDIRECT_PKT_TOUR_CBK (0) +#define GPIO_DEBUG_INDIRECT_PKT_TOUR_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RADIO_CSMA_TMR (0) +#define GPIO_DEBUG_RADIO_CSMA_TMR {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RAL_SM_DONE_EVNT_CBK (0) +#define GPIO_DEBUG_RAL_SM_DONE_EVNT_CBK {GPIOB, GPIO_PIN_4} + +#define USE_RT_DEBUG_ED_TMR_HNDL (0) +#define GPIO_DEBUG_ED_TMR_HNDL {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_OS_TMR_EVNT_CBK (0) +#define GPIO_DEBUG_OS_TMR_EVNT_CBK {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PROFILE_MARKER_PHY_WAKEUP_TIME (0) +#define GPIO_DEBUG_PROFILE_MARKER_PHY_WAKEUP_TIME {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PROFILE_END_DRIFT_TIME (0) +#define GPIO_DEBUG_PROFILE_END_DRIFT_TIME {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PROC_RADIO_RCV (0) +#define GPIO_DEBUG_PROC_RADIO_RCV {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_EVNT_TIME_UPDT (0) +#define GPIO_DEBUG_EVNT_TIME_UPDT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_MAC_RECEIVE_DONE (0) +#define GPIO_DEBUG_MAC_RECEIVE_DONE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_MAC_TX_DONE (0) +#define GPIO_DEBUG_MAC_TX_DONE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RADIO_APPLY_CSMA (0) +#define GPIO_DEBUG_RADIO_APPLY_CSMA {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RADIO_TRANSMIT (0) +#define GPIO_DEBUG_RADIO_TRANSMIT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_PROC_RADIO_TX (0) +#define GPIO_DEBUG_PROC_RADIO_TX {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RAL_TX_DONE (0) +#define GPIO_DEBUG_RAL_TX_DONE {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RAL_TX_DONE_INCREMENT_BACKOFF_COUNT (0) +#define GPIO_DEBUG_RAL_TX_DONE_INCREMENT_BACKOFF_COUNT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RAL_TX_DONE_RST_BACKOFF_COUNT (0) +#define GPIO_DEBUG_RAL_TX_DONE_RST_BACKOFF_COUNT {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RAL_CONTINUE_RX (0) +#define GPIO_DEBUG_RAL_CONTINUE_RX {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RAL_PERFORM_CCA (0) +#define GPIO_DEBUG_RAL_PERFORM_CCA {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_RAL_ENABLE_TRANSMITTER (0) +#define GPIO_DEBUG_RAL_ENABLE_TRANSMITTER {GPIOA, GPIO_PIN_0} + +#define USE_RT_DEBUG_LLHWC_GET_CH_IDX_ALGO_2 (0) +#define GPIO_DEBUG_LLHWC_GET_CH_IDX_ALGO_2 {GPIOA, GPIO_PIN_0} + +/* Application signal selection and GPIO assignment. + CAN BE MODIFIED BY USER */ + +#define USE_RT_DEBUG_APP_APPE_INIT (0) +#define GPIO_DEBUG_APP_APPE_INIT {GPIOA, GPIO_PIN_0} + +/********************************/ +/** Debug configuration setup **/ +/*******************************/ + +/* + * + * Debug configuration for System purpose + * + */ +#if (USE_RT_DEBUG_CONFIGURATION_SYSTEM == 1U) +/* SCM_SETUP activation */ +#undef USE_RT_DEBUG_SCM_SETUP +#define USE_RT_DEBUG_SCM_SETUP (1U) + +/* SCM_SYSTEM_CLOCK_CONFIG activation */ +#undef USE_RT_DEBUG_SCM_SYSTEM_CLOCK_CONFIG +#define USE_RT_DEBUG_SCM_SYSTEM_CLOCK_CONFIG (1U) + +/* SCM_HSERDY_ISR activation */ +#undef USE_RT_DEBUG_SCM_HSERDY_ISR +#define USE_RT_DEBUG_SCM_HSERDY_ISR (1U) + +/* LOW_POWER_STOP_MODE_ACTIVE activation */ +#undef USE_RT_DEBUG_LOW_POWER_STOP_MODE_ACTIVE +#define USE_RT_DEBUG_LOW_POWER_STOP_MODE_ACTIVE (1U) + +/* ADC_ACTIVATION activation */ +#undef USE_RT_DEBUG_ADC_ACTIVATION +#define USE_RT_DEBUG_ADC_ACTIVATION (1U) + +/* ADC_TEMPERATURE_ACQUISITION activation */ +#undef USE_RT_DEBUG_ADC_TEMPERATURE_ACQUISITION +#define USE_RT_DEBUG_ADC_TEMPERATURE_ACQUISITION (1U) + +/* RNG_GEN_RAND_NUM activation */ +#undef USE_RT_DEBUG_RNG_GEN_RAND_NUM +#define USE_RT_DEBUG_RNG_GEN_RAND_NUM (1U) + +/* LOW_POWER_STANDBY_MODE_ACTIVE activation */ +#undef USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_ACTIVE +#define USE_RT_DEBUG_LOW_POWER_STANDBY_MODE_ACTIVE (1U) + +/* + * + * Debug configuration for BLE purpose + * + */ +#elif (USE_RT_DEBUG_CONFIGURATION_BLE == 1U) + +/* LLHWC_CMN_LW_ISR activation */ +#undef USE_RT_DEBUG_LLHWC_CMN_LW_ISR +#define USE_RT_DEBUG_LLHWC_CMN_LW_ISR (1U) + +/* LLHWC_CMN_HG_ISR activation */ +#undef USE_RT_DEBUG_LLWCC_CMN_HG_ISR +#define USE_RT_DEBUG_LLWCC_CMN_HG_ISR (1U) + +/* PHY_CLBR_EXEC activation */ +#undef USE_RT_DEBUG_PHY_CLBR_EXEC +#define USE_RT_DEBUG_PHY_CLBR_EXEC (1U) + +/* SCHDLR_EVNT_RGSTR activation */ +#undef USE_RT_DEBUG_SCHDLR_EVNT_RGSTR +#define USE_RT_DEBUG_SCHDLR_EVNT_RGSTR (1U) + +/* SCHDLR_HNDL_MISSED_EVNT activation */ +#undef USE_RT_DEBUG_SCHDLR_HNDL_MISSED_EVNT +#define USE_RT_DEBUG_SCHDLR_HNDL_MISSED_EVNT (1U) + +/* SCHDLR_HNDL_NXT_TRACE activation */ +#undef USE_RT_DEBUG_SCHDLR_HNDL_NXT_TRACE +#define USE_RT_DEBUG_SCHDLR_HNDL_NXT_TRACE (1U) + +/* SCHDLR_EXEC_EVNT_TRACE activation */ +#undef USE_RT_DEBUG_SCHDLR_EXEC_EVNT_TRACE +#define USE_RT_DEBUG_SCHDLR_EXEC_EVNT_TRACE (1U) + +/* PHY_CLBR_ISR activation */ +#undef USE_RT_DEBUG_PHY_CLBR_ISR +#define USE_RT_DEBUG_PHY_CLBR_ISR (1U) + +/* + * + * Debug configuration for MAC purpose + * + */ +#elif (USE_RT_DEBUG_CONFIGURATION_MAC == 1U) + +/* LLHWC_CMN_LW_ISR activation */ +#undef USE_RT_DEBUG_LLHWC_CMN_LW_ISR +#define USE_RT_DEBUG_LLHWC_CMN_LW_ISR (1U) + +/* LLHWC_CMN_HG_ISR activation */ +#undef USE_RT_DEBUG_LLWCC_CMN_HG_ISR +#define USE_RT_DEBUG_LLWCC_CMN_HG_ISR (1U) + +/* RAL_ISR_TRACE activation */ +#undef USE_RT_DEBUG_RAL_ISR_TRACE +#define USE_RT_DEBUG_RAL_ISR_TRACE (1U) + +/* RAL_SM_DONE_EVNT_CBK activation */ +#undef USE_RT_DEBUG_RAL_SM_DONE_EVNT_CBK +#define USE_RT_DEBUG_RAL_SM_DONE_EVNT_CBK (1U) + +/* RAL_STOP_OPRTN activation */ +#undef USE_RT_DEBUG_RAL_STOP_OPRTN +#define USE_RT_DEBUG_RAL_STOP_OPRTN (1U) + +/* RAL_STRT_RX activation */ +#undef USE_RT_DEBUG_RAL_STRT_RX +#define USE_RT_DEBUG_RAL_STRT_RX (1U) + +/* RAL_STRT_TX activation */ +#undef USE_RT_DEBUG_RAL_STRT_TX +#define USE_RT_DEBUG_RAL_STRT_TX (1U) + +/* + * + * Debug configuration for COEX purpose + * + */ +#elif (USE_RT_DEBUG_CONFIGURATION_COEX == 1U) + +/* COEX_ASK_FOR_AIR activation */ +#undef USE_RT_DEBUG_COEX_ASK_FOR_AIR +#define USE_RT_DEBUG_COEX_ASK_FOR_AIR (1U) + +/* COEX_FORCE_STOP_RX activation */ +#undef USE_RT_DEBUG_COEX_FORCE_STOP_RX +#define USE_RT_DEBUG_COEX_FORCE_STOP_RX (1U) + +/* COEX_STRT_ON_IDLE activation */ +#undef USE_RT_DEBUG_COEX_STRT_ON_IDLE +#define USE_RT_DEBUG_COEX_STRT_ON_IDLE (1U) + +/* COEX_STRT_ONE_SHOT activation */ +#undef USE_RT_DEBUG_COEX_STRT_ONE_SHOT +#define USE_RT_DEBUG_COEX_STRT_ONE_SHOT (1U) + +/* SCHDLR_HNDL_NXT_TRACE activation */ +#undef USE_RT_DEBUG_SCHDLR_HNDL_NXT_TRACE +#define USE_RT_DEBUG_SCHDLR_HNDL_NXT_TRACE (1U) + +/* SCHDLR_EXEC_EVNT_TRACE activation */ +#undef USE_RT_DEBUG_SCHDLR_EXEC_EVNT_TRACE +#define USE_RT_DEBUG_SCHDLR_EXEC_EVNT_TRACE (1U) + +/* RAL_SM_DONE_EVNT_CBK activation */ +#undef USE_RT_DEBUG_RAL_SM_DONE_EVNT_CBK +#define USE_RT_DEBUG_RAL_SM_DONE_EVNT_CBK (1U) + +/* RAL_STOP_OPRTN activation */ +#undef USE_RT_DEBUG_RAL_STOP_OPRTN +#define USE_RT_DEBUG_RAL_STOP_OPRTN (1U) + +#else +/* Nothing to do */ +#endif /* (USE_RT_DEBUG_CONFIGURATION_COEX == 1U) */ + +#endif /* CFG_RT_DEBUG_GPIO_MODULE */ + +/******************************************************************/ +/** Association table between general debug signal and used gpio **/ +/******************************************************************/ + +#include "debug_signals.h" + +#if (CFG_RT_DEBUG_GPIO_MODULE == 1) + +#include "stm32wbaxx_hal.h" + +typedef struct { + GPIO_TypeDef* GPIO_port; + uint16_t GPIO_pin; +} st_gpio_debug_t; + +extern const st_gpio_debug_t general_debug_table[RT_DEBUG_SIGNALS_TOTAL_NUM]; + +#endif /* CFG_RT_DEBUG_GPIO_MODULE */ + +#ifdef __cplusplus +} +#endif + +#endif /* DEBUG_CONFIG_H */ diff --git a/lib/stm32wba/ble/System/Config/Log/log_module_conf.h b/lib/stm32wba/ble/System/Config/Log/log_module_conf.h new file mode 100644 index 000000000..67134f788 --- /dev/null +++ b/lib/stm32wba/ble/System/Config/Log/log_module_conf.h @@ -0,0 +1,294 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file log_module_conf.h + * @author MCD Application Team + * @brief Header file of the log module. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ +/* USER CODE END Header */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef LOG_MODULE_CONF_H +#define LOG_MODULE_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "app_conf.h" + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Module configuration ------------------------------------------------------*/ +/** + * @brief When this define is set to 0, there is no time stamp added to the trace data. + * When this define is set to 1, the time stamp is added to the trace data, + * according to the function registered with Log_Module_RegisterTimeStampFunction. + */ +#define LOG_INSERT_TIME_STAMP_INSIDE_THE_TRACE CFG_LOG_INSERT_TIME_STAMP_INSIDE_THE_TRACE + +/** + * @brief When this define is set to 0, the color of the trace data remains the same for all regions. + * When this define is set to 1, the color added to the trace data is based on LOG_COLOR_DEFAULT_CONFIGURATION. + */ +#define LOG_INSERT_COLOR_INSIDE_THE_TRACE CFG_LOG_INSERT_COLOR_INSIDE_THE_TRACE + +/** + * @brief When this define is set to 0, the trace data is not modified. + * When this define is set to 1, if there is no ENDOFLINE_CHAR as last + * character in the trace data, then one is added. + */ +#define LOG_INSERT_EOL_INSIDE_THE_TRACE CFG_LOG_INSERT_EOL_INSIDE_THE_TRACE + +/* USER CODE BEGIN Module configuration */ + +/* USER CODE END Module configuration */ + +/* Private defines -----------------------------------------------------------*/ +/* These defines are related to the UTIL_ADV_TRACE. Do not modify them please. */ +#define LOG_MODULE_MIN_VERBOSE_LEVEL (0) +#define LOG_MODULE_MAX_VERBOSE_LEVEL (0xFFFFFFFF) +#define LOG_MODULE_MIN_REGION_VALUE (0) +#define LOG_MODULE_ALL_REGION_MASK (0xFFFFFFFF) + +/* USER CODE BEGIN PD */ + +/* USER CODE END PD */ + +/* Exported types ------------------------------------------------------------*/ +/* Log module types */ +/** + * @brief Customizable enum describing the verbose levels used by the log module. + * The levels include the lower levels in the logs. + * + * E.g. LOG_VERBOSE_ERROR means LOG_VERBOSE_ERROR logs will be printed, + * as well as LOG_VERBOSE_INFO, but not the others with higher values. + * + * The min and max ranges are defined by LOG_MODULE_MIN_VERBOSE_LEVEL + * and LOG_MODULE_MAX_VERBOSE_LEVEL. + * + * The user can add its own levels but must NOT add a value to the said + * levels. Verbose levels are handled by the UTIL_ADV_TRACE. + */ +typedef enum +{ + LOG_VERBOSE_INFO = LOG_MODULE_MIN_VERBOSE_LEVEL, + /* USER CODE BEGIN Log_Verbose_Level_t_0 */ + + /* USER CODE END Log_Verbose_Level_t_0 */ + LOG_VERBOSE_ERROR, + /* USER CODE BEGIN Log_Verbose_Level_t_1 */ + + /* USER CODE END Log_Verbose_Level_t_1 */ + LOG_VERBOSE_WARNING, + /* USER CODE BEGIN Log_Verbose_Level_t_2 */ + + /* USER CODE END Log_Verbose_Level_t_2 */ + LOG_VERBOSE_DEBUG, + /* USER CODE BEGIN Log_Verbose_Level_t_3 */ + + /* USER CODE END Log_Verbose_Level_t_3 */ + LOG_VERBOSE_ALL_LOGS = LOG_MODULE_MAX_VERBOSE_LEVEL, +} Log_Verbose_Level_t; + +/** + * @brief Customizable enum describing the regions used by the log module. + * Regions are used to separate the logs into different places. + * + * Let's say you have a Task 1 and a Task 2. + * Both of them have Info and Debug logs. + * + * By using them as such, i.e. with the same regions, you'll + * print the logs of the 2 tasks as long as the verbose is Info or Debug. + * + * If you create a region for Task 1 and another for Task 2, you can + * split the logs between them, and, if needed, only print the Debug + * logs for Task 1 only (i.e. Task 1 logs for Info and Debug). + * + * Behind the scenes is a mask into which each region is a bit. + * The user can add its own regions but must NOT add a value to them. + * The log module handles the mask on its own. + */ +typedef enum +{ + LOG_REGION_BLE = LOG_MODULE_MIN_REGION_VALUE, + LOG_REGION_SYSTEM, + LOG_REGION_APP, + LOG_REGION_LINKLAYER, + LOG_REGION_MAC, + LOG_REGION_ZIGBEE, + LOG_REGION_THREAD, + LOG_REGION_RTOS, + /* USER CODE BEGIN Log_Region_t */ + + /* USER CODE END Log_Region_t */ + LOG_REGION_ALL_REGIONS = LOG_MODULE_ALL_REGION_MASK, +} Log_Region_t; + +typedef enum +{ + LOG_COLOR_NONE = 0, /* Initialization */ + LOG_COLOR_CODE_DEFAULT = 37, /* White */ + LOG_COLOR_CODE_RED = 91, + LOG_COLOR_CODE_GREEN = 92, + LOG_COLOR_CODE_YELLOW = 93, + LOG_COLOR_CODE_CYAN = 96, + /* USER CODE BEGIN Log_Color_t */ + + /* USER CODE END Log_Color_t */ +} Log_Color_t; + +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported macro ------------------------------------------------------------*/ +/* Display 64 bits number for all compiler. */ +/* Example : LOG_INFO_APP( "New Device : " LOG_DISPLAY64() " installed in %d seconds", LOG_NUMBER64( dlDevice ), iTime ); */ +#define LOG_DISPLAY64() "0x%08X%08X" +#define LOG_NUMBER64( number ) (uint32_t)( number >> 32u ), (uint32_t)( number ) + +/* Module API - Log macros for each region */ +/* LOG_REGION_BLE */ +#if (CFG_LOG_SUPPORTED != 0) +#define LOG_INFO_BLE(...) Log_Module_Print( LOG_VERBOSE_INFO, LOG_REGION_BLE, __VA_ARGS__) +#define LOG_ERROR_BLE(...) Log_Module_Print( LOG_VERBOSE_ERROR, LOG_REGION_BLE, __VA_ARGS__) +#define LOG_WARNING_BLE(...) Log_Module_Print( LOG_VERBOSE_WARNING, LOG_REGION_BLE, __VA_ARGS__) +#define LOG_DEBUG_BLE(...) Log_Module_Print( LOG_VERBOSE_DEBUG, LOG_REGION_BLE, __VA_ARGS__) +#else /* (CFG_LOG_SUPPORTED != 0) */ +#define LOG_INFO_BLE(...) do {} while(0) +#define LOG_ERROR_BLE(...) do {} while(0) +#define LOG_WARNING_BLE(...) do {} while(0) +#define LOG_DEBUG_BLE(...) do {} while(0) +#endif /* (CFG_LOG_SUPPORTED != 0) */ + +/* USER CODE BEGIN LOG_REGION_BLE */ +/** + * Add inside this user section your defines to match the new verbose levels you + * created into Log_Verbose_Level_t. + * Example : + * #define LOG_CUSTOM_BLE(...) Log_Module_Print( LOG_VERBOSE_CUSTOM, LOG_REGION_BLE, __VA_ARGS__); + * + * You don't need to update all regions with your custom values. + * Do it accordingly to your needs. E.g you might not need LOG_VERBOSE_CUSTOM for a System region. + */ + +/* USER CODE END LOG_REGION_BLE */ + +/* LOG_REGION_SYSTEM */ +#if (CFG_LOG_SUPPORTED != 0) +#define LOG_INFO_SYSTEM(...) Log_Module_Print( LOG_VERBOSE_INFO, LOG_REGION_SYSTEM, __VA_ARGS__) +#define LOG_ERROR_SYSTEM(...) Log_Module_Print( LOG_VERBOSE_ERROR, LOG_REGION_SYSTEM, __VA_ARGS__) +#define LOG_WARNING_SYSTEM(...) Log_Module_Print( LOG_VERBOSE_WARNING, LOG_REGION_SYSTEM, __VA_ARGS__) +#define LOG_DEBUG_SYSTEM(...) Log_Module_Print( LOG_VERBOSE_DEBUG, LOG_REGION_SYSTEM, __VA_ARGS__) +#else /* (CFG_LOG_SUPPORTED != 0) */ +#define LOG_INFO_SYSTEM(...) do {} while(0) +#define LOG_ERROR_SYSTEM(...) do {} while(0) +#define LOG_WARNING_SYSTEM(...) do {} while(0) +#define LOG_DEBUG_SYSTEM(...) do {} while(0) +#endif /* (CFG_LOG_SUPPORTED != 0) */ + +/* USER CODE BEGIN LOG_REGION_SYSTEM */ +/** + * Add inside this user section your defines to match the new verbose levels you + * created into Log_Verbose_Level_t. + * Example : + * #define LOG_CUSTOM_SYSTEM(...) Log_Module_Print( LOG_VERBOSE_CUSTOM, LOG_REGION_SYSTEM, __VA_ARGS__); + * + * You don't need to update all regions with your custom values. + * Do it accordingly to your needs. E.g you might not need LOG_VERBOSE_CUSTOM for a System region. + */ + +/* USER CODE END LOG_REGION_SYSTEM */ + +/* LOG_REGION_APP */ +#if (CFG_LOG_SUPPORTED != 0) +#define LOG_INFO_APP(...) Log_Module_Print( LOG_VERBOSE_INFO, LOG_REGION_APP, __VA_ARGS__) +#define LOG_ERROR_APP(...) Log_Module_Print( LOG_VERBOSE_ERROR, LOG_REGION_APP, __VA_ARGS__) +#define LOG_WARNING_APP(...) Log_Module_Print( LOG_VERBOSE_WARNING, LOG_REGION_APP, __VA_ARGS__) +#define LOG_DEBUG_APP(...) Log_Module_Print( LOG_VERBOSE_DEBUG, LOG_REGION_APP, __VA_ARGS__) +#else /* (CFG_LOG_SUPPORTED != 0) */ +#define LOG_INFO_APP(...) do {} while(0) +#define LOG_ERROR_APP(...) do {} while(0) +#define LOG_WARNING_APP(...) do {} while(0) +#define LOG_DEBUG_APP(...) do {} while(0) +#endif /* (CFG_LOG_SUPPORTED != 0) */ + +/* USER CODE BEGIN LOG_REGION_APP */ +/** + * Add inside this user section your defines to match the new verbose levels you + * created into Log_Verbose_Level_t. + * Example : + * #define LOG_CUSTOM_APP(...) Log_Module_Print( LOG_VERBOSE_CUSTOM, LOG_REGION_APP, __VA_ARGS__); + * + * You don't need to update all regions with your custom values. + * Do it accordingly to your needs. E.g you might not need LOG_VERBOSE_CUSTOM for a System region. + */ + +/* USER CODE END LOG_REGION_APP */ + +/* LOG_REGION_LINKLAYER */ +#if (CFG_LOG_SUPPORTED != 0) +#define LOG_INFO_LINKLAYER(...) Log_Module_Print( LOG_VERBOSE_INFO, LOG_REGION_LINKLAYER, __VA_ARGS__) +#define LOG_ERROR_LINKLAYER(...) Log_Module_Print( LOG_VERBOSE_ERROR, LOG_REGION_LINKLAYER, __VA_ARGS__) +#define LOG_WARNING_LINKLAYER(...)Log_Module_Print( LOG_VERBOSE_WARNING, LOG_REGION_LINKLAYER, __VA_ARGS__) +#define LOG_DEBUG_LINKLAYER(...) Log_Module_Print( LOG_VERBOSE_DEBUG, LOG_REGION_LINKLAYER, __VA_ARGS__) +#else /* (CFG_LOG_SUPPORTED != 0) */ +#define LOG_INFO_LINKLAYER(...) do {} while(0) +#define LOG_ERROR_LINKLAYER(...) do {} while(0) +#define LOG_WARNING_LINKLAYER(...)do {} while(0) +#define LOG_DEBUG_LINKLAYER(...) do {} while(0) +#endif /* (CFG_LOG_SUPPORTED != 0) */ + +/* USER CODE BEGIN LOG_REGION_LINKLAYER */ +/** + * Add inside this user section your defines to match the new verbose levels you + * created into Log_Verbose_Level_t. + * Example : + * #define LOG_CUSTOM_LINKLAYER(...) Log_Module_Print( LOG_VERBOSE_CUSTOM, LOG_REGION_LINKLAYER, __VA_ARGS__); + * + * You don't need to update all regions with your custom values. + * Do it accordingly to your needs. E.g you might not need LOG_VERBOSE_CUSTOM for a System region. + */ + +/* USER CODE END LOG_REGION_LINKLAYER */ + +/* USER CODE BEGIN APP_LOG_USER_DEFINES */ +/** + * Add inside this user section your defines to match the new regions you + * created into Log_Region_t. + * Example : +#if (CFG_LOG_SUPPORTED != 0) +#define LOG_INFO_CUSTOM(...) Log_Module_Print( LOG_VERBOSE_INFO, LOG_REGION_CUSTOM, __VA_ARGS__) +#define LOG_ERROR_CUSTOM(...) Log_Module_Print( LOG_VERBOSE_ERROR, LOG_REGION_CUSTOM, __VA_ARGS__) +#define LOG_WARNING_CUSTOM(...) Log_Module_Print( LOG_VERBOSE_WARNING, LOG_REGION_CUSTOM, __VA_ARGS__) +#define LOG_DEBUG_CUSTOM(...) Log_Module_Print( LOG_VERBOSE_DEBUG, LOG_REGION_CUSTOM, __VA_ARGS__) +#else +#define LOG_INFO_CUSTOM(...) do {} while(0) +#define LOG_ERROR_CUSTOM(...) do {} while(0) +#define LOG_WARNING_CUSTOM(...) do {} while(0) +#define LOG_DEBUG_CUSTOM(...) do {} while(0) +#endif + */ +/* USER CODE END APP_LOG_USER_DEFINES */ + +#ifdef __cplusplus +} +#endif + +#endif /* LOG_MODULE_CONF_H */ diff --git a/scripts/ble_library.py b/scripts/ble_library.py index 699991819..cfd259fca 100644 --- a/scripts/ble_library.py +++ b/scripts/ble_library.py @@ -2,7 +2,7 @@ """ SPDX-License-Identifier: Apache-2.0 Copyright (c) 2024 STMicroelectronics. -This script updates ble library +This script updates ble and ieee802154 library """ import sys @@ -41,6 +41,8 @@ ble_transparent_mode_app_path = "Projects/NUCLEO-WBA65RI/Applications/BLE/" \ + "BLE_TransparentMode" +zgbee_onoff_client_sed_app_path = "Projects/NUCLEO-WBA65RI/Applications/BLE/" \ + + "Zigbee_OnOff_Client_SED" file_list_wba = { "STM32_WPAN": [ "Middlewares/ST/STM32_WPAN/ble/stack/include/auto/ble_types.h", @@ -48,15 +50,20 @@ + "DWC_ble154combo.h", "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/bsp.h", "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/common_types.h", + "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/dtm.h", "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/event_manager.h", "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/evnt_schdlr_gnrc_if.h", + "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ll_error.h", "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/hci.h", "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ll_intf.h", "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ll_intf_cmn.h", "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/mem_intf.h", "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/os_wrapper.h", + "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/platform.h", "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/power_table.h", "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/pta.h", + "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/ral.h", + "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/inc/rfd_dev_config.h", "Middlewares/ST/STM32_WPAN/link_layer/ll_cmd_lib/config/ble_full/" + "ll_fw_config.h", "Middlewares/ST/STM32_WPAN/ble/stack/include/ble_bufsize.h", @@ -74,14 +81,14 @@ "Middlewares/ST/STM32_WPAN/link_layer/ll_sys/inc/ll_sys_startup.h", "Middlewares/ST/STM32_WPAN/stm32_wpan_common.h", ], - "BLE_TransparentMode": [ + "ble": [ ble_transparent_mode_app_path + "/Core/Inc/app_common.h", ble_transparent_mode_app_path + "/Core/Inc/app_conf.h", ble_transparent_mode_app_path + "/Core/Inc/app_entry.h", ble_transparent_mode_app_path + "/Core/Inc/utilities_conf.h", ble_transparent_mode_app_path + "/Core/Inc/main.h", - ble_transparent_mode_app_path + "/System/Config/Debug_GPIO/app_debug.h", ble_transparent_mode_app_path + "/System/Config/Debug_GPIO/debug_config.h", + ble_transparent_mode_app_path + "/System/Config/Log/log_module_conf.h", ble_transparent_mode_app_path + "/STM32_WPAN/Target/power_table.c", ble_transparent_mode_app_path + "/STM32_WPAN/Target/bpka.c", ble_transparent_mode_app_path + "/STM32_WPAN/Target/bpka.h", @@ -89,6 +96,19 @@ ble_transparent_mode_app_path + "/STM32_WPAN/Target/ll_sys_if.c", ble_transparent_mode_app_path + "/STM32_WPAN/Target/ll_sys_if.h", ], + "IEEE802154": [ + zgbee_onoff_client_sed_app_path + "/Core/Inc/app_common.h", + zgbee_onoff_client_sed_app_path + "/Core/Inc/app_conf.h", + zgbee_onoff_client_sed_app_path + "/Core/Inc/app_entry.h", + zgbee_onoff_client_sed_app_path + "/Core/Inc/utilities_conf.h", + zgbee_onoff_client_sed_app_path + "/Core/Inc/main.h", + zgbee_onoff_client_sed_app_path + "/System/Config/Debug_GPIO/debug_config.h", + zgbee_onoff_client_sed_app_path + "/System/Config/Log/log_module_conf.h", + zgbee_onoff_client_sed_app_path + "/STM32_WPAN/Target/power_table.c", + zgbee_onoff_client_sed_app_path + "/STM32_WPAN/Target/linklayer_plat.c", + zgbee_onoff_client_sed_app_path + "/STM32_WPAN/Target/ll_sys_if.c", + zgbee_onoff_client_sed_app_path + "/STM32_WPAN/Target/ll_sys_if.h", + ], "Common": [ "Projects/Common/WPAN/Modules/Flash/rf_timing_synchro.c", "Projects/Common/WPAN/Modules/Flash/rf_timing_synchro.h", diff --git a/zephyr/module.yml b/zephyr/module.yml index 2b39fd1cd..a7f94cc03 100644 --- a/zephyr/module.yml +++ b/zephyr/module.yml @@ -53,3 +53,17 @@ blobs: license-path: zephyr/blobs/stm32wb0/lib/license.md url: https://github.com/STMicroelectronics/STM32CubeWB0/raw/v1.0.0/Middlewares/ST/STM32_BLE/stack/lib/stm32wb0x_ble_stack_controller_only.a description: "Binary Stack library for the STM32WB0 Bluetooth subsystem" + - path: stm32wba/lib/WBA6_LinkLayer15_4_Zephyr.a + sha256: e89b955174e4aa65d9867bdc7bfc5c1ad198fc5f4912b01bea768f2b7a891b40 + type: lib + version: '1.6.0' + license-path: zephyr/blobs/stm32wba/lib/license.md + url: https://github.com/stm32-hotspot/STM32WBA-Zephyr-custom-binaries/raw/main/lib/WBA6_LinkLayer15_4_Zephyr.a + description: "Binary Link Layer library for the STM32WBA6 802.15.4 subsystem" + - path: stm32wba/lib/WBA6_LinkLayer_Thread_lib_Zephyr.a + sha256: 2b8c46d3d8afbe99f89fc4e6cf9a155d28ee273ee5a334a53f6b3f6e4718a944 + type: lib + version: '1.6.0' + license-path: zephyr/blobs/stm32wba/lib/license.md + url: https://github.com/stm32-hotspot/STM32WBA-Zephyr-custom-binaries/raw/main/lib/WBA6_LinkLayer_Thread_lib_Zephyr.a + description: "Binary Link Layer library for the STM32WBA6 Thread subsystem"