From 73a56862dd32ea400f0acda4673505d47d67e2ea Mon Sep 17 00:00:00 2001 From: Vincent Wan Date: Thu, 30 Apr 2020 17:16:32 -0700 Subject: [PATCH] cc13x2_cc26x2: update to TI SimpleLink SDK 4.10.00.78 Update the HAL to new TI SimpleLink SDK, including driverlib, rf patches and TI drivers. Add the temperature driver in order to support new changes in the Power Manager. Signed-off-by: Vincent Wan --- simplelink/CMakeLists.txt | 2 +- simplelink/README | 13 +- simplelink/source/ti/devices/DeviceFamily.h | 2 +- .../ti/devices/cc13x2_cc26x2/CMakeLists.txt | 12 +- .../devices/cc13x2_cc26x2/driverlib/aes_doc.h | 4 +- .../cc13x2_cc26x2/driverlib/aon_event.c | 4 +- .../cc13x2_cc26x2/driverlib/aon_event.h | 4 +- .../cc13x2_cc26x2/driverlib/aon_event_doc.h | 4 +- .../cc13x2_cc26x2/driverlib/aon_pmctl.c | 4 +- .../cc13x2_cc26x2/driverlib/aon_pmctl.h | 4 +- .../cc13x2_cc26x2/driverlib/aon_pmctl_doc.h | 4 +- .../devices/cc13x2_cc26x2/driverlib/aon_rtc.c | 4 +- .../devices/cc13x2_cc26x2/driverlib/aon_rtc.h | 4 +- .../devices/cc13x2_cc26x2/driverlib/aux_adc.c | 4 +- .../devices/cc13x2_cc26x2/driverlib/aux_adc.h | 4 +- .../cc13x2_cc26x2/driverlib/aux_sysif.c | 4 +- .../cc13x2_cc26x2/driverlib/aux_sysif.h | 4 +- .../devices/cc13x2_cc26x2/driverlib/aux_tdc.h | 4 +- .../cc13x2_cc26x2/driverlib/ccfgread.h | 38 +- .../cc13x2_cc26x2/driverlib/chipinfo.c | 10 +- .../cc13x2_cc26x2/driverlib/chipinfo.h | 7 +- .../ti/devices/cc13x2_cc26x2/driverlib/cpu.c | 22 +- .../ti/devices/cc13x2_cc26x2/driverlib/cpu.h | 6 +- .../devices/cc13x2_cc26x2/driverlib/crypto.c | 22 +- .../ti/devices/cc13x2_cc26x2/driverlib/ddi.h | 4 +- .../driverlib/driverlib_release.c | 2 +- .../driverlib/driverlib_release.h | 6 +- .../devices/cc13x2_cc26x2/driverlib/flash.c | 4 +- .../devices/cc13x2_cc26x2/driverlib/flash.h | 4 +- .../cc13x2_cc26x2/driverlib/interrupt.h | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/ioc.c | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/ioc.h | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/osc.c | 73 +- .../ti/devices/cc13x2_cc26x2/driverlib/osc.h | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/pka.c | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/pka.h | 4 +- .../devices/cc13x2_cc26x2/driverlib/pka_doc.h | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/prcm.c | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/prcm.h | 4 +- .../cc13x2_cc26x2/driverlib/pwr_ctrl.c | 4 +- .../cc13x2_cc26x2/driverlib/pwr_ctrl.h | 4 +- .../cc13x2_cc26x2/driverlib/rf_ble_cmd.h | 18 +- .../cc13x2_cc26x2/driverlib/rf_ble_mailbox.h | 4 +- .../cc13x2_cc26x2/driverlib/rf_bt5_coex.h | 167 ++ .../cc13x2_cc26x2/driverlib/rf_common_cmd.h | 16 +- .../cc13x2_cc26x2/driverlib/rf_data_entry.h | 4 +- .../cc13x2_cc26x2/driverlib/rf_hs_cmd.h | 4 +- .../cc13x2_cc26x2/driverlib/rf_hs_mailbox.h | 4 +- .../cc13x2_cc26x2/driverlib/rf_ieee_cmd.h | 4 +- .../cc13x2_cc26x2/driverlib/rf_ieee_mailbox.h | 6 +- .../cc13x2_cc26x2/driverlib/rf_mailbox.h | 4 +- .../cc13x2_cc26x2/driverlib/rf_prop_cmd.h | 20 +- .../cc13x2_cc26x2/driverlib/rf_prop_mailbox.h | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/rfc.h | 21 +- .../ti/devices/cc13x2_cc26x2/driverlib/rom.h | 4 +- .../cc13x2_cc26x2/driverlib/rom_crypto.c | 4 +- .../cc13x2_cc26x2/driverlib/rom_crypto.h | 4 +- .../devices/cc13x2_cc26x2/driverlib/setup.c | 4 +- .../cc13x2_cc26x2/driverlib/setup_rom.c | 4 +- .../cc13x2_cc26x2/driverlib/setup_rom.h | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/sha2.c | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/sha2.h | 4 +- .../cc13x2_cc26x2/driverlib/sha2_doc.h | 4 +- .../cc13x2_cc26x2/driverlib/sys_ctrl.c | 8 +- .../cc13x2_cc26x2/driverlib/sys_ctrl.h | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/uart.c | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/uart.h | 4 +- .../ti/devices/cc13x2_cc26x2/driverlib/udma.h | 6 +- .../ti/devices/cc13x2_cc26x2/driverlib/vims.c | 4 +- .../cc13x2_cc26x2/driverlib/watchdog.c | 2 +- .../ti/devices/cc13x2_cc26x2/inc/hw_ccfg.h | 72 +- .../devices/cc13x2_cc26x2/inc/hw_chip_def.h | 4 +- .../ti/devices/cc13x2_cc26x2/inc/hw_ddi.h | 4 +- .../devices/cc13x2_cc26x2/inc/hw_ddi_0_osc.h | 15 +- .../rf_patches/rf_patch_cpe_bt5.c | 457 +++ .../rf_patches/rf_patch_cpe_bt5.h | 159 +- .../rf_patches/rf_patch_cpe_ieee_802_15_4.c | 265 ++ .../rf_patches/rf_patch_cpe_ieee_802_15_4.h | 132 +- .../rf_patches/rf_patch_cpe_multi_bt5_coex.c | 1663 +++++++++++ .../rf_patches/rf_patch_cpe_multi_bt5_coex.h | 67 + .../rf_patches/rf_patch_cpe_multi_protocol.c | 565 ++++ .../rf_patches/rf_patch_cpe_multi_protocol.h | 187 +- .../rf_patch_cpe_multi_protocol_rtls.c | 1084 +++++++ .../rf_patch_cpe_multi_protocol_rtls.h | 1393 +-------- .../rf_patches/rf_patch_cpe_prop.c | 267 ++ .../rf_patches/rf_patch_cpe_prop.h | 160 +- .../rf_patches/rf_patch_mce_genook.c | 585 ++++ .../rf_patches/rf_patch_mce_genook.h | 46 + .../rf_patches/rf_patch_mce_iqdump.c | 453 +++ .../rf_patches/rf_patch_mce_iqdump.h | 400 +-- .../rf_patches/rf_patch_mce_tof.h | 609 ---- .../rf_patches/rf_patch_rfe_genook.c | 492 ++++ .../rf_patches/rf_patch_rfe_genook.h | 47 + .../rf_patches/rf_patch_rfe_tof.h | 571 ---- .../cc13x2_cc26x2/startup_files/ccfg.c | 25 +- simplelink/source/ti/drivers/Temperature.c | 79 + simplelink/source/ti/drivers/Temperature.h | 550 ++++ .../source/ti/drivers/power/PowerCC26X2.c | 234 +- .../source/ti/drivers/power/PowerCC26X2.h | 44 +- .../power/PowerCC26X2_calibrateRCOSC.c | 4 +- .../source/ti/drivers/power/PowerCC26XX.c | 1394 --------- .../source/ti/drivers/power/PowerCC26XX.h | 16 +- .../power/PowerCC26XX_calibrateRCOSC.c | 820 ------ simplelink/source/ti/drivers/rf/RF.h | 2414 +-------------- simplelink/source/ti/drivers/rf/RFCC26X2.h | 2586 +++++++++++++++++ .../source/ti/drivers/rf/RFCC26X2_multiMode.c | 364 ++- .../drivers/temperature/TemperatureCC26X2.c | 559 ++++ .../drivers/temperature/TemperatureCC26X2.h | 133 + 108 files changed, 10948 insertions(+), 8642 deletions(-) create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_bt5_coex.h create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_bt5.c create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_ieee_802_15_4.c create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_bt5_coex.c create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_bt5_coex.h create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol.c create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol_rtls.c create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_prop.c create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_genook.c create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_genook.h create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_iqdump.c delete mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_tof.h create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_rfe_genook.c create mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_rfe_genook.h delete mode 100644 simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_rfe_tof.h create mode 100644 simplelink/source/ti/drivers/Temperature.c create mode 100644 simplelink/source/ti/drivers/Temperature.h delete mode 100644 simplelink/source/ti/drivers/power/PowerCC26XX.c delete mode 100644 simplelink/source/ti/drivers/power/PowerCC26XX_calibrateRCOSC.c create mode 100644 simplelink/source/ti/drivers/rf/RFCC26X2.h create mode 100644 simplelink/source/ti/drivers/temperature/TemperatureCC26X2.c create mode 100644 simplelink/source/ti/drivers/temperature/TemperatureCC26X2.h diff --git a/simplelink/CMakeLists.txt b/simplelink/CMakeLists.txt index b9b6fee..d531333 100644 --- a/simplelink/CMakeLists.txt +++ b/simplelink/CMakeLists.txt @@ -83,7 +83,7 @@ elseif(CONFIG_HAS_CC13X2_CC26X2_SDK) PROPERTIES COMPILE_DEFINITIONS "DeviceFamily_CC13X2;${COMPILER}" ) set_source_files_properties(source/ti/drivers/rf/RFCC26X2_multiMode.c PROPERTIES COMPILE_DEFINITIONS "DeviceFamily_CC13X2;${COMPILER}" ) - else() + elseif(CONFIG_SOC_CC2652R) set_source_files_properties(source/ti/drivers/power/PowerCC26X2.c PROPERTIES COMPILE_DEFINITIONS "DeviceFamily_CC26X2;${COMPILER}" ) set_source_files_properties(source/ti/drivers/power/PowerCC26X2_calibrateRCOSC.c diff --git a/simplelink/README b/simplelink/README index 069988d..e15b0e3 100644 --- a/simplelink/README +++ b/simplelink/README @@ -8,27 +8,32 @@ http://dev.ti.com/tirex/content/simplelink_cc32xx_sdk_2_40_01_01/docs/simplelink 1. CC13x2/26x2 SDK The current version supported in Zephyr is the SimpleLink CC13x2 and CC26x2 SDK -3.10.00.53, downloaded from: +4.10.00.78, downloaded from: http://www.ti.com/tool/simplelink-cc13x2-26x2-sdk The driver library source is copied from the SDK, as follows: EXT_DIR=$HOME/hal_ti/simplelink/source/ti - pushd simplelink_cc13x2_26x2_sdk_3_10_00_53/source/ti + pushd simplelink_cc13x2_26x2_sdk_4_10_00_78/source/ti find devices/cc13x2_cc26x2/{driverlib,inc,rf_patches} -depth -name '*.[c|h]' -print0 | cpio --null -pvdm $EXT_DIR find devices/cc13x2_cc26x2/startup_files -depth -name ccfg.c -print0 | cpio --null -pvd $EXT_DIR cp -r drivers/power/* $EXT_DIR/drivers/power/. + mkdir $EXT_DIR/drivers/temperature + cp -r drivers/temperature/* $EXT_DIR/drivers/temperature/. + cp drivers/Temperature.* $EXT_DIR/drivers/. mkdir $EXT_DIR/drivers/rf cp drivers/rf/RF.h $EXT_DIR/drivers/rf/. + cp drivers/rf/RFCC26X2.h $EXT_DIR/drivers/rf/. cp drivers/rf/RFCC26X2_multiMode.c $EXT_DIR/drivers/rf/. find $EXT_DIR/devices/cc13x2_cc26x2 -name '*.[c|h]' -exec dos2unix {} \; find $EXT_DIR/drivers/power -name '*.[c|h]' -exec dos2unix {} \; find $EXT_DIR/drivers/rf -name '*.[c|h]' -exec dos2unix {} \; + find $EXT_DIR/drivers/temperature -name '*.[c|h]' -exec dos2unix {} \; popd -The source file startup_files/ccfg.c has been modified to use the appropriate -sections when linking. +The source file devices/cc13x2_cc26x2/startup_files/ccfg.c has been +modified to use the appropriate sections when linking. TI provides the driver library functions burned into ROM at the factory, or updated via a service pack patch, thus saving application code space. diff --git a/simplelink/source/ti/devices/DeviceFamily.h b/simplelink/source/ti/devices/DeviceFamily.h index 9b62aec..db82046 100644 --- a/simplelink/source/ti/devices/DeviceFamily.h +++ b/simplelink/source/ti/devices/DeviceFamily.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/CMakeLists.txt b/simplelink/source/ti/devices/cc13x2_cc26x2/CMakeLists.txt index c8c765e..2808bf3 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/CMakeLists.txt +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/CMakeLists.txt @@ -13,10 +13,18 @@ zephyr_library_sources( driverlib/aux_sysif.c # Required for CPUdelay which is not in ROM driverlib/cpu.c - # Required for RFCDoorbellSendTo which is not in ROM - driverlib/rfc.c # Required functions to support the TI Power module driverlib/sys_ctrl.c driverlib/osc.c driverlib/driverlib_release.c ) + +if(CONFIG_SOC_CC1352R) + # Required for RFCDoorbellSendTo which is not in ROM + set_source_files_properties(driverlib/rfc.c + PROPERTIES COMPILE_DEFINITIONS "DeviceFamily_CC13X2;${COMPILER}" ) +elseif(CONFIG_SOC_CC2652R) + # Required for RFCDoorbellSendTo which is not in ROM + set_source_files_properties(driverlib/rfc.c + PROPERTIES COMPILE_DEFINITIONS "DeviceFamily_CC26X2;${COMPILER}" ) +endif() diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aes_doc.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aes_doc.h index 6d156a4..a54b8ce 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aes_doc.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aes_doc.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aes_doc.h -* Revised: 2017-06-05 12:13:49 +0200 (Mon, 05 Jun 2017) -* Revision: 49096 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Copyright (c) 2015 - 2017, Texas Instruments Incorporated * All rights reserved. diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_event.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_event.c index cb699a1..44d2f81 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_event.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_event.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aon_event.c -* Revised: 2017-06-05 12:13:49 +0200 (Mon, 05 Jun 2017) -* Revision: 49096 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for the AON Event fabric. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_event.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_event.h index 999844a..9a78c44 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_event.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_event.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aon_event.h -* Revised: 2017-08-09 16:56:05 +0200 (Wed, 09 Aug 2017) -* Revision: 49506 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the AON Event fabric. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_event_doc.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_event_doc.h index 5210bbf..67dc89d 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_event_doc.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_event_doc.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aon_event_doc.h -* Revised: 2017-08-09 16:56:05 +0200 (Wed, 09 Aug 2017) -* Revision: 49506 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Copyright (c) 2015 - 2017, Texas Instruments Incorporated * All rights reserved. diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_pmctl.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_pmctl.c index b680fd7..a8ff040 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_pmctl.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_pmctl.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aon_pmctl.c -* Revised: 2017-06-05 12:13:49 +0200 (Mon, 05 Jun 2017) -* Revision: 49096 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for the AON Power-Management Controller. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_pmctl.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_pmctl.h index ec6bf2e..c1fd2b5 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_pmctl.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_pmctl.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aon_pmctl.h -* Revised: 2017-11-02 14:16:14 +0100 (Thu, 02 Nov 2017) -* Revision: 50156 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the AON Power-Management Controller * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_pmctl_doc.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_pmctl_doc.h index 0f44256..f8f4f39 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_pmctl_doc.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_pmctl_doc.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aon_pmctl_doc.h -* Revised: 2017-11-02 15:41:14 +0100 (Thu, 02 Nov 2017) -* Revision: 50165 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Copyright (c) 2015 - 2017, Texas Instruments Incorporated * All rights reserved. diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_rtc.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_rtc.c index 7187f84..9005de5 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_rtc.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_rtc.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aon_rtc.c -* Revised: 2017-06-05 12:13:49 +0200 (Mon, 05 Jun 2017) -* Revision: 49096 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for the AON RTC. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_rtc.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_rtc.h index 6e131d2..ed711a6 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_rtc.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aon_rtc.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aon_rtc.h -* Revised: 2017-08-16 15:13:43 +0200 (Wed, 16 Aug 2017) -* Revision: 49593 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the AON RTC * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_adc.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_adc.c index b1b3f19..532000a 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_adc.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_adc.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aux_adc.c -* Revised: 2017-11-20 14:31:35 +0100 (Mon, 20 Nov 2017) -* Revision: 50315 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for the AUX Time to Digital Converter interface. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_adc.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_adc.h index c87fd2f..4d8b8fc 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_adc.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_adc.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aux_adc.h -* Revised: 2018-02-07 09:45:39 +0100 (Wed, 07 Feb 2018) -* Revision: 51437 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the AUX Analog-to-Digital * Converter diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_sysif.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_sysif.c index 5e3e90b..c2a0e29 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_sysif.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_sysif.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aux_sysif.c -* Revised: 2018-04-17 14:54:06 +0200 (Tue, 17 Apr 2018) -* Revision: 51890 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for the AUX System Interface * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_sysif.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_sysif.h index 04214bc..573a668 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_sysif.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_sysif.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aux_sysif.h -* Revised: 2017-06-27 08:41:49 +0200 (Tue, 27 Jun 2017) -* Revision: 49245 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the AUX System Interface * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_tdc.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_tdc.h index 402c834..ee32780 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_tdc.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/aux_tdc.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: aux_tdc.h -* Revised: 2017-06-05 12:13:49 +0200 (Mon, 05 Jun 2017) -* Revision: 49096 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the AUX Time-to-Digital Converter * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ccfgread.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ccfgread.h index a1e809d..23d01ef 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ccfgread.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ccfgread.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: ccfgread.h -* Revised: 2016-09-13 14:21:40 +0200 (Tue, 13 Sep 2016) -* Revision: 47152 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: API for reading CCFG. * @@ -146,6 +146,7 @@ CCFGRead_SCLK_LF_OPTION( void ) #define CCFGREAD_XOSC_FREQ_24M ( CCFG_MODE_CONF_XOSC_FREQ_24M >> CCFG_MODE_CONF_XOSC_FREQ_S ) #define CCFGREAD_XOSC_FREQ_48M ( CCFG_MODE_CONF_XOSC_FREQ_48M >> CCFG_MODE_CONF_XOSC_FREQ_S ) #define CCFGREAD_XOSC_FREQ_HPOSC ( CCFG_MODE_CONF_XOSC_FREQ_HPOSC >> CCFG_MODE_CONF_XOSC_FREQ_S ) +#define CCFGREAD_XOSC_FREQ_TCXO ( CCFG_MODE_CONF_XOSC_FREQ_TCXO >> CCFG_MODE_CONF_XOSC_FREQ_S ) //***************************************************************************** // @@ -156,6 +157,7 @@ CCFGRead_SCLK_LF_OPTION( void ) //! - \ref CCFGREAD_XOSC_FREQ_24M //! - \ref CCFGREAD_XOSC_FREQ_48M //! - \ref CCFGREAD_XOSC_FREQ_HPOSC +//! - \ref CCFGREAD_XOSC_FREQ_TCXO //! // //***************************************************************************** @@ -167,6 +169,38 @@ CCFGRead_XOSC_FREQ( void ) CCFG_MODE_CONF_XOSC_FREQ_S ) ; } +//***************************************************************************** +// +//! \brief Read TCXO_MAX_START setting from CCFG. +//! +//! \return Returns the value of the CCFG_MODE_CONF_1_TCXO_MAX_START field. +//! +// +//***************************************************************************** +__STATIC_INLINE uint32_t +CCFGRead_TCXO_MAX_START( void ) +{ + return (( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) & + CCFG_MODE_CONF_1_TCXO_MAX_START_M ) >> + CCFG_MODE_CONF_1_TCXO_MAX_START_S ) ; +} + +//***************************************************************************** +// +//! \brief Read TCXO_TYPE setting from CCFG. +//! +//! \return Returns the value of the CCFG_MODE_CONF_1_TCXO_TYPE field. +//! +// +//***************************************************************************** +__STATIC_INLINE uint32_t +CCFGRead_TCXO_TYPE( void ) +{ + return (( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) & + CCFG_MODE_CONF_1_TCXO_TYPE_M ) >> + CCFG_MODE_CONF_1_TCXO_TYPE_S ) ; +} + //***************************************************************************** // // Mark the end of the C bindings section for C++ compilers. diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/chipinfo.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/chipinfo.c index d0b00a1..36fdf4f 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/chipinfo.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/chipinfo.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: chipinfo.c -* Revised: 2018-08-17 09:28:06 +0200 (Fri, 17 Aug 2018) -* Revision: 52354 +* Revised: 2020-02-17 10:51:36 +0100 (Mon, 17 Feb 2020) +* Revision: 56781 * * Description: Collection of functions returning chip information. * @@ -142,7 +142,11 @@ ChipInfo_GetChipType( void ) chipType = CHIP_TYPE_CC1352 ; } } else { - chipType = CHIP_TYPE_CC2652 ; + if ( fcfg1Pa ) { + chipType = CHIP_TYPE_CC2652P ; + } else { + chipType = CHIP_TYPE_CC2652 ; + } } break; case 0x9 : diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/chipinfo.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/chipinfo.h index b02d5f8..6986b89 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/chipinfo.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/chipinfo.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: chipinfo.h -* Revised: 2018-06-18 10:26:12 +0200 (Mon, 18 Jun 2018) -* Revision: 52189 +* Revised: 2020-02-17 10:51:36 +0100 (Mon, 17 Feb 2020) +* Revision: 56781 * * Description: Collection of functions returning chip information. * @@ -343,7 +343,8 @@ typedef enum { CHIP_TYPE_CC2652 = 11,//!< 11 means that this is a CC2652 chip. CHIP_TYPE_CC1312 = 12,//!< 12 means that this is a CC1312 chip. CHIP_TYPE_CC1352 = 13,//!< 13 means that this is a CC1352 chip. - CHIP_TYPE_CC1352P = 14 //!< 14 means that this is a CC1352P chip. + CHIP_TYPE_CC1352P = 14,//!< 14 means that this is a CC1352P chip. + CHIP_TYPE_CC2652P = 15 //!< 15 means that this is a CC2652P chip. } ChipType_t; //***************************************************************************** diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/cpu.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/cpu.c index 14d549e..c2d6377 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/cpu.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/cpu.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: cpu.c -* Revised: 2018-05-08 10:04:01 +0200 (Tue, 08 May 2018) -* Revision: 51972 +* Revised: 2019-05-27 15:23:10 +0200 (Mon, 27 May 2019) +* Revision: 55701 * * Description: Instruction wrappers for special CPU instructions needed by * the drivers. @@ -92,7 +92,7 @@ CPUcpsid(void) cpsid i; bx lr } -#elif defined(__TI_COMPILER_VERSION__) +#elif (defined(__TI_COMPILER_VERSION__) || defined(__clang__)) uint32_t CPUcpsid(void) { @@ -161,7 +161,7 @@ CPUprimask(void) mrs r0, PRIMASK; bx lr } -#elif defined(__TI_COMPILER_VERSION__) +#elif (defined(__TI_COMPILER_VERSION__) || defined(__clang__)) uint32_t CPUprimask(void) { @@ -230,7 +230,7 @@ CPUcpsie(void) cpsie i; bx lr } -#elif defined(__TI_COMPILER_VERSION__) +#elif (defined(__TI_COMPILER_VERSION__) || defined(__clang__)) uint32_t CPUcpsie(void) { @@ -299,7 +299,7 @@ CPUbasepriGet(void) mrs r0, BASEPRI; bx lr } -#elif defined(__TI_COMPILER_VERSION__) +#elif (defined(__TI_COMPILER_VERSION__) || defined(__clang__)) uint32_t CPUbasepriGet(void) { @@ -380,6 +380,16 @@ __asm(" .sect \".text:NOROM_CPUdelay\"\n" " subs r0, #1\n" " bne.n NOROM_CPUdelay\n" " bx lr\n"); +#elif defined(__clang__) +void +CPUdelay(uint32_t ui32Count) +{ + // Loop the specified number of times + __asm("CPUdelay:\n" + " subs r0, #1\n" + " bne.n CPUdelay\n" + " bx lr"); +} #else // GCC void __attribute__((naked)) diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/cpu.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/cpu.h index 13fda81..db5e02f 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/cpu.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/cpu.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: cpu.h -* Revised: 2018-06-04 16:10:13 +0200 (Mon, 04 Jun 2018) -* Revision: 52111 +* Revised: 2019-05-27 15:23:10 +0200 (Mon, 27 May 2019) +* Revision: 55701 * * Description: Defines and prototypes for the CPU instruction wrapper * functions. @@ -353,7 +353,7 @@ CPUbasepriSet(uint32_t ui32NewBasepri) msr BASEPRI, r0; bx lr } -#elif defined(__TI_COMPILER_VERSION__) +#elif (defined(__TI_COMPILER_VERSION__) || defined(__clang__)) __STATIC_INLINE void CPUbasepriSet(uint32_t ui32NewBasepri) { diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/crypto.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/crypto.c index 1944f85..4559992 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/crypto.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/crypto.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: crypto.c -* Revised: 2017-12-20 16:40:03 +0100 (Wed, 20 Dec 2017) -* Revision: 50869 +* Revised: 2020-01-07 14:06:28 +0100 (Tue, 07 Jan 2020) +* Revision: 56632 * * Description: Driver for the Crypto module * @@ -853,6 +853,7 @@ CRYPTOCcmInvAuthDecryptResultGet(uint32_t ui32AuthLength, uint32_t ui32TagIndex; uint32_t i; uint32_t ui32Idx; + uint8_t tempResult = 0; ui32TagIndex = ui32CipherTextLength - ui32AuthLength; @@ -883,17 +884,16 @@ CRYPTOCcmInvAuthDecryptResultGet(uint32_t ui32AuthLength, HWREG(CRYPTO_BASE + CRYPTO_O_IRQCLR) = (CRYPTO_IRQCLR_DMA_IN_DONE | CRYPTO_IRQCLR_RESULT_AVAIL); - // Verify the Tag. - for(i = 0; i < ui32AuthLength; i++) - { - if(*((uint8_t *)pui32CcmTag + i) != - (*((uint8_t *)pui32CipherText + ui32TagIndex + i))) - { - return CCM_AUTHENTICATION_FAILED; - } + /* XOR each byte of the computed tag with the provided tag and OR the results. + * If the OR'd result is non-zero, the tags do not match. + * There is no branch based on the content of the buffers here to avoid + * timing attacks. + */ + for (i = 0; i < ui32AuthLength; i++) { + tempResult |= ((uint8_t *) (pui32CipherText))[ui32TagIndex + i] ^ ((uint8_t *)ui32Tag)[i]; } - return AES_SUCCESS; + return tempResult == 0 ? AES_SUCCESS : CCM_AUTHENTICATION_FAILED; } //***************************************************************************** diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ddi.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ddi.h index c4e83e3..90b1ddc 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ddi.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ddi.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: ddi.h -* Revised: 2018-06-04 16:10:13 +0200 (Mon, 04 Jun 2018) -* Revision: 52111 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the DDI master interface. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/driverlib_release.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/driverlib_release.c index cdb08e3..b29e7e6 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/driverlib_release.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/driverlib_release.c @@ -42,4 +42,4 @@ /// Declare the current DriverLib release -DRIVERLIB_DECLARE_RELEASE(0, 54539); +DRIVERLIB_DECLARE_RELEASE(0, 56804); diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/driverlib_release.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/driverlib_release.h index 497f8b0..7af4571 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/driverlib_release.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/driverlib_release.h @@ -63,7 +63,7 @@ extern "C" /// DriverLib release group number #define DRIVERLIB_RELEASE_GROUP 0 /// DriverLib release build number -#define DRIVERLIB_RELEASE_BUILD 54539 +#define DRIVERLIB_RELEASE_BUILD 56804 @@ -83,7 +83,7 @@ extern "C" const volatile uint8_t driverlib_release_##group##_##build /// External declaration of the DriverLib release locking object -extern DRIVERLIB_DECLARE_RELEASE(0, 54539); +extern DRIVERLIB_DECLARE_RELEASE(0, 56804); @@ -135,7 +135,7 @@ extern DRIVERLIB_DECLARE_RELEASE(0, 54539); // //***************************************************************************** #define DRIVERLIB_ASSERT_CURR_RELEASE() \ - DRIVERLIB_ASSERT_RELEASE(0, 54539) + DRIVERLIB_ASSERT_RELEASE(0, 56804) diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/flash.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/flash.c index f51b30f..947163e 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/flash.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/flash.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: flash.c -* Revised: 2017-10-30 13:37:49 +0100 (Mon, 30 Oct 2017) -* Revision: 50105 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for on chip Flash. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/flash.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/flash.h index a44b02d..4091362 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/flash.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/flash.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: flash.h -* Revised: 2017-11-02 16:09:32 +0100 (Thu, 02 Nov 2017) -* Revision: 50166 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the Flash driver. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/interrupt.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/interrupt.h index 3a2d1dd..0a7b3e9 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/interrupt.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/interrupt.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: interrupt.h -* Revised: 2017-11-14 15:26:03 +0100 (Tue, 14 Nov 2017) -* Revision: 50272 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the NVIC Interrupt Controller * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ioc.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ioc.c index d92f811..85a11ff 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ioc.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ioc.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: ioc.c -* Revised: 2017-06-05 12:13:49 +0200 (Mon, 05 Jun 2017) -* Revision: 49096 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for the IOC. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ioc.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ioc.h index 6e4caaa..c052cfd 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ioc.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/ioc.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: ioc.h -* Revised: 2017-11-02 14:16:14 +0100 (Thu, 02 Nov 2017) -* Revision: 50156 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the IO Controller. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/osc.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/osc.c index 1212d01..1b1ab01 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/osc.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/osc.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: osc.c -* Revised: 2019-02-14 09:35:31 +0100 (Thu, 14 Feb 2019) -* Revision: 54539 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for setting up the system Oscillators * @@ -191,38 +191,49 @@ OSCHF_GetStartupTime( uint32_t timeUntilWakeupInMs ) int32_t deltaTempSinceXoscOn ; uint32_t newStartupTimeInUs ; - deltaTimeSinceXoscOnInMs = RTC_CV_TO_MS( AONRTCCurrentCompareValueGet() - oscHfGlobals.timeXoscOn_CV ); - deltaTempSinceXoscOn = AONBatMonTemperatureGetDegC() - oscHfGlobals.tempXoscOff; + // Check CCFG to determine if device is configured for TCXO. + if( ( HWREG( CCFG_BASE + CCFG_O_MODE_CONF ) & CCFG_MODE_CONF_XOSC_FREQ_M ) == CCFG_MODE_CONF_XOSC_FREQ_TCXO ) + { + // Device configured for TCXO. Report fixed startup time located in CCFG with + // coversion from number of 100us to number of us. + newStartupTimeInUs = (( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) & CCFG_MODE_CONF_1_TCXO_MAX_START_M ) >> + CCFG_MODE_CONF_1_TCXO_MAX_START_S ) * 100; + } + else + { + deltaTimeSinceXoscOnInMs = RTC_CV_TO_MS( AONRTCCurrentCompareValueGet() - oscHfGlobals.timeXoscOn_CV ); + deltaTempSinceXoscOn = AONBatMonTemperatureGetDegC() - oscHfGlobals.tempXoscOff; - if ( deltaTempSinceXoscOn < 0 ) { - deltaTempSinceXoscOn = -deltaTempSinceXoscOn; - } + if ( deltaTempSinceXoscOn < 0 ) { + deltaTempSinceXoscOn = -deltaTempSinceXoscOn; + } - if ( (( timeUntilWakeupInMs + deltaTimeSinceXoscOnInMs ) > 3000 ) || - ( deltaTempSinceXoscOn > 5 ) || - ( oscHfGlobals.timeXoscStable_CV < oscHfGlobals.timeXoscOn_CV ) || - ( oscHfGlobals.previousStartupTimeInUs == 0 ) ) - { - newStartupTimeInUs = 2000; - if (( HWREG( CCFG_BASE + CCFG_O_SIZE_AND_DIS_FLAGS ) & CCFG_SIZE_AND_DIS_FLAGS_DIS_XOSC_OVR_M ) == 0 ) { - newStartupTimeInUs = (( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) & - CCFG_MODE_CONF_1_XOSC_MAX_START_M ) >> - CCFG_MODE_CONF_1_XOSC_MAX_START_S ) * 125; - // Note: CCFG startup time is "in units of 100us" adding 25% margin results in *125 - } - } else { - newStartupTimeInUs = RTC_CV_TO_US( oscHfGlobals.timeXoscStable_CV - oscHfGlobals.timeXoscOn_CV ); - newStartupTimeInUs += ( newStartupTimeInUs >> 2 ); // Add 25 percent margin - if ( newStartupTimeInUs < oscHfGlobals.previousStartupTimeInUs ) { - newStartupTimeInUs = oscHfGlobals.previousStartupTimeInUs; - } - } + if ( (( timeUntilWakeupInMs + deltaTimeSinceXoscOnInMs ) > 3000 ) || + ( deltaTempSinceXoscOn > 5 ) || + ( oscHfGlobals.timeXoscStable_CV < oscHfGlobals.timeXoscOn_CV ) || + ( oscHfGlobals.previousStartupTimeInUs == 0 ) ) + { + newStartupTimeInUs = 2000; + if (( HWREG( CCFG_BASE + CCFG_O_SIZE_AND_DIS_FLAGS ) & CCFG_SIZE_AND_DIS_FLAGS_DIS_XOSC_OVR_M ) == 0 ) { + newStartupTimeInUs = (( HWREG( CCFG_BASE + CCFG_O_MODE_CONF_1 ) & + CCFG_MODE_CONF_1_XOSC_MAX_START_M ) >> + CCFG_MODE_CONF_1_XOSC_MAX_START_S ) * 125; + // Note: CCFG startup time is "in units of 100us" adding 25% margin results in *125 + } + } else { + newStartupTimeInUs = RTC_CV_TO_US( oscHfGlobals.timeXoscStable_CV - oscHfGlobals.timeXoscOn_CV ); + newStartupTimeInUs += ( newStartupTimeInUs >> 2 ); // Add 25 percent margin + if ( newStartupTimeInUs < oscHfGlobals.previousStartupTimeInUs ) { + newStartupTimeInUs = oscHfGlobals.previousStartupTimeInUs; + } + } - if ( newStartupTimeInUs < 200 ) { - newStartupTimeInUs = 200; - } - if ( newStartupTimeInUs > 4000 ) { - newStartupTimeInUs = 4000; + if ( newStartupTimeInUs < 200 ) { + newStartupTimeInUs = 200; + } + if ( newStartupTimeInUs > 4000 ) { + newStartupTimeInUs = 4000; + } } return ( newStartupTimeInUs ); } diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/osc.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/osc.h index 52fe0f3..200a92a 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/osc.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/osc.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: osc.h -* Revised: 2019-02-14 09:35:31 +0100 (Thu, 14 Feb 2019) -* Revision: 54539 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the system oscillator control. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pka.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pka.c index 57e4b58..dedbb7d 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pka.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pka.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: pka.c -* Revised: 2018-07-19 15:07:05 +0200 (Thu, 19 Jul 2018) -* Revision: 52294 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for the PKA module * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pka.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pka.h index e175ada..5dcd113 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pka.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pka.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: pka.h -* Revised: 2018-07-19 15:07:05 +0200 (Thu, 19 Jul 2018) -* Revision: 52294 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: PKA header file. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pka_doc.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pka_doc.h index c780a53..db4859a 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pka_doc.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pka_doc.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: pka_doc.h -* Revised: 2017-06-05 12:13:49 +0200 (Mon, 05 Jun 2017) -* Revision: 49096 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Copyright (c) 2015 - 2017, Texas Instruments Incorporated * All rights reserved. diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/prcm.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/prcm.c index e81df8f..b0b9e29 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/prcm.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/prcm.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: prcm.c -* Revised: 2018-10-18 17:33:32 +0200 (Thu, 18 Oct 2018) -* Revision: 52954 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for the PRCM. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/prcm.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/prcm.h index 783ca42..b31cd13 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/prcm.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/prcm.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: prcm.h -* Revised: 2018-10-23 10:19:14 +0200 (Tue, 23 Oct 2018) -* Revision: 52979 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the PRCM * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pwr_ctrl.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pwr_ctrl.c index 92e7955..98fdc54 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pwr_ctrl.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pwr_ctrl.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: pwr_ctrl.c -* Revised: 2017-06-05 12:13:49 +0200 (Mon, 05 Jun 2017) -* Revision: 49096 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Power Control driver. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pwr_ctrl.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pwr_ctrl.h index fe98972..44ade14 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pwr_ctrl.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/pwr_ctrl.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: pwr_ctrl.h -* Revised: 2017-11-02 15:41:14 +0100 (Thu, 02 Nov 2017) -* Revision: 50165 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the System Power Control. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ble_cmd.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ble_cmd.h index d8517d0..e95e127 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ble_cmd.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ble_cmd.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_ble_cmd.h -* Revised: 2018-07-31 20:13:42 +0200 (Tue, 31 Jul 2018) -* Revision: 18572 * * Description: CC13x2/CC26x2 API for Bluetooth Low Energy commands * -* Copyright (c) 2015 - 2017, Texas Instruments Incorporated +* Copyright (c) 2015 - 2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -122,7 +120,7 @@ typedef struct __RFC_STRUCT rfc_ble5RxStatus_s rfc_ble5RxStatus_t; //! \addtogroup bleRadioOp //! @{ struct __RFC_STRUCT rfc_bleRadioOp_s { - uint16_t commandNo; //!< The command ID number + uint16_t commandNo; //!< The command ID number uint16_t status; //!< \brief An integer telling the status of the command. This value is //!< updated by the radio CPU during operation and may be read by the //!< system CPU at any time. @@ -161,7 +159,7 @@ struct __RFC_STRUCT rfc_bleRadioOp_s { //! \addtogroup ble5RadioOp //! @{ struct __RFC_STRUCT rfc_ble5RadioOp_s { - uint16_t commandNo; //!< The command ID number + uint16_t commandNo; //!< The command ID number uint16_t status; //!< \brief An integer telling the status of the command. This value is //!< updated by the radio CPU during operation and may be read by the //!< system CPU at any time. @@ -215,7 +213,7 @@ struct __RFC_STRUCT rfc_ble5RadioOp_s { //! @{ //! Command structure for Bluetooth commands which includes the optional field for 20-dBm PA TX power struct __RFC_STRUCT rfc_ble5Tx20RadioOp_s { - uint16_t commandNo; //!< The command ID number + uint16_t commandNo; //!< The command ID number uint16_t status; //!< \brief An integer telling the status of the command. This value is //!< updated by the radio CPU during operation and may be read by the //!< system CPU at any time. @@ -749,6 +747,9 @@ struct __RFC_STRUCT rfc_CMD_BLE5_RADIO_SETUP_s { //!< Others: Reserved uint16_t bNoFsPowerUp:1; //!< \brief 0: Power up frequency synth
//!< 1: Do not power up frequency synth + uint16_t :1; + uint16_t bSynthNarrowBand:1; //!< \brief 0: Normal synth mode
+ //!< 1: Narrow-band synth mode } config; //!< Configuration options uint16_t txPower; //!< Default transmit power uint32_t* pRegOverrideCommon; //!< \brief Pointer to a list of hardware and configuration registers to override during common @@ -1511,7 +1512,7 @@ struct __RFC_STRUCT rfc_CMD_BLE5_ADV_SCAN_s { //! @{ //! Bluetooth 5 Radio Setup Command for all PHYs with PA Switching Fields struct __RFC_STRUCT rfc_CMD_BLE5_RADIO_SETUP_PA_s { - uint16_t commandNo; //!< The command ID number + uint16_t commandNo; //!< The command ID number uint16_t status; //!< \brief An integer telling the status of the command. This value is //!< updated by the radio CPU during operation and may be read by the //!< system CPU at any time. @@ -1558,6 +1559,9 @@ struct __RFC_STRUCT rfc_CMD_BLE5_RADIO_SETUP_PA_s { //!< Others: Reserved uint16_t bNoFsPowerUp:1; //!< \brief 0: Power up frequency synth
//!< 1: Do not power up frequency synth + uint16_t :1; + uint16_t bSynthNarrowBand:1; //!< \brief 0: Normal synth mode
+ //!< 1: Narrow-band synth mode } config; //!< Configuration options uint16_t txPower; //!< Default transmit power uint32_t* pRegOverrideCommon; //!< \brief Pointer to a list of hardware and configuration registers to override during common diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ble_mailbox.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ble_mailbox.h index b43d099..7331daf 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ble_mailbox.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ble_mailbox.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_ble_mailbox.h -* Revised: 2018-01-15 15:58:36 +0100 (Mon, 15 Jan 2018) -* Revision: 18171 * * Description: Definitions for BLE interface * -* Copyright (c) 2015 - 2017, Texas Instruments Incorporated +* Copyright (c) 2015 - 2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_bt5_coex.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_bt5_coex.h new file mode 100644 index 0000000..14da8b4 --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_bt5_coex.h @@ -0,0 +1,167 @@ +/****************************************************************************** +* Filename: rf_bt5_coex.h +* +* Description: CC13x2/CC26x2 structures for bt5 coexistence support +* +* Copyright (c) 2015 - 2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ + +#ifndef __BT5_COEX_H +#define __BT5_COEX_H + +//! \addtogroup rfCoreHal +//! @{ + +//! \addtogroup bt5_coex +//! @{ + +#include +#include "rf_mailbox.h" + +// Error code for GRANT signal not given +#define BLE_ERROR_NO_GRANT 0x1808 + +typedef struct rfCoreHal_bleCoExConfig_s rfCoreHal_bleCoExConfig_t; + + +//! \addtogroup bleCoExConfig +//! @{ +struct rfCoreHal_bleCoExConfig_s { + struct { + uint8_t bCoExEnable:1; //!< \brief 0: CoEx disabled + //!< 1: CoEx enabled + uint8_t bUseREQUEST:1; //!< \brief 0: REQUEST signal inactive + //!< 1: REQUEST signal active + uint8_t bUseGRANT:1; //!< \brief 0: GRANT signal inactive + //!< 1: GRANT signal active + uint8_t bUsePRIORITY:1; //!< \brief 0: PRIORITY signal inactive + //!< 1: PRIORITY signal active + uint8_t bRequestForChain:1; //!< \brief 0: Deassert REQUEST after each RF command + //!< 1: Keep REQUEST asserted for entire command chain + } coExEnable; + uint8_t coExTxRxIndication; //!< \brief 0 = RX indication is 0, TX indication is 0 + //!< 1 = RX indication is 0, TX indication is 1 + //!< 2 = RX indication is 1, TX indication is 0 + //!< 3 = RX indication is 1, RX indication is 1 + uint16_t priorityIndicationTime; //!< Time (in us) that the PRIORITY signal will indicate the priority. + struct { + uint8_t bRequestAsserted:1; //!< \brief READ ONLY. 0 = REQUEST not asserted, 1 = REQUEST is asserted. + //!< Will indicate if REQUEST would have been asserted, except if signal is not used. + uint8_t bIgnoreGrantInRxAsserted:1;//!< \brief READ ONLY. 0 = GRANT is checked in RX, 1 = GRANT is not checked in RX + //!< Will indicate if the current running command is ignoring GRANT in RX + } rfCoreCoExStatus; + struct { + uint8_t bUseOverridePriority:1; //!< \brief Bit to override default priority + //!< 0: Use default priority + //!< 1: use overridePriority priority for entire chain + uint8_t overridePriority:1; //!< \brief Priority to use if priority is overridden + //!< 0: Low priority if bUseOverridePriority = 1 + //!< 1: High priority if bUseOverridePriority = 1 + uint8_t bUseOverrideRequestForRx:1;//!< \brief Bit to override default request for RX + //!< 0: Use default request for RX + //!< 1: use overrideRequestForRx for entire chain + uint8_t overrideRequestForRx:1; //!< \brief REQUEST signal override if bUseOverrideRequestForRx = 1, used for entire chain + //!< 0: Don't request for RX if bUseOverrideRequestForRx = 1 + //!< 1: Request for RX if bUseOverrideRequestForRx = 1 + } overrideConfig; + struct { + uint8_t defaultPriority:1; //!< \brief 0: Default low priority + //!< 1: Default high priority + uint8_t bAssertRequestForRx:1; //!< \brief Default "request for RX" behaviour + //!< 0: Assert REQUEST for TX operations only + //!< 1: Assert REQUEST for both RX and TX operations + uint8_t bIgnoreGrantInRx:1; //!< \brief 0: Check GRANT in RX and TX + //!< 1: Ignore GRANT in RX, check GRANT in TX. Independent of asserting REQUEST for RX. + uint8_t bKeepRequestIfNoGrant:1; //!< \brief 0: Deassert REQUEST if GRANT was not given + //!< 1: Keep REQUEST asserted if no GRANT was given + } cmdBleMasterSlaveConfig; + struct { + uint8_t defaultPriority:1; //!< \brief 0: Default low priority + //!< 1: Default high priority + uint8_t bAssertRequestForRx:1; //!< \brief Default "request for RX" behaviour + //!< 0: Assert REQUEST for TX operations only + //!< 1: Assert REQUEST for both RX and TX operations + uint8_t bIgnoreGrantInRx:1; //!< \brief 0: Check GRANT in RX and TX + //!< 1: Ignore GRANT in RX, check GRANT in TX. Independent of asserting REQUEST for RX. + uint8_t bKeepRequestIfNoGrant:1; //!< \brief 0: Deassert REQUEST if GRANT was not given + //!< 1: Keep REQUEST asserted if no GRANT was given + } cmdBleAdvConfig; + struct { + uint8_t defaultPriority:1; //!< \brief 0: Default low priority + //!< 1: Default high priority + uint8_t bAssertRequestForRx:1; //!< \brief Default "request for RX" behaviour + //!< 0: Assert REQUEST for TX operations only + //!< 1: Assert REQUEST for both RX and TX operations + uint8_t bIgnoreGrantInRx:1; //!< \brief 0: Check GRANT in RX and TX + //!< 1: Ignore GRANT in RX, check GRANT in TX. Independent of asserting REQUEST for RX. + uint8_t bKeepRequestIfNoGrant:1; //!< \brief 0: Deassert REQUEST if GRANT was not given + //!< 1: Keep REQUEST asserted if no GRANT was given + } cmdBleScanConfig; + struct { + uint8_t defaultPriority:1; //!< \brief 0: Default low priority + //!< 1: Default high priority + uint8_t bAssertRequestForRx:1; //!< \brief Default "request for RX" behaviour + //!< 0: Assert REQUEST for TX operations only + //!< 1: Assert REQUEST for both RX and TX operations + uint8_t bIgnoreGrantInRx:1; //!< \brief 0: Check GRANT in RX and TX + //!< 1: Ignore GRANT in RX, check GRANT in TX. Independent of asserting REQUEST for RX. + uint8_t bKeepRequestIfNoGrant:1; //!< \brief 0: Deassert REQUEST if GRANT was not given + //!< 1: Keep REQUEST asserted if no GRANT was given + } cmdBleInitConfig; + struct { + uint8_t defaultPriority:1; //!< \brief 0: Default low priority + //!< 1: Default high priority + uint8_t bAssertRequestForRx:1; //!< \brief Default "request for RX" behaviour + //!< 0: Assert REQUEST for TX operations only + //!< 1: Assert REQUEST for both RX and TX operations + uint8_t bIgnoreGrantInRx:1; //!< \brief 0: Check GRANT in RX and TX + //!< 1: Ignore GRANT in RX, check GRANT in TX. Independent of asserting REQUEST for RX. + uint8_t bKeepRequestIfNoGrant:1; //!< \brief 0: Deassert REQUEST if GRANT was not given + //!< 1: Keep REQUEST asserted if no GRANT was given + } cmdBleGenericRxConfig; + struct { + uint8_t defaultPriority:1; //!< \brief 0: Default low priority + //!< 1: Default high priority + uint8_t bAssertRequestForRx:1; //!< \brief Default "request for RX" behaviour + //!< 0: Assert REQUEST for TX operations only + //!< 1: Assert REQUEST for both RX and TX operations + uint8_t bIgnoreGrantInRx:1; //!< \brief 0: Check GRANT in RX and TX + //!< 1: Ignore GRANT in RX, check GRANT in TX. Independent of asserting REQUEST for RX. + uint8_t bKeepRequestIfNoGrant:1; //!< \brief 0: Deassert REQUEST if GRANT was not given + //!< 1: Keep REQUEST asserted if no GRANT was given + } cmdBleTxTestConfig; +} ; + +//! @} + +//! @} +//! @} +#endif diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_common_cmd.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_common_cmd.h index b479f88..7e59b5a 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_common_cmd.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_common_cmd.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_common_cmd.h -* Revised: 2018-11-02 11:52:02 +0100 (Fri, 02 Nov 2018) -* Revision: 18756 * * Description: CC13x2/CC26x2 API for common/generic commands * -* Copyright (c) 2015 - 2017, Texas Instruments Incorporated +* Copyright (c) 2015 - 2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -112,7 +110,7 @@ typedef struct __RFC_STRUCT rfc_CMD_SET_CMD_START_IRQ_s rfc_CMD_SET_CMD_START_IR //! \addtogroup command //! @{ struct __RFC_STRUCT rfc_command_s { - uint16_t commandNo; //!< The command ID number + uint16_t commandNo; //!< The command ID number } __RFC_STRUCT_ATTR; //! @} @@ -122,7 +120,7 @@ struct __RFC_STRUCT rfc_command_s { //! Common definition for radio operation commands struct __RFC_STRUCT rfc_radioOp_s { - uint16_t commandNo; //!< The command ID number + uint16_t commandNo; //!< The command ID number uint16_t status; //!< \brief An integer telling the status of the command. This value is //!< updated by the radio CPU during operation and may be read by the //!< system CPU at any time. @@ -221,6 +219,9 @@ struct __RFC_STRUCT rfc_CMD_RADIO_SETUP_s { //!< Others: Reserved uint16_t bNoFsPowerUp:1; //!< \brief 0: Power up frequency synth
//!< 1: Do not power up frequency synth + uint16_t :1; + uint16_t bSynthNarrowBand:1; //!< \brief 0: Normal synth mode
+ //!< 1: Narrow-band synth mode } config; //!< Configuration options uint16_t txPower; //!< Transmit power uint32_t* pRegOverride; //!< \brief Pointer to a list of hardware and configuration registers to override. If NULL, no @@ -676,7 +677,7 @@ struct __RFC_STRUCT rfc_CMD_PATTERN_CHECK_s { //! @{ //! Radio Setup Command for Pre-Defined Schemes with PA Switching Fields struct __RFC_STRUCT rfc_CMD_RADIO_SETUP_PA_s { - uint16_t commandNo; //!< The command ID number + uint16_t commandNo; //!< The command ID number uint16_t status; //!< \brief An integer telling the status of the command. This value is //!< updated by the radio CPU during operation and may be read by the //!< system CPU at any time. @@ -721,6 +722,9 @@ struct __RFC_STRUCT rfc_CMD_RADIO_SETUP_PA_s { //!< Others: Reserved uint16_t bNoFsPowerUp:1; //!< \brief 0: Power up frequency synth
//!< 1: Do not power up frequency synth + uint16_t :1; + uint16_t bSynthNarrowBand:1; //!< \brief 0: Normal synth mode
+ //!< 1: Narrow-band synth mode } config; //!< Configuration options uint16_t txPower; //!< Transmit power uint32_t* pRegOverride; //!< \brief Pointer to a list of hardware and configuration registers to override. If NULL, no diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_data_entry.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_data_entry.h index c79465c..5e77508 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_data_entry.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_data_entry.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_data_entry.h -* Revised: 2018-01-15 06:15:14 +0100 (Mon, 15 Jan 2018) -* Revision: 18170 * * Description: Definition of API for data exchange * -* Copyright (c) 2015 - 2017, Texas Instruments Incorporated +* Copyright (c) 2015 - 2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_hs_cmd.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_hs_cmd.h index e681acc..59def95 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_hs_cmd.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_hs_cmd.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_hs_cmd.h -* Revised: 2018-01-15 06:15:14 +0100 (Mon, 15 Jan 2018) -* Revision: 18170 * * Description: CC13x2/CC26x2 API for high-speed mode commands * -* Copyright (c) 2015 - 2017, Texas Instruments Incorporated +* Copyright (c) 2015 - 2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_hs_mailbox.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_hs_mailbox.h index e1fb7a0..eb8fecf 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_hs_mailbox.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_hs_mailbox.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_hs_mailbox.h -* Revised: 2018-01-15 15:58:36 +0100 (Mon, 15 Jan 2018) -* Revision: 18171 * * Description: Definitions for high-speed mode radio interface * -* Copyright (c) 2015 - 2017, Texas Instruments Incorporated +* Copyright (c) 2015 - 2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ieee_cmd.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ieee_cmd.h index f33facd..2d1cc8d 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ieee_cmd.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ieee_cmd.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_ieee_cmd.h -* Revised: 2018-01-15 06:15:14 +0100 (Mon, 15 Jan 2018) -* Revision: 18170 * * Description: CC13x2/CC26x2 API for IEEE 802.15.4 commands * -* Copyright (c) 2015 - 2017, Texas Instruments Incorporated +* Copyright (c) 2015 - 2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ieee_mailbox.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ieee_mailbox.h index a9fc221..bfb731b 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ieee_mailbox.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_ieee_mailbox.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_ieee_mailbox.h -* Revised: 2018-01-23 19:51:42 +0100 (Tue, 23 Jan 2018) -* Revision: 18189 * * Description: Definitions for IEEE 802.15.4 interface * -* Copyright (c) 2015 - 2017, Texas Instruments Incorporated +* Copyright (c) 2015 - 2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,7 +54,7 @@ #define IEEE_DONE_ACKPEND 0x2404 ///< ACK packet received with pending data bit set #define IEEE_DONE_TIMEOUT 0x2405 ///< Operation ended due to timeout #define IEEE_DONE_BGEND 0x2406 ///< FG operation ended because necessary background level - ///< operation ended + ///< operation ended #define IEEE_DONE_ABORT 0x2407 ///< Operation aborted by command ///@} /// \name Operation finished with error diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_mailbox.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_mailbox.h index a23d71a..057fca6 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_mailbox.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_mailbox.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_mailbox.h -* Revised: 2018-11-02 11:52:02 +0100 (Fri, 02 Nov 2018) -* Revision: 18756 * * Description: Definitions for interface between system and radio CPU * -* Copyright (c) 2015 - 2017, Texas Instruments Incorporated +* Copyright (c) 2015 - 2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_prop_cmd.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_prop_cmd.h index 6dbccd6..db404ba 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_prop_cmd.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_prop_cmd.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_prop_cmd.h -* Revised: 2018-07-31 20:13:42 +0200 (Tue, 31 Jul 2018) -* Revision: 18572 * * Description: CC13x2/CC26x2 API for Proprietary mode commands * -* Copyright (c) 2015 - 2017, Texas Instruments Incorporated +* Copyright (c) 2015 - 2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -545,6 +543,9 @@ struct __RFC_STRUCT rfc_CMD_PROP_RADIO_SETUP_s { //!< Others: Reserved uint16_t bNoFsPowerUp:1; //!< \brief 0: Power up frequency synth
//!< 1: Do not power up frequency synth + uint16_t :1; + uint16_t bSynthNarrowBand:1; //!< \brief 0: Normal synth mode
+ //!< 1: Narrow-band synth mode } config; //!< Configuration options uint16_t txPower; //!< Transmit power uint32_t* pRegOverride; //!< \brief Pointer to a list of hardware and configuration registers to override. If NULL, no @@ -648,6 +649,9 @@ struct __RFC_STRUCT rfc_CMD_PROP_RADIO_DIV_SETUP_s { //!< Others: Reserved uint16_t bNoFsPowerUp:1; //!< \brief 0: Power up frequency synth
//!< 1: Do not power up frequency synth + uint16_t :1; + uint16_t bSynthNarrowBand:1; //!< \brief 0: Normal synth mode
+ //!< 1: Narrow-band synth mode } config; //!< Configuration options uint16_t txPower; //!< Transmit power uint32_t* pRegOverride; //!< \brief Pointer to a list of hardware and configuration registers to override. If NULL, no @@ -894,7 +898,7 @@ struct __RFC_STRUCT rfc_CMD_PROP_RX_ADV_SNIFF_s { //! @{ //! Proprietary Mode Radio Setup Command for 2.4 GHz with PA Switching Fields struct __RFC_STRUCT rfc_CMD_PROP_RADIO_SETUP_PA_s { - uint16_t commandNo; //!< The command ID number + uint16_t commandNo; //!< The command ID number uint16_t status; //!< \brief An integer telling the status of the command. This value is //!< updated by the radio CPU during operation and may be read by the //!< system CPU at any time. @@ -984,6 +988,9 @@ struct __RFC_STRUCT rfc_CMD_PROP_RADIO_SETUP_PA_s { //!< Others: Reserved uint16_t bNoFsPowerUp:1; //!< \brief 0: Power up frequency synth
//!< 1: Do not power up frequency synth + uint16_t :1; + uint16_t bSynthNarrowBand:1; //!< \brief 0: Normal synth mode
+ //!< 1: Narrow-band synth mode } config; //!< Configuration options uint16_t txPower; //!< Transmit power uint32_t* pRegOverride; //!< \brief Pointer to a list of hardware and configuration registers to override. If NULL, no @@ -1000,7 +1007,7 @@ struct __RFC_STRUCT rfc_CMD_PROP_RADIO_SETUP_PA_s { //! @{ //! Proprietary Mode Radio Setup Command for All Frequency Bands with PA Switching Fields struct __RFC_STRUCT rfc_CMD_PROP_RADIO_DIV_SETUP_PA_s { - uint16_t commandNo; //!< The command ID number + uint16_t commandNo; //!< The command ID number uint16_t status; //!< \brief An integer telling the status of the command. This value is //!< updated by the radio CPU during operation and may be read by the //!< system CPU at any time. @@ -1090,6 +1097,9 @@ struct __RFC_STRUCT rfc_CMD_PROP_RADIO_DIV_SETUP_PA_s { //!< Others: Reserved uint16_t bNoFsPowerUp:1; //!< \brief 0: Power up frequency synth
//!< 1: Do not power up frequency synth + uint16_t :1; + uint16_t bSynthNarrowBand:1; //!< \brief 0: Normal synth mode
+ //!< 1: Narrow-band synth mode } config; //!< Configuration options uint16_t txPower; //!< Transmit power uint32_t* pRegOverride; //!< \brief Pointer to a list of hardware and configuration registers to override. If NULL, no diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_prop_mailbox.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_prop_mailbox.h index 6819d8c..9e811f3 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_prop_mailbox.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rf_prop_mailbox.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_prop_mailbox.h -* Revised: 2018-01-15 15:58:36 +0100 (Mon, 15 Jan 2018) -* Revision: 18171 * * Description: Definitions for proprietary mode radio interface * -* Copyright (c) 2015 - 2017, Texas Instruments Incorporated +* Copyright (c) 2015 - 2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rfc.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rfc.h index 00d8f18..dc9d98c 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rfc.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rfc.h @@ -59,13 +59,14 @@ extern "C" #include #include -#include "../inc/hw_types.h" -#include "../inc/hw_memmap.h" -#include "../inc/hw_rfc_pwr.h" -#include "../inc/hw_rfc_dbell.h" -#include "../inc/hw_fcfg1.h" -#include "../inc/hw_adi_3_refsys.h" -#include "../inc/hw_adi.h" +#include +#include DeviceFamily_constructPath(inc/hw_types.h) +#include DeviceFamily_constructPath(inc/hw_memmap.h) +#include DeviceFamily_constructPath(inc/hw_rfc_pwr.h) +#include DeviceFamily_constructPath(inc/hw_rfc_dbell.h) +#include DeviceFamily_constructPath(inc/hw_fcfg1.h) +#include DeviceFamily_constructPath(inc/hw_adi_3_refsys.h) +#include DeviceFamily_constructPath(inc/hw_adi.h) #include "rf_common_cmd.h" #include "rf_prop_cmd.h" #include "rf_ble_cmd.h" @@ -80,9 +81,9 @@ typedef struct { // Definition of maximum search depth used by the RFCOverrideUpdate function #define RFC_MAX_SEARCH_DEPTH 5 -#define RFC_PA_TYPE_ADDRESS 0x21000345 +#define RFC_PA_TYPE_ADDRESS 0x21000385 #define RFC_PA_TYPE_MASK 0x04 -#define RFC_PA_GAIN_ADDRESS 0x2100034C +#define RFC_PA_GAIN_ADDRESS 0x21000398 #define RFC_PA_GAIN_MASK 0x003FFFFF #define RFC_FE_MODE_ESCAPE_VALUE 0xFF #define RFC_FE_OVERRIDE_ADDRESS 0x0703 @@ -411,7 +412,7 @@ extern uint32_t RFCAnaDivTxOverride(uint8_t loDivider, uint8_t frontEndMode); // //***************************************************************************** #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN) - #include "../driverlib/rom.h" + #include DeviceFamily_constructPath(driverlib/rom.h) #ifdef ROM_RFCCpeIntGetAndClear #undef RFCCpeIntGetAndClear #define RFCCpeIntGetAndClear ROM_RFCCpeIntGetAndClear diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rom.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rom.h index fc79556..f715712 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rom.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rom.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: rom.h -* Revised: 2018-11-02 13:54:49 +0100 (Fri, 02 Nov 2018) -* Revision: 53196 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Prototypes for the ROM utility functions. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rom_crypto.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rom_crypto.c index 2f284cd..4fcb5a7 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rom_crypto.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rom_crypto.c @@ -1,7 +1,7 @@ /******************************************************************************* * Filename: rom_crypto.c -* Revised: 2018-09-17 08:57:21 +0200 (Mon, 17 Sep 2018) -* Revision: 52619 +* Revised: 2020-02-14 14:37:11 +0100 (Fri, 14 Feb 2020) +* Revision: 56770 * * Description: This is the implementation for the API to the ECC functions * built into ROM on the CC13x2/CC26x2. diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rom_crypto.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rom_crypto.h index eecafac..cea4460 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rom_crypto.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/rom_crypto.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: rom_crypto.h -* Revised: 2018-09-17 09:24:56 +0200 (Mon, 17 Sep 2018) -* Revision: 52624 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: This header file is the API to the crypto functions * built into ROM on the CC13xx/CC26xx. diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/setup.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/setup.c index 1f438be..37b49f9 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/setup.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/setup.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: setup.c -* Revised: 2018-11-06 15:08:57 +0100 (Tue, 06 Nov 2018) -* Revision: 53239 +* Revised: 2020-02-14 13:45:15 +0100 (Fri, 14 Feb 2020) +* Revision: 56765 * * Description: Setup file for CC13xx/CC26xx devices. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/setup_rom.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/setup_rom.c index 745204b..d8a3ab4 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/setup_rom.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/setup_rom.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: setup_rom.c -* Revised: 2017-11-02 11:31:15 +0100 (Thu, 02 Nov 2017) -* Revision: 50143 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Setup file for CC13xx/CC26xx devices. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/setup_rom.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/setup_rom.h index e06ba29..bc13598 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/setup_rom.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/setup_rom.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: setup_rom.h -* Revised: 2018-10-24 11:23:04 +0200 (Wed, 24 Oct 2018) -* Revision: 52993 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Prototypes and defines for the setup API. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sha2.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sha2.c index 814e737..bf928d1 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sha2.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sha2.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: sha2.c -* Revised: 2018-04-17 15:57:27 +0200 (Tue, 17 Apr 2018) -* Revision: 51892 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for the SHA-2 functions of the crypto module * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sha2.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sha2.h index 4910222..e51f333 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sha2.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sha2.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: sha2.h -* Revised: 2018-04-17 16:04:03 +0200 (Tue, 17 Apr 2018) -* Revision: 51893 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: SHA-2 header file. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sha2_doc.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sha2_doc.h index 2ca7c75..054762e 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sha2_doc.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sha2_doc.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: sha2_doc.h -* Revised: 2017-11-01 10:33:37 +0100 (Wed, 01 Nov 2017) -* Revision: 50125 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Copyright (c) 2015 - 2017, Texas Instruments Incorporated * All rights reserved. diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sys_ctrl.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sys_ctrl.c index 1dd35f4..a431f53 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sys_ctrl.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sys_ctrl.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: sys_ctrl.c -* Revised: 2018-06-26 15:19:11 +0200 (Tue, 26 Jun 2018) -* Revision: 52220 +* Revised: 2020-02-18 14:05:12 +0100 (Tue, 18 Feb 2020) +* Revision: 56796 * * Description: Driver for the System Control. * @@ -160,6 +160,10 @@ void SysCtrlStandby(bool retainCache, uint32_t vimsPdMode, uint32_t rechargeMode { uint32_t modeVIMS; + // Handle compensation for improving RCOSC_LF stability at low temperatures + // as configured in CCFG + SysCtrlSetRechargeBeforePowerDown(XOSC_IN_HIGH_POWER_MODE); + // Freeze the IOs on the boundary between MCU and AON AONIOCFreezeEnable(); diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sys_ctrl.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sys_ctrl.h index 6dbe831..b6ed530 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sys_ctrl.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/sys_ctrl.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: sys_ctrl.h -* Revised: 2018-09-17 14:58:51 +0200 (Mon, 17 Sep 2018) -* Revision: 52634 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the System Controller. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/uart.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/uart.c index d9f493b..c6112b4 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/uart.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/uart.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: uart.c -* Revised: 2017-06-05 12:13:49 +0200 (Mon, 05 Jun 2017) -* Revision: 49096 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for the UART. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/uart.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/uart.h index 82ec130..22f76f5 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/uart.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/uart.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: uart.h -* Revised: 2017-06-05 12:13:49 +0200 (Mon, 05 Jun 2017) -* Revision: 49096 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the UART. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/udma.h b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/udma.h index 510691b..8cf2e33 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/udma.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/udma.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: udma.h -* Revised: 2017-05-23 12:08:52 +0200 (Tue, 23 May 2017) -* Revision: 49048 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines and prototypes for the uDMA controller. * @@ -294,6 +294,8 @@ tDMAControlTable; #define UDMA_CHAN_UART0_TX 2 // UART0 RX Data #define UDMA_CHAN_SSI0_RX 3 // SSI0 RX Data #define UDMA_CHAN_SSI0_TX 4 // SSI0 RX Data +#define UDMA_CHAN_UART1_RX 5 // UART1 RX Data +#define UDMA_CHAN_UART1_TX 6 // UART1 Tx Data #define UDMA_CHAN_AUX_ADC 7 // AUX ADC event #define UDMA_CHAN_AUX_SW 8 // AUX Software event #define UDMA_CHAN_TIMER0_A 9 // Timer0 A event diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/vims.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/vims.c index a80d44e..b206c22 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/vims.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/vims.c @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: vims.c -* Revised: 2017-06-05 12:13:49 +0200 (Mon, 05 Jun 2017) -* Revision: 49096 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Driver for the VIMS. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/watchdog.c b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/watchdog.c index 2cac28c..3527cff 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/watchdog.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/driverlib/watchdog.c @@ -36,6 +36,6 @@ * ******************************************************************************/ -#include +#include "watchdog.h" // See watchdog.h for implementation diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_ccfg.h b/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_ccfg.h index 568eca0..51b2237 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_ccfg.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_ccfg.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: hw_ccfg_h -* Revised: 2018-10-19 08:48:09 +0200 (Fri, 19 Oct 2018) -* Revision: 52957 +* Revised: 2019-04-01 09:23:38 +0200 (Mon, 01 Apr 2019) +* Revision: 55513 * * Copyright (c) 2015 - 2017, Texas Instruments Incorporated * All rights reserved. @@ -139,6 +139,28 @@ // Register: CCFG_O_MODE_CONF_1 // //***************************************************************************** +// Field: [31] TCXO_TYPE +// +// Selects the TCXO type. +// +// 0: CMOS type. Internal common-mode bias will not be enabled. +// 1: Clipped-sine type. Internal common-mode bias will be enabled when TCXO is +// used. +// +// Bit field value is only valid if MODE_CONF.XOSC_FREQ=0. +#define CCFG_MODE_CONF_1_TCXO_TYPE 0x80000000 +#define CCFG_MODE_CONF_1_TCXO_TYPE_BITN 31 +#define CCFG_MODE_CONF_1_TCXO_TYPE_M 0x80000000 +#define CCFG_MODE_CONF_1_TCXO_TYPE_S 31 + +// Field: [30:24] TCXO_MAX_START +// +// Maximum TCXO startup time in units of 100us. +// Bit field value is only valid if MODE_CONF.XOSC_FREQ=0. +#define CCFG_MODE_CONF_1_TCXO_MAX_START_W 7 +#define CCFG_MODE_CONF_1_TCXO_MAX_START_M 0x7F000000 +#define CCFG_MODE_CONF_1_TCXO_MAX_START_S 24 + // Field: [23:20] ALT_DCDC_VMIN // // Minimum voltage for when DC/DC should be used if alternate DC/DC setting is @@ -173,12 +195,12 @@ // Inductor peak current if alternate DC/DC setting is enabled // (SIZE_AND_DIS_FLAGS.DIS_ALT_DCDC_SETTING=0). Assuming 10uH external // inductor! -// Peak current = 31 + ( 4 * ALT_DCDC_IPEAK ) : -// 0: 31mA (min) +// +// 0: 46mA (min) // ... -// 4: 47mA +// 4: 70mA // ... -// 7: 59mA (max) +// 7: 87mA (max) #define CCFG_MODE_CONF_1_ALT_DCDC_IPEAK_W 3 #define CCFG_MODE_CONF_1_ALT_DCDC_IPEAK_M 0x00070000 #define CCFG_MODE_CONF_1_ALT_DCDC_IPEAK_S 16 @@ -232,11 +254,7 @@ // Field: [3] DIS_TCXO // -// Disable TCXO. -// 0: TCXO functionality enabled. -// 1: TCXO functionality disabled. -// Note: -// An external TCXO is required if DIS_TCXO = 0. +// Deprecated. Must be set to 1. #define CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO 0x00000008 #define CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO_BITN 3 #define CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO_M 0x00000008 @@ -368,16 +386,16 @@ // EXT_LF_CLK.DIO. The RTC tick speed // AON_RTC:SUBSECINC is updated to // EXT_LF_CLK.RTC_INCREMENT (done in the -// trimDevice() xxWare boot function). External -// clock must always be running when the chip is -// in standby for VDDR recharge timing. -// XOSC_HF_DLF 31.25kHz clock derived from 24MHz XOSC (dividing -// by 768 in HW). The RTC tick speed -// [AON_RTC.SUBSECINC.*] is updated to 0x8637BD, -// corresponding to a 31.25kHz clock (done in the -// trimDevice() xxWare boot function). Standby -// power mode is not supported when using this -// clock source. +// SetupTrimDevice() driverlib boot function). +// External clock must always be running when the +// chip is in standby for VDDR recharge timing. +// XOSC_HF_DLF 31.25kHz clock derived from 48MHz XOSC or HPOSC. +// The RTC tick speed AON_RTC:SUBSECINC is updated +// to 0x8637BD, corresponding to a 31.25kHz clock +// (done in the SetupTrimDevice() driverlib boot +// function). The device must be blocked from +// entering Standby mode when using this clock +// source. #define CCFG_MODE_CONF_SCLK_LF_OPTION_W 2 #define CCFG_MODE_CONF_SCLK_LF_OPTION_M 0x00C00000 #define CCFG_MODE_CONF_SCLK_LF_OPTION_S 22 @@ -415,17 +433,23 @@ // Field: [19:18] XOSC_FREQ // -// Selects high precision HF oscillator (activated when using the radio). +// Selects which high frequency oscillator is used (required for radio usage). // ENUMs: -// 24M 24 MHz XOSC_HF +// 24M 24 MHz XOSC_HF. Not supported. // 48M 48 MHz XOSC_HF -// HPOSC HPOSC +// HPOSC Internal high precision oscillator. +// TCXO External 48Mhz TCXO. +// Refer to +// MODE_CONF_1.TCXO_MAX_START and +// MODE_CONF_1.TCXO_TYPE bit fields for additional +// configuration of TCXO. #define CCFG_MODE_CONF_XOSC_FREQ_W 2 #define CCFG_MODE_CONF_XOSC_FREQ_M 0x000C0000 #define CCFG_MODE_CONF_XOSC_FREQ_S 18 #define CCFG_MODE_CONF_XOSC_FREQ_24M 0x000C0000 #define CCFG_MODE_CONF_XOSC_FREQ_48M 0x00080000 #define CCFG_MODE_CONF_XOSC_FREQ_HPOSC 0x00040000 +#define CCFG_MODE_CONF_XOSC_FREQ_TCXO 0x00000000 // Field: [17] XOSC_CAP_MOD // diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_chip_def.h b/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_chip_def.h index 19f70e0..9801825 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_chip_def.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_chip_def.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: hw_chip_def.h -* Revised: 2017-06-26 09:33:33 +0200 (Mon, 26 Jun 2017) -* Revision: 49227 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Description: Defines for device properties. * diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_ddi.h b/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_ddi.h index fc93c11..c2d5234 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_ddi.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_ddi.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: hw_ddi.h -* Revised: 2017-06-05 12:13:49 +0200 (Mon, 05 Jun 2017) -* Revision: 49096 +* Revised: 2020-02-14 11:30:20 +0100 (Fri, 14 Feb 2020) +* Revision: 56760 * * Copyright (c) 2015 - 2017, Texas Instruments Incorporated * All rights reserved. diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_ddi_0_osc.h b/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_ddi_0_osc.h index ee49e27..51b710c 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_ddi_0_osc.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/inc/hw_ddi_0_osc.h @@ -1,7 +1,7 @@ /****************************************************************************** * Filename: hw_ddi_0_osc_h -* Revised: 2018-05-14 12:24:52 +0200 (Mon, 14 May 2018) -* Revision: 51990 +* Revised: 2019-03-08 14:23:17 +0100 (Fri, 08 Mar 2019) +* Revision: 55206 * * Copyright (c) 2015 - 2017, Texas Instruments Incorporated * All rights reserved. @@ -151,7 +151,10 @@ // Field: [14] HPOSC_MODE_EN // -// Internal. Only to be used through TI provided API. +// 0: HPOSC mode is not enabled. The 48 MHz crystal is required for radio +// operation. +// 1: Enables HPOSC mode. The internal HPOSC can be used as HF system clock and +// for radio operation. #define DDI_0_OSC_CTL0_HPOSC_MODE_EN 0x00004000 #define DDI_0_OSC_CTL0_HPOSC_MODE_EN_M 0x00004000 #define DDI_0_OSC_CTL0_HPOSC_MODE_EN_S 14 @@ -243,7 +246,8 @@ // XOSCLF Low frequency XOSC // RCOSCLF Low frequency RCOSC // XOSCHFDLF Low frequency clock derived from High Frequency -// XOSC +// XOSC or HPOSC clk (use HPOSC when HPOSC_MODE_EN +// = 1) // RCOSCHFDLF Low frequency clock derived from High Frequency // RCOSC #define DDI_0_OSC_CTL0_SCLK_LF_SRC_SEL_W 2 @@ -258,7 +262,8 @@ // // Source select for sclk_hf. // ENUMs: -// XOSC High frequency XOSC clock +// XOSC High frequency XOSC or HPOSC clk (use HPOSC when +// HPOSC_MODE_EN = 1 // RCOSC High frequency RCOSC clock #define DDI_0_OSC_CTL0_SCLK_HF_SRC_SEL 0x00000001 #define DDI_0_OSC_CTL0_SCLK_HF_SRC_SEL_M 0x00000001 diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_bt5.c b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_bt5.c new file mode 100644 index 0000000..412a82d --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_bt5.c @@ -0,0 +1,457 @@ +/****************************************************************************** +* Filename: rf_patch_cpe_bt5.c +* +* Description: RF core patch for Bluetooth 5 support ("BLE" and "BLE5" API command sets) in CC13x2 and CC26x2 +* +* Copyright (c) 2015-2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ +//***************************************************************************** +// +// If building with a C++ compiler, make all of the definitions in this header +// have a C binding. +// +//***************************************************************************** +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +#include "rf_patch_cpe_bt5.h" + +#ifndef CPE_PATCH_TYPE +#define CPE_PATCH_TYPE static const uint32_t +#endif + +#ifndef SYS_PATCH_TYPE +#define SYS_PATCH_TYPE static const uint32_t +#endif + +#ifndef PATCH_FUN_SPEC +#define PATCH_FUN_SPEC static +#endif + +#ifndef _APPLY_PATCH_TAB +#define _APPLY_PATCH_TAB +#endif + + +CPE_PATCH_TYPE patchImageBt5[] = { + 0x21004325, + 0x21004075, + 0x21004091, + 0x21004399, + 0x210043d5, + 0x210040c1, + 0x210040cd, + 0x210040d9, + 0x21004461, + 0x2100410d, + 0xd00507db, + 0xf803f000, + 0x70084902, + 0xb570bd70, + 0x47284d01, + 0x210004e0, + 0x0002241d, + 0x79654c07, + 0xf809f000, + 0x40697961, + 0xd5030749, + 0x4a042101, + 0x60110389, + 0xb570bd70, + 0x47084902, + 0x21000380, + 0x40041108, + 0x0000592d, + 0x4700b570, + 0xf9b0f000, + 0x47004800, + 0x00007f57, + 0xf9b0f000, + 0x47004800, + 0x0000881b, + 0x0a9b9b03, + 0x2b834d08, + 0x4c08d10a, + 0x069b8923, + 0xb407d506, + 0xf805f000, + 0xd0002800, + 0xbc073542, + 0xb5704728, + 0x47004802, + 0x00020b1f, + 0x21000160, + 0x000209eb, + 0x4a094808, + 0x429a6803, + 0x4808d10a, + 0x4b088902, + 0xd0011ad2, + 0xd1032a01, + 0x49066e40, + 0x99034788, + 0x47184b05, + 0x210002a8, + 0x000203bd, + 0x21000160, + 0x00001821, + 0x000035f1, + 0x000006bd, + 0x4c86b510, + 0x31404621, + 0x28017d08, + 0x4884d134, + 0x08407dc0, + 0xd02f07c0, + 0x30604620, + 0x08527942, + 0xd02907d2, + 0x0b808940, + 0xd1252801, + 0x09417e08, + 0xd00c07c9, + 0x07006fa1, + 0x0fc08809, + 0x04090240, + 0x66604308, + 0x1c806fa0, + 0xf968f000, + 0x4874e013, + 0x69803020, + 0x28006840, + 0x4a72d00e, + 0x78012300, + 0x1a5956d3, + 0x00c9d408, + 0x78411808, + 0xd00307c9, + 0x66616801, + 0x66a06840, + 0x4780486b, + 0xb5f8bd10, + 0x496a4c66, + 0x36204626, + 0x46257b70, + 0x90003540, + 0x00b8792f, + 0x68801840, + 0x28004780, + 0x4960d128, + 0x09097dc9, + 0xd02307c9, + 0x32644622, + 0xd0202f15, + 0x23007e29, + 0x07ff094f, + 0x7d6dd003, + 0xd0002d00, + 0x9f002301, + 0x43bb6fa5, + 0x7b73d012, + 0xd00f2b00, + 0x065b7d23, + 0x88d2d50c, + 0x2a010b92, + 0x08c9d108, + 0xd00507c9, + 0x0b8988a9, + 0xd1012901, + 0x73712100, + 0x7eabbdf8, + 0x2b017de9, + 0x2300d0e3, + 0xb570e7e1, + 0x46254c46, + 0x35806a60, + 0xd11d2800, + 0x5d002054, + 0x28002200, + 0x2064d017, + 0x08805d00, + 0xd01207c0, + 0x888868a9, + 0x28010b80, + 0x483dd10d, + 0x08407dc0, + 0xd00807c0, + 0x3020483a, + 0x68006980, + 0xd0022800, + 0x60a86229, + 0x622ae000, + 0x47804839, + 0x29006a61, + 0x6a29d103, + 0xd0002900, + 0xbd7060a9, + 0x4c2fb5f8, + 0x46204934, + 0x7d023040, + 0xd02f2a00, + 0x46257e80, + 0x28033580, + 0x2804d002, + 0xe027d003, + 0x75e82001, + 0x2064e024, + 0x08805d00, + 0xd01f07c0, + 0x888068a8, + 0x28010b80, + 0x4822d11a, + 0x7dc07dea, + 0xd0132a00, + 0x07c008c0, + 0x4626d012, + 0x7b773620, + 0x46014788, + 0xd1084339, + 0x06097d21, + 0x8869d505, + 0x29010b89, + 0x2100d101, + 0xbdf87371, + 0xe7ea0880, + 0xbdf84788, + 0x30804812, + 0x75c12100, + 0x47004817, + 0x3140490f, + 0x28267108, + 0xdc06d014, + 0xd0132815, + 0xd00b281b, + 0xd104281f, + 0x283de00a, + 0x2847d00e, + 0x490bd00a, + 0x18400080, + 0x47706880, + 0x4770480c, + 0x4770480c, + 0x4770480c, + 0x4770480c, + 0x4770480c, + 0x21000160, + 0x210000c8, + 0x210004e0, + 0x00024959, + 0x00025500, + 0x00023d8f, + 0x00023075, + 0x00022a15, + 0x21004319, + 0x210042a5, + 0x21004247, + 0x210041c7, + 0x21004149, + 0x490cb510, + 0x4a0c4788, + 0x5e512106, + 0xd0072900, + 0xd0052902, + 0xd0032909, + 0xd0012910, + 0xd1072911, + 0x43c92177, + 0xdd014288, + 0xdd012800, + 0x43c0207f, + 0x0000bd10, + 0x000065a9, + 0x21000380, + 0x4810b510, + 0x481088c1, + 0xd0182905, + 0x68214c0f, + 0x0052084a, + 0x6ba26022, + 0x00520852, + 0x602163a2, + 0xfe62f7ff, + 0x07006ba0, + 0x2001d408, + 0x60606020, + 0x1c402000, + 0xdbfc280c, + 0x62202014, + 0xf7ffbd10, + 0xbd10fe53, + 0x21000380, + 0x00005b3f, + 0x40046000, + 0x490c6b80, + 0x0f000700, + 0x47707148, + 0x490a4a09, + 0x79502318, + 0x7e4956cb, + 0x428118c0, + 0x4608dd01, + 0x280fe002, + 0x200fdd00, + 0x090989d1, + 0x43010109, + 0x477081d1, + 0x210002e0, + 0x21000088, + 0x47702000, + 0x07810882, + 0x0ec90092, + 0x78c0ca0c, + 0x424940ca, + 0x408b3120, + 0x0211431a, + 0x06000a09, + 0x47704308, +}; +#define _NWORD_PATCHIMAGE_BT5 270 + +CPE_PATCH_TYPE patchCpeHd[] = { + 0x00000000, +}; +#define _NWORD_PATCHCPEHD_BT5 1 + +#define _NWORD_PATCHSYS_BT5 0 + + + +#ifndef _BT5_SYSRAM_START +#define _BT5_SYSRAM_START 0x20000000 +#endif + +#ifndef _BT5_CPERAM_START +#define _BT5_CPERAM_START 0x21000000 +#endif + +#define _BT5_SYS_PATCH_FIXED_ADDR 0x20000000 + +#define _BT5_PATCH_VEC_ADDR_OFFSET 0x03D0 +#define _BT5_PATCH_TAB_OFFSET 0x03D4 +#define _BT5_IRQPATCH_OFFSET 0x0480 +#define _BT5_PATCH_VEC_OFFSET 0x404C + +#define _BT5_PATCH_CPEHD_OFFSET 0x04E0 + +#ifndef _BT5_NO_PROG_STATE_VAR +static uint8_t bBt5PatchEntered = 0; +#endif + +PATCH_FUN_SPEC void enterBt5CpePatch(void) +{ +#if (_NWORD_PATCHIMAGE_BT5 > 0) + uint32_t *pPatchVec = (uint32_t *) (_BT5_CPERAM_START + _BT5_PATCH_VEC_OFFSET); + + memcpy(pPatchVec, patchImageBt5, sizeof(patchImageBt5)); +#endif +} + +PATCH_FUN_SPEC void enterBt5CpeHdPatch(void) +{ +#if (_NWORD_PATCHCPEHD_BT5 > 0) + uint32_t *pPatchCpeHd = (uint32_t *) (_BT5_CPERAM_START + _BT5_PATCH_CPEHD_OFFSET); + + memcpy(pPatchCpeHd, patchCpeHd, sizeof(patchCpeHd)); +#endif +} + +PATCH_FUN_SPEC void enterBt5SysPatch(void) +{ +} + +PATCH_FUN_SPEC void configureBt5Patch(void) +{ + uint8_t *pPatchTab = (uint8_t *) (_BT5_CPERAM_START + _BT5_PATCH_TAB_OFFSET); + + + pPatchTab[1] = 0; + pPatchTab[21] = 1; + pPatchTab[76] = 2; + pPatchTab[91] = 3; + pPatchTab[79] = 4; + pPatchTab[140] = 5; + pPatchTab[150] = 6; + pPatchTab[13] = 7; + pPatchTab[31] = 8; + pPatchTab[40] = 9; +} + +PATCH_FUN_SPEC void applyBt5Patch(void) +{ +#ifdef _BT5_NO_PROG_STATE_VAR + enterBt5SysPatch(); + enterBt5CpePatch(); +#else + if (!bBt5PatchEntered) + { + enterBt5SysPatch(); + enterBt5CpePatch(); + bBt5PatchEntered = 1; + } +#endif + enterBt5CpeHdPatch(); + configureBt5Patch(); +} + +void refreshBt5Patch(void) +{ + enterBt5CpeHdPatch(); + configureBt5Patch(); +} + +void cleanBt5Patch(void) +{ +#ifndef _BT5_NO_PROG_STATE_VAR + bBt5PatchEntered = 0; +#endif +} + +void rf_patch_cpe_bt5(void) +{ + applyBt5Patch(); +} + + +//***************************************************************************** +// +// Mark the end of the C bindings section for C++ compilers. +// +//***************************************************************************** +#ifdef __cplusplus +} +#endif + + diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_bt5.h b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_bt5.h index b293749..4e6340f 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_bt5.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_bt5.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_patch_cpe_bt5.h -* Revised: $Date: 2019-02-27 16:13:01 +0100 (on, 27 feb 2019) $ -* Revision: $Revision: 18889 $ * * Description: RF core patch for Bluetooth 5 support ("BLE" and "BLE5" API command sets) in CC13x2 and CC26x2 * -* Copyright (c) 2015-2019, Texas Instruments Incorporated +* Copyright (c) 2015-2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,158 +50,9 @@ extern "C" #include #include -#ifndef CPE_PATCH_TYPE -#define CPE_PATCH_TYPE static const uint32_t -#endif - -#ifndef SYS_PATCH_TYPE -#define SYS_PATCH_TYPE static const uint32_t -#endif - -#ifndef PATCH_FUN_SPEC -#define PATCH_FUN_SPEC static inline -#endif - -#ifndef _APPLY_PATCH_TAB -#define _APPLY_PATCH_TAB -#endif - - -CPE_PATCH_TYPE patchImageBt5[] = { - 0x21004059, - 0x210040a5, - 0x21004085, - 0x79654c07, - 0xf809f000, - 0x40697961, - 0xd5030749, - 0x4a042101, - 0x60110389, - 0xb570bd70, - 0x47084902, - 0x21000380, - 0x40041108, - 0x0000592d, - 0x21014805, - 0x438a6802, - 0x6b836002, - 0x6383438b, - 0x6002430a, - 0x47004801, - 0x40046000, - 0x00005b3f, - 0x490cb510, - 0x4a0c4788, - 0x5e512106, - 0xd0072900, - 0xd0052902, - 0xd0032909, - 0xd0012910, - 0xd1072911, - 0x43c92177, - 0xdd014288, - 0xdd012800, - 0x43c0207f, - 0x0000bd10, - 0x000065a9, - 0x21000380, -}; -#define _NWORD_PATCHIMAGE_BT5 37 - -#define _NWORD_PATCHCPEHD_BT5 0 - -#define _NWORD_PATCHSYS_BT5 0 - - - -#ifndef _BT5_SYSRAM_START -#define _BT5_SYSRAM_START 0x20000000 -#endif - -#ifndef _BT5_CPERAM_START -#define _BT5_CPERAM_START 0x21000000 -#endif - -#define _BT5_SYS_PATCH_FIXED_ADDR 0x20000000 - -#define _BT5_PATCH_VEC_ADDR_OFFSET 0x03D0 -#define _BT5_PATCH_TAB_OFFSET 0x03D4 -#define _BT5_IRQPATCH_OFFSET 0x0480 -#define _BT5_PATCH_VEC_OFFSET 0x404C - -#define _BT5_PATCH_CPEHD_OFFSET 0x04E0 - -#ifndef _BT5_NO_PROG_STATE_VAR -static uint8_t bBt5PatchEntered = 0; -#endif - -PATCH_FUN_SPEC void enterBt5CpePatch(void) -{ -#if (_NWORD_PATCHIMAGE_BT5 > 0) - uint32_t *pPatchVec = (uint32_t *) (_BT5_CPERAM_START + _BT5_PATCH_VEC_OFFSET); - - memcpy(pPatchVec, patchImageBt5, sizeof(patchImageBt5)); -#endif -} - -PATCH_FUN_SPEC void enterBt5CpeHdPatch(void) -{ -#if (_NWORD_PATCHCPEHD_BT5 > 0) - uint32_t *pPatchCpeHd = (uint32_t *) (_BT5_CPERAM_START + _BT5_PATCH_CPEHD_OFFSET); - - memcpy(pPatchCpeHd, patchCpeHd, sizeof(patchCpeHd)); -#endif -} - -PATCH_FUN_SPEC void enterBt5SysPatch(void) -{ -} - -PATCH_FUN_SPEC void configureBt5Patch(void) -{ - uint8_t *pPatchTab = (uint8_t *) (_BT5_CPERAM_START + _BT5_PATCH_TAB_OFFSET); - - - pPatchTab[76] = 0; - pPatchTab[91] = 1; - pPatchTab[79] = 2; -} - -PATCH_FUN_SPEC void applyBt5Patch(void) -{ -#ifdef _BT5_NO_PROG_STATE_VAR - enterBt5SysPatch(); - enterBt5CpePatch(); -#else - if (!bBt5PatchEntered) - { - enterBt5SysPatch(); - enterBt5CpePatch(); - bBt5PatchEntered = 1; - } -#endif - enterBt5CpeHdPatch(); - configureBt5Patch(); -} - -PATCH_FUN_SPEC void refreshBt5Patch(void) -{ - enterBt5CpeHdPatch(); - configureBt5Patch(); -} - -#ifndef _BT5_NO_PROG_STATE_VAR -PATCH_FUN_SPEC void cleanBt5Patch(void) -{ - bBt5PatchEntered = 0; -} -#endif - -PATCH_FUN_SPEC void rf_patch_cpe_bt5(void) -{ - applyBt5Patch(); -} - +extern void cleanBt5Patch(void); +extern void refreshBt5Patch(void); +extern void rf_patch_cpe_bt5(void); //***************************************************************************** // diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_ieee_802_15_4.c b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_ieee_802_15_4.c new file mode 100644 index 0000000..2fc9e43 --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_ieee_802_15_4.c @@ -0,0 +1,265 @@ +/****************************************************************************** +* Filename: rf_patch_cpe_ieee_802_15_4.c +* +* Description: RF core patch for IEEE 802.15.4-2006 support ("IEEE" API command set) in CC13x2 and CC26x2 +* +* Copyright (c) 2015-2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ +//***************************************************************************** +// +// If building with a C++ compiler, make all of the definitions in this header +// have a C binding. +// +//***************************************************************************** +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +#include "rf_patch_cpe_ieee_802_15_4.h" + +#ifndef CPE_PATCH_TYPE +#define CPE_PATCH_TYPE static const uint32_t +#endif + +#ifndef SYS_PATCH_TYPE +#define SYS_PATCH_TYPE static const uint32_t +#endif + +#ifndef PATCH_FUN_SPEC +#define PATCH_FUN_SPEC static +#endif + +#ifndef _APPLY_PATCH_TAB +#define _APPLY_PATCH_TAB +#endif + + +CPE_PATCH_TYPE patchImageIeee802154[] = { + 0x2100405d, + 0x21004089, + 0x21004095, + 0x21004133, + 0x79654c07, + 0xf809f000, + 0x40697961, + 0xd5030749, + 0x4a042101, + 0x60110389, + 0xb570bd70, + 0x47084902, + 0x21000380, + 0x40041108, + 0x0000592d, + 0xf80af000, + 0x47004800, + 0x00007f57, + 0xf80af000, + 0x47004800, + 0x0000881b, + 0x490c6b80, + 0x0f000700, + 0x47707148, + 0x490a4a09, + 0x79502318, + 0x7e4956cb, + 0x428118c0, + 0x4608dd01, + 0x280fe002, + 0x200fdd00, + 0x090989d1, + 0x43010109, + 0x477081d1, + 0x210002e0, + 0x21000088, + 0x4b252201, + 0x48232102, + 0xb5104718, + 0x47804823, + 0x6a404823, + 0xd10d2800, + 0x200a4922, + 0x28005608, + 0x1c40da09, + 0x4608d007, + 0x6a403820, + 0x4288491e, + 0x4780d100, + 0xf7ffbd10, + 0xbd10ffe3, + 0x4b1c2100, + 0x46084a1a, + 0x481b4718, + 0x780122fb, + 0x70014011, + 0x38ec4812, + 0xb5104700, + 0x47884917, + 0x39204911, + 0xd0072801, + 0xd5040402, + 0x85082000, + 0x62484813, + 0xbd102001, + 0x4b096a4a, + 0x429a3bec, + 0x4a10d101, + 0x4907e005, + 0x4b0f6a4a, + 0xd1f2429a, + 0x624a4a0e, + 0x0000bd10, + 0x00000806, + 0x0000069f, + 0x000292a1, + 0x21000108, + 0x21000154, + 0x00029263, + 0x210040e7, + 0x0002b4b5, + 0x21000380, + 0x000296f7, + 0x210040dd, + 0x21004123, + 0x00029569, + 0x21004119, +}; +#define _NWORD_PATCHIMAGE_IEEE_802_15_4 87 + +#define _NWORD_PATCHCPEHD_IEEE_802_15_4 0 + +#define _NWORD_PATCHSYS_IEEE_802_15_4 0 + + + +#ifndef _IEEE_802_15_4_SYSRAM_START +#define _IEEE_802_15_4_SYSRAM_START 0x20000000 +#endif + +#ifndef _IEEE_802_15_4_CPERAM_START +#define _IEEE_802_15_4_CPERAM_START 0x21000000 +#endif + +#define _IEEE_802_15_4_SYS_PATCH_FIXED_ADDR 0x20000000 + +#define _IEEE_802_15_4_PATCH_VEC_ADDR_OFFSET 0x03D0 +#define _IEEE_802_15_4_PATCH_TAB_OFFSET 0x03D4 +#define _IEEE_802_15_4_IRQPATCH_OFFSET 0x0480 +#define _IEEE_802_15_4_PATCH_VEC_OFFSET 0x404C + +#define _IEEE_802_15_4_PATCH_CPEHD_OFFSET 0x04E0 + +#ifndef _IEEE_802_15_4_NO_PROG_STATE_VAR +static uint8_t bIeee802154PatchEntered = 0; +#endif + +PATCH_FUN_SPEC void enterIeee802154CpePatch(void) +{ +#if (_NWORD_PATCHIMAGE_IEEE_802_15_4 > 0) + uint32_t *pPatchVec = (uint32_t *) (_IEEE_802_15_4_CPERAM_START + _IEEE_802_15_4_PATCH_VEC_OFFSET); + + memcpy(pPatchVec, patchImageIeee802154, sizeof(patchImageIeee802154)); +#endif +} + +PATCH_FUN_SPEC void enterIeee802154CpeHdPatch(void) +{ +#if (_NWORD_PATCHCPEHD_IEEE_802_15_4 > 0) + uint32_t *pPatchCpeHd = (uint32_t *) (_IEEE_802_15_4_CPERAM_START + _IEEE_802_15_4_PATCH_CPEHD_OFFSET); + + memcpy(pPatchCpeHd, patchCpeHd, sizeof(patchCpeHd)); +#endif +} + +PATCH_FUN_SPEC void enterIeee802154SysPatch(void) +{ +} + +PATCH_FUN_SPEC void configureIeee802154Patch(void) +{ + uint8_t *pPatchTab = (uint8_t *) (_IEEE_802_15_4_CPERAM_START + _IEEE_802_15_4_PATCH_TAB_OFFSET); + + + pPatchTab[76] = 0; + pPatchTab[140] = 1; + pPatchTab[150] = 2; + pPatchTab[164] = 3; +} + +PATCH_FUN_SPEC void applyIeee802154Patch(void) +{ +#ifdef _IEEE_802_15_4_NO_PROG_STATE_VAR + enterIeee802154SysPatch(); + enterIeee802154CpePatch(); +#else + if (!bIeee802154PatchEntered) + { + enterIeee802154SysPatch(); + enterIeee802154CpePatch(); + bIeee802154PatchEntered = 1; + } +#endif + enterIeee802154CpeHdPatch(); + configureIeee802154Patch(); +} + +void refreshIeee802154Patch(void) +{ + enterIeee802154CpeHdPatch(); + configureIeee802154Patch(); +} + +void cleanIeee802154Patch(void) +{ +#ifndef _IEEE_802_15_4_NO_PROG_STATE_VAR + bIeee802154PatchEntered = 0; +#endif +} + +void rf_patch_cpe_ieee_802_15_4(void) +{ + applyIeee802154Patch(); +} + + +//***************************************************************************** +// +// Mark the end of the C bindings section for C++ compilers. +// +//***************************************************************************** +#ifdef __cplusplus +} +#endif + + diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_ieee_802_15_4.h b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_ieee_802_15_4.h index 855993d..58edb06 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_ieee_802_15_4.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_ieee_802_15_4.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_patch_cpe_ieee_802_15_4.h -* Revised: $Date: 2019-02-27 16:13:01 +0100 (on, 27 feb 2019) $ -* Revision: $Revision: 18889 $ * * Description: RF core patch for IEEE 802.15.4-2006 support ("IEEE" API command set) in CC13x2 and CC26x2 * -* Copyright (c) 2015-2019, Texas Instruments Incorporated +* Copyright (c) 2015-2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,131 +50,9 @@ extern "C" #include #include -#ifndef CPE_PATCH_TYPE -#define CPE_PATCH_TYPE static const uint32_t -#endif - -#ifndef SYS_PATCH_TYPE -#define SYS_PATCH_TYPE static const uint32_t -#endif - -#ifndef PATCH_FUN_SPEC -#define PATCH_FUN_SPEC static inline -#endif - -#ifndef _APPLY_PATCH_TAB -#define _APPLY_PATCH_TAB -#endif - - -CPE_PATCH_TYPE patchImageIeee802154[] = { - 0x21004051, - 0x79654c07, - 0xf809f000, - 0x40697961, - 0xd5030749, - 0x4a042101, - 0x60110389, - 0xb570bd70, - 0x47084902, - 0x21000380, - 0x40041108, - 0x0000592d, -}; -#define _NWORD_PATCHIMAGE_IEEE_802_15_4 12 - -#define _NWORD_PATCHCPEHD_IEEE_802_15_4 0 - -#define _NWORD_PATCHSYS_IEEE_802_15_4 0 - - - -#ifndef _IEEE_802_15_4_SYSRAM_START -#define _IEEE_802_15_4_SYSRAM_START 0x20000000 -#endif - -#ifndef _IEEE_802_15_4_CPERAM_START -#define _IEEE_802_15_4_CPERAM_START 0x21000000 -#endif - -#define _IEEE_802_15_4_SYS_PATCH_FIXED_ADDR 0x20000000 - -#define _IEEE_802_15_4_PATCH_VEC_ADDR_OFFSET 0x03D0 -#define _IEEE_802_15_4_PATCH_TAB_OFFSET 0x03D4 -#define _IEEE_802_15_4_IRQPATCH_OFFSET 0x0480 -#define _IEEE_802_15_4_PATCH_VEC_OFFSET 0x404C - -#define _IEEE_802_15_4_PATCH_CPEHD_OFFSET 0x04E0 - -#ifndef _IEEE_802_15_4_NO_PROG_STATE_VAR -static uint8_t bIeee802154PatchEntered = 0; -#endif - -PATCH_FUN_SPEC void enterIeee802154CpePatch(void) -{ -#if (_NWORD_PATCHIMAGE_IEEE_802_15_4 > 0) - uint32_t *pPatchVec = (uint32_t *) (_IEEE_802_15_4_CPERAM_START + _IEEE_802_15_4_PATCH_VEC_OFFSET); - - memcpy(pPatchVec, patchImageIeee802154, sizeof(patchImageIeee802154)); -#endif -} - -PATCH_FUN_SPEC void enterIeee802154CpeHdPatch(void) -{ -#if (_NWORD_PATCHCPEHD_IEEE_802_15_4 > 0) - uint32_t *pPatchCpeHd = (uint32_t *) (_IEEE_802_15_4_CPERAM_START + _IEEE_802_15_4_PATCH_CPEHD_OFFSET); - - memcpy(pPatchCpeHd, patchCpeHd, sizeof(patchCpeHd)); -#endif -} - -PATCH_FUN_SPEC void enterIeee802154SysPatch(void) -{ -} - -PATCH_FUN_SPEC void configureIeee802154Patch(void) -{ - uint8_t *pPatchTab = (uint8_t *) (_IEEE_802_15_4_CPERAM_START + _IEEE_802_15_4_PATCH_TAB_OFFSET); - - - pPatchTab[76] = 0; -} - -PATCH_FUN_SPEC void applyIeee802154Patch(void) -{ -#ifdef _IEEE_802_15_4_NO_PROG_STATE_VAR - enterIeee802154SysPatch(); - enterIeee802154CpePatch(); -#else - if (!bIeee802154PatchEntered) - { - enterIeee802154SysPatch(); - enterIeee802154CpePatch(); - bIeee802154PatchEntered = 1; - } -#endif - enterIeee802154CpeHdPatch(); - configureIeee802154Patch(); -} - -PATCH_FUN_SPEC void refreshIeee802154Patch(void) -{ - enterIeee802154CpeHdPatch(); - configureIeee802154Patch(); -} - -#ifndef _IEEE_802_15_4_NO_PROG_STATE_VAR -PATCH_FUN_SPEC void cleanIeee802154Patch(void) -{ - bIeee802154PatchEntered = 0; -} -#endif - -PATCH_FUN_SPEC void rf_patch_cpe_ieee_802_15_4(void) -{ - applyIeee802154Patch(); -} - +extern void cleanIeee802154Patch(void); +extern void refreshIeee802154Patch(void); +extern void rf_patch_cpe_ieee_802_15_4(void); //***************************************************************************** // diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_bt5_coex.c b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_bt5_coex.c new file mode 100644 index 0000000..b43e309 --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_bt5_coex.c @@ -0,0 +1,1663 @@ +/****************************************************************************** +* Filename: rf_patch_cpe_multi_bt5_coex.c +* +* Description: RF core patch for coexistence support for Bluetooth 5 ("BLE" and "BLE5" API command sets) in CC13x2 and CC26x2 +* +* Copyright (c) 2015-2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ +//***************************************************************************** +// +// If building with a C++ compiler, make all of the definitions in this header +// have a C binding. +// +//***************************************************************************** +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +#include "rf_patch_cpe_multi_bt5_coex.h" + +#ifndef CPE_PATCH_TYPE +#define CPE_PATCH_TYPE static const uint32_t +#endif + +#ifndef SYS_PATCH_TYPE +#define SYS_PATCH_TYPE static const uint32_t +#endif + +#ifndef PATCH_FUN_SPEC +#define PATCH_FUN_SPEC static +#endif + +#ifndef _APPLY_PATCH_TAB +#define _APPLY_PATCH_TAB +#endif + + +CPE_PATCH_TYPE patchImageMultiBt5Coex[] = { + 0x210043d5, + 0x210040a1, + 0x210040bd, + 0x21004127, + 0x210040e9, + 0x21004449, + 0x21004485, + 0x2100414d, + 0x21004159, + 0x21004165, + 0x21004511, + 0x21004199, + 0x210041b1, + 0x210046ab, + 0x2100474d, + 0x21004a11, + 0x21004d2f, + 0x210050c7, + 0x21005283, + 0x210041d5, + 0x21005547, + 0xd00507db, + 0xf803f000, + 0x70084902, + 0xb570bd70, + 0x47284d01, + 0x210004e0, + 0x0002241d, + 0x79654c07, + 0xf809f000, + 0x40697961, + 0xd5030749, + 0x4a042101, + 0x60110389, + 0xb570bd70, + 0x47084902, + 0x21000380, + 0x40041108, + 0x0000592d, + 0xf819f000, + 0x296cb2e1, + 0x2804d00b, + 0x2806d001, + 0x490ed107, + 0x07c97809, + 0x7821d103, + 0xd4000709, + 0x490b2002, + 0x210c780a, + 0xd0024211, + 0x22804909, + 0xb003600a, + 0xb5f0bdf0, + 0x4907b083, + 0x48044708, + 0x22407801, + 0x70014391, + 0x47004804, + 0x210000c8, + 0x21000133, + 0xe000e200, + 0x00031641, + 0x00031b23, + 0x4700b570, + 0xf9c2f000, + 0x47004800, + 0x00007f57, + 0xf9c2f000, + 0x47004800, + 0x0000881b, + 0x0a9b9b03, + 0x2b834d08, + 0x4c08d10a, + 0x069b8923, + 0xb407d506, + 0xf805f000, + 0xd0002800, + 0xbc073542, + 0xb5704728, + 0x47004802, + 0x00020b1f, + 0x21000160, + 0x000209eb, + 0x781a4b09, + 0x43a22408, + 0xd0002800, + 0x701a4322, + 0x47104a00, + 0x00008e83, + 0x78084903, + 0xd4010700, + 0x47004802, + 0x00004770, + 0x21000380, + 0x00007e5f, + 0xb081b5f3, + 0xb5f84710, + 0x00004700, + 0x20284a04, + 0x48044790, + 0x60412101, + 0x4a044803, + 0x47106041, + 0x0000424f, + 0x40045000, + 0x40046000, + 0x00004285, + 0x4c86b510, + 0x31404621, + 0x28017d08, + 0x4884d134, + 0x08407dc0, + 0xd02f07c0, + 0x30604620, + 0x08527942, + 0xd02907d2, + 0x0b808940, + 0xd1252801, + 0x09417e08, + 0xd00c07c9, + 0x07006fa1, + 0x0fc08809, + 0x04090240, + 0x66604308, + 0x1c806fa0, + 0xf9bef001, + 0x4874e013, + 0x69803020, + 0x28006840, + 0x4a72d00e, + 0x78012300, + 0x1a5956d3, + 0x00c9d408, + 0x78411808, + 0xd00307c9, + 0x66616801, + 0x66a06840, + 0x4780486b, + 0xb5f8bd10, + 0x496a4c66, + 0x36204626, + 0x46257b70, + 0x90003540, + 0x00b8792f, + 0x68801840, + 0x28004780, + 0x4960d128, + 0x09097dc9, + 0xd02307c9, + 0x32644622, + 0xd0202f15, + 0x23007e29, + 0x07ff094f, + 0x7d6dd003, + 0xd0002d00, + 0x9f002301, + 0x43bb6fa5, + 0x7b73d012, + 0xd00f2b00, + 0x065b7d23, + 0x88d2d50c, + 0x2a010b92, + 0x08c9d108, + 0xd00507c9, + 0x0b8988a9, + 0xd1012901, + 0x73712100, + 0x7eabbdf8, + 0x2b017de9, + 0x2300d0e3, + 0xb570e7e1, + 0x46254c46, + 0x35806a60, + 0xd11d2800, + 0x5d002054, + 0x28002200, + 0x2064d017, + 0x08805d00, + 0xd01207c0, + 0x888868a9, + 0x28010b80, + 0x483dd10d, + 0x08407dc0, + 0xd00807c0, + 0x3020483a, + 0x68006980, + 0xd0022800, + 0x60a86229, + 0x622ae000, + 0x47804839, + 0x29006a61, + 0x6a29d103, + 0xd0002900, + 0xbd7060a9, + 0x4c2fb5f8, + 0x46204934, + 0x7d023040, + 0xd02f2a00, + 0x46257e80, + 0x28033580, + 0x2804d002, + 0xe027d003, + 0x75e82001, + 0x2064e024, + 0x08805d00, + 0xd01f07c0, + 0x888068a8, + 0x28010b80, + 0x4822d11a, + 0x7dc07dea, + 0xd0132a00, + 0x07c008c0, + 0x4626d012, + 0x7b773620, + 0x46014788, + 0xd1084339, + 0x06097d21, + 0x8869d505, + 0x29010b89, + 0x2100d101, + 0xbdf87371, + 0xe7ea0880, + 0xbdf84788, + 0x30804812, + 0x75c12100, + 0x47004817, + 0x3140490f, + 0x28267108, + 0xdc06d014, + 0xd0132815, + 0xd00b281b, + 0xd104281f, + 0x283de00a, + 0x2847d00e, + 0x490bd00a, + 0x18400080, + 0x47706880, + 0x4770480c, + 0x4770480c, + 0x4770480c, + 0x4770480c, + 0x4770480c, + 0x21000160, + 0x210000c8, + 0x210004e0, + 0x00024959, + 0x00025500, + 0x00023d8f, + 0x00023075, + 0x00022a15, + 0x210043c9, + 0x21004355, + 0x210042f7, + 0x21004277, + 0x210041f9, + 0x490cb510, + 0x4a0c4788, + 0x5e512106, + 0xd0072900, + 0xd0052902, + 0xd0032909, + 0xd0012910, + 0xd1072911, + 0x43c92177, + 0xdd014288, + 0xdd012800, + 0x43c0207f, + 0x0000bd10, + 0x000065a9, + 0x21000380, + 0x4810b510, + 0x481088c1, + 0xd0182905, + 0x68214c0f, + 0x0052084a, + 0x6ba26022, + 0x00520852, + 0x602163a2, + 0xfe50f7ff, + 0x07006ba0, + 0x2001d408, + 0x60606020, + 0x1c402000, + 0xdbfc280c, + 0x62202014, + 0xf7ffbd10, + 0xbd10fe41, + 0x21000380, + 0x00005b3f, + 0x40046000, + 0x490c6b80, + 0x0f000700, + 0x47707148, + 0x490a4a09, + 0x79502318, + 0x7e4956cb, + 0x428118c0, + 0x4608dd01, + 0x280fe002, + 0x200fdd00, + 0x090989d1, + 0x43010109, + 0x477081d1, + 0x210002e0, + 0x21000088, + 0x47702000, + 0x22ff0783, + 0x409a0edb, + 0x0e090789, + 0x28004099, + 0x0700da0b, + 0x38080f00, + 0x009b0883, + 0x181848ff, + 0x439369c3, + 0x61c3430b, + 0x08834770, + 0x009b48fc, + 0x68031818, + 0x430b4393, + 0x47706003, + 0x4694b5f0, + 0x7bd24af8, + 0xd0702a00, + 0x69234cf7, + 0xd06c2b00, + 0x07ea781d, + 0xd0680fd2, + 0xd07f2b00, + 0x2704785e, + 0xd0072e00, + 0x2e012205, + 0x2e02d006, + 0x2e03d006, + 0xe006d109, + 0xe00271e7, + 0xe00371e7, + 0x71a771e2, + 0x71e2e001, + 0x791a71a2, + 0xd0022800, + 0x43322601, + 0x0852e001, + 0x711a0052, + 0x07d208ea, + 0x4ee3d04a, + 0x4ae44fe3, + 0xd0414201, + 0x29007a61, + 0x8859d039, + 0x04894662, + 0x2a000c09, + 0x79a2d001, + 0x79e2e000, + 0xd0232a05, + 0xd0272900, + 0x220569b1, + 0x021243b9, + 0x61b11889, + 0x468c6871, + 0x220f6971, + 0x43910212, + 0x31ff31ff, + 0x61713102, + 0x21014ad0, + 0x60913240, + 0x43b969b1, + 0x31ff31ff, + 0x61b13102, + 0x008a8859, + 0x18514661, + 0x32804ac9, + 0xe0056091, + 0x79a269b1, + 0x021243b9, + 0x61b14311, + 0x21017862, + 0x7062430a, + 0x69b1e008, + 0x188943b9, + 0xe017e7f5, + 0x43b969b1, + 0x61b11889, + 0x07c90869, + 0x49bfd010, + 0x28002208, + 0xd0056948, + 0x61484310, + 0x21027860, + 0xe0044308, + 0x61484390, + 0x21fd7860, + 0x70604008, + 0x4bb2bdf0, + 0x7a9ab510, + 0x46144619, + 0x43847889, + 0x791bd002, + 0xd00e430b, + 0xd00c2a00, + 0xd10a4381, + 0x49af2001, + 0x60c803c0, + 0x384048ad, + 0x04006ac0, + 0x2000d401, + 0x2001bd10, + 0xb5f3bd10, + 0xb0814ca3, + 0x460e2500, + 0x27017225, + 0x047f48a6, + 0xb6626007, + 0x20114629, + 0xff26f7ff, + 0x600748a3, + 0x2201489c, + 0x61423040, + 0x6840489a, + 0x30a04999, + 0x61483180, + 0x3880489c, + 0x48946007, + 0x28007bc0, + 0x6921d028, + 0xd0252900, + 0x07c37808, + 0xd0210fdb, + 0xd01f2900, + 0x73660881, + 0xd00107c9, + 0xe00072a2, + 0x084172a5, + 0xd00807c9, + 0xd0022e00, + 0x732272e2, + 0x7921e005, + 0x732172e1, + 0x72e5e001, + 0x08c17325, + 0xd10007c9, + 0x09007325, + 0xd00307c0, + 0x07c07860, + 0x7325d000, + 0x46314a86, + 0xf7ff9801, + 0xbdfefd3f, + 0x2001b510, + 0x04404980, + 0x48796008, + 0x7b017b42, + 0xf7ff7ac0, + 0x2101fef7, + 0xf7ff2011, + 0xbd10fed5, + 0xb5104974, + 0x3140487b, + 0x48726048, + 0x220268c1, + 0x60c14311, + 0x03144875, + 0x21006004, + 0xf7ff200d, + 0x496bfec3, + 0x72082001, + 0x3880486f, + 0xbd106004, + 0x4d67b5f8, + 0x24017a28, + 0xd0052800, + 0x30404865, + 0x0a006840, + 0xd0062817, + 0x7d06486b, + 0x4780486b, + 0xd0662e01, + 0x4e6ae076, + 0x48696074, + 0x30402203, + 0x21616002, + 0x60c10149, + 0x61426044, + 0x01892159, + 0x61846201, + 0x684b4957, + 0xb2d26ab2, + 0x19d20057, + 0x684b189a, + 0xd3fc4293, + 0x010921c1, + 0x604460c1, + 0x60c1495c, + 0x49576044, + 0x620139d6, + 0x21a16184, + 0x62010109, + 0xbf006184, + 0x32804a55, + 0x232b6a91, + 0x0e090789, + 0x021b310c, + 0x60c118c9, + 0x6a916044, + 0x06c92211, + 0x01490f49, + 0x0212310e, + 0x60c11889, + 0x200c6044, + 0x200762f0, + 0x49426230, + 0x39402003, + 0x49406048, + 0x63c82000, + 0x4a4762c8, + 0x02127892, + 0x493b618a, + 0x2302694a, + 0x614a439a, + 0x702cbf00, + 0x49347228, + 0x60483140, + 0x200d2101, + 0xfe4cf7ff, + 0x49352001, + 0x60080340, + 0x483310c1, + 0x60013080, + 0x7928bdf8, + 0xd1fb2800, + 0x28007968, + 0x7868d1f8, + 0x07c02201, + 0x1c4917c1, + 0xf7ff4610, + 0x7868fe53, + 0x70684320, + 0xd1eb2e06, + 0x28007aa8, + 0x7828d0e8, + 0xd1e52800, + 0xff54f7ff, + 0xb5f8bdf8, + 0x6ac04828, + 0x4d1a4f2a, + 0x07c14e1a, + 0x2403d001, + 0x0700e07b, + 0x2c010f84, + 0x2c02d004, + 0x7fb8d107, + 0xd16e2800, + 0xf7ff2001, + 0x2800fec0, + 0x2c01d004, + 0x2c02d04a, + 0xe061d045, + 0x20014c1a, + 0x46016060, + 0x38964815, + 0xfe68f000, + 0x210120a1, + 0xf0000100, + 0x20c3fe63, + 0x01002101, + 0xfe64f000, + 0x62202007, + 0x20012403, + 0xe0257030, + 0xe000ed00, + 0xe000e400, + 0x210000a8, + 0x210056f8, + 0x40043000, + 0x00000700, + 0x00000400, + 0x40041100, + 0x40045040, + 0xe000e180, + 0xe000e280, + 0x00020be7, + 0x00001706, + 0x210002c0, + 0x000074f5, + 0x40046000, + 0x00001210, + 0x21000380, + 0x210002a0, + 0x72302000, + 0x03402001, + 0x600849ff, + 0x7fb8e023, + 0xd11c2800, + 0xf0002001, + 0x7ae8fe31, + 0x07c00840, + 0x7870d010, + 0xd00807c0, + 0x698849f8, + 0x02122207, + 0x79b24390, + 0x43100212, + 0x48f56188, + 0x22026941, + 0x61414311, + 0xd0022c02, + 0xd0042c03, + 0x2001e020, + 0xfe1af000, + 0x2000e01c, + 0x21017230, + 0xf7ff200d, + 0x49eafd9b, + 0x31402000, + 0x20016048, + 0x03404ee6, + 0x7ae86030, + 0x07c00840, + 0x48e5d004, + 0x21026942, + 0x6142438a, + 0xf0002000, + 0x2001fdff, + 0x60300280, + 0xbdf877bc, + 0x4cdfb570, + 0x72252500, + 0xf7ff4628, + 0x2800fe2a, + 0x7860d00f, + 0xd00807c0, + 0x698849d7, + 0x02122207, + 0x79e24390, + 0x43100212, + 0x48d66188, + 0xfbc7f7ff, + 0x2001bd70, + 0x48d47020, + 0xbd706205, + 0x470048d3, + 0x48d4b5f8, + 0x7ac04cd2, + 0x46262500, + 0x36400780, + 0x28002702, + 0x48d0da03, + 0x723780f0, + 0x48cf2503, + 0x280078c0, + 0x48ced003, + 0x723780f0, + 0x48c42503, + 0x28007800, + 0x49c2d00a, + 0x72082000, + 0xf0002086, + 0x48c7fdbf, + 0x80f01d00, + 0x25037237, + 0x300120ff, + 0xfdbcf000, + 0x48bae011, + 0x28007800, + 0x2088d00a, + 0xfdaef000, + 0x462049be, + 0x30401d09, + 0x720780c1, + 0xe0042503, + 0x47806c20, + 0x2d004605, + 0x48b7d0eb, + 0x28007840, + 0x48b7d017, + 0x07416840, + 0x49a9d50a, + 0x68093980, + 0xd5050709, + 0xf0002082, + 0x48b0fd91, + 0xe0091c80, + 0xd5060680, + 0x208c7931, + 0xfd94f000, + 0x1c4048ab, + 0x2000e000, + 0x28009000, + 0x2084d008, + 0xfd7ef000, + 0x30404620, + 0x80c19900, + 0x25037207, + 0x7808499b, + 0xd0072800, + 0x46204aa1, + 0x30401d12, + 0x720780c2, + 0xe0032503, + 0xd0012d03, + 0xd1702d02, + 0x20004993, + 0x489c7208, + 0x20007bc7, + 0x2f009000, + 0x4608d007, + 0x28006900, + 0x7800d003, + 0x07c79000, + 0x2d030fff, + 0xf000d11c, + 0xf000fd65, + 0x6aa0fd69, + 0xd0042800, + 0xf0006b60, + 0x2000fd69, + 0x498c62a0, + 0x1ec98920, + 0xd0024288, + 0x42881c49, + 0x4d84d108, + 0x28006ea8, + 0x6e68d004, + 0xfd58f000, + 0x66a82000, + 0xd0592f00, + 0x7801487a, + 0x438178c0, + 0x9800d103, + 0x07c00900, + 0x2200d109, + 0x46104611, + 0xfcc8f7ff, + 0x78414873, + 0x00490849, + 0x49767041, + 0x5d022048, + 0x2a023920, + 0x2a00d036, + 0x2001d001, + 0x2000e000, + 0x2701680b, + 0x072b7b5d, + 0xf0000f1b, + 0x0f06fd77, + 0x0805042b, + 0x40782b09, + 0xd1232800, + 0x4078e006, + 0xd0032800, + 0x2d00092d, + 0xe019dc01, + 0x68082501, + 0xd0072a03, + 0x90006840, + 0xfd1ef000, + 0xd1112800, + 0xe067e002, + 0xe7f66900, + 0xe0072701, + 0x68409800, + 0xf0009000, + 0x2800fd11, + 0x1c7fd104, + 0xdbf542af, + 0xda092d00, + 0x46112200, + 0xf7ff4610, + 0x4850fc81, + 0x08497841, + 0x70410049, + 0xfd04f000, + 0xf0002000, + 0x2001fd07, + 0xfd04f000, + 0xf0002002, + 0x4950fd01, + 0x1d098920, + 0xd0034288, + 0x3124494d, + 0xd1024288, + 0xfcfcf000, + 0x494ae030, + 0x42883123, + 0x4944d121, + 0x5c402065, + 0x07d20902, + 0x07c0d026, + 0x4608d024, + 0x69023080, + 0xd01f2a00, + 0x06537942, + 0x2b020f5b, + 0x88f5db1a, + 0x1cb64e3c, + 0xd01542b5, + 0x2b04258f, + 0x402ad005, + 0x71423210, + 0x730a6809, + 0x402ae00c, + 0x4937e7f9, + 0x42881d89, + 0x7f31d106, + 0x29004830, + 0x4936d002, + 0x60086e00, + 0x7a213440, + 0x220088e0, + 0xfccaf000, + 0x300120ff, + 0xfcccf000, + 0x4a31bdf8, + 0x2037492f, + 0x4a2f4710, + 0x2031492d, + 0x4a2d4710, + 0x2019492b, + 0x4a2b4710, + 0x203c4929, + 0x4a294710, + 0x200a4927, + 0x4a274710, + 0x20004925, + 0xb5f04710, + 0x21004f17, + 0x71797039, + 0x4c238801, + 0x0f93050a, + 0x0f92d005, + 0xd0022a01, + 0xd0602a02, + 0x4a1fe1b9, + 0xd17c1889, + 0x78856821, + 0x684378c2, + 0xb6726880, + 0xd0472900, + 0x260a4c0f, + 0x1cb657a6, + 0x880cd142, + 0x2c010b24, + 0x6909d13e, + 0xd13b4281, + 0x46214c08, + 0xe0253140, + 0xe000e180, + 0x40043000, + 0x40041100, + 0x210056f8, + 0x00005a8b, + 0x40046000, + 0x000200ab, + 0x21000160, + 0x21000128, + 0x00001407, + 0x21000380, + 0x00001804, + 0x40045080, + 0x210000a8, + 0x40042000, + 0x21004a51, + 0x000205a9, + 0x21000108, + 0xffffefff, + 0x3e0b790e, + 0xd80d2e03, + 0x7d36460e, + 0xd0022d00, + 0xd1022e00, + 0x2e00e008, + 0x2001d109, + 0x764a7608, + 0xe00a65e3, + 0xd0022d00, + 0x60c371c2, + 0x7182e001, + 0x20016083, + 0x02c049ff, + 0xb6626088, + 0x48ffe153, + 0x46064dfd, + 0x30c03680, + 0x7bf21b4b, + 0x42a969c0, + 0xdc1ad025, + 0x1b4b4dfa, + 0xd04742a9, + 0x4bf9dc07, + 0xf00018cb, + 0x1c05fc53, + 0x4343431c, + 0x2b03000c, + 0xdc05d07b, + 0xd0792b01, + 0xd1002b02, + 0xe077e0c1, + 0xd0742b04, + 0xd1732b1a, + 0xf000e12f, + 0x710efc3f, + 0x71565608, + 0xdeba8171, + 0x2f2f2f70, + 0x2a00712f, + 0x6138d020, + 0xd01d2800, + 0x79417982, + 0x0fdb0753, + 0x790570bb, + 0x403526fd, + 0x431d005b, + 0x07107105, + 0x70f80fc0, + 0x07c00888, + 0x0708d001, + 0x0790e000, + 0x71380fc0, + 0xd00207c8, + 0x0fc00788, + 0x07d0e001, + 0x72780fc0, + 0x8520207c, + 0xe0fb48d7, + 0xd0202a00, + 0x28006138, + 0x79c2d01d, + 0x07537941, + 0x70bb0fdb, + 0x26fd7905, + 0x005b4035, + 0x7105431d, + 0x0fc00710, + 0x088870f8, + 0xd00107c0, + 0xe0000708, + 0x0fc00790, + 0x07c87138, + 0x0788d002, + 0xe0010fc0, + 0x0fc007d0, + 0x20807278, + 0x48c58520, + 0x2a00e0d4, + 0x6138d024, + 0xd0212800, + 0x794179c2, + 0x0fdb0753, + 0x790570bb, + 0x403526fd, + 0x431d005b, + 0x07107105, + 0x70f80fc0, + 0x07c00888, + 0x0708d005, + 0xe06ee004, + 0xe093e010, + 0x0790e0bf, + 0x71380fc0, + 0xd00207c8, + 0x0fc00788, + 0x07d0e001, + 0x72780fc0, + 0x8520208c, + 0xe0a948b0, + 0xd0322a00, + 0x28006138, + 0x7a03d02f, + 0x075d7942, + 0x70bd0fed, + 0x4ea646ac, + 0x1c764daa, + 0x42b1682d, + 0x4ea1d003, + 0x42b11db6, + 0x7969d105, + 0x07c90849, + 0x2101d101, + 0x79017179, + 0x402925fd, + 0x006d4665, + 0x71014329, + 0x0fc00718, + 0x089070f8, + 0xd00107c0, + 0xe0000710, + 0x0fc00798, + 0x07d07138, + 0xbf00d002, + 0xe0240790, + 0x0fc007d8, + 0x20a8e025, + 0x48968520, + 0x2a00e070, + 0x6138d0f9, + 0xd0f62800, + 0x79417a42, + 0x0fdb0753, + 0x790570bb, + 0x403526fd, + 0x431d005b, + 0x07107105, + 0x70f80fc0, + 0x07c00888, + 0x0708d001, + 0x0790e000, + 0x71380fc0, + 0xd00207c8, + 0x0fc00788, + 0x07d0e001, + 0x72780fc0, + 0x2a00e7d7, + 0x6138d020, + 0xd01d2800, + 0x79417a82, + 0x0fdb0753, + 0x790570bb, + 0x403526fd, + 0x431d005b, + 0x07107105, + 0x70f80fc0, + 0x07c00888, + 0x0708d001, + 0x0790e000, + 0x71380fc0, + 0xd00207c8, + 0x0fc00788, + 0x07d0e001, + 0x72780fc0, + 0x85202054, + 0xe0254871, + 0xd0202a00, + 0x28006138, + 0x7ac2d01d, + 0x07537941, + 0x70bb0fdb, + 0x26fd7905, + 0x005b4035, + 0x7105431d, + 0x0fc00710, + 0x088870f8, + 0xd00107c0, + 0xe0000708, + 0x0fc00790, + 0x07c87138, + 0x0788d002, + 0xe0010fc0, + 0x0fc007d0, + 0x20687278, + 0x485f8520, + 0x20016260, + 0x200abdf0, + 0x485d8520, + 0x2082e7f8, + 0xb5f3bdf0, + 0xb0814d50, + 0x7be83580, + 0xd0142800, + 0x69014858, + 0xd0102900, + 0x07c27808, + 0xd00c0fd2, + 0xd00a2900, + 0x07c008c0, + 0x4853d007, + 0x22076981, + 0x43910212, + 0x18891502, + 0x98016181, + 0x27004c4f, + 0x28004e4f, + 0x7a70d016, + 0x42887a31, + 0x2181d00b, + 0xd0024208, + 0xf0002010, + 0x7a70fa7f, + 0x484706c1, + 0x30400ec9, + 0x20036141, + 0x48446060, + 0x63c73040, + 0xe01062c7, + 0x60602002, + 0x60a02001, + 0x60a76027, + 0x30404831, + 0x0a818800, + 0xd00407c9, + 0x07c00900, + 0xf000d001, + 0x4839faa3, + 0x694130c0, + 0x03522201, + 0x61414391, + 0x6b814837, + 0x43912220, + 0x60e76381, + 0x48356127, + 0x61a06160, + 0x28007b28, + 0xf000d001, + 0x4c32fa93, + 0x07c06ae0, + 0x7ae8d0fc, + 0x07c14d1c, + 0x6969d003, + 0x00490849, + 0x08c06169, + 0xd00907c0, + 0x69414825, + 0x431122f0, + 0x69816141, + 0x43912270, + 0x61813140, + 0x68414820, + 0xf000208a, + 0x4925fa7b, + 0x60084823, + 0x20024924, + 0x63287008, + 0x28009801, + 0x7af0d04a, + 0x42887ab1, + 0x2181d009, + 0xd0024208, + 0xf0002040, + 0x7af0fa19, + 0x0ec006c0, + 0x200161e0, + 0x491a6060, + 0x47889802, + 0x70702003, + 0xe0314818, + 0x40041100, + 0x00001821, + 0x21000028, + 0x00001806, + 0xffffe7ff, + 0x21004d27, + 0x21004d1f, + 0x21004d17, + 0x21000160, + 0x21004d0f, + 0x21004d07, + 0x21004cff, + 0x21004a4d, + 0x210056f8, + 0x40043000, + 0x40045000, + 0x21000380, + 0x40045100, + 0x0000ffff, + 0x40046000, + 0x00000914, + 0xe000e180, + 0x21000018, + 0x0000729f, + 0x000057bf, + 0xbdfe4780, + 0x60a02001, + 0x60a76027, + 0x6007488a, + 0x20787077, + 0xfa0af000, + 0xb5f7bdfe, + 0xb0844f87, + 0x46166838, + 0x42884986, + 0x4886d10a, + 0x89014a86, + 0xd0024291, + 0x42911c52, + 0x4984d102, + 0x47886e40, + 0x25004883, + 0x90026840, + 0xd0012e00, + 0xe0004c81, + 0x21004c81, + 0x2e006261, + 0x487fd003, + 0x60386a40, + 0x487ce004, + 0x28006a40, + 0x6039d100, + 0x7d504a7b, + 0xd00407c3, + 0x0fc00780, + 0xd10042b0, + 0x49747551, + 0x31402000, + 0x20016008, + 0x03004975, + 0x98056008, + 0xd03a2802, + 0xd0002800, + 0x68212001, + 0x070b7b49, + 0xf0000f1b, + 0x0406f9e7, + 0x0b080632, + 0x2701210d, + 0x2101e00d, + 0x28004048, + 0xe7f8d127, + 0x40502201, + 0xd0f42800, + 0x0f070608, + 0x2f00d011, + 0x9805dd28, + 0x68202803, + 0x6845d00d, + 0xf0004628, + 0x2800f989, + 0x4860d009, + 0xe0109004, + 0x1e80485e, + 0x6825e7fa, + 0x6905e016, + 0x2001e7f0, + 0x6868e00f, + 0xf0009001, + 0x2800f977, + 0x4857d004, + 0x27008068, + 0xe00743ff, + 0x80682003, + 0x9d019800, + 0x90001c40, + 0xdbec42b8, + 0x68219804, + 0x80482e00, + 0xd001484f, + 0xe0002104, + 0x60812101, + 0xda192f00, + 0xd0022e00, + 0x60812108, + 0x2102e00b, + 0x22006081, + 0x46104611, + 0xf8ccf7ff, + 0x78414846, + 0x00490849, + 0x21007041, + 0x30204620, + 0x602172c1, + 0x728121fc, + 0xbdf0b007, + 0x27008828, + 0x0f800500, + 0xd0022803, + 0xd0022802, + 0x4835e02b, + 0x4835e000, + 0x42a09000, + 0x6800d004, + 0xd0122800, + 0x1cbf4f34, + 0x30209800, + 0x22837ac1, + 0x72c14011, + 0x46284933, + 0x28824788, + 0x4932d015, + 0xd1154288, + 0x1cbf4f2c, + 0x222ce03a, + 0x98004621, + 0xf94ef000, + 0x46202100, + 0x72c13020, + 0x21fc6021, + 0x20017281, + 0x9c004046, + 0x4f23e7de, + 0xe0271c7f, + 0xd0062801, + 0xf000207f, + 0x4925f8e1, + 0x60484823, + 0x2f00e7fe, + 0x68a0d11c, + 0x980260e0, + 0x60256160, + 0x7b406820, + 0x0f000700, + 0xd9022805, + 0x1ebf4f16, + 0x2080e00e, + 0xf8d0f000, + 0x68204605, + 0x46312200, + 0xf924f000, + 0x46284607, + 0xf902f000, + 0xd09d2f00, + 0x21024632, + 0xf0004638, + 0xe797f8f5, + 0x40046040, + 0x210002a8, + 0x000203bd, + 0x21000160, + 0x00001821, + 0x000035f1, + 0x40043000, + 0x21000134, + 0x21000108, + 0x21000280, + 0xe000e180, + 0x00000804, + 0x40041100, + 0x210056f8, + 0x00000657, + 0x0000ffff, + 0x80000000, + 0xe000ed00, + 0x4b272201, + 0x48252102, + 0xb5104718, + 0x47804825, + 0x6a404825, + 0xd10d2800, + 0x200a4924, + 0x28005608, + 0x1c40da09, + 0x4608d007, + 0x6a403820, + 0x42884920, + 0x4780d100, + 0xf7ffbd10, + 0xbd10ffe3, + 0x4b1e2100, + 0x46084a1c, + 0x20014718, + 0x0240491c, + 0x481c6008, + 0x780122fb, + 0x70014011, + 0x38ec4812, + 0xb5104700, + 0x47884918, + 0x39204911, + 0xd0072801, + 0xd5040402, + 0x85082000, + 0x62484814, + 0xbd102001, + 0x4b096a4a, + 0x429a3bec, + 0x4a11d101, + 0x4907e005, + 0x4b106a4a, + 0xd1f2429a, + 0x624a4a0f, + 0x0000bd10, + 0x00000806, + 0x0000069f, + 0x000292a1, + 0x21000108, + 0x21000154, + 0x00029263, + 0x210054f3, + 0x0002b4b5, + 0xe000e180, + 0x21000380, + 0x000296f7, + 0x210054e9, + 0x2100552f, + 0x00029569, + 0x21005525, + 0x07810882, + 0x0ec90092, + 0x78c0ca0c, + 0x424940ca, + 0x408b3120, + 0x0211431a, + 0x06000a09, + 0x47704308, + 0x4801b403, + 0xbd019001, + 0x00004e75, + 0x4801b403, + 0xbd019001, + 0x00004e4f, + 0x4801b403, + 0xbd019001, + 0x000085bd, + 0x4801b403, + 0xbd019001, + 0x0000900f, + 0x4801b403, + 0xbd019001, + 0x00003cc3, + 0x4801b403, + 0xbd019001, + 0x0000424f, + 0x4801b403, + 0xbd019001, + 0x00003ca9, + 0x4801b403, + 0xbd019001, + 0x00007d65, + 0x4801b403, + 0xbd019001, + 0x00005d1b, + 0x4801b403, + 0xbd019001, + 0x000035f1, + 0x4801b403, + 0xbd019001, + 0x00003f9d, + 0x4801b403, + 0xbd019001, + 0x00005e9d, + 0x4801b403, + 0xbd019001, + 0x00000fc1, + 0x4801b403, + 0xbd019001, + 0x0002035d, + 0x4801b403, + 0xbd019001, + 0x0000069f, + 0x4801b403, + 0xbd019001, + 0x0000423d, + 0x4801b403, + 0xbd019001, + 0x000090fd, + 0x4801b403, + 0xbd019001, + 0x00005bbb, + 0x4801b403, + 0xbd019001, + 0x00003c8f, + 0x4801b403, + 0xbd019001, + 0x000002f9, + 0x4801b403, + 0xbd019001, + 0x000004bf, + 0x4674b430, + 0x78251e64, + 0x42ab1c64, + 0x461dd200, + 0x005b5d63, + 0xbc3018e3, + 0x00004718, + 0x00000000, + 0x04050001, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, +}; +#define _NWORD_PATCHIMAGE_MULTI_BT5_COEX 1457 + +CPE_PATCH_TYPE patchCpeHd[] = { + 0x00000000, +}; +#define _NWORD_PATCHCPEHD_MULTI_BT5_COEX 1 + +#define _NWORD_PATCHSYS_MULTI_BT5_COEX 0 + +#define _IRQ_PATCH_0 0x2100479d +#define _IRQ_PATCH_1 0x210048c7 + + +#ifndef _MULTI_BT5_COEX_SYSRAM_START +#define _MULTI_BT5_COEX_SYSRAM_START 0x20000000 +#endif + +#ifndef _MULTI_BT5_COEX_CPERAM_START +#define _MULTI_BT5_COEX_CPERAM_START 0x21000000 +#endif + +#define _MULTI_BT5_COEX_SYS_PATCH_FIXED_ADDR 0x20000000 + +#define _MULTI_BT5_COEX_PATCH_VEC_ADDR_OFFSET 0x03D0 +#define _MULTI_BT5_COEX_PATCH_TAB_OFFSET 0x03D4 +#define _MULTI_BT5_COEX_IRQPATCH_OFFSET 0x0480 +#define _MULTI_BT5_COEX_PATCH_VEC_OFFSET 0x404C + +#define _MULTI_BT5_COEX_PATCH_CPEHD_OFFSET 0x04E0 + +#ifndef _MULTI_BT5_COEX_NO_PROG_STATE_VAR +static uint8_t bMultiBt5CoexPatchEntered = 0; +#endif + +PATCH_FUN_SPEC void enterMultiBt5CoexCpePatch(void) +{ +#if (_NWORD_PATCHIMAGE_MULTI_BT5_COEX > 0) + uint32_t *pPatchVec = (uint32_t *) (_MULTI_BT5_COEX_CPERAM_START + _MULTI_BT5_COEX_PATCH_VEC_OFFSET); + + memcpy(pPatchVec, patchImageMultiBt5Coex, sizeof(patchImageMultiBt5Coex)); +#endif +} + +PATCH_FUN_SPEC void enterMultiBt5CoexCpeHdPatch(void) +{ +#if (_NWORD_PATCHCPEHD_MULTI_BT5_COEX > 0) + uint32_t *pPatchCpeHd = (uint32_t *) (_MULTI_BT5_COEX_CPERAM_START + _MULTI_BT5_COEX_PATCH_CPEHD_OFFSET); + + memcpy(pPatchCpeHd, patchCpeHd, sizeof(patchCpeHd)); +#endif +} + +PATCH_FUN_SPEC void enterMultiBt5CoexSysPatch(void) +{ +} + +PATCH_FUN_SPEC void configureMultiBt5CoexPatch(void) +{ + uint8_t *pPatchTab = (uint8_t *) (_MULTI_BT5_COEX_CPERAM_START + _MULTI_BT5_COEX_PATCH_TAB_OFFSET); + uint32_t *pIrqPatch = (uint32_t *) (_MULTI_BT5_COEX_CPERAM_START + _MULTI_BT5_COEX_IRQPATCH_OFFSET); + + + pPatchTab[1] = 0; + pPatchTab[21] = 1; + pPatchTab[76] = 2; + pPatchTab[62] = 3; + pPatchTab[64] = 4; + pPatchTab[91] = 5; + pPatchTab[79] = 6; + pPatchTab[140] = 7; + pPatchTab[150] = 8; + pPatchTab[13] = 9; + pPatchTab[31] = 10; + pPatchTab[152] = 11; + pPatchTab[151] = 12; + pPatchTab[12] = 13; + pPatchTab[139] = 14; + pPatchTab[78] = 15; + pPatchTab[163] = 16; + pPatchTab[81] = 17; + pPatchTab[40] = 18; + pPatchTab[73] = 19; + pPatchTab[164] = 20; + + pIrqPatch[17] = _IRQ_PATCH_0; + pIrqPatch[21] = _IRQ_PATCH_1; +} + +PATCH_FUN_SPEC void applyMultiBt5CoexPatch(void) +{ +#ifdef _MULTI_BT5_COEX_NO_PROG_STATE_VAR + enterMultiBt5CoexSysPatch(); + enterMultiBt5CoexCpePatch(); +#else + if (!bMultiBt5CoexPatchEntered) + { + enterMultiBt5CoexSysPatch(); + enterMultiBt5CoexCpePatch(); + bMultiBt5CoexPatchEntered = 1; + } +#endif + enterMultiBt5CoexCpeHdPatch(); + configureMultiBt5CoexPatch(); +} + +void refreshMultiBt5CoexPatch(void) +{ + enterMultiBt5CoexCpeHdPatch(); + configureMultiBt5CoexPatch(); +} + +void cleanMultiBt5CoexPatch(void) +{ +#ifndef _MULTI_BT5_COEX_NO_PROG_STATE_VAR + bMultiBt5CoexPatchEntered = 0; +#endif +} + +void rf_patch_cpe_multi_bt5_coex(void) +{ + applyMultiBt5CoexPatch(); +} + +#undef _IRQ_PATCH_0 +#undef _IRQ_PATCH_1 + +//***************************************************************************** +// +// Mark the end of the C bindings section for C++ compilers. +// +//***************************************************************************** +#ifdef __cplusplus +} +#endif + + diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_bt5_coex.h b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_bt5_coex.h new file mode 100644 index 0000000..2f717e6 --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_bt5_coex.h @@ -0,0 +1,67 @@ +/****************************************************************************** +* Filename: rf_patch_cpe_multi_bt5_coex.h +* +* Description: RF core patch for coexistence support for Bluetooth 5 ("BLE" and "BLE5" API command sets) in CC13x2 and CC26x2 +* +* Copyright (c) 2015-2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ +#ifndef _RF_PATCH_CPE_MULTI_BT5_COEX_H +#define _RF_PATCH_CPE_MULTI_BT5_COEX_H + +//***************************************************************************** +// +// If building with a C++ compiler, make all of the definitions in this header +// have a C binding. +// +//***************************************************************************** +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +extern void cleanMultiBt5CoexPatch(void); +extern void refreshMultiBt5CoexPatch(void); +extern void rf_patch_cpe_multi_bt5_coex(void); + +//***************************************************************************** +// +// Mark the end of the C bindings section for C++ compilers. +// +//***************************************************************************** +#ifdef __cplusplus +} +#endif + +#endif // _RF_PATCH_CPE_MULTI_BT5_COEX_H + diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol.c b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol.c new file mode 100644 index 0000000..dbf33b0 --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol.c @@ -0,0 +1,565 @@ +/****************************************************************************** +* Filename: rf_patch_cpe_multi_protocol.c +* +* Description: RF core patch for multi-protocol support (all available API command sets) in CC13x2 and CC26x2 +* +* Copyright (c) 2015-2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ +//***************************************************************************** +// +// If building with a C++ compiler, make all of the definitions in this header +// have a C binding. +// +//***************************************************************************** +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +#include "rf_patch_cpe_multi_protocol.h" + +#ifndef CPE_PATCH_TYPE +#define CPE_PATCH_TYPE static const uint32_t +#endif + +#ifndef SYS_PATCH_TYPE +#define SYS_PATCH_TYPE static const uint32_t +#endif + +#ifndef PATCH_FUN_SPEC +#define PATCH_FUN_SPEC static +#endif + +#ifndef _APPLY_PATCH_TAB +#define _APPLY_PATCH_TAB +#endif + + +CPE_PATCH_TYPE patchImageMultiProtocol[] = { + 0x210043f1, + 0x2100408d, + 0x210040a9, + 0x21004113, + 0x210040d5, + 0x21004465, + 0x210044a1, + 0x21004139, + 0x21004145, + 0x21004151, + 0x2100452d, + 0x21004185, + 0x2100419d, + 0x210041b5, + 0x210041f1, + 0x21004587, + 0xd00507db, + 0xf803f000, + 0x70084902, + 0xb570bd70, + 0x47284d01, + 0x210004e0, + 0x0002241d, + 0x79654c07, + 0xf809f000, + 0x40697961, + 0xd5030749, + 0x4a042101, + 0x60110389, + 0xb570bd70, + 0x47084902, + 0x21000380, + 0x40041108, + 0x0000592d, + 0xf819f000, + 0x296cb2e1, + 0x2804d00b, + 0x2806d001, + 0x490ed107, + 0x07c97809, + 0x7821d103, + 0xd4000709, + 0x490b2002, + 0x210c780a, + 0xd0024211, + 0x22804909, + 0xb003600a, + 0xb5f0bdf0, + 0x4907b083, + 0x48044708, + 0x22407801, + 0x70014391, + 0x47004804, + 0x210000c8, + 0x21000133, + 0xe000e200, + 0x00031641, + 0x00031b23, + 0x4700b570, + 0xf9daf000, + 0x47004800, + 0x00007f57, + 0xf9daf000, + 0x47004800, + 0x0000881b, + 0x0a9b9b03, + 0x2b834d08, + 0x4c08d10a, + 0x069b8923, + 0xb407d506, + 0xf805f000, + 0xd0002800, + 0xbc073542, + 0xb5704728, + 0x47004802, + 0x00020b1f, + 0x21000160, + 0x000209eb, + 0x781a4b09, + 0x43a22408, + 0xd0002800, + 0x701a4322, + 0x47104a00, + 0x00008e83, + 0x78084903, + 0xd4010700, + 0x47004802, + 0x00004770, + 0x21000380, + 0x00007e5f, + 0x4a094808, + 0x429a6803, + 0x4808d10a, + 0x4b088902, + 0xd0011ad2, + 0xd1032a01, + 0x49066e40, + 0x99034788, + 0x47184b05, + 0x210002a8, + 0x000203bd, + 0x21000160, + 0x00001821, + 0x000035f1, + 0x000006bd, + 0x20284a04, + 0x48044790, + 0x60412101, + 0x4a044803, + 0x47106041, + 0x0000424f, + 0x40045000, + 0x40046000, + 0x00004285, + 0x4c86b510, + 0x31404621, + 0x28017d08, + 0x4884d134, + 0x08407dc0, + 0xd02f07c0, + 0x30604620, + 0x08527942, + 0xd02907d2, + 0x0b808940, + 0xd1252801, + 0x09417e08, + 0xd00c07c9, + 0x07006fa1, + 0x0fc08809, + 0x04090240, + 0x66604308, + 0x1c806fa0, + 0xf9cef000, + 0x4874e013, + 0x69803020, + 0x28006840, + 0x4a72d00e, + 0x78012300, + 0x1a5956d3, + 0x00c9d408, + 0x78411808, + 0xd00307c9, + 0x66616801, + 0x66a06840, + 0x4780486b, + 0xb5f8bd10, + 0x496a4c66, + 0x36204626, + 0x46257b70, + 0x90003540, + 0x00b8792f, + 0x68801840, + 0x28004780, + 0x4960d128, + 0x09097dc9, + 0xd02307c9, + 0x32644622, + 0xd0202f15, + 0x23007e29, + 0x07ff094f, + 0x7d6dd003, + 0xd0002d00, + 0x9f002301, + 0x43bb6fa5, + 0x7b73d012, + 0xd00f2b00, + 0x065b7d23, + 0x88d2d50c, + 0x2a010b92, + 0x08c9d108, + 0xd00507c9, + 0x0b8988a9, + 0xd1012901, + 0x73712100, + 0x7eabbdf8, + 0x2b017de9, + 0x2300d0e3, + 0xb570e7e1, + 0x46254c46, + 0x35806a60, + 0xd11d2800, + 0x5d002054, + 0x28002200, + 0x2064d017, + 0x08805d00, + 0xd01207c0, + 0x888868a9, + 0x28010b80, + 0x483dd10d, + 0x08407dc0, + 0xd00807c0, + 0x3020483a, + 0x68006980, + 0xd0022800, + 0x60a86229, + 0x622ae000, + 0x47804839, + 0x29006a61, + 0x6a29d103, + 0xd0002900, + 0xbd7060a9, + 0x4c2fb5f8, + 0x46204934, + 0x7d023040, + 0xd02f2a00, + 0x46257e80, + 0x28033580, + 0x2804d002, + 0xe027d003, + 0x75e82001, + 0x2064e024, + 0x08805d00, + 0xd01f07c0, + 0x888068a8, + 0x28010b80, + 0x4822d11a, + 0x7dc07dea, + 0xd0132a00, + 0x07c008c0, + 0x4626d012, + 0x7b773620, + 0x46014788, + 0xd1084339, + 0x06097d21, + 0x8869d505, + 0x29010b89, + 0x2100d101, + 0xbdf87371, + 0xe7ea0880, + 0xbdf84788, + 0x30804812, + 0x75c12100, + 0x47004817, + 0x3140490f, + 0x28267108, + 0xdc06d014, + 0xd0132815, + 0xd00b281b, + 0xd104281f, + 0x283de00a, + 0x2847d00e, + 0x490bd00a, + 0x18400080, + 0x47706880, + 0x4770480c, + 0x4770480c, + 0x4770480c, + 0x4770480c, + 0x4770480c, + 0x21000160, + 0x210000c8, + 0x210004e0, + 0x00024959, + 0x00025500, + 0x00023d8f, + 0x00023075, + 0x00022a15, + 0x210043e5, + 0x21004371, + 0x21004313, + 0x21004293, + 0x21004215, + 0x490cb510, + 0x4a0c4788, + 0x5e512106, + 0xd0072900, + 0xd0052902, + 0xd0032909, + 0xd0012910, + 0xd1072911, + 0x43c92177, + 0xdd014288, + 0xdd012800, + 0x43c0207f, + 0x0000bd10, + 0x000065a9, + 0x21000380, + 0x4810b510, + 0x481088c1, + 0xd0182905, + 0x68214c0f, + 0x0052084a, + 0x6ba26022, + 0x00520852, + 0x602163a2, + 0xfe38f7ff, + 0x07006ba0, + 0x2001d408, + 0x60606020, + 0x1c402000, + 0xdbfc280c, + 0x62202014, + 0xf7ffbd10, + 0xbd10fe29, + 0x21000380, + 0x00005b3f, + 0x40046000, + 0x490c6b80, + 0x0f000700, + 0x47707148, + 0x490a4a09, + 0x79502318, + 0x7e4956cb, + 0x428118c0, + 0x4608dd01, + 0x280fe002, + 0x200fdd00, + 0x090989d1, + 0x43010109, + 0x477081d1, + 0x210002e0, + 0x21000088, + 0x47702000, + 0x4b252201, + 0x48232102, + 0xb5104718, + 0x47804823, + 0x6a404823, + 0xd10d2800, + 0x200a4922, + 0x28005608, + 0x1c40da09, + 0x4608d007, + 0x6a403820, + 0x4288491e, + 0x4780d100, + 0xf7ffbd10, + 0xbd10ffe3, + 0x4b1c2100, + 0x46084a1a, + 0x481b4718, + 0x780122fb, + 0x70014011, + 0x38ec4812, + 0xb5104700, + 0x47884917, + 0x39204911, + 0xd0072801, + 0xd5040402, + 0x85082000, + 0x62484813, + 0xbd102001, + 0x4b096a4a, + 0x429a3bec, + 0x4a10d101, + 0x4907e005, + 0x4b0f6a4a, + 0xd1f2429a, + 0x624a4a0e, + 0x0000bd10, + 0x00000806, + 0x0000069f, + 0x000292a1, + 0x21000108, + 0x21000154, + 0x00029263, + 0x2100453b, + 0x0002b4b5, + 0x21000380, + 0x000296f7, + 0x21004531, + 0x21004577, + 0x00029569, + 0x2100456d, + 0x07810882, + 0x0ec90092, + 0x78c0ca0c, + 0x424940ca, + 0x408b3120, + 0x0211431a, + 0x06000a09, + 0x47704308, +}; +#define _NWORD_PATCHIMAGE_MULTI_PROTOCOL 372 + +CPE_PATCH_TYPE patchCpeHd[] = { + 0x00000000, +}; +#define _NWORD_PATCHCPEHD_MULTI_PROTOCOL 1 + +#define _NWORD_PATCHSYS_MULTI_PROTOCOL 0 + + + +#ifndef _MULTI_PROTOCOL_SYSRAM_START +#define _MULTI_PROTOCOL_SYSRAM_START 0x20000000 +#endif + +#ifndef _MULTI_PROTOCOL_CPERAM_START +#define _MULTI_PROTOCOL_CPERAM_START 0x21000000 +#endif + +#define _MULTI_PROTOCOL_SYS_PATCH_FIXED_ADDR 0x20000000 + +#define _MULTI_PROTOCOL_PATCH_VEC_ADDR_OFFSET 0x03D0 +#define _MULTI_PROTOCOL_PATCH_TAB_OFFSET 0x03D4 +#define _MULTI_PROTOCOL_IRQPATCH_OFFSET 0x0480 +#define _MULTI_PROTOCOL_PATCH_VEC_OFFSET 0x404C + +#define _MULTI_PROTOCOL_PATCH_CPEHD_OFFSET 0x04E0 + +#ifndef _MULTI_PROTOCOL_NO_PROG_STATE_VAR +static uint8_t bMultiProtocolPatchEntered = 0; +#endif + +PATCH_FUN_SPEC void enterMultiProtocolCpePatch(void) +{ +#if (_NWORD_PATCHIMAGE_MULTI_PROTOCOL > 0) + uint32_t *pPatchVec = (uint32_t *) (_MULTI_PROTOCOL_CPERAM_START + _MULTI_PROTOCOL_PATCH_VEC_OFFSET); + + memcpy(pPatchVec, patchImageMultiProtocol, sizeof(patchImageMultiProtocol)); +#endif +} + +PATCH_FUN_SPEC void enterMultiProtocolCpeHdPatch(void) +{ +#if (_NWORD_PATCHCPEHD_MULTI_PROTOCOL > 0) + uint32_t *pPatchCpeHd = (uint32_t *) (_MULTI_PROTOCOL_CPERAM_START + _MULTI_PROTOCOL_PATCH_CPEHD_OFFSET); + + memcpy(pPatchCpeHd, patchCpeHd, sizeof(patchCpeHd)); +#endif +} + +PATCH_FUN_SPEC void enterMultiProtocolSysPatch(void) +{ +} + +PATCH_FUN_SPEC void configureMultiProtocolPatch(void) +{ + uint8_t *pPatchTab = (uint8_t *) (_MULTI_PROTOCOL_CPERAM_START + _MULTI_PROTOCOL_PATCH_TAB_OFFSET); + + + pPatchTab[1] = 0; + pPatchTab[21] = 1; + pPatchTab[76] = 2; + pPatchTab[62] = 3; + pPatchTab[64] = 4; + pPatchTab[91] = 5; + pPatchTab[79] = 6; + pPatchTab[140] = 7; + pPatchTab[150] = 8; + pPatchTab[13] = 9; + pPatchTab[31] = 10; + pPatchTab[152] = 11; + pPatchTab[151] = 12; + pPatchTab[40] = 13; + pPatchTab[73] = 14; + pPatchTab[164] = 15; +} + +PATCH_FUN_SPEC void applyMultiProtocolPatch(void) +{ +#ifdef _MULTI_PROTOCOL_NO_PROG_STATE_VAR + enterMultiProtocolSysPatch(); + enterMultiProtocolCpePatch(); +#else + if (!bMultiProtocolPatchEntered) + { + enterMultiProtocolSysPatch(); + enterMultiProtocolCpePatch(); + bMultiProtocolPatchEntered = 1; + } +#endif + enterMultiProtocolCpeHdPatch(); + configureMultiProtocolPatch(); +} + +void refreshMultiProtocolPatch(void) +{ + enterMultiProtocolCpeHdPatch(); + configureMultiProtocolPatch(); +} + +void cleanMultiProtocolPatch(void) +{ +#ifndef _MULTI_PROTOCOL_NO_PROG_STATE_VAR + bMultiProtocolPatchEntered = 0; +#endif +} + +void rf_patch_cpe_multi_protocol(void) +{ + applyMultiProtocolPatch(); +} + + +//***************************************************************************** +// +// Mark the end of the C bindings section for C++ compilers. +// +//***************************************************************************** +#ifdef __cplusplus +} +#endif + + diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol.h b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol.h index 6a19733..3cfe5f7 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_patch_cpe_multi_protocol.h -* Revised: $Date: 2019-02-27 16:13:01 +0100 (on, 27 feb 2019) $ -* Revision: $Revision: 18889 $ * * Description: RF core patch for multi-protocol support (all available API command sets) in CC13x2 and CC26x2 * -* Copyright (c) 2015-2019, Texas Instruments Incorporated +* Copyright (c) 2015-2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,186 +50,9 @@ extern "C" #include #include -#ifndef CPE_PATCH_TYPE -#define CPE_PATCH_TYPE static const uint32_t -#endif - -#ifndef SYS_PATCH_TYPE -#define SYS_PATCH_TYPE static const uint32_t -#endif - -#ifndef PATCH_FUN_SPEC -#define PATCH_FUN_SPEC static inline -#endif - -#ifndef _APPLY_PATCH_TAB -#define _APPLY_PATCH_TAB -#endif - - -CPE_PATCH_TYPE patchImageMultiProtocol[] = { - 0x21004061, - 0x210040cb, - 0x2100408d, - 0x2100410d, - 0x210040ed, - 0x79654c07, - 0xf809f000, - 0x40697961, - 0xd5030749, - 0x4a042101, - 0x60110389, - 0xb570bd70, - 0x47084902, - 0x21000380, - 0x40041108, - 0x0000592d, - 0xf819f000, - 0x296cb2e1, - 0x2804d00b, - 0x2806d001, - 0x490ed107, - 0x07c97809, - 0x7821d103, - 0xd4000709, - 0x490b2002, - 0x210c780a, - 0xd0024211, - 0x22804909, - 0xb003600a, - 0xb5f0bdf0, - 0x4907b083, - 0x48044708, - 0x22407801, - 0x70014391, - 0x47004804, - 0x210000c8, - 0x21000133, - 0xe000e200, - 0x00031641, - 0x00031b23, - 0x21014805, - 0x438a6802, - 0x6b836002, - 0x6383438b, - 0x6002430a, - 0x47004801, - 0x40046000, - 0x00005b3f, - 0x490cb510, - 0x4a0c4788, - 0x5e512106, - 0xd0072900, - 0xd0052902, - 0xd0032909, - 0xd0012910, - 0xd1072911, - 0x43c92177, - 0xdd014288, - 0xdd012800, - 0x43c0207f, - 0x0000bd10, - 0x000065a9, - 0x21000380, -}; -#define _NWORD_PATCHIMAGE_MULTI_PROTOCOL 63 - -#define _NWORD_PATCHCPEHD_MULTI_PROTOCOL 0 - -#define _NWORD_PATCHSYS_MULTI_PROTOCOL 0 - - - -#ifndef _MULTI_PROTOCOL_SYSRAM_START -#define _MULTI_PROTOCOL_SYSRAM_START 0x20000000 -#endif - -#ifndef _MULTI_PROTOCOL_CPERAM_START -#define _MULTI_PROTOCOL_CPERAM_START 0x21000000 -#endif - -#define _MULTI_PROTOCOL_SYS_PATCH_FIXED_ADDR 0x20000000 - -#define _MULTI_PROTOCOL_PATCH_VEC_ADDR_OFFSET 0x03D0 -#define _MULTI_PROTOCOL_PATCH_TAB_OFFSET 0x03D4 -#define _MULTI_PROTOCOL_IRQPATCH_OFFSET 0x0480 -#define _MULTI_PROTOCOL_PATCH_VEC_OFFSET 0x404C - -#define _MULTI_PROTOCOL_PATCH_CPEHD_OFFSET 0x04E0 - -#ifndef _MULTI_PROTOCOL_NO_PROG_STATE_VAR -static uint8_t bMultiProtocolPatchEntered = 0; -#endif - -PATCH_FUN_SPEC void enterMultiProtocolCpePatch(void) -{ -#if (_NWORD_PATCHIMAGE_MULTI_PROTOCOL > 0) - uint32_t *pPatchVec = (uint32_t *) (_MULTI_PROTOCOL_CPERAM_START + _MULTI_PROTOCOL_PATCH_VEC_OFFSET); - - memcpy(pPatchVec, patchImageMultiProtocol, sizeof(patchImageMultiProtocol)); -#endif -} - -PATCH_FUN_SPEC void enterMultiProtocolCpeHdPatch(void) -{ -#if (_NWORD_PATCHCPEHD_MULTI_PROTOCOL > 0) - uint32_t *pPatchCpeHd = (uint32_t *) (_MULTI_PROTOCOL_CPERAM_START + _MULTI_PROTOCOL_PATCH_CPEHD_OFFSET); - - memcpy(pPatchCpeHd, patchCpeHd, sizeof(patchCpeHd)); -#endif -} - -PATCH_FUN_SPEC void enterMultiProtocolSysPatch(void) -{ -} - -PATCH_FUN_SPEC void configureMultiProtocolPatch(void) -{ - uint8_t *pPatchTab = (uint8_t *) (_MULTI_PROTOCOL_CPERAM_START + _MULTI_PROTOCOL_PATCH_TAB_OFFSET); - - - pPatchTab[76] = 0; - pPatchTab[62] = 1; - pPatchTab[64] = 2; - pPatchTab[91] = 3; - pPatchTab[79] = 4; -} - -PATCH_FUN_SPEC void applyMultiProtocolPatch(void) -{ -#ifdef _MULTI_PROTOCOL_NO_PROG_STATE_VAR - enterMultiProtocolSysPatch(); - enterMultiProtocolCpePatch(); -#else - if (!bMultiProtocolPatchEntered) - { - enterMultiProtocolSysPatch(); - enterMultiProtocolCpePatch(); - bMultiProtocolPatchEntered = 1; - } -#endif - enterMultiProtocolCpeHdPatch(); - configureMultiProtocolPatch(); -} - -PATCH_FUN_SPEC void refreshMultiProtocolPatch(void) -{ - enterMultiProtocolCpeHdPatch(); - configureMultiProtocolPatch(); -} - -#ifndef _MULTI_PROTOCOL_NO_PROG_STATE_VAR -PATCH_FUN_SPEC void cleanMultiProtocolPatch(void) -{ - bMultiProtocolPatchEntered = 0; -} -#endif - -PATCH_FUN_SPEC void rf_patch_cpe_multi_protocol(void) -{ - applyMultiProtocolPatch(); -} - +extern void cleanMultiProtocolPatch(void); +extern void refreshMultiProtocolPatch(void); +extern void rf_patch_cpe_multi_protocol(void); //***************************************************************************** // diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol_rtls.c b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol_rtls.c new file mode 100644 index 0000000..2aa29c2 --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol_rtls.c @@ -0,0 +1,1084 @@ +/****************************************************************************** +* Filename: rf_patch_cpe_multi_protocol_rtls.c +* +* Description: RF core patch for multi-protocol support (all available API command sets) with RTLS components in CC13x2 and CC26x2 +* +* Copyright (c) 2015-2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ +//***************************************************************************** +// +// If building with a C++ compiler, make all of the definitions in this header +// have a C binding. +// +//***************************************************************************** +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +#include "rf_patch_cpe_multi_protocol_rtls.h" + +#ifndef CPE_PATCH_TYPE +#define CPE_PATCH_TYPE static const uint32_t +#endif + +#ifndef SYS_PATCH_TYPE +#define SYS_PATCH_TYPE static const uint32_t +#endif + +#ifndef PATCH_FUN_SPEC +#define PATCH_FUN_SPEC static +#endif + +#ifndef _APPLY_PATCH_TAB +#define _APPLY_PATCH_TAB +#endif + + +CPE_PATCH_TYPE patchImageMultiProtocolRtls[] = { + 0x21004099, + 0x2100492d, + 0x210049b5, + 0x210040b5, + 0x21004ba3, + 0x210040ed, + 0x21004157, + 0x21004119, + 0x21004c75, + 0x21004cb1, + 0x2100417d, + 0x21004189, + 0x21004195, + 0x21004d3d, + 0x210041c9, + 0x210041e1, + 0x210041f9, + 0x21004235, + 0x21004d97, + 0xd00507db, + 0xf803f000, + 0x70084902, + 0xb570bd70, + 0x47284d01, + 0x210004e0, + 0x0002241d, + 0x68084908, + 0x43902221, + 0x48076008, + 0x68c34700, + 0x230260c3, + 0xd1fd1e5b, + 0x68c32210, + 0x60c34393, + 0x4770618a, + 0x40048000, + 0x00005c01, + 0x4801b430, + 0x00004700, + 0x00020efd, + 0x79654c07, + 0xf809f000, + 0x40697961, + 0xd5030749, + 0x4a042101, + 0x60110389, + 0xb570bd70, + 0x47084902, + 0x21000380, + 0x40041108, + 0x0000592d, + 0xf819f000, + 0x296cb2e1, + 0x2804d00b, + 0x2806d001, + 0x490ed107, + 0x07c97809, + 0x7821d103, + 0xd4000709, + 0x490b2002, + 0x210c780a, + 0xd0024211, + 0x22804909, + 0xb003600a, + 0xb5f0bdf0, + 0x4907b083, + 0x48044708, + 0x22407801, + 0x70014391, + 0x47004804, + 0x210000c8, + 0x21000133, + 0xe000e200, + 0x00031641, + 0x00031b23, + 0x4700b570, + 0xfdc0f000, + 0x47004800, + 0x00007f57, + 0xfdc0f000, + 0x47004800, + 0x0000881b, + 0x0a9b9b03, + 0x2b834d08, + 0x4c08d10a, + 0x069b8923, + 0xb407d506, + 0xf805f000, + 0xd0002800, + 0xbc073542, + 0xb5704728, + 0x47004802, + 0x00020b1f, + 0x21000160, + 0x000209eb, + 0x781a4b09, + 0x43a22408, + 0xd0002800, + 0x701a4322, + 0x47104a00, + 0x00008e83, + 0x78084903, + 0xd4010700, + 0x47004802, + 0x00004770, + 0x21000380, + 0x00007e5f, + 0x4a094808, + 0x429a6803, + 0x4808d10a, + 0x4b088902, + 0xd0011ad2, + 0xd1032a01, + 0x49066e40, + 0x99034788, + 0x47184b05, + 0x210002a8, + 0x000203bd, + 0x21000160, + 0x00001821, + 0x000035f1, + 0x000006bd, + 0x20284a04, + 0x48044790, + 0x60412101, + 0x4a044803, + 0x47106041, + 0x0000424f, + 0x40045000, + 0x40046000, + 0x00004285, + 0x21004877, + 0x487775c1, + 0xb5704700, + 0x4d744c74, + 0x6a603c80, + 0xd11d2800, + 0x5d002054, + 0x28002200, + 0x2064d017, + 0x08805d00, + 0xd01207c0, + 0x888868a9, + 0x28010b80, + 0x486cd10d, + 0x08407dc0, + 0xd00807c0, + 0x30204869, + 0x68006980, + 0xd0022800, + 0x60a86229, + 0x622ae000, + 0x47804865, + 0x29006a61, + 0x6a29d103, + 0xd0002900, + 0xbd7060a9, + 0x4c5db5f8, + 0x3c804960, + 0x30404620, + 0x2a007d02, + 0x7e80d02e, + 0x28034d58, + 0x2804d002, + 0xe027d003, + 0x75e82001, + 0x2064e024, + 0x08805d00, + 0xd01f07c0, + 0x888068a8, + 0x28010b80, + 0x4851d11a, + 0x7dc07dea, + 0xd0132a00, + 0x07c008c0, + 0x4626d012, + 0x7b773620, + 0x46014788, + 0xd1084339, + 0x06097d21, + 0x8869d505, + 0x29010b89, + 0x2100d101, + 0xbdf87371, + 0xe7ea0880, + 0xbdf84788, + 0x4c40b5f8, + 0x3c804944, + 0x36204626, + 0x46257b70, + 0x90003540, + 0x00b8792f, + 0x68801840, + 0x28004780, + 0x493ad128, + 0x09097dc9, + 0xd02307c9, + 0x32644622, + 0xd0202f15, + 0x23007e29, + 0x07ff094f, + 0x7d6dd003, + 0xd0002d00, + 0x9f002301, + 0x43bb6fa5, + 0x7b73d012, + 0xd00f2b00, + 0x065b7d23, + 0x88d2d50c, + 0x2a010b92, + 0x08c9d108, + 0xd00507c9, + 0x0b8988a9, + 0xd1012901, + 0x73712100, + 0x7eabbdf8, + 0x2b017de9, + 0x2300d0e3, + 0xb510e7e1, + 0x3c804c1f, + 0x31404621, + 0x28017d08, + 0x481ed134, + 0x08407dc0, + 0xd02f07c0, + 0x30604620, + 0x08527942, + 0xd02907d2, + 0x0b808940, + 0xd1252801, + 0x09417e08, + 0xd00c07c9, + 0x07006fa1, + 0x0fc08809, + 0x04090240, + 0x66604308, + 0x1c806fa0, + 0xfd04f000, + 0x480ee013, + 0x69803020, + 0x28006840, + 0x4a0fd00e, + 0x78012300, + 0x1a5956d3, + 0x00c9d408, + 0x78411808, + 0xd00307c9, + 0x66616801, + 0x66a06840, + 0x47804808, + 0x0000bd10, + 0x210001e0, + 0x00022a15, + 0x210000c8, + 0x00023d8f, + 0x00023075, + 0x00025500, + 0x210004e0, + 0x00024959, + 0x4cf8b570, + 0x5d002044, + 0x008049f7, + 0x68801840, + 0x46054780, + 0xd0112801, + 0x5d00207e, + 0xd30d2805, + 0x06002021, + 0x00897e41, + 0x7f0a1809, + 0xd0072a02, + 0x77082003, + 0x49ed3480, + 0x478888a0, + 0xbd704628, + 0x77012104, + 0x700148ea, + 0xb5ffe7f4, + 0x7e9a4be5, + 0x49e81852, + 0x2182600a, + 0x09895cc9, + 0x49e6d178, + 0x29006909, + 0x680ad074, + 0x0e2e0415, + 0x3560461d, + 0xb2d47eed, + 0xd0222e01, + 0x006d2610, + 0x1eed46b6, + 0x7bdb3320, + 0x2b0146ac, + 0x1412d01e, + 0x4bdbb252, + 0x681b684d, + 0x00a43108, + 0x1f241864, + 0x402b1880, + 0x94023030, + 0x93004ad6, + 0x24019103, + 0x4ad56054, + 0x69142622, + 0x433c2710, + 0x22006114, + 0x2608e032, + 0x46b600ad, + 0xe7db1fad, + 0xe7e01612, + 0x4fcec910, + 0x402b4063, + 0x46239301, + 0x03642401, + 0x4cc8603c, + 0x60603440, + 0x3c404cc6, + 0x1a246864, + 0x4cc6d506, + 0x68273c80, + 0xd40104bf, + 0xe7fabf20, + 0x9c014fbf, + 0x9c02633c, + 0x42a14470, + 0x9903d900, + 0x68644cb9, + 0xd0064234, + 0x3c804cb7, + 0x27026826, + 0x602643be, + 0x1c522600, + 0xd3d14562, + 0x49b59c00, + 0x402c405c, + 0x684a3940, + 0xd4fc1a12, + 0x630448b0, + 0x210048b0, + 0x48b06041, + 0x22106901, + 0x61014391, + 0xe7ffbdff, + 0x212248a8, + 0x420a6842, + 0x49a6d0fc, + 0x68083980, + 0x43902202, + 0xe7f16008, + 0x4d9eb5f3, + 0x5d46202f, + 0xb08148a6, + 0x05806900, + 0x2e011600, + 0x1c40d002, + 0xe0001040, + 0x49a1301e, + 0x6a093140, + 0x4b954aa0, + 0x691a4351, + 0x6a1b0e09, + 0xd0222e01, + 0x01591852, + 0x316731ff, + 0x18544b93, + 0x68d93340, + 0xb2894f94, + 0xb2821a08, + 0x68783f40, + 0xd4fc1b00, + 0x462860da, + 0x90003060, + 0x49898381, + 0x31122050, + 0x35804788, + 0x980180a8, + 0xd0082800, + 0x990278aa, + 0xfadaf000, + 0x1852e007, + 0x31ce0119, + 0x488ae7dc, + 0x99006ac0, + 0x488977c8, + 0x68407829, + 0x08c14348, + 0xd00b2e01, + 0x380f4620, + 0x687a340e, + 0xd4fc1b12, + 0x0c0b4a83, + 0xb2896193, + 0xbdfe6151, + 0x380d4620, + 0xe7f23409, + 0x4c70b570, + 0x35604625, + 0x1e407fa8, + 0xd80d2802, + 0x28006aa0, + 0x2182d004, + 0x70015d09, + 0x62a01c40, + 0x1e406a60, + 0x7fa86260, + 0x77a81cc0, + 0x28057fa8, + 0xd112d322, + 0x28026a60, + 0x4971dd08, + 0x47881e80, + 0x62611c81, + 0xd0012800, + 0xbd702001, + 0x46082100, + 0xff7af7ff, + 0xf7ff2110, + 0x485efee8, + 0x6ac13840, + 0xd0fc07c9, + 0x3880485b, + 0x22026801, + 0x60014311, + 0x8ba84958, + 0x60c83140, + 0x36404626, + 0x49527930, + 0x18400080, + 0x47806880, + 0xd1de2800, + 0x29057fa9, + 0x7fead301, + 0x29047172, + 0x7de1d3d7, + 0xd1022900, + 0x29007e21, + 0x7eead0d1, + 0x015268e1, + 0x60e11889, + 0xb570bd70, + 0x20444d43, + 0x48475d46, + 0x38204942, + 0x00b07ec4, + 0x68801840, + 0x4b4e4780, + 0x781a09a1, + 0xd10a4211, + 0x21ff2221, + 0x76510612, + 0x2200493c, + 0x600a1f09, + 0x2101604a, + 0x212f7019, + 0x29025d49, + 0x2e31d008, + 0x07e1d003, + 0xd0032900, + 0x0861e003, + 0xe7f907c9, + 0x35802400, + 0xbd70706c, + 0x4c2db5f8, + 0x46272500, + 0x723d3760, + 0x5d00202f, + 0xd03a2802, + 0x47804839, + 0x36404626, + 0x7ff0492b, + 0x62203920, + 0x43087849, + 0x48287560, + 0x38406265, + 0x2d007fc5, + 0x7d20d006, + 0x43082120, + 0x06e87520, + 0x72380ec0, + 0x7f30492e, + 0x4a2e4788, + 0xd0112d00, + 0x61c5482d, + 0x20074b1c, + 0x63983b40, + 0x21054d1a, + 0x07806950, + 0x6868d1fc, + 0xd0f94208, + 0x30404825, + 0x63186800, + 0x28007f30, + 0x6e60d001, + 0x6be16210, + 0x47882039, + 0x20006420, + 0x4820bdf8, + 0xb5f0e7fa, + 0x20444909, + 0x2b045c43, + 0x460ad00a, + 0x78103268, + 0x28004f06, + 0x28ffd070, + 0x2b04d03f, + 0xe033d030, + 0x327b460a, + 0x0000e7f3, + 0x21000160, + 0x00025500, + 0x0000423d, + 0x21000020, + 0x40045080, + 0x210000e8, + 0x40022080, + 0x40043040, + 0xe000ed00, + 0xe000e280, + 0x400452c0, + 0x00155556, + 0x40046040, + 0x210002c0, + 0x40045180, + 0x0002175f, + 0x210004e1, + 0x00020749, + 0x00020e45, + 0x40042000, + 0x40042100, + 0x0002469d, + 0x014568cc, + 0x60cc1964, + 0x5c64242f, + 0xd1012c01, + 0x0e000640, + 0x20ff6248, + 0x202f7010, + 0x02004cd6, + 0x4dd56020, + 0x3d406a48, + 0x07d26862, + 0x220fd012, + 0x4ed263aa, + 0x2801e003, + 0x632edd07, + 0x28001e80, + 0x6862dd1a, + 0xd1f607d2, + 0x2007e006, + 0x20ff63a8, + 0xe0116328, + 0xdd0f2800, + 0x26146862, + 0xd0e34232, + 0x7b524ac7, + 0x60220212, + 0x22084bc6, + 0x4bc6601a, + 0x6248601a, + 0xbdf02001, + 0x19c00098, + 0x64086880, + 0xbdf02000, + 0x460148c1, + 0x7bca3120, + 0x76823060, + 0x73c82002, + 0x470048be, + 0x314049bc, + 0x28267108, + 0xdc12d038, + 0xd02f2809, + 0x2800dc08, + 0x2801d028, + 0x2804d020, + 0x2808d020, + 0xe023d117, + 0xd02b2815, + 0xd023281b, + 0xd110281f, + 0x2838e022, + 0xdc06d016, + 0xd0152831, + 0xd0152835, + 0xd1062836, + 0x283be014, + 0x283dd00a, + 0x2847d01a, + 0x49aad016, + 0x18400080, + 0x47706880, + 0x477048a8, + 0x477048a8, + 0x477048a8, + 0x477048a8, + 0x477048a8, + 0x477048a8, + 0x477048a8, + 0x477048a8, + 0x477048a8, + 0x477048a8, + 0x477048a8, + 0x4c9ab5f0, + 0x4621b085, + 0x91033120, + 0x21447bce, + 0x29075d09, + 0x2934d001, + 0x4625d17e, + 0x786a3580, + 0xd07a2a00, + 0x06897d21, + 0x498dd577, + 0x468e3180, + 0x2e017f09, + 0x0709d028, + 0x004b0f09, + 0x2301702b, + 0x469c025b, + 0x93002300, + 0x29009302, + 0x0993d030, + 0x07db4f94, + 0x7f3bd00b, + 0xd0012b00, + 0x401a23f7, + 0x33204b90, + 0x2b00781b, + 0x23efd001, + 0x0693401a, + 0x2b070f5b, + 0x08d3d00b, + 0xd00c07db, + 0x767a2200, + 0x321c4a88, + 0xe0139200, + 0x70290909, + 0x2201e7d7, + 0x46940292, + 0x0912e7f2, + 0xd00807d2, + 0x767a2201, + 0x32204a80, + 0x22019200, + 0x92020252, + 0x2100e000, + 0x23074a69, + 0x63d33a40, + 0x4a672322, + 0x421a6852, + 0x4a65d0fb, + 0x6b523a40, + 0x61da4b77, + 0x693b4f77, + 0x43932210, + 0x4b76613b, + 0x0792695a, + 0x4a74d1fc, + 0x68123240, + 0x06d370aa, + 0x1e9a0edb, + 0xd3002a13, + 0x46222302, + 0x92013260, + 0x76d33008, + 0xd0552900, + 0x7f7f4677, + 0x469600da, + 0x2a041bd2, + 0x2204da00, + 0xd0242e01, + 0xe0010093, + 0xe04fe053, + 0x330e4e65, + 0x467362b3, + 0x484c181b, + 0x62033840, + 0x4617434a, + 0xdd004562, + 0x48604667, + 0x60419902, + 0x19c99902, + 0x60811e49, + 0x22216801, + 0x60014311, + 0x1c766a26, + 0x62666226, + 0x7bc09803, + 0xd0062801, + 0x00d6e009, + 0x36164f54, + 0x011b62be, + 0x4954e7dc, + 0xf7ff483a, + 0x2e02face, + 0x78aadd06, + 0x98004639, + 0xf85cf000, + 0xe00f2102, + 0x98004639, + 0xfd40f7ff, + 0x3140494b, + 0x9a016ac9, + 0x210077d1, + 0xd0002e01, + 0xf7ff2108, + 0x2103fca6, + 0x77819801, + 0xbdf0b005, + 0x21019a01, + 0x6a217791, + 0x62211c49, + 0xe0026261, + 0x34602100, + 0x4a3c77a1, + 0x62912100, + 0x39404923, + 0x98036208, + 0x28017bc0, + 0x4820d1e8, + 0x06c968c1, + 0x2100d5fc, + 0x29021c49, + 0x4935dbfc, + 0xfa91f7ff, + 0x481fe7dc, + 0x4601b510, + 0x460a3160, + 0x232f7e89, + 0x29025419, + 0x7d01d010, + 0xd5130689, + 0x29016a01, + 0x6ec1dd10, + 0x06c97849, + 0x1e8b0ec9, + 0xd8092b12, + 0x1e5b7d43, + 0xe0067543, + 0xfa82f7ff, + 0xd0002800, + 0xbd102001, + 0x76d12100, + 0xbd102000, + 0x33804b20, + 0x7083695b, + 0x22017042, + 0x42910252, + 0x2102dd03, + 0x71017001, + 0x21014770, + 0x47707001, + 0x40045080, + 0x0000ffff, + 0x21000048, + 0xe000e280, + 0xe000e100, + 0x21000160, + 0x00020f47, + 0x00025500, + 0x21004919, + 0x21004813, + 0x21004785, + 0x2100472b, + 0x21004679, + 0x21004459, + 0x21004259, + 0x210042c1, + 0x21004263, + 0x21004335, + 0x210043b7, + 0x21000000, + 0x40042100, + 0x400451c0, + 0x40042000, + 0x40045300, + 0x40048000, + 0x40046000, + 0x490cb510, + 0x4a0c4788, + 0x5e512106, + 0xd0072900, + 0xd0052902, + 0xd0032909, + 0xd0012910, + 0xd1072911, + 0x43c92177, + 0xdd014288, + 0xdd012800, + 0x43c0207f, + 0x0000bd10, + 0x000065a9, + 0x21000380, + 0x4810b510, + 0x481088c1, + 0xd0182905, + 0x68214c0f, + 0x0052084a, + 0x6ba26022, + 0x00520852, + 0x602163a2, + 0xfa52f7ff, + 0x07006ba0, + 0x2001d408, + 0x60606020, + 0x1c402000, + 0xdbfc280c, + 0x62202014, + 0xf7ffbd10, + 0xbd10fa43, + 0x21000380, + 0x00005b3f, + 0x40046000, + 0x490c6b80, + 0x0f000700, + 0x47707148, + 0x490a4a09, + 0x79502318, + 0x7e4956cb, + 0x428118c0, + 0x4608dd01, + 0x280fe002, + 0x200fdd00, + 0x090989d1, + 0x43010109, + 0x477081d1, + 0x210002e0, + 0x21000088, + 0x47702000, + 0x4b252201, + 0x48232102, + 0xb5104718, + 0x47804823, + 0x6a404823, + 0xd10d2800, + 0x200a4922, + 0x28005608, + 0x1c40da09, + 0x4608d007, + 0x6a403820, + 0x4288491e, + 0x4780d100, + 0xf7ffbd10, + 0xbd10ffe3, + 0x4b1c2100, + 0x46084a1a, + 0x481b4718, + 0x780122fb, + 0x70014011, + 0x38ec4812, + 0xb5104700, + 0x47884917, + 0x39204911, + 0xd0072801, + 0xd5040402, + 0x85082000, + 0x62484813, + 0xbd102001, + 0x4b096a4a, + 0x429a3bec, + 0x4a10d101, + 0x4907e005, + 0x4b0f6a4a, + 0xd1f2429a, + 0x624a4a0e, + 0x0000bd10, + 0x00000806, + 0x0000069f, + 0x000292a1, + 0x21000108, + 0x21000154, + 0x00029263, + 0x21004d4b, + 0x0002b4b5, + 0x21000380, + 0x000296f7, + 0x21004d41, + 0x21004d87, + 0x00029569, + 0x21004d7d, + 0x07810882, + 0x0ec90092, + 0x78c0ca0c, + 0x424940ca, + 0x408b3120, + 0x0211431a, + 0x06000a09, + 0x47704308, +}; +#define _NWORD_PATCHIMAGE_MULTI_PROTOCOL_RTLS 888 + +CPE_PATCH_TYPE patchCpeHd[] = { + 0x00000000, +}; +#define _NWORD_PATCHCPEHD_MULTI_PROTOCOL_RTLS 1 + +#define _NWORD_PATCHSYS_MULTI_PROTOCOL_RTLS 0 + + + +#ifndef _MULTI_PROTOCOL_RTLS_SYSRAM_START +#define _MULTI_PROTOCOL_RTLS_SYSRAM_START 0x20000000 +#endif + +#ifndef _MULTI_PROTOCOL_RTLS_CPERAM_START +#define _MULTI_PROTOCOL_RTLS_CPERAM_START 0x21000000 +#endif + +#define _MULTI_PROTOCOL_RTLS_SYS_PATCH_FIXED_ADDR 0x20000000 + +#define _MULTI_PROTOCOL_RTLS_PATCH_VEC_ADDR_OFFSET 0x03D0 +#define _MULTI_PROTOCOL_RTLS_PATCH_TAB_OFFSET 0x03D4 +#define _MULTI_PROTOCOL_RTLS_IRQPATCH_OFFSET 0x0480 +#define _MULTI_PROTOCOL_RTLS_PATCH_VEC_OFFSET 0x404C + +#define _MULTI_PROTOCOL_RTLS_PATCH_CPEHD_OFFSET 0x04E0 + +#ifndef _MULTI_PROTOCOL_RTLS_NO_PROG_STATE_VAR +static uint8_t bMultiProtocolRtlsPatchEntered = 0; +#endif + +PATCH_FUN_SPEC void enterMultiProtocolRtlsCpePatch(void) +{ +#if (_NWORD_PATCHIMAGE_MULTI_PROTOCOL_RTLS > 0) + uint32_t *pPatchVec = (uint32_t *) (_MULTI_PROTOCOL_RTLS_CPERAM_START + _MULTI_PROTOCOL_RTLS_PATCH_VEC_OFFSET); + + memcpy(pPatchVec, patchImageMultiProtocolRtls, sizeof(patchImageMultiProtocolRtls)); +#endif +} + +PATCH_FUN_SPEC void enterMultiProtocolRtlsCpeHdPatch(void) +{ +#if (_NWORD_PATCHCPEHD_MULTI_PROTOCOL_RTLS > 0) + uint32_t *pPatchCpeHd = (uint32_t *) (_MULTI_PROTOCOL_RTLS_CPERAM_START + _MULTI_PROTOCOL_RTLS_PATCH_CPEHD_OFFSET); + + memcpy(pPatchCpeHd, patchCpeHd, sizeof(patchCpeHd)); +#endif +} + +PATCH_FUN_SPEC void enterMultiProtocolRtlsSysPatch(void) +{ +} + +PATCH_FUN_SPEC void configureMultiProtocolRtlsPatch(void) +{ + uint8_t *pPatchTab = (uint8_t *) (_MULTI_PROTOCOL_RTLS_CPERAM_START + _MULTI_PROTOCOL_RTLS_PATCH_TAB_OFFSET); + + + pPatchTab[21] = 0; + pPatchTab[1] = 1; + pPatchTab[18] = 2; + pPatchTab[81] = 3; + pPatchTab[26] = 4; + pPatchTab[76] = 5; + pPatchTab[62] = 6; + pPatchTab[64] = 7; + pPatchTab[91] = 8; + pPatchTab[79] = 9; + pPatchTab[140] = 10; + pPatchTab[150] = 11; + pPatchTab[13] = 12; + pPatchTab[31] = 13; + pPatchTab[152] = 14; + pPatchTab[151] = 15; + pPatchTab[40] = 16; + pPatchTab[73] = 17; + pPatchTab[164] = 18; +} + +PATCH_FUN_SPEC void applyMultiProtocolRtlsPatch(void) +{ +#ifdef _MULTI_PROTOCOL_RTLS_NO_PROG_STATE_VAR + enterMultiProtocolRtlsSysPatch(); + enterMultiProtocolRtlsCpePatch(); +#else + if (!bMultiProtocolRtlsPatchEntered) + { + enterMultiProtocolRtlsSysPatch(); + enterMultiProtocolRtlsCpePatch(); + bMultiProtocolRtlsPatchEntered = 1; + } +#endif + enterMultiProtocolRtlsCpeHdPatch(); + configureMultiProtocolRtlsPatch(); +} + +void refreshMultiProtocolRtlsPatch(void) +{ + enterMultiProtocolRtlsCpeHdPatch(); + configureMultiProtocolRtlsPatch(); +} + +void cleanMultiProtocolRtlsPatch(void) +{ +#ifndef _MULTI_PROTOCOL_RTLS_NO_PROG_STATE_VAR + bMultiProtocolRtlsPatchEntered = 0; +#endif +} + +void rf_patch_cpe_multi_protocol_rtls(void) +{ + applyMultiProtocolRtlsPatch(); +} + + +//***************************************************************************** +// +// Mark the end of the C bindings section for C++ compilers. +// +//***************************************************************************** +#ifdef __cplusplus +} +#endif + + diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol_rtls.h b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol_rtls.h index 6c6ddc9..49441cc 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol_rtls.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_multi_protocol_rtls.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_patch_cpe_multi_protocol_rtls.h -* Revised: $Date: 2019-02-27 16:13:01 +0100 (on, 27 feb 2019) $ -* Revision: $Revision: 18889 $ * * Description: RF core patch for multi-protocol support (all available API command sets) with RTLS components in CC13x2 and CC26x2 * -* Copyright (c) 2015-2019, Texas Instruments Incorporated +* Copyright (c) 2015-2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,1392 +50,9 @@ extern "C" #include #include -#ifndef CPE_PATCH_TYPE -#define CPE_PATCH_TYPE static const uint32_t -#endif - -#ifndef SYS_PATCH_TYPE -#define SYS_PATCH_TYPE static const uint32_t -#endif - -#ifndef PATCH_FUN_SPEC -#define PATCH_FUN_SPEC static inline -#endif - -#ifndef _APPLY_PATCH_TAB -#define _APPLY_PATCH_TAB -#endif - - -CPE_PATCH_TYPE patchImageMultiProtocolRtls[] = { - 0x21004631, - 0x21004683, - 0x21004075, - 0x2100486f, - 0x210040ad, - 0x21004117, - 0x210040d9, - 0x2100492d, - 0x21004139, - 0x21005349, - 0x68084908, - 0x43902221, - 0x48076008, - 0x68c34700, - 0x230260c3, - 0xd1fd1e5b, - 0x68c32210, - 0x60c34393, - 0x4770618a, - 0x40048000, - 0x00005c01, - 0x4801b430, - 0x00004700, - 0x00020efd, - 0x79654c07, - 0xf809f000, - 0x40697961, - 0xd5030749, - 0x4a042101, - 0x60110389, - 0xb570bd70, - 0x47084902, - 0x21000380, - 0x40041108, - 0x0000592d, - 0xf819f000, - 0x296cb2e1, - 0x2804d00b, - 0x2806d001, - 0x490ed107, - 0x07c97809, - 0x7821d103, - 0xd4000709, - 0x490b2002, - 0x210c780a, - 0xd0024211, - 0x22804909, - 0xb003600a, - 0xb5f0bdf0, - 0x4907b083, - 0x48044708, - 0x22407801, - 0x70014391, - 0x47004804, - 0x210000c8, - 0x21000133, - 0xe000e200, - 0x00031641, - 0x00031b23, - 0x21014805, - 0x438a6802, - 0x6b836002, - 0x6383438b, - 0x6002430a, - 0x47004801, - 0x40046000, - 0x00005b3f, - 0x4803b510, - 0x30106800, - 0xfe72f000, - 0x47084901, - 0x21000108, - 0x000095e3, - 0x4cffb570, - 0x5d002044, - 0x008049fe, - 0x68801840, - 0x46054780, - 0xd0112801, - 0x5d00207e, - 0xd30d2805, - 0x06002021, - 0x00897e41, - 0x7f0a1809, - 0xd0072a02, - 0x77082003, - 0x49f43480, - 0x478888a0, - 0xbd704628, - 0x77012104, - 0x700148f1, - 0xb5ffe7f4, - 0x7e934aec, - 0x49ef185b, - 0x3280600b, - 0x09897891, - 0x49edd16e, - 0x29006909, - 0x680bd06a, - 0x041bb2da, - 0x4be40e1c, - 0x7edb3360, - 0xd01b2c01, - 0x005b2410, - 0x1edb46a6, - 0x4be5469c, - 0x681b684d, - 0x00923108, - 0x1f121852, - 0x9202402b, - 0x4ae13030, - 0x93002401, - 0x60549103, - 0x26224adf, - 0x27106914, - 0x6114433c, - 0xe0302200, - 0x009b2408, - 0x1f9b46a6, - 0xc910e7e2, - 0x40634fd9, - 0x9301402b, - 0x24014623, - 0x603c0364, - 0x34404cd3, - 0x4cd26060, - 0x68643c40, - 0xd5061a24, - 0x3c804cd1, - 0x04bf6827, - 0xbf20d401, - 0x4fcbe7fa, - 0x633c9c01, - 0x44709c02, - 0xd90042a1, - 0x4cc59903, - 0x42346864, - 0x4cc3d006, - 0x68263c80, - 0x43be2702, - 0x26006026, - 0x45621c52, - 0x9c00d3d1, - 0x405c49c0, - 0x3940402c, - 0x1a12684a, - 0x48bcd4fc, - 0x48bc6304, - 0x60412100, - 0x690248bb, - 0x438a2110, - 0xbdff6102, - 0x212248b4, - 0x420a6842, - 0x4ab2d0fc, - 0x68103a80, - 0x43882102, - 0xbdff6010, - 0x4daab5f3, - 0x5d46202f, - 0xb08148b2, - 0x05806900, - 0x2e011600, - 0x1c40d002, - 0xe0001040, - 0x49ad301e, - 0x6a093140, - 0x4ba14aac, - 0x691a4351, - 0x6a1b0e09, - 0xd0222e01, - 0x01591852, - 0x316731ff, - 0x18544b9f, - 0x68d93340, - 0xb2894fa0, - 0xb2821a08, - 0x68783f40, - 0xd4fc1b00, - 0x462860da, - 0x90003060, - 0x49958381, - 0x31122050, - 0x35804788, - 0x980180a8, - 0xd0082800, - 0x990278aa, - 0xfabef000, - 0x1852e007, - 0x31ce0119, - 0x4896e7dc, - 0x99006ac0, - 0x489577c8, - 0x68407829, - 0x08c14348, - 0xd00b2e01, - 0x38134620, - 0x687a340e, - 0xd4fc1b12, - 0x0c0b4a8f, - 0xb2896193, - 0xbdfe6151, - 0x38114620, - 0xe7f23409, - 0x4c7cb570, - 0x35604625, - 0x1e407fa8, - 0xd80d2802, - 0x28006aa0, - 0x2182d004, - 0x70015d09, - 0x62a01c40, - 0x1e406a60, - 0x7fa86260, - 0x77a81cc0, - 0x28057fa8, - 0xd112d322, - 0x28026a60, - 0x497ddd08, - 0x47881e80, - 0x62611c81, - 0xd0012800, - 0xbd702001, - 0x46082100, - 0xff7af7ff, - 0xf7ff2110, - 0x486afef2, - 0x6ac13840, - 0xd0fc07c9, - 0x38804867, - 0x22026801, - 0x60014311, - 0x8ba84964, - 0x60c83140, - 0x36404626, - 0x495e7930, - 0x18400080, - 0x47806880, - 0xd1de2800, - 0x29057fa9, - 0x7fead301, - 0x29047172, - 0x7de1d3d7, - 0xd1022900, - 0x29007e21, - 0x7eead0d1, - 0x015268e1, - 0x60e11889, - 0xb570bd70, - 0x20444d4f, - 0x48535d46, - 0x3820494e, - 0x00b07ec4, - 0x68801840, - 0x4b5a4780, - 0x781a09a1, - 0xd10a4211, - 0x21ff2221, - 0x76510612, - 0x22004948, - 0x600a1f09, - 0x2101604a, - 0x212f7019, - 0x29025d49, - 0x2e31d008, - 0x07e1d003, - 0xd0032900, - 0x0861e003, - 0xe7f907c9, - 0x35802400, - 0xbd70706c, - 0x4c39b5f8, - 0x46272500, - 0x723d3760, - 0x5d00202f, - 0xd03a2802, - 0x47804845, - 0x36404626, - 0x7ff04937, - 0x62203920, - 0x43087849, - 0x48347560, - 0x38406265, - 0x2d007fc5, - 0x7d20d006, - 0x43082120, - 0x06e87520, - 0x72380ec0, - 0x7f30493a, - 0x4a3a4788, - 0xd0112d00, - 0x61c54839, - 0x20074b28, - 0x63983b40, - 0x21054d26, - 0x07806950, - 0x6868d1fc, - 0xd0f94208, - 0x30404831, - 0x63186800, - 0x28007f30, - 0x6e60d001, - 0x6be16210, - 0x47882039, - 0x20006420, - 0x482cbdf8, - 0xb5f0e7fa, - 0x20444915, - 0x2b045c43, - 0x460ad00a, - 0x78103268, - 0x28004f12, - 0x28ffd070, - 0x2b04d012, - 0xe006d003, - 0x327b460a, - 0x68cce7f3, - 0x19640145, - 0x242f60cc, - 0x2c015c64, - 0x0640d101, - 0x62480e00, - 0x701020ff, - 0x4c09202f, - 0x60200200, - 0x6a484d07, - 0x68623d40, - 0xd03f07d2, - 0xe02b220f, - 0x21000160, - 0x00025500, - 0x0000423d, - 0x21000020, - 0x40045080, - 0x210000e8, - 0x40022080, - 0x40043040, - 0xe000ed00, - 0xe000e280, - 0x400452c0, - 0x00155556, - 0x40046040, - 0x210002c0, - 0x40045180, - 0x0002175f, - 0x210004e0, - 0x00020749, - 0x00020e45, - 0x40042000, - 0x40042100, - 0x0002469d, - 0x4ec363aa, - 0x2801e003, - 0x632edd07, - 0x28001e80, - 0x6862dd1a, - 0xd1f607d2, - 0x2007e006, - 0x20ff63a8, - 0xe0116328, - 0xdd0f2800, - 0x26146862, - 0xd0b64232, - 0x7b524ab8, - 0x60220212, - 0x22084bb7, - 0x4bb7601a, - 0x6248601a, - 0xbdf02001, - 0x19c00098, - 0x64086880, - 0xbdf02000, - 0x460148b2, - 0x7bca3120, - 0x76823060, - 0x73c82002, - 0x470048af, - 0xb50049ad, - 0x71083140, - 0xd01c2831, - 0x4603dc08, - 0xfec0f000, - 0x0e13190a, - 0x0e0e150e, - 0x0e1d1b0e, - 0xd0122835, - 0xd0122836, - 0xd00a2838, - 0xd006283b, - 0x008049a3, - 0x68801840, - 0x48a2bd00, - 0x48a2bd00, - 0x48a2bd00, - 0x48a2bd00, - 0x48a2bd00, - 0x48a2bd00, - 0xb5f0bd00, - 0xb0854c98, - 0x31204621, - 0x7bce9103, - 0x5d092144, - 0xd0012907, - 0xd17e2934, - 0x35804625, - 0x2a00786a, - 0x7d21d07a, - 0xd5770689, - 0x3180498b, - 0x7f09468e, - 0xd0282e01, - 0x0f090709, - 0x702b004b, - 0x025b2301, - 0x2300469c, - 0x93029300, - 0xd0302900, - 0x4f8e0993, - 0xd00b07db, - 0x2b007f3b, - 0x23f7d001, - 0x4b8a401a, - 0x781b3320, - 0xd0012b00, - 0x401a23ef, - 0x0f5b0693, - 0xd00b2b07, - 0x07db08d3, - 0x2200d00c, - 0x4a82767a, - 0x9200321c, - 0x0909e013, - 0xe7d77029, - 0x02922201, - 0xe7f24694, - 0x07d20912, - 0x2201d008, - 0x4a7a767a, - 0x92003220, - 0x02522201, - 0xe0009202, - 0x4a772100, - 0x63d32307, - 0x4a752322, - 0x68523240, - 0xd0fa421a, - 0x6b524a72, - 0x61da4b72, - 0x693b4f72, - 0x43932210, - 0x4b71613b, - 0x0792695a, - 0x4a6fd1fc, - 0x68123240, - 0x06d370aa, - 0x1e9a0edb, - 0xd3002a13, - 0x46222302, - 0x92013260, - 0x76d33008, - 0xd0552900, - 0x7f7f4677, - 0x469600da, - 0x2a041bd2, - 0x2204da00, - 0xd0232e01, - 0x330e0093, - 0xe052e001, - 0x4e60e04e, - 0x467362b3, - 0x485a181b, - 0x434a6203, - 0x45624617, - 0x4667dd00, - 0x9902485b, - 0x99026041, - 0x1e4919c9, - 0x68016081, - 0x43112221, - 0x6a266001, - 0x62261c76, - 0x98036266, - 0x28017bc0, - 0xe00ad006, - 0x4f5000d6, - 0x62be3616, - 0xe7dd011b, - 0x494f4849, - 0xf7ff3040, - 0x2e02fc48, - 0x78aadd06, - 0x98004639, - 0xf85cf000, - 0xe00f2102, - 0x98004639, - 0xfd5cf7ff, - 0x31404946, - 0x9a016ac9, - 0x210077d1, - 0xd0002e01, - 0xf7ff2108, - 0x2103fccc, - 0x77819801, - 0xbdf0b005, - 0x21019a01, - 0x6a217791, - 0x62211c49, - 0xe0026261, - 0x34602100, - 0x4a3777a1, - 0x62912100, - 0x62084931, - 0x7bc09803, - 0xd1e92801, - 0x3040482e, - 0x06c968c1, - 0x2100d5fc, - 0x29021c49, - 0x4930dbfc, - 0xfc0bf7ff, - 0x481ee7dc, - 0x4601b510, - 0x460a3160, - 0x232f7e89, - 0x29025419, - 0x7d01d010, - 0xd5130689, - 0x29016a01, - 0x6ec1dd10, - 0x06c97849, - 0x1e8b0ec9, - 0xd8092b12, - 0x1e5b7d43, - 0xe0067543, - 0xfbfcf7ff, - 0xd0002800, - 0xbd102001, - 0x76d12100, - 0xbd102000, - 0x33804b1b, - 0x7083695b, - 0x22017042, - 0x42910252, - 0x2102dd03, - 0x71017001, - 0x21014770, - 0x47707001, - 0x0000ffff, - 0x21000048, - 0xe000e280, - 0xe000e100, - 0x21000160, - 0x00020f47, - 0x00025500, - 0x2100461d, - 0x21004517, - 0x21004489, - 0x2100442f, - 0x2100437d, - 0x21004171, - 0x21000000, - 0x40045040, - 0x40042100, - 0x400451c0, - 0x40042000, - 0x40045300, - 0x40048000, - 0x40046000, - 0x490cb510, - 0x4a0c4788, - 0x5e512106, - 0xd0072900, - 0xd0052902, - 0xd0032909, - 0xd0012910, - 0xd1072911, - 0x43c92177, - 0xdd014288, - 0xdd012800, - 0x43c0207f, - 0x0000bd10, - 0x000065a9, - 0x21000380, - 0x2500b570, - 0x614548ff, - 0xf000207d, - 0x4cfefcfd, - 0x07c06ae0, - 0x62e5d0fc, - 0xf0002082, - 0x48fbfcf5, - 0x07c96ac1, - 0x62c5d0fc, - 0x60a12101, - 0x60a56025, - 0x384048f6, - 0x60056081, - 0xbd706085, - 0x4bf4b530, - 0x68db685b, - 0xd00d2b00, - 0x189c0852, - 0x4def4aef, - 0xe0053240, - 0x079b6853, - 0x6b6bd5fc, - 0x1c405423, - 0xdbf74288, - 0xb5f7bd30, - 0x2400468e, - 0x00c9214b, - 0x49e8468c, - 0x684e4627, - 0x46254623, - 0x62544ae6, - 0x6ad24ae1, - 0x4ae307d1, - 0x68520fc9, - 0x42821b92, - 0x2701d900, - 0x6a524ae0, - 0xd006429a, - 0x684648dd, - 0x46604bde, - 0xb29d6adb, - 0x29014613, - 0x2f00d001, - 0x4ad6d0e6, - 0x6ad16ad0, - 0x0fc006c0, - 0x0fc90689, - 0x29014ed3, - 0x2801d101, - 0x210fd011, - 0x020968b0, - 0x1d404008, - 0x48cc6190, - 0x62c12100, - 0x62012101, - 0x68784fcc, - 0x99026130, - 0xd00e2902, - 0x9802e013, - 0xd1032802, - 0x684048c7, - 0x61486871, - 0x20004671, - 0xf7ff9a02, - 0x2401ff9b, - 0x6871e7ea, - 0x8d892c01, - 0x1a40d01c, - 0x48c160f0, - 0x0a2a6ac0, - 0x0a08b281, - 0xb2c91880, - 0x1889b2ea, - 0x084a0840, - 0x23ff1811, - 0x1a103301, - 0x02001a59, - 0xfc6cf000, - 0x68706170, - 0x8d828873, - 0x18d56931, - 0xe00468f0, - 0x30f01a40, - 0x6879e7e0, - 0x1a096131, - 0xd3fa42a9, - 0x21009d02, - 0xd0052d02, - 0xd1032c01, - 0x1a086931, - 0x1ac11a80, - 0x1a406930, - 0x2c0160f0, - 0x2000d002, - 0xbdfe43c0, - 0xbdfe2000, - 0x4ba6b510, - 0x2402499e, - 0x28002201, - 0x48a4d007, - 0x694861d8, - 0x61484390, - 0x43206948, - 0x48a1e006, - 0x694861d8, - 0x61484310, - 0x43a06948, - 0x499b6148, - 0x6bc83940, - 0x40184b9c, - 0x43032303, - 0x431063cb, - 0xbd1063c8, - 0x9c02b510, - 0x02240112, - 0x3c013cff, - 0x43143a10, - 0x430c1e49, - 0x61cc498b, - 0x4b8a624b, - 0x3b402202, - 0x2200605a, - 0x620a62ca, - 0x02004a87, - 0x79926852, - 0xd0022a02, - 0x61881cc0, - 0x1d00bd10, - 0x7808e7fb, - 0x62c84983, - 0x49804770, - 0x68896849, - 0xd0042900, - 0x18080840, - 0x7800497e, - 0x487a62c8, - 0x38402103, - 0x60416001, - 0x20014976, - 0x60486008, - 0xb5384770, - 0xf7ff4605, - 0x4872ffe8, - 0x62c12100, - 0x62012108, - 0x78234c71, - 0x68a09300, - 0x05004b77, - 0x78620f00, - 0xffb6f7ff, - 0xf7ff2000, - 0x6861ff91, - 0x68082d02, - 0x8dc8d100, - 0x2101462a, - 0xfef9f7ff, - 0xb5f7bd38, - 0x46154966, - 0x684a2000, - 0x46944607, - 0x6ac94960, - 0x496207ce, - 0x68490ff6, - 0x1a8a4662, - 0x428a9900, - 0x2701d900, - 0x6a4c495e, - 0xd0074284, - 0xd0012c00, - 0xe0002001, - 0xf7ff2000, - 0x4620ff69, - 0xd0012e01, - 0xd0e32f00, - 0x21004851, - 0x4a526141, - 0x4e526ad0, - 0x0fc006c0, - 0xd1032d00, - 0x685b4b50, - 0x61636874, - 0xd0012f00, - 0xd01d2800, - 0x462a2401, - 0x99012000, - 0xfea8f7ff, - 0x6ac0484b, - 0xb2810223, - 0xb2ca0a08, - 0x1a101811, - 0x02001a59, - 0xfb88f000, - 0x4a436170, - 0x61316851, - 0x79836870, - 0x432f461f, - 0x2b01d00e, - 0xe01ad014, - 0x68b0230f, - 0x4018021b, - 0x61901d40, - 0x62c14837, - 0x62012101, - 0xe7e82400, - 0x2c008d83, - 0x1ac9d002, - 0xe00731f0, - 0xe0051ac9, - 0xd1042d00, - 0x1ac98d83, - 0x310531ff, - 0x8d8160f1, - 0x23008877, - 0x19c9468c, - 0x68f06932, - 0x4a2ce002, - 0x61326852, - 0x428a1a12, - 0x2d00d3f9, - 0x2c00d006, - 0x6931d004, - 0x46601a09, - 0x1bc31a08, - 0x1ac06930, - 0x2c0060f0, - 0x2000d001, - 0x2000bdfe, - 0xbdfe43c0, - 0x4605b538, - 0xff39f7ff, - 0x2100481a, - 0x210862c1, - 0x4c1a6201, - 0x93007823, - 0x4b2068a0, - 0x0f000500, - 0xf7ff7862, - 0x2000ff07, - 0xfee2f7ff, - 0x2d006861, - 0xd1006808, - 0x462a8dc8, - 0xf7ff2101, - 0xbd38ff52, - 0x4c0db530, - 0x62e52500, - 0x3a100112, - 0x430a1e49, - 0x626361e2, - 0x1c800200, - 0x480961a0, - 0x60012101, - 0x61456942, - 0x32404a06, - 0x68406011, - 0xe0173028, - 0x40041100, - 0x40046000, - 0x40045040, - 0x210053e8, - 0x40043000, - 0x40045300, - 0x400451c0, - 0x40044040, - 0x08180532, - 0x0818070e, - 0xfff000ff, - 0x0000aaaa, - 0x318049ff, - 0xbd306008, - 0x4605b538, - 0xfee5f7ff, - 0x210048fc, - 0x210662c1, - 0x4cfb6201, - 0x78232108, - 0x68a09300, - 0x05004bf9, - 0x78620f00, - 0xffb8f7ff, - 0x48f749f8, - 0x200161c8, - 0xfe8af7ff, - 0x462a6860, - 0x21016800, - 0xfefdf7ff, - 0xb530bd38, - 0x4bf24df2, - 0x35804cf2, - 0xd00e2a40, - 0x58420089, - 0x625a0c12, - 0xb2925842, - 0x1808629a, - 0x0c096841, - 0x684062a1, - 0x6328b280, - 0x00c9bd30, - 0x0c125842, - 0x584262da, - 0x631ab292, - 0x68411808, - 0x62590c09, - 0xb2896841, - 0x68816299, - 0x49e00c0a, - 0x634a31c0, - 0xb2926882, - 0x68c1638a, - 0x62a10c09, - 0xe7e168c0, - 0x4606b5f0, - 0x2080b089, - 0xfa8ef000, - 0x2500b662, - 0x204f4cd2, - 0x60e56066, - 0x00c049d6, - 0x47889501, - 0x68606125, - 0x290079c1, - 0x21ffd001, - 0x30203101, - 0x4acf60a1, - 0x62117901, - 0x21207902, - 0xd1002a00, - 0x70212140, - 0x21027980, - 0xd1002800, - 0x48ca2101, - 0x47807061, - 0x49c06860, - 0x79403020, - 0x62c83180, - 0x478048c6, - 0x80602000, - 0x384048bf, - 0x48c56bc0, - 0x610149c3, - 0x90002000, - 0x684849b8, - 0x24003020, - 0x46267c40, - 0x46259405, - 0x90029403, - 0x48b3e20c, - 0x4ab02700, - 0x68506147, - 0x31504601, - 0x48ade001, - 0x42886840, - 0x48b8d3fb, - 0x48b64780, - 0x48b76147, - 0x7ac07ac1, - 0x0fc907c9, - 0x40102202, - 0xd0024301, - 0xb00948b3, - 0x48a5bdf0, - 0x80412100, - 0x97076847, - 0x7cf93720, - 0x90060860, - 0xfa32f000, - 0xd1142900, - 0x42a09805, - 0x9802d011, - 0xd03b2800, - 0x07c09902, - 0x0fc00849, - 0x28009102, - 0x7cb8d002, - 0x90024048, - 0x98027c39, - 0xfa1cf000, - 0x9807460d, - 0x6b409405, - 0x5bc200ef, - 0x428a9900, - 0x1db9d02e, - 0x1d395a43, - 0x5c439300, - 0x5c421cb9, - 0x5c411cf9, - 0xf000200e, - 0x488afa0d, - 0x68402201, - 0x6b402300, - 0x5bc04611, - 0xf0000400, - 0x488dfa09, - 0x48924780, - 0x29037801, - 0x4882d1fc, - 0x8f096841, - 0x497e8041, - 0x46026848, - 0xe0073238, - 0x7c381c6d, - 0x42a8b2ed, - 0x2500d8cd, - 0x6848e7cb, - 0xd3fc4290, - 0x68404878, - 0x5bc06b40, - 0x48799000, - 0x68813840, - 0xf000207e, - 0x4873f9eb, - 0x6a386847, - 0xd0062800, - 0x46200041, - 0xf9d0f000, - 0xd0052900, - 0x496de014, - 0x780a69b8, - 0xe0334621, - 0xd00b2c00, - 0x30204638, - 0x07ca7fc1, - 0x2201d018, - 0x43917782, - 0x496f77c1, - 0x608802d0, - 0x900469b8, - 0x90076a38, - 0x46200041, - 0xf9b2f000, - 0x42819807, - 0x2c00d113, - 0x4638d00f, - 0x7fc13020, - 0xd401078a, - 0xe7664869, - 0x77822202, - 0x401122fd, - 0x200177c1, - 0x02c04960, - 0x69f86088, - 0x46209004, - 0xf0006a39, - 0x4852f997, - 0x98047802, - 0xfec1f7ff, - 0xd1042c00, - 0x6840484e, - 0x28027980, - 0x9806d00c, - 0x484b9001, - 0x79806840, - 0xd0072801, - 0x28004f48, - 0x2802d058, - 0xe078d07e, - 0xe12f2402, - 0xf7ff4620, - 0xb280fe87, - 0x48414684, - 0x6ac33040, - 0x68504a40, - 0x98016907, - 0x1d4800c1, - 0x6850543b, - 0x1d086903, - 0x4660541d, - 0xd00e2800, - 0x20006852, - 0x691243c0, - 0x50502c00, - 0xe002d167, - 0xb2a41ca4, - 0x9803e053, - 0x90031c40, - 0x6857e04f, - 0x5dc02027, - 0xd0012801, - 0xe0146950, - 0x30804832, - 0x071b6a83, - 0x61530f1b, - 0x05806a80, - 0x2b070e80, - 0x3b10dd01, - 0x281f6153, - 0x3840dd01, - 0x0100b200, - 0x010018c0, - 0x30ff6150, - 0x30014b33, - 0xd3014298, - 0x61502000, - 0x30804824, - 0x69536a40, - 0x18c00200, - 0x5058693b, - 0xb2816950, - 0xe0ca207f, - 0xf7ff4620, - 0xb281fddf, - 0x30404817, - 0x48176ac3, - 0x69076840, - 0x00c09801, - 0x54bb1d42, - 0x1d034a13, - 0x29006852, - 0x54d56912, - 0x4910d04e, - 0x68492200, - 0x690943d2, - 0x500a2c00, - 0x1c76d0af, - 0x2c01b2b6, - 0xf7ffd8a8, - 0x4809fbf5, - 0x8d386847, - 0xe00042b0, - 0xd303e040, - 0x99038d7a, - 0xd27e428a, - 0x42884914, - 0xe054e028, - 0x40043000, - 0x40046000, - 0x210053e8, - 0x0000aaaa, - 0x08180532, - 0x40044040, - 0x40045140, - 0x40045300, - 0x0000424f, - 0x00009083, - 0x00004be3, - 0x0000c210, - 0x40041100, - 0x00000de5, - 0x21000128, - 0x04040003, - 0x210002e4, - 0x04060003, - 0x00000201, - 0x0000ffff, - 0x8d78d102, - 0xd06f4288, - 0x484d2101, - 0x60810449, - 0xe684484c, - 0x21004a4c, - 0x69126852, - 0xe75f5011, - 0xf7ff4620, - 0xb282fcc6, - 0x46946878, - 0x98016903, - 0x00c04639, - 0x549d1d02, - 0x6ad34a44, - 0x6917687a, - 0x54bb1d42, - 0x2a004662, - 0x6849d00a, - 0x43d22200, - 0x2c026909, - 0xd800500a, - 0x1c76e745, - 0xe73fb2b6, - 0x68494939, - 0x3120468c, - 0x290179c9, - 0x4938d125, - 0x07136a8a, - 0x0f1b4a37, - 0x6a896997, - 0x0f3f073f, - 0x69920589, - 0x05920e89, - 0x2b070e92, - 0x3b10dd00, - 0xdd002f07, - 0x291f3f10, - 0x3940dd01, - 0x2a1fb209, - 0x3a40dd03, - 0xe01fe000, - 0x0109b212, - 0x19c918c9, - 0x18890112, - 0x4924010a, - 0x4923614a, - 0x694a4b26, - 0x320132ff, - 0xd301429a, - 0x614a2200, - 0x6a524a20, - 0x0212694b, - 0x466218d3, - 0x50136912, - 0xb2816948, - 0xf0002083, - 0xe6fbf873, - 0x98018fb9, - 0xf856f000, - 0xd1072900, - 0x28009801, - 0x8778d004, - 0x48102101, - 0x608103c9, - 0x68414810, - 0x42a18889, - 0xe5ecd900, - 0x480b2101, - 0x60810409, - 0x1e49480b, - 0x8d026840, - 0xd103428a, - 0x42888d40, - 0xe5d3d100, - 0x98014906, - 0x87486849, - 0xf0002081, - 0x2000f825, - 0x0000e5ef, - 0x40041100, - 0x04030003, - 0x210053e8, - 0x40046040, - 0x400451c0, - 0x40045080, - 0x00000201, - 0x49068800, - 0xd1064288, - 0x21004805, - 0x49058501, - 0x20016241, - 0x20824770, - 0x00004770, - 0x00006801, - 0x21000108, - 0x21004159, - 0x4801b403, - 0xbd019001, - 0x00003cc3, - 0x4801b403, - 0xbd019001, - 0x0000937d, - 0x4801b403, - 0xbd019001, - 0x00009361, - 0x4801b403, - 0xbd019001, - 0x0000867b, - 0x4801b403, - 0xbd019001, - 0x000049a3, - 0x4801b403, - 0xbd019001, - 0x00003c8f, - 0x4801b403, - 0xbd019001, - 0x00003ca9, - 0x4674b430, - 0x78251e64, - 0x42ab1c64, - 0x461dd200, - 0x005b5d63, - 0xbc3018e3, - 0x00004718, - 0x08180532, - 0x0818070e, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, -}; -#define _NWORD_PATCHIMAGE_MULTI_PROTOCOL_RTLS 1261 - -CPE_PATCH_TYPE patchCpeHd[] = { - 0x00000000, -}; -#define _NWORD_PATCHCPEHD_MULTI_PROTOCOL_RTLS 1 - -#define _NWORD_PATCHSYS_MULTI_PROTOCOL_RTLS 0 - - - -#ifndef _MULTI_PROTOCOL_RTLS_SYSRAM_START -#define _MULTI_PROTOCOL_RTLS_SYSRAM_START 0x20000000 -#endif - -#ifndef _MULTI_PROTOCOL_RTLS_CPERAM_START -#define _MULTI_PROTOCOL_RTLS_CPERAM_START 0x21000000 -#endif - -#define _MULTI_PROTOCOL_RTLS_SYS_PATCH_FIXED_ADDR 0x20000000 - -#define _MULTI_PROTOCOL_RTLS_PATCH_VEC_ADDR_OFFSET 0x03D0 -#define _MULTI_PROTOCOL_RTLS_PATCH_TAB_OFFSET 0x03D4 -#define _MULTI_PROTOCOL_RTLS_IRQPATCH_OFFSET 0x0480 -#define _MULTI_PROTOCOL_RTLS_PATCH_VEC_OFFSET 0x404C - -#define _MULTI_PROTOCOL_RTLS_PATCH_CPEHD_OFFSET 0x04E0 - -#ifndef _MULTI_PROTOCOL_RTLS_NO_PROG_STATE_VAR -static uint8_t bMultiProtocolRtlsPatchEntered = 0; -#endif - -PATCH_FUN_SPEC void enterMultiProtocolRtlsCpePatch(void) -{ -#if (_NWORD_PATCHIMAGE_MULTI_PROTOCOL_RTLS > 0) - uint32_t *pPatchVec = (uint32_t *) (_MULTI_PROTOCOL_RTLS_CPERAM_START + _MULTI_PROTOCOL_RTLS_PATCH_VEC_OFFSET); - - memcpy(pPatchVec, patchImageMultiProtocolRtls, sizeof(patchImageMultiProtocolRtls)); -#endif -} - -PATCH_FUN_SPEC void enterMultiProtocolRtlsCpeHdPatch(void) -{ -#if (_NWORD_PATCHCPEHD_MULTI_PROTOCOL_RTLS > 0) - uint32_t *pPatchCpeHd = (uint32_t *) (_MULTI_PROTOCOL_RTLS_CPERAM_START + _MULTI_PROTOCOL_RTLS_PATCH_CPEHD_OFFSET); - - memcpy(pPatchCpeHd, patchCpeHd, sizeof(patchCpeHd)); -#endif -} - -PATCH_FUN_SPEC void enterMultiProtocolRtlsSysPatch(void) -{ -} - -PATCH_FUN_SPEC void configureMultiProtocolRtlsPatch(void) -{ - uint8_t *pPatchTab = (uint8_t *) (_MULTI_PROTOCOL_RTLS_CPERAM_START + _MULTI_PROTOCOL_RTLS_PATCH_TAB_OFFSET); - - - pPatchTab[1] = 0; - pPatchTab[18] = 1; - pPatchTab[81] = 2; - pPatchTab[26] = 3; - pPatchTab[76] = 4; - pPatchTab[62] = 5; - pPatchTab[64] = 6; - pPatchTab[91] = 7; - pPatchTab[79] = 8; - pPatchTab[168] = 9; -} - -PATCH_FUN_SPEC void applyMultiProtocolRtlsPatch(void) -{ -#ifdef _MULTI_PROTOCOL_RTLS_NO_PROG_STATE_VAR - enterMultiProtocolRtlsSysPatch(); - enterMultiProtocolRtlsCpePatch(); -#else - if (!bMultiProtocolRtlsPatchEntered) - { - enterMultiProtocolRtlsSysPatch(); - enterMultiProtocolRtlsCpePatch(); - bMultiProtocolRtlsPatchEntered = 1; - } -#endif - enterMultiProtocolRtlsCpeHdPatch(); - configureMultiProtocolRtlsPatch(); -} - -PATCH_FUN_SPEC void refreshMultiProtocolRtlsPatch(void) -{ - enterMultiProtocolRtlsCpeHdPatch(); - configureMultiProtocolRtlsPatch(); -} - -#ifndef _MULTI_PROTOCOL_RTLS_NO_PROG_STATE_VAR -PATCH_FUN_SPEC void cleanMultiProtocolRtlsPatch(void) -{ - bMultiProtocolRtlsPatchEntered = 0; -} -#endif - -PATCH_FUN_SPEC void rf_patch_cpe_multi_protocol_rtls(void) -{ - applyMultiProtocolRtlsPatch(); -} - +extern void cleanMultiProtocolRtlsPatch(void); +extern void refreshMultiProtocolRtlsPatch(void); +extern void rf_patch_cpe_multi_protocol_rtls(void); //***************************************************************************** // diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_prop.c b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_prop.c new file mode 100644 index 0000000..fb09a00 --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_prop.c @@ -0,0 +1,267 @@ +/****************************************************************************** +* Filename: rf_patch_cpe_prop.c +* +* Description: RF core patch for proprietary radio support ("PROP" API command set) in CC13x2 and CC26x2 +* +* Copyright (c) 2015-2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ +//***************************************************************************** +// +// If building with a C++ compiler, make all of the definitions in this header +// have a C binding. +// +//***************************************************************************** +#ifdef __cplusplus +extern "C" +{ +#endif + +#include +#include + +#include "rf_patch_cpe_prop.h" + +#ifndef CPE_PATCH_TYPE +#define CPE_PATCH_TYPE static const uint32_t +#endif + +#ifndef SYS_PATCH_TYPE +#define SYS_PATCH_TYPE static const uint32_t +#endif + +#ifndef PATCH_FUN_SPEC +#define PATCH_FUN_SPEC static +#endif + +#ifndef _APPLY_PATCH_TAB +#define _APPLY_PATCH_TAB +#endif + + +CPE_PATCH_TYPE patchImageProp[] = { + 0x2100406d, + 0x210040d7, + 0x21004099, + 0x210040f9, + 0x21004105, + 0x21004111, + 0x21004129, + 0x21004141, + 0x79654c07, + 0xf809f000, + 0x40697961, + 0xd5030749, + 0x4a042101, + 0x60110389, + 0xb570bd70, + 0x47084902, + 0x21000380, + 0x40041108, + 0x0000592d, + 0xf819f000, + 0x296cb2e1, + 0x2804d00b, + 0x2806d001, + 0x490ed107, + 0x07c97809, + 0x7821d103, + 0xd4000709, + 0x490b2002, + 0x210c780a, + 0xd0024211, + 0x22804909, + 0xb003600a, + 0xb5f0bdf0, + 0x4907b083, + 0x48044708, + 0x22407801, + 0x70014391, + 0x47004804, + 0x210000c8, + 0x21000133, + 0xe000e200, + 0x00031641, + 0x00031b23, + 0xf834f000, + 0x47004800, + 0x00007f57, + 0xf834f000, + 0x47004800, + 0x0000881b, + 0x781a4b09, + 0x43a22408, + 0xd0002800, + 0x701a4322, + 0x47104a00, + 0x00008e83, + 0x78084903, + 0xd4010700, + 0x47004802, + 0x00004770, + 0x21000380, + 0x00007e5f, + 0x20284a04, + 0x48044790, + 0x60412101, + 0x4a044803, + 0x47106041, + 0x0000424f, + 0x40045000, + 0x40046000, + 0x00004285, + 0x490c6b80, + 0x0f000700, + 0x47707148, + 0x490a4a09, + 0x79502318, + 0x7e4956cb, + 0x428118c0, + 0x4608dd01, + 0x280fe002, + 0x200fdd00, + 0x090989d1, + 0x43010109, + 0x477081d1, + 0x210002e0, + 0x21000088, +}; +#define _NWORD_PATCHIMAGE_PROP 85 + +#define _NWORD_PATCHCPEHD_PROP 0 + +#define _NWORD_PATCHSYS_PROP 0 + + + +#ifndef _PROP_SYSRAM_START +#define _PROP_SYSRAM_START 0x20000000 +#endif + +#ifndef _PROP_CPERAM_START +#define _PROP_CPERAM_START 0x21000000 +#endif + +#define _PROP_SYS_PATCH_FIXED_ADDR 0x20000000 + +#define _PROP_PATCH_VEC_ADDR_OFFSET 0x03D0 +#define _PROP_PATCH_TAB_OFFSET 0x03D4 +#define _PROP_IRQPATCH_OFFSET 0x0480 +#define _PROP_PATCH_VEC_OFFSET 0x404C + +#define _PROP_PATCH_CPEHD_OFFSET 0x04E0 + +#ifndef _PROP_NO_PROG_STATE_VAR +static uint8_t bPropPatchEntered = 0; +#endif + +PATCH_FUN_SPEC void enterPropCpePatch(void) +{ +#if (_NWORD_PATCHIMAGE_PROP > 0) + uint32_t *pPatchVec = (uint32_t *) (_PROP_CPERAM_START + _PROP_PATCH_VEC_OFFSET); + + memcpy(pPatchVec, patchImageProp, sizeof(patchImageProp)); +#endif +} + +PATCH_FUN_SPEC void enterPropCpeHdPatch(void) +{ +#if (_NWORD_PATCHCPEHD_PROP > 0) + uint32_t *pPatchCpeHd = (uint32_t *) (_PROP_CPERAM_START + _PROP_PATCH_CPEHD_OFFSET); + + memcpy(pPatchCpeHd, patchCpeHd, sizeof(patchCpeHd)); +#endif +} + +PATCH_FUN_SPEC void enterPropSysPatch(void) +{ +} + +PATCH_FUN_SPEC void configurePropPatch(void) +{ + uint8_t *pPatchTab = (uint8_t *) (_PROP_CPERAM_START + _PROP_PATCH_TAB_OFFSET); + + + pPatchTab[76] = 0; + pPatchTab[62] = 1; + pPatchTab[64] = 2; + pPatchTab[140] = 3; + pPatchTab[150] = 4; + pPatchTab[152] = 5; + pPatchTab[151] = 6; + pPatchTab[73] = 7; +} + +PATCH_FUN_SPEC void applyPropPatch(void) +{ +#ifdef _PROP_NO_PROG_STATE_VAR + enterPropSysPatch(); + enterPropCpePatch(); +#else + if (!bPropPatchEntered) + { + enterPropSysPatch(); + enterPropCpePatch(); + bPropPatchEntered = 1; + } +#endif + enterPropCpeHdPatch(); + configurePropPatch(); +} + +void refreshPropPatch(void) +{ + enterPropCpeHdPatch(); + configurePropPatch(); +} + +void cleanPropPatch(void) +{ +#ifndef _PROP_NO_PROG_STATE_VAR + bPropPatchEntered = 0; +#endif +} + +void rf_patch_cpe_prop(void) +{ + applyPropPatch(); +} + + +//***************************************************************************** +// +// Mark the end of the C bindings section for C++ compilers. +// +//***************************************************************************** +#ifdef __cplusplus +} +#endif + + diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_prop.h b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_prop.h index e9baefa..e21ce11 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_prop.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_cpe_prop.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_patch_cpe_prop.h -* Revised: $Date: 2019-02-27 16:13:01 +0100 (on, 27 feb 2019) $ -* Revision: $Revision: 18889 $ * * Description: RF core patch for proprietary radio support ("PROP" API command set) in CC13x2 and CC26x2 * -* Copyright (c) 2015-2019, Texas Instruments Incorporated +* Copyright (c) 2015-2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,159 +50,9 @@ extern "C" #include #include -#ifndef CPE_PATCH_TYPE -#define CPE_PATCH_TYPE static const uint32_t -#endif - -#ifndef SYS_PATCH_TYPE -#define SYS_PATCH_TYPE static const uint32_t -#endif - -#ifndef PATCH_FUN_SPEC -#define PATCH_FUN_SPEC static inline -#endif - -#ifndef _APPLY_PATCH_TAB -#define _APPLY_PATCH_TAB -#endif - - -CPE_PATCH_TYPE patchImageProp[] = { - 0x21004059, - 0x210040c3, - 0x21004085, - 0x79654c07, - 0xf809f000, - 0x40697961, - 0xd5030749, - 0x4a042101, - 0x60110389, - 0xb570bd70, - 0x47084902, - 0x21000380, - 0x40041108, - 0x0000592d, - 0xf819f000, - 0x296cb2e1, - 0x2804d00b, - 0x2806d001, - 0x490ed107, - 0x07c97809, - 0x7821d103, - 0xd4000709, - 0x490b2002, - 0x210c780a, - 0xd0024211, - 0x22804909, - 0xb003600a, - 0xb5f0bdf0, - 0x4907b083, - 0x48044708, - 0x22407801, - 0x70014391, - 0x47004804, - 0x210000c8, - 0x21000133, - 0xe000e200, - 0x00031641, - 0x00031b23, -}; -#define _NWORD_PATCHIMAGE_PROP 38 - -#define _NWORD_PATCHCPEHD_PROP 0 - -#define _NWORD_PATCHSYS_PROP 0 - - - -#ifndef _PROP_SYSRAM_START -#define _PROP_SYSRAM_START 0x20000000 -#endif - -#ifndef _PROP_CPERAM_START -#define _PROP_CPERAM_START 0x21000000 -#endif - -#define _PROP_SYS_PATCH_FIXED_ADDR 0x20000000 - -#define _PROP_PATCH_VEC_ADDR_OFFSET 0x03D0 -#define _PROP_PATCH_TAB_OFFSET 0x03D4 -#define _PROP_IRQPATCH_OFFSET 0x0480 -#define _PROP_PATCH_VEC_OFFSET 0x404C - -#define _PROP_PATCH_CPEHD_OFFSET 0x04E0 - -#ifndef _PROP_NO_PROG_STATE_VAR -static uint8_t bPropPatchEntered = 0; -#endif - -PATCH_FUN_SPEC void enterPropCpePatch(void) -{ -#if (_NWORD_PATCHIMAGE_PROP > 0) - uint32_t *pPatchVec = (uint32_t *) (_PROP_CPERAM_START + _PROP_PATCH_VEC_OFFSET); - - memcpy(pPatchVec, patchImageProp, sizeof(patchImageProp)); -#endif -} - -PATCH_FUN_SPEC void enterPropCpeHdPatch(void) -{ -#if (_NWORD_PATCHCPEHD_PROP > 0) - uint32_t *pPatchCpeHd = (uint32_t *) (_PROP_CPERAM_START + _PROP_PATCH_CPEHD_OFFSET); - - memcpy(pPatchCpeHd, patchCpeHd, sizeof(patchCpeHd)); -#endif -} - -PATCH_FUN_SPEC void enterPropSysPatch(void) -{ -} - -PATCH_FUN_SPEC void configurePropPatch(void) -{ - uint8_t *pPatchTab = (uint8_t *) (_PROP_CPERAM_START + _PROP_PATCH_TAB_OFFSET); - - - pPatchTab[76] = 0; - pPatchTab[62] = 1; - pPatchTab[64] = 2; -} - -PATCH_FUN_SPEC void applyPropPatch(void) -{ -#ifdef _PROP_NO_PROG_STATE_VAR - enterPropSysPatch(); - enterPropCpePatch(); -#else - if (!bPropPatchEntered) - { - enterPropSysPatch(); - enterPropCpePatch(); - bPropPatchEntered = 1; - } -#endif - enterPropCpeHdPatch(); - configurePropPatch(); -} - -PATCH_FUN_SPEC void refreshPropPatch(void) -{ - enterPropCpeHdPatch(); - configurePropPatch(); -} - -#ifndef _PROP_NO_PROG_STATE_VAR -PATCH_FUN_SPEC void cleanPropPatch(void) -{ - bPropPatchEntered = 0; -} -#endif - -PATCH_FUN_SPEC void rf_patch_cpe_prop(void) -{ - applyPropPatch(); -} - +extern void cleanPropPatch(void); +extern void refreshPropPatch(void); +extern void rf_patch_cpe_prop(void); //***************************************************************************** // diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_genook.c b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_genook.c new file mode 100644 index 0000000..3f30b76 --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_genook.c @@ -0,0 +1,585 @@ +/****************************************************************************** +* Filename: rf_patch_mce_genook.h +* +* Description: RF core patch for General OOK support in CC13x2 and CC26x2 +* +* Copyright (c) 2015-2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ + +#include +#include "rf_patch_mce_genook.h" +#include +#include DeviceFamily_constructPath(inc/hw_types.h) + +#ifndef MCE_PATCH_TYPE +#define MCE_PATCH_TYPE static const uint32_t +#endif + +#ifndef PATCH_FUN_SPEC +#define PATCH_FUN_SPEC +#endif + +#ifndef RFC_MCERAM_BASE +#define RFC_MCERAM_BASE 0x21008000 +#endif + +#ifndef MCE_PATCH_MODE +#define MCE_PATCH_MODE 0 +#endif + +MCE_PATCH_TYPE patchGenookMce[489] = { + 0x0000603b, + 0x01952fcf, + 0x7fff0001, + 0x030c003f, + 0x070c680a, + 0x00010000, + 0xaaaa000f, + 0x00fc00aa, + 0x272d8080, + 0x00170003, + 0x0000001f, + 0x04000000, + 0x0000000f, + 0x00020387, + 0x00434074, + 0x00028000, + 0x06f00020, + 0x091e0000, + 0x00540500, + 0x00000000, + 0x00505014, + 0x000f0000, + 0x007f7f30, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x72230000, + 0x73037263, + 0x72037305, + 0x73067304, + 0x73917204, + 0xc7c07291, + 0x00018001, + 0x90109001, + 0x90010801, + 0x720e720d, + 0x7210720f, + 0x7100b0d0, + 0xa0d0b110, + 0x8162721b, + 0x06701020, + 0x407d1e00, + 0x407e1e10, + 0x40681e20, + 0x06f23982, + 0x11011632, + 0x6c011421, + 0x61936193, + 0x633f6329, + 0x39423982, + 0x11011632, + 0x6c011421, + 0x60ef60ef, + 0x12206118, + 0x12106074, + 0x73117223, + 0x73137312, + 0x001081b1, + 0xb07091b0, + 0x60736050, + 0xc2b2c121, + 0x1820c4e0, + 0x6e236f13, + 0x16121611, + 0x78706882, + 0x78809c80, + 0x78909c90, + 0x78b09ca0, + 0x790099c0, + 0x94909480, + 0xc750c4f2, + 0x409a1820, + 0x6e231203, + 0x68971612, + 0x979078a0, + 0x81906073, + 0x81709640, + 0x2a703980, + 0x16111001, + 0x84b484a2, + 0xc0f5c0f3, + 0x1c01c200, + 0xc10040c1, + 0x40b71c10, + 0x10134cb9, + 0x18301803, + 0x1a101a13, + 0x68b43912, + 0x13f360c1, + 0x13f360c1, + 0xc1001015, + 0x1a151850, + 0x39141a10, + 0xb0e868bf, + 0xb1287100, + 0xb230a0e8, + 0xb012b002, + 0x22168246, + 0x817640c8, + 0x06f63d46, + 0x81708195, + 0x105106f0, + 0x65620611, + 0x68d13d15, + 0x22f08170, + 0x1a1644cb, + 0x87914cce, + 0x9a11d030, + 0x13f067cb, + 0x40e81c03, + 0x1021c0f0, + 0x65620611, + 0x68e33d12, + 0x1041c0f0, + 0x65620611, + 0x68e93d14, + 0x73117000, + 0xc0007312, + 0xb11191f0, + 0xc050b0d1, + 0xc0109910, + 0xc0089930, + 0x8ca3649d, + 0x39533983, + 0x82100613, + 0x410f2210, + 0x083181d1, + 0x65621017, + 0x39808160, + 0x1e103940, + 0x1071450e, + 0x65620a11, + 0x120160ff, + 0xb2346562, + 0xb111a0d1, + 0xc040a0d3, + 0x607367cb, + 0x73117223, + 0xc0007312, + 0xb11191f0, + 0xc050b0d1, + 0xc0109910, + 0xb2309930, + 0x22168246, + 0xb0024124, + 0xc008b012, + 0x78cac030, + 0x061110a1, + 0x391a6562, + 0xc0f0692c, + 0x10a178da, + 0x65620611, + 0x6933391a, + 0x78eac070, + 0x061110a1, + 0x391a6562, + 0xc090693a, + 0x10a178fa, + 0x65620611, + 0x6941391a, + 0x39838ca3, + 0x06133953, + 0x22108210, + 0xc0114157, + 0x65620831, + 0x67a781d1, + 0xc0016562, + 0x65620831, + 0xc011614a, + 0xc0016562, + 0xb2346562, + 0xb111a0d1, + 0xc050a0d3, + 0x607367cb, + 0x2208c029, + 0x22014568, + 0x6177417e, + 0x457e2201, + 0x22ff879f, + 0x65834177, + 0x92313111, + 0x10183911, + 0xc019811e, + 0xc0294576, + 0xb111617e, + 0x31117100, + 0x39119231, + 0xc0191018, + 0x7100b111, + 0x457e1a19, + 0x10f97000, + 0x04f9785f, + 0x10001000, + 0x10001000, + 0x10001000, + 0x10001000, + 0x10001000, + 0x45861a19, + 0x67617000, + 0x67cbc060, + 0xc01084ed, + 0x312d140d, + 0x8c9e142d, + 0x311e318e, + 0x8c99397e, + 0x39793149, + 0x31293949, + 0x99301090, + 0xb9147291, + 0xc662a914, + 0xb0029912, + 0xe070b012, + 0x9a2f9a1b, + 0xb63567cb, + 0x66aab63c, + 0x8c81a1b2, + 0x45bc22f1, + 0x22f18ca1, + 0x61f145bc, + 0x80b77100, + 0x460f2207, + 0x22b08090, + 0x105441c8, + 0x6648873c, + 0x61bc669f, + 0x22f18c81, + 0x223741d2, + 0xb13341d2, + 0x223080b0, + 0x61e045cd, + 0x41e522e1, + 0x22508090, + 0xb11541e5, + 0x22108240, + 0x993941bc, + 0xa914b914, + 0x61bcb116, + 0xb914993d, + 0xb116a914, + 0x8ca061bc, + 0x42eb22f0, + 0x42eb2237, + 0xb133b075, + 0x223080b0, + 0xb08745eb, + 0x710061bc, + 0x220780b7, + 0x2237460f, + 0x8090460e, + 0x420022b0, + 0x873c1054, + 0x669f6648, + 0x8c8161f1, + 0x41f122e1, + 0x22508090, + 0xb11541f1, + 0x22108240, + 0x993d41f1, + 0xa914b914, + 0x61f1b116, + 0xb130b1b2, + 0xb133a0f0, + 0xb074a0f3, + 0xa044b231, + 0x22408360, + 0xb0d24224, + 0x7100b112, + 0x22b08090, + 0x10544224, + 0x6648873c, + 0x621b669f, + 0xb112a0d2, + 0x9a1ad080, + 0xc00f67cb, + 0x7100c00e, + 0x22008090, + 0x873c4450, + 0x66481054, + 0x8160669f, + 0x06f03980, + 0x463a1e10, + 0x623b668b, + 0x8180667f, + 0x422b1e00, + 0x1cf01a10, + 0x62434e2b, + 0xa0d6622b, + 0xa0dbb116, + 0x6317b11b, + 0x8a72ba34, + 0x063189c1, + 0x42651e01, + 0x42571e21, + 0x425e1e31, + 0x14261056, + 0x10653916, + 0x10566266, + 0x18563126, + 0x39261426, + 0x62661065, + 0x31361056, + 0x14261856, + 0x10653936, + 0x10266266, + 0x39228242, + 0x4e741c26, + 0xc1011862, + 0x4e721c12, + 0x18211201, + 0x627c3121, + 0x627ccc01, + 0xc1011826, + 0x4e7b1c16, + 0x31211061, + 0xc401627c, + 0xb11b9731, + 0x1c8a7000, + 0x8240468a, + 0x1c043920, + 0xc0014e87, + 0xc0116288, + 0x161f91c1, + 0x1c8a7000, + 0x8730469e, + 0x3d803180, + 0x18701001, + 0x1e1e1017, + 0x3980469d, + 0x8ca13970, + 0x39513981, + 0x91c00810, + 0x0a1e161f, + 0x87317000, + 0x081010c0, + 0x42a62270, + 0x62a9120a, + 0x42a41cba, + 0x7000161a, + 0xb116b11b, + 0xb130b111, + 0xb115b133, + 0x720db112, + 0x720f720e, + 0xb0f0b0db, + 0x8c82b0f3, + 0x42bd22f2, + 0xb913b0d6, + 0x8ca062c0, + 0x42e022f0, + 0xa444b445, + 0xa469a468, + 0x3180caa0, + 0x0001caa1, + 0x94d194c1, + 0x31838ca3, + 0x84503983, + 0x39803180, + 0x00303183, + 0x84409450, + 0x39503150, + 0x39838ca3, + 0xc1f406f3, + 0x31841834, + 0x00403134, + 0xb0899440, + 0x42ea22e2, + 0x394a8c9a, + 0x312a398a, + 0xb0d5993a, + 0xb913b0d6, + 0xb23f7000, + 0xa0f3a0f0, + 0x993ea0db, + 0xa914b914, + 0xb130b116, + 0xb11bb133, + 0x22008240, + 0xb11542f6, + 0xa0048002, + 0xa001a006, + 0x72047203, + 0x67cbc090, + 0xb9147100, + 0xb0d5b116, + 0x7100a23f, + 0xa0d5b115, + 0x90307820, + 0x78309002, + 0x90609040, + 0xa23fb072, + 0x993a66aa, + 0xb116a914, + 0xba3c61b5, + 0x8b5481b0, + 0x31843924, + 0x91b40004, + 0x67cbc0a0, + 0x72917391, + 0x72067263, + 0x72047202, + 0x73067305, + 0x67616073, + 0x67cbc0b0, + 0xb0dbb118, + 0xb005b11b, + 0x7100b258, + 0x8ca0b11b, + 0x433922e0, + 0x22108240, + 0x66484331, + 0x39708730, + 0x679d0a10, + 0x67616331, + 0x67cbc0c0, + 0xb074b0db, + 0x89ce120c, + 0x1e0e398e, + 0x1210434f, + 0x1a2030e0, + 0x66487100, + 0x71006b4c, + 0x22e08ca0, + 0x82404356, + 0x43472210, + 0x39716648, + 0x91c10a11, + 0x1e048184, + 0x161c4347, + 0x43171cc4, + 0x12006347, + 0xb11891e0, + 0xb016b006, + 0xb014b004, + 0xb012b002, + 0x78628440, + 0x81730420, + 0x2a733983, + 0xc1f294e3, + 0x31621832, + 0x31511021, + 0x00200012, + 0x78209440, + 0x90509030, + 0x90407830, + 0xc04b9060, + 0x39308360, + 0x1e000630, + 0x300b4386, + 0x1a1b10b8, + 0xc00a3918, + 0xa234108f, + 0x8360a233, + 0x43942240, + 0xc022165f, + 0x639a67ac, + 0x439a2230, + 0xc022163f, + 0xb23367ac, + 0xb072b235, + 0x22007000, + 0xb00547a1, + 0x800063a6, + 0x43a62250, + 0xa005b270, + 0x82d27000, + 0x06123972, + 0x70000821, + 0x302084a0, + 0x39818191, + 0x1823c083, + 0x14103831, + 0x84b09590, + 0x84a13020, + 0x38313981, + 0x95a01410, + 0x302084c0, + 0x39818191, + 0x14103831, + 0x84d095b0, + 0x84c13020, + 0x38313981, + 0x95c01410, + 0x9a007000, + 0x220089f0, + 0xb9e047cc, + 0x00007000 +}; + +PATCH_FUN_SPEC void rf_patch_mce_genook(void) +{ +#ifdef __PATCH_NO_UNROLLING + uint32_t i; + for (i = 0; i < 489; i++) { + HWREG(RFC_MCERAM_BASE + 4 * i) = patchGenookMce[i]; + } +#else + const uint32_t *pS = patchGenookMce; + volatile unsigned long *pD = &HWREG(RFC_MCERAM_BASE); + uint32_t t1, t2, t3, t4, t5, t6, t7, t8; + uint32_t nIterations = 61; + + do { + t1 = *pS++; + t2 = *pS++; + t3 = *pS++; + t4 = *pS++; + t5 = *pS++; + t6 = *pS++; + t7 = *pS++; + t8 = *pS++; + *pD++ = t1; + *pD++ = t2; + *pD++ = t3; + *pD++ = t4; + *pD++ = t5; + *pD++ = t6; + *pD++ = t7; + *pD++ = t8; + } while (--nIterations); + + t1 = *pS++; + *pD++ = t1; +#endif +} diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_genook.h b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_genook.h new file mode 100644 index 0000000..6fabca1 --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_genook.h @@ -0,0 +1,46 @@ +/****************************************************************************** +* Filename: rf_patch_mce_genook.h +* +* Description: RF core patch for General OOK support in CC13x2 and CC26x2 +* +* Copyright (c) 2015-2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ + +#ifndef _RF_PATCH_MCE_GENOOK_H +#define _RF_PATCH_MCE_GENOOK_H + +#include +#include +#include DeviceFamily_constructPath(inc/hw_types.h) + +extern void rf_patch_mce_genook(void); + +#endif diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_iqdump.c b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_iqdump.c new file mode 100644 index 0000000..f38001e --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_iqdump.c @@ -0,0 +1,453 @@ +/****************************************************************************** +* Filename: rf_patch_mce_iqdump.h +* +* Description: RF core patch for IQ-dump support in CC13x2 PG2.1 and CC26x2 PG2.1 +* +* Copyright (c) 2015-2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ + +#include +#include "rf_patch_mce_iqdump.h" +#include +#include DeviceFamily_constructPath(inc/hw_types.h) + +#ifndef MCE_PATCH_TYPE +#define MCE_PATCH_TYPE static const uint32_t +#endif + +#ifndef PATCH_FUN_SPEC +#define PATCH_FUN_SPEC +#endif + +#ifndef RFC_MCERAM_BASE +#define RFC_MCERAM_BASE 0x21008000 +#endif + +#ifndef MCE_PATCH_MODE +#define MCE_PATCH_MODE 0 +#endif + +MCE_PATCH_TYPE patchIqdumpMce[360] = { + 0x2fcf6030, + 0x00013f9d, + 0xff00003f, + 0x07ff0fff, + 0x0300f800, + 0x00068080, + 0x00170003, + 0x00003d1f, + 0x08000000, + 0x0000000f, + 0x00000387, + 0x00434074, + 0x00828000, + 0x06f00080, + 0x091e0000, + 0x00540510, + 0x00000007, + 0x00505014, + 0xc02f0000, + 0x017f0c30, + 0x00000000, + 0x00000000, + 0x00000000, + 0x0000aa00, + 0x66c47223, + 0xa4e5a35d, + 0x73057303, + 0x73047203, + 0x72047306, + 0x72917391, + 0xffc0b008, + 0xa0089010, + 0x720e720d, + 0x7210720f, + 0x7100b0d0, + 0xa0d0b110, + 0x8162721b, + 0x39521020, + 0x0412c181, + 0x00200670, + 0x11011630, + 0x6c011401, + 0x60836082, + 0x613a60ff, + 0x60826082, + 0x60826082, + 0x60836082, + 0x61de60ff, + 0x60826082, + 0x60826082, + 0x60836082, + 0x614a60ff, + 0x60826082, + 0x60826082, + 0x60836082, + 0x61fa60ff, + 0x60826082, + 0x60826082, + 0x60836082, + 0x618260ff, + 0x72231210, + 0x73127311, + 0x81b17313, + 0x91b00010, + 0x6044b070, + 0xc0306078, + 0xc0c166ca, + 0xc4e0c2b2, + 0x6f131820, + 0x16116e23, + 0x68891612, + 0x99c07830, + 0x948078a0, + 0xc4f29490, + 0x1820c750, + 0x1203409b, + 0x16126e23, + 0x78b06898, + 0x72639990, + 0x6078b63c, + 0x96408190, + 0x39808170, + 0x10012a70, + 0x84a21611, + 0xc0f384b4, + 0xc200c0f5, + 0x40c41c01, + 0x1c10c100, + 0x4cbc40ba, + 0x18031013, + 0x1a131830, + 0x39121a10, + 0x60c468b7, + 0x60c413f3, + 0x101513f3, + 0x1850c100, + 0x1a101a15, + 0x68c23914, + 0x7100b0e8, + 0xa0e8b128, + 0xb910b230, + 0x99308990, + 0xb0d1b111, + 0xb0027100, + 0xb111b012, + 0x7291a0d1, + 0xb003b630, + 0x722cb013, + 0x7100b0e0, + 0x8170b120, + 0x710092c0, + 0x8170b120, + 0x44dd22f0, + 0x1c0313f0, + 0x92c340e9, + 0x71009642, + 0x92c5b120, + 0x71009644, + 0xb0e0b120, + 0x7000a630, + 0xc030a0e1, + 0xc0409910, + 0xb1119930, + 0x7100b0d1, + 0xa0d1b111, + 0xa0037291, + 0xa230a002, + 0x73117000, + 0x81607312, + 0x451022a0, + 0x66cac040, + 0x91f0c100, + 0xb63364a0, + 0xb0d3b113, + 0xa0d37100, + 0x607864f0, + 0x66cac050, + 0x91f0c030, + 0xb0e8b634, + 0xb1287100, + 0xb230a0e8, + 0xb012b002, + 0xb013b003, + 0x92f01200, + 0xb0e1b121, + 0xb1217100, + 0x06208210, + 0x45221e20, + 0x66cac060, + 0xb1217100, + 0x92f181d1, + 0x00000000, + 0x82120000, + 0x1e220622, + 0xc070412a, + 0xa63466ca, + 0x607864f0, + 0xa0f0a0d2, + 0x7311a0f3, + 0x663e7312, + 0x66cac080, + 0xc035b0d2, + 0x9b757100, + 0xb074ba38, + 0x6144b112, + 0xa0f0a0d2, + 0x7311a0f3, + 0x663e7312, + 0xc000c18b, + 0x120c91e0, + 0x786a1218, + 0x788e787d, + 0xb07410a9, + 0xc020b0d2, + 0x7100b112, + 0xc090695c, + 0xc03566ca, + 0x7100b112, + 0x8bf09b75, + 0x8ca165d3, + 0x416f2201, + 0x1ca81080, + 0x1208456e, + 0x65ca1618, + 0x65d38c00, + 0x22018ca1, + 0x1090417a, + 0x1e091a19, + 0x10a9457a, + 0x818465ca, + 0x41621e04, + 0x1c4c14bc, + 0x61624ead, + 0xa0f0a0d2, + 0x7311a0f3, + 0x663e7312, + 0x120c721e, + 0xb0741205, + 0xc020b0d2, + 0x7100b112, + 0xc0a0698e, + 0x789d66ca, + 0xb11289ce, + 0x8c907100, + 0x419e2200, + 0x22108230, + 0xb231459e, + 0x8ab29a3d, + 0x3d823182, + 0x31808af0, + 0x18023d80, + 0x1e0e063e, + 0x1e2e41c0, + 0x1e3e41b2, + 0x105641b9, + 0x3d161426, + 0x61c11065, + 0x31261056, + 0x14261856, + 0x10653d26, + 0x105661c1, + 0x18563136, + 0x3d361426, + 0x61c11065, + 0x39761026, + 0x818491c6, + 0x41951e04, + 0x1c4c161c, + 0x61954ead, + 0xc0b01001, + 0x391191c1, + 0x10001000, + 0x69cc1000, + 0x31307000, + 0x1cd03d30, + 0x1ce04dda, + 0x700049dc, + 0x700010d0, + 0x700010e0, + 0x66cac0b0, + 0xa0f0a0d2, + 0x7311a0f3, + 0x663e7312, + 0xb0f0b130, + 0x80b07100, + 0x45ed2200, + 0xb23161e8, + 0x66cac0c0, + 0xa0f0b130, + 0xc035b0d2, + 0x9b757100, + 0xb074ba38, + 0x61f4b112, + 0x66cac0d0, + 0xa0f0a0d2, + 0x7311a0f3, + 0x663e7312, + 0xc000c18b, + 0x120c91e0, + 0x786a1218, + 0x788e787d, + 0xb13010a9, + 0x7100b0f0, + 0x220080b0, + 0x620d4612, + 0xb231b074, + 0x66cac0e0, + 0xa0f0b130, + 0xc020b0d2, + 0x7100b112, + 0xc0356a1a, + 0x7100b112, + 0x8bf09b75, + 0x8ca165d3, + 0x422b2201, + 0x1ca81080, + 0x1208462a, + 0x65ca1618, + 0x65d38c00, + 0x22018ca1, + 0x10904236, + 0x1e091a19, + 0x10a94636, + 0x818465ca, + 0x421e1e04, + 0x1c4c14bc, + 0x621e4ead, + 0x22308240, + 0xb0d54646, + 0xb1157100, + 0x623ea0d5, + 0x66cac0f0, + 0xb006b118, + 0xb004b016, + 0xb002b014, + 0x8440b012, + 0x04207842, + 0x39838173, + 0x94e32a73, + 0x1832c1f2, + 0x10213162, + 0x00123151, + 0x94400020, + 0x16101030, + 0x22103930, + 0x12204264, + 0x10033150, + 0x16303180, + 0x12029380, + 0x22731204, + 0x84a04276, + 0x89829970, + 0x84c01a82, + 0x89849970, + 0x62781a84, + 0x42832263, + 0x997084b0, + 0x1a808980, + 0x84d01402, + 0x89809970, + 0x14041a80, + 0x84b0628f, + 0x04107851, + 0x89829970, + 0x84d01a42, + 0x04107851, + 0x89849970, + 0x31521a44, + 0x39633154, + 0x16130633, + 0x38343832, + 0x39823182, + 0x00423184, + 0x84a09722, + 0x84b09590, + 0x84c095a0, + 0x84d095b0, + 0x781095c0, + 0x90509030, + 0x90407820, + 0xb2359060, + 0x9170cd90, + 0xa2357000, + 0x7100b112, + 0xb112a0d2, + 0x81b0ba3c, + 0x39248b54, + 0x00043184, + 0xc10091b4, + 0x739166ca, + 0x66c47291, + 0x72027206, + 0x73057204, + 0x60787306, + 0xc8018630, + 0x04103151, + 0x70009630, + 0x89f09a00, + 0x46cb2200, + 0x7000b9e0 +}; + +PATCH_FUN_SPEC void rf_patch_mce_iqdump(void) +{ +#ifdef __PATCH_NO_UNROLLING + uint32_t i; + for (i = 0; i < 360; i++) { + HWREG(RFC_MCERAM_BASE + 4 * i) = patchIqdumpMce[i]; + } +#else + const uint32_t *pS = patchIqdumpMce; + volatile unsigned long *pD = &HWREG(RFC_MCERAM_BASE); + uint32_t t1, t2, t3, t4, t5, t6, t7, t8; + uint32_t nIterations = 45; + + do { + t1 = *pS++; + t2 = *pS++; + t3 = *pS++; + t4 = *pS++; + t5 = *pS++; + t6 = *pS++; + t7 = *pS++; + t8 = *pS++; + *pD++ = t1; + *pD++ = t2; + *pD++ = t3; + *pD++ = t4; + *pD++ = t5; + *pD++ = t6; + *pD++ = t7; + *pD++ = t8; + } while (--nIterations); +#endif +} diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_iqdump.h b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_iqdump.h index 12390d3..fc750eb 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_iqdump.h +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_iqdump.h @@ -1,11 +1,9 @@ /****************************************************************************** * Filename: rf_patch_mce_iqdump.h -* Revised: $Date: 2019-01-31 15:04:25 +0100 (to, 31 jan 2019) $ -* Revision: $Revision: 18842 $ * * Description: RF core patch for IQ-dump support in CC13x2 PG2.1 and CC26x2 PG2.1 * -* Copyright (c) 2015-2019, Texas Instruments Incorporated +* Copyright (c) 2015-2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,399 +38,9 @@ #define _RF_PATCH_MCE_IQDUMP_H #include -#include "../inc/hw_types.h" +#include +#include DeviceFamily_constructPath(inc/hw_types.h) -#ifndef MCE_PATCH_TYPE -#define MCE_PATCH_TYPE static const uint32_t -#endif - -#ifndef PATCH_FUN_SPEC -#define PATCH_FUN_SPEC static inline -#endif - -#ifndef RFC_MCERAM_BASE -#define RFC_MCERAM_BASE 0x21008000 -#endif - -#ifndef MCE_PATCH_MODE -#define MCE_PATCH_MODE 0 -#endif - -MCE_PATCH_TYPE patchIqdumpMce[337] = { - 0x2fcf6030, - 0x00013f9d, - 0xff00003f, - 0x07ff0fff, - 0x0300f800, - 0x00068080, - 0x00170003, - 0x00003d1f, - 0x08000000, - 0x0000000f, - 0x00000387, - 0x00434074, - 0x00828000, - 0x06f00080, - 0x091e0000, - 0x00540510, - 0x00000007, - 0x00505014, - 0xc02f0000, - 0x017f0c30, - 0x00000000, - 0x00000000, - 0x00000000, - 0x0000aa00, - 0x66957223, - 0xa4e5a35d, - 0x73057303, - 0x73047203, - 0x72047306, - 0x72917391, - 0xffc0b008, - 0xa0089010, - 0x720e720d, - 0x7210720f, - 0x7100b0d0, - 0xa0d0b110, - 0x8162721b, - 0x39521020, - 0x00200670, - 0x11011630, - 0x6c011401, - 0x60816080, - 0x610b60fd, - 0x60806080, - 0x60806080, - 0x60816080, - 0x61af60fd, - 0x60806080, - 0x60806080, - 0x60816080, - 0x611b60fd, - 0x60806080, - 0x60806080, - 0x60816080, - 0x61cb60fd, - 0x60806080, - 0x60806080, - 0x60816080, - 0x615360fd, - 0x72231210, - 0x73127311, - 0x81b17313, - 0x91b00010, - 0x6044b070, - 0xc0306076, - 0xc0c1669b, - 0xc4e0c2b2, - 0x6f131820, - 0x16116e23, - 0x68871612, - 0x99c07830, - 0x948078a0, - 0xc4f29490, - 0x1820c750, - 0x12034099, - 0x16126e23, - 0x78b06896, - 0x72639990, - 0x6076b63c, - 0x96408190, - 0x39808170, - 0x10012a70, - 0x84a21611, - 0xc0f384b4, - 0xc200c0f5, - 0x40c21c01, - 0x1c10c100, - 0x4cba40b8, - 0x18031013, - 0x1a131830, - 0x39121a10, - 0x60c268b5, - 0x60c213f3, - 0x101513f3, - 0x1850c100, - 0x1a101a15, - 0x68c03914, - 0x7100b0e8, - 0xa0e8b128, - 0xb910b230, - 0x99308990, - 0xb0d1b111, - 0xb0027100, - 0xb111b012, - 0x7291a0d1, - 0xb003b630, - 0x722cb013, - 0x7100b0e0, - 0x8170b120, - 0x710092c0, - 0x8170b120, - 0x44db22f0, - 0x1c0313f0, - 0x92c340e7, - 0x71009642, - 0x92c5b120, - 0x71009644, - 0xb0e0b120, - 0x7000a630, - 0xc030a0e1, - 0xc0409910, - 0xb1119930, - 0x7100b0d1, - 0xa0d1b111, - 0xa0037291, - 0xa230a002, - 0x73117000, - 0xc0407312, - 0xc100669b, - 0x649e91f0, - 0xb113b633, - 0x7100b0d3, - 0x64eea0d3, - 0xa0d26076, - 0xa0f3a0f0, - 0x73127311, - 0xc050660f, - 0xb0d2669b, - 0x7100c035, - 0xba389b75, - 0xb112b074, - 0xa0d26115, - 0xa0f3a0f0, - 0x73127311, - 0xc18b660f, - 0x91e0c000, - 0x1218120c, - 0x787d786a, - 0x10a9788e, - 0xb0d2b074, - 0xb112c020, - 0x692d7100, - 0x669bc060, - 0xb112c035, - 0x9b757100, - 0x65a48bf0, - 0x22018ca1, - 0x10804140, - 0x453f1ca8, - 0x16181208, - 0x8c00659b, - 0x8ca165a4, - 0x414b2201, - 0x1a191090, - 0x454b1e09, - 0x659b10a9, - 0x1e048184, - 0x14bc4133, - 0x4e7e1c4c, - 0xa0d26133, - 0xa0f3a0f0, - 0x73127311, - 0x721e660f, - 0x1205120c, - 0xb0d2b074, - 0xb112c020, - 0x695f7100, - 0x669bc070, - 0x89ce789d, - 0x7100b112, - 0x22008c90, - 0x8230416f, - 0x456f2210, - 0x9a3db231, - 0x31828ab2, - 0x8af03d82, - 0x3d803180, - 0x063e1802, - 0x41911e0e, - 0x41831e2e, - 0x418a1e3e, - 0x14261056, - 0x10653d16, - 0x10566192, - 0x18563126, - 0x3d261426, - 0x61921065, - 0x31361056, - 0x14261856, - 0x10653d36, - 0x10266192, - 0x91c63976, - 0x1e048184, - 0x161c4166, - 0x4e7e1c4c, - 0x10016166, - 0x91c1c0b0, - 0x10003911, - 0x10001000, - 0x7000699d, - 0x3d303130, - 0x4dab1cd0, - 0x49ad1ce0, - 0x10d07000, - 0x10e07000, - 0xc0807000, - 0xa0d2669b, - 0xa0f3a0f0, - 0x73127311, - 0xb130660f, - 0x7100b0f0, - 0x220080b0, - 0x61b945be, - 0xc090b231, - 0xb130669b, - 0xb0d2a0f0, - 0x7100c035, - 0xba389b75, - 0xb112b074, - 0xc0a061c5, - 0xa0d2669b, - 0xa0f3a0f0, - 0x73127311, - 0xc18b660f, - 0x91e0c000, - 0x1218120c, - 0x787d786a, - 0x10a9788e, - 0xb0f0b130, - 0x80b07100, - 0x45e32200, - 0xb07461de, - 0xc0b0b231, - 0xb130669b, - 0xb0d2a0f0, - 0xb112c020, - 0x69eb7100, - 0xb112c035, - 0x9b757100, - 0x65a48bf0, - 0x22018ca1, - 0x108041fc, - 0x45fb1ca8, - 0x16181208, - 0x8c00659b, - 0x8ca165a4, - 0x42072201, - 0x1a191090, - 0x46071e09, - 0x659b10a9, - 0x1e048184, - 0x14bc41ef, - 0x4e7e1c4c, - 0x824061ef, - 0x46172230, - 0x7100b0d5, - 0xa0d5b115, - 0xc0c0620f, - 0xb118669b, - 0xb016b006, - 0xb014b004, - 0xb012b002, - 0x78428440, - 0x81730420, - 0x2a733983, - 0xc1f294e3, - 0x31621832, - 0x31511021, - 0x00200012, - 0x10309440, - 0x39301610, - 0x42352210, - 0x31501220, - 0x31801003, - 0x93801630, - 0x12041202, - 0x42472273, - 0x997084a0, - 0x1a828982, - 0x997084c0, - 0x1a848984, - 0x22636249, - 0x84b04254, - 0x89809970, - 0x14021a80, - 0x997084d0, - 0x1a808980, - 0x62601404, - 0x785184b0, - 0x99700410, - 0x1a428982, - 0x785184d0, - 0x99700410, - 0x1a448984, - 0x31543152, - 0x06333963, - 0x38321613, - 0x31823834, - 0x31843982, - 0x97220042, - 0x959084a0, - 0x95a084b0, - 0x95b084c0, - 0x95c084d0, - 0x90307810, - 0x78209050, - 0x90609040, - 0xcd90b235, - 0x70009170, - 0xb112a235, - 0xa0d27100, - 0xba3cb112, - 0x8b5481b0, - 0x31843924, - 0x91b40004, - 0x669bc0d0, - 0x72917391, - 0x72066695, - 0x72047202, - 0x73067305, - 0x86306076, - 0x3151c801, - 0x96300410, - 0x9a007000, - 0x220089f0, - 0xb9e0469c, - 0x00007000 -}; - -PATCH_FUN_SPEC void rf_patch_mce_iqdump(void) -{ -#ifdef __PATCH_NO_UNROLLING - uint32_t i; - for (i = 0; i < 337; i++) { - HWREG(RFC_MCERAM_BASE + 4 * i) = patchIqdumpMce[i]; - } -#else - const uint32_t *pS = patchIqdumpMce; - volatile unsigned long *pD = &HWREG(RFC_MCERAM_BASE); - uint32_t t1, t2, t3, t4, t5, t6, t7, t8; - uint32_t nIterations = 42; - - do { - t1 = *pS++; - t2 = *pS++; - t3 = *pS++; - t4 = *pS++; - t5 = *pS++; - t6 = *pS++; - t7 = *pS++; - t8 = *pS++; - *pD++ = t1; - *pD++ = t2; - *pD++ = t3; - *pD++ = t4; - *pD++ = t5; - *pD++ = t6; - *pD++ = t7; - *pD++ = t8; - } while (--nIterations); - - t1 = *pS++; - *pD++ = t1; -#endif -} +extern void rf_patch_mce_iqdump(void); #endif diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_tof.h b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_tof.h deleted file mode 100644 index eeabf34..0000000 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_mce_tof.h +++ /dev/null @@ -1,609 +0,0 @@ -/****************************************************************************** -* Filename: rf_patch_mce_tof.h -* Revised: $Date: 2019-01-31 15:04:59 +0100 (to, 31 jan 2019) $ -* Revision: $Revision: 18843 $ -* -* Description: RF core MCE patch for time of flight 2Mbps PHY for CC13x2 and CC26x2 -* -* Copyright (c) 2015-2019, Texas Instruments Incorporated -* 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 ORGANIZATION 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. -* -******************************************************************************/ - -#ifndef _RF_PATCH_MCE_TOF_H -#define _RF_PATCH_MCE_TOF_H - -#include -#include "../inc/hw_types.h" - -#ifndef MCE_PATCH_TYPE -#define MCE_PATCH_TYPE static const uint32_t -#endif - -#ifndef PATCH_FUN_SPEC -#define PATCH_FUN_SPEC static inline -#endif - -#ifndef RFC_MCERAM_BASE -#define RFC_MCERAM_BASE 0x21008000 -#endif - -#ifndef MCE_PATCH_MODE -#define MCE_PATCH_MODE 0 -#endif - -MCE_PATCH_TYPE patchTofMce[506] = { - 0x0003605b, - 0x00f1000f, - 0x00000000, - 0x000c8000, - 0x00000000, - 0x0c650000, - 0x80000000, - 0x00800010, - 0x00000000, - 0x0594091e, - 0x00000350, - 0x7c200000, - 0x000000c2, - 0x34340013, - 0x0003005a, - 0x00000032, - 0xfe6b2840, - 0xdeade8ca, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x07d00011, - 0x6fdd2fea, - 0x0fb00ff0, - 0xf80f0003, - 0x007f7f30, - 0x3434001f, - 0x8010005a, - 0x01900000, - 0x40000800, - 0xc0300c65, - 0x722367ee, - 0xa35d7263, - 0x73057303, - 0x73047203, - 0x72047306, - 0x72917391, - 0x8001c7c0, - 0x90010001, - 0x08019010, - 0x720d9001, - 0x720f720e, - 0xb0d07210, - 0xc0407100, - 0xa0d067ee, - 0x721bb110, - 0x10208162, - 0x06703952, - 0x16300020, - 0x14011101, - 0x60936c01, - 0x60c260a4, - 0x6219617b, - 0x60936093, - 0x60936093, - 0x60c260a4, - 0x6219617b, - 0x60936093, - 0x60976093, - 0x12206095, - 0xc050609a, - 0x121267ee, - 0x73117223, - 0x73137312, - 0x81b17314, - 0x91b20012, - 0x6073b070, - 0xc2b2c011, - 0x1820c710, - 0x6e236f13, - 0x16121611, - 0x7d7068a8, - 0xc0229990, - 0x39818161, - 0xd0601812, - 0x67ee9a12, - 0x40971e01, - 0x99907d80, - 0x93807d50, - 0x93307d60, - 0x93007d90, - 0x6097b360, - 0xc07067e5, - 0x677e67ee, - 0x91f0c070, - 0x670bb750, - 0xb233b914, - 0xa750672d, - 0x95b488d4, - 0x95c488e4, - 0x95948ca4, - 0x95a487c4, - 0x2a007cb0, - 0x88d49060, - 0x88e495d4, - 0xc0f495e4, - 0x91449134, - 0x22008c80, - 0xb0f040e5, - 0xb0f6b130, - 0xb0d5b0d0, - 0xb110b136, - 0xb140b100, - 0x73137314, - 0x2a007cb0, - 0xc0f19060, - 0x40f51e0e, - 0x99311611, - 0xc037b912, - 0xb115b041, - 0xa910c031, - 0xb0737100, - 0xba3eb910, - 0x22008090, - 0x80b24574, - 0x45182262, - 0x220280c2, - 0xb061410b, - 0x2250b140, - 0x824040f9, - 0x45152200, - 0x40f9220f, - 0x679e100f, - 0x100f60f9, - 0x60f967b4, - 0xb234a913, - 0x93acba39, - 0xa0d58462, - 0xb0d1720f, - 0x7100b111, - 0xb1119937, - 0xb35d7100, - 0x9930c3f0, - 0xc0d0b074, - 0x894193f0, - 0x67bf9791, - 0x14018941, - 0x7100b111, - 0xba3aba3b, - 0xc210b078, - 0xa2329930, - 0xb111b235, - 0xa35d7100, - 0x7291b06e, - 0x8af2a0d1, - 0x3d823182, - 0x67eec080, - 0x8c528c33, - 0x8c441423, - 0x14248c62, - 0x06f28b32, - 0x31418b21, - 0x97a20012, - 0x0424cff2, - 0x31433143, - 0x97b40034, - 0x6957c8f0, - 0xb130b235, - 0xb136a0f0, - 0xb140a0f6, - 0xb914a100, - 0xa7507291, - 0xa002a003, - 0x9010c7c0, - 0x72047203, - 0x73067305, - 0xa23267e5, - 0x8242b235, - 0x456b1e02, - 0xc0907223, - 0x609767ee, - 0xa232b235, - 0xd0a08942, - 0x67ee9a12, - 0x67e56159, - 0x677ec00f, - 0x91f0c070, - 0xc0b0670b, - 0xb01367ee, - 0x22008c80, - 0xb0f04189, - 0xb0f6b130, - 0xb0d5b0d0, - 0xb136b111, - 0x72917313, - 0xc0e1b912, - 0x41951e0e, - 0x99311611, - 0xb041c037, - 0xc031b232, - 0xb115a910, - 0xb0737100, - 0xba3eb910, - 0x22008090, - 0x80b24614, - 0x45b32262, - 0x41992250, - 0x22008240, - 0x220f45b0, - 0x100f4199, - 0x6199679e, - 0x67b4100f, - 0xb9136199, - 0xba39b234, - 0xa0d593ac, - 0x7313720f, - 0x73147210, - 0x264081b0, - 0xb0d191b0, - 0x7100b111, - 0x9937b041, - 0x7100b111, - 0xc3f0b35d, - 0xb0749930, - 0x93f0c0d0, - 0x7100b111, - 0xc210b078, - 0xa2329930, - 0x7100b111, - 0xb06ea35d, - 0xa0d1a910, - 0x899167bf, - 0x81a01401, - 0x99311401, - 0xb0d6b116, - 0xb1167100, - 0x8090a0d6, - 0x46142200, - 0x88d4b012, - 0x88e495b4, - 0x8ca495c4, - 0x87c49594, - 0x729195a4, - 0x2a208230, - 0x92302630, - 0xc070672d, - 0x8af287b1, - 0x3d823182, - 0x69fbc310, - 0xb111b064, - 0xa0f6b136, - 0xa0f0b130, - 0x8242b235, - 0x46021e02, - 0x7291b914, - 0xa002a003, - 0x9010c7c0, - 0x72047203, - 0x73067305, - 0x67eec0c0, - 0x609767e5, - 0x67eec0d0, - 0x7291b235, - 0x677e6202, - 0xc070c00b, - 0x670b91f0, - 0x67eec0e0, - 0x727ab914, - 0xb0137226, - 0x73147313, - 0x8c8072c9, - 0x422d2200, - 0xb130b0f0, - 0x85b06231, - 0x95d085c1, - 0xb10095e1, - 0xb110b140, - 0xb0f6b064, - 0xb0d5b0d0, - 0x7313b136, - 0xb041b061, - 0x42411e1b, - 0xb9127291, - 0xc13772c9, - 0x1e0ec070, - 0x16104247, - 0x9930c0b7, - 0xb115b232, - 0xa910c031, - 0xb0737100, - 0xba3eb910, - 0x22008090, - 0x80b24705, - 0x46682262, - 0x220280c2, - 0xb061425b, - 0x2250b140, - 0x82404249, - 0x46652200, - 0x4249220f, - 0x679e100f, - 0x100f6249, - 0x624967b4, - 0x1e1bb234, - 0xa9154285, - 0xb913b916, - 0x8b33ba3b, - 0x8b2406f3, - 0x00433144, - 0x8c3397a3, - 0x14038c50, - 0x8c448c60, - 0x31431404, - 0x00343143, - 0x81b097b4, - 0x91b02650, - 0x67eec0f0, - 0xa91362bf, - 0x264081b0, - 0x993791b0, - 0x93acba39, - 0x720fa0d5, - 0xb111b0d1, - 0x7100b111, - 0xc3e0b35d, - 0xb0749930, - 0x93f0c0d0, - 0x97918941, - 0xb11167bf, - 0xb0787100, - 0x9930c210, - 0xb235a232, - 0x7100b111, - 0xb06ea35d, - 0xa0d17291, - 0x31828af2, - 0xba3b3d82, - 0x06f38b33, - 0x31448b24, - 0x92630043, - 0x8c508c33, - 0x8c601403, - 0x14048c44, - 0x31433143, - 0x97b40034, - 0x6abdc8f0, - 0xbc9062e3, - 0x95b488d4, - 0x95c488e4, - 0x95948ca4, - 0x95a487c4, - 0x85b0c01b, - 0x95d085c1, - 0x731195e1, - 0x73137312, - 0xb1007314, - 0xb0f6b140, - 0xb110b136, - 0xa232b064, - 0x22628242, - 0x722342d7, - 0xb115b064, - 0xc410b232, - 0x679e6ae0, - 0xb2356249, - 0xa100b140, - 0xa0f6b136, - 0x7291b914, - 0xa003a750, - 0xc7c0a002, - 0x72039010, - 0x73057204, - 0x73117306, - 0x73137312, - 0x720f7314, - 0x7210720d, - 0x7223720e, - 0xb235a232, - 0x1e028242, - 0x722346fc, - 0x67eec100, - 0xc1106097, - 0xb23567ee, - 0x8942a232, - 0x824262e4, - 0x430b2212, - 0xb016b006, - 0xb002b012, - 0xb014b004, - 0x90307ca0, - 0x7cb09050, - 0x90609040, - 0x73127311, - 0x73147313, - 0x720e720d, - 0x7210720f, - 0xb0e1b121, - 0xb0727100, - 0xd680a0e1, - 0x679e6b28, - 0x93f0c090, - 0xbc907000, - 0x9930c040, - 0xb910b911, - 0xb111b0d1, - 0x72917100, - 0xb111a0d1, - 0x9635722c, - 0xc0f38c82, - 0xb013b003, - 0x92c08170, - 0x96408190, - 0xb120b0e0, - 0x22027100, - 0x85b04750, - 0x92c39640, - 0x7100b120, - 0x964085c0, - 0x7100b120, - 0x96408590, - 0xb12092c3, - 0x85a07100, - 0xb1209640, - 0x8cb07100, - 0x0410cff1, - 0xb1209640, - 0x96367100, - 0x9930c040, - 0xb910b911, - 0xb111b0d1, - 0xb120a0e0, - 0x72917100, - 0xb111a0d1, - 0x1e108750, - 0xb2354371, - 0xa9156378, - 0xb913b916, - 0x2a308230, - 0x92302620, - 0x6b79c090, - 0xc120ac90, - 0x700067ee, - 0x721b7223, - 0x92c0c0f0, - 0xc1f1722f, - 0xc01592d1, - 0x7c977c86, - 0x8c807ccc, - 0x43912200, - 0x94407cf0, - 0x94607d10, - 0x7d206393, - 0xac909440, - 0xc1009636, - 0x816e91e0, - 0xc01d398e, - 0x439d1e0e, - 0x7000c03d, - 0x726a7269, - 0xb0537ce2, - 0xc76093a2, - 0x73a36ba4, - 0x96908a40, - 0x96a18a51, - 0x7cd093a6, - 0x8a4393a0, - 0x31338a54, - 0x31343d33, - 0x70003d34, - 0x8a439a31, - 0x31338a54, - 0x31343d63, - 0x96933d64, - 0xb05396a4, - 0x1e0e7000, - 0x8c3143d6, - 0x18108c40, - 0xc0024fd0, - 0x161110d1, - 0x16201812, - 0x1c203d20, - 0x10204fe4, - 0x63e41610, - 0x3d201620, - 0x4be41cd0, - 0x63e410d0, - 0xc082c000, - 0x8c448c33, - 0x1c241834, - 0x14424fe0, - 0x63e44be2, - 0x63e410d0, - 0x18d0c000, - 0x720d7000, - 0x720f720e, - 0x73117210, - 0x73137312, - 0x70007314, - 0x89f09a00, - 0x47ef2200, - 0x7000b9e0 -}; - -PATCH_FUN_SPEC void rf_patch_mce_tof(void) -{ -#ifdef __PATCH_NO_UNROLLING - uint32_t i; - for (i = 0; i < 506; i++) { - HWREG(RFC_MCERAM_BASE + 4 * i) = patchTofMce[i]; - } -#else - const uint32_t *pS = patchTofMce; - volatile unsigned long *pD = &HWREG(RFC_MCERAM_BASE); - uint32_t t1, t2, t3, t4, t5, t6, t7, t8; - uint32_t nIterations = 63; - - do { - t1 = *pS++; - t2 = *pS++; - t3 = *pS++; - t4 = *pS++; - t5 = *pS++; - t6 = *pS++; - t7 = *pS++; - t8 = *pS++; - *pD++ = t1; - *pD++ = t2; - *pD++ = t3; - *pD++ = t4; - *pD++ = t5; - *pD++ = t6; - *pD++ = t7; - *pD++ = t8; - } while (--nIterations); - - t1 = *pS++; - t2 = *pS++; - *pD++ = t1; - *pD++ = t2; -#endif -} - -#endif diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_rfe_genook.c b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_rfe_genook.c new file mode 100644 index 0000000..4096b23 --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_rfe_genook.c @@ -0,0 +1,492 @@ +/****************************************************************************** +* Filename: rf_patch_rfe_genook.h +* +* Description: RF core patch for General OOK support in CC13x2 and CC26x2. +* +* Copyright (c) 2015-2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ + + +#include +#include "rf_patch_rfe_genook.h" +#include +#include DeviceFamily_constructPath(inc/hw_types.h) + +#ifndef RFE_PATCH_TYPE +#define RFE_PATCH_TYPE static const uint32_t +#endif + +#ifndef PATCH_FUN_SPEC +#define PATCH_FUN_SPEC +#endif + +#ifndef RFC_RFERAM_BASE +#define RFC_RFERAM_BASE 0x2100C000 +#endif + +#ifndef RFE_PATCH_MODE +#define RFE_PATCH_MODE 0 +#endif + +RFE_PATCH_TYPE patchGenookRfe[383] = { + 0x00006122, + 0x11011000, + 0x004d1203, + 0x002e24f1, + 0x0a940018, + 0x003ffffe, + 0x00ff007f, + 0x000003ff, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x40300000, + 0x40014000, + 0x40074003, + 0x404f400f, + 0x41cf40cf, + 0x47cf43cf, + 0x3fcf4fcf, + 0x1fcf2fcf, + 0x00000fcf, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x9100c050, + 0xc0707000, + 0x70009100, + 0x00213182, + 0xb1109131, + 0x81017000, + 0xa100b101, + 0x91323182, + 0x9101b110, + 0x81411011, + 0x406d2241, + 0x700006f1, + 0xc0501025, + 0xc3f49100, + 0x1420c2b0, + 0x10316f03, + 0xc0220441, + 0x00213182, + 0xb1109131, + 0x10313963, + 0xc0820441, + 0x00213182, + 0xb1109131, + 0x10313963, + 0x3182c0a2, + 0x91310021, + 0x1050b110, + 0x14053115, + 0x70009255, + 0xc2b2645d, + 0x06311031, + 0x02c13161, + 0xc1126460, + 0x39211031, + 0x31510671, + 0x646002e1, + 0x645d7000, + 0x7100b054, + 0xb064a054, + 0x220080f0, + 0xc11140a4, + 0x6460c122, + 0x82b1645a, + 0x39813181, + 0x6460c0e2, + 0x68b5c300, + 0x1240645d, + 0xb03290b0, + 0x395382a3, + 0x64943953, + 0x68bfc360, + 0x90b01280, + 0x7000b032, + 0xc101645d, + 0x6460c122, + 0xc0c2c101, + 0x82a36460, + 0x12c06494, + 0xb03290b0, + 0x645d7000, + 0xc081c272, + 0xc1226460, + 0x6460c111, + 0xc111c002, + 0xc0626460, + 0x6460c331, + 0xc111c362, + 0xc3026460, + 0x6460c111, + 0x395382a3, + 0xc3e26494, + 0x22116465, + 0xc24240e7, + 0x6460c881, + 0xc111c252, + 0xc2726460, + 0x6460cee1, + 0xc881c202, + 0xc2026460, + 0x6460c801, + 0x68fbc170, + 0x645d7000, + 0xc801c242, + 0xc2526460, + 0x6460c011, + 0xc0e1c272, + 0xc0026460, + 0x6460c101, + 0xc301c062, + 0xc1226460, + 0x6460c101, + 0xc101c362, + 0xc3026460, + 0x6460c101, + 0x649482a3, + 0x00007000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + 0x72057306, + 0x720e720b, + 0x7100b050, + 0xb0608081, + 0x8092a050, + 0x224180a2, + 0x80804543, + 0x0410c1f1, + 0x11011630, + 0x6c011401, + 0x615e615e, + 0x615e615e, + 0x615e615e, + 0x615e615e, + 0x615e615e, + 0x615e615e, + 0x809162d5, + 0x0421c0f2, + 0x80823121, + 0x14122a42, + 0x11011632, + 0x6c011421, + 0x617b616e, + 0x62d5616e, + 0x615e615f, + 0x615e615e, + 0x617b616e, + 0x62d5616e, + 0x615e615f, + 0x615e615e, + 0x64d16163, + 0x64fd657b, + 0x12106163, + 0x616690b0, + 0x9050c010, + 0x906078a0, + 0x1210720e, + 0x61269030, + 0x91a07850, + 0x92607860, + 0x92707870, + 0x92807880, + 0x92907890, + 0x90a0c1a0, + 0xa0bc6163, + 0xb060a0e1, + 0x80f0a054, + 0x45862250, + 0x22008040, + 0x617d46a2, + 0x66f7cff0, + 0x393080f0, + 0x22100630, + 0x7841418f, + 0x22006194, + 0x78314193, + 0x78216194, + 0x827d91e1, + 0x39408280, + 0x0410c0f1, + 0xc0121007, + 0x82693072, + 0x0419c0f1, + 0xc0f1826a, + 0x041a394a, + 0xc0f1826e, + 0x041e398e, + 0x10bc10ab, + 0x647210c2, + 0x78e7c00f, + 0xb003b013, + 0xb0536646, + 0xb013b050, + 0xc082661c, + 0x662d6682, + 0xb0637100, + 0x22018041, + 0x80f046a2, + 0x41b82250, + 0x45b82210, + 0x46c022f0, + 0x6682c082, + 0x392010f0, + 0x82239210, + 0x1030664c, + 0x4dd618d3, + 0x16130bf3, + 0x49ea1ce3, + 0x82339213, + 0x61db143b, + 0x49ea1ce3, + 0x82339213, + 0x1cab183b, + 0x1c9b4e29, + 0x1cbc4a2b, + 0x10b241ea, + 0x22d08260, + 0x80f041e8, + 0x45ea2210, + 0x65eb6472, + 0x10c061b8, + 0x49fd18b0, + 0x39101003, + 0x41f41e00, + 0x3807380f, + 0x420d2203, + 0x392010f0, + 0x1070180f, + 0x18073920, + 0x1003620d, + 0x1801c001, + 0x1e013911, + 0x301f4205, + 0x22033017, + 0x10f0420d, + 0x140f3920, + 0x39201070, + 0x66991407, + 0x06f08280, + 0x80f13110, + 0x06313931, + 0x42171e01, + 0xb0633810, + 0x6a177100, + 0x700010bc, + 0x06f08280, + 0x80f13110, + 0x06313931, + 0x42251e01, + 0xb0633810, + 0x6a257100, + 0x10ab7000, + 0x109b61df, + 0x10f261df, + 0x92123922, + 0x82518222, + 0x81a11812, + 0x82911812, + 0x3d813181, + 0x4a3e1c12, + 0xb032b0e1, + 0x66f7cfe0, + 0x1421c7f1, + 0xc8124e42, + 0x91c291b2, + 0x7000b031, + 0xc0061208, + 0x91b0c800, + 0x700091c0, + 0x10308251, + 0x81a11810, + 0x14061810, + 0x829280e1, + 0x3d823182, + 0x4a5e1c20, + 0x46682211, + 0xb032b0e1, + 0x66f7cfd0, + 0x42682211, + 0x1c201a32, + 0xa0e14e68, + 0xdfc0b032, + 0x66f79342, + 0x39418281, + 0x1e0106f1, + 0x16184273, + 0x3010c010, + 0x46811c08, + 0xc7f13c16, + 0x4e771461, + 0x91b6c816, + 0x318181c1, + 0x1c163d81, + 0x91c64a7e, + 0xc006b031, + 0x70001208, + 0x31238203, + 0x187110f1, + 0x10153c21, + 0x4e8b1c37, + 0x1037628d, + 0x1417628e, + 0x4a911c3f, + 0x103f6293, + 0x1e016299, + 0x12114696, + 0x42991e0f, + 0x10f1181f, + 0x39311471, + 0x063080e0, + 0x14103121, + 0x700090e0, + 0x81b28251, + 0x3d823182, + 0x9341efb0, + 0x66f79352, + 0x64fda003, + 0x81b16163, + 0x3d813181, + 0x39808290, + 0x1cf11801, + 0x14014abf, + 0x22c080b0, + 0xb0bc46bf, + 0xefa0b033, + 0x935f9341, + 0x700066f7, + 0xb063a003, + 0xb054b064, + 0x64fdb0e0, + 0x80407100, + 0x46a22200, + 0x64d1b064, + 0x7100a0e0, + 0x22008040, + 0xb06446a2, + 0xb003a054, + 0xcf9061b8, + 0x64a366f7, + 0xb054b0e1, + 0xb064645d, + 0x80f07100, + 0x46f22240, + 0x42e32210, + 0xc20162ee, + 0x6460c0c2, + 0x318080a0, + 0x6ae93940, + 0xc0c2c101, + 0x62db6460, + 0xc0c2c331, + 0x62db6460, + 0xcf80a054, + 0x64c466f7, + 0x93306163, + 0x22008320, + 0xb31046f8, + 0x00007000 +}; + +PATCH_FUN_SPEC void rf_patch_rfe_genook(void) +{ +#ifdef __PATCH_NO_UNROLLING + uint32_t i; + for (i = 0; i < 383; i++) { + HWREG(RFC_RFERAM_BASE + 4 * i) = patchGenookRfe[i]; + } +#else + const uint32_t *pS = patchGenookRfe; + volatile unsigned long *pD = &HWREG(RFC_RFERAM_BASE); + uint32_t t1, t2, t3, t4, t5, t6, t7, t8; + uint32_t nIterations = 47; + + do { + t1 = *pS++; + t2 = *pS++; + t3 = *pS++; + t4 = *pS++; + t5 = *pS++; + t6 = *pS++; + t7 = *pS++; + t8 = *pS++; + *pD++ = t1; + *pD++ = t2; + *pD++ = t3; + *pD++ = t4; + *pD++ = t5; + *pD++ = t6; + *pD++ = t7; + *pD++ = t8; + } while (--nIterations); + + t1 = *pS++; + t2 = *pS++; + t3 = *pS++; + t4 = *pS++; + t5 = *pS++; + t6 = *pS++; + t7 = *pS++; + *pD++ = t1; + *pD++ = t2; + *pD++ = t3; + *pD++ = t4; + *pD++ = t5; + *pD++ = t6; + *pD++ = t7; +#endif +} diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_rfe_genook.h b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_rfe_genook.h new file mode 100644 index 0000000..5c10034 --- /dev/null +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_rfe_genook.h @@ -0,0 +1,47 @@ +/****************************************************************************** +* Filename: rf_patch_rfe_genook.h +* +* Description: RF core patch for General OOK support in CC13x2 and CC26x2. +* +* Copyright (c) 2015-2020, Texas Instruments Incorporated +* 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 ORGANIZATION 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. +* +******************************************************************************/ + + +#ifndef _RF_PATCH_RFE_GENOOK_H +#define _RF_PATCH_RFE_GENOOK_H + +#include +#include +#include DeviceFamily_constructPath(inc/hw_types.h) + +extern void rf_patch_rfe_genook(void); + +#endif diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_rfe_tof.h b/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_rfe_tof.h deleted file mode 100644 index d09cb4a..0000000 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/rf_patches/rf_patch_rfe_tof.h +++ /dev/null @@ -1,571 +0,0 @@ -/****************************************************************************** -* Filename: rf_patch_rfe_tof.h -* Revised: $Date: 2019-01-31 15:04:59 +0100 (to, 31 jan 2019) $ -* Revision: $Revision: 18843 $ -* -* Description: RF core RFE patch for time of flight 2Mbps PHY for CC13x2 and CC26x2 -* -* Copyright (c) 2015-2019, Texas Instruments Incorporated -* 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 ORGANIZATION 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. -* -******************************************************************************/ - - -#ifndef _RF_PATCH_RFE_TOF_H -#define _RF_PATCH_RFE_TOF_H - -#include -#include "../inc/hw_types.h" - -#ifndef RFE_PATCH_TYPE -#define RFE_PATCH_TYPE static const uint32_t -#endif - -#ifndef PATCH_FUN_SPEC -#define PATCH_FUN_SPEC static inline -#endif - -#ifndef RFC_RFERAM_BASE -#define RFC_RFERAM_BASE 0x2100C000 -#endif - -#ifndef RFE_PATCH_MODE -#define RFE_PATCH_MODE 0 -#endif - -RFE_PATCH_TYPE patchTofRfe[461] = { - 0x00006194, - 0x004535aa, - 0x0421a355, - 0x1f40004c, - 0x0000003f, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x40004030, - 0x40034001, - 0x400f4007, - 0x40cf404f, - 0x43cf41cf, - 0x4fcf47cf, - 0x2fcf3fcf, - 0x0fcf1fcf, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x00000000, - 0x40004030, - 0x40034001, - 0x400f4007, - 0x40cf404f, - 0x6fcf7fcf, - 0x4fcf5fcf, - 0x2fcf3fcf, - 0x0fcf1fcf, - 0x00000000, - 0x00000000, - 0x9100c050, - 0xc0707000, - 0x70009100, - 0x00213182, - 0xb1109131, - 0x81017000, - 0xa100b101, - 0x91323182, - 0x9101b110, - 0x81411011, - 0x40772241, - 0x700006f1, - 0x9150c050, - 0xc0707000, - 0x70009150, - 0x00213182, - 0xb1609181, - 0x10257000, - 0x9100c050, - 0xc140c3f4, - 0x6f031420, - 0x04411031, - 0x22f082a0, - 0x26514094, - 0x3182c022, - 0x91310021, - 0x3963b110, - 0x04411031, - 0x3182c082, - 0x91310021, - 0x3963b110, - 0xc0a21031, - 0x00213182, - 0xb1109131, - 0x31151050, - 0x92551405, - 0x64677000, - 0x1031c2b2, - 0x31610631, - 0x646a02c1, - 0x1031c112, - 0x06713921, - 0x02e13151, - 0x7000646a, - 0x82b16464, - 0x39813181, - 0x646ac0e2, - 0xc1116467, - 0x646ac122, - 0x68c7c470, - 0xc0c2c111, - 0x64e0646a, - 0x700064f3, - 0x82b1647c, - 0x39813181, - 0x6482c182, - 0xc111647f, - 0x6482c0a2, - 0x68d9c470, - 0xc162c331, - 0x64e06482, - 0x700064f3, - 0xb054b050, - 0x80407100, - 0x44ed2240, - 0x40e02200, - 0x8081b060, - 0x44e01e11, - 0xa0547000, - 0x80f0b064, - 0x40e02200, - 0x12407000, - 0xb03290b0, - 0x395382a3, - 0x64ad3953, - 0x68fbc2f0, - 0xc1f18080, - 0xc1510410, - 0x41071c10, - 0xc2216467, - 0x646ac0c2, - 0x647f610b, - 0xc162c441, - 0xce306482, - 0x1280690c, - 0xb03290b0, - 0x64677000, - 0xc0c2c201, - 0x80a0646a, - 0x39403180, - 0xc1016918, - 0x646ac0c2, - 0xc122c101, - 0x82a3646a, - 0x12c064ad, - 0xb03290b0, - 0x647f7000, - 0xc162c401, - 0x80a06482, - 0x39403180, - 0xc301692c, - 0x6482c162, - 0xc0a2c101, - 0x82a36482, - 0x12c064ad, - 0xb03290b0, - 0x64677000, - 0xc081c272, - 0xc122646a, - 0x646ac111, - 0xc111c002, - 0xc062646a, - 0x646ac331, - 0xc111c362, - 0xc302646a, - 0x646ac111, - 0x395382a3, - 0xc3e264ad, - 0x2211646f, - 0xc242414f, - 0x646ac881, - 0xc111c252, - 0xc272646a, - 0x646acee1, - 0xc881c202, - 0xc202646a, - 0x646ac801, - 0x6963c170, - 0x64677000, - 0xc801c242, - 0xc252646a, - 0x646ac011, - 0xc0e1c272, - 0xc002646a, - 0x646ac101, - 0xc301c062, - 0xc122646a, - 0x646ac101, - 0xc101c362, - 0xc302646a, - 0x646ac101, - 0x64ad82a3, - 0x80817000, - 0x418f1e11, - 0xb054b050, - 0x80407100, - 0x41902240, - 0xb064a054, - 0x220180f1, - 0x70004584, - 0x41842200, - 0x6181b060, - 0x72057306, - 0x720e720b, - 0x7100b050, - 0xa050b060, - 0x80928081, - 0x45b32241, - 0xc1f18080, - 0x16300410, - 0x14011101, - 0x61c66c01, - 0x61c661c6, - 0x61c661c6, - 0x61e661c6, - 0x61e661c6, - 0x61c661c6, - 0x809161c6, - 0x0421c0f2, - 0x80823121, - 0x14122a42, - 0x11011632, - 0x6c011421, - 0x61c661cf, - 0x61c661cf, - 0x61c661c6, - 0x61c661c6, - 0x61c861c8, - 0x61cbb0b0, - 0x7306b0b1, - 0xb0307205, - 0x78206198, - 0x78427831, - 0x78547873, - 0x78667885, - 0x92719260, - 0x92939282, - 0x92b592a4, - 0xc01f91a6, - 0x3940924f, - 0x100106f0, - 0x14103110, - 0x61c89250, - 0xcff0b060, - 0x66306793, - 0xb0e16624, - 0xb054b050, - 0x8262b064, - 0x39823182, - 0x64873942, - 0x7100b0e1, - 0x22008040, - 0xb0644621, - 0x225280f2, - 0x22224611, - 0x22324608, - 0x1e02460f, - 0xdfe041f5, - 0x67939342, - 0x61f56511, - 0x663f663a, - 0x80f0b064, - 0x46112250, - 0x663561f5, - 0xcfd061f5, - 0xa0546793, - 0xa050b064, - 0xa052b060, - 0xa053b062, - 0x6565b063, - 0xcfc06511, - 0x720e6793, - 0xcfb061c8, - 0x62116793, - 0x82b16464, - 0x39813181, - 0x646ac0e2, - 0xc1116467, - 0x646ac122, - 0x700064f3, - 0x70006539, - 0x70006511, - 0x64676565, - 0xc0c2c111, - 0x7000646a, - 0xc1016467, - 0x646ac0c2, - 0xc8007000, - 0x81a991b0, - 0x8091b050, - 0x46b02241, - 0x31828262, - 0x39423982, - 0x82626487, - 0x102f06f2, - 0x142f311f, - 0x22d68266, - 0xc1404655, - 0xc5006256, - 0x6f0d1420, - 0x10de396d, - 0x044ec3f4, - 0x3182c082, - 0x396d002e, - 0x3182c0a2, - 0x826a002d, - 0x06fa398a, - 0x31808270, - 0xc00b3980, - 0x10bc180b, - 0x825318ac, - 0x149b1439, - 0x06f08260, - 0x31101001, - 0x81a11410, - 0x140c1410, - 0x46ea22c6, - 0x39408280, - 0x100206f0, - 0x3001c011, - 0x1801c010, - 0x31821802, - 0x26c10021, - 0xb00391e1, - 0xb063b013, - 0x8041b053, - 0x46e12201, - 0x92148204, - 0x1cb58225, - 0x18954e99, - 0x80f091b5, - 0x428b2240, - 0x913d62ae, - 0x913eb110, - 0x80e0b110, - 0x46a32200, - 0x42a322e6, - 0x1895b0e0, - 0x925f91b5, - 0x14f981a9, - 0x225080f0, - 0x224046e1, - 0x637646ae, - 0x6793cfa0, - 0xa052b063, - 0xc0f28280, - 0x10020420, - 0x3001c011, - 0x1801c010, - 0x31821802, - 0x26c10021, - 0x720e91e1, - 0xb01391e1, - 0xb063b003, - 0xb064b053, - 0x7100b054, - 0x22018041, - 0xb06346e1, - 0x80f0b064, - 0x42e12220, - 0x92118201, - 0x18918221, - 0xb03191b1, - 0x674e62c7, - 0x81a9a0e0, - 0x14598255, - 0x7100c080, - 0x6addb063, - 0xb0e6628b, - 0xa053a052, - 0x81b28251, - 0x3d823182, - 0x7000a003, - 0x39478287, - 0x82803987, - 0x06f03980, - 0xc0111002, - 0xc0103001, - 0x18021801, - 0x00213182, - 0x91d126c1, - 0xb012b002, - 0x39408280, - 0x100206f0, - 0x3001c011, - 0x1801c010, - 0x31821802, - 0x26c10021, - 0xb00391e1, - 0xb063b013, - 0x7100b053, - 0xb062a053, - 0x8041b052, - 0x46e12201, - 0x921481f4, - 0x82048225, - 0x4f201cb5, - 0x91b51895, - 0x224080f0, - 0x62ae4311, - 0x92148204, - 0x10408224, - 0x91b01890, - 0x1c751845, - 0x80f04f2d, - 0x43112240, - 0x913d62ae, - 0x913eb110, - 0x80e0b110, - 0x47372200, - 0x433722e6, - 0x91b5b0e0, - 0x81a9925f, - 0x80f014f9, - 0x463f2250, - 0x46ae2240, - 0x674e6355, - 0x81a9a0e0, - 0x14598255, - 0x7100c140, - 0x6b47b062, - 0x80a26311, - 0x61c86487, - 0x39428262, - 0x608706f2, - 0x7100b050, - 0x829061c8, - 0x22018041, - 0x81f446e1, - 0x82259214, - 0x91b51895, - 0x224180f1, - 0x6b5646ae, - 0x318181b1, - 0xdf903d81, - 0x67939341, - 0x22018041, - 0x81f446e1, - 0x82259214, - 0x4b411cc5, - 0x91b51895, - 0x224080f0, - 0x62ae4362, - 0x6793cf80, - 0x80418290, - 0x46e12201, - 0x92148204, - 0x18958225, - 0x80f191b5, - 0x46ae2241, - 0x80416b79, - 0x46e12201, - 0x92148204, - 0x1cc58225, - 0x18954ad7, - 0x80f091b5, - 0x43852240, - 0x933062ae, - 0x22008320, - 0xb3104794, - 0x00007000 -}; - -PATCH_FUN_SPEC void rf_patch_rfe_tof(void) -{ -#ifdef __PATCH_NO_UNROLLING - uint32_t i; - for (i = 0; i < 461; i++) { - HWREG(RFC_RFERAM_BASE + 4 * i) = patchTofRfe[i]; - } -#else - const uint32_t *pS = patchTofRfe; - volatile unsigned long *pD = &HWREG(RFC_RFERAM_BASE); - uint32_t t1, t2, t3, t4, t5, t6, t7, t8; - uint32_t nIterations = 57; - - do { - t1 = *pS++; - t2 = *pS++; - t3 = *pS++; - t4 = *pS++; - t5 = *pS++; - t6 = *pS++; - t7 = *pS++; - t8 = *pS++; - *pD++ = t1; - *pD++ = t2; - *pD++ = t3; - *pD++ = t4; - *pD++ = t5; - *pD++ = t6; - *pD++ = t7; - *pD++ = t8; - } while (--nIterations); - - t1 = *pS++; - t2 = *pS++; - t3 = *pS++; - t4 = *pS++; - t5 = *pS++; - *pD++ = t1; - *pD++ = t2; - *pD++ = t3; - *pD++ = t4; - *pD++ = t5; -#endif -} - -#endif diff --git a/simplelink/source/ti/devices/cc13x2_cc26x2/startup_files/ccfg.c b/simplelink/source/ti/devices/cc13x2_cc26x2/startup_files/ccfg.c index b81de47..6a17697 100644 --- a/simplelink/source/ti/devices/cc13x2_cc26x2/startup_files/ccfg.c +++ b/simplelink/source/ti/devices/cc13x2_cc26x2/startup_files/ccfg.c @@ -186,7 +186,7 @@ //##################################### #ifndef SET_CCFG_MODE_CONF_SCLK_LF_OPTION -// #define SET_CCFG_MODE_CONF_SCLK_LF_OPTION 0x0 // LF clock derived from High Frequency XOSC +// #define SET_CCFG_MODE_CONF_SCLK_LF_OPTION 0x0 // LF clock derived from HF clock. Note: using this configuration will block the device from entering Standby mode. // #define SET_CCFG_MODE_CONF_SCLK_LF_OPTION 0x1 // External LF clock #define SET_CCFG_MODE_CONF_SCLK_LF_OPTION 0x2 // LF XOSC // #define SET_CCFG_MODE_CONF_SCLK_LF_OPTION 0x3 // LF RCOSC @@ -213,9 +213,10 @@ // Special HF clock source setting //##################################### #ifndef SET_CCFG_MODE_CONF_XOSC_FREQ -// #define SET_CCFG_MODE_CONF_XOSC_FREQ 0x1 // Use HPOSC as HF source (if executing on a HPOSC chip, otherwise using default (=0x3)) -#define SET_CCFG_MODE_CONF_XOSC_FREQ 0x2 // HF source is a 48 MHz xtal (default on x2/x4 chips) -// #define SET_CCFG_MODE_CONF_XOSC_FREQ 0x3 // HF source is a 24 MHz xtal (default on x0 chips) +// #define SET_CCFG_MODE_CONF_XOSC_FREQ 0x0 // HF source is 48 MHz TCXO +// #define SET_CCFG_MODE_CONF_XOSC_FREQ 0x1 // HF source is HPOSC (BAW) (only valid for CC2652RB) +#define SET_CCFG_MODE_CONF_XOSC_FREQ 0x2 // HF source is a 48 MHz xtal +// #define SET_CCFG_MODE_CONF_XOSC_FREQ 0x3 // HF source is a 24 MHz xtal (not supported) #endif //##################################### @@ -353,11 +354,19 @@ #endif //##################################### -// Select TCXO +// TCXO settings //##################################### #ifndef SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO -#define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO 0x1 // Disable TCXO -// #define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO 0x0 // Enable TXCO +#define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_TCXO 0x1 // Deprecated. Must be set to 0x1. +#endif + +#ifndef SET_CCFG_MODE_CONF_1_TCXO_TYPE +#define SET_CCFG_MODE_CONF_1_TCXO_TYPE 0x1 // 1 = Clipped-sine type. +//#define SET_CCFG_MODE_CONF_1_TCXO_TYPE 0x0 // 0 = CMOS type. +#endif + +#ifndef SET_CCFG_MODE_CONF_1_TCXO_MAX_START +#define SET_CCFG_MODE_CONF_1_TCXO_MAX_START 0x7F // Maximum TCXO startup time in units of 100us. #endif //***************************************************************************** @@ -406,6 +415,8 @@ ((((uint32_t)( SET_CCFG_EXT_LF_CLK_RTC_INCREMENT )) << CCFG_EXT_LF_CLK_RTC_INCREMENT_S ) | ~CCFG_EXT_LF_CLK_RTC_INCREMENT_M ) ) #define DEFAULT_CCFG_MODE_CONF_1 ( \ + ((((uint32_t)( SET_CCFG_MODE_CONF_1_TCXO_TYPE )) << CCFG_MODE_CONF_1_TCXO_TYPE_S ) | ~CCFG_MODE_CONF_1_TCXO_TYPE_M ) & \ + ((((uint32_t)( SET_CCFG_MODE_CONF_1_TCXO_MAX_START )) << CCFG_MODE_CONF_1_TCXO_MAX_START_S ) | ~CCFG_MODE_CONF_1_TCXO_MAX_START_M ) & \ ((((uint32_t)( SET_CCFG_MODE_CONF_1_ALT_DCDC_VMIN )) << CCFG_MODE_CONF_1_ALT_DCDC_VMIN_S ) | ~CCFG_MODE_CONF_1_ALT_DCDC_VMIN_M ) & \ ((((uint32_t)( SET_CCFG_MODE_CONF_1_ALT_DCDC_DITHER_EN )) << CCFG_MODE_CONF_1_ALT_DCDC_DITHER_EN_S ) | ~CCFG_MODE_CONF_1_ALT_DCDC_DITHER_EN_M ) & \ ((((uint32_t)( SET_CCFG_MODE_CONF_1_ALT_DCDC_IPEAK )) << CCFG_MODE_CONF_1_ALT_DCDC_IPEAK_S ) | ~CCFG_MODE_CONF_1_ALT_DCDC_IPEAK_M ) & \ diff --git a/simplelink/source/ti/drivers/Temperature.c b/simplelink/source/ti/drivers/Temperature.c new file mode 100644 index 0000000..e73147d --- /dev/null +++ b/simplelink/source/ti/drivers/Temperature.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2020, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * 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. + * + * * Neither the name of Texas Instruments Incorporated 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 OWNER 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. + */ + +/* + * ======== Temperature.c ======== + * + */ + +#include +#include + +#include + +/* + * ======== Temperature_getThresholdHigh ======== + */ +int16_t Temperature_getThresholdHigh(Temperature_NotifyObj *notifyObject) { + return notifyObject->thresholdHigh; +} + +/* + * ======== Temperature_getThresholdLow ======== + */ +int16_t Temperature_getThresholdLow(Temperature_NotifyObj *notifyObject) { + return notifyObject->thresholdLow; +} + +/* + * ======== Temperature_getThresholdRange ======== + */ +void Temperature_getThresholdRange(Temperature_NotifyObj *notifyObject, + int16_t *thresholdHigh, + int16_t *thresholdLow) { + *thresholdHigh = notifyObject->thresholdHigh; + *thresholdLow = notifyObject->thresholdLow; +} + +/* + * ======== Temperature_getClientArg ======== + */ +uintptr_t Temperature_getClientArg(Temperature_NotifyObj *notifyObject) { + return notifyObject->clientArg; +} + +/* + * ======== Temperature_getNotifyFxn ======== + */ +Temperature_NotifyFxn Temperature_getNotifyFxn(Temperature_NotifyObj *notifyObject) { + return notifyObject->notifyFxn; +} diff --git a/simplelink/source/ti/drivers/Temperature.h b/simplelink/source/ti/drivers/Temperature.h new file mode 100644 index 0000000..99c4070 --- /dev/null +++ b/simplelink/source/ti/drivers/Temperature.h @@ -0,0 +1,550 @@ +/* + * Copyright (c) 2020, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * 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. + * + * * Neither the name of Texas Instruments Incorporated 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 OWNER 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 Temperature.h + * + * @brief Temperature driver + * + * @anchor ti_drivers_Temperature_Overview + * # Overview # + * The Temperature driver provides services related to measuring and reacting + * to the current temperature of the chip and changes to it. + * + * The two main services provided are: + * - Getting the current temperature + * - Providing notification callbacks when the temperature changes + * + * @anchor ti_drivers_Temperature_Usage + * # Usage # + * + * ## Initialisation # + * Unlike most drivers, there is only a single instance of the temperature + * driver that is always available once #Temperature_init() is called. + * #Temperature_init() should be called once before using other Temperature + * driver APIs. Subsequent #Temperature_init() calls will have no effect. + * + * ## Getting the Current Temperature # + * The most basic function of the driver is to provide the current temperature + * and return it. It is encoded as a signed integer in degrees C. + * + * ## Notifications # + * The other major function of the Temperature driver is to notify the + * application when the temperature changes and crosses an application-defined + * threshold. + * + * There are three default usecases for this: + * - High threshold. + * The application will receive a notification callback when + * currentTemperature >= thresholdHigh. + * - Low threshold. + * The application will receive a notification callback when + * currentTemperature <= thresholdLow. + * - Range threshold. + * The application will receive a notification callback when + * currentTemperature >= thresholdHigh || currentTemperature <= + * thresholdLow. This setup addresses usecases + * where a notification is required when the temperature changes by a + * certain amount regardless of whether it is up or down. Adjusting + * clock offsets based on temperature is a good example of this. + * + * ### Registering Notifications + * There are three functions that register a notification for the application: + * - #Temperature_registerNotifyHigh() + * - #Temperature_registerNotifyLow() + * - #Temperature_registerNotifyRange() + * + * Multiple notifications may be registered. The different parts of the + * application and drivers that need to respond to a temperature change do not + * need to know of one another. + * Each notification must have its own #Temperature_NotifyObj and must be + * registered individually. + * + * ### Notification Callbacks + * Once the chip temperature crosses the smallest high threshold or largest + * low threshold amongst the registered notifications, the driver will + * iterate over the entire list of registered notification and check which + * ones have triggered. Notifications that have triggered are removed from + * the list of registered notifications and thus are no longer registered. + * Their callback function is then invoked. + * + * If an application wishes to reregister a notification that just triggered + * and was unregistered, it may register it again from within the notification + * callback or another context. + * + * It is possible to determine whether the high or low threshold triggered + * the notification callback as follows: + * - currentTemperature <= thresholdTemperature: Low threshold triggered + * - currentTemperature >= thresholdTemperature: High threshold triggered + * This information is only reasonably useful when registering a notification + * with both a high and low threshold using #Temperature_registerNotifyRange(). + * Even then, the expected basic usecase only cares about the current + * temperature and adding an offset to it when registering the notification + * again. + * + * ### Unregistering Notifications + * Registered notifications are unregistered in two ways: + * - Automatically when a notification triggers + * - By calling #Temperature_unregisterNotify() + * + * Unregistered notifications may be registered again at any time. + * + * # Measured vs True Temperature + * While the driver aims to supply and act on an accurate absolute temperature, + * there will be differences between the measured vs the true temperature due + * to inherent variances in the manufacturing process. The nature of these + * differences varies by device family. + * + * Examples of such differences: + * - A constant per-chip offset between the measured and the true + * temperature + * - An temperature dependent per-chip offset between the measured and the + * true temperature + * - A variance in the measured temperature when measuring multiple times + * at the same chip temperature + * + * It is strongly recommended to read the device-specific Temperature driver + * documentation for details of the temperature sensor characteristics and + * how they might affect choices of threshold values. + * + * @anchor ti_drivers_Temperature_Synopsis + * # Synopsis # + * @anchor ti_drivers_Temperature_Synopsis_Code + * @code + * #include + * + * #define WINDOW_DELTA 10 + * + * Temperature_init(); + * + * currentTemperature = Temperature_getTemperature(); + * + * result = Temperature_registerNotifyRange(¬ifyObject, + * currentTemperature + WINDOW_DELTA, + * currentTemperature - WINDOW_DELTA, + * myNotifyFxn, + * clientArg); + * @endcode + * + * @anchor ti_drivers_Temperature_Examples + * # Examples # + * + * ## Register a High Threshold Notification # + * + * @code + * + * // The notification will trigger when the temperature reaches 40 C + * #define THRESHOLD_CUTOFF 40 + * + * #include + * + * void thresholdNotifyFxn(int16_t currentTemperature, + * int16_t thresholdTemperature, + * uintptr_t clientArg, + * Temperature_NotifyObj *notifyObject) { + * // Post a semaphore, set a flag, or otherwise act upon the temperature + * // change. + * } + * + * ... + * + * // Initialize the Temperature driver and register a notification. + * + * Temperature_init(); + * + * int_fast16_t status = Temperature_registerNotifyHigh(notifyObject, + * THRESHOLD_CUTOFF, + * thresholdNotifyFxn, + * NULL); + * + * if (status != Temperature_STATUS_SUCCESS) { + * // Handle error + * } + * + * @endcode + * + * ## Register a Range Threshold Notification and Reregister in Callback # + * + * @code + * + * #define THRESHOLD_DELTA 5 + * + * #include + * + * + * void deltaNotificationFxn(int16_t currentTemperature, + * int16_t thresholdTemperature, + * uintptr_t clientArg, + * Temperature_NotifyObj *notifyObject) { + * int_fast16_t status; + * + * status = Temperature_registerNotifyRange(notifyObject, + * currentTemperature + THRESHOLD_DELTA, + * currentTemperature - THRESHOLD_DELTA, + * deltaNotificationFxn, + * NULL); + * + * if (status != Temperature_STATUS_SUCCESS) { + * while(1); + * } + * } + * + * ... + * + * // Initialize the Temperature driver and register a notification. + * + * Temperature_init(); + * + * int16_t currentTemperature = Temperature_getTemperature(); + * + * int_fast16_t status = Temperature_registerNotifyRange(notifyObject, + * currentTemperature + THRESHOLD_DELTA, + * currentTemperature - THRESHOLD_DELTA, + * deltaNotificationFxn, + * NULL); + * @endcode + */ + +#ifndef ti_drivers_Temperature__include +#define ti_drivers_Temperature__include + +#include +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + * Common Temperature status code reservation offset. + * Temperature driver implementations should offset status codes with + * Temperature_STATUS_RESERVED growing negatively. + * + * Example implementation specific status codes: + * @code + * #define TemperatureXYZ_STATUS_ERROR0 Temperature_STATUS_RESERVED - 0 + * #define TemperatureXYZ_STATUS_ERROR1 Temperature_STATUS_RESERVED - 1 + * #define TemperatureXYZ_STATUS_ERROR2 Temperature_STATUS_RESERVED - 2 + * @endcode + */ +#define Temperature_STATUS_RESERVED (-32) + +/*! + * @brief Successful status code. + * + * Functions return Temperature_STATUS_SUCCESS if the function was executed + * successfully. + */ +#define Temperature_STATUS_SUCCESS (0) + +/*! + * @brief Generic error status code. + * + * Functions return Temperature_STATUS_ERROR if the function was not executed + * successfully. + */ +#define Temperature_STATUS_ERROR (-1) + + +/* @cond + * + * Type declaration for the notification object made separately from the + * struct definition because of the circular dependency between + * #Temperature_NotifyFxn() and #Temperature_NotifyObj. + */ +typedef struct Temperature_NotifyObj Temperature_NotifyObj; +/* @endcond */ + +/*! + * @brief Function prototype for a notification callback. + * + * @param [in] currentTemperature Current chip temperature + * + * @param [in] thresholdTemperature Temperature threshold that caused + * this notification callback. + * + * @param [in] clientArg Argument provided by the application + * during registration. + * + * @param [in/out] notifyObject The notification object that was + * registered previously. This pointer + * may be used to register the + * notification again with updated + * inputs from within the notification + * callback. + */ +typedef void (*Temperature_NotifyFxn) (int16_t currentTemperature, + int16_t thresholdTemperature, + uintptr_t clientArg, + Temperature_NotifyObj *notifyObject); + +/*! + * @brief Temperature notify object structure. + * + * This structure specification is for internal use. Notification clients must + * pre-allocate a notify object when registering for a notification; + * #Temperature_registerNotifyHigh(), #Temperature_registerNotifyLow(), + * or #Temperature_registerNotifyRange() will take care initializing the + * internal elements appropriately. + */ +struct Temperature_NotifyObj { + List_Elem link; /*!< For placing on the notify list */ + Temperature_NotifyFxn notifyFxn; /*!< Application callback function */ + int16_t thresholdHigh; /*!< High threshold in degrees C */ + int16_t thresholdLow; /*!< Low threshold in degrees C */ + uintptr_t clientArg; /*!< Application provided arg */ + bool isRegistered; /*!< Is the notification active */ +}; + + +/*! + * @brief This function initializes the Temperature driver. + * + * This function initializes the internal state of the Temperature driver. + * It must be called before calling any other Temperature functions. Calling + * this function multiple times will only have an effect the first time. + */ +void Temperature_init(); + +/*! + * @brief Gets the current temperature in degrees C. + * + * @return Current temperature in degrees C + */ +int16_t Temperature_getTemperature(void); + +/*! + * @brief Registers a notification with a high threshold. + * + * This function registers a Temperature notification with a high threshold. + * Once the chip temperature rises above @c thresholdHigh, @c notifyFxn is + * called and the notification is automatically unregistered. + * + * @param notifyObject Structure to be initialized. After returning, + * it will contain the data necessary to issue a + * notification callback. The memory of the + * structure must persist while the notification + * is registered. + * + * @param [in] thresholdHigh Threshold temperature in degrees C + * + * @param [in] notifyFxn Callback function that is called once the + * chip temperature rises above + * @c thresholdHigh. + * + * @param [in] clientArg Application-specified argument + * + * @retval #Temperature_STATUS_SUCCESS The notification was successfully + * registered. + * @retval #Temperature_STATUS_ERROR There was an error during registration. + * + * @pre Temperature_init() called + */ +int_fast16_t Temperature_registerNotifyHigh(Temperature_NotifyObj *notifyObject, + int16_t thresholdHigh, + Temperature_NotifyFxn notifyFxn, + uintptr_t clientArg); + +/*! + * @brief Registers a notification with a low threshold. + * + * This function registers a Temperature notification with a low threshold. + * Once the chip temperature falls below @c thresholdLow, @c notifyFxn is + * called and the notification is automatically unregistered. + * + * @param notifyObject Structure to be initialized. After returning, + * it will contain the data necessary to issue a + * notification callback. The memory of the + * structure must persist while the notification + * is registered. + * + * @param [in] thresholdLow Threshold temperature in degrees C + * + * @param [in] notifyFxn Callback function that is called once the + * chip temperature falls below + * @c thresholdLow. + * + * @param [in] clientArg Application-specified argument + * + * @retval #Temperature_STATUS_SUCCESS The notification was successfully + * registered. + * @retval #Temperature_STATUS_ERROR There was an error during registration. + * + * @pre Temperature_init() called + */ +int_fast16_t Temperature_registerNotifyLow(Temperature_NotifyObj *notifyObject, + int16_t thresholdLow, + Temperature_NotifyFxn notifyFxn, + uintptr_t clientArg); + +/*! + * @brief Registers a notification with both a high and low threshold. + * + * This function registers a Temperature notification with a high and low + * threshold. Once the chip temperature rises above @c thresholdHigh or + * falls below @c thresholdLow, @c notifyFxn is called and the notification is + * automatically unregistered. + * + * @param notifyObject Structure to be initialized. After returning, + * it will contain the data necessary to issue a + * notification callback. The memory of the + * structure must persist while the notification + * is registered. + * + * @param [in] thresholdHigh High threshold temperature in degrees C + * + * @param [in] thresholdLow Low threshold temperature in degrees C + * + * @param [in] notifyFxn Callback function that is called once the + * chip temperature falls below + * @c thresholdLow, or rises above + * @c thresholdHigh. + * + * @param [in] clientArg Application-specified argument + * + * @retval #Temperature_STATUS_SUCCESS The notification was successfully + * registered + * @retval #Temperature_STATUS_ERROR There was an error during registration + * + * @pre Temperature_init() called + */ +int_fast16_t Temperature_registerNotifyRange(Temperature_NotifyObj *notifyObject, + int16_t thresholdHigh, + int16_t thresholdLow, + Temperature_NotifyFxn notifyFxn, + uintptr_t clientArg); + + +/*! + * @brief Unregisters a currently registered notification. + * + * This function unregisters a currently registered notification. It should not + * be called on a @c notifyObject that is not currently registered. + * + * @param notifyObject Notification to unregister. + * + * @retval #Temperature_STATUS_SUCCESS The notification was successfully + * unregistered. + * @retval #Temperature_STATUS_ERROR There was an error during + * unregistration. + * + * @pre Register @c notifyObject with #Temperature_registerNotifyHigh(), + * #Temperature_registerNotifyLow(), or #Temperature_registerNotifyRange() + */ +int_fast16_t Temperature_unregisterNotify(Temperature_NotifyObj *notifyObject); + +/*! + * @brief Get the high threshold of a notification. + * + * This function should not be called on a @c notifyObject registered with + * #Temperature_registerNotifyLow(). The high threshold value returned in + * that case will be a device-specific invalid temperature. + * + * @param notifyObject Notification to get the high threshold of. + * + * @return High threshold in degrees C. + * + * @pre Register @c notifyObject with #Temperature_registerNotifyHigh(), + * or #Temperature_registerNotifyRange() + */ +int16_t Temperature_getThresholdHigh(Temperature_NotifyObj *notifyObject); + +/*! + * @brief Get the low threshold of a notification. + * + * This function should not be called on a @c notifyObject registered with + * #Temperature_registerNotifyHigh(). The low threshold value returned in + * that case will be a device-specific invalid temperature. + * + * @param notifyObject Notification to get the low threshold of. + * + * @return Low threshold in degrees C. + * + * @pre Register @c notifyObject with #Temperature_registerNotifyLow(), + * or #Temperature_registerNotifyRange() + */ +int16_t Temperature_getThresholdLow(Temperature_NotifyObj *notifyObject); + +/*! + * @brief Get the high and low threshold of a notification. + * + * This function should not be called on a @c notifyObject registered with + * #Temperature_registerNotifyLow() or #Temperature_registerNotifyHigh(). + * The unconfigured threshold value returned in that case will be a + * device-specific invalid temperature. + * + * @param notifyObject Notification to get the high and low threshold of. + * + * @param [out] thresholdHigh High threshold value in degrees C written back + * by this function. + * + * @param [out] thresholdLow Low threshold value in degrees C written back + * by this function. + * + * @pre Register @c notifyObject with #Temperature_registerNotifyRange() + */ +void Temperature_getThresholdRange(Temperature_NotifyObj *notifyObject, + int16_t *thresholdHigh, + int16_t *thresholdLow); + +/*! + * @brief Get the application-provided clientArg of a notification. + * + * @param notifyObject Notification to get the clientArg of. + * + * @return The clientArg provided during registration. + * + * @pre Register @c notifyObject with #Temperature_registerNotifyHigh(), + * #Temperature_registerNotifyLow(), or #Temperature_registerNotifyRange() + */ +uintptr_t Temperature_getClientArg(Temperature_NotifyObj *notifyObject); + +/*! + * @brief Get the notifyFxn provided during registration. + * + * @param notifyObject Notification to get the notifyFxn of. + * + * @return The notifyFxn provided during registration + * + * @pre Register @c notifyObject with #Temperature_registerNotifyHigh(), + * #Temperature_registerNotifyLow(), or #Temperature_registerNotifyRange() + */ +Temperature_NotifyFxn Temperature_getNotifyFxn(Temperature_NotifyObj *notifyObject); + + +#ifdef __cplusplus +} +#endif + +#endif /* ti_drivers_Temperature__include */ diff --git a/simplelink/source/ti/drivers/power/PowerCC26X2.c b/simplelink/source/ti/drivers/power/PowerCC26X2.c index 67bd016..0a71d72 100644 --- a/simplelink/source/ti/drivers/power/PowerCC26X2.c +++ b/simplelink/source/ti/drivers/power/PowerCC26X2.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2019, Texas Instruments Incorporated + * Copyright (c) 2015-2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ #include #include +#include /* driverlib header files */ #include @@ -65,7 +66,6 @@ #include DeviceFamily_constructPath(driverlib/osc.h) #include DeviceFamily_constructPath(driverlib/cpu.h) #include DeviceFamily_constructPath(driverlib/vims.h) -#include DeviceFamily_constructPath(driverlib/rfc.h) #include DeviceFamily_constructPath(driverlib/sys_ctrl.h) #include DeviceFamily_constructPath(driverlib/driverlib_release.h) #include DeviceFamily_constructPath(driverlib/setup.h) @@ -79,6 +79,12 @@ static void disableLFClockQualifiers(void); static void emptyClockFunc(uintptr_t arg); static int_fast16_t notify(uint_fast16_t eventType); static void oscillatorISR(uintptr_t arg); +static void switchToTCXO(void); +static void delayUs(uint32_t us); +static void hposcRtcCompensateFxn(int16_t currentTemperature, + int16_t thresholdTemperature, + uintptr_t clientArg, + Temperature_NotifyObj *notifyObject); /* RCOSC calibration functions functions */ extern void PowerCC26X2_calibrate(void); @@ -94,8 +100,11 @@ PowerCC26X2_ModuleState PowerCC26X2_module = { .notifyList = {0}, /* list of registered notifications */ .constraintMask = 0, /* the constraint mask */ .clockObj = {0}, /* Clock object for scheduling wakeups */ + .calibrationClock = {0}, /* Clock object for RCOSC calibration */ + .tcxoEnableClock = {0}, /* Clock object for TCXO startup */ .tdcHwi = {0}, /* hwi object for calibration */ .oscHwi = {0}, /* hwi object for oscillators */ + .hposcRtcCompNotifyObj = {0}, /* Temperature notification */ .nDeltaFreqCurr = 0, /* RCOSC calibration variable */ .nCtrimCurr = 0, /* RCOSC calibration variable */ .nCtrimFractCurr = 0, /* RCOSC calibration variable */ @@ -149,6 +158,12 @@ const PowerCC26XX_ResourceRecord resourceDB[PowerCC26X2_NUMRESOURCES] = { {PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_UART1}, /* PERIPH_UART1 */ }; +/* Defines */ +#define TCXO_RAMP_DELAY 10 +#define CC26X2_CLOCK_FREQUENCY 48000000 + +/* This is an approximate scaling factor previously used in test firmware. */ +#define DELAY_SCALING_FACTOR 6000000 /* ****************** Power APIs ******************** */ @@ -273,6 +288,22 @@ int_fast16_t Power_init() /* copy the Power policy function to module state */ PowerCC26X2_module.policyFxn = PowerCC26X2_config.policyFxn; + /* Check if TCXO is selected in CCFG and in addition configured to be + * enabled by the function pointed to by PowerCC26X2_config.enableTCXOFxn + */ + if ((CCFGRead_XOSC_FREQ() == CCFGREAD_XOSC_FREQ_TCXO) && + (PowerCC26X2_config.enableTCXOFxn != NULL)) { + /* Construct the Clock object for TCXO startup time. + * Set timeout to TCXO startup time as specified in CCFG. + */ + ClockP_construct(&PowerCC26X2_module.tcxoEnableClock, + (ClockP_Fxn)&switchToTCXO, + (CCFGRead_TCXO_MAX_START()*100)/ClockP_getSystemTickPeriod(), + NULL); + + HWREG(AUX_DDI0_OSC_BASE + DDI_O_CLR + DDI_0_OSC_O_CTL0) = DDI_0_OSC_CTL0_XTAL_IS_24M; + } + /* construct the Clock object for scheduling of wakeups */ /* initiated and started by the power policy */ ClockP_Params_init(&clockParams); @@ -695,7 +726,6 @@ int_fast16_t Power_sleep(uint_fast16_t sleepState) unsigned int constraints; bool retainCache = false; uint32_t modeVIMS; - unsigned int swiKey; /* first validate the sleep code */ if (sleepState != PowerCC26XX_STANDBY) { @@ -720,7 +750,7 @@ int_fast16_t Power_sleep(uint_fast16_t sleepState) postEvent = PowerCC26XX_AWAKE_STANDBY; postEventLate = PowerCC26XX_AWAKE_STANDBY_LATE; - /* disable Task scheduling */ + /* disable scheduling */ PowerCC26XX_schedulerDisable(); /* signal all clients registered for pre-sleep notification */ @@ -733,9 +763,6 @@ int_fast16_t Power_sleep(uint_fast16_t sleepState) return (status); } - /* now disable Swi scheduling */ - swiKey = SwiP_disable(); - /* 1. Query and save domain states before powering them off */ if (Power_getDependencyCount(PowerCC26XX_DOMAIN_RFCORE)) { poweredDomains |= PRCM_DOMAIN_RFCORE; @@ -875,10 +902,7 @@ int_fast16_t Power_sleep(uint_fast16_t sleepState) */ PowerCC26X2_module.state = Power_ACTIVE; - /* Re-enable Swi scheduling */ - SwiP_restore(swiKey); - - /* re-enable Task scheduling */ + /* 19. Re-enable scheduling */ PowerCC26XX_schedulerRestore(); /* if there was a notification error, set return status */ @@ -912,6 +936,35 @@ void Power_unregisterNotify(Power_NotifyObj * pNotifyObj) /* ****************** CC26XX specific APIs ******************** */ +/* + * ======== PowerCC26X2_enableHposcRtcCompensation ======== + * This function enabled temperature based compensation of the RTC when + * SCLK_LF is derived from HPOSC. + */ +void PowerCC26X2_enableHposcRtcCompensation(void) { + /* If we are using HPOSC and SCLK_LF is derived from it, we need to + * compensate the RTC to account for HPOSC frequency drift over temperature. + */ + if (OSC_IsHPOSCEnabledWithHfDerivedLfClock()) { + Temperature_init(); + + int16_t currentTemperature = Temperature_getTemperature(); + + OSC_HPOSCInitializeFrequencyOffsetParameters(); + + /* The compensation fxn will register itself with updated thresholds + * based on the current temperature each time it is invoked. If we + * call it from the init function, it will register itself for the + * first time and handle initial RTC compensation. + */ + hposcRtcCompensateFxn(currentTemperature, + currentTemperature + PowerCC26X2_HPOSC_RTC_COMPENSATION_DELTA, + (uintptr_t)NULL, + &PowerCC26X2_module.hposcRtcCompNotifyObj); + } +} + + /* * ======== PowerCC26XX_calibrate ======== * Plug this function into the PowerCC26X2_Config structure @@ -1055,6 +1108,32 @@ void PowerCC26XX_switchXOSC_HF(void) /* * * * * * * * * * * internal and support functions * * * * * * * * * * */ +/* + * ======== hposcRtcCompensateFxn ======== + */ +void hposcRtcCompensateFxn(int16_t currentTemperature, + int16_t thresholdTemperature, + uintptr_t clientArg, + Temperature_NotifyObj *notifyObject) { + int_fast16_t status; + int32_t relFreqOffset; + + relFreqOffset = OSC_HPOSCRelativeFrequencyOffsetGet(currentTemperature); + + OSC_HPOSCRtcCompensate(relFreqOffset); + + /* Register the notification again with updated thresholds */ + status = Temperature_registerNotifyRange(notifyObject, + currentTemperature + PowerCC26X2_HPOSC_RTC_COMPENSATION_DELTA, + currentTemperature - PowerCC26X2_HPOSC_RTC_COMPENSATION_DELTA, + hposcRtcCompensateFxn, + (uintptr_t)NULL); + + if (status != Temperature_STATUS_SUCCESS) { + while(1); + } +} + /* * ======== oscillatorISR ======== */ @@ -1156,6 +1235,17 @@ static unsigned int nopResourceHandler(unsigned int action) return (0); } +/* + * ======== delayUs ======== + * Polls for an approximate number of us. Not very accurate. + * In this use case we only care about waiting 'at least X' + * and a few extra microseconds will only allow additional + * stabilisation time. + */ +static void delayUs(uint32_t us) { + CPUdelay((CC26X2_CLOCK_FREQUENCY / DELAY_SCALING_FACTOR) * us); +} + /* * ======== notify ======== * Send notifications to registered clients. @@ -1202,16 +1292,11 @@ static int_fast16_t notify(uint_fast16_t eventType) /* * ======== configureRFCoreClocks ======== * Special dependency function for controlling RF core clocks. + * This function does nothing, but is kept for legacy reasons. + * All functionality has been integrated into the RF driver. */ static unsigned int configureRFCoreClocks(unsigned int action) { - if (action == PowerCC26XX_ENABLE) { - RFCClockEnable(); - } - else { - RFCClockDisable(); - } - return (0); } @@ -1272,18 +1357,62 @@ static unsigned int configureXOSCHF(unsigned int action) OSCClockSourceGet(OSC_SRC_CLK_HF) != OSC_XOSC_HF && PowerCC26X2_module.xoscPending == false) { - OSCHF_TurnOnXosc(); + /* Check if TCXO is selected in CCFG and in addition configured to be enabled + * by the function pointed to by PowerCC26X2_config.enableTCXOFxn. + */ + if ((CCFGRead_XOSC_FREQ() == CCFGREAD_XOSC_FREQ_TCXO) && + (PowerCC26X2_config.enableTCXOFxn != NULL)) { + + /* Enable clock qualification on 48MHz signal from TCXO */ + if (CCFGRead_TCXO_TYPE() == 0x1) { + /* If the selected TCXO type is clipped-sine, also enable + * internal common-mode bias + */ + HWREG(AUX_DDI0_OSC_BASE + DDI_O_SET + DDI_0_OSC_O_XOSCHFCTL) = DDI_0_OSC_XOSCHFCTL_TCXO_MODE_XOSC_HF_EN | + DDI_0_OSC_XOSCHFCTL_TCXO_MODE; + } + else { + HWREG(AUX_DDI0_OSC_BASE + DDI_O_SET + DDI_0_OSC_O_XOSCHFCTL) = DDI_0_OSC_XOSCHFCTL_TCXO_MODE; + } + + /* Wait for ~10 us for common mode bias to stabilise and clock + * qual to take affect. + */ + delayUs(TCXO_RAMP_DELAY); + + /* Enable power on TCXO */ + (*(PowerCC26X2_config.enableTCXOFxn))(true); + + /* Start clock to wait for TCXO startup time before clock switch + * can be attempted. + */ + ClockP_start(ClockP_handle(&PowerCC26X2_module.tcxoEnableClock)); + } + else { + /* Turn on and request XOSC_HF from the hardware for regular + * XOSC and HPOSC. TCXO does not require this call until right + * before switching since we do not rely on the harware to + * interrupt the system once the XOSC is stable. + */ + OSCHF_TurnOnXosc(); + } PowerCC26X2_module.xoscPending = true; /* Unless it is disallowed, unmask the XOSC_HF ready to switch flag */ - if (!(Power_getConstraintMask() & (1 << PowerCC26XX_SWITCH_XOSC_HF_MANUALLY))) { + if (!((CCFGRead_XOSC_FREQ() == CCFGREAD_XOSC_FREQ_TCXO) && + (PowerCC26X2_config.enableTCXOFxn != NULL))) + { + if (!(Power_getConstraintMask() & (1 << PowerCC26XX_SWITCH_XOSC_HF_MANUALLY))) { - /* Clearing the flag in the ISR does not always work. Clear it again just in case */ - HWREG(PRCM_BASE + PRCM_O_OSCICR) = PRCM_OSCICR_HFSRCPENDC_M; + /* Clearing the flag in the ISR does not always work. Clear it + * again just in case + * */ + HWREG(PRCM_BASE + PRCM_O_OSCICR) = PRCM_OSCICR_HFSRCPENDC_M; - /* Turn on oscillator interrupt for SCLK_HF switching */ - HWREG(PRCM_BASE + PRCM_O_OSCIMSC) |= PRCM_OSCIMSC_HFSRCPENDIM_M; + /* Turn on oscillator interrupt for SCLK_HF switching */ + HWREG(PRCM_BASE + PRCM_O_OSCIMSC) |= PRCM_OSCIMSC_HFSRCPENDIM_M; + } } /* If the device goes into IDLE in between turning on XOSC_HF and @@ -1299,6 +1428,43 @@ static unsigned int configureXOSCHF(unsigned int action) else if (action == PowerCC26XX_DISABLE) { OSCHF_SwitchToRcOscTurnOffXosc(); + /* Handle TCXO if selected in CCFG */ + if ((CCFGRead_XOSC_FREQ() == CCFGREAD_XOSC_FREQ_TCXO) && + (PowerCC26X2_config.enableTCXOFxn != NULL)) { + /* Disable Clock in case we have started it and are waiting for + * the TCXO to stabilise. + * If the Clock is not currently active, this should do nothing. + */ + ClockP_stop(ClockP_handle(&PowerCC26X2_module.tcxoEnableClock)); + + /* Disable clock qualification on 48MHz signal from TCXO and turn + * off TCXO bypass. + * If we do not disable clock qualificaition, it will not run the + * next time we switch to TCXO. + */ + if (CCFGRead_TCXO_TYPE() == 1) { + /* Also turn off bias if clipped sine TCXO type. The bias + * consumes a few hundred uA. That is fine while the TCXO is + * running but we should not incur this penalty when not running + * on TCXO. + */ + HWREG(AUX_DDI0_OSC_BASE + DDI_O_CLR + DDI_0_OSC_O_XOSCHFCTL) = DDI_0_OSC_XOSCHFCTL_TCXO_MODE | + DDI_0_OSC_XOSCHFCTL_BYPASS | + DDI_0_OSC_XOSCHFCTL_TCXO_MODE_XOSC_HF_EN; + } + else { + HWREG(AUX_DDI0_OSC_BASE + DDI_O_CLR + DDI_0_OSC_O_XOSCHFCTL) = DDI_0_OSC_XOSCHFCTL_TCXO_MODE | + DDI_0_OSC_XOSCHFCTL_BYPASS; + } + + /* Check if function for enabling/disabling TCXO is supported */ + if (PowerCC26X2_config.enableTCXOFxn != NULL) { + + /* Disable TCXO by turning off power */ + (*(PowerCC26X2_config.enableTCXOFxn))(false); + } + } + /* If we have not actually switched to XOSC_HF yet, we need to * undo what we did above when turning on XOSC_HF. Otherwise, * we may not balance the constraints correctly or get @@ -1319,3 +1485,23 @@ static unsigned int configureXOSCHF(unsigned int action) } return (0); } + +/* + * ======== switchToTCXO ======== + * Switching to TCXO after TCXO startup time has expired. + */ +static void switchToTCXO(void) +{ + /* Set bypass bit */ + HWREG(AUX_DDI0_OSC_BASE + DDI_O_SET + DDI_0_OSC_O_XOSCHFCTL) = DDI_0_OSC_XOSCHFCTL_BYPASS; + + /* Request XOSC_HF. In this instance, that is the TCXO and it will + * immediately be ready to switch to after requesting since we turned it on + * earlier with a GPIO and waited for it to stabilise. + */ + OSCHF_TurnOnXosc(); + + /* Switch to TCXO */ + switchXOSCHF(); +} + diff --git a/simplelink/source/ti/drivers/power/PowerCC26X2.h b/simplelink/source/ti/drivers/power/PowerCC26X2.h index 8804cad..a82fd68 100644 --- a/simplelink/source/ti/drivers/power/PowerCC26X2.h +++ b/simplelink/source/ti/drivers/power/PowerCC26X2.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,14 +52,15 @@ #ifndef ti_drivers_power_PowerCC26X2_ #define ti_drivers_power_PowerCC26X2_ -#ifdef __cplusplus -extern "C" { -#endif - #include #include #include #include +#include + +#ifdef __cplusplus +extern "C" { +#endif /*! The latency to reserve for resume from STANDBY (usec). */ #define PowerCC26X2_RESUMETIMESTANDBY 750 @@ -92,6 +93,11 @@ extern "C" { #define PowerCC26X2_PERIPH_UART1 PowerCC26XX_NUMRESOURCES + 1 /*!< Resource ID: UART1 */ +/*! The temperature delta in degrees C before the RTC is re-compensated when + * SCLK_LF is derived from SCLK_HF and SCLK_HF is supplied by HPOSC. + */ +#define PowerCC26X2_HPOSC_RTC_COMPENSATION_DELTA 3 + /* \cond */ #define PowerCC26X2_NUMRESOURCES (PowerCC26XX_NUMRESOURCES + 2) /* Number of resources in database */ /* \endcond */ @@ -111,7 +117,7 @@ extern "C" { /*! @brief Global configuration structure */ -typedef struct PowerCC26X2_Config { +typedef struct { /*! * @brief The Power Policy's initialization function * @@ -184,6 +190,13 @@ typedef struct PowerCC26X2_Config { * RCOSC_HF should be calibrated. */ bool calibrateRCOSC_HF; + /*! + * @brief The function to be used for enabling or disabling the TCXO + * + * If TCXO is configured to be enabled in CCFG this function will + * enable or disable the TCXO by asserting or deasserting power to it. + */ + void (*enableTCXOFxn)(bool); } PowerCC26X2_Config; /*! @@ -192,13 +205,18 @@ typedef struct PowerCC26X2_Config { * Power manager state structure. The application must not access any members * of this structure! */ -typedef struct PowerCC26X2_ModuleState { +typedef struct { List_List notifyList; /*!< Event notification list */ uint32_t constraintMask; /*!< Aggregate constraints mask */ ClockP_Struct clockObj; /*!< Clock object for scheduling wakeups */ ClockP_Struct calibrationClock; /*!< Clock object for scheduling wakeups */ + ClockP_Struct tcxoEnableClock; /*!< Clock object for TCXO startup time */ HwiP_Struct oscHwi; /*!< Hwi object for oscillator stabilisation */ HwiP_Struct tdcHwi; /*!< Hwi object for RCOSC calibration */ + Temperature_NotifyObj hposcRtcCompNotifyObj; + /*! Temperature notification to compensate the RTC when SCLK_LF is derived + * from SCLK_HF when SCLK_HF is configured as HPOSC. + */ int32_t nDeltaFreqCurr; /*!< RCOSC calibration variable */ int32_t nCtrimCurr; /*!< RCOSC calibration variable */ int32_t nCtrimFractCurr; /*!< RCOSC calibration variable */ @@ -226,6 +244,18 @@ typedef struct PowerCC26X2_ModuleState { Power_PolicyFxn policyFxn; /*!< The Power policy function */ } PowerCC26X2_ModuleState; +/*! + * @brief Enable RTC compensation when SCLK_LF is derived from HPOSC + * + * Enables automatic compensation for temperature based clock drift of the RTC + * when SCLK_LF is derived from HPOSC. + * + * It only needs to be called once after the system boots. + * + * This function should only be called when SCLK_LF is configured to be drived + * from HPOSC. + */ +void PowerCC26X2_enableHposcRtcCompensation(void); #ifdef __cplusplus } diff --git a/simplelink/source/ti/drivers/power/PowerCC26X2_calibrateRCOSC.c b/simplelink/source/ti/drivers/power/PowerCC26X2_calibrateRCOSC.c index 45f6bb3..d9ec052 100644 --- a/simplelink/source/ti/drivers/power/PowerCC26X2_calibrateRCOSC.c +++ b/simplelink/source/ti/drivers/power/PowerCC26X2_calibrateRCOSC.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, Texas Instruments Incorporated + * Copyright (c) 2017-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -87,7 +87,7 @@ #define PowerCC26X2_STATE_CLEANUP 6 /* FSM results */ -typedef enum PowerCC26X2_FsmResult_ { +typedef enum { PowerCC26X2_FSM_RESULT_RUN_FSM, PowerCC26X2_FSM_RESULT_WAIT_FOR_TDC, PowerCC26X2_FSM_RESULT_DONE, diff --git a/simplelink/source/ti/drivers/power/PowerCC26XX.c b/simplelink/source/ti/drivers/power/PowerCC26XX.c deleted file mode 100644 index 0cfa419..0000000 --- a/simplelink/source/ti/drivers/power/PowerCC26XX.c +++ /dev/null @@ -1,1394 +0,0 @@ -/* - * Copyright (c) 2015-2018, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * 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. - * - * * Neither the name of Texas Instruments Incorporated 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 OWNER 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. - */ -/* - * ======== PowerCC26XX.c ======== - */ - -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include DeviceFamily_constructPath(inc/hw_types.h) -#include DeviceFamily_constructPath(inc/hw_prcm.h) -#include DeviceFamily_constructPath(inc/hw_nvic.h) -#include DeviceFamily_constructPath(inc/hw_aon_wuc.h) -#include DeviceFamily_constructPath(inc/hw_aon_rtc.h) -#include DeviceFamily_constructPath(inc/hw_memmap.h) -#include DeviceFamily_constructPath(inc/hw_ccfg.h) -#include DeviceFamily_constructPath(inc/hw_rfc_pwr.h) -#include DeviceFamily_constructPath(driverlib/sys_ctrl.h) -#include DeviceFamily_constructPath(driverlib/pwr_ctrl.h) -#include DeviceFamily_constructPath(driverlib/prcm.h) -#include DeviceFamily_constructPath(driverlib/aon_wuc.h) -#include DeviceFamily_constructPath(driverlib/aon_ioc.h) -#include DeviceFamily_constructPath(driverlib/aon_rtc.h) -#include DeviceFamily_constructPath(driverlib/aon_event.h) -#include DeviceFamily_constructPath(driverlib/aux_wuc.h) -#include DeviceFamily_constructPath(driverlib/osc.h) -#include DeviceFamily_constructPath(driverlib/cpu.h) -#include DeviceFamily_constructPath(driverlib/vims.h) -#include DeviceFamily_constructPath(driverlib/rfc.h) -#include DeviceFamily_constructPath(driverlib/sys_ctrl.h) -#include DeviceFamily_constructPath(driverlib/driverlib_release.h) -#include DeviceFamily_constructPath(driverlib/setup.h) -#include DeviceFamily_constructPath(driverlib/ccfgread.h) - -static unsigned int configureXOSCHF(unsigned int action); -static unsigned int nopResourceHandler(unsigned int action); -static unsigned int configureRFCoreClocks(unsigned int action); -static void switchXOSCHFclockFunc(uintptr_t arg0); -static void lfClockReadyCallback(uintptr_t arg); -static void disableLfClkQualifiersEnableClkLoss(); -static void emptyClockFunc(uintptr_t arg); -static int_fast16_t notify(uint_fast16_t eventType); - -/* RCOSC calibration functions functions */ -extern void PowerCC26XX_doCalibrate(void); -extern bool PowerCC26XX_initiateCalibration(void); -extern void PowerCC26XX_auxISR(uintptr_t arg); -extern void PowerCC26XX_RCOSC_clockFunc(uintptr_t arg); - -/* Externs */ -extern const PowerCC26XX_Config PowerCC26XX_config; - -/* Module_State */ -PowerCC26XX_ModuleState PowerCC26XX_module = { - .notifyList = { NULL }, /* list of registered notifications */ - .constraintMask = 0, /* the constraint mask */ - .clockObj = { 0 }, /* Clock object for scheduling wakeups */ - .xoscClockObj = { 0 }, /* Clock object for XOSC_HF switching */ - .lfClockObj = { 0 }, /* Clock object for LF clock check */ - .calClockStruct = { 0 }, /* Clock object for RCOSC calibration */ - .hwiStruct = { 0 }, /* hwi object for calibration */ - .nDeltaFreqCurr = 0, /* RCOSC calibration variable */ - .nCtrimCurr = 0, /* RCOSC calibration variable */ - .nCtrimFractCurr = 0, /* RCOSC calibration variable */ - .nCtrimNew = 0, /* RCOSC calibration variable */ - .nCtrimFractNew = 0, /* RCOSC calibration variable */ - .nRtrimNew = 0, /* RCOSC calibration variable */ - .nRtrimCurr = 0, /* RCOSC calibration variable */ - .nDeltaFreqNew = 0, /* RCOSC calibration variable */ - .bRefine = false, /* RCOSC calibration variable */ - .state = Power_ACTIVE, /* current transition state */ - .xoscPending = false, /* is XOSC_HF activation in progress? */ - .calLF = false, /* calibrate RCOSC_LF? */ - .hwiState = 0, /* calibration AUX ISR state */ - .busyCal = false, /* already busy calibrating */ - .calStep = 1, /* current calibration step */ - .firstLF = true, /* is this first LF calibration? */ - .enablePolicy = false, /* default value is false */ - .initialized = false, /* whether Power_init has been called */ -#if defined(DeviceFamily_CC26X0R2) - .emulatorAttached = false, /* emulator attached during boot */ -#endif - .constraintCounts = { 0, 0, 0, 0, 0, 0, 0 }, - .resourceCounts = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - .resourceHandlers = { - configureRFCoreClocks, - configureXOSCHF, - nopResourceHandler - }, /* special resource handler functions */ - .policyFxn = NULL /* power policyFxn */ -}; - -/* resource database */ -const PowerCC26XX_ResourceRecord resourceDB[PowerCC26XX_NUMRESOURCES] = { - { PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_TIMER0 }, /* PERIPH_GPT0 */ - { PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_TIMER1 }, /* PERIPH_GPT1 */ - { PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_TIMER2 }, /* PERIPH_GPT2 */ - { PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_TIMER3 }, /* PERIPH_GPT3 */ - { PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_SERIAL, PRCM_PERIPH_SSI0 }, /* PERIPH_SSI0 */ - { PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_SSI1 }, /* PERIPH_SSI1 */ - { PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_SERIAL, PRCM_PERIPH_UART0 }, /* PERIPH_UART0 */ - { PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_SERIAL, PRCM_PERIPH_I2C0 }, /* PERIPH_I2C0 */ - { PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_TRNG }, /* PERIPH_TRNG */ - { PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_GPIO }, /* PERIPH_GPIO */ - { PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_UDMA }, /* PERIPH_UDMA */ - { PowerCC26XX_PERIPH | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_CRYPTO }, /* PERIPH_CRYPTO */ - { PowerCC26XX_PERIPH | PowerCC26XX_PERIPH_UDMA, PRCM_PERIPH_I2S }, /* PERIPH_I2S */ - { PowerCC26XX_SPECIAL | PowerCC26XX_DOMAIN_RFCORE, 0 }, /* PERIPH_RFCORE */ - { PowerCC26XX_SPECIAL | PowerCC26XX_NOPARENT, 1 }, /* XOSC_HF */ - { PowerCC26XX_DOMAIN | PowerCC26XX_NOPARENT, PRCM_DOMAIN_PERIPH }, /* DOMAIN_PERIPH */ - { PowerCC26XX_DOMAIN | PowerCC26XX_NOPARENT, PRCM_DOMAIN_SERIAL }, /* DOMAIN_SERIAL */ - { PowerCC26XX_DOMAIN | PowerCC26XX_NOPARENT, PRCM_DOMAIN_RFCORE }, /* DOMAIN_RFCORE */ - { PowerCC26XX_SPECIAL | PowerCC26XX_NOPARENT, 2 } /* DOMAIN_SYSBUS */ -}; - - -/* ****************** Power APIs ******************** */ - -/* - * ======== Power_disablePolicy ======== - * Do not run the configured policy - */ -bool Power_disablePolicy(void) -{ - bool enablePolicy = PowerCC26XX_module.enablePolicy; - PowerCC26XX_module.enablePolicy = false; - - return (enablePolicy); -} - -/* - * ======== Power_enablePolicy ======== - * Run the configured policy - */ -void Power_enablePolicy(void) -{ - PowerCC26XX_module.enablePolicy = true; -} - -/* - * ======== Power_getConstraintMask ======== - * Get a bitmask indicating the constraints that have been registered with - * Power. - */ -uint_fast32_t Power_getConstraintMask(void) -{ - return (PowerCC26XX_module.constraintMask); -} - -/* - * ======== Power_getDependencyCount ======== - * Get the count of dependencies that are currently declared upon a resource. - */ -int_fast16_t Power_getDependencyCount(uint_fast16_t resourceId) -{ - DebugP_assert(resourceId < PowerCC26XX_NUMRESOURCES); - - return ((int_fast16_t)PowerCC26XX_module.resourceCounts[resourceId]); -} - -/* - * ======== Power_getTransitionLatency ======== - * Get the transition latency for a sleep state. The latency is reported - * in units of microseconds. - */ -uint_fast32_t Power_getTransitionLatency(uint_fast16_t sleepState, - uint_fast16_t type) -{ - uint32_t latency = 0; - - if (type == Power_RESUME) { - if (sleepState == PowerCC26XX_STANDBY) { - latency = PowerCC26XX_RESUMETIMESTANDBY; - } - } - else { - if (sleepState == PowerCC26XX_STANDBY) { - latency = PowerCC26XX_TOTALTIMESTANDBY; - } - } - - return (latency); -} - -/* - * ======== Power_getTransitionState ======== - * Get the current sleep transition state. - */ -uint_fast16_t Power_getTransitionState(void) -{ - return (PowerCC26XX_module.state); -} - -/* - * ======== Power_idleFunc ======== - * Function needs to be plugged into the idle loop. - * It calls the configured policy function if the - * 'enablePolicy' flag is set. - */ -void Power_idleFunc() -{ - if (PowerCC26XX_module.enablePolicy) { - if (PowerCC26XX_module.policyFxn != NULL) { - (*(PowerCC26XX_module.policyFxn))(); - } - } -} - -/* - * ======== Power_init ======== - */ -int_fast16_t Power_init() -{ - ClockP_Params clockParams; - uint32_t ccfgLfClkSrc; - uint32_t timeout; - - /* if this function has already been called, just return */ - if (PowerCC26XX_module.initialized) { - return (Power_SOK); - } - -#if defined(DeviceFamily_CC26X0R2) - /* check to see if the JTAG_PD is on, meaning the emulator was attached during boot and */ - /* that the user is in an active debug session */ - PowerCC26XX_module.emulatorAttached = (HWREG(AON_WUC_BASE + AON_WUC_O_PWRSTAT) & AON_WUC_PWRSTAT_JTAG_PD_ON) == AON_WUC_PWRSTAT_JTAG_PD_ON; -#endif - - /* set module state field 'initialized' to true */ - PowerCC26XX_module.initialized = true; - - /* set the module state enablePolicy field */ - PowerCC26XX_module.enablePolicy = PowerCC26XX_config.enablePolicy; - - /* copy the Power policy function to module state */ - PowerCC26XX_module.policyFxn = PowerCC26XX_config.policyFxn; - - /* construct the Clock object for scheduling of wakeups */ - /* initiated and started by the power policy */ - ClockP_Params_init(&clockParams); - clockParams.period = 0; - clockParams.startFlag = false; - clockParams.arg = 0; - ClockP_construct(&PowerCC26XX_module.clockObj, &emptyClockFunc, - 0, &clockParams); - - /* construct the Clock object for XOSC_HF switching */ - /* initiated and started by Power module when activating XOSC_HF */ - ClockP_construct(&PowerCC26XX_module.xoscClockObj, &switchXOSCHFclockFunc, - 0, &clockParams); - - /* construct the Clock object for disabling LF clock quailifiers */ - /* one shot, auto start, first expires at 100 msec */ - ClockP_construct(&PowerCC26XX_module.lfClockObj, &lfClockReadyCallback, - 0, &clockParams); - - (*(PowerCC26XX_config.calibrateFxn))(PowerCC26XX_SETUP_CALIBRATE); - - DRIVERLIB_ASSERT_CURR_RELEASE(); - - /* read the LF clock source from CCFG */ - ccfgLfClkSrc = CCFGRead_SCLK_LF_OPTION(); - - /* check if should calibrate RCOSC_LF */ - if (PowerCC26XX_config.calibrateRCOSC_LF) { - /* verify RCOSC_LF is the LF clock source */ - if (ccfgLfClkSrc == CCFGREAD_SCLK_LF_OPTION_RCOSC_LF) { - PowerCC26XX_module.calLF = true; - } - } - - /* - * if LF source is RCOSC_LF or XOSC_LF: assert DISALLOW_STANDBY constraint - * and start a timeout to check for activation - */ - if ((ccfgLfClkSrc == CCFGREAD_SCLK_LF_OPTION_RCOSC_LF) || - (ccfgLfClkSrc == CCFGREAD_SCLK_LF_OPTION_XOSC_LF)) { - - /* disallow STANDBY pending LF clock quailifier disabling */ - Power_setConstraint(PowerCC26XX_DISALLOW_STANDBY); - - /* determine timeout */ - if (ccfgLfClkSrc == CCFGREAD_SCLK_LF_OPTION_RCOSC_LF) { - timeout = PowerCC26XX_INITIALWAITRCOSC_LF; - } - else { - timeout = PowerCC26XX_INITIALWAITXOSC_LF; - } - - /* start the Clock object */ - ClockP_setTimeout(ClockP_handle(&PowerCC26XX_module.lfClockObj), - (timeout / ClockP_tickPeriod)); - ClockP_start(ClockP_handle(&PowerCC26XX_module.lfClockObj)); - } - - /* - * else, if the LF clock source is external, can disable clock qualifiers - * now; no need to assert DISALLOW_STANDBY or start the Clock object - */ - else if (ccfgLfClkSrc == CCFGREAD_SCLK_LF_OPTION_EXTERNAL_LF) { - - /* Disable clock qualifiers and enable clock loss */ - disableLfClkQualifiersEnableClkLoss(); - } - /* - * else, user has requested LF to be derived from XOSC_HF - */ - else if(ccfgLfClkSrc == CCFGREAD_SCLK_LF_OPTION_XOSC_HF_DLF) - { - /* disallow standby */ - Power_setConstraint(PowerCC26XX_DISALLOW_STANDBY); - - /* wait for the XOSC_HF to power up if it's not ready.. */ - if(OSCClockSourceGet(OSC_SRC_CLK_LF) == OSC_XOSC_HF) - { - /* XOSC_HF is ready. Simply disable clock qualifiers and enable clock loss */ - disableLfClkQualifiersEnableClkLoss(NULL); - } - else - { - /* XOSC_HF is not ready yet, schedule clock to check again later */ - timeout = PowerCC26XX_INITIALWAITXOSC_HF / ClockP_tickPeriod; - /* start the Clock object */ - ClockP_setTimeout(ClockP_handle(&PowerCC26XX_module.lfClockObj), - (timeout / ClockP_tickPeriod)); - ClockP_start(ClockP_handle(&PowerCC26XX_module.lfClockObj)); - } - } - - /* if VIMS RAM is configured as GPRAM: set retention constraint */ - if (!CCFGRead_DIS_GPRAM()) { - Power_setConstraint(PowerCC26XX_RETAIN_VIMS_CACHE_IN_STANDBY); - } - - return (Power_SOK); -} - -/* - * ======== Power_registerNotify ======== - * Register a function to be called on a specific power event. - * - */ -int_fast16_t Power_registerNotify(Power_NotifyObj * pNotifyObj, - uint_fast16_t eventTypes, Power_NotifyFxn notifyFxn, uintptr_t clientArg) -{ - int_fast16_t status = Power_SOK; - - /* check for NULL pointers */ - if ((pNotifyObj == NULL) || (notifyFxn == NULL)) { - status = Power_EINVALIDPOINTER; - } - - else { - /* fill in notify object elements */ - pNotifyObj->eventTypes = eventTypes; - pNotifyObj->notifyFxn = notifyFxn; - pNotifyObj->clientArg = clientArg; - - /* place notify object on event notification queue */ - List_put(&PowerCC26XX_module.notifyList, (List_Elem*)pNotifyObj); - } - - return (status); -} - -/* - * ======== Power_releaseConstraint ======== - * Release a previously declared constraint. - */ -int_fast16_t Power_releaseConstraint(uint_fast16_t constraintId) -{ - unsigned int key; - uint8_t count; - - DebugP_assert(constraintId < PowerCC26XX_NUMCONSTRAINTS); - - key = HwiP_disable(); - - /* get the count of the constraint */ - count = PowerCC26XX_module.constraintCounts[constraintId]; - - DebugP_assert(count != 0); - - count--; - - /* save the updated count */ - PowerCC26XX_module.constraintCounts[constraintId] = count; - - if (count == 0) { - PowerCC26XX_module.constraintMask &= ~(1 << constraintId); - } - - HwiP_restore(key); - - return (Power_SOK); -} - -/* - * ======== Power_releaseDependency ======== - * Release a previously declared dependency. - */ -int_fast16_t Power_releaseDependency(uint_fast16_t resourceId) -{ - uint8_t parent; - uint8_t count; - uint32_t id; - unsigned int key; - - /* assert resourceId is valid */ - DebugP_assert(resourceId < PowerCC26XX_NUMRESOURCES); - - /* disable interrupts */ - key = HwiP_disable(); - - /* read and decrement the reference count */ - count = PowerCC26XX_module.resourceCounts[resourceId]; - - DebugP_assert(count != 0); - - count--; - - /* save the reference count */ - PowerCC26XX_module.resourceCounts[resourceId] = count; - - /* if this was the last dependency being released.., */ - if (count == 0) { - /* deactivate this resource ... */ - id = resourceDB[resourceId].driverlibID; - - /* is resource a peripheral?... */ - if (resourceDB[resourceId].flags & PowerCC26XX_PERIPH) { - PRCMPeripheralRunDisable(id); - PRCMPeripheralSleepDisable(id); - PRCMPeripheralDeepSleepDisable(id); - PRCMLoadSet(); - while (!PRCMLoadGet()) { - ; - } - } - /* else, does resource require a special handler?... */ - else if (resourceDB[resourceId].flags & PowerCC26XX_SPECIAL) { - /* call the special handler */ - PowerCC26XX_module.resourceHandlers[id](PowerCC26XX_DISABLE); - } - - /* else resource is a power domain */ - else { - PRCMPowerDomainOff(id); - while (PRCMPowerDomainStatus(id) != PRCM_DOMAIN_POWER_OFF) { - ; - } - } - - /* propagate release up the dependency tree ... */ - - /* check for a first parent */ - parent = resourceDB[resourceId].flags & PowerCC26XX_PARENTMASK; - - /* if 1st parent, make recursive call to release that dependency */ - if (parent < PowerCC26XX_NUMRESOURCES) { - Power_releaseDependency(parent); - } - } - - /* re-enable interrupts */ - HwiP_restore(key); - - return (Power_SOK); -} - -/* - * ======== Power_setConstraint ======== - * Declare an operational constraint. - */ -int_fast16_t Power_setConstraint(uint_fast16_t constraintId) -{ - unsigned int key; - - DebugP_assert(constraintId < PowerCC26XX_NUMCONSTRAINTS); - - /* disable interrupts */ - key = HwiP_disable(); - - /* set the specified constraint in the constraintMask */ - PowerCC26XX_module.constraintMask |= 1 << constraintId; - - /* increment the specified constraint count */ - PowerCC26XX_module.constraintCounts[constraintId]++; - - /* re-enable interrupts */ - HwiP_restore(key); - - return (Power_SOK); -} - -/* - * ======== Power_setDependency ======== - * Declare a dependency upon a resource. - */ -int_fast16_t Power_setDependency(uint_fast16_t resourceId) -{ - uint8_t parent; - uint8_t count; - uint32_t id; - unsigned int key; - - DebugP_assert(resourceId < PowerCC26XX_NUMRESOURCES); - - /* disable interrupts */ - key = HwiP_disable(); - - /* read and increment reference count */ - count = PowerCC26XX_module.resourceCounts[resourceId]++; - - /* if resource was NOT activated previously ... */ - if (count == 0) { - /* propagate set up the dependency tree ... */ - - /* check for a first parent */ - parent = resourceDB[resourceId].flags & PowerCC26XX_PARENTMASK; - - /* if first parent, make recursive call to set that dependency */ - if (parent < PowerCC26XX_NUMRESOURCES) { - Power_setDependency(parent); - } - - /* now activate this resource ... */ - id = resourceDB[resourceId].driverlibID; - - /* is resource a peripheral?... */ - if (resourceDB[resourceId].flags & PowerCC26XX_PERIPH) { - PRCMPeripheralRunEnable(id); - PRCMPeripheralSleepEnable(id); - PRCMPeripheralDeepSleepEnable(id); - PRCMLoadSet(); - while (!PRCMLoadGet()) { - ; - } - } - /* else, does resource require a special handler?... */ - else if (resourceDB[resourceId].flags & PowerCC26XX_SPECIAL) { - /* call the special handler */ - PowerCC26XX_module.resourceHandlers[id](PowerCC26XX_ENABLE); - } - /* else resource is a power domain */ - else { - PRCMPowerDomainOn(id); - while (PRCMPowerDomainStatus(id) != PRCM_DOMAIN_POWER_ON) { - ; - } - } - } - - /* re-enable interrupts */ - HwiP_restore(key); - - return (Power_SOK); -} - -/* - * ======== Power_setPolicy ======== - * Set the Power policy function - */ -void Power_setPolicy(Power_PolicyFxn policy) -{ - PowerCC26XX_module.policyFxn = policy; -} - -/* - * ======== Power_shutdown ======== - */ -int_fast16_t Power_shutdown(uint_fast16_t shutdownState, - uint_fast32_t shutdownTime) -{ - int_fast16_t status = Power_EFAIL; - unsigned int constraints; - unsigned int hwiKey; - - /* disable interrupts */ - hwiKey = HwiP_disable(); - - /* check if there is a constraint to prohibit shutdown */ - constraints = Power_getConstraintMask(); - if (constraints & (1 << PowerCC26XX_DISALLOW_SHUTDOWN)) { - status = Power_ECHANGE_NOT_ALLOWED; - } - - /* OK to shutdown ... */ - else if (PowerCC26XX_module.state == Power_ACTIVE) { - /* set new transition state to entering shutdown */ - PowerCC26XX_module.state = Power_ENTERING_SHUTDOWN; - - /* signal all clients registered for pre-shutdown notification */ - status = notify(PowerCC26XX_ENTERING_SHUTDOWN); - - /* check for any error */ - if (status != Power_SOK) { - PowerCC26XX_module.state = Power_ACTIVE; - HwiP_restore(hwiKey); - return (status); - } - - /* now proceed with shutdown sequence ... */ - - /* If the JTAG_PD is on, make sure that the DUT reboots without - * stopping for halt-in-boot when it enters shutdown. */ -#if defined(DeviceFamily_CC26X0R2) - uint32_t aonSysctrlResetctl; - - if((HWREG(AON_WUC_BASE + AON_WUC_O_PWRSTAT) & AON_WUC_PWRSTAT_JTAG_PD_ON) && - (!PowerCC26XX_module.emulatorAttached)) { - /* set BOOT_DET = b10. - * The next time the device enters shutdown the - * device will start booting immediately because the JTAG_PD is already on. - * However since since BOOT_DET == b10, the boot code will run not wait - * for a GPIO interrupt, but rather run to completion and branch to the - * flash image with the JTAG_PD turned off. - */ - aonSysctrlResetctl = HWREG( AON_SYSCTL_BASE + AON_SYSCTL_O_RESETCTL ) & - ~( AON_SYSCTL_RESETCTL_BOOT_DET_1_CLR_M | AON_SYSCTL_RESETCTL_BOOT_DET_0_CLR_M | - AON_SYSCTL_RESETCTL_BOOT_DET_1_SET_M | AON_SYSCTL_RESETCTL_BOOT_DET_0_SET_M ); - /* To get BOOT_DET = b10, set BOOT_DET_1_SET and BOOT_DET_0_CLR*/ - HWREG(AON_SYSCTL_BASE + AON_SYSCTL_O_RESETCTL) = aonSysctrlResetctl | - (AON_SYSCTL_RESETCTL_BOOT_DET_0_CLR | AON_SYSCTL_RESETCTL_BOOT_DET_1_SET); - } -#endif - - /* 1. Switch HF, MF, and LF clocks to source from RCOSC_HF */ - if (OSCClockSourceGet(OSC_SRC_CLK_HF) != OSC_RCOSC_HF) { - /* 1.1. Source HF and MF from RCOSC_HF */ - OSCClockSourceSet(OSC_SRC_CLK_HF | OSC_SRC_CLK_MF, OSC_RCOSC_HF); - while (!OSCHfSourceReady()); - OSCHfSourceSwitch(); - } - /* 1.2. Source LF from RCOSC_LF */ - OSCClockSourceSet(OSC_SRC_CLK_LF, OSC_RCOSC_LF); - while (OSCClockSourceGet(OSC_SRC_CLK_LF) != OSC_RCOSC_LF); - - /* 2. Make sure DMA and CRYTO clocks are off in deep-sleep */ - PRCMPeripheralDeepSleepDisable(PRCM_PERIPH_CRYPTO); - PRCMPeripheralDeepSleepDisable(PRCM_PERIPH_UDMA); - PRCMLoadSet(); - while (!PRCMLoadGet()) { - ; - } - - /* 3. Power OFF AUX and disconnect from bus */ - AUXWUCPowerCtrl(AUX_WUC_POWER_OFF); - - /* 4. Remove AUX force ON */ - HWREG(AON_WUC_BASE + AON_WUC_O_AUXCTL) &= - ~AON_WUC_AUXCTL_AUX_FORCE_ON; - - /* - * 5. Reset AON event source IDs to avoid pending events powering - * on MCU/AUX - */ - HWREG(AON_EVENT_BASE + AON_EVENT_O_MCUWUSEL) = 0x3F3F3F3F; - HWREG(AON_EVENT_BASE + AON_EVENT_O_AUXWUSEL) = 0x003F3F3F; - - /* sync AON */ - SysCtrlAonSync(); - - /* - * 6. Enable shutdown - this latches the IOs, so configuration of - * IOCFGx registers must be done prior to this - */ - AONWUCShutDownEnable(); - - /* 7. Sync AON */ - SysCtrlAonSync(); - - /* 8. Wait until AUX powered off */ - while (AONWUCPowerStatusGet() & AONWUC_AUX_POWER_ON); - - /* 9. Request to power off MCU when go to deep sleep */ - PRCMMcuPowerOff(); - - /* - * 10. Turn off power domains inside MCU VD (BUS, FL_BUS, RFC, - * CPU) - */ - PRCMPowerDomainOff(PRCM_DOMAIN_RFCORE | PRCM_DOMAIN_SERIAL | - PRCM_DOMAIN_PERIPH | PRCM_DOMAIN_CPU | PRCM_DOMAIN_VIMS); - - /* 11. Deep sleep to activate shutdown */ - PRCMDeepSleep(); - } - else { - status = Power_EBUSY; - } - - /* NOTE: if shutdown succeeded, should never get here */ - - /* return failure status */ - PowerCC26XX_module.state = Power_ACTIVE; - - /* re-enable interrupts */ - HwiP_restore(hwiKey); - - /* if get here, failed to shutdown, return error code */ - return (status); -} - -/* - * ======== Power_sleep ======== - */ -int_fast16_t Power_sleep(uint_fast16_t sleepState) -{ - int_fast16_t status = Power_SOK; - int_fast16_t notifyStatus = Power_SOK; - int_fast16_t lateNotifyStatus = Power_SOK; - unsigned int xosc_hf_active = false; - uint_fast16_t postEventLate; - uint32_t poweredDomains = 0; - uint_fast16_t preEvent; - uint_fast16_t postEvent; - unsigned int constraints; - bool retainCache = false; - uint32_t modeVIMS; - unsigned int swiKey; - -#if defined(DeviceFamily_CC26X0R2) - /* has JTAG_PD been turned AFTER boot due to TCK noise? */ - if((HWREG(AON_WUC_BASE + AON_WUC_O_PWRSTAT) & AON_WUC_PWRSTAT_JTAG_PD_ON) && (!PowerCC26XX_module.emulatorAttached)) - { - /* notify all subscribers */ - notify(PowerCC26XX_JTAG_PD_TURNED_ON); - } -#endif - - /* first validate the sleep code */ - if (sleepState != PowerCC26XX_STANDBY) { - status = Power_EINVALIDINPUT; - } - - else { - - /* check to make sure Power is not busy with another transition */ - if (PowerCC26XX_module.state == Power_ACTIVE) { - /* set transition state to entering sleep */ - PowerCC26XX_module.state = Power_ENTERING_SLEEP; - } - else { - status = Power_EBUSY; - } - - if (status == Power_SOK) { - - /* setup sleep vars */ - preEvent = PowerCC26XX_ENTERING_STANDBY; - postEvent = PowerCC26XX_AWAKE_STANDBY; - postEventLate = PowerCC26XX_AWAKE_STANDBY_LATE; - - /* disable Task scheduling; allow Swis and Hwis for notifications */ - PowerCC26XX_schedulerDisable(); - - /* signal all clients registered for pre-sleep notification */ - status = notify(preEvent); - - /* check for any error */ - if (status != Power_SOK) { - PowerCC26XX_module.state = Power_ACTIVE; - PowerCC26XX_schedulerRestore(); - return (status); - } - - /* now disable Swi scheduling */ - swiKey = SwiP_disable(); - - /* 1. Freeze the IOs on the boundary between MCU and AON */ - AONIOCFreezeEnable(); - - /* 2. If XOSC_HF is active, force it off */ - if(OSCClockSourceGet(OSC_SRC_CLK_HF) == OSC_XOSC_HF) { - xosc_hf_active = true; - configureXOSCHF(PowerCC26XX_DISABLE); - } - - /* 3. Allow AUX to power down */ - AONWUCAuxWakeupEvent(AONWUC_AUX_ALLOW_SLEEP); - - /* 4. Make sure writes take effect */ - SysCtrlAonSync(); - - /* now proceed to transition to Power_STANDBY ... */ - - /* 5. Query and save domain states before powering them off */ - if (Power_getDependencyCount(PowerCC26XX_DOMAIN_RFCORE)) { - poweredDomains |= PRCM_DOMAIN_RFCORE; - } - if (Power_getDependencyCount(PowerCC26XX_DOMAIN_SERIAL)){ - poweredDomains |= PRCM_DOMAIN_SERIAL; - } - if (Power_getDependencyCount(PowerCC26XX_DOMAIN_PERIPH)) { - poweredDomains |= PRCM_DOMAIN_PERIPH; - } - - /* 6. Gate running deep sleep clocks for Crypto and DMA */ - if (Power_getDependencyCount(PowerCC26XX_PERIPH_CRYPTO)) { - PRCMPeripheralDeepSleepDisable( - resourceDB[PowerCC26XX_PERIPH_CRYPTO].driverlibID); - } - if (Power_getDependencyCount(PowerCC26XX_PERIPH_UDMA)) { - PRCMPeripheralDeepSleepDisable( - resourceDB[PowerCC26XX_PERIPH_UDMA].driverlibID); - } - /* 7. Make sure clock settings take effect */ - PRCMLoadSet(); - - /* 8. Request power off of domains in the MCU voltage domain */ - PRCMPowerDomainOff(poweredDomains | PRCM_DOMAIN_CPU); - - /* 9. Request uLDO during standby */ - PRCMMcuUldoConfigure(true); - - /* query constraints to determine if cache should be retained */ - constraints = Power_getConstraintMask(); - if (constraints & (1 << PowerCC26XX_RETAIN_VIMS_CACHE_IN_STANDBY)) { - retainCache = true; - } - - /* 10. If don't want VIMS retention in standby, disable it now... */ - if (retainCache == false) { - - /* 10.1 Get the current VIMS mode */ - do { - modeVIMS = VIMSModeGet(VIMS_BASE); - } while (modeVIMS == VIMS_MODE_CHANGING); - - /* 10.2 If in a cache mode, turn VIMS off */ - if (modeVIMS == VIMS_MODE_ENABLED) { - - /* 10.3 Now turn off the VIMS */ - VIMSModeSet(VIMS_BASE, VIMS_MODE_OFF); - } - - /* 10.4 Now disable retention */ - PRCMCacheRetentionDisable(); - } - - /* 11. Setup recharge parameters */ - SysCtrlSetRechargeBeforePowerDown(XOSC_IN_HIGH_POWER_MODE); - - /* 12. Make sure all writes have taken effect */ - SysCtrlAonSync(); - - /* 13. Invoke deep sleep to go to STANDBY */ - PRCMDeepSleep(); - - /* 14. If didn't retain VIMS in standby, re-enable retention now */ - if (retainCache == false) { - - /* 14.1 If previously in a cache mode, restore the mode now */ - if (modeVIMS == VIMS_MODE_ENABLED) { - VIMSModeSet(VIMS_BASE, modeVIMS); - } - - /* 14.2 Re-enable retention */ - PRCMCacheRetentionEnable(); - } - - /* 15. Start forcing on power to AUX */ - AONWUCAuxWakeupEvent(AONWUC_AUX_WAKEUP); - - /* 16. Start re-powering power domains */ - PRCMPowerDomainOn(poweredDomains); - - /* 17. Restore deep sleep clocks of Crypto and DMA */ - if (Power_getDependencyCount(PowerCC26XX_PERIPH_CRYPTO)) { - PRCMPeripheralDeepSleepEnable( - resourceDB[PowerCC26XX_PERIPH_CRYPTO].driverlibID); - } - if (Power_getDependencyCount(PowerCC26XX_PERIPH_UDMA)) { - PRCMPeripheralDeepSleepEnable( - resourceDB[PowerCC26XX_PERIPH_UDMA].driverlibID); - } - - /* 18. Make sure clock settings take effect */ - PRCMLoadSet(); - - /* 19. Release request for uLDO */ - PRCMMcuUldoConfigure(false); - - /* 20. Set transition state to EXITING_SLEEP */ - PowerCC26XX_module.state = Power_EXITING_SLEEP; - - /* 21. Wait until all power domains are back on */ - while (PRCMPowerDomainStatus(poweredDomains) != - PRCM_DOMAIN_POWER_ON) { - ; - } - - /* 22. Wait for the RTC shadow values to be updated so that - * the early notification callbacks can read out valid RTC values - */ - SysCtrlAonSync(); - - /* - * 23. Signal clients registered for early post-sleep notification; - * this should be used to initialize any timing critical or IO - * dependent hardware - */ - notifyStatus = notify(postEvent); - - /* 24. Disable IO freeze and ensure RTC shadow value is updated */ - AONIOCFreezeDisable(); - SysCtrlAonSync(); - - /* 25. Wait for AUX to power up */ - while(!(AONWUCPowerStatusGet() & AONWUC_AUX_POWER_ON)) {}; - - /* 26. If XOSC_HF was forced off above, initiate switch back */ - if (xosc_hf_active == true) { - configureXOSCHF(PowerCC26XX_ENABLE); - } - - /* 27. Re-enable interrupts */ - CPUcpsie(); - - /* - * 28. Signal all clients registered for late post-sleep - * notification - */ - lateNotifyStatus = notify(postEventLate); - - /* - * 29. Now clear the transition state before re-enabling - * scheduler - */ - PowerCC26XX_module.state = Power_ACTIVE; - - /* 30. Re-enable Swi scheduling */ - SwiP_restore(swiKey); - - /* 31. Adjust recharge parameters */ - SysCtrlAdjustRechargeAfterPowerDown(PowerCC26XX_config.vddrRechargeMargin); - - /* re-enable Task scheduling */ - PowerCC26XX_schedulerRestore(); - - /* if there was a notification error, set return status */ - if ((notifyStatus != Power_SOK) || - (lateNotifyStatus != Power_SOK)) { - status = Power_EFAIL; - } - } - } - - return (status); -} - -/* - * ======== Power_unregisterNotify ======== - * Unregister for a power notification. - * - */ -void Power_unregisterNotify(Power_NotifyObj * pNotifyObj) -{ - unsigned int key; - - /* remove notify object from its event queue */ - key = HwiP_disable(); - - /* remove notify object from its event queue */ - List_remove(&PowerCC26XX_module.notifyList, (List_Elem *)pNotifyObj); - - HwiP_restore(key); -} - -/* ****************** CC26XX specific APIs ******************** */ - -/* - * ======== PowerCC26XX_calibrate ======== - * Plug this function into the PowerCC26XX_Config structure - * if calibration is needed. - */ -bool PowerCC26XX_calibrate(unsigned int arg) -{ - bool retVal = false; - ClockP_Params clockParams; - - switch (arg) { - case PowerCC26XX_SETUP_CALIBRATE: - /* - * If RCOSC calibration is enabled, construct a Clock object for - * delays. Set timeout to '1' Clock tick period for the minimal - * delay. The object will explicitly started by Power module when - * appropriate - */ - ClockP_Params_init(&clockParams); - clockParams.period = 0; - clockParams.startFlag = false; - clockParams.arg = 0; - ClockP_construct(&PowerCC26XX_module.calClockStruct, - &PowerCC26XX_RCOSC_clockFunc, 1, &clockParams); - - /* construct the Hwi */ - HwiP_construct(&PowerCC26XX_module.hwiStruct, - 44, PowerCC26XX_auxISR, NULL); - - break; - - case PowerCC26XX_INITIATE_CALIBRATE: - retVal = PowerCC26XX_initiateCalibration(); - break; - - case PowerCC26XX_DO_CALIBRATE: - PowerCC26XX_doCalibrate(); - break; - } - - return (retVal); -} - -/* - * ======== PowerCC26XX_doWFI ======== - */ -void PowerCC26XX_doWFI(void) -{ - __asm(" wfi"); -} - -/* - * ======== PowerCC26XX_getClockHandle ======== - */ -ClockP_Handle PowerCC26XX_getClockHandle() -{ - return ((ClockP_Handle)&PowerCC26XX_module.clockObj); -} - -/* - * ======== PowerCC26XX_noCalibrate ======== - * Plug this function into the PowerCC26XX config structure if calibration - * is not needed. - */ -bool PowerCC26XX_noCalibrate(unsigned int arg) -{ - return (0); -} - -/* - * ======== PowerCC26XX_getXoscStartupTime ======== - * Get the estimated crystal oscillator startup time - */ -uint32_t PowerCC26XX_getXoscStartupTime(uint32_t timeUntilWakeupInMs) -{ - return (OSCHF_GetStartupTime(timeUntilWakeupInMs)); -} - -/* - * ======== PowerCC26XX_injectCalibration ======== - * Explicitly trigger RCOSC calibration - */ -bool PowerCC26XX_injectCalibration(void) -{ - if ((*(PowerCC26XX_config.calibrateFxn))(PowerCC26XX_INITIATE_CALIBRATE)) { - /* here if AUX SMPH was available, start calibration now ... */ - (*(PowerCC26XX_config.calibrateFxn))(PowerCC26XX_DO_CALIBRATE); - return (true); - } - - return (false); -} - -/* - * ======== PowerCC26XX_isStableXOSC_HF ======== - * Check if XOSC_HF has stabilized. - */ -bool PowerCC26XX_isStableXOSC_HF(void) -{ - bool ready = true; - unsigned int key; - - key = HwiP_disable(); - - /* only query if HF source is ready if there is a pending change */ - if (PowerCC26XX_module.xoscPending) { - ready = OSCHfSourceReady(); - } - - HwiP_restore(key); - - return (ready); -} - -/* - * ======== PowerCC26XX_switchXOSC_HF ======== - * Switch to enable XOSC_HF. - * May only be called when using the PowerCC26XX_SWITCH_XOSC_HF_MANUALLY - * constraint. - * May only be called after ensuring the XOSC_HF is stable by calling - * PowerCC26XX_isStableXOSC_HF(). - */ -void PowerCC26XX_switchXOSC_HF(void) -{ - /* This function is just a veneer to call the static callback function for - * the XOSC_HF clock. This way, if the switching does fail because a constraint - * stopped it from switching, a clock will be scheduled into the future to try - * again. This could happen if there is an ongoing operation from another bus - * master that reads from flash such as SPI or AES DMA operations. - */ - switchXOSCHFclockFunc((uintptr_t) NULL); -} - -/* * * * * * * * * * * internal and support functions * * * * * * * * * * */ - -/* - * ======== emptyClockFunc ======== - * Clock function used by power policy to schedule early wakeups. - */ -static void emptyClockFunc(uintptr_t arg) -{ -} - -/* - * ======== disableLfClkQualifiersEnableClkLoss ======== - * Function used to disable LF clock qualifiers and enable clock loss - */ -static void disableLfClkQualifiersEnableClkLoss() -{ - /* Disable the LF clock qualifiers */ - DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL0, - DDI_0_OSC_CTL0_BYPASS_XOSC_LF_CLK_QUAL_M | - DDI_0_OSC_CTL0_BYPASS_RCOSC_LF_CLK_QUAL_M, - DDI_0_OSC_CTL0_BYPASS_RCOSC_LF_CLK_QUAL_S, 0x3); - - /* Enable clock loss detection */ - OSCClockLossEventEnable(); -} - -/* - * ======== lfClockReadyCallback ======== - * Clock function callback used to check if the LF clock is ready - */ -static void lfClockReadyCallback(uintptr_t arg) -{ - uint32_t ccfgLfClkSrc; - uint32_t sourceLF; - uint32_t timeout; - - /* query LF clock source */ - sourceLF = OSCClockSourceGet(OSC_SRC_CLK_LF); - - /* is LF source either RCOSC_LF or XOSC_LF yet? */ - if ((sourceLF == OSC_RCOSC_LF) || (sourceLF == OSC_XOSC_LF)) { - - /* Disable clock qualifiers and enable clock loss */ - disableLfClkQualifiersEnableClkLoss(); - - /* now finish by releasing the standby disallow constraint */ - Power_releaseConstraint(PowerCC26XX_DISALLOW_STANDBY); - } - /* is LF source XOSC_HF yet? */ - else if(sourceLF == OSC_XOSC_HF) - { - /* Disable clock qualifiers and enable clock loss */ - disableLfClkQualifiersEnableClkLoss(); - - /* Keep PowerCC26XX_DISALLOW_STANDBY set, not allowed to enter standby - * when LF clock is sourced from from XOSC_HF - */ - } - - /* not yet, LF still derived from RCOSC_HF, restart clock to check back later */ - else { - - /* read the LF clock source from CCFG */ - ccfgLfClkSrc = CCFGRead_SCLK_LF_OPTION(); - - /* determine retry timeout */ - if (ccfgLfClkSrc == CCFGREAD_SCLK_LF_OPTION_RCOSC_LF) { - timeout = PowerCC26XX_RETRYWAITRCOSC_LF; - } - else if(ccfgLfClkSrc == CCFGREAD_SCLK_LF_OPTION_XOSC_LF){ - timeout = PowerCC26XX_RETRYWAITXOSC_LF; - } - else { - /* ccfgLfClkSrc == CCFGREAD_SCLK_LF_OPTION_XOSC_HF_DLF */ - timeout = PowerCC26XX_RETRYWAITXOSC_HF; - } - /* retrigger LF Clock to fire again */ - ClockP_setTimeout(ClockP_handle(&PowerCC26XX_module.lfClockObj), - (timeout / ClockP_tickPeriod)); - ClockP_start(ClockP_handle(&PowerCC26XX_module.lfClockObj)); - } -} - -/* - * ======== nopResourceFunc ======== - * special resource handler - */ -static unsigned int nopResourceHandler(unsigned int action) -{ - return (0); -} - -/* - * ======== notify ======== - * Send notifications to registered clients. - * Note: Task scheduling is disabled when this function is called. - */ -static int_fast16_t notify(uint_fast16_t eventType) -{ - int_fast16_t notifyStatus; - Power_NotifyFxn notifyFxn; - uintptr_t clientArg; - List_Elem *elem; - - /* if queue is empty, return immediately */ - if (!List_empty(&PowerCC26XX_module.notifyList)) { - /* point to first client notify object */ - elem = List_head(&PowerCC26XX_module.notifyList); - - /* walk the queue and notify each registered client of the event */ - do { - if (((Power_NotifyObj *)elem)->eventTypes & eventType) { - /* pull params from notify object */ - notifyFxn = ((Power_NotifyObj *)elem)->notifyFxn; - clientArg = ((Power_NotifyObj *)elem)->clientArg; - - /* call the client's notification function */ - notifyStatus = (int_fast16_t)(*(Power_NotifyFxn)notifyFxn)( - eventType, 0, clientArg); - - /* if client declared error stop all further notifications */ - if (notifyStatus != Power_NOTIFYDONE) { - return (Power_EFAIL); - } - } - - /* get next element in the notification queue */ - elem = List_next(elem); - - } while (elem != NULL); - } - - return (Power_SOK); -} - -/* - * ======== configureRFCoreClocks ======== - * Special dependency function for controlling RF core clocks. - */ -static unsigned int configureRFCoreClocks(unsigned int action) -{ - if (action == PowerCC26XX_ENABLE) { - RFCClockEnable(); - } - else { - RFCClockDisable(); - } - - return (0); -} - -/* - * ======== switchXOSCHFclockFunc ======== - * Clock function used for delayed switching to XOSC_HF. - */ -static void switchXOSCHFclockFunc(uintptr_t arg0) -{ - bool readyToCal; - uint32_t timeout; - unsigned int key; - - key = HwiP_disable(); - - /* if pending switch has already been made, just send out notifications */ - if (PowerCC26XX_module.xoscPending == false) { - - /* initiate RCOSC calibration */ - readyToCal = (*(PowerCC26XX_config.calibrateFxn))(PowerCC26XX_INITIATE_CALIBRATE); - - /* notify clients that were waiting for a switch notification */ - notify(PowerCC26XX_XOSC_HF_SWITCHED); - - /* if ready to start first cal measurment, do it now */ - if (readyToCal == true) { - (*(PowerCC26XX_config.calibrateFxn))(PowerCC26XX_DO_CALIBRATE); - } - } - - /* else, if HF ready to switch and we are allowed to, do it now ... */ - else if (!(Power_getConstraintMask() & (1 << PowerCC26XX_DISALLOW_XOSC_HF_SWITCHING)) && OSCHfSourceReady()) { - OSCHF_AttemptToSwitchToXosc(); - - PowerCC26XX_module.xoscPending = false; - - /* initiate RCOSC calibration */ - readyToCal = (*(PowerCC26XX_config.calibrateFxn))(PowerCC26XX_INITIATE_CALIBRATE); - - /* now notify clients that were waiting for a switch notification */ - notify(PowerCC26XX_XOSC_HF_SWITCHED); - - /* if ready to start first cal measurment, do it now */ - if (readyToCal == true) { - (*(PowerCC26XX_config.calibrateFxn))(PowerCC26XX_DO_CALIBRATE); - } - } - - /* else, wait some more, then see if can switch ... */ - else { - /* calculate wait timeout in units of ticks */ - timeout = PowerCC26XX_RETRYWAITXOSC_HF / ClockP_tickPeriod; - if (timeout == 0) { - timeout = 1; /* wait at least 1 tick */ - } - - /* re-start Clock object with retry timeout */ - ClockP_setTimeout( - ClockP_handle(&PowerCC26XX_module.xoscClockObj), timeout); - ClockP_start(ClockP_handle(&PowerCC26XX_module.xoscClockObj)); - } - - HwiP_restore(key); -} - -/* - * ======== configureXOSCHF ======== - */ -static unsigned int configureXOSCHF(unsigned int action) -{ - uint32_t timeout; - - if (action == PowerCC26XX_ENABLE && OSCClockSourceGet(OSC_SRC_CLK_HF) != OSC_XOSC_HF) { - OSCHF_TurnOnXosc(); - - PowerCC26XX_module.xoscPending = true; - - /* Unless it is disallowed, estimate the required stabilisation - * time and start a clock. - * When the clock times out, the callback will try and switch to - * the XOSC_HF. If the XOSC_HF is not ready yet, the callback - * will start a new clock to try again. - */ - if (!(Power_getConstraintMask() & (1 << PowerCC26XX_SWITCH_XOSC_HF_MANUALLY))) { - /* calculate wait timeout in units of ticks */ - timeout = PowerCC26XX_INITIALWAITXOSC_HF / ClockP_tickPeriod; - if (timeout == 0) { - timeout = 1; /* wait at least 1 tick */ - } - - /* start Clock object with initial timeout */ - ClockP_stop(ClockP_handle(&PowerCC26XX_module.xoscClockObj)); - ClockP_setTimeout(ClockP_handle(&PowerCC26XX_module.xoscClockObj), - timeout); - ClockP_start(ClockP_handle(&PowerCC26XX_module.xoscClockObj)); - } - } - - /* when release XOSC_HF, auto switch to RCOSC_HF */ - else { - OSCHF_SwitchToRcOscTurnOffXosc(); - } - return (0); -} diff --git a/simplelink/source/ti/drivers/power/PowerCC26XX.h b/simplelink/source/ti/drivers/power/PowerCC26XX.h index da601fc..b51198f 100644 --- a/simplelink/source/ti/drivers/power/PowerCC26XX.h +++ b/simplelink/source/ti/drivers/power/PowerCC26XX.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, Texas Instruments Incorporated + * Copyright (c) 2015-2019, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,14 +52,14 @@ #ifndef ti_drivers_power_PowerCC26XX_ #define ti_drivers_power_PowerCC26XX_ -#ifdef __cplusplus -extern "C" { -#endif - #include #include #include +#ifdef __cplusplus +extern "C" { +#endif + /* \cond */ typedef uint8_t PowerCC26XX_Resource; /* Resource identifier */ /* \endcond */ @@ -319,14 +319,14 @@ typedef uint8_t PowerCC26XX_Resource; /* Resource identifier */ /* \cond */ /*! @brief Power resource database record format */ -typedef struct PowerCC26XX_ResourceRecord { +typedef struct { uint8_t flags; /* resource type | first parent */ uint16_t driverlibID; /* corresponding driverlib ID for this resource */ } PowerCC26XX_ResourceRecord; /* \endcond */ /*! @brief Global configuration structure */ -typedef struct PowerCC26XX_Config { +typedef struct { /*! * @brief The Power Policy's initialization function * @@ -464,7 +464,7 @@ typedef struct PowerCC26XX_Config { * Power manager state structure. The application must not access any members * of this structure! */ -typedef struct PowerCC26XX_ModuleState { +typedef struct { List_List notifyList; /*!< Event notification list */ uint32_t constraintMask; /*!< Aggregate constraints mask */ ClockP_Struct clockObj; /*!< Clock object for scheduling wakeups */ diff --git a/simplelink/source/ti/drivers/power/PowerCC26XX_calibrateRCOSC.c b/simplelink/source/ti/drivers/power/PowerCC26XX_calibrateRCOSC.c deleted file mode 100644 index 3ec874e..0000000 --- a/simplelink/source/ti/drivers/power/PowerCC26XX_calibrateRCOSC.c +++ /dev/null @@ -1,820 +0,0 @@ -/* - * Copyright (c) 2015-2018, Texas Instruments Incorporated - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * 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. - * - * * Neither the name of Texas Instruments Incorporated 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 OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQueueNTIAL 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. - */ -/* - * ======== PowerCC26XX_calibrateRCOSC.c ======== - */ - -#include - -#include -#include - -#include -#include - -#include -#include DeviceFamily_constructPath(inc/hw_aux_evctl.h) -#include DeviceFamily_constructPath(inc/hw_aux_smph.h) -#include DeviceFamily_constructPath(inc/hw_aux_wuc.h) -#include DeviceFamily_constructPath(inc/hw_aux_tdc.h) -#include DeviceFamily_constructPath(inc/hw_ddi_0_osc.h) -#include DeviceFamily_constructPath(inc/hw_ddi.h) -#include DeviceFamily_constructPath(inc/hw_ccfg.h) -#include DeviceFamily_constructPath(driverlib/aon_batmon.h) -#include DeviceFamily_constructPath(driverlib/ddi.h) -#include DeviceFamily_constructPath(driverlib/ioc.h) -#include DeviceFamily_constructPath(driverlib/osc.h) -#include DeviceFamily_constructPath(driverlib/gpio.h) -#include DeviceFamily_constructPath(driverlib/sys_ctrl.h) -#include DeviceFamily_constructPath(driverlib/aux_wuc.h) - -#define AUX_TDC_SEMAPHORE_NUMBER 1 /* semaphore 1 protects TDC */ -#define NUM_RCOSC_LF_PERIODS_TO_MEASURE 32 /* x RCOSC_LF periods vs XOSC_HF */ -#define NUM_RCOSC_HF_PERIODS_TO_MEASURE 1 /* x RCOSC_HF periods vs XOSC_HF */ -#define ACLK_REF_SRC_RCOSC_HF 0 /* Use RCOSC_HF for ACLK REF */ -#define ACLK_REF_SRC_RCOSC_LF 2 /* Use RCOSC_LF for ACLK REF */ -#define SCLK_LF_OPTION_RCOSC_LF 3 /* defined in cc26_ccfg.xls */ -#define RCOSC_HF_LOW_THRESHOLD_TDC_VALUE 1535 /* If TDC value is within threshold range, no need for another TDC measurement */ -#define RCOSC_HF_PERFECT_TDC_VALUE 1536 /* RCOSC_HF runs at perfect 48 MHz when ending up with this TDC value */ -#define RCOSC_HF_HIGH_THRESHOLD_TDC_VALUE 1537 /* If TDC value is within threshold range, no need for another TDC measurement */ - -#define DDI_0_OSC_O_CTL1_LOCAL 0x00000004 /* offset */ -#define DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_LOCAL_M 0x007C0000 /* mask */ -#define DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_LOCAL_S 18 /* shift */ -#define DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_EN_LOCAL_M 0x00020000 /* mask */ -#define DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_EN_LOCAL_S 17 /* shift */ -#define DDI_0_OSC_ATESTCTL_SET_RCOSC_HF_FINE_RESISTOR_LOCAL_M 0x00000C00 /* offset */ -#define DDI_0_OSC_ATESTCTL_SET_RCOSC_HF_FINE_RESISTOR_LOCAL_S 10 /* shift */ - -/* AUX ISR states */ -#define WAIT_SMPH 0 /* just took SMPH, start RCOSC_LF */ -#define CAL_RCOSC_LF 1 /* just finished RCOSC_LF, start first RCOSC_HF */ -#define CAL_RCOSC_HF1 2 /* just finished 1st RCOSC_HF, start 2nd */ -#define CAL_RCOSC_HF2 3 /* just finished 2nd RCOSC_HF, decide best */ - -/* calibration steps */ -#define STEP_TDC_INIT_1 1 -#define STEP_TDC_INIT_2 2 -#define STEP_CAL_LF_1 3 -#define STEP_CAL_LF_2 4 -#define STEP_CAL_LF_3 5 -#define STEP_CAL_HF1_1 6 -#define STEP_CAL_HF1_2 7 -#define STEP_CAL_HF1_3 8 -#define STEP_CAL_HF2_1 9 -#define STEP_CAL_HF2_2 10 -#define STEP_CLEANUP_1 11 -#define STEP_CLEANUP_2 12 - -/* macros */ -#define Min(a,b) (((a)<(b))?(a):(b)) -#define Max(a,b) (((a)>(b))?(a):(b)) -#define Abs(x) ((x) < 0 ? -(x) : (x)) -#define Scale_rndInf(x) ((3 * (x) + (((x) < 0) ? -2 : 2)) / 4) - -#define INSTRUMENT 0 - -#if INSTRUMENT -volatile unsigned int gotSEM = 0; -volatile unsigned int calLFi = 0; -volatile unsigned int calHF1i = 0; -volatile unsigned int calHF2i = 0; -volatile bool doneCal = false; -unsigned int tdcResult_LF = 0; -unsigned int tdcResult_HF1 = 0; -unsigned int tdcResult_HF2 = 0; -unsigned int numISRs = 0; -unsigned int calClocks = 0; -#endif - -/* Forward declarations */ -static bool getTdcSemaphore(); -static void updateSubSecInc(uint32_t tdcResult); -static void calibrateRcoscHf1(int32_t tdcResult); -static void calibrateRcoscHf2(int32_t tdcResult); -void PowerCC26XX_doCalibrate(void); - -/* Externs */ -extern PowerCC26XX_ModuleState PowerCC26XX_module; -extern const PowerCC26XX_Config PowerCC26XX_config; - -/* - * ======== PowerCC26XX_initiateCalibration ======== - * Initiate calibration of RCOSC_LF and RCOSCHF - */ -bool PowerCC26XX_initiateCalibration() -{ - unsigned int hwiKey; - bool busy = false; - bool status; - bool gotSem; - - if ((PowerCC26XX_module.calLF == false) && - (PowerCC26XX_config.calibrateRCOSC_HF == false)) { - return (false); - } - - /* make sure calibration is not already in progress */ - hwiKey = HwiP_disable(); - - if (PowerCC26XX_module.busyCal == false) { - PowerCC26XX_module.busyCal = true; - } - else { - busy = true; - } - - HwiP_restore(hwiKey); - - if (busy == true) { - return (false); - } - -#if INSTRUMENT - gotSEM = 0; - calLFi = 0; - calHF1i = 0; - calHF2i = 0; - doneCal = false; -#endif - - /* set contraint to prohibit standby during calibration sequence */ - Power_setConstraint(PowerCC26XX_DISALLOW_STANDBY); - - /* set dependency to keep XOSC_HF active during calibration sequence */ - Power_setDependency(PowerCC26XX_XOSC_HF); - - /* initiate acquisition of semaphore protecting TDC */ - gotSem = getTdcSemaphore(); - - /* if didn't acquire semaphore, must wait for autotake ISR */ - if (gotSem == false) { - PowerCC26XX_module.hwiState = WAIT_SMPH; - status = false; /* false: don't do anything else until acquire SMPH */ - } - - /* else, semaphore acquired, OK to proceed with first measurement */ - else { -#if INSTRUMENT - gotSEM = 1; -#endif - status = true; /* true: OK to start first measurement */ - } - - return (status); -} - -/* - * ======== PowerCC26XX_auxISR ======== - * ISR for the AUX combo interrupt event. Implements Hwi state machine to - * step through the RCOSC calibration steps. - */ -void PowerCC26XX_auxISR(uintptr_t arg) -{ - uint32_t tdcResult; - -#if INSTRUMENT - numISRs++; -#endif - - /* - * disable all events that are part of AUX_COMBINED_INTERRUPT. - * This interrupt is reserved for use during RCOSC calibration. - * Other AUX perihperals that want to generate interrupts to CM3 - * must use dedicated interrupt lines or go through AON combined. - */ - HWREG(AUX_EVCTL_BASE + AUX_EVCTL_O_COMBEVTOMCUMASK) = 0; - - /* ****** state = WAIT_SMPH: arrive here if just took the SMPH ****** */ - if (PowerCC26XX_module.hwiState == WAIT_SMPH) { -#if INSTRUMENT - gotSEM = 1; -#endif - } - - /* **** state = CAL_RCOSC_LF: here when just finished LF counting **** */ - else if (PowerCC26XX_module.hwiState == CAL_RCOSC_LF) { - - tdcResult = HWREG(AUX_TDC_BASE + AUX_TDC_O_RESULT); - -#if INSTRUMENT - tdcResult_LF = tdcResult; -#endif - /* update the RTC SUBSECINC register based on LF measurement result */ - updateSubSecInc(tdcResult); -#if INSTRUMENT - calLFi = 1; -#endif - /* if doing HF calibration initiate it now */ - if (PowerCC26XX_config.calibrateRCOSC_HF) { - PowerCC26XX_module.calStep = STEP_CAL_LF_3; /* next: trigger LF */ - } - - /* else, start cleanup */ - else { - PowerCC26XX_module.calStep = STEP_CLEANUP_1; /* next: cleanup */ - } - } - - /* ****** state = CAL_RCOSC_HF1: here when just finished 1st RCOSC_HF */ - else if (PowerCC26XX_module.hwiState == CAL_RCOSC_HF1) { - - tdcResult = HWREG(AUX_TDC_BASE + AUX_TDC_O_RESULT); - -#if INSTRUMENT - tdcResult_HF1 = tdcResult; - calHF1i = 1; -#endif - - /* use first HF measurement to setup new trim values */ - calibrateRcoscHf1(tdcResult); - - /* if HF setting perfect, nothing more to do, calibration is done */ - if ((tdcResult >= RCOSC_HF_LOW_THRESHOLD_TDC_VALUE) && - (tdcResult <= RCOSC_HF_HIGH_THRESHOLD_TDC_VALUE)) { - PowerCC26XX_module.calStep = STEP_CLEANUP_1; /* next: cleanup */ - } - - /* else, tweak trims, initiate another HF measurement */ - else { - - PowerCC26XX_module.calStep = STEP_CAL_HF1_3; /* next: HF meas. #2 */ - } - } - - /* ****** state = just finished second RCOSC_HF measurement ****** */ - else if (PowerCC26XX_module.hwiState == CAL_RCOSC_HF2) { - - tdcResult = HWREG(AUX_TDC_BASE + AUX_TDC_O_RESULT); - -#if INSTRUMENT - tdcResult_HF2 = tdcResult; -#endif - /* look for improvement on #2, else revert to previous trim values */ - calibrateRcoscHf2(tdcResult); - - PowerCC26XX_module.calStep = STEP_CLEANUP_1; /* next: cleanup */ - } - - /* do the next calibration step... */ - PowerCC26XX_doCalibrate(); -} - -/* - * ======== PowerCC26XX_doCalibrate ======== - */ -void PowerCC26XX_doCalibrate(void) -{ - switch (PowerCC26XX_module.calStep) { - - case STEP_TDC_INIT_1: - - /* turn on clock to TDC module */ - AUXWUCClockEnable(AUX_WUC_TDCIF_CLOCK); - - /* set saturation config to 2^24 */ - HWREG(AUX_TDC_BASE + AUX_TDC_O_SATCFG) = - AUX_TDC_SATCFG_LIMIT_R24; - - /* set start and stop trigger sources and polarity */ - HWREG(AUX_TDC_BASE + AUX_TDC_O_TRIGSRC) = - (AUX_TDC_TRIGSRC_STOP_SRC_ACLK_REF | - AUX_TDC_TRIGSRC_STOP_POL_HIGH) | - (AUX_TDC_TRIGSRC_START_SRC_ACLK_REF | - AUX_TDC_TRIGSRC_START_POL_HIGH); - - /* set TDC_SRC clock to be XOSC_HF/2 = 24 MHz */ - DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL0, - DDI_0_OSC_CTL0_ACLK_TDC_SRC_SEL_M, - DDI_0_OSC_CTL0_ACLK_TDC_SRC_SEL_S, 2); - - /* read back to ensure no race condition between OSC_DIG and AUX_WUC */ - DDI16BitfieldRead(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL0, - DDI_0_OSC_CTL0_ACLK_TDC_SRC_SEL_M, DDI_0_OSC_CTL0_ACLK_TDC_SRC_SEL_S); - - /* set AUX_WUC:TDCCLKCTL.REQ... */ - HWREG(AUX_WUC_BASE + AUX_WUC_O_TDCCLKCTL) = AUX_WUC_TDCCLKCTL_REQ; - - /* set next state */ - PowerCC26XX_module.calStep = STEP_TDC_INIT_2; - - /* start Clock object to delay while wait for ACK */ - ClockP_start(ClockP_handle(&PowerCC26XX_module.calClockStruct)); - - break; - - case STEP_TDC_INIT_2: - - /* Enable trig count */ - HWREG(AUX_TDC_BASE + AUX_TDC_O_TRIGCNTCFG) = - AUX_TDC_TRIGCNTCFG_EN; - - /* if LF calibration enabled start LF measurement */ - if (PowerCC26XX_module.calLF) { - - /* clear UPD_REQ, new sub-second increment is NOT available */ - HWREG(AUX_WUC_BASE + AUX_WUC_O_RTCSUBSECINCCTL) = 0; - - /* set next Swi state */ - PowerCC26XX_module.calStep = STEP_CAL_LF_1; - } - - /* else, start first HF measurement */ - else { - /* set next Swi state */ - PowerCC26XX_module.calStep = STEP_CAL_HF1_1; - } - - /* abort TDC */ - HWREG(AUX_TDC_BASE + AUX_TDC_O_CTL) = AUX_TDC_CTL_CMD_ABORT; - - /* clear AUX_WUC:REFCLKCTL.REQ... */ - HWREG(AUX_WUC_BASE + AUX_WUC_O_REFCLKCTL) = 0; - - /* if not ready, start Clock object to delay while wait for ACK */ - if (HWREG(AUX_WUC_BASE + AUX_WUC_O_REFCLKCTL) & - AUX_WUC_REFCLKCTL_ACK) { - - /* start Clock object to delay while wait for ACK */ - ClockP_start(ClockP_handle(&PowerCC26XX_module.calClockStruct)); - - break; - } - - /* else, if ready now, fall thru to next step ... */ - - - case STEP_CAL_LF_1: - case STEP_CAL_HF1_1: - case STEP_CAL_HF2_1: - - if (PowerCC26XX_module.calStep == STEP_CAL_LF_1) { - - /* set the ACLK reference clock */ - DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL0, - DDI_0_OSC_CTL0_ACLK_REF_SRC_SEL_M, - DDI_0_OSC_CTL0_ACLK_REF_SRC_SEL_S, - ACLK_REF_SRC_RCOSC_LF); - - /* set next Swi state */ - PowerCC26XX_module.calStep = STEP_CAL_LF_2; - } - else { - - /* set the ACLK reference clock */ - DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL0, - DDI_0_OSC_CTL0_ACLK_REF_SRC_SEL_M, - DDI_0_OSC_CTL0_ACLK_REF_SRC_SEL_S, - ACLK_REF_SRC_RCOSC_HF); - - /* set next Swi state */ - if (PowerCC26XX_module.calStep == STEP_CAL_HF1_1) { - PowerCC26XX_module.calStep = STEP_CAL_HF1_2; - } - else { - PowerCC26XX_module.calStep = STEP_CAL_HF2_2; - } - } - - /* set AUX_WUC:REFCLKCTL.REQ */ - HWREG(AUX_WUC_BASE + AUX_WUC_O_REFCLKCTL) = AUX_WUC_REFCLKCTL_REQ; - - /* start Clock object to delay while wait for ACK */ - ClockP_start(ClockP_handle(&PowerCC26XX_module.calClockStruct)); - - break; - - case STEP_CAL_LF_2: - case STEP_CAL_HF1_2: - case STEP_CAL_HF2_2: - - if (PowerCC26XX_module.calStep == STEP_CAL_LF_2) { - - /* Set number of periods of ACLK to count */ - HWREG(AUX_TDC_BASE + AUX_TDC_O_TRIGCNTLOAD) = - NUM_RCOSC_LF_PERIODS_TO_MEASURE; - - /* set next Hwi state before triggering TDC */ - PowerCC26XX_module.hwiState = CAL_RCOSC_LF; - } - else { - - /* Set number of periods of ACLK to count */ - HWREG(AUX_TDC_BASE + AUX_TDC_O_TRIGCNTLOAD) = - NUM_RCOSC_HF_PERIODS_TO_MEASURE; - - /* set next Hwi state before triggering TDC */ - if (PowerCC26XX_module.calStep == STEP_CAL_HF2_2) { - PowerCC26XX_module.hwiState = CAL_RCOSC_HF2; - } - else { - PowerCC26XX_module.hwiState = CAL_RCOSC_HF1; - } - } - - /* Reset/clear result of TDC */ - HWREG(AUX_TDC_BASE + AUX_TDC_O_CTL) = AUX_TDC_CTL_CMD_CLR_RESULT; - - /* Clear possible pending interrupt source */ - HWREG(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOMCUFLAGSCLR) = - AUX_EVCTL_EVTOMCUFLAGSCLR_TDC_DONE; - - /* Enable TDC done interrupt as part of AUX_COMBINED interrupt */ - HWREG(AUX_EVCTL_BASE + AUX_EVCTL_O_COMBEVTOMCUMASK) = - AUX_EVCTL_COMBEVTOMCUMASK_TDC_DONE; - - /* Run TDC (start synchronously) */ - HWREG(AUX_TDC_BASE + AUX_TDC_O_CTL) = - AUX_TDC_CTL_CMD_RUN_SYNC_START; - - break; - - case STEP_CAL_LF_3: - case STEP_CAL_HF1_3: - - /* set next Swi state */ - if (PowerCC26XX_module.calStep == STEP_CAL_LF_3) { - PowerCC26XX_module.calStep = STEP_CAL_HF1_1; - } - else { - PowerCC26XX_module.calStep = STEP_CAL_HF2_1; - } - - /* clear AUX_WUC:REFCLKCTL.REQ... */ - HWREG(AUX_WUC_BASE + AUX_WUC_O_REFCLKCTL) = 0; - - /* start Clock object to delay while wait for ACK */ - ClockP_start(ClockP_handle(&PowerCC26XX_module.calClockStruct)); - - break; - - case STEP_CLEANUP_1: - - /* release the TDC clock request */ - HWREG(AUX_WUC_BASE + AUX_WUC_O_TDCCLKCTL) = 0; - - /* release the TDC reference clock request */ - HWREG(AUX_WUC_BASE + AUX_WUC_O_REFCLKCTL) = 0; - - /* set next state */ - PowerCC26XX_module.calStep = STEP_CLEANUP_2; - - /* start Clock object to delay while wait for ACK */ - ClockP_start(ClockP_handle(&PowerCC26XX_module.calClockStruct)); - - break; - - case STEP_CLEANUP_2: - - /* - * Disable all interrupts as part of AUX_COMBINED interrupt - * Once we release semaphore, the sensor controller is allowed - * to use the TDC. When it does, we must ensure that this - * does not cause any unexpected interrupts to the CM3. - */ - HWREG(AUX_EVCTL_BASE + AUX_EVCTL_O_COMBEVTOMCUMASK) = 0; - - /* release AUX semaphore */ - HWREG(AUX_SMPH_BASE + AUX_SMPH_O_SMPH1) = 1; - - /* release the power down constraints and XOSC_HF dependency */ - Power_releaseDependency(PowerCC26XX_XOSC_HF); - Power_releaseConstraint(PowerCC26XX_DISALLOW_STANDBY); - - /* set next state */ - PowerCC26XX_module.calStep = STEP_TDC_INIT_1; - -#if INSTRUMENT - doneCal = true; - calHF2i = 1; -#endif - PowerCC26XX_module.busyCal = false; - break; - - default: - for (;;) { - } - } -} - -/* - * ======== PowerCC26XX_RCOSC_clockFunc ======== - */ -void PowerCC26XX_RCOSC_clockFunc(uintptr_t arg) -{ -#if INSTRUMENT - calClocks++; -#endif - - switch (PowerCC26XX_module.calStep) { - - case STEP_TDC_INIT_2: - /* finish wait for AUX_WUC:TDCCLKCTL.ACK to be set ... */ - while(!(HWREG(AUX_WUC_BASE + AUX_WUC_O_TDCCLKCTL) & - AUX_WUC_TDCCLKCTL_ACK)); - break; - - case STEP_CAL_LF_1: - case STEP_CAL_HF1_1: - case STEP_CAL_HF2_1: - /* finish wait for AUX_WUC:REFCLKCTL.ACK to be cleared ... */ - while(HWREG(AUX_WUC_BASE + AUX_WUC_O_REFCLKCTL) & - AUX_WUC_REFCLKCTL_ACK); - break; - - case STEP_CAL_LF_2: - case STEP_CAL_HF1_2: - case STEP_CAL_HF2_2: - /* finish wait for AUX_WUC:REFCLKCTL.ACK to be set ... */ - while(!(HWREG(AUX_WUC_BASE + AUX_WUC_O_REFCLKCTL) & - AUX_WUC_REFCLKCTL_ACK)); - break; - - case STEP_CLEANUP_2: - /* finish wait for AUX_WUC:TDCCLKCTL.ACK to be cleared ... */ - while ((HWREG(AUX_WUC_BASE + AUX_WUC_O_TDCCLKCTL) & - AUX_WUC_TDCCLKCTL_ACK)); - /* finish wait for AUX_WUC:REFCLKCTL.ACK to be cleared ... */ - while(HWREG(AUX_WUC_BASE + AUX_WUC_O_REFCLKCTL) & - AUX_WUC_REFCLKCTL_ACK); - break; - - default: - for (;;) { - } - } - - PowerCC26XX_doCalibrate(); -} - -/* - * ======== getTdcSemaphore ======== - * Get TDC semaphore (number 1) - */ -static bool getTdcSemaphore() -{ - unsigned int own; - - /* try to acquire SMPH */ - own = HWREG(AUX_SMPH_BASE + AUX_SMPH_O_SMPH1); - - /* if acquired SMPH: done */ - if (own != 0) { - return (true); - } - - /* clear the interrupt source, can only be cleared when we don't have semaphore */ - HWREG(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOMCUFLAGSCLR) = - AUX_EVCTL_EVTOMCUFLAGSCLR_SMPH_AUTOTAKE_DONE; - - /* - * else, did not acquire the semaphore, enable SMPH_AUTOTAKE_DONE event - * (don't OR, write entire register, no other interrupts can be enabled!) - */ - HWREG(AUX_EVCTL_BASE + AUX_EVCTL_O_COMBEVTOMCUMASK) = - AUX_EVCTL_COMBEVTOMCUMASK_SMPH_AUTOTAKE_DONE; - - /* start AUTOTAKE of semaphore for TDC access */ - HWREG(AUX_SMPH_BASE + AUX_SMPH_O_AUTOTAKE) = AUX_TDC_SEMAPHORE_NUMBER; - - return (false); -} - -/* - * ======== updateSubSecInc ======== - * Update the SUBSECINC register based on measured RCOSC_LF frequency - */ -static void updateSubSecInc(uint32_t tdcResult) -{ - int32_t newSubSecInc; - uint32_t oldSubSecInc; - uint32_t subSecInc; - uint32_t ccfgModeConfReg; - int32_t hposcOffset; - int32_t hposcOffsetInv; - - /* - * Calculate the new SUBSECINC - * Here's the formula: AON_RTC:SUBSECINC = (45813 * NR) / 256 - * Based on measuring 32 LF clock periods - */ - newSubSecInc = (45813 * tdcResult) / 256; - - /* TODO: Replace with ccfgread driverlib call */ - ccfgModeConfReg = HWREG( CCFG_BASE + CCFG_O_MODE_CONF ); - /* Compensate HPOSC drift if HPOSC is in use */ - if(((ccfgModeConfReg & CCFG_MODE_CONF_XOSC_FREQ_M ) >> CCFG_MODE_CONF_XOSC_FREQ_S) == 1) { - /* Get the HPOSC relative offset at this temperature */ - hposcOffset = OSC_HPOSCRelativeFrequencyOffsetGet(AONBatMonTemperatureGetDegC()); - /* Convert to RF core format */ - hposcOffsetInv = OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert(hposcOffset); - /* Adjust SUBSECINC */ - newSubSecInc += (((newSubSecInc >> 4) * (hposcOffsetInv >> 3)) >> 15); - } - - /* Apply filter, but not for first calibration */ - if (PowerCC26XX_module.firstLF) { - /* Don't apply filter first time, to converge faster */ - subSecInc = newSubSecInc; - /* No longer first measurement */ - PowerCC26XX_module.firstLF = false; - } - else { - /* Read old SUBSECINC value */ - oldSubSecInc = HWREG(AON_RTC_BASE + AON_RTC_O_SUBSECINC) & 0x00FFFFFF; - /* Apply filter, 0.5 times old value, 0.5 times new value */ - subSecInc = (oldSubSecInc * 1 + newSubSecInc * 1) / 2; - } - - /* Update SUBSECINC values */ - HWREG(AUX_WUC_BASE + AUX_WUC_O_RTCSUBSECINC0) = subSecInc; - HWREG(AUX_WUC_BASE + AUX_WUC_O_RTCSUBSECINC1) = subSecInc >> 16; - - /* update to use new values */ - HWREG(AUX_WUC_BASE + AUX_WUC_O_RTCSUBSECINCCTL) = - AUX_WUC_RTCSUBSECINCCTL_UPD_REQ; -} - -/* - * ======== PowerCC26XX_calibrateRcoscHf1 ======== - * Calibrate RCOSC_HF agains XOSC_HF: compute and setup new trims - */ -static void calibrateRcoscHf1(int32_t tdcResult) -{ - /* *** STEP 1: Find RCOSC_HF-XOSC_HF frequency offset with current trim settings */ - /* Read in current trim settings */ - PowerCC26XX_module.nCtrimCurr = - (DDI32RegRead(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_RCOSCHFCTL) & - DDI_0_OSC_RCOSCHFCTL_RCOSCHF_CTRIM_M) >> - DDI_0_OSC_RCOSCHFCTL_RCOSCHF_CTRIM_S; - - PowerCC26XX_module.nCtrimFractCurr = - (DDI32RegRead(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL1_LOCAL) - & DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_LOCAL_M) >> - DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_LOCAL_S; - - PowerCC26XX_module.nRtrimCurr = - (DDI32RegRead(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_ATESTCTL) - & DDI_0_OSC_ATESTCTL_SET_RCOSC_HF_FINE_RESISTOR_LOCAL_M) >> - DDI_0_OSC_ATESTCTL_SET_RCOSC_HF_FINE_RESISTOR_LOCAL_S; - - - /* - * Find RCOSC_HF-XOSC_HF frequency offset with current trim settings - * Positive value => RCOSC_HF runs slow, CTRIM(FRACT) should be increased - * Negative value => RCOSC_HF runs fast, CTRIM(FRACT) should be decreased - * Resolution: 31.25 kHz; CTRIMFRACT resolution ~30 kHz - */ - PowerCC26XX_module.nDeltaFreqCurr = (int32_t) tdcResult - RCOSC_HF_PERFECT_TDC_VALUE; - - /* *** STEP 2: Attempt to calculate more optimal settings */ - if (PowerCC26XX_module.nDeltaFreqCurr == 0) { - /* If perfect, don't perform second measurement and keep current settings */ - PowerCC26XX_module.bRefine = false; - return; - } - if (PowerCC26XX_module.bRefine) { - /* - * Trying to find better match across CTRIM/RTRIM. Due to mismatches the - * first try might not have been more optimal than the current setting. - * Continue refining, starting from stored values - */ - } else { - /* Start from current values */ - PowerCC26XX_module.nCtrimFractNew = PowerCC26XX_module.nCtrimFractCurr; - PowerCC26XX_module.nCtrimNew = PowerCC26XX_module.nCtrimCurr; - PowerCC26XX_module.nRtrimNew = PowerCC26XX_module.nRtrimCurr; - PowerCC26XX_module.nDeltaFreqNew = PowerCC26XX_module.nDeltaFreqCurr; - } - - /* - * Calculate change to CTRIMFRACT with safe assumptions of gain, - * apply delta to current CTRIMFRACT and convert to valid CTRIM/CTRIMFRACT - */ - PowerCC26XX_module.nCtrimFractNew = PowerCC26XX_module.nCtrimFractNew + - Scale_rndInf(PowerCC26XX_module.nDeltaFreqNew); - PowerCC26XX_module.nCtrimNew = PowerCC26XX_module.nCtrimCurr; - - /* One step of CTRIM is about 500 kHz, so limit to one CTRIM step */ - if (PowerCC26XX_module.nCtrimFractNew < 1) { - if (PowerCC26XX_module.nRtrimNew == 3) { - /* We try the slow RTRIM in this CTRIM first */ - PowerCC26XX_module.nCtrimFractNew = Max(1, PowerCC26XX_module.nCtrimFractNew + 21); - PowerCC26XX_module.nRtrimNew = 0; - } - else { - /* Step down one CTRIM and use fast RTRIM */ - PowerCC26XX_module.nCtrimFractNew = Max(1, PowerCC26XX_module.nCtrimFractNew + 32 - 21); - PowerCC26XX_module.nCtrimNew = Max(0, PowerCC26XX_module.nCtrimNew - 1); - PowerCC26XX_module.nRtrimNew = 3; - } - } - else if (PowerCC26XX_module.nCtrimFractNew > 30) { - if (PowerCC26XX_module.nRtrimNew == 0) { - /* We try the slow RTRIM in this CTRIM first */ - PowerCC26XX_module.nCtrimFractNew = Min(30, PowerCC26XX_module.nCtrimFractNew - 21); - PowerCC26XX_module.nRtrimNew = 3; - } - else { - /* Step down one CTRIM and use fast RTRIM */ - PowerCC26XX_module.nCtrimFractNew = Min(30, PowerCC26XX_module.nCtrimFractNew - 32 + 21); - PowerCC26XX_module.nCtrimNew = Min(0x3F, PowerCC26XX_module.nCtrimNew + 1); - PowerCC26XX_module.nRtrimNew = 0; - } - } - else - { - /* We're within sweet spot of current CTRIM => no change */ - } - - /* Find RCOSC_HF vs XOSC_HF frequency offset with new trim settings */ - DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_RCOSCHFCTL, - DDI_0_OSC_RCOSCHFCTL_RCOSCHF_CTRIM_M, - DDI_0_OSC_RCOSCHFCTL_RCOSCHF_CTRIM_S, - PowerCC26XX_module.nCtrimNew); - - /* Enable RCOSCHFCTRIMFRACT_EN */ - DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL1_LOCAL, - DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_EN_LOCAL_M, - DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_EN_LOCAL_S, - 1); - - /* Modify CTRIM_FRACT */ - DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL1_LOCAL, - DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_LOCAL_M, - DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_LOCAL_S, - PowerCC26XX_module.nCtrimFractNew); - - /* Modify RTRIM */ - DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_ATESTCTL, - DDI_0_OSC_ATESTCTL_SET_RCOSC_HF_FINE_RESISTOR_LOCAL_M, - DDI_0_OSC_ATESTCTL_SET_RCOSC_HF_FINE_RESISTOR_LOCAL_S, - PowerCC26XX_module.nRtrimNew); -} - -/* - * ======== Power_calibrateRcoscHf2 ======== - * Calibrate RCOSC_HF agains XOSC_HF: determine better result, set new trims - */ -static void calibrateRcoscHf2(int32_t tdcResult) -{ - - PowerCC26XX_module.nDeltaFreqNew = (int32_t) tdcResult - RCOSC_HF_PERFECT_TDC_VALUE; - /* Calculate new delta freq */ - - /* *** STEP 4: Determine whether the new settings are better or worse */ - if (Abs(PowerCC26XX_module.nDeltaFreqNew) <= Abs(PowerCC26XX_module.nDeltaFreqCurr)) { - /* New settings are better or same -> make current by keeping in registers */ - PowerCC26XX_module.bRefine = false; - } - else { - /* First measurement was better than second, restore current settings */ - DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_RCOSCHFCTL, - DDI_0_OSC_RCOSCHFCTL_RCOSCHF_CTRIM_M, - DDI_0_OSC_RCOSCHFCTL_RCOSCHF_CTRIM_S, - PowerCC26XX_module.nCtrimCurr); - - DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL1_LOCAL, - DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_LOCAL_M, - DDI_0_OSC_CTL1_RCOSCHFCTRIMFRACT_LOCAL_S, - PowerCC26XX_module.nCtrimFractCurr); - - DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_ATESTCTL, - DDI_0_OSC_ATESTCTL_SET_RCOSC_HF_FINE_RESISTOR_LOCAL_M, - DDI_0_OSC_ATESTCTL_SET_RCOSC_HF_FINE_RESISTOR_LOCAL_S, - PowerCC26XX_module.nRtrimCurr); - - /* Enter a refinement mode where we keep searching for better matches */ - PowerCC26XX_module.bRefine = true; - } - -} diff --git a/simplelink/source/ti/drivers/rf/RF.h b/simplelink/source/ti/drivers/rf/RF.h index 52ceaba..d50abc5 100644 --- a/simplelink/source/ti/drivers/rf/RF.h +++ b/simplelink/source/ti/drivers/rf/RF.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2019, Texas Instruments Incorporated + * Copyright (c) 2016-2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,8 +31,7 @@ */ /*!**************************************************************************** @file RF.h -@brief Radio Frequency (RF) Core Driver for the CC13XX and CC26XX device - family. +@brief Common Radio Frequency (RF) Core Driver. To use the RF driver, ensure that the correct driver library for your device is linked in and include this header file as follows: @@ -41,2418 +40,21 @@ is linked in and include this header file as follows: #include @endcode -
-@anchor rf_overview -Overview -======== - -The RF driver provides access to the radio core on the CC13xx/CC26xx device -family. It offers a high-level interface for command execution and to the -radio timer (RAT). The RF driver ensures the lowest possible power consumption -by providing automatic power management that is fully transparent for the -application. - -@note This document describes the features and usage of the RF driver API. For a -detailed explanation of the RF core, please refer to the -Technical -Reference Manual or the -Proprietary -RF User Guide. - -Key features are: - -@li @ref rf_command_execution "Synchronous execution of direct and immediate radio commands" -@li @ref rf_command_execution "Synchronous and asynchronous execution of radio operation commands" -@li Various @ref rf_event_callbacks "event hooks" to interact with RF commands and the RF driver -@li Automatic @ref rf_power_management "power management" -@li @ref rf_scheduling "Preemptive scheduler for RF operations" of different RF driver instances -@li Convenient @ref rf_rat "Access to the radio timer" (RAT) -@li @ref rf_tx_power "Programming the TX power level" - -@anchor rf_setup_and_configuration -Setup and configuration -======================= - -The RF driver can be configured at 4 different places: - -1. In the build configuration by choosing either the single-client or - multi-client driver version. - -2. At compile-time by setting hardware and software interrupt priorities - in the board support file. - -3. During run-time initialization by setting #RF_Params when calling - #RF_open(). - -4. At run-time via #RF_control(). - - -Build configuration -------------------- - -The RF driver comes in two versions: single-client and multi-client. The -single-client version allows only one driver instance to access the RF core at -a time. The multi-client driver version allows concurrent access to the RF -core with different RF settings. The multi-client driver has a slightly larger -footprint and is not needed for many proprietary applications. The driver -version can be selected in the build configuration by linking either against a -RFCC26XX_singleMode or RFCC26XX_multiMode pre-built library. When using the -single-client driver, `RF_SINGLEMODE` has to be defined globally in the build -configuration. The multi-client driver is the default configuration in the -SimpleLink SDKs. - - -Board configuration -------------------- - -The RF driver handles RF core hardware interrupts and uses software interrupts -for its internal state machine. For managing the interrupt priorities, it -expects the existence of a global #RFCC26XX_HWAttrsV2 object. This is -usually defined in the board support file, for example `CC1310_LAUNCHXL.c`, -but when developing on custom boards, it might be kept anywhere in the -application. By default, the priorities are set to the lowest possible value: - -@code -const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { - .hwiPriority = INT_PRI_LEVEL7, // Lowest HWI priority: INT_PRI_LEVEL7 - // Highest HWI priority: INT_PRI_LEVEL1 - - .swiPriority = 0, // Lowest SWI priority: 0 - // Highest SWI priority: Swi.numPriorities - 1 - - .xoscHfAlwaysNeeded = true // Power driver always starts XOSC-HF: true - // RF driver will request XOSC-HF if needed: false -}; -@endcode - - -Initialization --------------- - -When initiating an RF driver instance, the function #RF_open() accepts a -pointer to a #RF_Params object which might set several driver parameters. In -addition, it expects an #RF_Mode object and a setup command which is usually -generated by SmartRF Studio: - -@code -RF_Params rfParams; -RF_Params_init(&rfParams); -rfParams.nInactivityTimeout = 2000; - -RF_Handle rfHandle = RF_open(&rfObject, &RF_prop, - (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams); -@endcode - -The function #RF_open() returns a driver handle that is used for accessing the -correct driver instance. Please note that the first RF operation command -before an RX or TX operation command must be a `CMD_FS` to set the synthesizer -frequency. The RF driver caches both, the pointer to the setup command and the -physical `CMD_FS` for automatic power management. - - -Run-time configuration ----------------------- - -While a driver instance is opened, it can be re-configured with the function -#RF_control(). Various configuration parameters @ref RF_CTRL are available. -Example: - -@code -uint32_t timeoutUs = 2000; -RF_control(rfHandle, RF_CTRL_SET_INACTIVITY_TIMEOUT, &timeoutUs); -@endcode - -
-@anchor rf_command_execution -Command execution -================= - -The RF core supports 3 different kinds of commands: - -1. Direct commands -2. Immediate commands -3. Radio operation commands - -Direct and immediate commands are dispatched via #RF_runDirectCmd() and -#RF_runImmediateCmd() respectively. These functions block until the command -has completed and return a status code of the type #RF_Stat when done. - -@code -#include - -RF_Stat status = RF_runDirectCmd(rfHandle, CMD_ABORT); -assert(status == RF_StatCmdDoneSuccess); -@endcode - -Radio operation commands are potentially long-running commands and support -different triggers as well as conditional execution. Only one command can be -executed at a time, but the RF driver provides an internal queue that stores -commands until the RF core is free. Two interfaces are provided for radio -operation commands: - -1. Asynchronous: #RF_postCmd() and #RF_pendCmd() -2. Synchronous: #RF_runCmd() - -The asynchronous function #RF_postCmd() posts a radio operation into the -driver's internal command queue and returns a command handle of the type -#RF_CmdHandle which is an index in the command queue. The command is -dispatched as soon as the RF core has completed any previous radio operation -command. - -@code -#include - -RF_Callback callback = NULL; -RF_EventMask subscribedEvents = 0; -RF_CmdHandle rxCommandHandle = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdRx, - RF_PriorityNormal, callback, subscribedEvents); - -assert(rxCommandHandle != RF_ALLOC_ERROR); // The command queue is full. -@endcode - -Command execution happens in background. The calling task may proceed with -other work or execute direct and immediate commands to interact with the -posted radio operation. But beware that the posted command might not have -started, yet. By calling the function #RF_pendCmd() and subscribing events of -the type #RF_EventMask, it is possible to re-synchronize to a posted command: - -@code -// RF_EventRxEntryDone must have been subscribed in RF_postCmd(). -RF_EventMask events = RF_pendCmd(rfHandle, rxCommandHandle, - RF_EventRxEntryDone); - -// Program proceeds after RF_EventRxEntryDone or after a termination event. -@endcode - -The function #RF_runCmd() is a combination of both, #RF_postCmd() and -#RF_pendCmd() and allows synchronous execution. - -A pending or already running command might be aborted at any time by calling -the function #RF_cancelCmd() or #RF_flushCmd(). These functions take command -handles as parameters, but can also just abort anything in the RF driver's -queue: - -@code -uint8_t abortGraceful = 1; - -// Abort a single command -RF_cancelCmd(rfHandle, rxCommandHandle, abortGraceful); - -// Abort anything -RF_flushCmd(rfHandle, RF_CMDHANDLE_FLUSH_ALL, abortGraceful); -@endcode - -When aborting a command, the return value of #RF_runCmd() or #RF_pendCmd() -will contain the termination reason in form of event flags. If the command is -in the RF driver queue, but has not yet start, the #RF_EventCmdCancelled event is -raised. - -
-@anchor rf_event_callbacks -Event callbacks -=============== - -The RF core generates multiple interrupts during command execution. The RF -driver maps these interrupts 1:1 to callback events of the type #RF_EventMask. -Hence, it is unnecessary to implement own interrupt handlers. Callback events -are divided into 3 groups: - -- Command-specific events, documented for each radio operation command. An example - is the #RF_EventRxEntryDone for the `CMD_PROP_RX`. - -- Generic events, defined for all radio operations and originating on the RF core. - These are for instance #RF_EventCmdDone and #RF_EventLastCmdDone. Both events - indicate the termination of one or more RF operations. - -- Generic events, defined for all radio operations and originating in the RF driver, - for instance #RF_EventCmdCancelled. - -@sa @ref RF_Core_Events, @ref RF_Driver_Events. - -How callback events are subscribed was shown in the previous section. The -following snippet shows a typical event handler callback for a proprietary RX -operation: - -@code -void rxCallback(RF_Handle handle, RF_CmdHandle command, RF_EventMask events) -{ - if (events & RF_EventRxEntryDone) - { - Semaphore_post(rxPacketSemaphore); - } - if (events & RF_EventLastCmdDone) - { - // ... - } -} -@endcode - -In addition, the RF driver can generate error and power-up events that do not -relate directly to the execution of a radio command. Such events can be -subscribed by specifying the callback function pointers #RF_Params::pErrCb and -#RF_Params::pPowerCb. - -All callback functions run in software interrupt (SWI) context. Therefore, -only a minimum amount of code should be executed. When using absolute timed -commands with tight timing constraints, then it is recommended to set the RF -driver SWIs to a high priority. -See @ref rf_setup_and_configuration "Setup and configuration" for more details. - -
-@anchor rf_power_management -Power management -================ - -The RF core is a hardware peripheral and can be switched on and off. The RF -driver handles that automatically and provides the following power -optimization features: - -- Lazy power-up and radio setup caching -- Power-down on inactivity -- Deferred dispatching of commands with absolute timing - - -Lazy power-up and radio setup caching -------------------------------------- - -The RF core optimizes the power consumption by enabling the RF core as late as -possible. For instance does #RF_open() not power up the RF core immediately. -Instead, it waits until the first radio operation command is dispatched by -#RF_postCmd() or #RF_runCmd(). - -The function #RF_open() takes a radio setup command as parameter and expects a -`CMD_FS` command to follow. The pointer to the radio setup command and the -whole `CMD_FS` command are cached internally in the RF driver. They will be -used for every proceeding power-up procedure. Whenever the client re-runs a -setup command or a `CMD_FS` command, the driver updates its internal cache -with the new settings. - -By default, the RF driver measures the time that it needs for the power-up -procedure and uses that as an estimate for the next power cycle. On the -CC13x0/CC26x0 devices, power-up takes usually 1.6 ms. Automatic measurement -can be suppressed by specifying a custom power-up time with -#RF_Params::nPowerUpDuration. In addition, the client might set -#RF_Params::nPowerUpDurationMargin to cover any uncertainty when doing -automatic measurements. This is necessary in applications with a high hardware -interrupt load which can delay the RF driver's internal state machine -execution. - - -Power-down on inactivity ------------------------- - -Whenever a radio operation completes and there is no other radio operation in -the queue, the RF core might be powered down. There are two options in the RF -driver: - -- **Automatic power-down** by setting the parameter - #RF_Params::nInactivityTimeout. The RF core will then start a timer after - the last command in the queue has completed. The default timeout is "forever" - and this feature is disabled. - -- **Manual power-down** by calling #RF_yield(). The client should do this - whenever it knows that no further radio operation will be executed for a - couple of milliseconds. - -During the power-down procedure the RF driver stops the radio timer and saves -a synchronization timestamp for the next power-up. This keeps the radio timer -virtually in sync with the RTC even though it is not running all the time. The -synchronization is done in hardware. - - -Deferred dispatching of commands with absolute timing ------------------------------------------------------ - -When dispatching a radio operation command with an absolute start trigger that -is ahead in the future, the RF driver defers the execution and powers the RF -core down until the command is due. It does that only, when: - -1. `cmd.startTrigger.triggerType` is set to `TRIG_ABSTIME` - -2. The difference between #RF_getCurrentTime() and `cmd.startTime` - is at not more than 3/4 of a full RAT cycle. Otherwise the driver assumes - that `cmd.startTime` is in the past. - -3. There is enough time to run a full power cycle before `cmd.startTime` is - due. That includes: - - - the power-down time (fixed value, 1 ms) if the RF core is already - powered up, - - - the measured power-up duration or the value specified by - #RF_Params::nPowerUpDuration, - - - the power-up safety margin #RF_Params::nPowerUpDurationMargin - (the default is 282 microseconds). - -If one of the conditions are not fulfilled, the RF core is kept up and -running and the command is dispatched immediately. This ensures, that the -command will execute on-time and not miss the configured start trigger. - -
-@anchor rf_scheduling -Preemptive scheduling of RF commands in multi-client applications -================================================================= - -Schedule BLE and proprietary radio commands. - -@code -RF_Object rfObject_ble; -RF_Object rfObject_prop; - -RF_Handle rfHandle_ble, rfHandle_prop; -RF_Params rfParams_ble, rfParams_prop; -RF_ScheduleCmdParams schParams_ble, schParams_prop; - -RF_Mode rfMode_ble = -{ - .rfMode = RF_MODE_MULTIPLE, // rfMode for dual mode - .cpePatchFxn = &rf_patch_cpe_ble, - .mcePatchFxn = 0, - .rfePatchFxn = &rf_patch_rfe_ble, -}; - -RF_Mode rfMode_prop = -{ - .rfMode = RF_MODE_MULTIPLE, // rfMode for dual mode - .cpePatchFxn = &rf_patch_cpe_genfsk, - .mcePatchFxn = 0, - .rfePatchFxn = 0, -}; - -// Init RF and specify non-default parameters -RF_Params_init(&rfParams_ble); -rfParams_ble.nInactivityTimeout = 200; // 200us - -RF_Params_init(&rfParams_prop); -rfParams_prop.nInactivityTimeout = 200; // 200us - -// Configure RF schedule command parameters directly. -schParams_ble.priority = RF_PriorityNormal; -schParams_ble.endTime = 0; -schParams_ble.allowDelay = RF_AllowDelayAny; - -// Alternatively, use the helper function to configure the default behavior -RF_ScheduleCmdParams_init(&schParams_prop); - -// Open BLE and proprietary RF handles -rfHandle_ble = RF_open(rfObj_ble, &rfMode_ble, (RF_RadioSetup*)&RF_cmdRadioSetup, &rfParams_ble); -rfHandle_prop = RF_open(rfObj_prop, &rfMode_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams_prop); - -// Run a proprietary Fs command -RF_runCmd(rfHandle_pro, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, NULL); - -// Schedule a proprietary RX command -RF_scheduleCmd(rfHandle_pro, (RF_Op*)&RF_cmdPropRx, &schParams_prop, &prop_callback, RF_EventRxOk); - -// Schedule a BLE advertiser command -RF_scheduleCmd(rfHandle_ble, (RF_Op*)&RF_cmdBleAdv, &schParams_ble, &ble_callback, - (RF_EventLastCmdDone | RF_EventRxEntryDone | RF_EventTxEntryDone)); - -@endcode - -Get dual mode schedule map including timing and priority information for access requests and commands. - -@code - -RF_ScheduleMap rfSheduleMap; -RF_InfoVal rfGetInfoVal; - -// Get schedule map -rfGetInfoVal.pScheduleMap = &rfScheduleMap; -RF_getInfo(NULL, RF_GET_SCHEDULE_MAP, &rfGetInfoVal); - -// RF_scheduleMap includes the following information: -// (RF_NUM_SCHEDULE_ACCESS_ENTRIES (default = 2)) entries of access request information -// (RF_NUM_SCHEDULE_COMMAND_ENTRIES (default = 8)) entries of radio command information -// Each entry has the type of RF_ScheduleMapElement. - -@endcode - -
-@anchor rf_rat -Accessing the Radio Timer (RAT) -============================== - -The Radio Timer on the RF core is an independent 32 bit timer running at a -tick rate of 4 ticks per microsecond. It is only physically active while the -RF core is on. But because the RF driver resynchronizes the RAT to the RTC on -every power-up, it appears to the application as the timer is always running. -The RAT accuracy depends on the system HF clock while the RF core is active -and on the LF clock while the RF core is powered down. - -The current RAT time stamp can be obtained by #RF_getCurrentTime(): - -@code -uint32_t now = RF_getCurrentTime(); -@endcode - -The RAT has 8 independent channels that can be set up in capture and compare -mode by #RF_ratCapture() and #RF_ratCompare() respectively. Three of these -channels are accessible by the RF driver. Each channel may be connected to -physical hardware signals for input and output or may trigger a callback -function. - -In order to allocate a RAT channel and trigger a callback function at a -certain time stamp, use #RF_ratCompare(): - -@code -RF_Handle rfDriver; -RF_RatConfigCompare config; -RF_RatConfigCompare_init(&config); -config.callback = &onRatTriggered; -config.channel = RF_RatChannelAny; -config.timeout = RF_getCurrentTime() + RF_convertMsToRatTicks(1701); - -RF_RatHandle ratHandle = RF_ratCompare(rfDriver, &config, nullptr); -assert(ratHandle != RF_ALLOC_ERROR); - -void onRatTriggered(RF_Handle h, RF_RatHandle rh, RF_EventMask e, uint32_t compareCaptureTime) -{ - if (e & RF_EventError) - { - // RF driver failed to trigger the callback on time. - } - printf("RAT has triggered at %u.", compareCaptureTime); - - // Trigger precisely with the same period again - config.timeout = compareCaptureTime + RF_convertMsToRatTicks(1701); - ratHandle = RF_ratCompare(rfDriver, &config, nullptr); - assert(ratHandle != RF_ALLOC_ERROR); -} -@endcode - -The RAT may be used to capture a time stamp on an edge of a physical pin. This -can be achieved with #RF_ratCapture(). - -@code -#include -// Map IO 26 to RFC_GPI0 -PINCC26XX_setMux(pinHandle, IOID_26, PINCC26XX_MUX_RFC_GPI0); - -RF_Handle rfDriver; -RF_RatConfigCapture config; -RF_RatConfigCapture_init(&config); -config.callback = &onSignalTriggered; -config.channel = RF_RatChannelAny; -config.source = RF_RatCaptureSourceRfcGpi0; -config.captureMode = RF_RatCaptureModeRising; -config.repeat = RF_RatCaptureRepeat; - -RF_RatHandle ratHandle = RF_ratCapture(rfDriver, &config, nullptr); -assert(ratHandle != RF_ALLOC_ERROR); - -void onSignalTriggered(RF_Handle h, RF_RatHandle rh, RF_EventMask e, uint32_t compareCaptureTime) -{ - if (e & RF_EventError) - { - // An internal error has occurred - } - printf("Rising edge detected on IO 26 at %u.", compareCaptureTime); -} -@endcode - -In both cases, the RAT may generate an output signal when being triggered. The -signal can be routed to a physical IO pin: - -@code -// Generate a pulse on an internal RAT output signal -RF_RatConfigOutput output; -RF_RatConfigOutput_init(&output); -output.mode = RF_RatOutputModePulse; -output.select = RF_RatOutputSelectRatGpo3; -RF_ratCompare(...); - -// Map RatGpo3 to one of four intermediate doorbell signals. -// This has to be done in the override list in order to take permanent effect. -// The override list can be found in the RF settings .c file exported from -// SmartRF Studio. -// Attention: This will change the default mapping of the PA and LNA signal as well. -#include -static uint32_t pOverrides[] = -{ - HW_REG_OVERRIDE(0x1110, RFC_DBELL_SYSGPOCTL_GPOCTL2_RATGPO3), - // ... -} - -// Finally, route the intermediate doorbell signal to a physical pin. -#include -PINCC26XX_setMux(pinHandle, IOID_17, PINCC26XX_MUX_RFC_GPO2); -@endcode - -
-@anchor rf_tx_power -Programming the TX power level -============================== - -The application can program a TX power level for each RF client with the function -#RF_setTxPower(). The new value takes immediate effect if the RF core is up and -running. Otherwise, it is stored in the RF driver client configuration. - -TX power may be stored in a lookup table in ascending order. This table is usually -generated and exported from SmartRF Studio together with the rest of the PHY configuration. -A typical power table my look as follows: -@code -RF_TxPowerTable_Entry txPowerTable[] = { - { .power = 11, .value = { 0x1233, RF_TxPowerTable_DefaultPA }}, - { .power = 13, .value = { 0x1234, RF_TxPowerTable_DefaultPA }}, - // ... - RF_TxPowerTable_TERMINATION_ENTRY -}; -@endcode - -@note Some devices offer a high-power PA in addition to the default PA. -A client must not mix configuration values in the same power table and must -not hop from a default PA configuration to a high-power PA configuration unless it -can guarantee that the RF setup command is re-executed in between. - -Given this power table format, the application may program a new power level in multiple -ways. It can use convenience functions to search a certain power level -in the power table or may access the table index-based: -@code -// Set a certain power level. Search a matching level. -RF_setTxPower(h, RF_TxPowerTable_findValue(txPowerTable, 17)); - -// Set a certain power level with a known level. -RF_setTxPower(h, txPowerTable[3].value); - -// Set a certain power without using a human readable level. -RF_setTxPower(h, value); - -// Set maximum power. Search the value. -RF_setTxPower(h, RF_TxPowerTable_findValue(txPowerTable, RF_TxPowerTable_MAX_DBM)); - -// Set minimum power without searching. -RF_setTxPower(h, txPowerTable[0].value); - -// Set minimum power. Search the value. -RF_setTxPower(h, RF_TxPowerTable_findValue(txPowerTable, RF_TxPowerTable_MIN_DBM)); - -// Set maximum power without searching. -int32_t lastIndex = sizeof(txPowerTable) / sizeof(RF_TxPowerTable_Entry) - 2; -RF_setTxPower(h, txPowerTable[lastIndex].value); -@endcode - -The current configured power level for a client can be retrieved by #RF_getTxPower(). -@code -// Get the current configured power level. -int8_t power = RF_TxPowerTable_findPowerLevel(txPowerTable, RF_getTxPower(h)); -@endcode - -
-@anchor rf_convenience_features -Convenience features -==================== - -The RF driver simplifies often needed tasks and provides additional functions. -For instance, it can read the RSSI while the RF core is in RX mode using the -function :tidrivers_api:`RF_getRssi`: - -@code -int8_t rssi = RF_getRssi(rfHandle); -assert (rssi != RF_GET_RSSI_ERROR_VAL); // Could not read the RSSI -@endcode - -
****************************************************************************** */ #ifndef ti_drivers_rf__include #define ti_drivers_rf__include -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -#include -#include -#include - #include -#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) -#include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h) -#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h) -/** - * @name RF Core Events - * @anchor RF_Core_Events - * - * Events originating on the RF core and caused during command execution. - * They are aliases for the corresponding interrupt flags. - * RF Core Events are command-specific and are explained in the Technical Reference Manual. - * - * @sa RF_postCmd(), RF_pendCmd(), RF_runCmd() - * @{ - */ -#define RF_EventCmdDone (1 << 0) ///< A radio operation command in a chain finished. -#define RF_EventLastCmdDone (1 << 1) ///< A stand-alone radio operation command or the last radio operation command in a chain finished. -#define RF_EventFGCmdDone (1 << 2) ///< A IEEE-mode radio operation command in a chain finished. -#define RF_EventLastFGCmdDone (1 << 3) ///< A stand-alone IEEE-mode radio operation command or the last command in a chain finished. -#define RF_EventTxDone (1 << 4) ///< Packet transmitted -#define RF_EventTXAck (1 << 5) ///< ACK packet transmitted -#define RF_EventTxCtrl (1 << 6) ///< Control packet transmitted -#define RF_EventTxCtrlAck (1 << 7) ///< Acknowledgement received on a transmitted control packet -#define RF_EventTxCtrlAckAck (1 << 8) ///< Acknowledgement received on a transmitted control packet, and acknowledgement transmitted for that packet -#define RF_EventTxRetrans (1 << 9) ///< Packet retransmitted -#define RF_EventTxEntryDone (1 << 10) ///< Tx queue data entry state changed to Finished -#define RF_EventTxBufferChange (1 << 11) ///< A buffer change is complete -#define RF_EventPaChanged (1 << 14) ///< The PA was reconfigured on the fly. -#define RF_EventRxOk (1 << 16) ///< Packet received with CRC OK, payload, and not to be ignored -#define RF_EventRxNOk (1 << 17) ///< Packet received with CRC error -#define RF_EventRxIgnored (1 << 18) ///< Packet received with CRC OK, but to be ignored -#define RF_EventRxEmpty (1 << 19) ///< Packet received with CRC OK, not to be ignored, no payload -#define RF_EventRxCtrl (1 << 20) ///< Control packet received with CRC OK, not to be ignored -#define RF_EventRxCtrlAck (1 << 21) ///< Control packet received with CRC OK, not to be ignored, then ACK sent -#define RF_EventRxBufFull (1 << 22) ///< Packet received that did not fit in the Rx queue -#define RF_EventRxEntryDone (1 << 23) ///< Rx queue data entry changing state to Finished -#define RF_EventDataWritten (1 << 24) ///< Data written to partial read Rx buffer -#define RF_EventNDataWritten (1 << 25) ///< Specified number of bytes written to partial read Rx buffer -#define RF_EventRxAborted (1 << 26) ///< Packet reception stopped before packet was done -#define RF_EventRxCollisionDetected (1 << 27) ///< A collision was indicated during packet reception -#define RF_EventModulesUnlocked (1 << 29) ///< As part of the boot process, the CM0 has opened access to RF core modules and memories -#define RF_EventInternalError (uint32_t)(1 << 31) ///< Internal error observed -#define RF_EventMdmSoft 0x0000002000000000 ///< Synchronization word detected (MDMSOFT interrupt flag) -/** @}*/ - -/** - * @name RF Driver Events - * @anchor RF_Driver_Events - * - * Event flags generated by the RF Driver. - * @{ - */ -#define RF_EventCmdCancelled 0x1000000000000000 ///< Command canceled before it was started. -#define RF_EventCmdAborted 0x2000000000000000 ///< Abrupt command termination caused by RF_cancelCmd() or RF_flushCmd(). -#define RF_EventCmdStopped 0x4000000000000000 ///< Graceful command termination caused by RF_cancelCmd() or RF_flushCmd(). -#define RF_EventRatCh 0x0800000000000000 ///< A user-programmable RAT channel triggered an event. -#define RF_EventPowerUp 0x0400000000000000 ///< RF power up event. \deprecated This event is deprecated. Use #RF_ClientEventPowerUpFinished instead. -#define RF_EventError 0x0200000000000000 ///< Event flag used for error callback functions to indicate an error. See RF_Params::pErrCb. -#define RF_EventCmdPreempted 0x0100000000000000 ///< Command preempted by another command with higher priority. Applies only to multi-client applications. -/** @}*/ - -/** - * @name Control codes for driver configuration - * @anchor RF_CTRL - * - * Control codes are used in RF_control(). - * - * @{ - */ - -/*! - * @brief Control code used by RF_control to set inactivity timeout - * - * Setting this control allows RF to power down the radio upon completion of a radio - * command after a specified timeout period (in us) - * With this control code @b arg is a pointer to the timeout variable and returns RF_StatSuccess. - */ -#define RF_CTRL_SET_INACTIVITY_TIMEOUT 0 -/*! - * @brief Control code used by RF_control to update setup command - * - * Setting this control notifies RF that the setup command is to be updated, so that RF will take - * proper actions when executing the next setup command. - * Note the updated setup command will take effect in the next power up cycle when RF executes the - * setup command. Prior to updating the setup command, user should make sure all pending commands - * have completed. - */ -#define RF_CTRL_UPDATE_SETUP_CMD 1 -/*! - * @brief Control code used by RF_control to set powerup duration margin - * - * Setting this control updates the powerup duration margin. Default is RF_DEFAULT_POWER_UP_MARGIN. - */ -#define RF_CTRL_SET_POWERUP_DURATION_MARGIN 2 -/*! - * @brief Control code used by RF_control to set the phy switching margin - * - * Setting this control updates the phy switching duration margin, which is used to calculate when - * run-time conflicts shall be evaluated in case of colliding radio operations issued from two - * different clients. Default is RF_DEFAULT_PHY_SWITCHING_MARGIN. - */ -#define RF_CTRL_SET_PHYSWITCHING_DURATION_MARGIN 3 -/*! - * @brief Control code used by RF_control to set max error tolerance for RAT/RTC - * - * Setting this control updates the error tol for how frequently the CMD_RAT_SYNC_STOP is sent. - * Default is RF_DEFAULT_RAT_RTC_ERR_TOL_IN_US (5 us) - * Client is recommeneded to change this setting before sending any commands. - */ -#define RF_CTRL_SET_RAT_RTC_ERR_TOL_VAL 4 -/*! - * @brief Control code used by RF_control to set power management - * - * Setting this control configures RF driver to enable or disable power management. - * By default power management is enabled. - * If disabled, once RF core wakes up, RF driver will not go to standby and will not power down RF core. - * To configure power management, use this control to pass a parameter value of 0 to disable power management, - * and pass a parameter value of 1 to re-enable power management. - * This control is valid for dual-mode code only. Setting this control when using single-mode code has no effect - * (power management always enabled). - */ -#define RF_CTRL_SET_POWER_MGMT 5 -/*! - * @brief Control code used by RF_control to set the hardware interrupt priority level of the RF driver. - * - * This control code sets the hardware interrupt priority level that is used by the RF driver. Valid - * values are INT_PRI_LEVEL1 (highest) until INT_PRI_LEVEL7 (lowest). The default interrupt priority is - * set in the board support file. The default value is -1 which means "lowest possible priority". - * - * When using the TI-RTOS kernel, INT_PRI_LEVEL0 is reserved for zero-latency interrupts and must not be used. - * - * Execute this control code only while the RF core is powered down and the RF driver command queue is empty. - * This is usually the case after calling RF_open(). Changing the interrupt priority level while the RF driver - * is active will result in RF_StatBusyError being returned. - * - * Example: - * @code - * #include DeviceFamily_constructPath(driverlib/interrupt.h) - * - * int32_t hwiPriority = INT_PRI_LEVEL5; - * RF_control(rfHandle, RF_CTRL_SET_HWI_PRIORITY, &hwiPriority); - * @endcode - */ -#define RF_CTRL_SET_HWI_PRIORITY 6 -/*! - * @brief Control code used by RF_control to set the software interrupt priority level of the RF driver. - * - * This control code sets the software interrupt priority level that is used by the RF driver. Valid - * values are integers starting at 0 (lowest) until Swi_numPriorities - 1 (highest). The default - * interrupt priority is set in the board support file. The default value is 0 which means means - * "lowest possible priority". - * - * Execute this control code only while the RF core is powered down and the RF driver command queue is empty. - * This is usually the case after calling RF_open(). Changing the interrupt priority level while the RF driver - * is active will result in RF_StatBusyError being returned. - * - * Example: - * @code - * #include - * - * // Set highest possible priority - * uint32_t swiPriority = ~0; - * RF_control(rfHandle, RF_CTRL_SET_SWI_PRIORITY, &swiPriority); - * @endcode - */ -#define RF_CTRL_SET_SWI_PRIORITY 7 -/*! - * @brief Control code used by RF_control to mask the available RAT channels manually. - * - * This control code can be used to manually disallow/allow access to certain RAT channels from the RAT APIs. - * A typical use case is when a RAT channel is programmed through chained radio operations, and hence is - * used outside the scope of the RF driver. By disallowing access to this channel one can prevent collision - * between the automatic channel allocation through #RF_ratCompare()/#RF_ratCapture() and the direct - * configuration through #RF_postCmd(). - */ -#define RF_CTRL_SET_AVAILABLE_RAT_CHANNELS_MASK 8 -/** @}*/ - -/** - * @name TX Power Table defines - * @{ - */ - -/** - * Refers to the the minimum available power in dBm when accessing a power - * table. - * - * \sa #RF_TxPowerTable_findValue() - */ -#define RF_TxPowerTable_MIN_DBM -128 - -/** - * Refers to the the maximum available power in dBm when accessing a power - * table. - * - * \sa #RF_TxPowerTable_findValue() - */ -#define RF_TxPowerTable_MAX_DBM 126 - -/** - * Refers to an invalid power level in a TX power table. - * - * \sa #RF_TxPowerTable_findPowerLevel() - */ -#define RF_TxPowerTable_INVALID_DBM 127 - -/** - * Refers to an invalid power value in a TX power table. - * - * This is the raw value part of a TX power configuration. In order to check - * whether a given power configuration is valid, do: - * - * @code - * RF_TxPowerTable_Value value = ...; - * if (value.rawValue == RF_TxPowerTable_INVALID_VALUE) { - * // error, value not valid - * } - * @endcode - * - * A TX power table is always terminated by an invalid power configuration. - * - * \sa #RF_getTxPower(), RF_TxPowerTable_findValue - */ -#define RF_TxPowerTable_INVALID_VALUE 0x3fffff - -/** - * Marks the last entry in a TX power table. - * - * In order to use #RF_TxPowerTable_findValue() and #RF_TxPowerTable_findPowerLevel(), - * every power table must be terminated by a %RF_TxPowerTable_TERMINATION_ENTRY: - * - * @code - * RF_TxPowerTable_Entry txPowerTable[] = - * { - * { 20, RF_TxPowerTable_HIGH_PA_ENTRY(1, 2, 3) }, - * // ... , - * RF_TxPowerTable_TERMINATION_ENTRY - * }; - * @endcode - */ -#define RF_TxPowerTable_TERMINATION_ENTRY \ - { .power = RF_TxPowerTable_INVALID_DBM, .value = { .rawValue = RF_TxPowerTable_INVALID_VALUE, .paType = RF_TxPowerTable_DefaultPA } } - -/** - * Creates a TX power table entry for the default PA. - * - * The values for \a bias, \a gain, \a boost and \a coefficient are usually measured by Texas Instruments - * for a specific front-end configuration. They can then be obtained from SmartRFStudio. - */ -#define RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost, coefficient) \ - { .rawValue = ((bias) << 0) | ((gain) << 6) | ((boost) << 8) | ((coefficient) << 9), .paType = RF_TxPowerTable_DefaultPA } - -/** - * Creates a TX power table entry for the High-power PA. - * - * The values for \a bias, \a ibboost, \a boost, \a coefficient and \a ldoTrim are usually measured by Texas Instruments - * for a specific front-end configuration. They can then be obtained from SmartRFStudio. - */ -#define RF_TxPowerTable_HIGH_PA_ENTRY(bias, ibboost, boost, coefficient, ldotrim) \ - { .rawValue = ((bias) << 0) | ((ibboost) << 6) | ((boost) << 8) | ((coefficient) << 9) | ((ldotrim) << 16), .paType = RF_TxPowerTable_HighPA } - - -/** @} */ - -/** - * @name Other defines - * @{ - */ -#define RF_GET_RSSI_ERROR_VAL (-128) ///< Error return value for RF_getRssi() -#define RF_CMDHANDLE_FLUSH_ALL (-1) ///< RF command handle to flush all RF commands -#define RF_ALLOC_ERROR (-2) ///< RF command or RAT channel allocation error -#define RF_SCHEDULE_CMD_ERROR (-3) ///< RF command schedule error -#define RF_ERROR_RAT_PROG (-255) ///< A rat channel could not be programmed. -#define RF_ERROR_INVALID_RFMODE (-256) ///< Invalid RF_Mode. Used in error callback. -#define RF_ERROR_CMDFS_SYNTH_PROG (-257) ///< Synthesizer error with CMD_FS. Used in error callback. If this error occurred in error callback, user needs to resend CMD_FS to recover. See the device's errata for more details. - -#define RF_NUM_SCHEDULE_ACCESS_ENTRIES 2 ///< Number of access request entries -#define RF_NUM_SCHEDULE_COMMAND_ENTRIES 8 ///< Number of scheduled command entries -#define RF_NUM_SCHEDULE_MAP_ENTRIES (RF_NUM_SCHEDULE_ACCESS_ENTRIES + RF_NUM_SCHEDULE_COMMAND_ENTRIES) ///< Number of schedule map entries. This is the sum of access request and scheduled command entries -#define RF_SCH_MAP_CURRENT_CMD_OFFSET RF_NUM_SCHEDULE_ACCESS_ENTRIES ///< Offset of the current command entry in the schedule map -#define RF_SCH_MAP_PENDING_CMD_OFFSET (RF_SCH_MAP_CURRENT_CMD_OFFSET + 2) ///< Offset of the first pending command entry in the schedule map - -#define RF_ABORT_PREEMPTION (1<<2) ///< Used with RF_cancelCmd() to provoke subscription to RadioFreeCallback -#define RF_ABORT_GRACEFULLY (1<<0) ///< Used with RF_cancelCmd() for graceful command termination - -#define RF_SCH_CMD_EXECUTION_TIME_UNKNOWN 0 ///< For unknown execution time for RF scheduler - -#define RF_RAT_ANY_CHANNEL (-1) ///< To be used within the channel configuration structure. Allocate any of the available channels. -#define RF_RAT_TICKS_PER_US 4 ///< Radio timer (RAT) ticks per microsecond. - -#define RF_LODIVIDER_MASK 0x7F ///< Mask to be used to determine the effective value of the setup command's loDivider field. - -/*! -\brief Converts a duration given in \a microseconds into radio timer (RAT) ticks. -*/ -#define RF_convertUsToRatTicks(microseconds) \ - ((microseconds) * (RF_RAT_TICKS_PER_US)) - -/*! -\brief Converts a duration given in \a milliseconds into radio timer (RAT) ticks. -*/ -#define RF_convertMsToRatTicks(milliseconds) \ - ((milliseconds) * 1000 * (RF_RAT_TICKS_PER_US)) - -/*! -\brief Converts a duration given in radio timer (RAT) \a ticks into microseconds. -*/ -#define RF_convertRatTicksToUs(ticks) \ - ((ticks) / (RF_RAT_TICKS_PER_US)) - -/*! -\brief Converts a duration given in radio timer (RAT) \a ticks into milliseconds. -*/ -#define RF_convertRatTicksToMs(ticks) \ - ((ticks) / (1000 * (RF_RAT_TICKS_PER_US))) - - -/** @}*/ - - -/** - * \brief PA configuration value for a certain power level. - * - * A %RF_TxPowerTable_Value contains the power amplifier (PA) configuration for a certain power level. - * It encodes the PA type as well as a raw configuration value for the RF core hardware. - * - * \sa #RF_getTxPower(), #RF_setTxPower(), #RF_TxPowerTable_Entry, #RF_TxPowerTable_PAType. - */ -typedef struct { - uint32_t rawValue:22; ///< Hardware configuration value. - ///< - ///< - \c [15:0] used for default PA, - ///< - \c [21:0] used for High-power PA - uint32_t __dummy:9; - uint32_t paType:1; ///< Selects the PA type to be used. - ///< - ///< - 0: #RF_TxPowerTable_DefaultPA - ///< - 1: #RF_TxPowerTable_HighPA -} RF_TxPowerTable_Value; - -/** - * \brief TX power configuration entry in a TX power table. - * - * A %RF_TxPowerTable_Entry defines an entry in a lookup table. Each entry contains a - * human-readable power level \a power as key and a hardware configuration \a value. - * - * Example of a typical power table: - * \code - * RF_TxPowerTable_Entry txPowerTable[] = { - * { .power = 20, .value = { .rawValue = 0x1234, .paType = RF_TxPowerTable_HighPA }}, - * { .power = 19, .value = { .rawValue = 0x1233, .paType = RF_TxPowerTable_HighPA }}, - * // ... - * RF_TxPowerTable_TERMINATION_ENTRY - * }; - * \endcode - * - * \sa #RF_TxPowerTable_findPowerLevel(), #RF_TxPowerTable_findPowerLevel() - */ -typedef struct -{ - int8_t power; ///< Human readable power value representing - ///< the output in dBm. - - RF_TxPowerTable_Value value; ///< PA hardware configuration for that power level. -} __attribute__((packed)) RF_TxPowerTable_Entry; - - -/** - * \brief Selects a power amplifier path in a TX power value. - * - * %RF_TxPowerTable_PAType selects one of the available power amplifiers - * on the RF core. It is usually included in a #RF_TxPowerTable_Value. - */ -typedef enum { - RF_TxPowerTable_DefaultPA = 0, ///< Default PA - RF_TxPowerTable_HighPA = 1, ///< High-power PA -} RF_TxPowerTable_PAType; - - -/** @brief Base type for all radio operation commands. - * - * All radio operation commands share a common part. - * That includes the command id, a status field, chaining properties - * and a start trigger. - * Whenever an RF operation command is used with the RF driver, it needs - * to be casted to an RF_Op. - * - * More information about RF operation commands can be found in the Proprietary RF - * User's Guide. - * - * @sa RF_runCmd(), RF_postCmd(), RF_pendCmd() - */ -typedef rfc_radioOp_t RF_Op; - - -/** @brief Specifies a RF core firmware configuration. - * - * %RF_Mode selects a mode of operation and points to firmware patches for the RF core. - * There exists one instance per radio PHY configuration, usually generated by - * SmartRF Studio. - * After assigning %RF_Mode configuration to the RF driver via RF_open(), the - * driver caches the containing information and re-uses it on every power-up. - */ -typedef struct { - uint8_t rfMode; ///< Specifies which PHY modes should be activated. Must be set to RF_MODE_MULTIPLE for dual-mode operation. - void (*cpePatchFxn)(void); ///< Pointer to CPE patch function - void (*mcePatchFxn)(void); ///< Pointer to MCE patch function - void (*rfePatchFxn)(void); ///< Pointer to RFE patch function -} RF_Mode; - -/** @brief Scheduling priority of RF operation commands. - * - * When multiple RF driver instances are used at the same time, - * commands from different clients may overlap. - * If an RF operation with a higher priority than the currently - * running operation is scheduled by RF_scheduleCmd(), then the - * running operation is interrupted. - * - * In single-client applications, %RF_PriorityNormal should be used. - */ -typedef enum { - RF_PriorityHighest = 2, ///< Highest priority. Only use this for urgent commands. - RF_PriorityHigh = 1, ///< High priority. Use this for time-critical commands in synchronous protocols. - RF_PriorityNormal = 0, ///< Default priority. Use this in single-client applications. -} RF_Priority; - -/** @brief Status codes for various RF driver functions. - * - * RF_Stat is reported as return value for RF driver functions which - * execute direct and immediate commands. - * Such commands are executed by RF_runDirectCmd() and RF_runImmediateCmd() in the - * first place, but also by some convenience functions like RF_cancelCmd(), - * RF_flushCmd(), RF_getInfo() and others. - */ -typedef enum { - RF_StatBusyError, ///< Command not executed because RF driver is busy. - RF_StatRadioInactiveError, ///< Command not executed because RF core is powered down. - RF_StatCmdDoneError, ///< Command finished with an error. - RF_StatInvalidParamsError, ///< Function was called with an invalid parameter. - RF_StatCmdEnded, ///< Cmd is found in the pool but was already ended. - RF_StatError = 0x80, ///< General error specifier. - RF_StatCmdDoneSuccess, ///< Command finished with success. - RF_StatCmdSch, ///< Command successfully scheduled for execution. - RF_StatSuccess ///< Function finished with success. -} RF_Stat; - -/** @brief Data type for events during command execution. - * - * Possible event flags are listed in @ref RF_Core_Events and @ref RF_Driver_Events. - */ -typedef uint64_t RF_EventMask; - -/** @brief A unified type for radio setup commands of different PHYs. - * - * Radio setup commands are used to initialize a PHY on the RF core. - * Various partially similar commands exist, each one represented - * by a different data type. - * RF_RadioSetup is a generic container for all types. - * A specific setup command is usually exported from SmartRF Studio - * and then passed to the RF driver in RF_open(). - */ -typedef union { - rfc_command_t commandId; ///< Generic command identifier. This is the first field - ///< in every radio operation command. - rfc_CMD_RADIO_SETUP_t common; ///< Radio setup command for BLE and IEEE modes - rfc_CMD_BLE5_RADIO_SETUP_t ble5; ///< Radio setup command for BLE5 mode - rfc_CMD_PROP_RADIO_SETUP_t prop; ///< Radio setup command for PROPRIETARY mode on 2.4 GHz - rfc_CMD_PROP_RADIO_DIV_SETUP_t prop_div; ///< Radio setup command for PROPRIETARY mode on Sub-1 Ghz - -#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2) - rfc_CMD_RADIO_SETUP_PA_t common_pa; ///< Radio setup command for BLE and IEEE modes with High Gain PA - rfc_CMD_BLE5_RADIO_SETUP_PA_t ble5_pa; ///< Radio setup command for BLE5 mode with High Gain PA - rfc_CMD_PROP_RADIO_SETUP_PA_t prop_pa; ///< Radio setup command for PROPRIETARY mode on 2.4 GHz with High Gain PA - rfc_CMD_PROP_RADIO_DIV_SETUP_PA_t prop_div_pa; ///< Radio setup command for PROPRIETARY mode on Sub-1 Ghz with High Gain PA -#endif -} RF_RadioSetup; - -/** @brief Client-related RF driver events. - * - * Events originating in the RF driver but not directly related to a specific radio command, - * are called client events. - * Clients may subscribe to these events by specifying a callback function RF_Params::pClientEventCb. - * Events are activated by specifying a bitmask RF_Params::nClientEventMask. - * The callback is called separately for every event providing an optional argument. - * - * @code - * void onClientEvent(RF_Handle h, RF_ClientEvent event, void* arg) - * { - * switch (event) - * { - * case RF_ClientEventPowerUpFinished: - * // Set output port - * break; - * default: - * // Unsubscribed events must not be issued. - * assert(false); - * } - * } - * - * RF_Params params; - * params.pClientEventCb = &onClientEvent; - * params.nClientEventMask = RF_ClientEventPowerUpFinished; - * RF_open(...); - * @endcode - */ -typedef enum { - RF_ClientEventPowerUpFinished = (1 << 0), ///< The RF core has been powered up the radio setup has been finished. - RF_ClientEventRadioFree = (1 << 1), ///< Radio becomes free after a command has been preempted by a high-priority command of another client. - ///< This event is only triggered on a client that has been preempted. - ///< Clients may use this event to retry running their low-priority RF operation. - - RF_ClientEventSwitchClientEntered = (1 << 2) ///< Signals the client that the RF driver is about to switch over from another client. -} RF_ClientEvent; - -/** @brief Global RF driver events. - * - * The RF driver provides an interface through the global \c RFCC26XX_hwAttrs - * struct to register a global, client independent callback. This callback is - * typically used to control board related configurations such as antenna - * switches. - * - * @code - * void globalCallback(RF_Handle h, RF_GlobalEvent event, void* arg) - * { - * switch (event) - * { - * case RF_GlobalEventRadioSetup: - * { - * RF_RadioSetup* setupCommand = (RF_RadioSetup*)arg; - * // Select antenna path - * if (setupCommand->common.commandNo == CMD_PROP_RADIO_DIV_SETUP) { - * // Sub-1 GHz ... - * } else { - * // 2.4 GHz ... - * } - * } - * break; - * - * case RF_GlobalEventRadioPowerDown: - * // Disable antenna switch - * break; - * - * default: - * // Unsubscribed events must not be issued. - * assert(false); - * } - * } - * @endcode - * - * \sa #RF_GlobalCallback - */ -typedef enum { - RF_GlobalEventRadioSetup = (1 << 0), ///< The RF core is being reconfigured through a setup command. - ///< The \a arg argument is a pointer to the setup command. - ///< HWI context. - - RF_GlobalEventRadioPowerDown = (1 << 1), ///< The RF core is being powered down. - ///< The \a arg argument is empty. - ///< SWI context. -} RF_GlobalEvent; - - -/** @brief Event mask for combining #RF_ClientEvent event flags in #RF_Params::nClientEventMask. - * - */ -typedef uint32_t RF_ClientEventMask; - -/** @brief Event mask for combining #RF_GlobalEvent event flags in #RFCC26XX_HWAttrsV2::globalEventMask. - * - */ -typedef uint32_t RF_GlobalEventMask; - -/** @brief Command handle that is returned by RF_postCmd(). - * - * A command handle is an integer number greater equals zero and identifies - * a command container in the RF driver's internal command queue. A client - * can dispatch a command with RF_postCmd() and use the command handle - * later on to make the RF driver interact with the command. - * - * A negative value has either a special meaning or indicates an error. - * - * @sa RF_pendCmd(), RF_flushCmd(), RF_cancelCmd(), ::RF_ALLOC_ERROR, - * ::RF_CMDHANDLE_FLUSH_ALL - */ -typedef int16_t RF_CmdHandle; - -/** @struct RF_Object - * @brief Stores the client's internal configuration and states. - * - * Before RF_open() can be called, an instance of RF_Object must be created where - * the RF driver can store its internal configuration and states. - * This object must remain persistent throughout application run-time and must not be - * modified by the application. - * - * The size of #RF_Object can be optimized for single-mode applications by providing a - * `RF_SINGLEMODE` symbol at compilation time. The pre-built single-mode archive was generated - * with this symbol defined, hence any project using this archive must also define `RF_SINGLEMODE` - * on project level. - * - * @note Except configuration fields before call to RF_open(), modification of - * any field in %RF_Object is forbidden. - */ - - -/** @cond */ - -#if defined (RF_SINGLEMODE) - typedef struct RF_ObjectSingleMode RF_Object; +#if (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0) + #include +#elif (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2) + #include #else - typedef struct RF_ObjectMultiMode RF_Object; -#endif - -/* Definition of the RF_Object structure for single-mode applications. - * It is applicable with the single-mode RF driver through the #RF_Object common type. - */ -struct RF_ObjectSingleMode{ - /// Configuration - struct { - uint32_t nInactivityTimeout; ///< Inactivity timeout in us. - RF_Mode* pRfMode; ///< Mode of operation. - RF_RadioSetup* pRadioSetup; ///< Pointer to the setup command to be executed at power up. - uint32_t nPowerUpDuration; ///< Radio power up time to be used to calculate future wake-up events. - bool bMeasurePowerUpDuration; ///< Indicates if nPowerUpDuration holds a fix value or being measured and updated at every power up. - bool bUpdateSetup; ///< Indicates if an analog configuration update should be performed at the next setup command execution. - uint16_t nPowerUpDurationMargin; ///< Power up duration margin in us. - void* pPowerCb; ///< \deprecated Power up callback, will go away in future versions, see clientConfig::pClienteventCb instead. - void* pErrCb; ///< Error callback. - } clientConfig; - /// State & variables - struct { - struct { - rfc_CMD_FS_t cmdFs; ///< FS command to be executed when the radio is powered up. - } mode_state; ///< (Mode-specific) state structure - SemaphoreP_Struct semSync; ///< Semaphore used by RF_runCmd(), RF_pendCmd() and power down sequence. - RF_EventMask volatile eventSync; ///< Event mask/value used by RF_runCmd() and RF_pendCmd(). - void* pCbSync; ///< Internal storage of user callbacks when RF_runCmd() is used. - RF_EventMask unpendCause; ///< Internal storage of the return value of RF_pendCmd(). - bool bYielded; ///< Flag indicates that the radio can be powered down at the earliest convenience. - } state; -}; - -/** Definition of the RF_Object structure for multi mode applications. - * It is applicable with the multi mode RF driver through the #RF_Object common type. - */ -struct RF_ObjectMultiMode{ - /// Configuration - struct { - uint32_t nInactivityTimeout; ///< Inactivity timeout in us. - RF_Mode* pRfMode; ///< Mode of operation. - RF_RadioSetup* pRadioSetup; ///< Pointer to the setup command to be executed at power up. - uint32_t nPhySwitchingDuration; ///< Radio reconfiguration time to this client's phy and protocol. - uint32_t nPowerUpDuration; ///< Radio power up time to be used to calculate future wake-up events. - bool bMeasurePowerUpDuration; ///< Indicates if nPowerUpDuration holds a fix value or being measured and updated at every power up. - bool bUpdateSetup; ///< Indicates if an analog configuration update should be performed at the next setup command execution. - uint16_t nPowerUpDurationMargin; ///< Power up duration margin in us. - void* pPowerCb; ///< \deprecated Power up callback, will go away in future versions, see clientConfig::pClienteventCb instead - void* pErrCb; ///< Error callback. - void* pClientEventCb; ///< Client event callback. - RF_ClientEventMask nClientEventMask; ///< Client event mask to activate client event callback. - uint16_t nPhySwitchingDurationMargin; ///< Phy switching duration margin in us. It is used to calculate when run-time conflicts shall be resolved. - } clientConfig; - /// State & variables - struct { - struct { - rfc_CMD_FS_t cmdFs; ///< FS command to be executed when the radio is powered up. - } mode_state; ///< (Mode-specific) state structure - SemaphoreP_Struct semSync; ///< Semaphore used by RF_runCmd(), RF_pendCmd() and power down sequence. - RF_EventMask volatile eventSync; ///< Event mask/value used by RF_runCmd() and RF_pendCmd(). - void* pCbSync; ///< Internal storage of user callbacks when RF_runCmd() is used. - RF_EventMask unpendCause; ///< Internal storage of the return value of RF_pendCmd(). - ClockP_Struct clkReqAccess; ///< Clock used for request access timeout. - bool bYielded; ///< Flag indicates that the radio can be powered down at the earliest convenience. - } state; -}; - -/** @endcond */ - -/** @brief A handle that is returned by to RF_open(). - * - * %RF_Handle is used for further RF client interaction with the RF driver. - * An invalid handle has the value NULL. - */ -typedef RF_Object* RF_Handle; - - -/** @brief RAT handle that is returned by RF_ratCompare() or RF_ratCapture(). - * - * An %RF_RatHandle is an integer number with value greater than or equal to zero and identifies - * a Radio Timer Channel in the RF driver's internal RAT module. A client can interact with the - * RAT module through the RF_ratCompare(), RF_ratCapture() or RF_ratDisableChannel() APIs. - * - * A negative value indicates an error. A typical example when RF_ratCompare() returns with RF_ALLOC_ERROR. - */ -typedef int8_t RF_RatHandle; - -/** @brief Selects the entry of interest in RF_getInfo(). - * - */ -typedef enum { - RF_GET_CURR_CMD, ///< Retrieve a command handle of the current command. - RF_GET_AVAIL_RAT_CH, ///< Create a bitmask showing available RAT channels. - RF_GET_RADIO_STATE, ///< Show the current RF core power state. 0: Radio OFF, 1: Radio ON. - RF_GET_SCHEDULE_MAP, ///< Provide a timetable of all scheduled commands. - RF_GET_CLIENT_LIST, ///< Provide the client list. - RF_GET_CLIENT_SWITCHING_TIME, ///< Provide the client to client switching times -} RF_InfoType; - -/** @brief Stores output parameters for RF_getInfo(). - * - * This union structure holds one out of multiple data types. - * The contained value is selected by #RF_InfoType. - */ -typedef union { - RF_CmdHandle ch; ///< Command handle (#RF_GET_CURR_CMD). - uint16_t availRatCh; ///< Available RAT channels (RF_GET_AVAIL_RAT_CH). - bool bRadioState; ///< Current RF core power state (#RF_GET_RADIO_STATE). - RF_Handle pClientList[2]; ///< Client pointer list, [0]: client 1, [1]: client 2. - uint32_t phySwitchingTimeInUs[2]; ///< Phy switching time 0: client 1 -> 2, 1 : client 2 -> 1. - void *pScheduleMap; ///< Pointer to scheduling map (#RF_GET_SCHEDULE_MAP). -} RF_InfoVal; - -/** @brief RF schedule map entry structure. - * - */ -typedef struct { - RF_CmdHandle ch; ///< Command handle - RF_Handle pClient; ///< Pointer to client object - uint32_t startTime; ///< Start time (in RAT tick) of the command or access request - uint32_t endTime; ///< End time (in RAT tick) of the command or access request - RF_Priority priority; ///< Priority of the command or access request -} RF_ScheduleMapElement; - -/** @brief RF schedule map structure. - * - */ -typedef struct { - RF_ScheduleMapElement accessMap[RF_NUM_SCHEDULE_ACCESS_ENTRIES]; ///< Access request schedule map - RF_ScheduleMapElement commandMap[RF_NUM_SCHEDULE_COMMAND_ENTRIES]; ///< Command schedule map -} RF_ScheduleMap; - -/** @brief Handles events related to RF command execution. - * - * RF command callbacks notify the application of any events happening during RF command execution. - * Events may either refer to RF core interrupts (@ref RF_Core_Events) or may be generated by the RF driver - * (@ref RF_Driver_Events). - * - * RF command callbacks are set up as parameter to RF_postCmd() or RF_runCmd() and provide: - * - * - the relevant driver client handle \a h which was returned by RF_open(), - * - the relevant radio operation command handle \a ch, - * - an event mask \a e containing the occurred events. - * - * RF command callbacks are executed in Software Interrupt (SWI) context and must not perform any - * blocking operation. - * The priority is configurable via #RFCC26XX_HWAttrsV2 in the board file or #RF_CTRL_SET_SWI_PRIORITY in RF_control(). - * - * The %RF_Callback function type is also used for signaling power events and - * errors. - * These are set in #RF_Params::pPowerCb and #RF_Params::pErrCb respectively. - * In case of a power event, \a ch can be ignored and \a e has #RF_EventPowerUp set. - * In case of an error callback, \a ch contains an error code instead of a command handle and - * \a e has the #RF_EventError flag set. - * - * @note Error and power callbacks will be replaced by #RF_ClientCallback in future releases. - */ -typedef void (*RF_Callback)(RF_Handle h, RF_CmdHandle ch, RF_EventMask e); - -/** @brief Handles events related to the Radio Timer (RAT). - * - * The RF driver provides an interface to the Radio Timer through RF_ratCompare(), RF_ratCapture() and - * RF_ratDisableChannel() APIs. Each API call receives an optional input argument of the type - * RF_RatCallback. When a timer event occurs (compare, capture or error events), the registered - * callback is invoked. - * - * The RF_RatCallback provides the following argument: - * - the relevant driver client handle \a h which was returned by RF_open(), - * - the relevant rat timer handle \a rh which the event is caused by, - * - an event mask \a e containing the occurred event (RF_EventRatCh or RF_EventError) - * - the captured value or the compare time \a compareCaptureTime read from the Radio Timer channel. - */ -typedef void (*RF_RatCallback)(RF_Handle h, RF_RatHandle rh, RF_EventMask e, uint32_t compareCaptureTime); - -/** - * @brief Handles events related to a driver instance. - * - * The RF driver produces additional events that are not directly related to the execution of a certain command, but - * happen during general RF driver operations. - * This includes power-up events, client switching events and others. - * - * A client callback provides the following arguments: - * - the relevant driver client handle \a h which was returned by RF_open(), - * - an event identifier \a event, - * - an optional argument \a arg depending on the event. - * - * RF client callbacks are executed in Software Interrupt (SWI) context and must not perform any blocking operation. - * The priority is configurable via #RFCC26XX_HWAttrsV2 in the board file or #RF_CTRL_SET_SWI_PRIORITY in RF_control(). - */ -typedef void (*RF_ClientCallback)(RF_Handle h, RF_ClientEvent event, void* arg); - -/** - * @brief Handles global events as part of PHY configuration. - * - * The RF driver serves additional global, client independent events by invoking the #RF_GlobalCallback function - * registered through #RFCC26XX_HWAttrsV2::globalCallback in the board file. The function can subscribe to - * particular events through the #RFCC26XX_HWAttrsV2::globalEventMask, and receives the following arguments: - * - the relevant driver client handle \a h which was returned by RF_open(), - * - an event identifier \a event, - * - an optional argument \a arg depending on the event. - * - * If multiple events happen at the same time, the callback is always invoked separately for each event. - * Depending on the event, the callback might be invoked in SWI or HWI context. - */ -typedef void (*RF_GlobalCallback)(RF_Handle h, RF_GlobalEvent event, void* arg); - -/** @brief RF driver configuration parameters. - * - * %RF_Params is used for initial RF driver configuration. - * It is initialized by RF_Params_init() and used by RF_open(). - * Each client has its own set of parameters. - * They are reconfigured on a client switch. - * Some of the parameters can be changed during run-time using RF_control(). - */ -typedef struct { - uint32_t nInactivityTimeout; ///< Inactivity timeout in microseconds. - ///< The default value is 0xFFFFFFFF (infinite). - - uint32_t nPowerUpDuration; ///< A custom power-up duration in microseconds. - ///< If 0, the RF driver will start with a conservative value and measure the actual time during the first power-up. - ///< The default value is 0. - - RF_Callback pPowerCb; ///< \deprecated Power up callback, will be removed future versions, see RF_Params::pClienteventCb instead. - ///< The default value is NULL. - - RF_Callback pErrCb; ///< \deprecated Callback function for driver error events. - - uint16_t nPowerUpDurationMargin; ///< An additional safety margin to be added to #RF_Params::nPowerUpDuration. - ///< This is necessary because of other hardware and software interrupts - ///< preempting the RF driver interrupt handlers and state machine. - ///< The default value is platform-dependent. - - uint16_t nPhySwitchingDurationMargin; ///< An additional safety margin to be used to calculate when conflicts shall be evaluated run-time. - - RF_ClientCallback pClientEventCb; ///< Callback function for client-related events. - ///< The default value is NULL. - - RF_ClientEventMask nClientEventMask; ///< Event mask used to subscribe certain client events. - ///< The purpose is to keep the number of callback executions small. -} RF_Params; - -/* RF command. */ -typedef struct RF_Cmd_s RF_Cmd; - -/* RF command . */ -struct RF_Cmd_s { - List_Elem _elem; /* Pointer to next and previous elements. */ - RF_Callback volatile pCb; /* Pointer to callback function */ - RF_Op* pOp; /* Pointer to (chain of) RF operations(s) */ - RF_Object* pClient; /* Pointer to client */ - RF_EventMask bmEvent; /* Enable mask for interrupts from the command */ - RF_EventMask pastifg; /* Accumulated value of events happened within a command chain */ - RF_EventMask rfifg; /* Return value for callback 0:31 - RF_CPE0_INT, 32:63 - RF_HW_INT */ - uint32_t startTime; /* Command start time (in RAT ticks) */ - uint32_t endTime; /* Command end time (in RAT ticks) */ - uint32_t allowDelay; /* Delay allowed if the start time cannot be met. */ - RF_CmdHandle ch; /* Command handle */ - RF_Priority ePri; /* Priority of RF command */ - uint8_t volatile flags; /* [0: Aborted, 1: Stopped, 2: canceled] */ -}; - -/** @brief RF Hardware attributes. - * - * This data structure contains platform-specific driver configuration. - * It is usually defined globally in a board support file. - */ -typedef struct { - uint8_t hwiPriority; ///< Priority for HWIs belong to the RF driver. - uint8_t swiPriority; ///< Priority for SWIs belong to the RF driver. - bool xoscHfAlwaysNeeded; ///< Indicate that the XOSC HF should be turned on by the power driver - RF_GlobalCallback globalCallback; ///< Pointer to a callback function serving client independent events listed in #RF_GlobalEvent. - RF_GlobalEventMask globalEventMask; ///< Event mask which the globalCallback is invoked upon. -} RFCC26XX_HWAttrsV2; - -/** @brief Controls the behavior of the state machine of the RF driver when a conflict is identified - * run-time between the commands waiting on the pend queue and the commands being actively executed - * by the radio. - */ -typedef enum -{ - RF_ConflictNone = 0, - RF_ConflictReject = 1, - RF_ConflictAbort = 2, -} RF_Conflict; - -/** @brief Describes the location within the pend queue where the new command was inserted by the scheduler. - */ -typedef enum -{ - RF_ScheduleStatusError = -3, - RF_ScheduleStatusNone = 0, - RF_ScheduleStatusTop = 1, - RF_ScheduleStatusMiddle = 2, - RF_ScheduleStatusTail = 4, - RF_ScheduleStatusPreempt = 8 -} RF_ScheduleStatus; - -/** - * @brief Handles the queue sorting algorithm when a new command is submitted to the driver from any of - * the active clients. - * - * The function is invoked within the RF_scheduleCmd API. - * - * The default algorithm is subscribed through the #RFCC26XX_SchedulerPolicy::submitHook and implemented - * in the RF driver. The arguments are: - * - \a pCmdNew points to the command to be submitted. - * - \a pCmdBg is the running background command. - * - \a pCmdFg is the running foreground command. - * - \a pPendQueue points to the head structure of pend queue. - * - \a pDoneQueue points to the head structure of done queue. - * - * In case the radio APIs do not distinguish between background and foreground contexts, the active operation - * will be returned within the pCmdBg pointer. If there are no commands being executed, both the - * pCmdBg and pCmdFg pointers are returned as NULL. - */ -typedef RF_ScheduleStatus (*RF_SubmitHook)(RF_Cmd* pCmdNew, RF_Cmd* pCmdBg, RF_Cmd* pCmdFg, List_List* pPendQueue, List_List* pDoneQueue); - -/** - * @brief Defines the conflict resolution in runtime. - * - * The function is invoked if a conflict is identified before the start-time of the next radio command in - * the pending queue. The return value of type #RF_Conflict determines the policy to be followed by the RF driver. - * - * The arguments are: - * - \a pCmdBg is the running background command. - * - \a pCmdFg is the running foreground command. - * - \a pPendQueue points to the head structure of pend queue. - * - \a pDoneQueue points to the head structure of done queue. - */ -typedef RF_Conflict (*RF_ConflictHook)(RF_Cmd* pCmdBg, RF_Cmd* pCmdFg, List_List* pPendQueue, List_List* pDoneQueue); - -/** @brief RF scheduler policy. - * - * This data structure contains function hooks which implements the scheduling - * algorithm used to inter-align one or more independent protocol stacks. - */ -typedef struct { - RF_SubmitHook submitHook; ///< Function hook implements the scheduling policy to be executed at the time of RF_scheduleCmd API call. - RF_ConflictHook conflictHook; ///< Function hook implements the runtime conflict resolution, if any identified at the start time of next command. -} RFCC26XX_SchedulerPolicy; - -/** @brief Controls the behavior of the RF_scheduleCmd() API. - * - */ -typedef enum { - RF_AllowDelayNone = 0, - RF_AllowDelayAny = UINT32_MAX -} RF_AllowDelay; - -/* @brief RF schedule command parameter struct - * - * RF schedule command parameters are used with the RF_scheduleCmd() call. - */ -typedef struct { - uint32_t endTime; ///< End time in RAT Ticks for the radio command - RF_Priority priority; ///< Intra client priority - uint32_t allowDelay; ///< Control word to define the policy of the scheduler if the timing of a command cannot be met. - ///< Only applicable on CC13x2 and CC26x2 devices. - ///< RF_AllowDelayNone: Reject the command. - ///< RF_AllowDelayAny: Append the command to the end of the queue. -} RF_ScheduleCmdParams; - -/** @brief RF request access parameter struct - * - * RF request access command parameters are used with the RF_requestAccess() call. - */ -typedef struct { - uint32_t duration; ///< Radio access duration in RAT Ticks requested by the client - uint32_t startTime; ///< Start time window in RAT Time for radio access - RF_Priority priority; ///< Access priority -} RF_AccessParams; - -/** @brief Select the preferred RAT channel through the configuration of #RF_ratCompare() or #RF_ratCapture(). - * - * If RF_RatChannelAny is provided within the channel configuration (default), the API will - * allocate the first available channel. Otherwise, it tries to allocate the requested channel, - * and if it is not available, returns with #RF_ALLOC_ERROR. - */ -typedef enum { - RF_RatChannelAny = -1, ///< Chose the first available channel. - RF_RatChannel0 = 0, ///< Use RAT user channel 0. - RF_RatChannel1 = 1, ///< Use RAT user channel 1. - RF_RatChannel2 = 2, ///< Use RAT user channel 2. -} RF_RatSelectChannel; - -/** @brief Selects the source signal for #RF_ratCapture(). - * - * The source of a capture event can be selected through the source field of the - * #RF_RatConfigCapture configuration structure. - */ -typedef enum { - RF_RatCaptureSourceRtcUpdate = 20, ///< Selects the RTC update signal source. - RF_RatCaptureSourceEventGeneric = 21, ///< Selects the Generic event of Event Fabric as source. - RF_RatCaptureSourceRfcGpi0 = 22, ///< Selects the RFC_GPI[0] as source. This can be used i.e. - ///< to capture events on a GPIO. This requires that the GPIO - ///< is connected to RFC_GPO[0] from the GPIO driver. - RF_RatCaptureSourceRfcGpi1 = 23 ///< Selects the RFC_GPO[1] as source. This can be used i.e. - ///< to capture events on a GPIO. This requires that the GPIO - ///< is connected to RFC_GPO[1] from the GPIO driver. -} RF_RatCaptureSource; - -/** @brief Selects the mode of #RF_ratCapture(). - * - * The trigger mode of a capture event can be selected through the mode field of - * #RF_RatConfigCapture configuration structure. - */ -typedef enum { - RF_RatCaptureModeRising = 0, ///< Rising edge of the selected source will trigger a capture event. - RF_RatCaptureModeFalling = 1, ///< Falling edge of the selected source will trigger a capture event. - RF_RatCaptureModeBoth = 2 ///< Both rising and falling edges of the selected source will generate - ///< capture events. -} RF_RatCaptureMode; - -/** @brief Selects the repetition of #RF_ratCapture(). - * - * The configuration of a capture channel also defines whether the channel should be - * freed or automatically rearmed after a capture event occurred. In the latter case, the - * user needs to free the channel manually through the #RF_ratDisableChannel() API. - */ -typedef enum { - RF_RatCaptureSingle = 0, ///< Free the channel after the first capture event. - RF_RatCaptureRepeat = 1 ///< Rearm the channel after each capture events. -} RF_RatCaptureRepetition; - -/** @brief Selects the mode of the RAT_GPO[x] for #RF_ratCompare() or #RF_ratCapture(). - * - * In case of compare mode, the channel can generate an output signal of the selected - * mode on the configured RAT_GPO[x] interface, and can be interconnected with - * other subsystems through the RFC_GPO[x] or Event Fabric. An example use case is - * to generate a pulse on a GPIO. - * - * In case of capture mode, the channel can also generate an output signal of the - * selected mode on the configured RAT_GPO[x] interface. Note that the configuration - * of this output event is independent of the source signal of the capture event. - * An example use case is to generate a pulse on a GPIO on each raising edge of another - * GPIO source. - * - */ -typedef enum { - RF_RatOutputModePulse = 0, ///< Generates a one-clock period width pulse. - RF_RatOutputModeSet = 1, ///< Sets the output high on a RAT event. - RF_RatOutputModeClear = 2, ///< Sets the output low on a RAT event. - RF_RatOutputModeToggle = 3, ///< Inverts the polarity of the output. - RF_RatOutputModeAlwaysZero = 4, ///< Sets the output low independently of any RAT events. - RF_RatOutputModeAlwaysOne = 5, ///< Sets the output high independently of any RAT events. -} RF_RatOutputMode; - -/** @brief Selects GPO to be used with #RF_ratCompare() or #RF_ratCapture(). - * - * RAT_GPO[0] - Reserved by the RF core. User shall not modify the configuration, - * but can observe the signal through any of RFC_GPO[0:3]. - * RAT_GPO[1] - Reserved by the RF core only if sync word detection is enabled. - * Otherwise can be used through RFC_GPO[0:3]. - * RAT_GPO[2:3] - Available and can be used through any of the RFC_GPO[0:3]. - * RAT_GPO[4:7] - Available and can be used through the Event fabric. - */ -typedef enum { - RF_RatOutputSelectRatGpo1 = 1, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[1] - RF_RatOutputSelectRatGpo2 = 2, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[2] - RF_RatOutputSelectRatGpo3 = 3, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[3] - RF_RatOutputSelectRatGpo4 = 4, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[4] - RF_RatOutputSelectRatGpo5 = 5, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[5] - RF_RatOutputSelectRatGpo6 = 6, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[6] - RF_RatOutputSelectRatGpo7 = 7, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[7] -} RF_RatOutputSelect; - -/** @brief RF_ratCapture parameter structure. - * - * %RF_RatCapture parameters are used with the #RF_ratCapture() call. - */ -typedef struct { - RF_RatCallback callback; ///< Callback function to be invoked upon a capture event (optional). - RF_RatHandle channel; ///< RF_RatHandle identifies the channel to be allocated. - RF_RatCaptureSource source; ///< Configuration of the event source to cause a capture event. - RF_RatCaptureMode captureMode; ///< Configuration of the mode of event to cause a capture event. - RF_RatCaptureRepetition repeat; ///< Configuration of the channel to be used in single or repeated mode. -} RF_RatConfigCapture; - -/** @brief RF_ratCompare parameter structure. - * - * %RF_RatCompare parameters are used with the #RF_ratCompare() call. - */ -typedef struct { - RF_RatCallback callback; ///< Callback function to be invoked upon a capture event (optional). - RF_RatHandle channel; ///< RF_RatHandle identifies the channel to be allocated. - uint32_t timeout; ///< Timeout value in RAT ticks to be programmed in the timer as the - ///< trigger of compare event. -} RF_RatConfigCompare; - -/** @brief RAT related IO parameter structure. - * - * These parameters are used with the #RF_ratCompare() or #RF_ratCapture() calls. - */ -typedef struct { - RF_RatOutputMode mode; ///< The mode the GPO should operate in. - RF_RatOutputSelect select; ///< The signal which shall be connected to the GPO. -} RF_RatConfigOutput; - -/** @brief Creates a a new client instance of the RF driver. - * - * This function initializes an RF driver client instance using \a pObj as storage. - * It does not power up the RF core. - * Once the client starts the first RF operation command later in the application, - * the RF core is powered up and set into a PHY mode specified by \a pRfMode. - * The chosen PHY is then configured by a radio setup command \a pRadioSetup. - * Whenever the RF core is powered up, the RF driver re-executes the radio setup command \a pRadioSetup. - * Additional driver behavior may be set by an optional \a params. - * - * @code - * // Define parameters - * RF_Params rfParams; - * rfParams.nInactivityTimeout = 4; - * RF_Params_init(&rfParams); - * rfParams.nInactivityTimeout = 1701; // microseconds - * - * RF_Handle rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams); - * @endcode - * - * @note Calling context : Task - * - * @param pObj Pointer to a #RF_Object that will hold the state for this - * RF client. The object must be in persistent and writable - * memory. - * @param pRfMode Pointer to a #RF_Mode struct holding PHY information - * @param pRadioSetup Pointer to the radio setup command used for this client. - * This is re-executed by the RF Driver on each power-up. - * @param params Pointer to an RF_Params object with the desired driver configuration. - * A NULL pointer results in the default configuration being loaded. - * @return A handle for further RF driver calls on success. Otherwise NULL. - */ -extern RF_Handle RF_open(RF_Object *pObj, RF_Mode *pRfMode, RF_RadioSetup *pRadioSetup, RF_Params *params); - -/** - * @brief Close client connection to RF driver - * - * Allows a RF client (high-level driver or application) to close its connection - * to the RF driver. - * - * @note Calling context : Task - * - * @param h Handle previously returned by RF_open() - */ -extern void RF_close(RF_Handle h); - -/** - * @brief Return current radio timer value - * - * If the radio is powered returns the current radio timer value, if not returns - * a conservative estimate of the current radio timer value - * - * @note Calling context : Task/SWI/HWI - * - * @return Current radio timer value - */ -extern uint32_t RF_getCurrentTime(void); - -/** - * @brief Appends RF operation commands to the driver's command queue and returns a - * command handle. - * - * The RF operation \a pOp may either represent a single operation or may be the first - * operation in a chain. - * If the command queue is empty, the \a pCmd is dispatched immediately. If there are - * other operations pending, then \a pCmd is processed after all other commands have been - * finished. - * The RF operation command must be compatible to the RF_Mode selected by RF_open(), e.g. - * proprietary commands can only be used when the RF core is configured for proprietary mode. - * - * The returned command handle is an identifier that can be used to control command execution - * later on, for instance with RF_pendCmd() or RF_cancelCmd(). - * It is a 16 Bit signed integer value, incremented on every new command. - * If the RF driver runs out of command containers, RF_ALLOC_ERROR is returned. - * - * The priority \a ePri is only relevant in multi-client applications where commands of distinct - * clients may interrupt each other. - * Only commands started by RF_scheduleCmd() can preempt - * running commands. #RF_postCmd() or RF_runCmd() do never interrupt a running command. - * In single-client applications, \a ePri is ignored and should be set to ::RF_PriorityNormal. - * - * A callback function \a pCb might be specified to get notified about events during command - * execution. Events are subscribed by the bit mask \a bmEvent. - * Valid event flags are specified in @ref RF_Core_Events and @ref RF_Driver_Events. - * If no callback is set, RF_pendCmd() can be used to synchronize the current task to command - * execution. For this it is necessary to subscribe all relevant events. - * The termination events ::RF_EventLastCmdDone, ::RF_EventCmdCancelled, ::RF_EventCmdAborted and - * ::RF_EventCmdStopped are always implicitly subscribed. - * - * The following limitations apply to the execution of command chains: - * - * - If TRIG_ABSTIME is used as a start trigger for the first command, TRIG_REL_FIRST_START - * can not be used for any other command. This is because the RF driver may insert a - * frequency-select command (CMD_FS) at the front of the chain when it performs an - * automatic power-up. - * - Having more than one CMD_FS in a chain may lead to unexpected behavior. - * If a chain contains a CMD_FS and the command can be reached by iterating over the pNextOp - * field, then RF driver will always update the cached CMD_FS with the new settings. On the - * next automatic power-up, the RF driver will use the updated frequency. - * - * @note Calling context : Task/SWI - * - * @sa RF_pendCmd(), RF_runCmd(), RF_scheduleCmd(), RF_RF_cancelCmd(), RF_flushCmd(), RF_getCmdOp() - * - * @param h Driver handle previously returned by RF_open() - * @param pOp Pointer to the RF operation command. - * @param ePri Priority of this RF command (used for arbitration in multi-client systems) - * @param pCb Callback function called during command execution and upon completion. - * If RF_postCmd() fails, no callback is made. - * @param bmEvent Bitmask of events that will trigger the callback or that can be pended on. - * @return A handle to the RF command. Return value of RF_ALLOC_ERROR indicates error. - */ -extern RF_CmdHandle RF_postCmd(RF_Handle h, RF_Op *pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent); - -/** - * @brief Sorts and adds commands to the RF driver internal command queue. - * - * @param pCmdNew Pointer to the command to be submitted. - * @param pCmdBg Running background command. - * @param pCmdFg Running foreground command. - * @param pPendQueue Pointer to the head structure of pend queue. - * @param pDoneQueue Pointer to the head structure of done queue.. - * @return RF_defaultSubmitPolicy identifies the success or failure of queuing. - */ -extern RF_ScheduleStatus RF_defaultSubmitPolicy(RF_Cmd* pCmdNew, RF_Cmd* pCmdBg, RF_Cmd* pCmdFg, List_List* pPendQueue, List_List* pDoneQueue); - -/** - * @brief Makes a final decision when a conflict in run-time is identified. - * - * @param pCmdBg Running background command. - * @param pCmdFg Running foreground command. - * @param pPendQueue Pointer to the head structure of pend queue. - * @param pDoneQueue Pointer to the head structure of done queue.. - * @return RF_defaultSubmitPolicy identifies the success or failure of queuing. - */ -extern RF_Conflict RF_defaultConflictPolicy(RF_Cmd* pCmdBg, RF_Cmd* pCmdFg, List_List* pPendQueue, List_List* pDoneQueue); - - -/** - * @brief Initialize the configuration structure to default values to be used with the RF_scheduleCmd() API. - * - * @note Calling context : Task/SWI/HWI - * - * @param pSchParams Pointer to the configuration structure. - * @return none - */ -extern void RF_ScheduleCmdParams_init(RF_ScheduleCmdParams *pSchParams); - -/** - * @brief Schedule an RF operation (chain) to the command queue. - * - * Schedule an #RF_Op to the RF command queue of the client with handle h.
- * The command can be the first in a chain of RF operations or a standalone RF operation. - * If a chain of operations are posted they are treated atomically, i.e. either all - * or none of the chained operations are run.
- * All operations must be posted in strictly increasing chronological order. Function returns - * immediately.
- * - * Limitations apply to the operations posted: - * - The operation must be in the set supported in the chosen radio mode when - * RF_open() was called - * - Only a subset of radio operations are supported - * - Only some of the trigger modes are supported with potential power saving (TRIG_NOW, TRIG_ABSTIME) - * - * @note Calling context : Task/SWI - * - * @param h Handle previously returned by RF_open() - * @param pOp Pointer to the #RF_Op. Must normally be in persistent and writable memory - * @param pSchParams Pointer to the schedule command parameter structure - * @param pCb Callback function called upon command completion (and some other events). - * If RF_scheduleCmd() fails no callback is made - * @param bmEvent Bitmask of events that will trigger the callback. - * @return A handle to the RF command. Return value of RF_ALLOC_ERROR indicates error. - */ -extern RF_CmdHandle RF_scheduleCmd(RF_Handle h, RF_Op *pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent); - -/** - * @brief Synchronizes the calling task to an RF operation command \a ch and - * returns accumulated event flags. - * - * After having dispatched an RF operation represented by \a ch with RF_postCmd(), the - * command is running in parallel on the RF core. Thus, it might be desirable to synchronize - * the calling task to the execution of the command. - * With #RF_pendCmd(), the application can block until one of the events specified in - * \a bmEvent occurs or until the command finishes. - * The function consumes and returns all accumulated event flags that occurred during - * execution if they have been previously subscribed by RF_postCmd(). - * Possible events are specified in @ref RF_Core_Events and @ref RF_Driver_Events. - * The termination events ::RF_EventLastCmdDone, ::RF_EventCmdCancelled, - * ::RF_EventCmdAborted and ::RF_EventCmdStopped are always implicitly subscribed and - * can not be masked. - * - * #RF_pendCmd() may be called multiple times for the same command. - * - * If #RF_pendCmd() is called for a command handle representing a finished command, - * then only the ::RF_EventLastCmdDone flag is returned, regardless of how the command - * finished. - * - * If the command has also a callback set, the callback is executed before #RF_pendCmd() - * returns. - * - * Example: - * @code - * // Dispatch a command to the RF driver's command queue - * RF_CmdHandle ch = RF_postCmd(driver, (RF_Op*)&CMD_PROP_RX, RF_PriorityNormal, NULL, RF_EventRxEntryDone); - * assert(ch != RF_ALLOC_ERROR); - * - * bool finished = false; - * while (finished == false) - * { - * // Synchronize to events during command execution. - * uint32_t events = RF_pendCmd(driver, ch, RF_EventRxEntryDone); - * // Check events that happen during execution - * if (events & RF_EventRxEntryDone) - * { - * // Process packet - * } - * if (events & (RF_EventLastCmdDone | RF_EventCmdStopped | RF_EventCmdAborted | RF_EventCmdCancelled)) - * { - * finished = true; - * } - * // ... - * } - * @endcode - * - * @note Calling context : Task - * - * @param h Driver handle previously returned by RF_open() - * @param ch Command handle previously returned by RF_postCmd(). - * @param bmEvent Bitmask of events that make RF_pendCmd() return. Termination events - * are always implicitly subscribed. - * @return Event flags accumulated during command execution. - * - * @sa RF_postCmd() - */ -extern RF_EventMask RF_pendCmd(RF_Handle h, RF_CmdHandle ch, RF_EventMask bmEvent); - -/** - * @brief Runs synchronously an RF operation command or a chain of commands and returns - * the termination reason. - * - * This function appends an RF operation command or a chain of commands to the RF driver's - * command queue and then waits for it to complete. - * A command is completed if one of the termination events ::RF_EventLastCmdDone, - * ::RF_EventCmdCancelled, ::RF_EventCmdAborted, ::RF_EventCmdStopped occurred. - * - * This function is a combination of RF_postCmd() and RF_pendCmd(). - * All options and limitations for RF_postCmd() apply here as well. - * - * An application should always ensure that the command completed in the expected way and - * with an expected status code. - * - * @note Calling context : Task - * - * @param h Driver handle previously returned by RF_open() - * @param pOp Pointer to the RF operation command. - * @param ePri Priority of this RF command (used for arbitration in multi-client systems) - * @param pCb Callback function called during command execution and upon completion. - * If RF_runCmd() fails, no callback is made. - * @param bmEvent Bitmask of events that will trigger the callback or that can be pended on. - * @return The relevant termination event. - * - * @sa RF_postCmd(), RF_pendCmd(), RF_cancelCmd(), RF_flushCmd() - */ -extern RF_EventMask RF_runCmd(RF_Handle h, RF_Op *pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent); - -/** - * @brief Runs synchronously a (chain of) RF operation(s) for dual or single-mode. - * - * Allows a (chain of) operation(s) to be scheduled to the command queue and then waits - * for it to complete.
A command is completed if one of the RF_EventLastCmdDone, - * RF_EventCmdCancelled, RF_EventCmdAborted, RF_EventCmdStopped occurred. - * - * @note Calling context : Task - * @note Only one call to RF_pendCmd() or RF_runScheduleCmd() can be made at a time for - * each client - * - * @param h Handle previously returned by RF_open() - * @param pOp Pointer to the #RF_Op. Must normally be in persistent and writable memory - * @param pSchParams Pointer to the schedule command parameter structure - * @param pCb Callback function called upon command completion (and some other events). - * If RF_runScheduleCmd() fails, no callback is made. - * @param bmEvent Bitmask of events that will trigger the callback. - * @return The relevant command completed event. - */ -extern RF_EventMask RF_runScheduleCmd(RF_Handle h, RF_Op *pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent); - -/** - * @brief Abort/stop/cancel single command in command queue. - * - * If command is running, aborts/stops it and posts callback for the - * aborted/stopped command.
- * If command has not yet run, cancels it it and posts callback for the - * canceled command.
- * If command has already run or been aborted/stopped/canceled, has no effect.
- * If RF_cancelCmd is called from a Swi context with same or higher priority - * than RF Driver Swi, when the RF core is powered OFF -> the cancel callback will be delayed - * until the next power-up cycle.
- * - * @note Calling context : Task/SWI - * - * @param h Handle previously returned by RF_open() - * @param ch Command handle previously returned by RF_postCmd(). - * @param mode 1: Stop gracefully, 0: abort abruptly - * @return RF_Stat indicates if command was successfully completed - */ -extern RF_Stat RF_cancelCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode); - -/** - * @brief Abort/stop/cancel command and any subsequent commands in command queue. - * - * If command is running, aborts/stops it and then cancels all later commands in queue.
- * If command has not yet run, cancels it and all later commands in queue.
- * If command has already run or been aborted/stopped/canceled, has no effect.
- * The callbacks for all canceled commands are issued in chronological order.
- * If RF_flushCmd is called from a Swi context with same or higher priority - * than RF Driver Swi, when the RF core is powered OFF -> the cancel callback will be delayed - * until the next power-up cycle.
- * - * @note Calling context : Task/SWI - * - * @param h Handle previously returned by RF_open() - * @param ch Command handle previously returned by RF_postCmd(). - * @param mode 1: Stop gracefully, 0: abort abruptly - * @return RF_Stat indicates if command was successfully completed - */ -extern RF_Stat RF_flushCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode); - -/** - * @brief Send any Immediate command.
- * - * Immediate Command is send to RDBELL, if radio is active and the RF_Handle points - * to the current client.
- * In other appropriate RF_Stat values are returned.
- * - * @note Calling context : Task/SWI/HWI - * - * @param h Handle previously returned by RF_open() - * @param pCmdStruct Pointer to the immediate command structure - * @return RF_Stat indicates if command was successfully completed - */ -extern RF_Stat RF_runImmediateCmd(RF_Handle h, uint32_t *pCmdStruct); - -/** - * @brief Send any Direct command.
- * - * Direct Command value is send to RDBELL immediately, if radio is active and - * the RF_Handle point to the current client.
- * In other appropriate RF_Stat values are returned.
- * - * @note Calling context : Task/SWI/HWI - * - * @param h Handle previously returned by RF_open() - * @param cmd Direct command value. - * @return RF_Stat indicates if command was successfully completed. - */ -extern RF_Stat RF_runDirectCmd(RF_Handle h, uint32_t cmd); - -/** - * @brief Signal that radio client is not going to issue more commands in a while.
- * - * Hint to RF driver that, irrespective of inactivity timeout, no new further - * commands will be issued for a while and thus the radio can be powered down at - * the earliest convenience. In case the RF_yield() is called within a callback, - * the callback will need to finish and return before the power down sequence is - * initiated. Posting new commands to the queue will cancel any pending RF_yield() - * request.
- * - * @note Calling context : Task - * - * @param h Handle previously returned by RF_open() - */ -extern void RF_yield(RF_Handle h); - -/** - * @brief Function to initialize the RF_Params struct to its defaults. - * - * @param params An pointer to RF_Params structure for - * initialization - * - * Defaults values are: - * nInactivityTimeout = BIOS_WAIT_FOREVER - * nPowerUpDuration = RF_DEFAULT_POWER_UP_TIME - */ -extern void RF_Params_init(RF_Params *params); - -/** - * @brief Get value for some RF driver parameters.
- * - * @note Calling context : Task/SWI/HWI - * - * @param h Handle previously returned by RF_open() - * @param type Request value parameter defined by RF_InfoType - * @param pValue Pointer to return parameter values specified by RF_InfoVal - * @return RF_Stat indicates if command was successfully completed - */ -extern RF_Stat RF_getInfo(RF_Handle h, RF_InfoType type, RF_InfoVal *pValue); - -/** - * @brief Get RSSI value. - * - * @note Calling context : Task/SWI/HWI - * - * @param h Handle previously returned by RF_open() - * @return RSSI value. Return value of RF_GET_RSSI_ERROR_VAL indicates error case. - */ -extern int8_t RF_getRssi(RF_Handle h); - -/** - * @brief Get command structure pointer. - * - * @note Calling context : Task/SWI/HWI - * - * @param h Handle previously returned by RF_open() - * @param cmdHnd Command handle returned by RF_postCmd() - * @return Pointer to the command structure. - */ -extern RF_Op* RF_getCmdOp(RF_Handle h, RF_CmdHandle cmdHnd); - -/** - * @brief Initialize the configuration structure to be used to set up a RAT compare event. - * - * @note Calling context : Task/SWI/HWI - * - * @param channelConfig Pointer to the compare configuration structure. - * @return none - */ -extern void RF_RatConfigCompare_init(RF_RatConfigCompare* channelConfig); - -/** - * @brief Initialize the configuration structure to be used to set up a RAT capture event. - * - * @note Calling context : Task/SWI/HWI - * - * @param channelConfig Pointer to the capture configuration structure. - * @return none - */ -extern void RF_RatConfigCapture_init(RF_RatConfigCapture* channelConfig); - -/** - * @brief Initialize the configuration structure to be used to set up a RAT IO. - * - * @note Calling context : Task/SWI/HWI - * - * @param ioConfig Pointer to the IO configuration structure. - * @return none - */ -extern void RF_RatConfigOutput_init(RF_RatConfigOutput* ioConfig); - -/** - * @brief Setup a Radio Timer (RAT) channel in compare mode. - * - * The %RF_ratCompare() API sets up one of the three available RAT channels in compare mode. - * When the compare event happens at the given compare time, the registered callback - * is invoked. - * - * The RF driver handles power management. If the provided compare time is far into the future - * (and there is no other constraint set i.e. due to radio command execution), the RF core will be - * powered OFF and the device will enter the lowest possible power state. The RF core will be - * automatically powered ON just before the registered compare event. The callback function is - * served upon expiration of the allocated channel. The function is invoked with event type - * #RF_EventRatCh and runs in SWI context. - * - * The API generates a "one-shot" compare event. Since the channel is automatically freed before - * the callback is served, the same channel can be reallocated from the callback itself through a - * new API call. - * - * In case there were no available channels at the time of API call, the function returns with - * #RF_ALLOC_ERROR and no callback is invoked. - * - * In case a runtime error occurs after the API successfully allocated a channel, the registered - * callback is invoked with event type #RF_EventError. A typical example is when the provided compare - * time is in the past and rejected by the RF core itself. - * - * The events issued by the RAT timer can be output from the timer module through the RAT_GPO - * interface, and can be interconnected with other parts of the system through the RFC_GPO or - * the Event Fabric. The mapping between the allocated RAT channel and the selected RAT_GPO - * can be controlled through the optional ioConfig argument of %RF_ratCompare(). The possible - * RAT_GPO[x] are defined in #RF_RatOutputSelect. - * - * @note Calling context : Task/SWI - * - * @param rfHandle Handle previously returned by RF_open(). - * @param channelConfig Pointer to configuration structure needed to set up a channel in compare mode. - * @param ioConfig Pointer to a configuration structure to set up the RAT_GPOs for the allocated - * channel (optional). - * @return Allocated RAT channel. If allocation fails, #RF_ALLOC_ERROR is returned. - * - * \sa #RF_RatConfigCompare_init(), #RF_RatConfigOutput_init(), #RF_ratDisableChannel(), #RF_ratCapture() - */ -extern RF_RatHandle RF_ratCompare(RF_Handle rfHandle, RF_RatConfigCompare* channelConfig, RF_RatConfigOutput* ioConfig); - -/** - * @brief Setup a Radio Timer (RAT) channel in capture mode. - * - * The %RF_ratCapture() API sets up one of the three available RAT channels in capture mode. - * The registered callback is invoked on the capture event. - * - * The RF driver handles power management. If the RF core is OFF when the %RF_ratCapture() is called, - * it will be powered ON immediately and the RAT channel will be configured to capture mode. As long as - * at least one of the three RAT channels are in capture mode, the RF core will be kept ON. The callback - * function is served upon a capture event occurs. The function is invoked with event type RF_EventRatCh - * and runs in SWI context. - * - * In case the channel is configured into single capture mode, the channel is automatically freed before - * the callback is called. In repeated capture mode, the channel remains allocated and automatically rearmed. - * - * In case there were no available channels at the time of API call, the function returns with - * #RF_ALLOC_ERROR and no callback is invoked. - * - * In case a runtime error occurs after the API successfully allocated a channel, the registered - * callback is invoked with event type #RF_EventError. A typical example is when the provided compare - * time is in the past and rejected by the RF core itself. - * - * The events issued by the RAT timer can be output from the timer module through the RAT_GPO - * interface, and can be interconnected with other parts of the system through the RFC_GPO or - * the Event Fabric. The mapping between the allocated RAT channel and the selected RAT_GPO - * can be controlled through the optional ioConfig argument of %RF_ratCapture(). The possible - * RAT_GPO[x] are defined in #RF_RatOutputSelect. Note that this configuration is independent of - * the source signal of the capture event. - * - * @note Calling context : Task/SWI - * - * @param rfHandle Handle previously returned by RF_open(). - * @param channelConfig Pointer to configuration structure needed to set up a channel in compare mode. - * @param ioConfig Pointer to a configuration structure to set up the RAT_GPO for the allocated - * channel (optional). - * @return Allocated RAT channel. If allocation fails, #RF_ALLOC_ERROR is returned. - * - * \sa #RF_RatConfigCapture_init(), #RF_RatConfigOutput_init() , #RF_ratDisableChannel(), #RF_ratCompare() - */ -extern RF_RatHandle RF_ratCapture(RF_Handle rfHandle, RF_RatConfigCapture* channelConfig, RF_RatConfigOutput* ioConfig); - -/** - * @brief Disable a RAT channel. - * - * The #RF_RatHandle returned by the #RF_ratCompare() or #RF_ratCapture() APIs can be used for further interaction with the - * Radio Timer. Passing the handle to %RF_ratDisableChannel() will abort a compare/capture event, and the provided channel - * is deallocated. No callback is invoked. This API can be called both if the RF core is ON or OFF. After the channel is - * freed, the next radio event will be rescheduled. A typical use case if a channel is configured in repeated capture mode, - * and the application decides to abort this operation. - * - * @note Calling context : Task/SWI - * - * @param rfHandle Handle previously returned by RF_open(). - * @param ratHandle #RF_RatHandle returned by #RF_ratCompare() or #RF_ratCapture(). - * @return #RF_Stat indicates if command was successfully completed. - * - * \sa #RF_ratCompare(), #RF_ratCapture() - */ -extern RF_Stat RF_ratDisableChannel(RF_Handle rfHandle, RF_RatHandle ratHandle); - -/** - * @brief Set RF control parameters. - * - * @note Calling context : Task - * - * @param h Handle previously returned by RF_open() - * @param ctrl Control codes - * @param args Pointer to control arguments - * @return RF_Stat indicates if API call was successfully completed. - */ -extern RF_Stat RF_control(RF_Handle h, int8_t ctrl, void *args); - -/** - * @brief Request radio access.
- * - * Scope: - * 1. Only supports request access which start immediately.
- * 2. The #RF_AccessParams duration should be less than a pre-defined value - * RF_REQ_ACCESS_MAX_DUR_US in RFCC26XX_multiMode.c.
- * 3. The #RF_AccessParams priority should be set RF_PriorityHighest.
- * 4. Single request for a client at anytime.
- * 5. Command from different client are blocked until the radio access - * period is completed.
- * - * @note Calling context : Task - * - * @param h Handle previously returned by RF_open() - * @param pParams Pointer to RF_AccessRequest parameters - * @return RF_Stat indicates if API call was successfully completed. - */ -extern RF_Stat RF_requestAccess(RF_Handle h, RF_AccessParams *pParams); - -/** - * @brief Returns the currently configured transmit power configuration. - * - * This function returns the currently configured transmit power configuration under the assumption - * that it has been previously set by #RF_setTxPower(). The value might be used for reverse - * lookup in a TX power table. If no power has been programmed, it returns an invalid value. - * - * @code - * RF_TxPowerTable_Value value = RF_getTxPower(handle); - * if (value.rawValue == RF_TxPowerTable_INVALID_VALUE) { - * // error, value not valid - * } - * @endcode - * - * @param h Handle previously returned by #RF_open() - * @return PA configuration struct - * - * @sa #RF_setTxPower(), #RF_TxPowerTable_findPowerLevel() - */ -extern RF_TxPowerTable_Value RF_getTxPower(RF_Handle h); - -/** - * @brief Updates the transmit power configuration of the RF core. - * - * This function programs a new TX power \a value and returns a status code. The API will return - * with RF_StatBusyError if there are still pending commands in the internal queue. In case of - * success, RF_StatSuccess is returned and the new configuration becomes effective from the next - * radio operation. - * - * Some devices provide an integrated high-power PA in addition to the Default PA. On these devices - * the API accepts configurations for both, and if \a value selects a different PA, the - * \a globalCallback is invoked. The implementation of \a globalCallback is board specific and can - * be used to reconfigure the external RF switches (if any). - * - * @param h Handle previously returned by #RF_open() - * @param value TX power configuration value. - * @return #RF_StatSuccess on success, otherwise an error code. - * - * @sa #RF_getTxPower(), #RF_TxPowerTable_Value, #RF_TxPowerTable_findValue() - */ -extern RF_Stat RF_setTxPower(RF_Handle h, RF_TxPowerTable_Value value); - -/** - * @brief Retrieves a power level in dBm for a given power configuration value. - * - * \c %RF_TxPowerTable_findPowerLevel() searches in a lookup \a table for a given transmit power - * configuration \a value and returns the power level in dBm if a matching configuration is found. - * If \a value can not be found, #RF_TxPowerTable_INVALID_DBM is returned. - * - * This function does a reverse lookup compared to #RF_TxPowerTable_findValue() and has - * O(n). It is assumed that \a table is terminated by a #RF_TxPowerTable_TERMINATION_ENTRY. - * - * @param table List of #RF_TxPowerTable_Entry entries, - * terminated by #RF_TxPowerTable_TERMINATION_ENTRY. - * - * @param value Power configuration value. - * - * @return Human readable power level in dBm on success, - * otherwise #RF_TxPowerTable_INVALID_DBM. - */ -extern int8_t RF_TxPowerTable_findPowerLevel(RF_TxPowerTable_Entry table[], RF_TxPowerTable_Value value); - -/** - * @brief Retrieves a power configuration value for a given power level in dBm. - * - * \c %RF_TxPowerTable_findValue() searches in a lookup \a table for a given transmit power level - * \a powerLevel in dBm and returns a matching power configuration. If \a powerLevel can not be - * found, #RF_TxPowerTable_INVALID_VALUE is returned. - * - * This function performs a linear search in \a table and has O(n). - * It is assumed that \a table is defined in ascending order and is terminated by a - * #RF_TxPowerTable_TERMINATION_ENTRY. - * - * The following special values for \a powerLevel are also accepted: - * - * - #RF_TxPowerTable_MIN_DBM which returns always the lowest power value in the table - * - #RF_TxPowerTable_MAX_DBM which returns always the highest power value in the table - * - * @param table List of #RF_TxPowerTable_Entry entries, - * terminated by #RF_TxPowerTable_TERMINATION_ENTRY. - * - * @param powerLevel Human-readable power level in dBm. - * - * @return PA configuration value on success. - * otherwise #RF_TxPowerTable_INVALID_VALUE. - */ -extern RF_TxPowerTable_Value RF_TxPowerTable_findValue(RF_TxPowerTable_Entry table[], int8_t powerLevel); - - -#ifdef __cplusplus -} +#error "An incompatible device is defined in the project. \ + To build with this driver, change the DeviceFamily token definition." #endif #endif /* ti_drivers_rf__include */ diff --git a/simplelink/source/ti/drivers/rf/RFCC26X2.h b/simplelink/source/ti/drivers/rf/RFCC26X2.h new file mode 100644 index 0000000..1c57434 --- /dev/null +++ b/simplelink/source/ti/drivers/rf/RFCC26X2.h @@ -0,0 +1,2586 @@ +/* + * Copyright (c) 2016-2020, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * 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. + * + * * Neither the name of Texas Instruments Incorporated 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 OWNER 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 RFCC26X2.h +@brief Radio Frequency (RF) Core Driver for the CC13X2 and CC26X2 device + family. + +To use the RF driver, ensure that the correct driver library for your device +is linked in and include the top-level header file as follows: + +@code +#include +@endcode + +
+@anchor rf_overview +Overview +======== + +The RF driver provides access to the radio core on the CC13x2/CC26x2 device +family. It offers a high-level interface for command execution and to the +radio timer (RAT). The RF driver ensures the lowest possible power consumption +by providing automatic power management that is fully transparent for the +application. + +@note This document describes the features and usage of the RF driver API. For a +detailed explanation of the RF core, please refer to the +Technical +Reference Manual or the +Proprietary +RF User Guide. + +Key features are: + +@li @ref rf_command_execution "Synchronous execution of direct and immediate radio commands" +@li @ref rf_command_execution "Synchronous and asynchronous execution of radio operation commands" +@li Various @ref rf_event_callbacks "event hooks" to interact with RF commands and the RF driver +@li Automatic @ref rf_power_management "power management" +@li @ref rf_scheduling "Preemptive scheduler for RF operations" of different RF driver instances +@li Convenient @ref rf_rat "Access to the radio timer" (RAT) +@li @ref rf_tx_power "Programming the TX power level" + +@anchor rf_setup_and_configuration +Setup and configuration +======================= + +The RF driver can be configured at 4 different places: + +1. In the build configuration by choosing either the single-client or + multi-client driver version. + +2. At compile-time by setting hardware and software interrupt priorities + in the board support file. + +3. During run-time initialization by setting #RF_Params when calling + #RF_open(). + +4. At run-time via #RF_control(). + + +Build configuration +------------------- + +The RF driver comes in two versions: single-client and multi-client. The +single-client version allows only one driver instance to access the RF core at +a time. The multi-client driver version allows concurrent access to the RF +core with different RF settings. The multi-client driver has a slightly larger +footprint and is not needed for many proprietary applications. The driver +version can be selected in the build configuration by linking against a +RFCC26X2_multiMode pre-built library. The multi-client driver is the default +configuration in the SimpleLink SDKs. + + +Board configuration +------------------- + +The RF driver handles RF core hardware interrupts and uses software interrupts +for its internal state machine. For managing the interrupt priorities, it +expects the existence of a global #RFCC26XX_HWAttrsV2 object. This is +usually defined in the board support file, for example `CC2652RB_LAUNCHXL.c`, +but when developing on custom boards, it might be kept anywhere in the +application. By default, the priorities are set to the lowest possible value: + +@code +const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { + .hwiPriority = INT_PRI_LEVEL7, // Lowest HWI priority: INT_PRI_LEVEL7 + // Highest HWI priority: INT_PRI_LEVEL1 + + .swiPriority = 0, // Lowest SWI priority: 0 + // Highest SWI priority: Swi.numPriorities - 1 + + .xoscHfAlwaysNeeded = true // Power driver always starts XOSC-HF: true + // RF driver will request XOSC-HF if needed: false +}; +@endcode + + +Initialization +-------------- + +When initiating an RF driver instance, the function #RF_open() accepts a +pointer to a #RF_Params object which might set several driver parameters. In +addition, it expects an #RF_Mode object and a setup command which is usually +generated by SmartRF Studio: + +@code +RF_Params rfParams; +RF_Params_init(&rfParams); +rfParams.nInactivityTimeout = 2000; + +RF_Handle rfHandle = RF_open(&rfObject, &RF_prop, + (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams); +@endcode + +The function #RF_open() returns a driver handle that is used for accessing the +correct driver instance. Please note that the first RF operation command +before an RX or TX operation command must be a `CMD_FS` to set the synthesizer +frequency. The RF driver caches both, the pointer to the setup command and the +physical `CMD_FS` for automatic power management. + + +Run-time configuration +---------------------- + +While a driver instance is opened, it can be re-configured with the function +#RF_control(). Various configuration parameters @ref RF_CTRL are available. +Example: + +@code +uint32_t timeoutUs = 2000; +RF_control(rfHandle, RF_CTRL_SET_INACTIVITY_TIMEOUT, &timeoutUs); +@endcode + +
+@anchor rf_command_execution +Command execution +================= + +The RF core supports 3 different kinds of commands: + +1. Direct commands +2. Immediate commands +3. Radio operation commands + +Direct and immediate commands are dispatched via #RF_runDirectCmd() and +#RF_runImmediateCmd() respectively. These functions block until the command +has completed and return a status code of the type #RF_Stat when done. + +@code +#include + +RF_Stat status = RF_runDirectCmd(rfHandle, CMD_ABORT); +assert(status == RF_StatCmdDoneSuccess); +@endcode + +Radio operation commands are potentially long-running commands and support +different triggers as well as conditional execution. Only one command can be +executed at a time, but the RF driver provides an internal queue that stores +commands until the RF core is free. Two interfaces are provided for radio +operation commands: + +1. Asynchronous: #RF_postCmd() and #RF_pendCmd() +2. Synchronous: #RF_runCmd() + +The asynchronous function #RF_postCmd() posts a radio operation into the +driver's internal command queue and returns a command handle of the type +#RF_CmdHandle which is an index in the command queue. The command is +dispatched as soon as the RF core has completed any previous radio operation +command. + +@code +#include + +RF_Callback callback = NULL; +RF_EventMask subscribedEvents = 0; +RF_CmdHandle rxCommandHandle = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdRx, + RF_PriorityNormal, callback, subscribedEvents); + +assert(rxCommandHandle != RF_ALLOC_ERROR); // The command queue is full. +@endcode + +Command execution happens in background. The calling task may proceed with +other work or execute direct and immediate commands to interact with the +posted radio operation. But beware that the posted command might not have +started, yet. By calling the function #RF_pendCmd() and subscribing events of +the type #RF_EventMask, it is possible to re-synchronize to a posted command: + +@code +// RF_EventRxEntryDone must have been subscribed in RF_postCmd(). +RF_EventMask events = RF_pendCmd(rfHandle, rxCommandHandle, + RF_EventRxEntryDone); + +// Program proceeds after RF_EventRxEntryDone or after a termination event. +@endcode + +The function #RF_runCmd() is a combination of both, #RF_postCmd() and +#RF_pendCmd() and allows synchronous execution. + +A pending or already running command might be aborted at any time by calling +the function #RF_cancelCmd() or #RF_flushCmd(). These functions take command +handles as parameters, but can also just abort anything in the RF driver's +queue: + +@code +uint8_t abortGraceful = 1; + +// Abort a single command +RF_cancelCmd(rfHandle, rxCommandHandle, abortGraceful); + +// Abort anything +RF_flushCmd(rfHandle, RF_CMDHANDLE_FLUSH_ALL, abortGraceful); +@endcode + +When aborting a command, the return value of #RF_runCmd() or #RF_pendCmd() +will contain the termination reason in form of event flags. If the command is +in the RF driver queue, but has not yet start, the #RF_EventCmdCancelled event is +raised. + +
+@anchor rf_event_callbacks +Event callbacks +=============== + +The RF core generates multiple interrupts during command execution. The RF +driver maps these interrupts 1:1 to callback events of the type #RF_EventMask. +Hence, it is unnecessary to implement own interrupt handlers. Callback events +are divided into 3 groups: + +- Command-specific events, documented for each radio operation command. An example + is the #RF_EventRxEntryDone for the `CMD_PROP_RX`. + +- Generic events, defined for all radio operations and originating on the RF core. + These are for instance #RF_EventCmdDone and #RF_EventLastCmdDone. Both events + indicate the termination of one or more RF operations. + +- Generic events, defined for all radio operations and originating in the RF driver, + for instance #RF_EventCmdCancelled. + +@sa @ref RF_Core_Events, @ref RF_Driver_Events. + +How callback events are subscribed was shown in the previous section. The +following snippet shows a typical event handler callback for a proprietary RX +operation: + +@code +void rxCallback(RF_Handle handle, RF_CmdHandle command, RF_EventMask events) +{ + if (events & RF_EventRxEntryDone) + { + Semaphore_post(rxPacketSemaphore); + } + if (events & RF_EventLastCmdDone) + { + // ... + } +} +@endcode + +In addition, the RF driver can generate error and power-up events that do not +relate directly to the execution of a radio command. Such events can be +subscribed by specifying the callback function pointers #RF_Params::pErrCb and +#RF_Params::pPowerCb. + +All callback functions run in software interrupt (SWI) context. Therefore, +only a minimum amount of code should be executed. When using absolute timed +commands with tight timing constraints, then it is recommended to set the RF +driver SWIs to a high priority. +See @ref rf_setup_and_configuration "Setup and configuration" for more details. + +
+@anchor rf_power_management +Power management +================ + +The RF core is a hardware peripheral and can be switched on and off. The RF +driver handles that automatically and provides the following power +optimization features: + +- Lazy power-up and radio setup caching +- Power-down on inactivity +- Deferred dispatching of commands with absolute timing + + +Lazy power-up and radio setup caching +------------------------------------- + +The RF core optimizes the power consumption by enabling the RF core as late as +possible. For instance does #RF_open() not power up the RF core immediately. +Instead, it waits until the first radio operation command is dispatched by +#RF_postCmd() or #RF_runCmd(). + +The function #RF_open() takes a radio setup command as parameter and expects a +`CMD_FS` command to follow. The pointer to the radio setup command and the +whole `CMD_FS` command are cached internally in the RF driver. They will be +used for every proceeding power-up procedure. Whenever the client re-runs a +setup command or a `CMD_FS` command, the driver updates its internal cache +with the new settings. + +By default, the RF driver measures the time that it needs for the power-up +procedure and uses that as an estimate for the next power cycle. On the +CC13x0/CC26x0 devices, power-up takes usually 1.6 ms. Automatic measurement +can be suppressed by specifying a custom power-up time with +#RF_Params::nPowerUpDuration. In addition, the client might set +#RF_Params::nPowerUpDurationMargin to cover any uncertainty when doing +automatic measurements. This is necessary in applications with a high hardware +interrupt load which can delay the RF driver's internal state machine +execution. + + +Power-down on inactivity +------------------------ + +Whenever a radio operation completes and there is no other radio operation in +the queue, the RF core might be powered down. There are two options in the RF +driver: + +- **Automatic power-down** by setting the parameter + #RF_Params::nInactivityTimeout. The RF core will then start a timer after + the last command in the queue has completed. The default timeout is "forever" + and this feature is disabled. + +- **Manual power-down** by calling #RF_yield(). The client should do this + whenever it knows that no further radio operation will be executed for a + couple of milliseconds. + +During the power-down procedure the RF driver stops the radio timer and saves +a synchronization timestamp for the next power-up. This keeps the radio timer +virtually in sync with the RTC even though it is not running all the time. The +synchronization is done in hardware. + + +Deferred dispatching of commands with absolute timing +----------------------------------------------------- + +When dispatching a radio operation command with an absolute start trigger that +is ahead in the future, the RF driver defers the execution and powers the RF +core down until the command is due. It does that only, when: + +1. `cmd.startTrigger.triggerType` is set to `TRIG_ABSTIME` + +2. The difference between #RF_getCurrentTime() and `cmd.startTime` + is at not more than 3/4 of a full RAT cycle. Otherwise the driver assumes + that `cmd.startTime` is in the past. + +3. There is enough time to run a full power cycle before `cmd.startTime` is + due. That includes: + + - the power-down time (fixed value, 1 ms) if the RF core is already + powered up, + + - the measured power-up duration or the value specified by + #RF_Params::nPowerUpDuration, + + - the power-up safety margin #RF_Params::nPowerUpDurationMargin + (the default is 282 microseconds). + +If one of the conditions are not fulfilled, the RF core is kept up and +running and the command is dispatched immediately. This ensures, that the +command will execute on-time and not miss the configured start trigger. + +
+@anchor rf_scheduling +Preemptive scheduling of RF commands in multi-client applications +================================================================= + +Schedule BLE and proprietary radio commands. + +@code +RF_Object rfObject_ble; +RF_Object rfObject_prop; + +RF_Handle rfHandle_ble, rfHandle_prop; +RF_Params rfParams_ble, rfParams_prop; +RF_ScheduleCmdParams schParams_ble, schParams_prop; + +RF_Mode rfMode_ble = +{ + .rfMode = RF_MODE_MULTIPLE, // rfMode for dual mode + .cpePatchFxn = &rf_patch_cpe_ble, + .mcePatchFxn = 0, + .rfePatchFxn = &rf_patch_rfe_ble, +}; + +RF_Mode rfMode_prop = +{ + .rfMode = RF_MODE_MULTIPLE, // rfMode for dual mode + .cpePatchFxn = &rf_patch_cpe_genfsk, + .mcePatchFxn = 0, + .rfePatchFxn = 0, +}; + +// Init RF and specify non-default parameters +RF_Params_init(&rfParams_ble); +rfParams_ble.nInactivityTimeout = 200; // 200us + +RF_Params_init(&rfParams_prop); +rfParams_prop.nInactivityTimeout = 200; // 200us + +// Configure RF schedule command parameters directly. +schParams_ble.priority = RF_PriorityNormal; +schParams_ble.endTime = 0; +schParams_ble.allowDelay = RF_AllowDelayAny; + +// Alternatively, use the helper function to configure the default behavior +RF_ScheduleCmdParams_init(&schParams_prop); + +// Open BLE and proprietary RF handles +rfHandle_ble = RF_open(rfObj_ble, &rfMode_ble, (RF_RadioSetup*)&RF_cmdRadioSetup, &rfParams_ble); +rfHandle_prop = RF_open(rfObj_prop, &rfMode_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams_prop); + +// Run a proprietary Fs command +RF_runCmd(rfHandle_pro, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, NULL); + +// Schedule a proprietary RX command +RF_scheduleCmd(rfHandle_pro, (RF_Op*)&RF_cmdPropRx, &schParams_prop, &prop_callback, RF_EventRxOk); + +// Schedule a BLE advertiser command +RF_scheduleCmd(rfHandle_ble, (RF_Op*)&RF_cmdBleAdv, &schParams_ble, &ble_callback, + (RF_EventLastCmdDone | RF_EventRxEntryDone | RF_EventTxEntryDone)); + +@endcode + +
+@anchor rf_rat +Accessing the Radio Timer (RAT) +============================== + +The Radio Timer on the RF core is an independent 32 bit timer running at a +tick rate of 4 ticks per microsecond. It is only physically active while the +RF core is on. But because the RF driver resynchronizes the RAT to the RTC on +every power-up, it appears to the application as the timer is always running. +The RAT accuracy depends on the system HF clock while the RF core is active +and on the LF clock while the RF core is powered down. + +The current RAT time stamp can be obtained by #RF_getCurrentTime(): + +@code +uint32_t now = RF_getCurrentTime(); +@endcode + +The RAT has 8 independent channels that can be set up in capture and compare +mode by #RF_ratCapture() and #RF_ratCompare() respectively. Three of these +channels are accessible by the RF driver. Each channel may be connected to +physical hardware signals for input and output or may trigger a callback +function. + +In order to allocate a RAT channel and trigger a callback function at a +certain time stamp, use #RF_ratCompare(): + +@code +RF_Handle rfDriver; +RF_RatConfigCompare config; +RF_RatConfigCompare_init(&config); +config.callback = &onRatTriggered; +config.channel = RF_RatChannelAny; +config.timeout = RF_getCurrentTime() + RF_convertMsToRatTicks(1701); + +RF_RatHandle ratHandle = RF_ratCompare(rfDriver, &config, nullptr); +assert(ratHandle != RF_ALLOC_ERROR); + +void onRatTriggered(RF_Handle h, RF_RatHandle rh, RF_EventMask e, uint32_t compareCaptureTime) +{ + if (e & RF_EventError) + { + // RF driver failed to trigger the callback on time. + } + printf("RAT has triggered at %u.", compareCaptureTime); + + // Trigger precisely with the same period again + config.timeout = compareCaptureTime + RF_convertMsToRatTicks(1701); + ratHandle = RF_ratCompare(rfDriver, &config, nullptr); + assert(ratHandle != RF_ALLOC_ERROR); +} +@endcode + +The RAT may be used to capture a time stamp on an edge of a physical pin. This +can be achieved with #RF_ratCapture(). + +@code +#include +// Map IO 26 to RFC_GPI0 +PINCC26XX_setMux(pinHandle, IOID_26, PINCC26XX_MUX_RFC_GPI0); + +RF_Handle rfDriver; +RF_RatConfigCapture config; +RF_RatConfigCapture_init(&config); +config.callback = &onSignalTriggered; +config.channel = RF_RatChannelAny; +config.source = RF_RatCaptureSourceRfcGpi0; +config.captureMode = RF_RatCaptureModeRising; +config.repeat = RF_RatCaptureRepeat; + +RF_RatHandle ratHandle = RF_ratCapture(rfDriver, &config, nullptr); +assert(ratHandle != RF_ALLOC_ERROR); + +void onSignalTriggered(RF_Handle h, RF_RatHandle rh, RF_EventMask e, uint32_t compareCaptureTime) +{ + if (e & RF_EventError) + { + // An internal error has occurred + } + printf("Rising edge detected on IO 26 at %u.", compareCaptureTime); +} +@endcode + +In both cases, the RAT may generate an output signal when being triggered. The +signal can be routed to a physical IO pin: + +@code +// Generate a pulse on an internal RAT output signal +RF_RatConfigOutput output; +RF_RatConfigOutput_init(&output); +output.mode = RF_RatOutputModePulse; +output.select = RF_RatOutputSelectRatGpo3; +RF_ratCompare(...); + +// Map RatGpo3 to one of four intermediate doorbell signals. +// This has to be done in the override list in order to take permanent effect. +// The override list can be found in the RF settings .c file exported from +// SmartRF Studio. +// Attention: This will change the default mapping of the PA and LNA signal as well. +#include +static uint32_t pOverrides[] = +{ + HW_REG_OVERRIDE(0x1110, RFC_DBELL_SYSGPOCTL_GPOCTL2_RATGPO3), + // ... +} + +// Finally, route the intermediate doorbell signal to a physical pin. +#include +PINCC26XX_setMux(pinHandle, IOID_17, PINCC26XX_MUX_RFC_GPO2); +@endcode + +
+@anchor rf_tx_power +Programming the TX power level +============================== + +The application can program a TX power level for each RF client with the function +#RF_setTxPower(). The new value takes immediate effect if the RF core is up and +running. Otherwise, it is stored in the RF driver client configuration. + +TX power may be stored in a lookup table in ascending order. This table is usually +generated and exported from SmartRF Studio together with the rest of the PHY configuration. +A typical power table my look as follows: +@code +RF_TxPowerTable_Entry txPowerTable[] = { + { .power = 11, .value = { 0x1233, RF_TxPowerTable_DefaultPA }}, + { .power = 13, .value = { 0x1234, RF_TxPowerTable_DefaultPA }}, + // ... + RF_TxPowerTable_TERMINATION_ENTRY +}; +@endcode + +@note Some devices offer a high-power PA in addition to the default PA. +A client must not mix configuration values in the same power table and must +not hop from a default PA configuration to a high-power PA configuration unless it +can guarantee that the RF setup command is re-executed in between. + +Given this power table format, the application may program a new power level in multiple +ways. It can use convenience functions to search a certain power level +in the power table or may access the table index-based: +@code +// Set a certain power level. Search a matching level. +RF_setTxPower(h, RF_TxPowerTable_findValue(txPowerTable, 17)); + +// Set a certain power level with a known level. +RF_setTxPower(h, txPowerTable[3].value); + +// Set a certain power without using a human readable level. +RF_setTxPower(h, value); + +// Set maximum power. Search the value. +RF_setTxPower(h, RF_TxPowerTable_findValue(txPowerTable, RF_TxPowerTable_MAX_DBM)); + +// Set minimum power without searching. +RF_setTxPower(h, txPowerTable[0].value); + +// Set minimum power. Search the value. +RF_setTxPower(h, RF_TxPowerTable_findValue(txPowerTable, RF_TxPowerTable_MIN_DBM)); + +// Set maximum power without searching. +int32_t lastIndex = sizeof(txPowerTable) / sizeof(RF_TxPowerTable_Entry) - 2; +RF_setTxPower(h, txPowerTable[lastIndex].value); +@endcode + +The current configured power level for a client can be retrieved by #RF_getTxPower(). +@code +// Get the current configured power level. +int8_t power = RF_TxPowerTable_findPowerLevel(txPowerTable, RF_getTxPower(h)); +@endcode + +
+@anchor rf_convenience_features +Convenience features +==================== + +The RF driver simplifies often needed tasks and provides additional functions. +For instance, it can read the RSSI while the RF core is in RX mode using the +function :tidrivers_api:`RF_getRssi`: + +@code +int8_t rssi = RF_getRssi(rfHandle); +assert (rssi != RF_GET_RSSI_ERROR_VAL); // Could not read the RSSI +@endcode + +
+ ****************************************************************************** + */ + +//***************************************************************************** +// +//! \addtogroup rf_driver +//! @{ +//! \addtogroup rf_driver_cc13x2_cc26x2 +//! @{ +// +//***************************************************************************** + +#ifndef ti_drivers_rfcc26x2__include +#define ti_drivers_rfcc26x2__include + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#include +#include +#include + +#include +#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) +#include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h) +#include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h) + +/** + * @name RF Core Events + * @anchor RF_Core_Events + * + * Events originating on the RF core and caused during command execution. + * They are aliases for the corresponding interrupt flags. + * RF Core Events are command-specific and are explained in the Technical Reference Manual. + * + * @sa RF_postCmd(), RF_pendCmd(), RF_runCmd() + * @{ + */ +#define RF_EventCmdDone (1 << 0) ///< A radio operation command in a chain finished. +#define RF_EventLastCmdDone (1 << 1) ///< A stand-alone radio operation command or the last radio operation command in a chain finished. +#define RF_EventFGCmdDone (1 << 2) ///< A IEEE-mode radio operation command in a chain finished. +#define RF_EventLastFGCmdDone (1 << 3) ///< A stand-alone IEEE-mode radio operation command or the last command in a chain finished. +#define RF_EventTxDone (1 << 4) ///< Packet transmitted +#define RF_EventTXAck (1 << 5) ///< ACK packet transmitted +#define RF_EventTxCtrl (1 << 6) ///< Control packet transmitted +#define RF_EventTxCtrlAck (1 << 7) ///< Acknowledgement received on a transmitted control packet +#define RF_EventTxCtrlAckAck (1 << 8) ///< Acknowledgement received on a transmitted control packet, and acknowledgement transmitted for that packet +#define RF_EventTxRetrans (1 << 9) ///< Packet retransmitted +#define RF_EventTxEntryDone (1 << 10) ///< Tx queue data entry state changed to Finished +#define RF_EventTxBufferChange (1 << 11) ///< A buffer change is complete +#define RF_EventPaChanged (1 << 14) ///< The PA was reconfigured on the fly. +#define RF_EventRxOk (1 << 16) ///< Packet received with CRC OK, payload, and not to be ignored +#define RF_EventRxNOk (1 << 17) ///< Packet received with CRC error +#define RF_EventRxIgnored (1 << 18) ///< Packet received with CRC OK, but to be ignored +#define RF_EventRxEmpty (1 << 19) ///< Packet received with CRC OK, not to be ignored, no payload +#define RF_EventRxCtrl (1 << 20) ///< Control packet received with CRC OK, not to be ignored +#define RF_EventRxCtrlAck (1 << 21) ///< Control packet received with CRC OK, not to be ignored, then ACK sent +#define RF_EventRxBufFull (1 << 22) ///< Packet received that did not fit in the Rx queue +#define RF_EventRxEntryDone (1 << 23) ///< Rx queue data entry changing state to Finished +#define RF_EventDataWritten (1 << 24) ///< Data written to partial read Rx buffer +#define RF_EventNDataWritten (1 << 25) ///< Specified number of bytes written to partial read Rx buffer +#define RF_EventRxAborted (1 << 26) ///< Packet reception stopped before packet was done +#define RF_EventRxCollisionDetected (1 << 27) ///< A collision was indicated during packet reception +#define RF_EventModulesUnlocked (1 << 29) ///< As part of the boot process, the CM0 has opened access to RF core modules and memories +#define RF_EventInternalError (uint32_t)(1 << 31) ///< Internal error observed +#define RF_EventMdmSoft 0x0000002000000000 ///< Synchronization word detected (MDMSOFT interrupt flag) +/** @}*/ + +/** + * @name RF Driver Events + * @anchor RF_Driver_Events + * + * Event flags generated by the RF Driver. + * @{ + */ +#define RF_EventCmdCancelled 0x1000000000000000 ///< Command canceled before it was started. +#define RF_EventCmdAborted 0x2000000000000000 ///< Abrupt command termination caused by RF_cancelCmd() or RF_flushCmd(). +#define RF_EventCmdStopped 0x4000000000000000 ///< Graceful command termination caused by RF_cancelCmd() or RF_flushCmd(). +#define RF_EventRatCh 0x0800000000000000 ///< A user-programmable RAT channel triggered an event. +#define RF_EventPowerUp 0x0400000000000000 ///< RF power up event. \deprecated This event is deprecated. Use #RF_ClientEventPowerUpFinished instead. +#define RF_EventError 0x0200000000000000 ///< Event flag used for error callback functions to indicate an error. See RF_Params::pErrCb. +#define RF_EventCmdPreempted 0x0100000000000000 ///< Command preempted by another command with higher priority. Applies only to multi-client applications. +/** @}*/ + +/** + * @name Control codes for driver configuration + * @anchor RF_CTRL + * + * Control codes are used in RF_control(). + * + * @{ + */ + +/*! + * @brief Control code used by RF_control to set inactivity timeout + * + * Setting this control allows RF to power down the radio upon completion of a radio + * command after a specified timeout period (in us) + * With this control code @b arg is a pointer to the timeout variable and returns RF_StatSuccess. + */ +#define RF_CTRL_SET_INACTIVITY_TIMEOUT 0 +/*! + * @brief Control code used by RF_control to update setup command + * + * Setting this control notifies RF that the setup command is to be updated, so that RF will take + * proper actions when executing the next setup command. + * Note the updated setup command will take effect in the next power up cycle when RF executes the + * setup command. Prior to updating the setup command, user should make sure all pending commands + * have completed. + */ +#define RF_CTRL_UPDATE_SETUP_CMD 1 +/*! + * @brief Control code used by RF_control to set powerup duration margin + * + * Setting this control updates the powerup duration margin. Default is RF_DEFAULT_POWER_UP_MARGIN. + */ +#define RF_CTRL_SET_POWERUP_DURATION_MARGIN 2 +/*! + * @brief Control code used by RF_control to set the phy switching margin + * + * Setting this control updates the phy switching duration margin, which is used to calculate when + * run-time conflicts shall be evaluated in case of colliding radio operations issued from two + * different clients. Default is RF_DEFAULT_PHY_SWITCHING_MARGIN. + */ +#define RF_CTRL_SET_PHYSWITCHING_DURATION_MARGIN 3 +/*! + * @brief Control code used by RF_control to set max error tolerance for RAT/RTC + * + * Setting this control updates the error tol for how frequently the CMD_RAT_SYNC_STOP is sent. + * Default is RF_DEFAULT_RAT_RTC_ERR_TOL_IN_US (5 us) + * Client is recommeneded to change this setting before sending any commands. + */ +#define RF_CTRL_SET_RAT_RTC_ERR_TOL_VAL 4 +/*! + * @brief Control code used by RF_control to set power management + * + * Setting this control configures RF driver to enable or disable power management. + * By default power management is enabled. + * If disabled, once RF core wakes up, RF driver will not go to standby and will not power down RF core. + * To configure power management, use this control to pass a parameter value of 0 to disable power management, + * and pass a parameter value of 1 to re-enable power management. + * This control is valid for dual-mode code only. Setting this control when using single-mode code has no effect + * (power management always enabled). + */ +#define RF_CTRL_SET_POWER_MGMT 5 +/*! + * @brief Control code used by RF_control to set the hardware interrupt priority level of the RF driver. + * + * This control code sets the hardware interrupt priority level that is used by the RF driver. Valid + * values are INT_PRI_LEVEL1 (highest) until INT_PRI_LEVEL7 (lowest). The default interrupt priority is + * set in the board support file. The default value is -1 which means "lowest possible priority". + * + * When using the TI-RTOS kernel, INT_PRI_LEVEL0 is reserved for zero-latency interrupts and must not be used. + * + * Execute this control code only while the RF core is powered down and the RF driver command queue is empty. + * This is usually the case after calling RF_open(). Changing the interrupt priority level while the RF driver + * is active will result in RF_StatBusyError being returned. + * + * Example: + * @code + * #include DeviceFamily_constructPath(driverlib/interrupt.h) + * + * int32_t hwiPriority = INT_PRI_LEVEL5; + * RF_control(rfHandle, RF_CTRL_SET_HWI_PRIORITY, &hwiPriority); + * @endcode + */ +#define RF_CTRL_SET_HWI_PRIORITY 6 +/*! + * @brief Control code used by RF_control to set the software interrupt priority level of the RF driver. + * + * This control code sets the software interrupt priority level that is used by the RF driver. Valid + * values are integers starting at 0 (lowest) until Swi_numPriorities - 1 (highest). The default + * interrupt priority is set in the board support file. The default value is 0 which means means + * "lowest possible priority". + * + * Execute this control code only while the RF core is powered down and the RF driver command queue is empty. + * This is usually the case after calling RF_open(). Changing the interrupt priority level while the RF driver + * is active will result in RF_StatBusyError being returned. + * + * Example: + * @code + * #include + * + * // Set highest possible priority + * uint32_t swiPriority = ~0; + * RF_control(rfHandle, RF_CTRL_SET_SWI_PRIORITY, &swiPriority); + * @endcode + */ +#define RF_CTRL_SET_SWI_PRIORITY 7 +/*! + * @brief Control code used by RF_control to mask the available RAT channels manually. + * + * This control code can be used to manually disallow/allow access to certain RAT channels from the RAT APIs. + * A typical use case is when a RAT channel is programmed through chained radio operations, and hence is + * used outside the scope of the RF driver. By disallowing access to this channel one can prevent collision + * between the automatic channel allocation through #RF_ratCompare()/#RF_ratCapture() and the direct + * configuration through #RF_postCmd(). + */ +#define RF_CTRL_SET_AVAILABLE_RAT_CHANNELS_MASK 8 +/*! + * @brief Control code used by RF_control to enable or disable the coexistence feature at runtime + * + * This control code can be used to manually override the statically configured setting for global enable/disable + * of the coexistence feature. It will have no effect if coexistence is not originally enabled and included + * in the compiled project. + * + * Example: + * @code + * // Disable the CoEx feature + * uint32_t coexEnabled = 0; + * RF_control(rfHandle, RF_CTRL_COEX_CONTROL, &coexEnabled); + * @endcode + */ +#define RF_CTRL_COEX_CONTROL 9 +/** @}*/ + +/** + * @name TX Power Table defines + * @{ + */ + +/** + * Refers to the the minimum available power in dBm when accessing a power + * table. + * + * \sa #RF_TxPowerTable_findValue() + */ +#define RF_TxPowerTable_MIN_DBM -128 + +/** + * Refers to the the maximum available power in dBm when accessing a power + * table. + * + * \sa #RF_TxPowerTable_findValue() + */ +#define RF_TxPowerTable_MAX_DBM 126 + +/** + * Refers to an invalid power level in a TX power table. + * + * \sa #RF_TxPowerTable_findPowerLevel() + */ +#define RF_TxPowerTable_INVALID_DBM 127 + +/** + * Refers to an invalid power value in a TX power table. + * + * This is the raw value part of a TX power configuration. In order to check + * whether a given power configuration is valid, do: + * + * @code + * RF_TxPowerTable_Value value = ...; + * if (value.rawValue == RF_TxPowerTable_INVALID_VALUE) { + * // error, value not valid + * } + * @endcode + * + * A TX power table is always terminated by an invalid power configuration. + * + * \sa #RF_getTxPower(), RF_TxPowerTable_findValue + */ +#define RF_TxPowerTable_INVALID_VALUE 0x3fffff + +/** + * Marks the last entry in a TX power table. + * + * In order to use #RF_TxPowerTable_findValue() and #RF_TxPowerTable_findPowerLevel(), + * every power table must be terminated by a %RF_TxPowerTable_TERMINATION_ENTRY: + * + * @code + * RF_TxPowerTable_Entry txPowerTable[] = + * { + * { 20, RF_TxPowerTable_HIGH_PA_ENTRY(1, 2, 3) }, + * // ... , + * RF_TxPowerTable_TERMINATION_ENTRY + * }; + * @endcode + */ +#define RF_TxPowerTable_TERMINATION_ENTRY \ + { .power = RF_TxPowerTable_INVALID_DBM, .value = { .rawValue = RF_TxPowerTable_INVALID_VALUE, .paType = RF_TxPowerTable_DefaultPA } } + +/** + * Creates a TX power table entry for the default PA. + * + * The values for \a bias, \a gain, \a boost and \a coefficient are usually measured by Texas Instruments + * for a specific front-end configuration. They can then be obtained from SmartRFStudio. + */ +#define RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost, coefficient) \ + { .rawValue = ((bias) << 0) | ((gain) << 6) | ((boost) << 8) | ((coefficient) << 9), .paType = RF_TxPowerTable_DefaultPA } + +/** + * Creates a TX power table entry for the High-power PA. + * + * The values for \a bias, \a ibboost, \a boost, \a coefficient and \a ldoTrim are usually measured by Texas Instruments + * for a specific front-end configuration. They can then be obtained from SmartRFStudio. + */ +#define RF_TxPowerTable_HIGH_PA_ENTRY(bias, ibboost, boost, coefficient, ldotrim) \ + { .rawValue = ((bias) << 0) | ((ibboost) << 6) | ((boost) << 8) | ((coefficient) << 9) | ((ldotrim) << 16), .paType = RF_TxPowerTable_HighPA } + + +/** @} */ + +/** + * @name Other defines + * @{ + */ +#define RF_GET_RSSI_ERROR_VAL (-128) ///< Error return value for RF_getRssi() +#define RF_CMDHANDLE_FLUSH_ALL (-1) ///< RF command handle to flush all RF commands +#define RF_ALLOC_ERROR (-2) ///< RF command or RAT channel allocation error +#define RF_SCHEDULE_CMD_ERROR (-3) ///< RF command schedule error +#define RF_ERROR_RAT_PROG (-255) ///< A rat channel could not be programmed. +#define RF_ERROR_INVALID_RFMODE (-256) ///< Invalid RF_Mode. Used in error callback. +#define RF_ERROR_CMDFS_SYNTH_PROG (-257) ///< Synthesizer error with CMD_FS. Used in error callback. If this error occurred in error callback, user needs to resend CMD_FS to recover. See the device's errata for more details. + +#define RF_NUM_SCHEDULE_ACCESS_ENTRIES 2 ///< Number of access request entries +#define RF_NUM_SCHEDULE_COMMAND_ENTRIES 8 ///< Number of scheduled command entries +#define RF_NUM_SCHEDULE_MAP_ENTRIES (RF_NUM_SCHEDULE_ACCESS_ENTRIES + RF_NUM_SCHEDULE_COMMAND_ENTRIES) ///< Number of schedule map entries. This is the sum of access request and scheduled command entries +#define RF_SCH_MAP_CURRENT_CMD_OFFSET RF_NUM_SCHEDULE_ACCESS_ENTRIES ///< Offset of the current command entry in the schedule map +#define RF_SCH_MAP_PENDING_CMD_OFFSET (RF_SCH_MAP_CURRENT_CMD_OFFSET + 2) ///< Offset of the first pending command entry in the schedule map + +#define RF_ABORT_PREEMPTION (1<<2) ///< Used with RF_cancelCmd() to provoke subscription to RadioFreeCallback +#define RF_ABORT_GRACEFULLY (1<<0) ///< Used with RF_cancelCmd() for graceful command termination + +#define RF_SCH_CMD_EXECUTION_TIME_UNKNOWN 0 ///< For unknown execution time for RF scheduler + +#define RF_RAT_ANY_CHANNEL (-1) ///< To be used within the channel configuration structure. Allocate any of the available channels. +#define RF_RAT_TICKS_PER_US 4 ///< Radio timer (RAT) ticks per microsecond. + +#define RF_LODIVIDER_MASK 0x7F ///< Mask to be used to determine the effective value of the setup command's loDivider field. + +/** + * @name Stack ID defines + * @anchor RF_Stack_ID + * + * Reserved values to identify which stack owns an RF_Handle h (stored as h->clientConfig.nID) + * @{ + */ +#define RF_STACK_ID_DEFAULT 0x00000000 ///< No value is set. +#define RF_STACK_ID_154 0x8000F154 ///< ID for TI 15.4 Stack +#define RF_STACK_ID_BLE 0x8000FB1E ///< ID for TI BLE Stack +#define RF_STACK_ID_EASYLINK 0x8000FEA2 ///< ID for TI EasyLink Stack +#define RF_STACK_ID_THREAD 0x8000FEAD ///< ID for TI Thread Stack +#define RF_STACK_ID_TOF 0x8000F00F ///< ID for TI TOF Stack +#define RF_STACK_ID_CUSTOM 0x0000FC00 ///< ID for Custom Stack +/** @} */ + +/*! +\brief Converts a duration given in \a microseconds into radio timer (RAT) ticks. +*/ +#define RF_convertUsToRatTicks(microseconds) \ + ((microseconds) * (RF_RAT_TICKS_PER_US)) + +/*! +\brief Converts a duration given in \a milliseconds into radio timer (RAT) ticks. +*/ +#define RF_convertMsToRatTicks(milliseconds) \ + ((milliseconds) * 1000 * (RF_RAT_TICKS_PER_US)) + +/*! +\brief Converts a duration given in radio timer (RAT) \a ticks into microseconds. +*/ +#define RF_convertRatTicksToUs(ticks) \ + ((ticks) / (RF_RAT_TICKS_PER_US)) + +/*! +\brief Converts a duration given in radio timer (RAT) \a ticks into milliseconds. +*/ +#define RF_convertRatTicksToMs(ticks) \ + ((ticks) / (1000 * (RF_RAT_TICKS_PER_US))) + + +/** @}*/ + + +/** + * \brief PA configuration value for a certain power level. + * + * A %RF_TxPowerTable_Value contains the power amplifier (PA) configuration for a certain power level. + * It encodes the PA type as well as a raw configuration value for the RF core hardware. + * + * \sa #RF_getTxPower(), #RF_setTxPower(), #RF_TxPowerTable_Entry, #RF_TxPowerTable_PAType. + */ +typedef struct { + uint32_t rawValue:22; ///< Hardware configuration value. + ///< + ///< - \c [15:0] used for default PA, + ///< - \c [21:0] used for High-power PA + uint32_t __dummy:9; + uint32_t paType:1; ///< Selects the PA type to be used. + ///< + ///< - 0: #RF_TxPowerTable_DefaultPA + ///< - 1: #RF_TxPowerTable_HighPA +} RF_TxPowerTable_Value; + +/** + * \brief TX power configuration entry in a TX power table. + * + * A %RF_TxPowerTable_Entry defines an entry in a lookup table. Each entry contains a + * human-readable power level \a power as key and a hardware configuration \a value. + * + * Example of a typical power table: + * \code + * RF_TxPowerTable_Entry txPowerTable[] = { + * { .power = 20, .value = { .rawValue = 0x1234, .paType = RF_TxPowerTable_HighPA }}, + * { .power = 19, .value = { .rawValue = 0x1233, .paType = RF_TxPowerTable_HighPA }}, + * // ... + * RF_TxPowerTable_TERMINATION_ENTRY + * }; + * \endcode + * + * \sa #RF_TxPowerTable_findPowerLevel(), #RF_TxPowerTable_findPowerLevel() + */ +typedef struct +{ + int8_t power; ///< Human readable power value representing + ///< the output in dBm. + + RF_TxPowerTable_Value value; ///< PA hardware configuration for that power level. +} __attribute__((packed)) RF_TxPowerTable_Entry; + + +/** + * \brief Selects a power amplifier path in a TX power value. + * + * %RF_TxPowerTable_PAType selects one of the available power amplifiers + * on the RF core. It is usually included in a #RF_TxPowerTable_Value. + */ +typedef enum { + RF_TxPowerTable_DefaultPA = 0, ///< Default PA + RF_TxPowerTable_HighPA = 1, ///< High-power PA +} RF_TxPowerTable_PAType; + + +/** @brief Base type for all radio operation commands. + * + * All radio operation commands share a common part. + * That includes the command id, a status field, chaining properties + * and a start trigger. + * Whenever an RF operation command is used with the RF driver, it needs + * to be casted to an RF_Op. + * + * More information about RF operation commands can be found in the Proprietary RF + * User's Guide. + * + * @sa RF_runCmd(), RF_postCmd(), RF_pendCmd() + */ +typedef rfc_radioOp_t RF_Op; + + +/** @brief Specifies a RF core firmware configuration. + * + * %RF_Mode selects a mode of operation and points to firmware patches for the RF core. + * There exists one instance per radio PHY configuration, usually generated by + * SmartRF Studio. + * After assigning %RF_Mode configuration to the RF driver via RF_open(), the + * driver caches the containing information and re-uses it on every power-up. + */ +typedef struct { + uint8_t rfMode; ///< Specifies which PHY modes should be activated. Must be set to RF_MODE_MULTIPLE for dual-mode operation. + void (*cpePatchFxn)(void); ///< Pointer to CPE patch function + void (*mcePatchFxn)(void); ///< Pointer to MCE patch function + void (*rfePatchFxn)(void); ///< Pointer to RFE patch function +} RF_Mode; + +/** @brief Scheduling priority of RF operation commands. + * + * When multiple RF driver instances are used at the same time, + * commands from different clients may overlap. + * If an RF operation with a higher priority than the currently + * running operation is scheduled by RF_scheduleCmd(), then the + * running operation is interrupted. + * + * In single-client applications, %RF_PriorityNormal should be used. + */ +typedef enum { + RF_PriorityHighest = 2, ///< Highest priority. Only use this for urgent commands. + RF_PriorityHigh = 1, ///< High priority. Use this for time-critical commands in synchronous protocols. + RF_PriorityNormal = 0, ///< Default priority. Use this in single-client applications. +} RF_Priority; + +/** + * @brief Priority level for coexistence priority signal. + * + * When the RF driver is configured for three-wire coexistence mode, one of the + * output wires will signal the priority level of the coexistence request. When + * RF operations are scheduled with RF_scheduleCmd(), the scheduler can be configured + * to override the default coexistence priority level for the RF operation. + * + * The coexistence priority level is binary because it translates to a high/low output signal. + */ +typedef enum { + RF_PriorityCoexDefault = 0, ///< Default priority. Use value configured by setup command. + RF_PriorityCoexLow = 1, ///< Low priority. Override default value configured by setup command. + RF_PriorityCoexHigh = 2, ///< High priority. Override default value configured by setup command. +} RF_PriorityCoex; + +/** + * @brief Behavior for coexistence request signal. + * + * When the RF driver is configured for three-wire coexistence mode, one of the + * output wires will signal the request level of the coexistence request. When + * RF operations are scheduled with RF_scheduleCmd(), the scheduler can be configured + * to override the default coexistence request line behavior for the RF operation in RX. + * + * This override will be ignored if the option to set request for an entire chain is active. + */ +typedef enum { + RF_RequestCoexDefault = 0, ///< Default request line behavior. Use value configured by setup command. + RF_RequestCoexAssertRx = 1, ///< Assert REQUEST in RX. Override default value configured by setup command. + RF_RequestCoexNoAssertRx = 2, ///< Do not assert REQUEST in RX. Override default value configured by setup command. +} RF_RequestCoex; + +/** + * @brief Runtime coexistence override parameters + * + * When RF operations are scheduled with RF_scheduleCmd(), the scheduler can be configured + * to override the default coexistence behavior. This structure encapsulates the available parameters. + */ +typedef struct { + RF_PriorityCoex priority; ///< Priority level for coexistence priority signal. + RF_RequestCoex request; ///< Behavior for coexistence request signal. +} RF_CoexOverride; + +/** + * @brief Coexistence override settings for BLE5 application scenarios + * + * This configuration is provided to the BLE Stack to override the default coexistence configuration + * depending on the current application and stack states. + */ +typedef struct { + RF_CoexOverride bleInitiator; + RF_CoexOverride bleConnected; + RF_CoexOverride bleBroadcaster; + RF_CoexOverride bleObserver; +} RF_CoexOverride_BLEUseCases; + +/** @brief Status codes for various RF driver functions. + * + * RF_Stat is reported as return value for RF driver functions which + * execute direct and immediate commands. + * Such commands are executed by RF_runDirectCmd() and RF_runImmediateCmd() in the + * first place, but also by some convenience functions like RF_cancelCmd(), + * RF_flushCmd(), RF_getInfo() and others. + */ +typedef enum { + RF_StatBusyError, ///< Command not executed because RF driver is busy. + RF_StatRadioInactiveError, ///< Command not executed because RF core is powered down. + RF_StatCmdDoneError, ///< Command finished with an error. + RF_StatInvalidParamsError, ///< Function was called with an invalid parameter. + RF_StatCmdEnded, ///< Cmd is found in the pool but was already ended. + RF_StatError = 0x80, ///< General error specifier. + RF_StatCmdDoneSuccess, ///< Command finished with success. + RF_StatCmdSch, ///< Command successfully scheduled for execution. + RF_StatSuccess ///< Function finished with success. +} RF_Stat; + +/** @brief Data type for events during command execution. + * + * Possible event flags are listed in @ref RF_Core_Events and @ref RF_Driver_Events. + */ +typedef uint64_t RF_EventMask; + +/** @brief A unified type for radio setup commands of different PHYs. + * + * Radio setup commands are used to initialize a PHY on the RF core. + * Various partially similar commands exist, each one represented + * by a different data type. + * RF_RadioSetup is a generic container for all types. + * A specific setup command is usually exported from SmartRF Studio + * and then passed to the RF driver in RF_open(). + */ +typedef union { + rfc_command_t commandId; ///< Generic command identifier. This is the first field + ///< in every radio operation command. + rfc_CMD_RADIO_SETUP_t common; ///< Radio setup command for BLE and IEEE modes + rfc_CMD_BLE5_RADIO_SETUP_t ble5; ///< Radio setup command for BLE5 mode + rfc_CMD_PROP_RADIO_SETUP_t prop; ///< Radio setup command for PROPRIETARY mode on 2.4 GHz + rfc_CMD_PROP_RADIO_DIV_SETUP_t prop_div; ///< Radio setup command for PROPRIETARY mode on Sub-1 Ghz + rfc_CMD_RADIO_SETUP_PA_t common_pa; ///< Radio setup command for BLE and IEEE modes with High Gain PA + rfc_CMD_BLE5_RADIO_SETUP_PA_t ble5_pa; ///< Radio setup command for BLE5 mode with High Gain PA + rfc_CMD_PROP_RADIO_SETUP_PA_t prop_pa; ///< Radio setup command for PROPRIETARY mode on 2.4 GHz with High Gain PA + rfc_CMD_PROP_RADIO_DIV_SETUP_PA_t prop_div_pa; ///< Radio setup command for PROPRIETARY mode on Sub-1 Ghz with High Gain PA +} RF_RadioSetup; + +/** @brief Client-related RF driver events. + * + * Events originating in the RF driver but not directly related to a specific radio command, + * are called client events. + * Clients may subscribe to these events by specifying a callback function RF_Params::pClientEventCb. + * Events are activated by specifying a bitmask RF_Params::nClientEventMask. + * The callback is called separately for every event providing an optional argument. + * + * @code + * void onClientEvent(RF_Handle h, RF_ClientEvent event, void* arg) + * { + * switch (event) + * { + * case RF_ClientEventPowerUpFinished: + * // Set output port + * break; + * default: + * // Unsubscribed events must not be issued. + * assert(false); + * } + * } + * + * RF_Params params; + * params.pClientEventCb = &onClientEvent; + * params.nClientEventMask = RF_ClientEventPowerUpFinished; + * RF_open(...); + * @endcode + */ +typedef enum { + RF_ClientEventPowerUpFinished = (1 << 0), ///< The RF core has been powered up the radio setup has been finished. + RF_ClientEventRadioFree = (1 << 1), ///< Radio becomes free after a command has been preempted by a high-priority command of another client. + ///< This event is only triggered on a client that has been preempted. + ///< Clients may use this event to retry running their low-priority RF operation. + + RF_ClientEventSwitchClientEntered = (1 << 2) ///< Signals the client that the RF driver is about to switch over from another client. +} RF_ClientEvent; + +/** @brief Global RF driver events. + * + * The RF driver provides an interface through the global \c RFCC26XX_hwAttrs + * struct to register a global, client independent callback. This callback is + * typically used to control board related configurations such as antenna + * switches. + * + * @code + * void globalCallback(RF_Handle h, RF_GlobalEvent event, void* arg) + * { + * switch (event) + * { + * case RF_GlobalEventRadioSetup: + * { + * RF_RadioSetup* setupCommand = (RF_RadioSetup*)arg; + * // Select antenna path + * if (setupCommand->common.commandNo == CMD_PROP_RADIO_DIV_SETUP) { + * // Sub-1 GHz ... + * } else { + * // 2.4 GHz ... + * } + * } + * break; + * + * case RF_GlobalEventRadioPowerDown: + * // Disable antenna switch + * break; + * + * default: + * // Unsubscribed events must not be issued. + * assert(false); + * } + * } + * @endcode + * + * For the coexistence (coex) feature, some of the events are used to handle + * the I/O muxing of the GPIO signals for REQUEST, PRIORITY and GRANT. + * + * @code + * void globalCallback(RF_Handle h, RF_GlobalEvent event, void* arg) + * { + * RF_Cmd* pCurrentCmd = (RF_Cmd*)arg; + * + * if (event & RF_GlobalEventInit) { + * // Initialize and mux coex I/O pins to RF Core I/O signals + * } + * else if (event & RF_GlobalEventCmdStart) { + * if (pCurrentCmd->coexPriority != RF_PriorityCoexDefault){ + * // Release PRIORITY pin from RF Core and set it to value of coexPriority + * } + * } + * else if (event & RF_GlobalEventCmdStop) { + * if (pCurrentCmd->coexPriority != RF_PriorityCoexDefault) { + * // Mux PRIORITY pin to RF Core signal to return to default priority level + * } + * } + * } + * @endcode + * + * \sa #RF_GlobalCallback + */ +typedef enum { + RF_GlobalEventRadioSetup = (1 << 0), ///< The RF core is being reconfigured through a setup command. + ///< The \a arg argument is a pointer to the setup command. + ///< HWI context. + + RF_GlobalEventRadioPowerDown = (1 << 1), ///< The RF core is being powered down. + ///< The \a arg argument is empty. + ///< SWI context. + + RF_GlobalEventInit = (1 << 2), ///< RF_open() is called for the first time (number of registered clients changes from 0 to 1). + ///< The \a arg argument is empty. + ///< Task context. + + RF_GlobalEventCmdStart = (1 << 3), ///< A command chain is being dispatched to the radio. + ///< The \a arg argument is a pointer to the current command. + ///< HWI context. + + RF_GlobalEventCmdStop = (1 << 4), ///< Command termination event is handled. + ///< The \a arg argument is a pointer to the current command. + ///< HWI context. + + RF_GlobalEventCoexControl = (1 << 5), ///< Change to coex configuration is requested + ///< The \a arg argument is pointer to at least 8-bit wide int with value 1=enable, or 0=disable + ///< Task/HWI context. +} RF_GlobalEvent; + + +/** @brief Event mask for combining #RF_ClientEvent event flags in #RF_Params::nClientEventMask. + * + */ +typedef uint32_t RF_ClientEventMask; + +/** @brief Event mask for combining #RF_GlobalEvent event flags in #RFCC26XX_HWAttrsV2::globalEventMask. + * + */ +typedef uint32_t RF_GlobalEventMask; + +/** @brief Command handle that is returned by RF_postCmd(). + * + * A command handle is an integer number greater equals zero and identifies + * a command container in the RF driver's internal command queue. A client + * can dispatch a command with RF_postCmd() and use the command handle + * later on to make the RF driver interact with the command. + * + * A negative value has either a special meaning or indicates an error. + * + * @sa RF_pendCmd(), RF_flushCmd(), RF_cancelCmd(), ::RF_ALLOC_ERROR, + * ::RF_CMDHANDLE_FLUSH_ALL + */ +typedef int16_t RF_CmdHandle; + +/** @struct RF_Object + * @brief Stores the client's internal configuration and states. + * + * Before RF_open() can be called, an instance of RF_Object must be created where + * the RF driver can store its internal configuration and states. + * This object must remain persistent throughout application run-time and must not be + * modified by the application. + * + * The size of #RF_Object can be optimized for single-mode applications by providing a + * `RF_SINGLEMODE` symbol at compilation time. The pre-built single-mode archive was generated + * with this symbol defined, hence any project using this archive must also define `RF_SINGLEMODE` + * on project level. + * + * @note Except configuration fields before call to RF_open(), modification of + * any field in %RF_Object is forbidden. + */ + + +/** @cond */ + +typedef struct RF_ObjectMultiMode RF_Object; + +/** Definition of the RF_Object structure for multi mode applications. + * It is applicable with the multi mode RF driver through the #RF_Object common type. + */ +struct RF_ObjectMultiMode{ + /// Configuration + struct { + uint32_t nInactivityTimeout; ///< Inactivity timeout in us. + RF_Mode* pRfMode; ///< Mode of operation. + RF_RadioSetup* pRadioSetup; ///< Pointer to the setup command to be executed at power up. + uint32_t nPhySwitchingDuration; ///< Radio reconfiguration time to this client's phy and protocol. + uint32_t nPowerUpDuration; ///< Radio power up time to be used to calculate future wake-up events. + bool bMeasurePowerUpDuration; ///< Indicates if nPowerUpDuration holds a fix value or being measured and updated at every power up. + bool bUpdateSetup; ///< Indicates if an analog configuration update should be performed at the next setup command execution. + uint16_t nPowerUpDurationMargin; ///< Power up duration margin in us. + void* pPowerCb; ///< \deprecated Power up callback, will go away in future versions, see clientConfig::pClienteventCb instead + void* pErrCb; ///< Error callback. + void* pClientEventCb; ///< Client event callback. + RF_ClientEventMask nClientEventMask; ///< Client event mask to activate client event callback. + uint16_t nPhySwitchingDurationMargin; ///< Phy switching duration margin in us. It is used to calculate when run-time conflicts shall be resolved. + uint32_t nID; ///< RF handle identifier. + } clientConfig; + /// State & variables + struct { + struct { + rfc_CMD_FS_t cmdFs; ///< FS command to be executed when the radio is powered up. + } mode_state; ///< (Mode-specific) state structure + SemaphoreP_Struct semSync; ///< Semaphore used by RF_runCmd(), RF_pendCmd() and power down sequence. + RF_EventMask volatile eventSync; ///< Event mask/value used by RF_runCmd() and RF_pendCmd(). + void* pCbSync; ///< Internal storage of user callbacks when RF_runCmd() is used. + RF_EventMask unpendCause; ///< Internal storage of the return value of RF_pendCmd(). + ClockP_Struct clkReqAccess; ///< Clock used for request access timeout. + bool bYielded; ///< Flag indicates that the radio can be powered down at the earliest convenience. + } state; +}; + +/** @endcond */ + +/** @brief A handle that is returned by to RF_open(). + * + * %RF_Handle is used for further RF client interaction with the RF driver. + * An invalid handle has the value NULL. + */ +typedef RF_Object* RF_Handle; + + +/** @brief RAT handle that is returned by RF_ratCompare() or RF_ratCapture(). + * + * An %RF_RatHandle is an integer number with value greater than or equal to zero and identifies + * a Radio Timer Channel in the RF driver's internal RAT module. A client can interact with the + * RAT module through the RF_ratCompare(), RF_ratCapture() or RF_ratDisableChannel() APIs. + * + * A negative value indicates an error. A typical example when RF_ratCompare() returns with RF_ALLOC_ERROR. + */ +typedef int8_t RF_RatHandle; + +/** @brief Selects the entry of interest in RF_getInfo(). + * + */ +typedef enum { + RF_GET_CURR_CMD, ///< Retrieve a command handle of the current command. + RF_GET_AVAIL_RAT_CH, ///< Create a bitmask showing available RAT channels. + RF_GET_RADIO_STATE, ///< Show the current RF core power state. 0: Radio OFF, 1: Radio ON. + RF_GET_SCHEDULE_MAP, ///< Deprecated. Not supported. + RF_GET_CLIENT_LIST, ///< Provide the client list. + RF_GET_CLIENT_SWITCHING_TIME, ///< Provide the client to client switching times +} RF_InfoType; + +/** @brief Stores output parameters for RF_getInfo(). + * + * This union structure holds one out of multiple data types. + * The contained value is selected by #RF_InfoType. + */ +typedef union { + RF_CmdHandle ch; ///< Command handle (#RF_GET_CURR_CMD). + uint16_t availRatCh; ///< Available RAT channels (RF_GET_AVAIL_RAT_CH). + bool bRadioState; ///< Current RF core power state (#RF_GET_RADIO_STATE). + RF_Handle pClientList[2]; ///< Client pointer list, [0]: client 1, [1]: client 2. + uint32_t phySwitchingTimeInUs[2]; ///< Phy switching time 0: client 1 -> 2, 1 : client 2 -> 1. + void *pScheduleMap; ///< Deprecated. Not supported. +} RF_InfoVal; + +/** @brief RF schedule map entry structure. + * + */ +typedef struct { + RF_CmdHandle ch; ///< Command handle + RF_Handle pClient; ///< Pointer to client object + uint32_t startTime; ///< Start time (in RAT tick) of the command or access request + uint32_t endTime; ///< End time (in RAT tick) of the command or access request + RF_Priority priority; ///< Priority of the command or access request +} RF_ScheduleMapElement; + +/** @brief RF schedule map structure. + * + */ +typedef struct { + RF_ScheduleMapElement accessMap[RF_NUM_SCHEDULE_ACCESS_ENTRIES]; ///< Access request schedule map + RF_ScheduleMapElement commandMap[RF_NUM_SCHEDULE_COMMAND_ENTRIES]; ///< Command schedule map +} RF_ScheduleMap; + +/** @brief Handles events related to RF command execution. + * + * RF command callbacks notify the application of any events happening during RF command execution. + * Events may either refer to RF core interrupts (@ref RF_Core_Events) or may be generated by the RF driver + * (@ref RF_Driver_Events). + * + * RF command callbacks are set up as parameter to RF_postCmd() or RF_runCmd() and provide: + * + * - the relevant driver client handle \a h which was returned by RF_open(), + * - the relevant radio operation command handle \a ch, + * - an event mask \a e containing the occurred events. + * + * RF command callbacks are executed in Software Interrupt (SWI) context and must not perform any + * blocking operation. + * The priority is configurable via #RFCC26XX_HWAttrsV2 in the board file or #RF_CTRL_SET_SWI_PRIORITY in RF_control(). + * + * The %RF_Callback function type is also used for signaling power events and + * errors. + * These are set in #RF_Params::pPowerCb and #RF_Params::pErrCb respectively. + * In case of a power event, \a ch can be ignored and \a e has #RF_EventPowerUp set. + * In case of an error callback, \a ch contains an error code instead of a command handle and + * \a e has the #RF_EventError flag set. + * + * @note Error and power callbacks will be replaced by #RF_ClientCallback in future releases. + */ +typedef void (*RF_Callback)(RF_Handle h, RF_CmdHandle ch, RF_EventMask e); + +/** @brief Handles events related to the Radio Timer (RAT). + * + * The RF driver provides an interface to the Radio Timer through RF_ratCompare(), RF_ratCapture() and + * RF_ratDisableChannel() APIs. Each API call receives an optional input argument of the type + * RF_RatCallback. When a timer event occurs (compare, capture or error events), the registered + * callback is invoked. + * + * The RF_RatCallback provides the following argument: + * - the relevant driver client handle \a h which was returned by RF_open(), + * - the relevant rat timer handle \a rh which the event is caused by, + * - an event mask \a e containing the occurred event (RF_EventRatCh or RF_EventError) + * - the captured value or the compare time \a compareCaptureTime read from the Radio Timer channel. + */ +typedef void (*RF_RatCallback)(RF_Handle h, RF_RatHandle rh, RF_EventMask e, uint32_t compareCaptureTime); + +/** + * @brief Handles events related to a driver instance. + * + * The RF driver produces additional events that are not directly related to the execution of a certain command, but + * happen during general RF driver operations. + * This includes power-up events, client switching events and others. + * + * A client callback provides the following arguments: + * - the relevant driver client handle \a h which was returned by RF_open(), + * - an event identifier \a event, + * - an optional argument \a arg depending on the event. + * + * RF client callbacks are executed in Software Interrupt (SWI) context and must not perform any blocking operation. + * The priority is configurable via #RFCC26XX_HWAttrsV2 in the board file or #RF_CTRL_SET_SWI_PRIORITY in RF_control(). + */ +typedef void (*RF_ClientCallback)(RF_Handle h, RF_ClientEvent event, void* arg); + +/** + * @brief Handles global events as part of PHY configuration. + * + * The RF driver serves additional global, client independent events by invoking the #RF_GlobalCallback function + * registered through #RFCC26XX_HWAttrsV2::globalCallback in the board file. The function can subscribe to + * particular events through the #RFCC26XX_HWAttrsV2::globalEventMask, and receives the following arguments: + * - the relevant driver client handle \a h which was returned by RF_open(), + * - an event identifier \a event, + * - an optional argument \a arg depending on the event. + * + * If multiple events happen at the same time, the callback is always invoked separately for each event. + * Depending on the event, the callback might be invoked in SWI or HWI context. + */ +typedef void (*RF_GlobalCallback)(RF_Handle h, RF_GlobalEvent event, void* arg); + +/** @brief RF driver configuration parameters. + * + * %RF_Params is used for initial RF driver configuration. + * It is initialized by RF_Params_init() and used by RF_open(). + * Each client has its own set of parameters. + * They are reconfigured on a client switch. + * Some of the parameters can be changed during run-time using RF_control(). + */ +typedef struct { + uint32_t nInactivityTimeout; ///< Inactivity timeout in microseconds. + ///< The default value is 0xFFFFFFFF (infinite). + + uint32_t nPowerUpDuration; ///< A custom power-up duration in microseconds. + ///< If 0, the RF driver will start with a conservative value and measure the actual time during the first power-up. + ///< The default value is 0. + + RF_Callback pPowerCb; ///< \deprecated Power up callback, will be removed future versions, see RF_Params::pClienteventCb instead. + ///< The default value is NULL. + + RF_Callback pErrCb; ///< \deprecated Callback function for driver error events. + + uint16_t nPowerUpDurationMargin; ///< An additional safety margin to be added to #RF_Params::nPowerUpDuration. + ///< This is necessary because of other hardware and software interrupts + ///< preempting the RF driver interrupt handlers and state machine. + ///< The default value is platform-dependent. + + uint16_t nPhySwitchingDurationMargin; ///< An additional safety margin to be used to calculate when conflicts shall be evaluated run-time. + + RF_ClientCallback pClientEventCb; ///< Callback function for client-related events. + ///< The default value is NULL. + + RF_ClientEventMask nClientEventMask; ///< Event mask used to subscribe certain client events. + ///< The purpose is to keep the number of callback executions small. + + uint32_t nID; ///< RF handle identifier. +} RF_Params; + +/** @brief Controls the behavior of the RF_scheduleCmd() API. + * + */ +typedef enum { + RF_StartNotSpecified = 0, + RF_StartAbs = 1, +} RF_StartType; + +/** @brief Controls the behavior of the RF_scheduleCmd() API. + * + */ +typedef enum { + RF_EndNotSpecified = 0, + RF_EndAbs = 1, + RF_EndRel = 2, + RF_EndInfinit = 3, + } RF_EndType; + +/* RF command. */ +typedef struct RF_Cmd_s RF_Cmd; + +/* RF command . */ +struct RF_Cmd_s { + List_Elem _elem; /* Pointer to next and previous elements. */ + RF_Callback volatile pCb; /* Pointer to callback function */ + RF_Op* pOp; /* Pointer to (chain of) RF operations(s) */ + RF_Object* pClient; /* Pointer to client */ + RF_EventMask bmEvent; /* Enable mask for interrupts from the command */ + RF_EventMask pastifg; /* Accumulated value of events happened within a command chain */ + RF_EventMask rfifg; /* Return value for callback 0:31 - RF_CPE0_INT, 32:63 - RF_HW_INT */ + RF_CmdHandle ch; /* Command handle */ + RF_Priority ePri; /* Priority of RF command */ + uint8_t volatile flags; /* [0: Aborted, 1: Stopped, 2: canceled] */ + uint32_t startTime; /* Command start time (in RAT ticks) */ + RF_StartType startType; /* Command start time type */ + uint32_t allowDelay; /* Delay allowed if the start time cannot be met. */ + uint32_t endTime; /* Command end time (in RAT ticks) */ + RF_EndType endType; /* Command end type */ + uint32_t duration; /* Command duration (in RAT ticks) */ + uint32_t activityInfo; /* General value supported by user */ + RF_PriorityCoex coexPriority; /* Command priority to use for coexistence request. */ + RF_RequestCoex coexRequest; /* Command REQUEST line behavior to use for coexistence request. */ +}; + +/** @brief RF Hardware attributes. + * + * This data structure contains platform-specific driver configuration. + * It is usually defined globally in a board support file. + */ +typedef struct { + uint8_t hwiPriority; ///< Priority for HWIs belong to the RF driver. + uint8_t swiPriority; ///< Priority for SWIs belong to the RF driver. + bool xoscHfAlwaysNeeded; ///< Indicate that the XOSC HF should be turned on by the power driver + RF_GlobalCallback globalCallback; ///< Pointer to a callback function serving client independent events listed in #RF_GlobalEvent. + RF_GlobalEventMask globalEventMask; ///< Event mask which the globalCallback is invoked upon. +} RFCC26XX_HWAttrsV2; + +/** @brief Controls the behavior of the state machine of the RF driver when a conflict is identified + * run-time between the commands waiting on the pend queue and the commands being actively executed + * by the radio. + */ +typedef enum +{ + RF_ConflictNone = 0, + RF_ConflictReject = 1, + RF_ConflictAbort = 2, +} RF_Conflict; + +/** @brief Describes the location within the pend queue where the new command was inserted by the scheduler. + */ +typedef enum +{ + RF_ScheduleStatusError = -3, + RF_ScheduleStatusNone = 0, + RF_ScheduleStatusTop = 1, + RF_ScheduleStatusMiddle = 2, + RF_ScheduleStatusTail = 4, + RF_ScheduleStatusPreempt = 8 +} RF_ScheduleStatus; + +/** + * @brief Handles the queue sorting algorithm when a new command is submitted to the driver from any of + * the active clients. + * + * The function is invoked within the RF_scheduleCmd API. + * + * The default algorithm is subscribed through the #RFCC26XX_SchedulerPolicy::submitHook and implemented + * in the RF driver. The arguments are: + * - \a pCmdNew points to the command to be submitted. + * - \a pCmdBg is the running background command. + * - \a pCmdFg is the running foreground command. + * - \a pPendQueue points to the head structure of pend queue. + * - \a pDoneQueue points to the head structure of done queue. + * + * In case the radio APIs do not distinguish between background and foreground contexts, the active operation + * will be returned within the pCmdBg pointer. If there are no commands being executed, both the + * pCmdBg and pCmdFg pointers are returned as NULL. + */ +typedef RF_ScheduleStatus (*RF_SubmitHook)(RF_Cmd* pCmdNew, RF_Cmd* pCmdBg, RF_Cmd* pCmdFg, List_List* pPendQueue, List_List* pDoneQueue); + +/** + * @brief Defines the conflict resolution in runtime. + * + * The function is invoked if a conflict is identified before the start-time of the next radio command in + * the pending queue. The return value of type #RF_Conflict determines the policy to be followed by the RF driver. + * + * The arguments are: + * - \a pCmdBg is the running background command. + * - \a pCmdFg is the running foreground command. + * - \a pPendQueue points to the head structure of pend queue. + * - \a pDoneQueue points to the head structure of done queue. + */ +typedef RF_Conflict (*RF_ConflictHook)(RF_Cmd* pCmdBg, RF_Cmd* pCmdFg, List_List* pPendQueue, List_List* pDoneQueue); + +/** @brief RF scheduler policy. + * + * This data structure contains function hooks which implements the scheduling + * algorithm used to inter-align one or more independent protocol stacks. + */ +typedef struct { + RF_SubmitHook submitHook; ///< Function hook implements the scheduling policy to be executed at the time of RF_scheduleCmd API call. + RF_ConflictHook conflictHook; ///< Function hook implements the runtime conflict resolution, if any identified at the start time of next command. +} RFCC26XX_SchedulerPolicy; + +/** @brief Controls the behavior of the RF_scheduleCmd() API. + * + */ +typedef enum { + RF_AllowDelayNone = 0, + RF_AllowDelayAny = UINT32_MAX +} RF_AllowDelay; + +/* @brief RF schedule command parameter struct + * + * RF schedule command parameters are used with the RF_scheduleCmd() call. + */ +typedef struct { + uint32_t startTime; ///< Start time in RAT Ticks for the radio command + RF_StartType startType; ///< Start type for the start time + uint32_t allowDelay; ///< Control word to define the policy of the scheduler if the timing of a command cannot be met. + ///< Only applicable on CC13x2 and CC26x2 devices. + ///< RF_AllowDelayNone: Reject the command. + ///< RF_AllowDelayAny: Append the command to the end of the queue. + uint32_t endTime; ///< End time in RAT Ticks for the radio command + RF_EndType endType; ///< End type for the end time + uint32_t duration; ///< Duration in RAT Ticks for the radio command + uint32_t activityInfo; ///< Activity info provided by user + RF_PriorityCoex coexPriority; ///< Priority to use for coexistence request. + RF_RequestCoex coexRequest; ///< REQUEST line behavior to use for coexistence request. +} RF_ScheduleCmdParams; + +/** @brief RF request access parameter struct + * + * RF request access command parameters are used with the RF_requestAccess() call. + */ +typedef struct { + uint32_t duration; ///< Radio access duration in RAT Ticks requested by the client + uint32_t startTime; ///< Start time window in RAT Time for radio access + RF_Priority priority; ///< Access priority +} RF_AccessParams; + +/** @brief Select the preferred RAT channel through the configuration of #RF_ratCompare() or #RF_ratCapture(). + * + * If RF_RatChannelAny is provided within the channel configuration (default), the API will + * allocate the first available channel. Otherwise, it tries to allocate the requested channel, + * and if it is not available, returns with #RF_ALLOC_ERROR. + */ +typedef enum { + RF_RatChannelAny = -1, ///< Chose the first available channel. + RF_RatChannel0 = 0, ///< Use RAT user channel 0. + RF_RatChannel1 = 1, ///< Use RAT user channel 1. + RF_RatChannel2 = 2, ///< Use RAT user channel 2. +} RF_RatSelectChannel; + +/** @brief Selects the source signal for #RF_ratCapture(). + * + * The source of a capture event can be selected through the source field of the + * #RF_RatConfigCapture configuration structure. + */ +typedef enum { + RF_RatCaptureSourceRtcUpdate = 20, ///< Selects the RTC update signal source. + RF_RatCaptureSourceEventGeneric = 21, ///< Selects the Generic event of Event Fabric as source. + RF_RatCaptureSourceRfcGpi0 = 22, ///< Selects the RFC_GPI[0] as source. This can be used i.e. + ///< to capture events on a GPIO. This requires that the GPIO + ///< is connected to RFC_GPO[0] from the GPIO driver. + RF_RatCaptureSourceRfcGpi1 = 23 ///< Selects the RFC_GPO[1] as source. This can be used i.e. + ///< to capture events on a GPIO. This requires that the GPIO + ///< is connected to RFC_GPO[1] from the GPIO driver. +} RF_RatCaptureSource; + +/** @brief Selects the mode of #RF_ratCapture(). + * + * The trigger mode of a capture event can be selected through the mode field of + * #RF_RatConfigCapture configuration structure. + */ +typedef enum { + RF_RatCaptureModeRising = 0, ///< Rising edge of the selected source will trigger a capture event. + RF_RatCaptureModeFalling = 1, ///< Falling edge of the selected source will trigger a capture event. + RF_RatCaptureModeBoth = 2 ///< Both rising and falling edges of the selected source will generate + ///< capture events. +} RF_RatCaptureMode; + +/** @brief Selects the repetition of #RF_ratCapture(). + * + * The configuration of a capture channel also defines whether the channel should be + * freed or automatically rearmed after a capture event occurred. In the latter case, the + * user needs to free the channel manually through the #RF_ratDisableChannel() API. + */ +typedef enum { + RF_RatCaptureSingle = 0, ///< Free the channel after the first capture event. + RF_RatCaptureRepeat = 1 ///< Rearm the channel after each capture events. +} RF_RatCaptureRepetition; + +/** @brief Selects the mode of the RAT_GPO[x] for #RF_ratCompare() or #RF_ratCapture(). + * + * In case of compare mode, the channel can generate an output signal of the selected + * mode on the configured RAT_GPO[x] interface, and can be interconnected with + * other subsystems through the RFC_GPO[x] or Event Fabric. An example use case is + * to generate a pulse on a GPIO. + * + * In case of capture mode, the channel can also generate an output signal of the + * selected mode on the configured RAT_GPO[x] interface. Note that the configuration + * of this output event is independent of the source signal of the capture event. + * An example use case is to generate a pulse on a GPIO on each raising edge of another + * GPIO source. + * + */ +typedef enum { + RF_RatOutputModePulse = 0, ///< Generates a one-clock period width pulse. + RF_RatOutputModeSet = 1, ///< Sets the output high on a RAT event. + RF_RatOutputModeClear = 2, ///< Sets the output low on a RAT event. + RF_RatOutputModeToggle = 3, ///< Inverts the polarity of the output. + RF_RatOutputModeAlwaysZero = 4, ///< Sets the output low independently of any RAT events. + RF_RatOutputModeAlwaysOne = 5, ///< Sets the output high independently of any RAT events. +} RF_RatOutputMode; + +/** @brief Selects GPO to be used with #RF_ratCompare() or #RF_ratCapture(). + * + * RAT_GPO[0] - Reserved by the RF core. User shall not modify the configuration, + * but can observe the signal through any of RFC_GPO[0:3]. + * RAT_GPO[1] - Reserved by the RF core only if sync word detection is enabled. + * Otherwise can be used through RFC_GPO[0:3]. + * RAT_GPO[2:3] - Available and can be used through any of the RFC_GPO[0:3]. + * RAT_GPO[4:7] - Available and can be used through the Event fabric. + */ +typedef enum { + RF_RatOutputSelectRatGpo1 = 1, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[1] + RF_RatOutputSelectRatGpo2 = 2, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[2] + RF_RatOutputSelectRatGpo3 = 3, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[3] + RF_RatOutputSelectRatGpo4 = 4, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[4] + RF_RatOutputSelectRatGpo5 = 5, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[5] + RF_RatOutputSelectRatGpo6 = 6, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[6] + RF_RatOutputSelectRatGpo7 = 7, ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[7] +} RF_RatOutputSelect; + +/** @brief RF_ratCapture parameter structure. + * + * %RF_RatCapture parameters are used with the #RF_ratCapture() call. + */ +typedef struct { + RF_RatCallback callback; ///< Callback function to be invoked upon a capture event (optional). + RF_RatHandle channel; ///< RF_RatHandle identifies the channel to be allocated. + RF_RatCaptureSource source; ///< Configuration of the event source to cause a capture event. + RF_RatCaptureMode captureMode; ///< Configuration of the mode of event to cause a capture event. + RF_RatCaptureRepetition repeat; ///< Configuration of the channel to be used in single or repeated mode. +} RF_RatConfigCapture; + +/** @brief RF_ratCompare parameter structure. + * + * %RF_RatCompare parameters are used with the #RF_ratCompare() call. + */ +typedef struct { + RF_RatCallback callback; ///< Callback function to be invoked upon a capture event (optional). + RF_RatHandle channel; ///< RF_RatHandle identifies the channel to be allocated. + uint32_t timeout; ///< Timeout value in RAT ticks to be programmed in the timer as the + ///< trigger of compare event. +} RF_RatConfigCompare; + +/** @brief RAT related IO parameter structure. + * + * These parameters are used with the #RF_ratCompare() or #RF_ratCapture() calls. + */ +typedef struct { + RF_RatOutputMode mode; ///< The mode the GPO should operate in. + RF_RatOutputSelect select; ///< The signal which shall be connected to the GPO. +} RF_RatConfigOutput; + +/** @brief Creates a a new client instance of the RF driver. + * + * This function initializes an RF driver client instance using \a pObj as storage. + * It does not power up the RF core. + * Once the client starts the first RF operation command later in the application, + * the RF core is powered up and set into a PHY mode specified by \a pRfMode. + * The chosen PHY is then configured by a radio setup command \a pRadioSetup. + * Whenever the RF core is powered up, the RF driver re-executes the radio setup command \a pRadioSetup. + * Additional driver behavior may be set by an optional \a params. + * + * @code + * // Define parameters + * RF_Params rfParams; + * rfParams.nInactivityTimeout = 4; + * RF_Params_init(&rfParams); + * rfParams.nInactivityTimeout = 1701; // microseconds + * + * RF_Handle rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams); + * @endcode + * + * @note Calling context : Task + * + * @param pObj Pointer to a #RF_Object that will hold the state for this + * RF client. The object must be in persistent and writable + * memory. + * @param pRfMode Pointer to a #RF_Mode struct holding PHY information + * @param pRadioSetup Pointer to the radio setup command used for this client. + * This is re-executed by the RF Driver on each power-up. + * @param params Pointer to an RF_Params object with the desired driver configuration. + * A NULL pointer results in the default configuration being loaded. + * @return A handle for further RF driver calls on success. Otherwise NULL. + */ +extern RF_Handle RF_open(RF_Object *pObj, RF_Mode *pRfMode, RF_RadioSetup *pRadioSetup, RF_Params *params); + +/** + * @brief Close client connection to RF driver + * + * Allows a RF client (high-level driver or application) to close its connection + * to the RF driver. + * + * @note Calling context : Task + * + * @param h Handle previously returned by RF_open() + */ +extern void RF_close(RF_Handle h); + +/** + * @brief Return current radio timer value + * + * If the radio is powered returns the current radio timer value, if not returns + * a conservative estimate of the current radio timer value + * + * @note Calling context : Task/SWI/HWI + * + * @return Current radio timer value + */ +extern uint32_t RF_getCurrentTime(void); + +/** + * @brief Appends RF operation commands to the driver's command queue and returns a + * command handle. + * + * The RF operation \a pOp may either represent a single operation or may be the first + * operation in a chain. + * If the command queue is empty, the \a pCmd is dispatched immediately. If there are + * other operations pending, then \a pCmd is processed after all other commands have been + * finished. + * The RF operation command must be compatible to the RF_Mode selected by RF_open(), e.g. + * proprietary commands can only be used when the RF core is configured for proprietary mode. + * + * The returned command handle is an identifier that can be used to control command execution + * later on, for instance with RF_pendCmd() or RF_cancelCmd(). + * It is a 16 Bit signed integer value, incremented on every new command. + * If the RF driver runs out of command containers, RF_ALLOC_ERROR is returned. + * + * The priority \a ePri is only relevant in multi-client applications where commands of distinct + * clients may interrupt each other. + * Only commands started by RF_scheduleCmd() can preempt + * running commands. #RF_postCmd() or RF_runCmd() do never interrupt a running command. + * In single-client applications, \a ePri is ignored and should be set to ::RF_PriorityNormal. + * + * A callback function \a pCb might be specified to get notified about events during command + * execution. Events are subscribed by the bit mask \a bmEvent. + * Valid event flags are specified in @ref RF_Core_Events and @ref RF_Driver_Events. + * If no callback is set, RF_pendCmd() can be used to synchronize the current task to command + * execution. For this it is necessary to subscribe all relevant events. + * The termination events ::RF_EventLastCmdDone, ::RF_EventCmdCancelled, ::RF_EventCmdAborted and + * ::RF_EventCmdStopped are always implicitly subscribed. + * + * The following limitations apply to the execution of command chains: + * + * - If TRIG_ABSTIME is used as a start trigger for the first command, TRIG_REL_FIRST_START + * can not be used for any other command. This is because the RF driver may insert a + * frequency-select command (CMD_FS) at the front of the chain when it performs an + * automatic power-up. + * - Having more than one CMD_FS in a chain may lead to unexpected behavior. + * If a chain contains a CMD_FS and the command can be reached by iterating over the pNextOp + * field, then RF driver will always update the cached CMD_FS with the new settings. On the + * next automatic power-up, the RF driver will use the updated frequency. + * + * @note Calling context : Task/SWI + * + * @sa RF_pendCmd(), RF_runCmd(), RF_scheduleCmd(), RF_RF_cancelCmd(), RF_flushCmd(), RF_getCmdOp() + * + * @param h Driver handle previously returned by RF_open() + * @param pOp Pointer to the RF operation command. + * @param ePri Priority of this RF command (used for arbitration in multi-client systems) + * @param pCb Callback function called during command execution and upon completion. + * If RF_postCmd() fails, no callback is made. + * @param bmEvent Bitmask of events that will trigger the callback or that can be pended on. + * @return A handle to the RF command. Return value of RF_ALLOC_ERROR indicates error. + */ +extern RF_CmdHandle RF_postCmd(RF_Handle h, RF_Op *pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent); + +/** + * @brief Sorts and adds commands to the RF driver internal command queue. + * + * @param pCmdNew Pointer to the command to be submitted. + * @param pCmdBg Running background command. + * @param pCmdFg Running foreground command. + * @param pPendQueue Pointer to the head structure of pend queue. + * @param pDoneQueue Pointer to the head structure of done queue.. + * @return RF_defaultSubmitPolicy identifies the success or failure of queuing. + */ +extern RF_ScheduleStatus RF_defaultSubmitPolicy(RF_Cmd* pCmdNew, RF_Cmd* pCmdBg, RF_Cmd* pCmdFg, List_List* pPendQueue, List_List* pDoneQueue); + +/** + * @brief Makes a final decision when a conflict in run-time is identified. + * + * @param pCmdBg Running background command. + * @param pCmdFg Running foreground command. + * @param pPendQueue Pointer to the head structure of pend queue. + * @param pDoneQueue Pointer to the head structure of done queue.. + * @return RF_defaultSubmitPolicy identifies the success or failure of queuing. + */ +extern RF_Conflict RF_defaultConflictPolicy(RF_Cmd* pCmdBg, RF_Cmd* pCmdFg, List_List* pPendQueue, List_List* pDoneQueue); + + +/** + * @brief Initialize the configuration structure to default values to be used with the RF_scheduleCmd() API. + * + * @note Calling context : Task/SWI/HWI + * + * @param pSchParams Pointer to the configuration structure. + * @return none + */ +extern void RF_ScheduleCmdParams_init(RF_ScheduleCmdParams *pSchParams); + +/** + * @brief Schedule an RF operation (chain) to the command queue. + * + * Schedule an #RF_Op to the RF command queue of the client with handle h.
+ * The command can be the first in a chain of RF operations or a standalone RF operation. + * If a chain of operations are posted they are treated atomically, i.e. either all + * or none of the chained operations are run.
+ * All operations must be posted in strictly increasing chronological order. Function returns + * immediately.
+ * + * Limitations apply to the operations posted: + * - The operation must be in the set supported in the chosen radio mode when + * RF_open() was called + * - Only a subset of radio operations are supported + * - Only some of the trigger modes are supported with potential power saving (TRIG_NOW, TRIG_ABSTIME) + * + * @note Calling context : Task/SWI + * + * @param h Handle previously returned by RF_open() + * @param pOp Pointer to the #RF_Op. Must normally be in persistent and writable memory + * @param pSchParams Pointer to the schedule command parameter structure + * @param pCb Callback function called upon command completion (and some other events). + * If RF_scheduleCmd() fails no callback is made + * @param bmEvent Bitmask of events that will trigger the callback. + * @return A handle to the RF command. Return value of RF_ALLOC_ERROR indicates error. + */ +extern RF_CmdHandle RF_scheduleCmd(RF_Handle h, RF_Op *pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent); + +/** + * @brief Synchronizes the calling task to an RF operation command \a ch and + * returns accumulated event flags. + * + * After having dispatched an RF operation represented by \a ch with RF_postCmd(), the + * command is running in parallel on the RF core. Thus, it might be desirable to synchronize + * the calling task to the execution of the command. + * With #RF_pendCmd(), the application can block until one of the events specified in + * \a bmEvent occurs or until the command finishes. + * The function consumes and returns all accumulated event flags that occurred during + * execution if they have been previously subscribed by RF_postCmd(). + * Possible events are specified in @ref RF_Core_Events and @ref RF_Driver_Events. + * The termination events ::RF_EventLastCmdDone, ::RF_EventCmdCancelled, + * ::RF_EventCmdAborted and ::RF_EventCmdStopped are always implicitly subscribed and + * can not be masked. + * + * #RF_pendCmd() may be called multiple times for the same command. + * + * If #RF_pendCmd() is called for a command handle representing a finished command, + * then only the ::RF_EventLastCmdDone flag is returned, regardless of how the command + * finished. + * + * If the command has also a callback set, the callback is executed before #RF_pendCmd() + * returns. + * + * Example: + * @code + * // Dispatch a command to the RF driver's command queue + * RF_CmdHandle ch = RF_postCmd(driver, (RF_Op*)&CMD_PROP_RX, RF_PriorityNormal, NULL, RF_EventRxEntryDone); + * assert(ch != RF_ALLOC_ERROR); + * + * bool finished = false; + * while (finished == false) + * { + * // Synchronize to events during command execution. + * uint32_t events = RF_pendCmd(driver, ch, RF_EventRxEntryDone); + * // Check events that happen during execution + * if (events & RF_EventRxEntryDone) + * { + * // Process packet + * } + * if (events & (RF_EventLastCmdDone | RF_EventCmdStopped | RF_EventCmdAborted | RF_EventCmdCancelled)) + * { + * finished = true; + * } + * // ... + * } + * @endcode + * + * @note Calling context : Task + * + * @param h Driver handle previously returned by RF_open() + * @param ch Command handle previously returned by RF_postCmd(). + * @param bmEvent Bitmask of events that make RF_pendCmd() return. Termination events + * are always implicitly subscribed. + * @return Event flags accumulated during command execution. + * + * @sa RF_postCmd() + */ +extern RF_EventMask RF_pendCmd(RF_Handle h, RF_CmdHandle ch, RF_EventMask bmEvent); + +/** + * @brief Runs synchronously an RF operation command or a chain of commands and returns + * the termination reason. + * + * This function appends an RF operation command or a chain of commands to the RF driver's + * command queue and then waits for it to complete. + * A command is completed if one of the termination events ::RF_EventLastCmdDone, + * ::RF_EventCmdCancelled, ::RF_EventCmdAborted, ::RF_EventCmdStopped occurred. + * + * This function is a combination of RF_postCmd() and RF_pendCmd(). + * All options and limitations for RF_postCmd() apply here as well. + * + * An application should always ensure that the command completed in the expected way and + * with an expected status code. + * + * @note Calling context : Task + * + * @param h Driver handle previously returned by RF_open() + * @param pOp Pointer to the RF operation command. + * @param ePri Priority of this RF command (used for arbitration in multi-client systems) + * @param pCb Callback function called during command execution and upon completion. + * If RF_runCmd() fails, no callback is made. + * @param bmEvent Bitmask of events that will trigger the callback or that can be pended on. + * @return The relevant termination event. + * + * @sa RF_postCmd(), RF_pendCmd(), RF_cancelCmd(), RF_flushCmd() + */ +extern RF_EventMask RF_runCmd(RF_Handle h, RF_Op *pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent); + +/** + * @brief Runs synchronously a (chain of) RF operation(s) for dual or single-mode. + * + * Allows a (chain of) operation(s) to be scheduled to the command queue and then waits + * for it to complete.
A command is completed if one of the RF_EventLastCmdDone, + * RF_EventCmdCancelled, RF_EventCmdAborted, RF_EventCmdStopped occurred. + * + * @note Calling context : Task + * @note Only one call to RF_pendCmd() or RF_runScheduleCmd() can be made at a time for + * each client + * + * @param h Handle previously returned by RF_open() + * @param pOp Pointer to the #RF_Op. Must normally be in persistent and writable memory + * @param pSchParams Pointer to the schedule command parameter structure + * @param pCb Callback function called upon command completion (and some other events). + * If RF_runScheduleCmd() fails, no callback is made. + * @param bmEvent Bitmask of events that will trigger the callback. + * @return The relevant command completed event. + */ +extern RF_EventMask RF_runScheduleCmd(RF_Handle h, RF_Op *pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent); + +/** + * @brief Abort/stop/cancel single command in command queue. + * + * If command is running, aborts/stops it and posts callback for the + * aborted/stopped command.
+ * If command has not yet run, cancels it it and posts callback for the + * canceled command.
+ * If command has already run or been aborted/stopped/canceled, has no effect.
+ * If RF_cancelCmd is called from a Swi context with same or higher priority + * than RF Driver Swi, when the RF core is powered OFF -> the cancel callback will be delayed + * until the next power-up cycle.
+ * + * @note Calling context : Task/SWI + * + * @param h Handle previously returned by RF_open() + * @param ch Command handle previously returned by RF_postCmd(). + * @param mode 1: Stop gracefully, 0: abort abruptly + * @return RF_Stat indicates if command was successfully completed + */ +extern RF_Stat RF_cancelCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode); + +/** + * @brief Abort/stop/cancel command and any subsequent commands in command queue. + * + * If command is running, aborts/stops it and then cancels all later commands in queue.
+ * If command has not yet run, cancels it and all later commands in queue.
+ * If command has already run or been aborted/stopped/canceled, has no effect.
+ * The callbacks for all canceled commands are issued in chronological order.
+ * If RF_flushCmd is called from a Swi context with same or higher priority + * than RF Driver Swi, when the RF core is powered OFF -> the cancel callback will be delayed + * until the next power-up cycle.
+ * + * @note Calling context : Task/SWI + * + * @param h Handle previously returned by RF_open() + * @param ch Command handle previously returned by RF_postCmd(). + * @param mode 1: Stop gracefully, 0: abort abruptly + * @return RF_Stat indicates if command was successfully completed + */ +extern RF_Stat RF_flushCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode); + +/** + * @brief Send any Immediate command.
+ * + * Immediate Command is send to RDBELL, if radio is active and the RF_Handle points + * to the current client.
+ * In other appropriate RF_Stat values are returned.
+ * + * @note Calling context : Task/SWI/HWI + * + * @param h Handle previously returned by RF_open() + * @param pCmdStruct Pointer to the immediate command structure + * @return RF_Stat indicates if command was successfully completed + */ +extern RF_Stat RF_runImmediateCmd(RF_Handle h, uint32_t *pCmdStruct); + +/** + * @brief Send any Direct command.
+ * + * Direct Command value is send to RDBELL immediately, if radio is active and + * the RF_Handle point to the current client.
+ * In other appropriate RF_Stat values are returned.
+ * + * @note Calling context : Task/SWI/HWI + * + * @param h Handle previously returned by RF_open() + * @param cmd Direct command value. + * @return RF_Stat indicates if command was successfully completed. + */ +extern RF_Stat RF_runDirectCmd(RF_Handle h, uint32_t cmd); + +/** + * @brief Signal that radio client is not going to issue more commands in a while.
+ * + * Hint to RF driver that, irrespective of inactivity timeout, no new further + * commands will be issued for a while and thus the radio can be powered down at + * the earliest convenience. In case the RF_yield() is called within a callback, + * the callback will need to finish and return before the power down sequence is + * initiated. Posting new commands to the queue will cancel any pending RF_yield() + * request.
+ * + * @note Calling context : Task + * + * @param h Handle previously returned by RF_open() + */ +extern void RF_yield(RF_Handle h); + +/** + * @brief Function to initialize the RF_Params struct to its defaults. + * + * @param params An pointer to RF_Params structure for + * initialization + * + * Defaults values are: + * nInactivityTimeout = BIOS_WAIT_FOREVER + * nPowerUpDuration = RF_DEFAULT_POWER_UP_TIME + */ +extern void RF_Params_init(RF_Params *params); + +/** + * @brief Get value for some RF driver parameters.
+ * + * @note Calling context : Task/SWI/HWI + * + * @param h Handle previously returned by RF_open() + * @param type Request value parameter defined by RF_InfoType + * @param pValue Pointer to return parameter values specified by RF_InfoVal + * @return RF_Stat indicates if command was successfully completed + */ +extern RF_Stat RF_getInfo(RF_Handle h, RF_InfoType type, RF_InfoVal *pValue); + +/** + * @brief Get RSSI value. + * + * @note Calling context : Task/SWI/HWI + * + * @param h Handle previously returned by RF_open() + * @return RSSI value. Return value of RF_GET_RSSI_ERROR_VAL indicates error case. + */ +extern int8_t RF_getRssi(RF_Handle h); + +/** + * @brief Get command structure pointer. + * + * @note Calling context : Task/SWI/HWI + * + * @param h Handle previously returned by RF_open() + * @param cmdHnd Command handle returned by RF_postCmd() + * @return Pointer to the command structure. + */ +extern RF_Op* RF_getCmdOp(RF_Handle h, RF_CmdHandle cmdHnd); + +/** + * @brief Initialize the configuration structure to be used to set up a RAT compare event. + * + * @note Calling context : Task/SWI/HWI + * + * @param channelConfig Pointer to the compare configuration structure. + * @return none + */ +extern void RF_RatConfigCompare_init(RF_RatConfigCompare* channelConfig); + +/** + * @brief Initialize the configuration structure to be used to set up a RAT capture event. + * + * @note Calling context : Task/SWI/HWI + * + * @param channelConfig Pointer to the capture configuration structure. + * @return none + */ +extern void RF_RatConfigCapture_init(RF_RatConfigCapture* channelConfig); + +/** + * @brief Initialize the configuration structure to be used to set up a RAT IO. + * + * @note Calling context : Task/SWI/HWI + * + * @param ioConfig Pointer to the IO configuration structure. + * @return none + */ +extern void RF_RatConfigOutput_init(RF_RatConfigOutput* ioConfig); + +/** + * @brief Setup a Radio Timer (RAT) channel in compare mode. + * + * The %RF_ratCompare() API sets up one of the three available RAT channels in compare mode. + * When the compare event happens at the given compare time, the registered callback + * is invoked. + * + * The RF driver handles power management. If the provided compare time is far into the future + * (and there is no other constraint set i.e. due to radio command execution), the RF core will be + * powered OFF and the device will enter the lowest possible power state. The RF core will be + * automatically powered ON just before the registered compare event. The callback function is + * served upon expiration of the allocated channel. The function is invoked with event type + * #RF_EventRatCh and runs in SWI context. + * + * The API generates a "one-shot" compare event. Since the channel is automatically freed before + * the callback is served, the same channel can be reallocated from the callback itself through a + * new API call. + * + * In case there were no available channels at the time of API call, the function returns with + * #RF_ALLOC_ERROR and no callback is invoked. + * + * In case a runtime error occurs after the API successfully allocated a channel, the registered + * callback is invoked with event type #RF_EventError. A typical example is when the provided compare + * time is in the past and rejected by the RF core itself. + * + * The events issued by the RAT timer can be output from the timer module through the RAT_GPO + * interface, and can be interconnected with other parts of the system through the RFC_GPO or + * the Event Fabric. The mapping between the allocated RAT channel and the selected RAT_GPO + * can be controlled through the optional ioConfig argument of %RF_ratCompare(). The possible + * RAT_GPO[x] are defined in #RF_RatOutputSelect. + * + * @note Calling context : Task/SWI + * + * @param rfHandle Handle previously returned by RF_open(). + * @param channelConfig Pointer to configuration structure needed to set up a channel in compare mode. + * @param ioConfig Pointer to a configuration structure to set up the RAT_GPOs for the allocated + * channel (optional). + * @return Allocated RAT channel. If allocation fails, #RF_ALLOC_ERROR is returned. + * + * \sa #RF_RatConfigCompare_init(), #RF_RatConfigOutput_init(), #RF_ratDisableChannel(), #RF_ratCapture() + */ +extern RF_RatHandle RF_ratCompare(RF_Handle rfHandle, RF_RatConfigCompare* channelConfig, RF_RatConfigOutput* ioConfig); + +/** + * @brief Setup a Radio Timer (RAT) channel in capture mode. + * + * The %RF_ratCapture() API sets up one of the three available RAT channels in capture mode. + * The registered callback is invoked on the capture event. + * + * The RF driver handles power management. If the RF core is OFF when the %RF_ratCapture() is called, + * it will be powered ON immediately and the RAT channel will be configured to capture mode. As long as + * at least one of the three RAT channels are in capture mode, the RF core will be kept ON. The callback + * function is served upon a capture event occurs. The function is invoked with event type RF_EventRatCh + * and runs in SWI context. + * + * In case the channel is configured into single capture mode, the channel is automatically freed before + * the callback is called. In repeated capture mode, the channel remains allocated and automatically rearmed. + * + * In case there were no available channels at the time of API call, the function returns with + * #RF_ALLOC_ERROR and no callback is invoked. + * + * In case a runtime error occurs after the API successfully allocated a channel, the registered + * callback is invoked with event type #RF_EventError. A typical example is when the provided compare + * time is in the past and rejected by the RF core itself. + * + * The events issued by the RAT timer can be output from the timer module through the RAT_GPO + * interface, and can be interconnected with other parts of the system through the RFC_GPO or + * the Event Fabric. The mapping between the allocated RAT channel and the selected RAT_GPO + * can be controlled through the optional ioConfig argument of %RF_ratCapture(). The possible + * RAT_GPO[x] are defined in #RF_RatOutputSelect. Note that this configuration is independent of + * the source signal of the capture event. + * + * @note Calling context : Task/SWI + * + * @param rfHandle Handle previously returned by RF_open(). + * @param channelConfig Pointer to configuration structure needed to set up a channel in compare mode. + * @param ioConfig Pointer to a configuration structure to set up the RAT_GPO for the allocated + * channel (optional). + * @return Allocated RAT channel. If allocation fails, #RF_ALLOC_ERROR is returned. + * + * \sa #RF_RatConfigCapture_init(), #RF_RatConfigOutput_init() , #RF_ratDisableChannel(), #RF_ratCompare() + */ +extern RF_RatHandle RF_ratCapture(RF_Handle rfHandle, RF_RatConfigCapture* channelConfig, RF_RatConfigOutput* ioConfig); + +/** + * @brief Disable a RAT channel. + * + * The #RF_RatHandle returned by the #RF_ratCompare() or #RF_ratCapture() APIs can be used for further interaction with the + * Radio Timer. Passing the handle to %RF_ratDisableChannel() will abort a compare/capture event, and the provided channel + * is deallocated. No callback is invoked. This API can be called both if the RF core is ON or OFF. After the channel is + * freed, the next radio event will be rescheduled. A typical use case if a channel is configured in repeated capture mode, + * and the application decides to abort this operation. + * + * @note Calling context : Task/SWI + * + * @param rfHandle Handle previously returned by RF_open(). + * @param ratHandle #RF_RatHandle returned by #RF_ratCompare() or #RF_ratCapture(). + * @return #RF_Stat indicates if command was successfully completed. + * + * \sa #RF_ratCompare(), #RF_ratCapture() + */ +extern RF_Stat RF_ratDisableChannel(RF_Handle rfHandle, RF_RatHandle ratHandle); + +/** + * @brief Set RF control parameters. + * + * @note Calling context : Task + * + * @param h Handle previously returned by RF_open() + * @param ctrl Control codes + * @param args Pointer to control arguments + * @return RF_Stat indicates if API call was successfully completed. + */ +extern RF_Stat RF_control(RF_Handle h, int8_t ctrl, void *args); + +/** + * @brief Request radio access.
+ * + * Scope: + * 1. Only supports request access which start immediately.
+ * 2. The #RF_AccessParams duration should be less than a pre-defined value + * RF_REQ_ACCESS_MAX_DUR_US in RFCC26X2_multiMode.c.
+ * 3. The #RF_AccessParams priority should be set RF_PriorityHighest.
+ * 4. Single request for a client at anytime.
+ * 5. Command from different client are blocked until the radio access + * period is completed.
+ * + * @note Calling context : Task + * + * @param h Handle previously returned by RF_open() + * @param pParams Pointer to RF_AccessRequest parameters + * @return RF_Stat indicates if API call was successfully completed. + */ +extern RF_Stat RF_requestAccess(RF_Handle h, RF_AccessParams *pParams); + +/** + * @brief Returns the currently configured transmit power configuration. + * + * This function returns the currently configured transmit power configuration under the assumption + * that it has been previously set by #RF_setTxPower(). The value might be used for reverse + * lookup in a TX power table. If no power has been programmed, it returns an invalid value. + * + * @code + * RF_TxPowerTable_Value value = RF_getTxPower(handle); + * if (value.rawValue == RF_TxPowerTable_INVALID_VALUE) { + * // error, value not valid + * } + * @endcode + * + * @param h Handle previously returned by #RF_open() + * @return PA configuration struct + * + * @sa #RF_setTxPower(), #RF_TxPowerTable_findPowerLevel() + */ +extern RF_TxPowerTable_Value RF_getTxPower(RF_Handle h); + +/** + * @brief Updates the transmit power configuration of the RF core. + * + * This function programs a new TX power \a value and returns a status code. The API will return + * with RF_StatBusyError if there are still pending commands in the internal queue. In case of + * success, RF_StatSuccess is returned and the new configuration becomes effective from the next + * radio operation. + * + * Some devices provide an integrated high-power PA in addition to the Default PA. On these devices + * the API accepts configurations for both, and if \a value selects a different PA, the + * \a globalCallback is invoked. The implementation of \a globalCallback is board specific and can + * be used to reconfigure the external RF switches (if any). + * + * @param h Handle previously returned by #RF_open() + * @param value TX power configuration value. + * @return #RF_StatSuccess on success, otherwise an error code. + * + * @sa #RF_getTxPower(), #RF_TxPowerTable_Value, #RF_TxPowerTable_findValue() + */ +extern RF_Stat RF_setTxPower(RF_Handle h, RF_TxPowerTable_Value value); + +/** + * @brief Retrieves a power level in dBm for a given power configuration value. + * + * \c %RF_TxPowerTable_findPowerLevel() searches in a lookup \a table for a given transmit power + * configuration \a value and returns the power level in dBm if a matching configuration is found. + * If \a value can not be found, #RF_TxPowerTable_INVALID_DBM is returned. + * + * This function does a reverse lookup compared to #RF_TxPowerTable_findValue() and has + * O(n). It is assumed that \a table is terminated by a #RF_TxPowerTable_TERMINATION_ENTRY. + * + * @param table List of #RF_TxPowerTable_Entry entries, + * terminated by #RF_TxPowerTable_TERMINATION_ENTRY. + * + * @param value Power configuration value. + * + * @return Human readable power level in dBm on success, + * otherwise #RF_TxPowerTable_INVALID_DBM. + */ +extern int8_t RF_TxPowerTable_findPowerLevel(RF_TxPowerTable_Entry table[], RF_TxPowerTable_Value value); + +/** + * @brief Retrieves a power configuration value for a given power level in dBm. + * + * \c %RF_TxPowerTable_findValue() searches in a lookup \a table for a given transmit power level + * \a powerLevel in dBm and returns a matching power configuration. If \a powerLevel can not be + * found, #RF_TxPowerTable_INVALID_VALUE is returned. + * + * This function performs a linear search in \a table and has O(n). + * It is assumed that \a table is defined in ascending order and is terminated by a + * #RF_TxPowerTable_TERMINATION_ENTRY. + * + * The following special values for \a powerLevel are also accepted: + * + * - #RF_TxPowerTable_MIN_DBM which returns always the lowest power value in the table + * - #RF_TxPowerTable_MAX_DBM which returns always the highest power value in the table + * + * @param table List of #RF_TxPowerTable_Entry entries, + * terminated by #RF_TxPowerTable_TERMINATION_ENTRY. + * + * @param powerLevel Human-readable power level in dBm. + * + * @return PA configuration value on success. + * otherwise #RF_TxPowerTable_INVALID_VALUE. + */ +extern RF_TxPowerTable_Value RF_TxPowerTable_findValue(RF_TxPowerTable_Entry table[], int8_t powerLevel); + + +/** + * @brief Enables temperature monitoring and temperature based drift compensation + * + */ +extern void RF_enableHPOSCTemperatureCompensation(void); + +#ifdef __cplusplus +} +#endif + +#endif /* ti_drivers_rfcc26x2__include */ + +//***************************************************************************** +// +//! Close the Doxygen group. +//! @} +//! @} +// +//***************************************************************************** + diff --git a/simplelink/source/ti/drivers/rf/RFCC26X2_multiMode.c b/simplelink/source/ti/drivers/rf/RFCC26X2_multiMode.c index b813ad1..d6f48d8 100644 --- a/simplelink/source/ti/drivers/rf/RFCC26X2_multiMode.c +++ b/simplelink/source/ti/drivers/rf/RFCC26X2_multiMode.c @@ -1,5 +1,5 @@ /* -* Copyright (c) 2015-2019, Texas Instruments Incorporated +* Copyright (c) 2015-2020, Texas Instruments Incorporated * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,6 +38,7 @@ #include #include +#include #include #include @@ -55,8 +56,8 @@ #include DeviceFamily_constructPath(driverlib/adi.h) #include DeviceFamily_constructPath(driverlib/aon_rtc.h) #include DeviceFamily_constructPath(driverlib/chipinfo.h) -#include DeviceFamily_constructPath(driverlib/aon_batmon.h) #include DeviceFamily_constructPath(driverlib/osc.h) +#include DeviceFamily_constructPath(driverlib/ccfgread.h) #if defined(__IAR_SYSTEMS_ICC__) #pragma diag_remark=Pa082 @@ -237,6 +238,8 @@ typedef enum RF_ScheduleCmdStatus_ { #define RF_HPOSC_OVERRIDE_MASK 0xFFFF /* Common defines for override handling*/ #define RF_OVERRIDE_SEARCH_DEPTH 80 +/* Define for HPOSC temperature limits */ +#define RF_TEMP_LIMIT_3_DEGREES_CELSIUS 0x3 /*-------------- Structures and definitions ---------------*/ @@ -248,7 +251,7 @@ typedef struct RF_RatChannel_s RF_RatChannel; /* Rat channel configuration. */ struct RF_RatChannel_s { - RF_Handle pClient; /* Pointer to current client. NULL means the channel is free. */ + RF_Handle pClient; /* Pointer to client owning the channel. NULL means the channel is free. */ RF_RatCallback pCb; /* Callback pointer of the channel. */ RF_RatMode mode; /* Mode of this RAT channel: RF_RatModeCompare, etc. */ RF_RatHandle handle; /* Channel number: 0,1,2. */ @@ -371,6 +374,7 @@ static const RF_Params RF_defaultParams = { .nPhySwitchingDurationMargin = RF_DEFAULT_PHY_SWITCHING_MARGIN, .pClientEventCb = NULL, .nClientEventMask = 0, + .nID = 0, }; /*-------------- Global variables ---------------*/ @@ -410,6 +414,12 @@ static uint32_t RF_errTolValInUs; /* max allowed error betwe /* Counter of radio clients */ static uint8_t RF_numClients; +/* Current HPOSC frequency offset */ +static int32_t RF_currentHposcFreqOffset; + +/* Temperature notify object used by HPOSC device */ +static Temperature_NotifyObj RF_hposcRfCompNotifyObj; + /*-------------- Externs ---------------*/ /* Hardware attribute structure populated in board file. */ @@ -509,6 +519,10 @@ static void RF_detachOverrides(uint32_t* baseOverride, uint32_t* new /* HPOSC management */ static void RF_updateHpOscOverride(uint32_t *pRegOverride); +static void RF_hposcRfCompensateFxn(int16_t currentTemperature, + int16_t thresholdTemperature, + uintptr_t clientArg, + Temperature_NotifyObj *notifyObject); /*-------------- Command queue internal functions ---------------*/ @@ -770,10 +784,10 @@ static bool RF_cmdDispatchTime(uint32_t* dispatchTimeClockTicks, bool conflict, /* Calculate the remained time until this absolute event. The calculation takes into account the minimum power cycle time. */ - *dispatchTimeClockTicks = RF_calculateDeltaTimeUs(pCmd->pOp->startTime, nTotalDuration); + *dispatchTimeClockTicks = RF_calculateDeltaTimeUs(pCmd->startTime, nTotalDuration); /* Scale the value to clock ticks*/ - *dispatchTimeClockTicks /= ClockP_tickPeriod; + *dispatchTimeClockTicks /= ClockP_getSystemTickPeriod(); } else { @@ -957,11 +971,16 @@ static bool RF_ratReleaseChannels(void) /* If the next event is sufficiently far into the future. */ if (!validTime || (validTime && dispatchTimeClockTicks)) { - /* Suspend all RAT channels. */ - RF_ratSuspendChannels(); + /* Avoid powering down the radio if there are callbacks to be served. The + SWI will try to access the RAT timer, which need to be powered. */ + if (RF_ratModule.pendingInt == 0U) + { + /* Suspend all RAT channels. */ + RF_ratSuspendChannels(); - /* RAT channels were suspended. */ - return(true); + /* RAT channels were suspended. */ + return(true); + } } } @@ -1021,7 +1040,7 @@ static bool RF_ratDispatchTime(uint32_t* dispatchTimeClockTicks) (RF_RAT_COMPENSATION_TIME_US * RF_ratModule.numActiveChannels)); /* Scale the value to clock ticks. */ - uint32_t deltaTimeClockTicks = deltaTimeUs / ClockP_tickPeriod; + uint32_t deltaTimeClockTicks = deltaTimeUs / ClockP_getSystemTickPeriod(); /* If this is the closest RAT event, update the timer. */ if (deltaTimeClockTicks < (*dispatchTimeClockTicks)) @@ -1351,7 +1370,7 @@ static uint8_t RF_wakeupNotification(uint8_t eventType, uint32_t *eventArg, uint if ((eventType == PowerCC26XX_AWAKE_STANDBY) && (ClockP_isActive(&RF_clkPowerUpObj))) { /* Calculate time (in us) until next trigger (assume next trigger is max ~70 min away) */ - uint32_t timeInUsUntilNextTrig = ClockP_tickPeriod * ClockP_getTimeout(&RF_clkPowerUpObj); + uint32_t timeInUsUntilNextTrig = ClockP_getSystemTickPeriod() * ClockP_getTimeout(&RF_clkPowerUpObj); /* Check if the next trig time is close enough to the actual power up */ if (timeInUsUntilNextTrig < RF_WAKEUP_DETECTION_WINDOW_IN_US) @@ -1477,11 +1496,11 @@ static bool RF_verifyGap(RF_Cmd* newCmd, RF_Cmd* prevCmd, RF_Cmd* nextCmd) /* Step 1 - The newCmd must have an endTime in order to be placed anywhere else than the end. Or if there are no commands behind. */ - if ((newCmd) && (insertNewCmdBeforeNext || (newCmd->endTime != RF_SCH_CMD_ENDTIME_IGNORE))) + if ((newCmd) && (insertNewCmdBeforeNext || (newCmd->endType != RF_EndNotSpecified))) { /* If there is a prevCmd and it have an endTime, we could potentially put the new command behind it. */ - if ((prevCmd) && (prevCmd->endTime != RF_SCH_CMD_ENDTIME_IGNORE)) + if ((prevCmd) && (prevCmd->endType != RF_EndNotSpecified)) { /* Take the start time of the command located later in the timeline. */ deltaInUs = (int32_t)RF_convertRatTicksToUs(newCmd->startTime); @@ -2194,6 +2213,9 @@ static void RF_dispatchNextCmd(void) /* Decode the radio operation itself. */ RF_Op* pOp = (RF_Op*)pNextCmd->pOp; + /* Invoke global callback to indicate start of command chain */ + RF_invokeGlobalCallback(RF_GlobalEventCmdStart, (void*)pNextCmd); + /* Send the radio operation to the RF core. */ RFCDoorbellSendTo((uint32_t)pOp); @@ -2437,6 +2459,9 @@ static void RF_hwiCpe0Active(uintptr_t a) RFCCpeIntDisable((uint32_t)((*ppActiveCmd)->bmEvent & ~(RFC_DBELL_RFCPEIFG_LAST_COMMAND_DONE_M | RFC_DBELL_RFCPEIEN_IRQ14_M))); RFCHwIntDisable((uint32_t) ((*ppActiveCmd)->bmEvent >> RF_SHIFT_32_BITS)); + /* Invoke global callback to indicate end of command chain */ + RF_invokeGlobalCallback(RF_GlobalEventCmdStop, (void*)(*ppActiveCmd)); + /* Move active command to done queue. */ List_put(&RF_cmdQ.pDone, (List_Elem*)(*ppActiveCmd)); @@ -2470,6 +2495,53 @@ static void RF_hwiCpe0Active(uintptr_t a) RF_dispatchNextCmd(); } +/* + * Temperature limit notification function. + */ +static void RF_hposcRfCompensateFxn(int16_t currentTemperature, + int16_t thresholdTemperature, + uintptr_t clientArg, + Temperature_NotifyObj *NotifyObj) +{ + int32_t relFreqOffset; + int16_t relFreqOffsetConverted; + int_fast16_t status; + + /* Check if HPOSC frequency offset has changed */ + relFreqOffset = OSC_HPOSCRelativeFrequencyOffsetGet(currentTemperature); + if (relFreqOffset != RF_currentHposcFreqOffset) + { + /* Frequency offset has changed. Compensation is required */ + RF_currentHposcFreqOffset = relFreqOffset; + relFreqOffsetConverted = OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert(relFreqOffset); + + /* Check if radio is powered */ + if ((RF_core.status == RF_CoreStatusActive) || (RF_core.status == RF_CoreStatusPhySwitching)) + { + /* Radio is powered. Check if any actively running command */ + if (RF_cmdQ.pCurrCmdBg || RF_cmdQ.pCurrCmdFg) + { + /* Command is running. Abort command and assure that both RF_EventCmdAborted and RF_EventCmdPreemptrf events are set */ + RF_abortCmd(RF_cmdQ.pCurrCmdBg->pClient, RF_cmdQ.pCurrCmdBg->ch, false, false, true); + } + + /* Update RFCore with the HPOSC frequency offset */ + RF_runDirectImmediateCmd(RF_currClient, CMDR_DIR_CMD_2BYTE(CMD_UPDATE_HPOSC_FREQ, relFreqOffsetConverted), NULL); + } + } + + /* Register the notification again with updated thresholds */ + status = Temperature_registerNotifyRange(NotifyObj, + currentTemperature + RF_TEMP_LIMIT_3_DEGREES_CELSIUS, + currentTemperature - RF_TEMP_LIMIT_3_DEGREES_CELSIUS, + RF_hposcRfCompensateFxn, + (uintptr_t)NULL); + + if (status != Temperature_STATUS_SUCCESS) { + while(1); + } +} + /* * Clock callback due to inactivity timeout. * @@ -2791,7 +2863,7 @@ static void RF_setInactivityTimeout(void) else if (inactivityTimeUs != SemaphoreP_WAIT_FOREVER) { /* Reprogram and start inactivity timer */ - RF_restartClockTimeout(&RF_clkInactivityObj, inactivityTimeUs/ClockP_tickPeriod); + RF_restartClockTimeout(&RF_clkInactivityObj, inactivityTimeUs/ClockP_getSystemTickPeriod()); } } @@ -3118,7 +3190,7 @@ static void RF_fsmXOSCState(RF_Object *pObj, RF_FsmEvent e) else { /* Clock source not yet switched to XOSC_HF: schedule new polling */ - RF_restartClockTimeout(&RF_clkPowerUpObj, RF_XOSC_HF_SWITCH_CHECK_PERIOD_US/ClockP_tickPeriod); + RF_restartClockTimeout(&RF_clkPowerUpObj, RF_XOSC_HF_SWITCH_CHECK_PERIOD_US/ClockP_getSystemTickPeriod()); } } } @@ -3567,11 +3639,16 @@ static void RF_init(void) ClockP_construct(&RF_clkPowerUpObj, &RF_clkPowerUp, 0, NULL); ClockP_construct(&RF_clkInactivityObj, &RF_clkInactivityCallback, 0, NULL); - /* Subscribe to wakeup notification from the Power driver */ - Power_registerNotify(&RF_wakeupNotifyObj, /* Object to register */ - PowerCC26XX_AWAKE_STANDBY, /* Event the notification to be invoked upon */ - (Power_NotifyFxn) RF_wakeupNotification, /* Function to be invoked */ - (uintptr_t) NULL); /* Parameters */ + /* If TCXO is selected in CCFG, the RF Driver must not be allowed to control + the XOSC switching by subscribing to wakeup notification from the Power driver. */ + if (CCFGRead_XOSC_FREQ() != CCFGREAD_XOSC_FREQ_TCXO) + { + /* Subscribe to wakeup notification from the Power driver */ + Power_registerNotify(&RF_wakeupNotifyObj, /* Object to register */ + PowerCC26XX_AWAKE_STANDBY, /* Event the notification to be invoked upon */ + (Power_NotifyFxn) RF_wakeupNotification, /* Function to be invoked */ + (uintptr_t) NULL); /* Parameters */ + } /* Set the XOSC_HF dependency if the HW attributes say so. This will ensure that the XOSC_HF is turned on by the power driver as soon as possible when @@ -3598,6 +3675,9 @@ static void RF_init(void) /* Set FSM state to power up */ RF_core.fxn = RF_fsmPowerUpState; + + /* Invoke the board file init function. */ + RF_invokeGlobalCallback(RF_GlobalEventInit, NULL); } /* @@ -4003,7 +4083,7 @@ static void RF_detachOverrides(uint32_t* baseOverride, uint32_t* newOverride) static bool RF_decodeOverridePointers(RF_RadioSetup* radioSetup, uint16_t** pTxPower, uint32_t** pRegOverride, uint32_t** pRegOverrideTxStd, uint32_t** pRegOverrideTx20) { /* Decode if High Gain PA is even available. */ - bool tx20FeatureAvailable = (ChipInfo_GetChipType() == CHIP_TYPE_CC1352P); + bool tx20FeatureAvailable = (ChipInfo_GetChipType() == CHIP_TYPE_CC1352P) || (ChipInfo_GetChipType() == CHIP_TYPE_CC2652P); /* Only decode the offset of those fields which exist on this device. */ if (tx20FeatureAvailable) @@ -4014,7 +4094,7 @@ static bool RF_decodeOverridePointers(RF_RadioSetup* radioSetup, uint16_t** pTxP uint8_t index; /* Decode the offset of txPower field and all the override pointers - available on the CC1352P device. */ + available on the CC1352P/CC2652P devices. */ switch (radioSetup->commandId.commandNo) { case (CMD_RADIO_SETUP): @@ -4162,18 +4242,13 @@ static void RF_updateHpOscOverride(uint32_t *pRegOverride) if (index < RF_OVERRIDE_SEARCH_DEPTH) { /* Get temperature dependent HPOSC frequency offset */ - tempDegC = AONBatMonTemperatureGetDegC(); + tempDegC = Temperature_getTemperature(); relFreqOffset = OSC_HPOSCRelativeFrequencyOffsetGet(tempDegC); + RF_currentHposcFreqOffset = relFreqOffset; relFreqOffsetConverted = OSC_HPOSCRelativeFrequencyOffsetToRFCoreFormatConvert(relFreqOffset); /* Update override with the HPOSC frequency offset */ pRegOverride[index] = HPOSC_OVERRIDE(relFreqOffsetConverted); - - /* Adjust the RTC increment if the LF clock is derived from the HF clock of the HPOSC */ - if(OSC_IsHPOSCEnabledWithHfDerivedLfClock()) - { - OSC_HPOSCRtcCompensate(relFreqOffset); - } } } else @@ -4209,7 +4284,7 @@ static RF_Stat RF_updatePaConfiguration(RF_RadioSetup* radioSetup, RF_TxPowerTab /* The new value requires the deault PA. */ if (newValue.paType == RF_TxPowerTable_DefaultPA) { - /* On CC1352P devices with the correct override lists. */ + /* On CC1352P/CC2652P devices with the correct override lists. */ if (tx20FeatureAvailable && pRegOverrideTxStd && pRegOverrideTx20) { /* Store the new value in the setup command. */ @@ -4227,7 +4302,7 @@ static RF_Stat RF_updatePaConfiguration(RF_RadioSetup* radioSetup, RF_TxPowerTab } else if (tx20FeatureAvailable) { - /* Limited backward compatibility on CC1352P devices without the + /* Limited backward compatibility on CC1352P/CC2652P devices without the proper override lists. Only gain tuning on the Default PA is available. */ if (*pTxPower != RF_TX20_ENABLED) { @@ -4256,7 +4331,7 @@ static RF_Stat RF_updatePaConfiguration(RF_RadioSetup* radioSetup, RF_TxPowerTab } else { - /* On CC1352P devices with the correct override lists. */ + /* On CC1352P/CC2652P devices with the correct override lists. */ if (tx20FeatureAvailable && pRegOverrideTxStd && pRegOverrideTx20) { /* If the High Gain PA is available store the escape value in the setup @@ -4275,7 +4350,7 @@ static RF_Stat RF_updatePaConfiguration(RF_RadioSetup* radioSetup, RF_TxPowerTab } else if (tx20FeatureAvailable) { - /* Limited backward compatibility on CC1352P devices without the + /* Limited backward compatibility on CC1352P/CC2652P devices without the proper override lists. Only gain tuning on the High PA is available if the gain override is present within the base override list.*/ if (RF_searchAndReplacePAOverride(pRegOverride, RF_TX20_PATTERN, newValue.rawValue) == RF_TX_OVERRIDE_INVALID_OFFSET) @@ -4367,6 +4442,7 @@ RF_Handle RF_open(RF_Object *pObj, RF_Mode* pRfMode, RF_RadioSetup* pRadioSetup, pObj->clientConfig.nClientEventMask = params->nClientEventMask; pObj->clientConfig.nPowerUpDurationMargin = params->nPowerUpDurationMargin; pObj->clientConfig.bUpdateSetup = true; + pObj->clientConfig.nID = params->nID; /* Decide if automatic adjustment should be used. */ if (params->nPowerUpDuration) @@ -4505,6 +4581,10 @@ void RF_close(RF_Handle h) HwiP_destruct(&RF_hwiHwObj); ClockP_destruct(&RF_clkPowerUpObj); ClockP_destruct(&RF_clkInactivityObj); + if(OSC_IsHPOSCEnabled() == true) + { + Temperature_unregisterNotify(&RF_hposcRfCompNotifyObj); + } /* Unregister the wakeup notify callback */ Power_unregisterNotify(&RF_wakeupNotifyObj); @@ -4544,7 +4624,7 @@ uint32_t RF_getCurrentTime(void) uint32_t key = HwiP_disable(); /* If radio is active, read the RAT */ - if (RF_core.status == RF_CoreStatusActive) + if ((RF_core.status == RF_CoreStatusActive) || (RF_core.status == RF_CoreStatusPhySwitching)) { /* Read the RAT timer through register access */ nCurrentTime = RF_ratGetValue(); @@ -4602,14 +4682,30 @@ RF_CmdHandle RF_postCmd(RF_Handle h, RF_Op* pOp, RF_Priority ePri, RF_Callback p RF_cmdQ.nSeqPost = (RF_cmdQ.nSeqPost + 1) & N_CMD_MODMASK; /* Populate container with reset values */ - pCmd->pOp = pOp; - pCmd->ePri = ePri; - pCmd->pCb = pCb; - pCmd->ch = RF_cmdQ.nSeqPost; - pCmd->pClient = h; - pCmd->bmEvent = (bmEvent | RFC_DBELL_RFCPEIFG_LAST_COMMAND_DONE_M) & ~RF_INTERNAL_IFG_MASK; - pCmd->pastifg = 0; - pCmd->flags = RF_CMD_ALLOC_FLAG; + pCmd->pOp = pOp; + pCmd->ePri = ePri; + pCmd->pCb = pCb; + pCmd->ch = RF_cmdQ.nSeqPost; + pCmd->pClient = h; + pCmd->bmEvent = (bmEvent | RFC_DBELL_RFCPEIFG_LAST_COMMAND_DONE_M) & ~RF_INTERNAL_IFG_MASK; + pCmd->pastifg = 0; + pCmd->flags = RF_CMD_ALLOC_FLAG; + pCmd->endTime = 0; + pCmd->endType = RF_EndNotSpecified; + pCmd->startTime = 0; + pCmd->startType = RF_StartNotSpecified; + pCmd->allowDelay = RF_AllowDelayAny; + pCmd->duration = 0; + pCmd->activityInfo = 0; + pCmd->coexPriority = RF_PriorityCoexDefault; + pCmd->coexRequest = RF_RequestCoexDefault; + + /* Update start time if absolute start time present in radio operation. */ + if (pOp->startTrigger.triggerType == TRIG_ABSTIME) + { + pCmd->startType = RF_StartAbs; + pCmd->startTime = pOp->startTime; + } /* Cancel ongoing yielding */ h->state.bYielded = false; @@ -4644,9 +4740,15 @@ void RF_ScheduleCmdParams_init(RF_ScheduleCmdParams *pSchParams) DebugP_assert(pSchParams != NULL); /* Set the configuration to use the default values. */ - pSchParams->priority = RF_PriorityNormal; - pSchParams->endTime = 0; - pSchParams->allowDelay = RF_AllowDelayAny; + pSchParams->startTime = 0; + pSchParams->startType = RF_StartNotSpecified; + pSchParams->allowDelay = RF_AllowDelayAny; + pSchParams->endTime = 0; + pSchParams->endType = RF_EndNotSpecified; + pSchParams->duration = 0; + pSchParams->activityInfo = 0; + pSchParams->coexPriority = RF_PriorityCoexDefault; + pSchParams->coexRequest = RF_RequestCoexDefault; } /* @@ -4707,28 +4809,41 @@ RF_CmdHandle RF_scheduleCmd(RF_Handle h, RF_Op* pOp, RF_ScheduleCmdParams *pSchP RF_cmdQ.nSeqPost = (RF_cmdQ.nSeqPost + 1) & N_CMD_MODMASK; /* Cache meta-data. */ - pCmd->pOp = pOp; - pCmd->ePri = pSchParams->priority; - pCmd->pCb = pCb; - pCmd->ch = RF_cmdQ.nSeqPost; - pCmd->pClient = h; - pCmd->bmEvent = bmEvent & ~RF_INTERNAL_IFG_MASK; - pCmd->flags = 0; - pCmd->pastifg = 0; - pCmd->endTime = RF_SCH_CMD_ENDTIME_IGNORE; - pCmd->startTime = RF_SCH_CMD_STARTTIME_NOW; - pCmd->allowDelay = pSchParams->allowDelay; + pCmd->pOp = pOp; + pCmd->ePri = RF_PriorityNormal; + pCmd->pCb = pCb; + pCmd->ch = RF_cmdQ.nSeqPost; + pCmd->pClient = h; + pCmd->bmEvent = bmEvent & ~RF_INTERNAL_IFG_MASK; + pCmd->flags = 0; + pCmd->pastifg = 0; + pCmd->endTime = pSchParams->endTime; + pCmd->endType = pSchParams->endType; + pCmd->startTime = pSchParams->startTime; + pCmd->startType = pSchParams->startType; + pCmd->allowDelay = pSchParams->allowDelay; + pCmd->duration = pSchParams->duration; + pCmd->activityInfo = pSchParams->activityInfo; + pCmd->coexPriority = pSchParams->coexPriority; + pCmd->coexRequest = pSchParams->coexRequest; /* Update the default endTime based on the scheduling parameters. */ - if (pSchParams->endTime) + if (pSchParams->endType == RF_EndNotSpecified) { - pCmd->endTime = pSchParams->endTime; + if (pSchParams->endTime != 0) + { + pCmd->endType = RF_EndAbs; + } } /* Update the default startTime based on the command parameters. */ - if (pOp->startTrigger.triggerType == TRIG_ABSTIME) + if (pSchParams->startType == RF_StartNotSpecified) { - pCmd->startTime = pOp->startTime; + if (pOp->startTrigger.triggerType == TRIG_ABSTIME) + { + pCmd->startType = RF_StartAbs; + pCmd->startTime = pOp->startTime; + } } /* Find the last radio operation within the chain. */ @@ -4802,7 +4917,8 @@ RF_CmdHandle RF_scheduleCmd(RF_Handle h, RF_Op* pOp, RF_ScheduleCmdParams *pSchP h->state.bYielded = false; /* Trigger dispatcher if the timings need to be reconsidered. */ - if (List_head(&RF_cmdQ.pPend) == (List_Elem*)pCmd) + if ((List_head(&RF_cmdQ.pPend) == (List_Elem*)pCmd) || + (pCmd->pOp->startTrigger.triggerType == TRIG_ABSTIME)) { RF_dispatchNextEvent(); } @@ -5089,11 +5205,6 @@ int8_t RF_getRssi(RF_Handle h) */ RF_Stat RF_getInfo(RF_Handle h, RF_InfoType type, RF_InfoVal *pValue) { - /* Local variables */ - int8_t i = 0; - RF_Cmd* pCmd; - RF_ScheduleMapElement *pScheduleMap; - /* Prepare the default status value */ RF_Stat status = RF_StatSuccess; @@ -5139,79 +5250,6 @@ RF_Stat RF_getInfo(RF_Handle h, RF_InfoType type, RF_InfoVal *pValue) pValue->phySwitchingTimeInUs[1] = RF_Sch.clientHnd[1] ? RF_Sch.clientHnd[1]->clientConfig.nPhySwitchingDuration : 0; break; - case RF_GET_SCHEDULE_MAP: - /* Get scheduler timing map. This can be used to determine the recent - time slots which are occupied by posted commands; and can help to - find out if a command can be inserted to the queue or not. In dual-mode - applications, this can help to sync the two protocol. */ - pScheduleMap = (RF_ScheduleMapElement *)pValue->pScheduleMap; - memset(pScheduleMap, 0, sizeof(RF_ScheduleMapElement) * RF_NUM_SCHEDULE_MAP_ENTRIES); - - for (i = 0; i < RF_NUM_SCHEDULE_ACCESS_ENTRIES; i++) - { - /* Copy access request info to schedule map */ - pScheduleMap[i].pClient = RF_Sch.clientHnd[i]; - pScheduleMap[i].priority = RF_Sch.accReq[i].priority; - uint32_t startTime = RF_Sch.accReq[i].startTime; - pScheduleMap[i].startTime = startTime; - pScheduleMap[i].endTime = startTime + RF_Sch.accReq[i].duration; - } - - /* Check if there is current command running */ - if (RF_cmdQ.pCurrCmdBg) - { - /* Copy current command info to schedule map */ - pScheduleMap[i].pClient = RF_cmdQ.pCurrCmdBg->pClient; - pScheduleMap[i].ch = RF_cmdQ.pCurrCmdBg->ch; - pScheduleMap[i].priority = RF_cmdQ.pCurrCmdBg->ePri; - pScheduleMap[i].startTime = RF_cmdQ.pCurrCmdBg->startTime; - pScheduleMap[i].endTime = RF_cmdQ.pCurrCmdBg->endTime; - } - - /* Increment the index to ensure a fixed location for the background command. */ - i++; - - /* Check if there is current command running */ - if (RF_cmdQ.pCurrCmdFg) - { - /* Copy current command info to schedule map */ - pScheduleMap[i].pClient = RF_cmdQ.pCurrCmdFg->pClient; - pScheduleMap[i].ch = RF_cmdQ.pCurrCmdFg->ch; - pScheduleMap[i].priority = RF_cmdQ.pCurrCmdFg->ePri; - pScheduleMap[i].startTime = RF_cmdQ.pCurrCmdFg->startTime; - pScheduleMap[i].endTime = RF_cmdQ.pCurrCmdFg->endTime; - } - - /* Increment the index to ensure a fixed location for the foreground command. */ - i++; - - /* Check pending commands */ - pCmd = (RF_Cmd*)List_head(&RF_cmdQ.pPend); - - /* Loop until end of command queue or number of entries exceed */ - while (pCmd) - { - if (i < RF_NUM_SCHEDULE_MAP_ENTRIES) - { - /* Copy pending command info to schedule map */ - pScheduleMap[i].pClient = pCmd->pClient; - pScheduleMap[i].ch = pCmd->ch; - pScheduleMap[i].priority = pCmd->ePri; - pScheduleMap[i].startTime = pCmd->startTime; - pScheduleMap[i].endTime = pCmd->endTime; - i++; - } - else - { - /* Number of entries exceeded, get out of loop */ - break; - } - - /* Walk the queue. */ - pCmd = (RF_Cmd*)List_next((List_Elem*)pCmd); - } - break; - default: status = RF_StatInvalidParamsError; break; @@ -5339,7 +5377,7 @@ RF_Stat RF_ratDisableChannel(RF_Handle h, RF_RatHandle ratHandle) RF_RatChannel* ratCh = RF_ratGetChannel(ratHandle); /* If the provided handler is valid. */ - if (ratCh && ratCh->status) + if (ratCh && ratCh->status && (ratCh->pClient == h)) { /* If the RF core is active, abort the RAT event. */ if (RF_core.status == RF_CoreStatusActive) @@ -5347,8 +5385,14 @@ RF_Stat RF_ratDisableChannel(RF_Handle h, RF_RatHandle ratHandle) /* Calculate the configuration field of command (the channel we disable). */ uint16_t config = (uint16_t)(RF_RAT_CH_LOWEST + ratCh->handle) << RF_SHIFT_8_BITS; - /* Disable the channel within the RF core. */ - status = RF_runDirectImmediateCmd(h, ((uint32_t)CMDR_DIR_CMD_2BYTE(CMD_DISABLE_RAT_CH, config)), NULL); + /* Disable the channel within the RF core. + It has been checked that RAT channel to be disabled is owned by the input handle h. + Call the function that executes the disabling with RF_currClient as input argument in + instead of h in order to force the function to accept the disable request. This is + required in the case where the client that will disable a RAT channel is not the same + client as currently controlling the radio. + */ + status = RF_runDirectImmediateCmd(RF_currClient, ((uint32_t)CMDR_DIR_CMD_2BYTE(CMD_DISABLE_RAT_CH, config)), NULL); /* Free the container for further use. We do it after the direct command to be sure it is not powered down. This will implicitely schedule the next event and run the power management accordingly. */ @@ -5488,6 +5532,12 @@ RF_Stat RF_control(RF_Handle h, int8_t ctrl, void *args) RF_ratModule.availableRatChannels = *(uint8_t *)args; break; + case RF_CTRL_COEX_CONTROL: + /* Pass this request on to the dynamically generated board file + event handler */ + RF_invokeGlobalCallback(RF_GlobalEventCoexControl, args); + break; + default: /* Request can not be served */ status = RF_StatInvalidParamsError; @@ -5548,7 +5598,7 @@ RF_Stat RF_requestAccess(RF_Handle h, RF_AccessParams *pParams) RF_Sch.accReq[clientIdx].priority = pParams->priority; /* Start timeout of the request. */ - RF_restartClockTimeout(&h->state.clkReqAccess, durationInUs/ClockP_tickPeriod); + RF_restartClockTimeout(&h->state.clkReqAccess, durationInUs/ClockP_getSystemTickPeriod()); /* Set status to success after the access was granted. */ status = RF_StatSuccess; @@ -5721,3 +5771,31 @@ RF_TxPowerTable_Value RF_TxPowerTable_findValue(RF_TxPowerTable_Entry table[], i } } } + +/* + * ======== RF_enableHPOSCTemperatureCompensation ======== + * Initializes the temperature compensation monitoring + */ +void RF_enableHPOSCTemperatureCompensation(void) +{ + int_fast16_t status; + + if(OSC_IsHPOSCEnabled() == true) + { + Temperature_init(); + + int16_t currentTemperature = Temperature_getTemperature(); + + status = Temperature_registerNotifyRange(&RF_hposcRfCompNotifyObj, + currentTemperature + RF_TEMP_LIMIT_3_DEGREES_CELSIUS, + currentTemperature - RF_TEMP_LIMIT_3_DEGREES_CELSIUS, + RF_hposcRfCompensateFxn, + (uintptr_t)NULL); + + if (status != Temperature_STATUS_SUCCESS) + { + while(1); + } + } +} + diff --git a/simplelink/source/ti/drivers/temperature/TemperatureCC26X2.c b/simplelink/source/ti/drivers/temperature/TemperatureCC26X2.c new file mode 100644 index 0000000..bc20e5e --- /dev/null +++ b/simplelink/source/ti/drivers/temperature/TemperatureCC26X2.c @@ -0,0 +1,559 @@ +/* + * Copyright (c) 2020, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * 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. + * + * * Neither the name of Texas Instruments Incorporated 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 OWNER 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. + */ + +/* Includes */ +#include +#include +#include + +#include + +#include +#include + +#include +#include DeviceFamily_constructPath(inc/hw_memmap.h) +#include DeviceFamily_constructPath(inc/hw_ints.h) +#include DeviceFamily_constructPath(inc/hw_types.h) +#include DeviceFamily_constructPath(driverlib/cpu.h) +#include DeviceFamily_constructPath(driverlib/interrupt.h) +#include DeviceFamily_constructPath(driverlib/sys_ctrl.h) +#include DeviceFamily_constructPath(driverlib/aon_batmon.h) +#include DeviceFamily_constructPath(driverlib/aon_event.h) + +/* Macros */ +#define MIN(x,y) (((x) < (y)) ? (x) : (y)) +#define MAX(x,y) (((x) > (y)) ? (x) : (y)) + +/* Defines */ +#define BATMON_TEMPERATURE_MAX (250) +#define BATMON_TEMPERATURE_MIN (-250) +#define BATMON_TEMPERATURE_CODE_MAX 0x0000FF00 +#define BATMON_TEMPERATURE_CODE_MIN 0x00010000 +#define BATMON_TEMPERATURE_MASK_POSITIVE 0x0000FF00 +#define BATMON_TEMPERATURE_MASK_NEGATIVE 0x0001FF00 + +/* Offset to apply to all thresholds before programming the hardware. + * + * When the hardware samples the temperature sensor, the returned reading + * is drawn from a probability distribution of measurements for each true + * temperature. In order for a notification to trigger, two separate + * measurements must cross the configured threshold temperature. + * The first is initiated by the hardware in the background to check whether + * to trigger the HWI. The second is triggered by software within the HWI + * function. If the first measurement is part of the long tail of the + * distribution, it is highly probable that the second measurement will not + * cross the threshold. This is effectively a spurrious interrupt that wastes + * energy and CPU cycles. + * If we program the actual hardware registers with an additional offset, we + * effectively shift the distribution up or down such that the first measurement + * triggers on the long tail of the distribution that is DISTRIBUTION_OFFSET + * degrees away from the threshold provided by the application. The second + * measurement then has a much higher probability of crossing the threshold + * and triggering the notification and an update of the thresholds. + * + * The risk is of course that a particular chip has a compressed distribution + * where the long tail does not reach far enough to trigger the HWI with the + * offset applied. + * Additionally, the device does not sample nearly as frequently when in + * standby. + * + * Both of these risks result in a less accurate but overall more useful system. + * If the temperature keeps rising, both scenarios still cause a notification + * to trigger. Given that temperature changes are usually not instantaneous, + * this should be considered an acceptable risk. + */ +#define DISTRIBUTION_OFFSET 2 + +#define INVALID_TEMPERATURE_MAX BATMON_TEMPERATURE_MAX +#define INVALID_TEMPERATURE_MIN BATMON_TEMPERATURE_MIN + +/* Forward declarations */ +static void walkNotifyList(); +static void setNextThresholds(); +static void temperatureHwiFxn(uintptr_t arg0); +static void updateThresholds(int16_t thresholdHigh, int16_t thresholdLow); +static uint32_t degreesToCode(int32_t temperatureDegreesC); +static void setTempLowerLimit(int16_t thresholdLow); +static void setTempUpperLimit(int16_t thresholdHigh); +static void enableTempLowerLimit(); +static void enableTempUpperLimit(); +static void disableTempLowerLimit(); +static void disableTempUpperLimit(); +static void clearEventFlags(); + +/* Globals */ + +/* Hwi struct for the shared batmon interrupt */ +static HwiP_Struct batmonHwi; + +/* Global list that stores all registered notifications */ +static List_List notificationList; + +/* Current threshold values. These should always reflect the state of the + * batmon registers without the need to read them out, shift down, and sign + * extend the values. + */ +static volatile int16_t currentThresholdHigh = INVALID_TEMPERATURE_MAX; +static volatile int16_t currentThresholdLow = INVALID_TEMPERATURE_MIN; + +static bool isInitialized = 0; + +extern const TemperatureCC26X2_Config TemperatureCC26X2_config; + +/* + * ======== degreesToCode ======== + */ +static uint32_t degreesToCode(int32_t temperatureDegreesC) { + /* Voltage dependent temp correction with 8 fractional bits */ + int32_t correctionOffset; + /* Signed byte value representing the TEMP offset slope with battery + * voltage in degrees C/V with 4 fractional bits. This must be multiplied + * by the voltage delta between the current voltage and the voltage used + * to compute this slope. + */ + int8_t voltageSlope; + int32_t temperatureCode; + + /* Typecasting voltageSlope to int8_t prior to assignment in order to make + * sure sign extension works properly. + * Using byte read (HWREGB) in order to make more efficient code since + * voltageSlope is assigned to bits[7:0] of FCFG1_O_MISC_TRIM + */ + voltageSlope = ((int8_t)HWREGB(FCFG1_BASE + FCFG1_O_MISC_TRIM)); + + /* Get the current supply voltage */ + correctionOffset = ((int32_t)HWREG(AON_BATMON_BASE + AON_BATMON_O_BAT)); + /* The voltageSlope is measured at 3V in production test. We need to remove + * this from the current voltage to find the delta we need to apply. + * At 3V, there should be no adjustment necessary. The BATMON voltage + * measurement has 8 fractional bits. + */ + correctionOffset = correctionOffset - (3 << 8); + /* Multiply the delta with the voltageSlope. */ + correctionOffset = correctionOffset * voltageSlope; + /* Right shift by four to remove the fractional bits */ + correctionOffset = correctionOffset >> 4; + + /* Shift up and then back down to sign-extend the temperatureCode. + * Shift the temperature up by net 8 bit positions to move the integer part + * into bits 16:8. This is what the register expects and gives us 8 + * fractional bits to work with as well for voltage compensation. + */ + temperatureCode = (int32_t)((uint32_t)temperatureDegreesC << (32 - AON_BATMON_TEMP_INT_W)); + temperatureCode = temperatureCode >> (32 - AON_BATMON_TEMP_INT_W - AON_BATMON_TEMP_INT_S); + + /* 0x80 represents the rounding factor of half the previous net shift value */ + temperatureCode = temperatureCode - 0x80; + + temperatureCode = temperatureCode + correctionOffset; + + if (temperatureDegreesC <= BATMON_TEMPERATURE_MIN) { + temperatureCode = BATMON_TEMPERATURE_CODE_MIN; + } + else if (temperatureDegreesC >= BATMON_TEMPERATURE_MAX) { + temperatureCode = BATMON_TEMPERATURE_CODE_MAX; + } + + if (temperatureCode < 0) { + temperatureCode &= BATMON_TEMPERATURE_MASK_NEGATIVE; + } + else if (temperatureCode >= 0) { + temperatureCode &= BATMON_TEMPERATURE_MASK_POSITIVE; + } + + return (uint32_t)(temperatureCode); +} + +/* + * ======== setTempLowerLimit ======== + */ +static void setTempLowerLimit(int16_t thresholdLow) { + uint32_t temperatureCode = degreesToCode(thresholdLow - DISTRIBUTION_OFFSET); + + HWREG(AON_BATMON_BASE + AON_BATMON_O_TEMPLL) = temperatureCode; + + currentThresholdLow = thresholdLow; +} + +/* + * ======== setTempUpperLimit ======== + */ +static void setTempUpperLimit(int16_t thresholdHigh) { + uint32_t temperatureCode = degreesToCode(thresholdHigh + DISTRIBUTION_OFFSET); + + HWREG(AON_BATMON_BASE + AON_BATMON_O_TEMPUL) = temperatureCode; + + currentThresholdHigh = thresholdHigh; +} + +/* + * ======== enableTempLowerLimit ======== + */ +static void enableTempLowerLimit() { + HWREG(AON_BATMON_BASE + AON_BATMON_O_EVENTMASK) |= AON_BATMON_EVENTMASK_TEMP_BELOW_LL_MASK; +} + +/* + * ======== enableTempUpperLimit ======== + */ +static void enableTempUpperLimit() { + HWREG(AON_BATMON_BASE + AON_BATMON_O_EVENTMASK) |= AON_BATMON_EVENTMASK_TEMP_OVER_UL_MASK; +} + +/* + * ======== disableTempLowerLimit ======== + */ +static void disableTempLowerLimit() { + HWREG(AON_BATMON_BASE + AON_BATMON_O_EVENTMASK) &= ~AON_BATMON_EVENTMASK_TEMP_BELOW_LL_MASK; +} + +/* + * ======== disableTempUpperLimit ======== + */ +static void disableTempUpperLimit() { + HWREG(AON_BATMON_BASE + AON_BATMON_O_EVENTMASK) &= ~AON_BATMON_EVENTMASK_TEMP_OVER_UL_MASK; +} + +/* + * ======== clearEventFlags ======== + */ +static void clearEventFlags() { + do { + HWREG(AON_BATMON_BASE + AON_BATMON_O_EVENT) &= AON_BATMON_EVENT_TEMP_BELOW_LL | + AON_BATMON_EVENT_TEMP_OVER_UL; + } while (HWREG(AON_BATMON_BASE + AON_BATMON_O_EVENT) & + (AON_BATMON_EVENT_TEMP_BELOW_LL | AON_BATMON_EVENT_TEMP_OVER_UL)); +} + +/* + * ======== setNextThresholds ======== + */ +static void setNextThresholds() { + List_Elem *notifyLink; + int16_t nextThresholdHigh = INVALID_TEMPERATURE_MAX; + int16_t nextThresholdLow = INVALID_TEMPERATURE_MIN; + uint32_t key; + + key = HwiP_disable(); + + /* Starting with the head of the list, keep track of the smallest high + * threshold and largest low threshold. + */ + notifyLink = List_head(¬ificationList); + + while (notifyLink != NULL) { + Temperature_NotifyObj* notifyObject = (Temperature_NotifyObj *)notifyLink; + + nextThresholdHigh = MIN(nextThresholdHigh, + notifyObject->thresholdHigh); + nextThresholdLow = MAX(nextThresholdLow, + notifyObject->thresholdLow); + + notifyLink = List_next(notifyLink); + } + + /* Now that we have found the next upper and lower thresholds, set them. + * These could be INVALID_TEMPERATURE_MAX and/or INVALID_TEMPERATURE_MIN + * if the list is empty or only high/low notifications were registered. + */ + updateThresholds(nextThresholdHigh, nextThresholdLow); + + HwiP_restore(key); +} + +/* + * ======== walkNotifyList ======== + */ +static void walkNotifyList() { + List_Elem *notifyLink = List_head(¬ificationList); + int16_t currentTemperature = Temperature_getTemperature(); + + /* If the notification list is empty, the head pointer will be + * NULL and the while loop will never execute the statement. + */ + while (notifyLink != NULL) { + Temperature_NotifyObj* notifyObject = (Temperature_NotifyObj *)notifyLink; + + /* Buffer the next link in case the notification triggers. + * Without buffering, we might skip list entries if the + * notifyObject is freed or reregistered and the notifyObject->link.next + * pointer is altered. + */ + List_Elem *notifyLinkNext = List_next(notifyLink); + + /* If the current temperature is below this notification's low + * threshold or above its high threshold, remove it from the list and + * call the callback fxn + */ + if (currentTemperature <= notifyObject->thresholdLow || + currentTemperature >= notifyObject->thresholdHigh) { + + /* Choose the threshold to provide to the notifyFxn based on the + * thresholds and the current temperature. + */ + int16_t threshold = (currentTemperature <= notifyObject->thresholdLow) ? + notifyObject->thresholdLow : notifyObject->thresholdHigh; + + List_remove(¬ificationList, notifyLink); + notifyObject->isRegistered = false; + + notifyObject->notifyFxn(currentTemperature, + threshold, + notifyObject->clientArg, + notifyObject); + } + + notifyLink = notifyLinkNext; + } +} + +/* + * ======== updateThresholds ======== + */ +static void updateThresholds(int16_t thresholdHigh, int16_t thresholdLow) { + if (thresholdHigh < currentThresholdHigh) { + setTempUpperLimit(thresholdHigh); + enableTempUpperLimit(); + } + + if (thresholdLow > currentThresholdLow) { + setTempLowerLimit(thresholdLow); + enableTempLowerLimit(); + } +} + +/* + * ======== temperatureHwiFxn ======== + * + * Batmon interrupt triggered on high or low temperature event + */ +static void temperatureHwiFxn(uintptr_t arg0) { + + setTempUpperLimit(INVALID_TEMPERATURE_MAX); + disableTempUpperLimit(); + + setTempLowerLimit(INVALID_TEMPERATURE_MIN); + disableTempLowerLimit(); + + + /* Walk the notification list and issue any callbacks that have triggered + * at the current temperature. + */ + walkNotifyList(); + + /* Walk the queue another time to find and set the next set of thresholds. + * This is faster than making even one extra access to AON_BATMON. + */ + setNextThresholds(); + + + + /* Clear event flags. They may not immediately clear properly. */ + clearEventFlags(); + + IntPendClear(INT_BATMON_COMB); +} + +/* + * ======== Temperature_init ======== + */ +void Temperature_init() { + uint32_t key; + + key = HwiP_disable(); + + if (isInitialized == false) { + /* Initialise the batmon hwi. The temperature sensor shares this + * interrupt with the battery voltage monitoring events. + */ + HwiP_Params hwiParams; + HwiP_Params_init(&hwiParams); + hwiParams.priority = TemperatureCC26X2_config.intPriority; + hwiParams.enableInt = true; + HwiP_construct(&batmonHwi, INT_BATMON_COMB, temperatureHwiFxn, NULL); + + disableTempUpperLimit(); + disableTempLowerLimit(); + + AONBatMonEnable(); + + /* Set the combined BATMON interrupt as a wakeup source. This means the + * BATMON can bring the device out of standby when an event is + * triggered. + * We use WU2 since WU0 is the RTC and WU1 is a pad (GPIO) event. + */ + AONEventMcuWakeUpSet(AON_EVENT_MCU_WU2, AON_EVENT_BATMON_COMBINED); + + isInitialized = true; + } + + HwiP_restore(key); +} + +/* + * ======== Temperature_getTemperature ======== + */ +int16_t Temperature_getTemperature(void) { + /* The temperature on CC13X2/CC26X2 is stored in a 32-bit register + * containing a 9-bit signed integer part and a 2-bit unsigned fractional + * part. + * The driverlib fxn handles this as well as compensating for the battery + * voltage which also affects the measured temperature. + */ + int16_t currentTemperature = AONBatMonTemperatureGetDegC(); + + return currentTemperature; +} + +/* + * ======== Temperature_registerNotifyHigh ======== + */ +int_fast16_t Temperature_registerNotifyHigh(Temperature_NotifyObj *notifyObject, + int16_t thresholdHigh, + Temperature_NotifyFxn notifyFxn, + uintptr_t clientArg) { + uint32_t key; + + key = HwiP_disable(); + + notifyObject->thresholdHigh = thresholdHigh; + notifyObject->thresholdLow = INVALID_TEMPERATURE_MIN; + notifyObject->notifyFxn = notifyFxn; + notifyObject->clientArg = clientArg; + + if (notifyObject->isRegistered == false) { + /* Add the notification to the end of the list. + * There is the implicit assumption that the notification is not already + * in the list. Otherwise the list linkage will be corrupted. + */ + List_put(¬ificationList, ¬ifyObject->link); + + notifyObject->isRegistered = true; + } + + updateThresholds(notifyObject->thresholdHigh, notifyObject->thresholdLow); + + HwiP_restore(key); + + return Temperature_STATUS_SUCCESS; +} + +/* + * ======== Temperature_registerNotifyLow ======== + */ +int_fast16_t Temperature_registerNotifyLow(Temperature_NotifyObj *notifyObject, + int16_t thresholdLow, + Temperature_NotifyFxn notifyFxn, + uintptr_t clientArg){ + uint32_t key; + + key = HwiP_disable(); + + notifyObject->thresholdHigh = INVALID_TEMPERATURE_MAX; + notifyObject->thresholdLow = thresholdLow; + notifyObject->notifyFxn = notifyFxn; + notifyObject->clientArg = clientArg; + + if (notifyObject->isRegistered == false) { + /* Add the notification to the end of the list. + * There is the implicit assumption that the notification is not already + * in the list. Otherwise the list linkage will be corrupted. + */ + List_put(¬ificationList, ¬ifyObject->link); + + notifyObject->isRegistered = true; + } + + updateThresholds(notifyObject->thresholdHigh, notifyObject->thresholdLow); + + HwiP_restore(key); + + return Temperature_STATUS_SUCCESS; +} + +/* + * ======== Temperature_registerNotifyRange ======== + */ +int_fast16_t Temperature_registerNotifyRange(Temperature_NotifyObj *notifyObject, + int16_t thresholdHigh, + int16_t thresholdLow, + Temperature_NotifyFxn notifyFxn, + uintptr_t clientArg) { + uint32_t key; + + key = HwiP_disable(); + + notifyObject->thresholdHigh = thresholdHigh; + notifyObject->thresholdLow = thresholdLow; + notifyObject->notifyFxn = notifyFxn; + notifyObject->clientArg = clientArg; + + if (notifyObject->isRegistered == false) { + /* Add the notification to the end of the list. + * There is the implicit assumption that the notification is not already + * in the list. Otherwise the list linkage will be corrupted. + */ + List_put(¬ificationList, ¬ifyObject->link); + + notifyObject->isRegistered = true; + } + + updateThresholds(notifyObject->thresholdHigh, notifyObject->thresholdLow); + + HwiP_restore(key); + + return Temperature_STATUS_SUCCESS; +} + +/* + * ======== Temperature_unregisterNotify ======== + */ +int_fast16_t Temperature_unregisterNotify(Temperature_NotifyObj *notifyObject) { + uint32_t key; + + key = HwiP_disable(); + + if (notifyObject->isRegistered == true) { + /* Remove the notification from the list */ + List_remove(¬ificationList, &(notifyObject->link)); + + notifyObject->isRegistered = false; + } + + /* Find the next set of thresholds and update the registers */ + setNextThresholds(); + + HwiP_restore(key); + + return Temperature_STATUS_SUCCESS; +} diff --git a/simplelink/source/ti/drivers/temperature/TemperatureCC26X2.h b/simplelink/source/ti/drivers/temperature/TemperatureCC26X2.h new file mode 100644 index 0000000..83be322 --- /dev/null +++ b/simplelink/source/ti/drivers/temperature/TemperatureCC26X2.h @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2020, Texas Instruments Incorporated + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * 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. + * + * * Neither the name of Texas Instruments Incorporated 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 OWNER 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 TemperatureCC26X2.h + * + * @brief Temperature driver implementation for the CC26X2 family + * + * The temperature driver on CC26X2 is a part of the battery monitoring + * system in AON (always on). It periodically takes measurements of the + * temperature of the chip and will issue interrupts if the configured + * upper limit or lower limit is crossed. + * + * # Standby Power Mode Behavior # + * The temperature measurement is active while in standby power mode as well. + * The interrupt used by the temperature module is capable of bringing the + * device out of standby and into active mode to handle it. That means that + * an application will not miss a change in temperature just because the device + * has transitioned to standby power mode. + * While in standby, the temperature will only be sampled during a VDDR + * recharge pulse. This means that the sampling frequency in standby will be + * determined by the temperature as leakage increases with temperature and + * requires more frequent recharging of VDDR. + * + * # Measurement Confidence Bounds + * There is an inherent inaccuracy in the temperature measurements reported + * by the device for any given chip temperature. This inaccuracy varies + * by chip. + * In order to set accurate threshold values and act upon provided + * temperatures, the following table provides a 99% confidence interval for + * the upper and lower bounds of the measured temperature by true + * temperature. These figures are given across the range of manufacturing + * variances. + * + * | Ambient Temperature | -40 | -30 | -20 | -10 | 0 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 100 | 110 | 120 | + * |---------------------|-----|-----|-----|-----|----|----|----|----|----|----|----|----|----|----|-----|-----|-----| + * | Upper | -28 | -20 | -12 | -3 | 7 | 17 | 26 | 36 | 46 | 56 | 65 | 75 | 85 | 95 | 105 | 115 | 125 | + * | Lower | -45 | -36 | -26 | -16 | -5 | 4 | 14 | 24 | 35 | 45 | 54 | 65 | 75 | 85 | 94 | 104 | 113 | + * + * # Measurement-to-Measurement Variations # + * For each chip, there is a distribution of temperature readings each + * measurement will yield for each true temperature. This means that if a + * notification threshold close to the current temperature is chosen, the + * hardware may cause an interrupt only for the driver to read out the + * temperature again with a value that does not cross the set threshold. + * In this case, the driver will not issue a notification. This does cost + * cpu cycles and energy though. + * + * Because of this measurement-to-measurement variability, it is not + * recommended to set a threshold closer than 5 degrees to the current + * temperature when registering a notification. + */ + +#ifndef ti_drivers_temperature_TemperatureCC26X2__include +#define ti_drivers_temperature_TemperatureCC26X2__include + +#include +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + * @brief Temperature driver configuration struct for CC26X2 + * + * This struct globally controls configuration settings for the CC26X2 + * Temperature driver. + * + * The CC26X2 Temperature driver implementation links against a structure + * of this type named TemperatureCC26X2_config. + * + * This structure must be allocated and configured by the application. If + * SysConfig is used, this struct will be automatically created when the + * Temperature module is used in SysConfig. + */ +typedef struct { + /*! @brief Temperature sensor's interrupt priority. + * + * The interrupt line is shared between the temperature sensor and the + * battery voltage monitor on CC26X2 + * + * The CC26X2 uses three of the priority bits, meaning ~0 has the same + * effect as (7 << 5). + * + * (7 << 5) will apply the lowest priority. + * + * (1 << 5) will apply the highest priority. + * + * Setting the priority to 0 is not supported by this driver. + * + * HWI's with priority 0 ignore the HWI dispatcher to support zero-latency + * interrupts, thus invalidating the critical sections. + */ + uint8_t intPriority; +} TemperatureCC26X2_Config; + + +#ifdef __cplusplus +} +#endif + +#endif /* ti_drivers_temperature_TemperatureCC26X2__include */