From cf8872816e83c572a513843bed947bc79ae8b8ad Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Thu, 8 Jul 2021 19:44:28 +0200 Subject: [PATCH 1/1] Own changes --- .../Application/mt/mt.h | 4 + .../Application/mt/mt_util.c | 106 ++ .../Application/mt/mt_version.c | 8 +- .../Application/mt/mt_zdo.c | 5 + .../Stack/Config/preinclude.h | 73 ++ .../Stack/Config/znp_cnf.opts | 2 + .../Stack/af/af.c | 18 +- .../Stack/nwk/nwk_globals.c | 8 +- .../Stack/sys/zglobals.c | 6 +- .../Stack/zdo/zd_app.c | 30 +- .../cc13x2_cc26x2.cmd | 6 +- .../syscfg/ti_devices_config.c | 104 ++ .../syscfg/ti_drivers_config.c | 1060 +++++++++++++++++ .../syscfg/ti_drivers_config.h | 283 +++++ .../syscfg/ti_radio_config.c | 340 ++++++ .../syscfg/ti_radio_config.h | 77 ++ .../syscfg/ti_utils_build_linker.cmd.genlibs | 35 + .../syscfg/ti_zstack_config.h | 226 ++++ .../Application/mt/mt.h | 4 + .../Application/mt/mt_util.c | 106 ++ .../Application/mt/mt_version.c | 8 +- .../Application/mt/mt_zdo.c | 5 + .../Stack/Config/preinclude.h | 60 + .../Stack/Config/znp_cnf.opts | 2 + .../Stack/af/af.c | 18 +- .../Stack/nwk/nwk_globals.c | 8 +- .../Stack/sys/zglobals.c | 6 +- .../Stack/zdo/zd_app.c | 30 +- .../cc13x2_cc26x2.cmd | 6 +- znp_CC26X2R1_LAUNCHXL_tirtos_ccs/znp.syscfg | 31 +- .../Application/mt/mt.h | 4 + .../Application/mt/mt_util.c | 106 ++ .../Application/mt/mt_version.c | 8 +- .../Application/mt/mt_zdo.c | 5 + .../Stack/Config/preinclude.h | 60 + .../Stack/Config/znp_cnf.opts | 2 + znp_LP_CC2652RB_tirtos_ccs/Stack/af/af.c | 18 +- .../Stack/nwk/nwk_globals.c | 8 +- .../Stack/sys/zglobals.c | 6 +- znp_LP_CC2652RB_tirtos_ccs/Stack/zdo/zd_app.c | 30 +- znp_LP_CC2652RB_tirtos_ccs/cc13x2_cc26x2.cmd | 6 +- znp_LP_CC2652RB_tirtos_ccs/znp.syscfg | 31 +- 42 files changed, 2853 insertions(+), 106 deletions(-) create mode 100644 znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/Config/preinclude.h mode change 100644 => 100755 znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/af/af.c mode change 100644 => 100755 znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/nwk/nwk_globals.c create mode 100644 znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_devices_config.c create mode 100644 znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_drivers_config.c create mode 100644 znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_drivers_config.h create mode 100644 znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_radio_config.c create mode 100644 znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_radio_config.h create mode 100644 znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_utils_build_linker.cmd.genlibs create mode 100644 znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_zstack_config.h create mode 100644 znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/Config/preinclude.h create mode 100644 znp_LP_CC2652RB_tirtos_ccs/Stack/Config/preinclude.h diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt.h b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt.h index 2c5073c..48f050b 100644 --- a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt.h +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt.h @@ -415,6 +415,8 @@ extern "C" #define MT_UTIL_CALLBACK_SUB_CMD 0x06 #define MT_UTIL_TIME_ALIVE 0x09 +#define MT_UTIL_LED_CONTROL 0x0A + #define MT_UTIL_TEST_LOOPBACK 0x10 #define MT_UTIL_DATA_REQ 0x11 @@ -441,6 +443,8 @@ extern "C" #define MT_UTIL_SRNG_GENERATE 0x4C #endif #define MT_UTIL_BIND_ADD_ENTRY 0x4D +#define MT_UTIL_ASSOC_REMOVE 0x63 // Custom command +#define MT_UTIL_ASSOC_ADD 0x64 // Custom command #define MT_UTIL_ZCL_KEY_EST_INIT_EST 0x80 #define MT_UTIL_ZCL_KEY_EST_SIGN 0x81 diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt_util.c b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt_util.c index 90d6d4a..4f416e8 100644 --- a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt_util.c +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt_util.c @@ -53,6 +53,9 @@ #include "mt_zdo.h" #include "ssp.h" +#include +#include "ti_drivers_config.h" + #if !defined NONWK #include "mt_nwk.h" @@ -95,6 +98,8 @@ static void MT_UtilSpi2Addr( zAddrType_t *pDst, uint8_t *pSrc ); #endif #if defined (MT_UTIL_FUNC) +static LED_Handle gLedHandle; + static void MT_UtilGetDeviceInfo(void); static void MT_UtilGetNvInfo(void); static void MT_UtilSetPanID(uint8_t *pBuf); @@ -128,6 +133,9 @@ static void MT_UtilAPSME_LinkKeyNvIdGet(uint8_t *pBuf); #endif //MT_SYS_KEY_MANAGEMENT static void MT_UtilAPSME_RequestKeyCmd(uint8_t *pBuf); static void MT_UtilAssocCount(uint8_t *pBuf); +static void MT_UtilLedControl(uint8_t *pBuf); +static void MT_UtilAssocRemove(uint8_t *pBuf); +static void MT_UtilAssocAdd(uint8_t *pBuf); static void MT_UtilAssocFindDevice(uint8_t *pBuf); static void MT_UtilAssocGetWithAddress(uint8_t *pBuf); static void MT_UtilBindAddEntry(uint8_t *pBuf); @@ -260,6 +268,10 @@ uint8_t MT_UtilCommandProcessing(uint8_t *pBuf) MT_UtilAssocCount(pBuf); break; + case MT_UTIL_LED_CONTROL: + MT_UtilLedControl(pBuf); + break; + case MT_UTIL_ASSOC_FIND_DEVICE: MT_UtilAssocFindDevice(pBuf); break; @@ -272,6 +284,14 @@ uint8_t MT_UtilCommandProcessing(uint8_t *pBuf) MT_UtilBindAddEntry(pBuf); break; + case MT_UTIL_ASSOC_REMOVE: + MT_UtilAssocRemove(pBuf); + break; + + case MT_UTIL_ASSOC_ADD: + MT_UtilAssocAdd(pBuf); + break; + case MT_UTIL_SYNC_REQ: MT_UtilSync(); break; @@ -1375,6 +1395,92 @@ static void MT_UtilAssocCount(uint8_t *pBuf) MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 2, pBuf); } +/*************************************************************************************************** + * @fn MT_UtilLedControl + * + * @brief Proxy the LedControl() function. + * + * @param pBuf - pointer to the received buffer + * + * @return void + ***************************************************************************************************/ +static void MT_UtilLedControl(uint8_t *pBuf) +{ + uint8_t cmdId = pBuf[MT_RPC_POS_CMD1]; + pBuf += MT_RPC_FRAME_HDR_SZ; + + uint8_t mode = pBuf[1]; + + if (gLedHandle == NULL) { + LED_Params ledParams; + LED_Params_init(&ledParams); + gLedHandle = LED_open(CONFIG_LED_GREEN, &ledParams); + } + + if (mode==0) { + LED_setOff(gLedHandle); + } else { + LED_setOn(gLedHandle, LED_BRIGHTNESS_MAX); + } + + uint8_t retValue = 0; + MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); +} + +/*************************************************************************************************** + * @fn MT_UtilAssocRemove + * + * @brief Proxy the AssocRemove() function. + * + * @param pBuf - pointer to the received buffer + * + * @return void + ***************************************************************************************************/ +static void MT_UtilAssocRemove(uint8_t *pBuf) +{ + uint8_t cmdId; + uint8_t ieeeAddr[Z_EXTADDR_LEN]; + uint8_t retValue = 0; + + // parse header + cmdId = pBuf[MT_RPC_POS_CMD1]; + pBuf += MT_RPC_FRAME_HDR_SZ; + + /* IeeAddress */ + OsalPort_memcpy(ieeeAddr, pBuf, Z_EXTADDR_LEN); + + AssocRemove(ieeeAddr); + + MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); +} + +/*************************************************************************************************** + * @fn MT_UtilAssocAdd + * + * @brief Proxy the AssocAdd() function. + * + * @param pBuf - pointer to the received buffer + * + * @return void + ***************************************************************************************************/ +static void MT_UtilAssocAdd(uint8_t *pBuf) +{ + uint8_t cmdId; + uint8_t retValue = 0; + + // parse header + cmdId = pBuf[MT_RPC_POS_CMD1]; + pBuf += MT_RPC_FRAME_HDR_SZ; + + AssocAddNew( + BUILD_UINT16(pBuf[Z_EXTADDR_LEN], pBuf[Z_EXTADDR_LEN + 1]), + pBuf, + pBuf[Z_EXTADDR_LEN + 2] + ); + + MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); +} + /*************************************************************************************************** * @fn MT_UtilAssocFindDevice * diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt_version.c b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt_version.c index 63c143b..590ec09 100644 --- a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt_version.c +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt_version.c @@ -43,15 +43,21 @@ #include "zcomdef.h" #include "mt_version.h" +#define CODE_REVISION_NUMBER 20210708 + /****************************************************************************** * CONSTANTS *****************************************************************************/ const uint8_t MTVersionString[] = { 2, /* Transport protocol revision */ - 0, /* Product ID */ + 1, /* Product ID */ 2, /* Software major release number */ 7, /* Software minor release number */ 1, /* Software maintenance release number */ + ((CODE_REVISION_NUMBER >> 0) & 0xFF), + ((CODE_REVISION_NUMBER >> 8) & 0xFF), + ((CODE_REVISION_NUMBER >> 16) & 0xFF), + ((CODE_REVISION_NUMBER >> 24) & 0xFF), }; /****************************************************************************** diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt_zdo.c b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt_zdo.c index 9755b1d..3f8e60a 100644 --- a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt_zdo.c +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Application/mt/mt_zdo.c @@ -1658,6 +1658,11 @@ static void MT_ZdoMgmtPermitJoinRequest(uint8_t *pBuf) ignoreIndication = TRUE; retValue = (uint8_t)ZDP_MgmtPermitJoinReq( &destAddr, duration, tcSignificance, 0); ignoreIndication = FALSE; + + // If joining is enabled via a router, ZDO_ProcessMgmtPermitJoinReq is never triggered thus + // ZDSecMgrPermitJoining is never called. Joining via a router would always fail now since + // ZDSecMgrPermitJoiningEnabled in zd_sec_mgr.c stays FALSE + ZDSecMgrPermitJoining(duration); MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_ZDO), cmdId, 1, &retValue); } diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/Config/preinclude.h b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/Config/preinclude.h new file mode 100644 index 0000000..ed4ba66 --- /dev/null +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/Config/preinclude.h @@ -0,0 +1,73 @@ +#define MT_SYS_KEY_MANAGEMENT 1 +#define FEATURE_NVEXID 1 + +// Increase MAC buffers +#undef MAC_CFG_TX_DATA_MAX +#define MAC_CFG_TX_DATA_MAX 20 +#undef MAC_CFG_TX_MAX +#define MAC_CFG_TX_MAX 32 +#undef MAC_CFG_RX_MAX +#define MAC_CFG_RX_MAX 20 + +// Save memory +#undef NWK_MAX_BINDING_ENTRIES +#define NWK_MAX_BINDING_ENTRIES 1 +#undef APS_MAX_GROUPS +#define APS_MAX_GROUPS 1 + +// Increase NV pages to 3 to allow for bigger device tables +#undef NVOCMP_NVPAGES +#define NVOCMP_NVPAGES 3 + +// Disabling MULTICAST is required in order for proper group support. +// If MULTICAST is not disabled, the group adress is not included in the APS header +#define MULTICAST_ENABLED FALSE + +// Increase the max number of boardcasts, the default broadcast delivery time is 3 seconds +// with the value below this will allow for 1 broadcast every 0.15 second +#define MAX_BCAST 30 + +/** + * Enable MTO routing + */ +#define CONCENTRATOR_ENABLE TRUE +#define CONCENTRATOR_DISCOVERY_TIME 100 +#define CONCENTRATOR_ROUTE_CACHE TRUE +#define MAX_RTG_SRC_ENTRIES 200 +#define SRC_RTG_EXPIRY_TIME 2 + +/** + * Scale other device tables appropriately + */ +#define NWK_MAX_DEVICE_LIST 50 +#define ZDSECMGR_TC_DEVICE_MAX 200 +#define MAX_NEIGHBOR_ENTRIES 20 +#define MAX_RTG_ENTRIES 100 + +/** + * Reduce the APS ack wait duration from 6000 ms to 1000 ms (value * 2 = value in ms). + * This will make requests timeout quicker, in pratice the default timeout of 6000ms is too long. + */ +#define APSC_ACK_WAIT_DURATION_POLLED 500 + +// From https://www.ti.com/lit/an/swra650b/swra650b.pdf +#define LINK_DOWN_TRIGGER 12 +#define NWK_ROUTE_AGE_LIMIT 5 +#define DEF_NWK_RADIUS 15 +#define DEFAULT_ROUTE_REQUEST_RADIUS 8 +#define ZDNWKMGR_MIN_TRANSMISSIONS 0 +#define ROUTE_DISCOVERY_TIME 13 +#define MTO_RREQ_LIMIT_TIME 5000 + +// Different configs, uncomment for for launchpad firmware +#define LAUNCHPAD_CONFIG 1 + +#ifdef LAUNCHPAD_CONFIG +#define CONFIG_RF_24GHZ 0x0000001c +#define CONFIG_RF_HIGH_PA 0x0000001d +#define SET_CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA 0xc1 +#else +#define CONFIG_RF_24GHZ 0x0000006 +#define CONFIG_RF_HIGH_PA 0x0000005 +#define SET_CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA 0xfa +#endif diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/Config/znp_cnf.opts b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/Config/znp_cnf.opts index 6e3cb6a..886d0b4 100644 --- a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/Config/znp_cnf.opts +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/Config/znp_cnf.opts @@ -32,3 +32,5 @@ -DMT_GP_CB_FUNC -DMT_APP_CNF_FUNC + +--preinclude=preinclude.h \ No newline at end of file diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/af/af.c b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/af/af.c old mode 100644 new mode 100755 index 3a7afa3..2dcef5a --- a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/af/af.c +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/af/af.c @@ -407,10 +407,18 @@ void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress, uint16_t S #if !defined ( APS_NO_GROUPS ) // Find the first endpoint for this group grpEp = aps_FindGroupForEndpoint( aff->GroupID, APS_GROUPS_FIND_FIRST ); - if ( grpEp == APS_GROUPS_EP_NOT_FOUND ) - return; // No endpoint found + if ( grpEp == APS_GROUPS_EP_NOT_FOUND ) { + // No endpoint found, default to endpoint 1. + // In the original source code there is a return here. + // This prevent the messags from being forwarded. + // For our use-case we want to capture all messages. + // Even if the coordinator is not in the group. + epDesc = afFindEndPointDesc( 1 ); + } + else { + epDesc = afFindEndPointDesc( grpEp ); + } - epDesc = afFindEndPointDesc( grpEp ); if ( epDesc == NULL ) return; // Endpoint descriptor not found @@ -457,7 +465,9 @@ void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress, uint16_t S // if the Wildcard ProfileID is received the message should not be sent to ZDO endpoint if ( (aff->ProfileID == epProfileID) || ((epDesc->endPoint == ZDO_EP) && (aff->ProfileID == ZDO_PROFILE_ID)) || - ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) ) + ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) || + // Forward messages to endpoint even with profileID mismatches + ((aff->ProfileID >= 0x100) && (aff->ProfileID <= 0xFC01)) ) { // Save original endpoint uint8_t endpoint = aff->DstEndPoint; diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/nwk/nwk_globals.c b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/nwk/nwk_globals.c old mode 100644 new mode 100755 index 2b63c06..6ac3fb2 --- a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/nwk/nwk_globals.c +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/nwk/nwk_globals.c @@ -65,10 +65,10 @@ * CONSTANTS */ // Maximums for the data buffer queue -#define NWK_MAX_DATABUFS_WAITING 8 // Waiting to be sent to MAC -#define NWK_MAX_DATABUFS_SCHEDULED 5 // Timed messages to be sent -#define NWK_MAX_DATABUFS_CONFIRMED 5 // Held after MAC confirms -#define NWK_MAX_DATABUFS_TOTAL 12 // Total number of buffers +#define NWK_MAX_DATABUFS_WAITING 32 // Waiting to be sent to MAC +#define NWK_MAX_DATABUFS_SCHEDULED 20 // Timed messages to be sent +#define NWK_MAX_DATABUFS_CONFIRMED 20 // Held after MAC confirms +#define NWK_MAX_DATABUFS_TOTAL 48 // Total number of buffers // 1-255 (0 -> 256) X RTG_TIMER_INTERVAL // A known shortcoming is that when a message is enqueued as "hold" for a diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/sys/zglobals.c b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/sys/zglobals.c index 764dabd..e9135fb 100644 --- a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/sys/zglobals.c +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/sys/zglobals.c @@ -105,7 +105,7 @@ uint8_t zgSecurePermitJoin = TRUE; // TC Link Key. In this scenario, if this flag is TRUE, the Trust Center will // encrypt the outgoing NWK Key with the default TC Link Key (ZigbeeAlliance09). // If this flag is FALSE (default), the Trust Center will not send the NWK Key at all. -uint8_t zgAllowRejoinsWithWellKnownKey = FALSE; +uint8_t zgAllowRejoinsWithWellKnownKey = TRUE; // https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread/f/158/p/882650/3265311#3265311 //allowInstallCodes uint8_t zgAllowInstallCodes = ZG_IC_SUPPORTED_NOT_REQUIRED; @@ -199,7 +199,9 @@ uint8_t zgEndDeviceConfiguration = END_DEV_CONFIGURATION; // // NOTICE: Before enabling Child Aging make sure to review all the related // definitions in this file, especially zgNwkParentInformation. -uint8_t zgChildAgingEnable = TRUE; + +// Disable child aging, otherwise Xiaomi devices are being kicked off the network. +uint8_t zgChildAgingEnable = FALSE; //========== TouchLink NWK configuration =============== // Values used by Router when starts a network as initiator diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/zdo/zd_app.c b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/zdo/zd_app.c index 1f807ca..b3e2694 100644 --- a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/zdo/zd_app.c +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/Stack/zdo/zd_app.c @@ -419,12 +419,11 @@ uint32_t ZDApp_event_loop( uint8_t task_id, uint32_t events ) ZDApp_ChangeState( DEV_ROUTER ); } - if ( zgChildAgingEnable == TRUE ) - { - // Once the device has changed its state to a ROUTER set the timer to send - // Parent annce - ZDApp_SetParentAnnceTimer(); - } + // As we cannot enable child aging as Xiaomi devices will drop off + // but we stil want to have the parent announces we always enable it here. + // Otherwise some end devices could be unreachable when they changed parent + // while the coordinator was powered off. + ZDApp_SetParentAnnceTimer(); } else { @@ -885,12 +884,11 @@ void ZDApp_NetworkStartEvt( void ) bdb_reportCommissioningState(BDB_INITIALIZATION,TRUE); } - if ( zgChildAgingEnable == TRUE ) - { - // Once the device has changed its state to a COORDINATOR set the timer to send - // Parent annce - ZDApp_SetParentAnnceTimer(); - } + // As we cannot enable child aging as Xiaomi devices will drop off + // but we stil want to have the parent announces we always enable it here. + // Otherwise some end devices could be unreachable when they changed parent + // while the coordinator was powered off. + ZDApp_SetParentAnnceTimer(); } else { @@ -3132,6 +3130,14 @@ void ZDO_NetworkStatusCB( uint16_t nwkDstAddr, uint8_t statusCode, uint16_t dstA // Routing error for dstAddr, this is informational and a Route // Request should happen automatically. } + + if ( (nwkDstAddr == NLME_GetShortAddr()) + && (statusCode == NWKSTAT_SOURCE_ROUTE_FAILURE) ) + { + // Received a source route failure, remove route and rediscover. + RTG_RemoveRtgEntry( dstAddr, 0 ); + NLME_RouteDiscoveryRequest( dstAddr, 0, 30 ); + } } /****************************************************************************** diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/cc13x2_cc26x2.cmd b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/cc13x2_cc26x2.cmd index 2dcc711..a8b8d93 100755 --- a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/cc13x2_cc26x2.cmd +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/cc13x2_cc26x2.cmd @@ -70,9 +70,9 @@ /* must be located at the beginning of the application. */ #define FLASH_BASE 0x00000000 -#define FLASH_SIZE 0x52000 -#define FLASH_NV_BASE 0x52000 -#define FLASH_NV_SIZE 0x4000 +#define FLASH_SIZE 0x50000 +#define FLASH_NV_BASE 0x50000 +#define FLASH_NV_SIZE 0x6000 #define FLASH_LAST_BASE 0x56000 #define FLASH_LAST_SIZE 0x2000 diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_devices_config.c b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_devices_config.c new file mode 100644 index 0000000..05c6fc1 --- /dev/null +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_devices_config.c @@ -0,0 +1,104 @@ +/* + * ======== ti_devices_config.c ======== + * Customer Configuration for CC26XX and CC13XX devices. + * + * DO NOT EDIT - This file is generated by the SysConfig tool. + * + */ + +//##################################### +// Force VDDR high setting (Higher output power but also higher power consumption) +// This is also called "boost mode" +//##################################### + +// Force VDDR voltage to the factory HH setting (FCFG1..VDDR_TRIM_HH) +#define CCFG_FORCE_VDDR_HH 0x1 + + +//##################################### +// Power settings +//##################################### + +// Do not use the DC/DC during recharge in powerdown +#define SET_CCFG_MODE_CONF_DCDC_RECHARGE 0x1 + +// Do not use the DC/DC during active mode +#define SET_CCFG_MODE_CONF_DCDC_ACTIVE 0x1 + + +//##################################### +// Clock settings +//##################################### + +// LF XOSC +#define SET_CCFG_MODE_CONF_SCLK_LF_OPTION 0x2 + +// Apply cap-array delta +#define SET_CCFG_MODE_CONF_XOSC_CAP_MOD 0x0 +// #define SET_CCFG_MODE_CONF_XOSC_CAPARRAY_DELTA 0xc1 + +//##################################### +// Special HF clock source setting +//##################################### + +// HF source is a 48 MHz xtal +#define SET_CCFG_MODE_CONF_XOSC_FREQ 0x2 + +//##################################### +// Bootloader settings +//##################################### + +// Enable ROM boot loader +#define SET_CCFG_BL_CONFIG_BOOTLOADER_ENABLE 0xC5 + +// Enabled boot loader backdoor +#define SET_CCFG_BL_CONFIG_BL_ENABLE 0xC5 + +// DIO number for boot loader backdoor +#define SET_CCFG_BL_CONFIG_BL_PIN_NUMBER 0xf + +// Active low to open boot loader backdoor +#define SET_CCFG_BL_CONFIG_BL_LEVEL 0x0 + + +// Default address in IMAGE_VALID_CONF register +#define SET_CCFG_IMAGE_VALID_CONF_IMAGE_VALID 0x00000000 + +//##################################### +// Debug access settings +//##################################### + +// Disable unlocking of TI FA option. +#define SET_CCFG_CCFG_TI_OPTIONS_TI_FA_ENABLE 0x00 + +// Access enabled if also enabled in FCFG +#define SET_CCFG_CCFG_TAP_DAP_0_CPU_DAP_ENABLE 0xC5 + +// Access enabled if also enabled in FCFG +#define SET_CCFG_CCFG_TAP_DAP_0_PWRPROF_TAP_ENABLE 0xC5 + +// Access disabled +#define SET_CCFG_CCFG_TAP_DAP_0_TEST_TAP_ENABLE 0x00 + +// Access disabled +#define SET_CCFG_CCFG_TAP_DAP_1_PBIST2_TAP_ENABLE 0x00 + +// Access disabled +#define SET_CCFG_CCFG_TAP_DAP_1_PBIST1_TAP_ENABLE 0x00 + +// Access disabled +#define SET_CCFG_CCFG_TAP_DAP_1_AON_TAP_ENABLE 0x00 + +//##################################### +// Select between cache or GPRAM +//##################################### + +// Cache is enabled and GPRAM is disabled (unavailable) +#define SET_CCFG_SIZE_AND_DIS_FLAGS_DIS_GPRAM 0x1 + +/* + * ======== Include Base Settings for device ======== + */ + +#include +#include DeviceFamily_constructPath(startup_files/ccfg.c) diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_drivers_config.c b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_drivers_config.c new file mode 100644 index 0000000..db9821f --- /dev/null +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_drivers_config.c @@ -0,0 +1,1060 @@ +/* + * ======== ti_drivers_config.c ======== + * Configured TI-Drivers module definitions + * + * DO NOT EDIT - This file is generated for the CC1352P_2_LAUNCHXL + * by the SysConfig tool. + */ + +#include +#include + +#ifndef DeviceFamily_CC13X2 +#define DeviceFamily_CC13X2 +#endif + +#include + +#include "ti_drivers_config.h" + +/* + * =============================== AESCBC =============================== + */ + +#include +#include + +#define CONFIG_AESCBC_COUNT 1 +AESCBCCC26XX_Object aescbcCC26XXObjects[CONFIG_AESCBC_COUNT]; + +/* + * ======== aescbcCC26XXHWAttrs ======== + */ +const AESCBCCC26XX_HWAttrs aescbcCC26XXHWAttrs[CONFIG_AESCBC_COUNT] = { + { + .intPriority = (~0), + }, +}; + +const AESCBC_Config AESCBC_config[CONFIG_AESCBC_COUNT] = { + { /* CONFIG_AESCBC_0 */ + .object = &aescbcCC26XXObjects[CONFIG_AESCBC_0], + .hwAttrs = &aescbcCC26XXHWAttrs[CONFIG_AESCBC_0] + }, +}; + +const uint_least8_t CONFIG_AESCBC_0_CONST = CONFIG_AESCBC_0; +const uint_least8_t AESCBC_count = CONFIG_AESCBC_COUNT; + +/* + * =============================== AESCCM =============================== + */ + +#include +#include + +#define CONFIG_AESCCM_COUNT 1 +AESCCMCC26XX_Object aesccmCC26XXObjects[CONFIG_AESCCM_COUNT]; + +/* + * ======== aesccmCC26XXHWAttrs ======== + */ +const AESCCMCC26XX_HWAttrs aesccmCC26XXHWAttrs[CONFIG_AESCCM_COUNT] = { + { + .intPriority = 0x40, + }, +}; + +const AESCCM_Config AESCCM_config[CONFIG_AESCCM_COUNT] = { + { /* CONFIG_AESCCM_0 */ + .object = &aesccmCC26XXObjects[CONFIG_AESCCM_0], + .hwAttrs = &aesccmCC26XXHWAttrs[CONFIG_AESCCM_0] + }, +}; + +const uint_least8_t CONFIG_AESCCM_0_CONST = CONFIG_AESCCM_0; +const uint_least8_t AESCCM_count = CONFIG_AESCCM_COUNT; + +/* + * =============================== AESECB =============================== + */ + +#include +#include + +#define CONFIG_AESECB_COUNT 1 +AESECBCC26XX_Object aesecbCC26XXObjects[CONFIG_AESECB_COUNT]; + +/* + * ======== aesecbCC26XXHWAttrs ======== + */ +const AESECBCC26XX_HWAttrs aesecbCC26XXHWAttrs[CONFIG_AESECB_COUNT] = { + { + .intPriority = 0x20, + }, +}; + +const AESECB_Config AESECB_config[CONFIG_AESECB_COUNT] = { + { /* CONFIG_AESECB_0 */ + .object = &aesecbCC26XXObjects[CONFIG_AESECB_0], + .hwAttrs = &aesecbCC26XXHWAttrs[CONFIG_AESECB_0] + }, +}; + + +const uint_least8_t CONFIG_AESECB_0_CONST = CONFIG_AESECB_0; +const uint_least8_t AESECB_count = CONFIG_AESECB_COUNT; + +/* + * =============================== DMA =============================== + */ + +#include +#include +#include + +UDMACC26XX_Object udmaCC26XXObject; + +const UDMACC26XX_HWAttrs udmaCC26XXHWAttrs = { + .baseAddr = UDMA0_BASE, + .powerMngrId = PowerCC26XX_PERIPH_UDMA, + .intNum = INT_DMA_ERR, + .intPriority = (~0) +}; + +const UDMACC26XX_Config UDMACC26XX_config[1] = { + { + .object = &udmaCC26XXObject, + .hwAttrs = &udmaCC26XXHWAttrs, + }, +}; + +/* + * =============================== ECDH =============================== + */ + +#include +#include + +#define CONFIG_ECDH_COUNT 1 + +ECDHCC26X2_Object ecdhCC26X2Objects[CONFIG_ECDH_COUNT]; + +/* + * ======== ecdhCC26X2HWAttrs ======== + */ +const ECDHCC26X2_HWAttrs ecdhCC26X2HWAttrs[CONFIG_ECDH_COUNT] = { + { + .intPriority = (~0), + }, +}; + +const ECDH_Config ECDH_config[CONFIG_ECDH_COUNT] = { + { /* CONFIG_ECDH_0 */ + .object = &ecdhCC26X2Objects[CONFIG_ECDH_0], + .hwAttrs = &ecdhCC26X2HWAttrs[CONFIG_ECDH_0] + }, +}; + +const uint_least8_t CONFIG_ECDH_0_CONST = CONFIG_ECDH_0; +const uint_least8_t ECDH_count = CONFIG_ECDH_COUNT; + +/* + * =============================== ECDSA =============================== + */ + +#include +#include + +#define CONFIG_ECDSA_COUNT 1 +ECDSACC26X2_Object ecdsaCC26X2Objects[CONFIG_ECDSA_COUNT]; + +/* + * ======== ecdsaCC26X2HWAttrs ======== + */ +const ECDSACC26X2_HWAttrs ecdsaCC26X2HWAttrs[CONFIG_ECDSA_COUNT] = { + { + .intPriority = (~0), + .trngIntPriority = (~0), + }, +}; + +const ECDSA_Config ECDSA_config[CONFIG_ECDSA_COUNT] = { + { /* CONFIG_ECDSA_0 */ + .object = &ecdsaCC26X2Objects[CONFIG_ECDSA_0], + .hwAttrs = &ecdsaCC26X2HWAttrs[CONFIG_ECDSA_0] + }, +}; + +const uint_least8_t CONFIG_ECDSA_0_CONST = CONFIG_ECDSA_0; +const uint_least8_t ECDSA_count = CONFIG_ECDSA_COUNT; + +/* + * =============================== ECJPAKE =============================== + */ + +#include +#include + +#define CONFIG_ECJPAKE_COUNT 1 +ECJPAKECC26X2_Object ecjpakeCC26X2Objects[CONFIG_ECJPAKE_COUNT]; + +/* + * ======== ecjpakeCC26X2HWAttrs ======== + */ +const ECJPAKECC26X2_HWAttrs ecjpakeCC26X2HWAttrs[CONFIG_ECJPAKE_COUNT] = { + { + .intPriority = (~0), + }, +}; + +const ECJPAKE_Config ECJPAKE_config[CONFIG_ECJPAKE_COUNT] = { + { /* CONFIG_ECJPAKE_0 */ + .object = &ecjpakeCC26X2Objects[CONFIG_ECJPAKE_0], + .hwAttrs = &ecjpakeCC26X2HWAttrs[CONFIG_ECJPAKE_0] + }, +}; + +const uint_least8_t CONFIG_ECJPAKE_0_CONST = CONFIG_ECJPAKE_0; +const uint_least8_t ECJPAKE_count = CONFIG_ECJPAKE_COUNT; + +/* + * =============================== GPIO =============================== + */ + +#include +#include + +#define CONFIG_GPIO_COUNT 5 + +/* + * ======== gpioPinConfigs ======== + * Array of Pin configurations + */ +GPIO_PinConfig gpioPinConfigs[] = { + /* CONFIG_GPIO_BTN1 : LaunchPad Button BTN-1 (Left) */ + GPIOCC26XX_DIO_15 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING, + /* CONFIG_GPIO_BTN2 : LaunchPad Button BTN-2 (Right) */ + GPIOCC26XX_DIO_14 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING, + /* CONFIG_GPIO_RLED : LaunchPad LED Red */ + GPIOCC26XX_DIO_06 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_MED | GPIO_CFG_OUT_LOW, + /* CONFIG_GPIO_GLED : LaunchPad LED Green */ + GPIOCC26XX_DIO_07 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_MED | GPIO_CFG_OUT_LOW, + /* SPI Flash Slave Select GPIO Instance */ + GPIOCC26XX_DIO_20 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_MED | GPIO_CFG_OUT_HIGH, +}; + +/* + * ======== gpioCallbackFunctions ======== + * Array of callback function pointers + * + * NOTE: Unused callback entries can be omitted from the callbacks array to + * reduce memory usage by enabling callback table optimization + * (GPIO.optimizeCallbackTableSize = true) + */ +GPIO_CallbackFxn gpioCallbackFunctions[] = { + /* CONFIG_GPIO_BTN1 : LaunchPad Button BTN-1 (Left) */ + NULL, + /* CONFIG_GPIO_BTN2 : LaunchPad Button BTN-2 (Right) */ + NULL, + /* CONFIG_GPIO_RLED : LaunchPad LED Red */ + NULL, + /* CONFIG_GPIO_GLED : LaunchPad LED Green */ + NULL, + /* SPI Flash Slave Select GPIO Instance */ + NULL, +}; + +const uint_least8_t CONFIG_GPIO_BTN1_CONST = CONFIG_GPIO_BTN1; +const uint_least8_t CONFIG_GPIO_BTN2_CONST = CONFIG_GPIO_BTN2; +const uint_least8_t CONFIG_GPIO_RLED_CONST = CONFIG_GPIO_RLED; +const uint_least8_t CONFIG_GPIO_GLED_CONST = CONFIG_GPIO_GLED; +const uint_least8_t CONFIG_GPIO_0_CONST = CONFIG_GPIO_0; + +/* + * ======== GPIOCC26XX_config ======== + */ +const GPIOCC26XX_Config GPIOCC26XX_config = { + .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs, + .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions, + .numberOfPinConfigs = 5, + .numberOfCallbacks = 5, + .intPriority = (~0) +}; + +/* + * =============================== NVS =============================== + */ + +#include +#include + +/* + * NVSCC26XX Internal NVS flash region definitions + * + * Place uninitialized char arrays at addresses + * corresponding to the 'regionBase' addresses defined in + * the configured NVS regions. These arrays are used as + * place holders so that the linker will not place other + * content there. + * + * For GCC targets, the char arrays are each placed into + * the shared ".nvs" section. The user must add content to + * their GCC linker command file to place the .nvs section + * at the lowest 'regionBase' address specified in their NVS + * regions. + */ + +#if defined(__TI_COMPILER_VERSION__) || defined(__clang__) + +static char flashBuf0[0x6000] __attribute__ ((retain, noinit, location(0x50000))); + +#elif defined(__IAR_SYSTEMS_ICC__) + +__no_init static char flashBuf0[0x6000] @ 0x50000; + +#elif defined(__GNUC__) + +__attribute__ ((section (".nvs"))) +static char flashBuf0[0x6000]; + +#endif + +NVSCC26XX_Object nvsCC26XXObjects[1]; + +static const NVSCC26XX_HWAttrs nvsCC26XXHWAttrs[1] = { + /* CONFIG_NVSINTERNAL */ + { + .regionBase = (void *) flashBuf0, + .regionSize = 0x6000 + }, +}; + +#include + +/* + * NVSSPI25X External NVS flash region definitions + */ + +/* + * Provide write verification buffer whose size is + * the largest specified Verification Buffer Size + */ + +static uint8_t verifyBuf[64]; + +NVSSPI25X_Object nvsSPI25XObjects[1]; + +static const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = { + /* CONFIG_NVSEXTERNAL */ + /* MX25R8035F SPI Flash */ + { + .regionBaseOffset = 0x0, + .regionSize = 0x256000, + .sectorSize = 0x1000, + .verifyBuf = verifyBuf, + .verifyBufSize = 64, + /* NVS opens SPI */ + .spiHandle = NULL, + /* SPI driver index */ + .spiIndex = CONFIG_SPI_0, + .spiBitRate = 4000000, + /* GPIO driver pin index */ + .spiCsnGpioIndex = CONFIG_GPIO_0, + .statusPollDelayUs = 100 + }, +}; + +#define CONFIG_NVS_COUNT 2 + +const NVS_Config NVS_config[CONFIG_NVS_COUNT] = { + /* CONFIG_NVSINTERNAL */ + { + .fxnTablePtr = &NVSCC26XX_fxnTable, + .object = &nvsCC26XXObjects[0], + .hwAttrs = &nvsCC26XXHWAttrs[0], + }, + /* CONFIG_NVSEXTERNAL */ + /* MX25R8035F SPI Flash */ + { + .fxnTablePtr = &NVSSPI25X_fxnTable, + .object = &nvsSPI25XObjects[0], + .hwAttrs = &nvsSPI25XHWAttrs[0], + }, +}; + +const uint_least8_t CONFIG_NVSINTERNAL_CONST = CONFIG_NVSINTERNAL; +const uint_least8_t CONFIG_NVSEXTERNAL_CONST = CONFIG_NVSEXTERNAL; +const uint_least8_t NVS_count = CONFIG_NVS_COUNT; + +/* + * =============================== PIN =============================== + */ +#include +#include + +#define CONFIG_PIN_COUNT 13 + +const PIN_Config BoardGpioInitTable[CONFIG_PIN_COUNT + 1] = { + /* XDS110 UART, Parent Signal: CONFIG_DISPLAY_UART TX, (DIO13) */ + CONFIG_PIN_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED, + /* XDS110 UART, Parent Signal: CONFIG_DISPLAY_UART RX, (DIO12) */ + CONFIG_PIN_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN | PIN_IRQ_DIS, + /* SKY13317-373LF RF Antenna Switch, Parent Signal: /ti/drivers/RF RF Antenna Pin 0, (DIO28) */ + CONFIG_RF_24GHZ | PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_DIS, + /* SKY13317-373LF RF Antenna Switch, Parent Signal: /ti/drivers/RF RF Antenna Pin 1, (DIO29) */ + CONFIG_RF_HIGH_PA | PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_DIS, + /* SKY13317-373LF RF Antenna Switch, Parent Signal: /ti/drivers/RF RF Antenna Pin 2, (DIO30) */ + CONFIG_RF_SUB1GHZ | PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_DIS, + /* LaunchPad Button BTN-1 (Left), Parent Signal: CONFIG_GPIO_BTN1 GPIO Pin, (DIO15) */ + CONFIG_PIN_BTN1 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_DIS, + /* LaunchPad Button BTN-2 (Right), Parent Signal: CONFIG_GPIO_BTN2 GPIO Pin, (DIO14) */ + CONFIG_PIN_BTN2 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_DIS, + /* LaunchPad LED Red, Parent Signal: CONFIG_GPIO_RLED GPIO Pin, (DIO6) */ + CONFIG_PIN_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED, + /* LaunchPad LED Green, Parent Signal: CONFIG_GPIO_GLED GPIO Pin, (DIO7) */ + CONFIG_PIN_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED, + /* MX25R8035F SPI Flash Slave Select, Parent Signal: CONFIG_GPIO_0 GPIO Pin, (DIO20) */ + CONFIG_PIN_0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MED, + /* LaunchPad SPI Bus, Parent Signal: CONFIG_SPI_0 SCLK, (DIO10) */ + CONFIG_PIN_SPI_SCLK | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED, + /* LaunchPad SPI Bus, Parent Signal: CONFIG_SPI_0 MISO, (DIO8) */ + CONFIG_PIN_SPI_MISO | PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_DIS, + /* LaunchPad SPI Bus, Parent Signal: CONFIG_SPI_0 MOSI, (DIO9) */ + CONFIG_PIN_SPI_MOSI | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MED, + + PIN_TERMINATE +}; + +const PINCC26XX_HWAttrs PINCC26XX_hwAttrs = { + .intPriority = (~0), + .swiPriority = 0 +}; + +/* + * =============================== Power =============================== + */ +#include +#include +#include "ti_drivers_config.h" + +extern void PowerCC26XX_standbyPolicy(void); +extern bool PowerCC26XX_calibrate(unsigned int); + +const PowerCC26X2_Config PowerCC26X2_config = { + .enablePolicy = true, + .policyInitFxn = NULL, + .policyFxn = PowerCC26XX_standbyPolicy, + .calibrateFxn = PowerCC26XX_calibrate, + .calibrateRCOSC_LF = true, + .calibrateRCOSC_HF = true, + .enableTCXOFxn = NULL +}; + + +/* + * =============================== RF Driver =============================== + */ +#include + +/* + * RF driver callback function, called by the driver on global driver events. + */ +static void RF_globalCallbackFunction (RF_Handle client, RF_GlobalEvent events, void* arg); + +/* + * Callback function to handle custom / application specific behavior + */ +extern void __attribute__((weak)) rfDriverCallback (RF_Handle client, RF_GlobalEvent events, void *arg); + +/* + * Callback function to handle antenna switching + */ +extern void __attribute__((weak)) rfDriverCallbackAntennaSwitching (RF_Handle client, RF_GlobalEvent events, void *arg); + +/* + * Platform-specific driver configuration + */ +const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = { + .hwiPriority = (~0), + .swiPriority = (uint8_t)0, + .xoscHfAlwaysNeeded = true, + .globalCallback = &RF_globalCallbackFunction, + .globalEventMask = RF_GlobalEventInit | RF_GlobalEventRadioPowerDown | RF_GlobalEventRadioSetup +}; + +/* + * ======== RF_globalCallbackFunction ======== + * This function is called by the driver on global driver events. + * It will call specific callback functions to further handle the triggering events. + */ +static void RF_globalCallbackFunction(RF_Handle client, RF_GlobalEvent events, void *arg) +{ + rfDriverCallback(client, events, arg); + rfDriverCallbackAntennaSwitching(client, events, arg); +} + +/* + * ======== rfDriverCallback ======== + * Handle events triggered by the RF driver for custom / application specific behavior. + */ +void __attribute__((weak)) rfDriverCallback(RF_Handle client, RF_GlobalEvent events, void *arg) +{ + /* ======== PLEASE READ THIS ======== + * + * This function is declared weak for the application to override it. + * A new definition of 'rfDriverCallback' is required if you want to + * handle the events listed in '.globalEventMask'. + * + * Please copy this function definition to create your own, but make + * sure to remove '__attribute__((weak))' for your definition. + * + * According to '.globalEventMask', this function will be triggered by: + * - RF_GlobalEventInit + * - RF_GlobalEventRadioPowerDown + * - RF_GlobalEventRadioSetup + * + * An example of how to handle these events would be: + * + * --- Code snippet begin --- + * + * if(events & RF_GlobalEventInit) { + * // Perform action for this event + * } + * else if (events & RF_GlobalEventRadioPowerDown) { + * // Perform action for this event + * } + * else if (events & RF_GlobalEventRadioSetup) { + * // Perform action for this event + * } + * + * --- Code snippet end --- + */ +} + + +/* + * ======== Antenna switching ======== + */ +static PIN_Handle antennaPins; +static PIN_State antennaState; + +static void initAntennaSwitch() +{ + PIN_Config antennaConfig[] = { + CONFIG_RF_24GHZ | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* Path disabled */ + CONFIG_RF_HIGH_PA | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* Path disabled */ + CONFIG_RF_SUB1GHZ | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* Path disabled */ + PIN_TERMINATE + }; + antennaPins = PIN_open(&antennaState, antennaConfig); +} + +/* + * ======== rfDriverCallbackAntennaSwitching ======== + * Sets up the antenna switch depending on the current PHY configuration. + * + * Truth table: + * + * Path DIO28 DIO29 DIO30 + * =========== ===== ===== ===== + * Off 0 0 0 + * Sub-1 GHz 0 0 1 + * 2.4 GHz 1 0 0 + * 20 dBm TX 0 1 0 + */ +void __attribute__((weak)) rfDriverCallbackAntennaSwitching(RF_Handle client, RF_GlobalEvent events, void *arg) +{ + /* Protect against repeated RF_init */ + static bool initialized = false; + + /* Local variable. */ + bool sub1GHz = false; + uint8_t loDivider = 0; + + if (!initialized && events & RF_GlobalEventInit) { + /* Don't do it again */ + initialized = true; + initAntennaSwitch(); + } + else if (events & RF_GlobalEventRadioSetup) { + /* Switch off all paths. */ + PINCC26XX_setOutputValue(CONFIG_RF_24GHZ, 0); + PINCC26XX_setOutputValue(CONFIG_RF_HIGH_PA, 0); + PINCC26XX_setOutputValue(CONFIG_RF_SUB1GHZ, 0); + + /* Decode the current PA configuration. */ + RF_TxPowerTable_PAType paType = (RF_TxPowerTable_PAType)RF_getTxPower(client).paType; + + /* Decode the generic argument as a setup command. */ + RF_RadioSetup* setupCommand = (RF_RadioSetup*)arg; + + switch (setupCommand->common.commandNo) { + case (CMD_RADIO_SETUP): + case (CMD_BLE5_RADIO_SETUP): + loDivider = RF_LODIVIDER_MASK & setupCommand->common.loDivider; + + /* Sub-1GHz front-end. */ + if (loDivider != 0) { + sub1GHz = true; + } + break; + case (CMD_PROP_RADIO_DIV_SETUP): + loDivider = RF_LODIVIDER_MASK & setupCommand->prop_div.loDivider; + + /* Sub-1GHz front-end. */ + if (loDivider != 0) { + sub1GHz = true; + } + break; + default:break; + } + + if (sub1GHz) { + /* Sub-1 GHz */ + if (paType == RF_TxPowerTable_HighPA) { + /* PA enable --> HIGH PA + * LNA enable --> Sub-1 GHz + */ + PINCC26XX_setMux(antennaPins, CONFIG_RF_24GHZ, PINCC26XX_MUX_GPIO); + /* Note: RFC_GPO3 is a work-around because the RFC_GPO1 (PA enable signal) is sometimes not + de-asserted on CC1352 Rev A. */ + PINCC26XX_setMux(antennaPins, CONFIG_RF_HIGH_PA, PINCC26XX_MUX_RFC_GPO3); + PINCC26XX_setMux(antennaPins, CONFIG_RF_SUB1GHZ, PINCC26XX_MUX_RFC_GPO0); + } else { + /* RF core active --> Sub-1 GHz */ + PINCC26XX_setMux(antennaPins, CONFIG_RF_24GHZ, PINCC26XX_MUX_GPIO); + PINCC26XX_setMux(antennaPins, CONFIG_RF_HIGH_PA, PINCC26XX_MUX_GPIO); + PINCC26XX_setMux(antennaPins, CONFIG_RF_SUB1GHZ, PINCC26XX_MUX_GPIO); + PINCC26XX_setOutputValue(CONFIG_RF_SUB1GHZ, 1); + } + } else { + /* 2.4 GHz */ + if (paType == RF_TxPowerTable_HighPA) + { + /* PA enable --> HIGH PA + * LNA enable --> 2.4 GHz + */ + PINCC26XX_setMux(antennaPins, CONFIG_RF_24GHZ, PINCC26XX_MUX_RFC_GPO0); + /* Note: RFC_GPO3 is a work-around because the RFC_GPO1 (PA enable signal) is sometimes not + de-asserted on CC1352 Rev A. */ + PINCC26XX_setMux(antennaPins, CONFIG_RF_HIGH_PA, PINCC26XX_MUX_RFC_GPO3); + PINCC26XX_setMux(antennaPins, CONFIG_RF_SUB1GHZ, PINCC26XX_MUX_GPIO); + } else { + /* RF core active --> 2.4 GHz */ + PINCC26XX_setMux(antennaPins, CONFIG_RF_24GHZ, PINCC26XX_MUX_GPIO); + PINCC26XX_setMux(antennaPins, CONFIG_RF_HIGH_PA, PINCC26XX_MUX_GPIO); + PINCC26XX_setMux(antennaPins, CONFIG_RF_SUB1GHZ, PINCC26XX_MUX_GPIO); + PINCC26XX_setOutputValue(CONFIG_RF_24GHZ, 1); + } + } + } + else if (events & RF_GlobalEventRadioPowerDown) { + /* Switch off all paths. */ + PINCC26XX_setOutputValue(CONFIG_RF_24GHZ, 0); + PINCC26XX_setOutputValue(CONFIG_RF_HIGH_PA, 0); + PINCC26XX_setOutputValue(CONFIG_RF_SUB1GHZ, 0); + + /* Reset the IO multiplexer to GPIO functionality */ + PINCC26XX_setMux(antennaPins, CONFIG_RF_24GHZ, PINCC26XX_MUX_GPIO); + PINCC26XX_setMux(antennaPins, CONFIG_RF_HIGH_PA, PINCC26XX_MUX_GPIO); + PINCC26XX_setMux(antennaPins, CONFIG_RF_SUB1GHZ, PINCC26XX_MUX_GPIO); + } +} + +/* + * =============================== SHA2 =============================== + */ + +#include +#include + +#define CONFIG_SHA2_COUNT 1 + +SHA2CC26X2_Object sha2CC26X2Objects[CONFIG_SHA2_COUNT]; + +/* + * ======== sha2CC26X2HWAttrs ======== + */ +const SHA2CC26X2_HWAttrs sha2CC26X2HWAttrs[CONFIG_SHA2_COUNT] = { + { + .intPriority = (~0), + }, +}; + +const SHA2_Config SHA2_config[CONFIG_SHA2_COUNT] = { + { /* CONFIG_SHA2_0 */ + .object = &sha2CC26X2Objects[CONFIG_SHA2_0], + .hwAttrs = &sha2CC26X2HWAttrs[CONFIG_SHA2_0] + }, +}; + +const uint_least8_t CONFIG_SHA2_0_CONST = CONFIG_SHA2_0; +const uint_least8_t SHA2_count = CONFIG_SHA2_COUNT; + +/* + * =============================== SPI DMA =============================== + */ +#include +#include + +#define CONFIG_SPI_COUNT 1 + +/* + * ======== spiCC26X2DMAObjects ======== + */ +SPICC26X2DMA_Object spiCC26X2DMAObjects[CONFIG_SPI_COUNT]; + +/* + * ======== spiCC26X2DMAHWAttrs ======== + */ +const SPICC26X2DMA_HWAttrs spiCC26X2DMAHWAttrs[CONFIG_SPI_COUNT] = { + /* CONFIG_SPI_0 */ + /* LaunchPad SPI Bus */ + { + .baseAddr = SSI0_BASE, + .intNum = INT_SSI0_COMB, + .intPriority = (~0), + .swiPriority = 0, + .powerMngrId = PowerCC26XX_PERIPH_SSI0, + .defaultTxBufValue = ~0, + .rxChannelBitMask = 1< +#include + +#define CONFIG_TRNG_COUNT 1 + +TRNGCC26XX_Object trngCC26XXObjects[CONFIG_TRNG_COUNT]; + +/* + * ======== trngCC26XXHWAttrs ======== + */ +static const TRNGCC26XX_HWAttrs trngCC26XXHWAttrs[CONFIG_TRNG_COUNT] = { + { + .intPriority = (~0), + .swiPriority = 0, + .samplesPerCycle = 240000 + }, +}; + +const TRNG_Config TRNG_config[CONFIG_TRNG_COUNT] = { + { /* CONFIG_TRNG_0 */ + .object = &trngCC26XXObjects[CONFIG_TRNG_0], + .hwAttrs = &trngCC26XXHWAttrs[CONFIG_TRNG_0] + }, +}; + +const uint_least8_t CONFIG_TRNG_0_CONST = CONFIG_TRNG_0; +const uint_least8_t TRNG_count = CONFIG_TRNG_COUNT; + +/* + * =============================== Temperature =============================== + */ +#include +#include + +const TemperatureCC26X2_Config TemperatureCC26X2_config = { + .intPriority = (~0), +}; + +/* + * =============================== UART =============================== + */ + +#include +#include +#include +#include +#include +#include + +#define CONFIG_UART_COUNT 1 + +UARTCC26XX_Object uartCC26XXObjects[CONFIG_UART_COUNT]; + +static unsigned char uartCC26XXRingBuffer0[32]; + +static const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CONFIG_UART_COUNT] = { + { + .baseAddr = UART0_BASE, + .intNum = INT_UART0_COMB, + .intPriority = (~0), + .swiPriority = 0, + .powerMngrId = PowerCC26XX_PERIPH_UART0, + .ringBufPtr = uartCC26XXRingBuffer0, + .ringBufSize = sizeof(uartCC26XXRingBuffer0), + .rxPin = IOID_12, + .txPin = IOID_13, + .ctsPin = PIN_UNASSIGNED, + .rtsPin = PIN_UNASSIGNED, + .txIntFifoThr = UARTCC26XX_FIFO_THRESHOLD_1_8, + .rxIntFifoThr = UARTCC26XX_FIFO_THRESHOLD_4_8, + .errorFxn = NULL + }, +}; + +const UART_Config UART_config[CONFIG_UART_COUNT] = { + { /* CONFIG_DISPLAY_UART */ + .fxnTablePtr = &UARTCC26XX_fxnTable, + .object = &uartCC26XXObjects[CONFIG_DISPLAY_UART], + .hwAttrs = &uartCC26XXHWAttrs[CONFIG_DISPLAY_UART] + }, +}; + +const uint_least8_t CONFIG_DISPLAY_UART_CONST = CONFIG_DISPLAY_UART; +const uint_least8_t UART_count = CONFIG_UART_COUNT; + +/* + * =============================== Button =============================== + */ +#include + +#define CONFIG_BUTTON_COUNT 2 +Button_Object ButtonObjects[CONFIG_BUTTON_COUNT]; + +static const Button_HWAttrs ButtonHWAttrs[CONFIG_BUTTON_COUNT] = { + /* CONFIG_BTN_LEFT */ + /* LaunchPad Button BTN-1 (Left) */ + { + .gpioIndex = CONFIG_GPIO_BTN1 + }, + /* CONFIG_BTN_RIGHT */ + /* LaunchPad Button BTN-2 (Right) */ + { + .gpioIndex = CONFIG_GPIO_BTN2 + }, +}; + +const Button_Config Button_config[CONFIG_BUTTON_COUNT] = { + /* CONFIG_BTN_LEFT */ + /* LaunchPad Button BTN-1 (Left) */ + { + .object = &ButtonObjects[CONFIG_BTN_LEFT], + .hwAttrs = &ButtonHWAttrs[CONFIG_BTN_LEFT] + }, + /* CONFIG_BTN_RIGHT */ + /* LaunchPad Button BTN-2 (Right) */ + { + .object = &ButtonObjects[CONFIG_BTN_RIGHT], + .hwAttrs = &ButtonHWAttrs[CONFIG_BTN_RIGHT] + }, +}; + +const uint_least8_t CONFIG_BTN_LEFT_CONST = CONFIG_BTN_LEFT; +const uint_least8_t CONFIG_BTN_RIGHT_CONST = CONFIG_BTN_RIGHT; +const uint_least8_t Button_count = CONFIG_BUTTON_COUNT; + +/* + * =============================== LED =============================== + */ +#include + +#define CONFIG_LED_COUNT 2 +LED_Object LEDObjects[CONFIG_LED_COUNT]; + +static const LED_HWAttrs LEDHWAttrs[CONFIG_LED_COUNT] = { + /* CONFIG_LED_RED */ + /* LaunchPad LED Red */ + { + .type = LED_GPIO_CONTROLLED, + .index = CONFIG_GPIO_RLED, + }, + /* CONFIG_LED_GREEN */ + /* LaunchPad LED Green */ + { + .type = LED_GPIO_CONTROLLED, + .index = CONFIG_GPIO_GLED, + }, +}; + +const LED_Config LED_config[CONFIG_LED_COUNT] = { + /* CONFIG_LED_RED */ + /* LaunchPad LED Red */ + { + .object = &LEDObjects[CONFIG_LED_RED], + .hwAttrs = &LEDHWAttrs[CONFIG_LED_RED] + }, + /* CONFIG_LED_GREEN */ + /* LaunchPad LED Green */ + { + .object = &LEDObjects[CONFIG_LED_GREEN], + .hwAttrs = &LEDHWAttrs[CONFIG_LED_GREEN] + }, +}; + +const uint_least8_t CONFIG_LED_RED_CONST = CONFIG_LED_RED; +const uint_least8_t CONFIG_LED_GREEN_CONST = CONFIG_LED_GREEN; +const uint_least8_t LED_count = CONFIG_LED_COUNT; + +#include + +#include +#include + +#include + +/* + * ======== Board_sendExtFlashByte ======== + */ +void Board_sendExtFlashByte(PIN_Handle pinHandle, uint8_t byte) +{ + uint8_t i; + + /* SPI Flash CS */ + PIN_setOutputValue(pinHandle, IOID_20, 0); + + for (i = 0; i < 8; i++) { + PIN_setOutputValue(pinHandle, IOID_10, 0); /* SPI Flash CLK */ + + /* SPI Flash MOSI */ + PIN_setOutputValue(pinHandle, IOID_9, (byte >> (7 - i)) & 0x01); + PIN_setOutputValue(pinHandle, IOID_10, 1); /* SPI Flash CLK */ + + /* + * Waste a few cycles to keep the CLK high for at + * least 45% of the period. + * 3 cycles per loop: 8 loops @ 48 Mhz = 0.5 us. + */ + CPUdelay(8); + } + + PIN_setOutputValue(pinHandle, IOID_10, 0); /* CLK */ + PIN_setOutputValue(pinHandle, IOID_20, 1); /* CS */ + + /* + * Keep CS high at least 40 us + * 3 cycles per loop: 700 loops @ 48 Mhz ~= 44 us + */ + CPUdelay(700); +} + +/* + * ======== Board_wakeUpExtFlash ======== + */ +void Board_wakeUpExtFlash(void) +{ + PIN_Config extFlashPinTable[] = { + /* SPI Flash CS */ + IOID_20 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | + PIN_INPUT_DIS | PIN_DRVSTR_MED, + PIN_TERMINATE + }; + PIN_State extFlashPinState; + PIN_Handle extFlashPinHandle = PIN_open(&extFlashPinState, extFlashPinTable); + + /* + * To wake up we need to toggle the chip select at + * least 20 ns and ten wait at least 35 us. + */ + + /* Toggle chip select for ~20ns to wake ext. flash */ + PIN_setOutputValue(extFlashPinHandle, IOID_20, 0); + /* 3 cycles per loop: 1 loop @ 48 Mhz ~= 62 ns */ + CPUdelay(1); + PIN_setOutputValue(extFlashPinHandle, IOID_20, 1); + /* 3 cycles per loop: 560 loops @ 48 Mhz ~= 35 us */ + CPUdelay(560); + + PIN_close(extFlashPinHandle); +} + +/* + * ======== Board_shutDownExtFlash ======== + */ +void Board_shutDownExtFlash(void) +{ + /* + * To be sure we are putting the flash into sleep and not waking it, + * we first have to make a wake up call + */ + Board_wakeUpExtFlash(); + + PIN_Config extFlashPinTable[] = { + /* SPI Flash CS*/ + IOID_20 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | + PIN_INPUT_DIS | PIN_DRVSTR_MED, + /* SPI Flash CLK */ + IOID_10 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | + PIN_INPUT_DIS | PIN_DRVSTR_MED, + /* SPI Flash MOSI */ + IOID_9 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | + PIN_INPUT_DIS | PIN_DRVSTR_MED, + /* SPI Flash MISO */ + IOID_8 | PIN_INPUT_EN | PIN_PULLDOWN, + PIN_TERMINATE + }; + PIN_State extFlashPinState; + PIN_Handle extFlashPinHandle = PIN_open(&extFlashPinState, extFlashPinTable); + + uint8_t extFlashShutdown = 0xB9; + + Board_sendExtFlashByte(extFlashPinHandle, extFlashShutdown); + + PIN_close(extFlashPinHandle); +} + + +#include + +/* + * ======== Board_initHook ======== + * Perform any board-specific initialization needed at startup. This + * function is declared weak to allow applications to override it if needed. + */ +void __attribute__((weak)) Board_initHook(void) +{ +} + +/* + * ======== Board_init ======== + * Perform any initialization needed before using any board APIs + */ +void Board_init(void) +{ + /* ==== /ti/drivers/Power initialization ==== */ + Power_init(); + + /* ==== /ti/devices/CCFGTemplate initialization ==== */ + + /* ==== /ti/drivers/PIN initialization ==== */ + if (PIN_init(BoardGpioInitTable) != PIN_SUCCESS) { + /* Error with PIN_init */ + while (1); + } + /* ==== /ti/drivers/RF initialization ==== */ + + + Board_shutDownExtFlash(); + + Board_initHook(); +} + diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_drivers_config.h b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_drivers_config.h new file mode 100644 index 0000000..abf128f --- /dev/null +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_drivers_config.h @@ -0,0 +1,283 @@ +/* + * ======== ti_drivers_config.h ======== + * Configured TI-Drivers module declarations + * + * The macros defines herein are intended for use by applications which + * directly include this header. These macros should NOT be hard coded or + * copied into library source code. + * + * Symbols declared as const are intended for use with libraries. + * Library source code must extern the correct symbol--which is resolved + * when the application is linked. + * + * DO NOT EDIT - This file is generated for the CC1352P_2_LAUNCHXL + * by the SysConfig tool. + */ +#ifndef ti_drivers_config_h +#define ti_drivers_config_h + +#define CONFIG_SYSCONFIG_PREVIEW + +#define CONFIG_CC1352P_2_LAUNCHXL +#ifndef DeviceFamily_CC13X2 +#define DeviceFamily_CC13X2 +#endif + +#include + +#include + +/* support C++ sources */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * ======== CCFG ======== + */ + + +/* + * ======== AESCBC ======== + */ + +extern const uint_least8_t CONFIG_AESCBC_0_CONST; +#define CONFIG_AESCBC_0 0 +#define CONFIG_TI_DRIVERS_AESCBC_COUNT 1 + + +/* + * ======== AESCCM ======== + */ + +extern const uint_least8_t CONFIG_AESCCM_0_CONST; +#define CONFIG_AESCCM_0 0 +#define CONFIG_TI_DRIVERS_AESCCM_COUNT 1 + + +/* + * ======== AESECB ======== + */ + +extern const uint_least8_t CONFIG_AESECB_0_CONST; +#define CONFIG_AESECB_0 0 +#define CONFIG_TI_DRIVERS_AESECB_COUNT 1 + + +/* + * ======== ECDH ======== + */ + +extern const uint_least8_t CONFIG_ECDH_0_CONST; +#define CONFIG_ECDH_0 0 +#define CONFIG_TI_DRIVERS_ECDH_COUNT 1 + + +/* + * ======== ECDSA ======== + */ + +extern const uint_least8_t CONFIG_ECDSA_0_CONST; +#define CONFIG_ECDSA_0 0 +#define CONFIG_TI_DRIVERS_ECDSA_COUNT 1 + + +/* + * ======== ECJPAKE ======== + */ + +extern const uint_least8_t CONFIG_ECJPAKE_0_CONST; +#define CONFIG_ECJPAKE_0 0 +#define CONFIG_TI_DRIVERS_ECJPAKE_COUNT 1 + + +/* + * ======== GPIO ======== + */ + +/* DIO15, LaunchPad Button BTN-1 (Left) */ +extern const uint_least8_t CONFIG_GPIO_BTN1_CONST; +#define CONFIG_GPIO_BTN1 0 +/* DIO14, LaunchPad Button BTN-2 (Right) */ +extern const uint_least8_t CONFIG_GPIO_BTN2_CONST; +#define CONFIG_GPIO_BTN2 1 +/* DIO6, LaunchPad LED Red */ +extern const uint_least8_t CONFIG_GPIO_RLED_CONST; +#define CONFIG_GPIO_RLED 2 +/* DIO7, LaunchPad LED Green */ +extern const uint_least8_t CONFIG_GPIO_GLED_CONST; +#define CONFIG_GPIO_GLED 3 +/* DIO20, MX25R8035F SPI Flash Slave Select */ +extern const uint_least8_t CONFIG_GPIO_0_CONST; +#define CONFIG_GPIO_0 4 +#define CONFIG_TI_DRIVERS_GPIO_COUNT 5 + +/* LEDs are active high */ +#define CONFIG_GPIO_LED_ON (1) +#define CONFIG_GPIO_LED_OFF (0) + +#define CONFIG_LED_ON (CONFIG_GPIO_LED_ON) +#define CONFIG_LED_OFF (CONFIG_GPIO_LED_OFF) + + +/* + * ======== NVS ======== + */ + +extern const uint_least8_t CONFIG_NVSINTERNAL_CONST; +#define CONFIG_NVSINTERNAL 0 +/* + * MOSI: DIO9 + * MISO: DIO8 + * SCLK: DIO10 + * LaunchPad SPI Bus + * SS: DIO20, MX25R8035F SPI Flash Slave Select + */ +extern const uint_least8_t CONFIG_NVSEXTERNAL_CONST; +#define CONFIG_NVSEXTERNAL 1 +#define CONFIG_TI_DRIVERS_NVS_COUNT 2 + + +/* + * ======== PIN ======== + */ +#include + +extern const PIN_Config BoardGpioInitTable[]; + +/* XDS110 UART, Parent Signal: CONFIG_DISPLAY_UART TX, (DIO13) */ +#define CONFIG_PIN_UART_TX 0x0000000d +/* XDS110 UART, Parent Signal: CONFIG_DISPLAY_UART RX, (DIO12) */ +#define CONFIG_PIN_UART_RX 0x0000000c +/* SKY13317-373LF RF Antenna Switch, Parent Signal: /ti/drivers/RF RF Antenna Pin 0, (DIO28) */ +// #define CONFIG_RF_24GHZ 0x0000001c +/* SKY13317-373LF RF Antenna Switch, Parent Signal: /ti/drivers/RF RF Antenna Pin 1, (DIO29) */ +// #define CONFIG_RF_HIGH_PA 0x0000001d +/* SKY13317-373LF RF Antenna Switch, Parent Signal: /ti/drivers/RF RF Antenna Pin 2, (DIO30) */ +#define CONFIG_RF_SUB1GHZ 0x0000001e +/* LaunchPad Button BTN-1 (Left), Parent Signal: CONFIG_GPIO_BTN1 GPIO Pin, (DIO15) */ +#define CONFIG_PIN_BTN1 0x0000000f +/* LaunchPad Button BTN-2 (Right), Parent Signal: CONFIG_GPIO_BTN2 GPIO Pin, (DIO14) */ +#define CONFIG_PIN_BTN2 0x0000000e +/* LaunchPad LED Red, Parent Signal: CONFIG_GPIO_RLED GPIO Pin, (DIO6) */ +#define CONFIG_PIN_RLED 0x00000006 +/* LaunchPad LED Green, Parent Signal: CONFIG_GPIO_GLED GPIO Pin, (DIO7) */ +#define CONFIG_PIN_GLED 0x00000007 +/* MX25R8035F SPI Flash Slave Select, Parent Signal: CONFIG_GPIO_0 GPIO Pin, (DIO20) */ +#define CONFIG_PIN_0 0x00000014 +/* LaunchPad SPI Bus, Parent Signal: CONFIG_SPI_0 SCLK, (DIO10) */ +#define CONFIG_PIN_SPI_SCLK 0x0000000a +/* LaunchPad SPI Bus, Parent Signal: CONFIG_SPI_0 MISO, (DIO8) */ +#define CONFIG_PIN_SPI_MISO 0x00000008 +/* LaunchPad SPI Bus, Parent Signal: CONFIG_SPI_0 MOSI, (DIO9) */ +#define CONFIG_PIN_SPI_MOSI 0x00000009 +#define CONFIG_TI_DRIVERS_PIN_COUNT 13 + + +/* + * ======== RF ======== + */ +#define Board_DIO_30_RFSW 0x0000001e + + +/* + * ======== SHA2 ======== + */ + +extern const uint_least8_t CONFIG_SHA2_0_CONST; +#define CONFIG_SHA2_0 0 +#define CONFIG_TI_DRIVERS_SHA2_COUNT 1 + + +/* + * ======== SPI ======== + */ + +/* + * MOSI: DIO9 + * MISO: DIO8 + * SCLK: DIO10 + * LaunchPad SPI Bus + */ +extern const uint_least8_t CONFIG_SPI_0_CONST; +#define CONFIG_SPI_0 0 +#define CONFIG_TI_DRIVERS_SPI_COUNT 1 + + +/* + * ======== TRNG ======== + */ + +extern const uint_least8_t CONFIG_TRNG_0_CONST; +#define CONFIG_TRNG_0 0 +#define CONFIG_TI_DRIVERS_TRNG_COUNT 1 + + +/* + * ======== UART ======== + */ + +/* + * TX: DIO13 + * RX: DIO12 + * XDS110 UART + */ +extern const uint_least8_t CONFIG_DISPLAY_UART_CONST; +#define CONFIG_DISPLAY_UART 0 +#define CONFIG_TI_DRIVERS_UART_COUNT 1 + + +/* + * ======== Button ======== + */ + +/* DIO15, LaunchPad Button BTN-1 (Left) */ +extern const uint_least8_t CONFIG_BTN_LEFT_CONST; +#define CONFIG_BTN_LEFT 0 +/* DIO14, LaunchPad Button BTN-2 (Right) */ +extern const uint_least8_t CONFIG_BTN_RIGHT_CONST; +#define CONFIG_BTN_RIGHT 1 +#define CONFIG_TI_DRIVERS_BUTTON_COUNT 2 + + +/* + * ======== LED ======== + */ + +/* DIO6, LaunchPad LED Red */ +extern const uint_least8_t CONFIG_LED_RED_CONST; +#define CONFIG_LED_RED 0 +/* DIO7, LaunchPad LED Green */ +extern const uint_least8_t CONFIG_LED_GREEN_CONST; +#define CONFIG_LED_GREEN 1 +#define CONFIG_TI_DRIVERS_LED_COUNT 2 + + +/* + * ======== Board_init ======== + * Perform all required TI-Drivers initialization + * + * This function should be called once at a point before any use of + * TI-Drivers. + */ +extern void Board_init(void); + +/* + * ======== Board_initGeneral ======== + * (deprecated) + * + * Board_initGeneral() is defined purely for backward compatibility. + * + * All new code should use Board_init() to do any required TI-Drivers + * initialization _and_ use _init() for only where specific drivers + * are explicitly referenced by the application. _init() functions + * are idempotent. + */ +#define Board_initGeneral Board_init + +#ifdef __cplusplus +} +#endif + +#endif /* include guard */ diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_radio_config.c b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_radio_config.c new file mode 100644 index 0000000..e40350d --- /dev/null +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_radio_config.c @@ -0,0 +1,340 @@ +/* + * ======== ti_radio_config.c ======== + * Configured RadioConfig module definitions + * + * DO NOT EDIT - This file is generated for the CC1352P1F3RGZ + * by the SysConfig tool. + * + * Radio Config module version : 1.9 + * SmartRF Studio data version : 2.21.0 + */ + +#include +#include DeviceFamily_constructPath(driverlib/rf_mailbox.h) +#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) +#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h) +#include +#include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_ieee_802_15_4.h) +#include "ti_radio_config.h" + + +// ********************************************************************************* +// RF Frontend configuration +// ********************************************************************************* +// RF design based on: LAUNCHXL-CC1352P-2 (CC1352PEM-XD4251-XD24-PA24_10dBm) + +// TX Power tables +// The RF_TxPowerTable_DEFAULT_PA_ENTRY and RF_TxPowerTable_HIGH_PA_ENTRY macros are defined in RF.h. +// The following arguments are required: +// RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost, coefficient) +// RF_TxPowerTable_HIGH_PA_ENTRY(bias, ibboost, boost, coefficient, ldoTrim) +// See the Technical Reference Manual for further details about the "txPower" Command field. +// The PA settings require the CCFG_FORCE_VDDR_HH = 0 unless stated otherwise. + +// 868 MHz, 13 dBm +RF_TxPowerTable_Entry txPowerTable_868_pa13[TXPOWERTABLE_868_PA13_SIZE] = +{ + {-20, RF_TxPowerTable_DEFAULT_PA_ENTRY(0, 3, 0, 2) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(1, 3, 0, 3) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(2, 3, 0, 5) }, + {-5, RF_TxPowerTable_DEFAULT_PA_ENTRY(4, 3, 0, 5) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 0, 8) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(9, 3, 0, 9) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 9) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(11, 3, 0, 10) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(13, 3, 0, 11) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(14, 3, 0, 14) }, + {6, RF_TxPowerTable_DEFAULT_PA_ENTRY(17, 3, 0, 16) }, + {7, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 3, 0, 19) }, + {8, RF_TxPowerTable_DEFAULT_PA_ENTRY(24, 3, 0, 22) }, + {9, RF_TxPowerTable_DEFAULT_PA_ENTRY(28, 3, 0, 31) }, + {10, RF_TxPowerTable_DEFAULT_PA_ENTRY(18, 2, 0, 31) }, + {11, RF_TxPowerTable_DEFAULT_PA_ENTRY(26, 2, 0, 51) }, + {12, RF_TxPowerTable_DEFAULT_PA_ENTRY(16, 0, 0, 82) }, + // The original PA value (12.5 dBm) has been rounded to an integer value. + {13, RF_TxPowerTable_DEFAULT_PA_ENTRY(36, 0, 0, 89) }, + // This setting requires CCFG_FORCE_VDDR_HH = 1. + {14, RF_TxPowerTable_DEFAULT_PA_ENTRY(63, 0, 1, 0) }, + RF_TxPowerTable_TERMINATION_ENTRY +}; + + +// 2400 MHz, 5 dBm +RF_TxPowerTable_Entry txPowerTable_2400_pa5[TXPOWERTABLE_2400_PA5_SIZE] = +{ + {-20, RF_TxPowerTable_DEFAULT_PA_ENTRY(6, 3, 0, 2) }, + {-18, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 0, 3) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 3) }, + {-12, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 3, 0, 5) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(15, 3, 0, 5) }, + {-9, RF_TxPowerTable_DEFAULT_PA_ENTRY(16, 3, 0, 5) }, + {-6, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 3, 0, 8) }, + {-5, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 3, 0, 9) }, + {-3, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 2, 0, 12) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 1, 0, 20) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 1, 0, 20) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 25) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(29, 1, 0, 28) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(35, 1, 0, 39) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(23, 0, 0, 57) }, + RF_TxPowerTable_TERMINATION_ENTRY +}; + +// 2400 MHz, 5 + 20 dBm +RF_TxPowerTable_Entry txPowerTable_2400_pa5_20[TXPOWERTABLE_2400_PA5_20_SIZE] = +{ + {-20, RF_TxPowerTable_DEFAULT_PA_ENTRY(6, 3, 0, 2) }, + {-18, RF_TxPowerTable_DEFAULT_PA_ENTRY(8, 3, 0, 3) }, + {-15, RF_TxPowerTable_DEFAULT_PA_ENTRY(10, 3, 0, 3) }, + {-12, RF_TxPowerTable_DEFAULT_PA_ENTRY(12, 3, 0, 5) }, + {-10, RF_TxPowerTable_DEFAULT_PA_ENTRY(15, 3, 0, 5) }, + {-9, RF_TxPowerTable_DEFAULT_PA_ENTRY(16, 3, 0, 5) }, + {-6, RF_TxPowerTable_DEFAULT_PA_ENTRY(20, 3, 0, 8) }, + {-5, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 3, 0, 9) }, + {-3, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 2, 0, 12) }, + {0, RF_TxPowerTable_DEFAULT_PA_ENTRY(19, 1, 0, 20) }, + {1, RF_TxPowerTable_DEFAULT_PA_ENTRY(22, 1, 0, 20) }, + {2, RF_TxPowerTable_DEFAULT_PA_ENTRY(25, 1, 0, 25) }, + {3, RF_TxPowerTable_DEFAULT_PA_ENTRY(29, 1, 0, 28) }, + {4, RF_TxPowerTable_DEFAULT_PA_ENTRY(35, 1, 0, 39) }, + {5, RF_TxPowerTable_DEFAULT_PA_ENTRY(23, 0, 0, 57) }, + {14, RF_TxPowerTable_HIGH_PA_ENTRY(22, 3, 1, 19, 27) }, + {15, RF_TxPowerTable_HIGH_PA_ENTRY(26, 3, 1, 23, 27) }, + {16, RF_TxPowerTable_HIGH_PA_ENTRY(30, 3, 1, 28, 27) }, + {17, RF_TxPowerTable_HIGH_PA_ENTRY(37, 3, 1, 39, 27) }, + {18, RF_TxPowerTable_HIGH_PA_ENTRY(32, 3, 1, 35, 48) }, + {19, RF_TxPowerTable_HIGH_PA_ENTRY(34, 3, 1, 48, 63) }, + {20, RF_TxPowerTable_HIGH_PA_ENTRY(53, 3, 1, 58, 63) }, + RF_TxPowerTable_TERMINATION_ENTRY +}; + + + +//********************************************************************************* +// RF Setting: IEEE 802.15.4-2006, 250 kbps, OQPSK, DSSS = 1:8 +// +// PHY: ieee154 +// Setting file: setting_ieee_802_15_4.json +//********************************************************************************* + +// PARAMETER SUMMARY +// Channel - Frequency (MHz): 2405 +// TX Power (dBm): 5 + +// TI-RTOS RF Mode Object +RF_Mode RF_prop_ieee154 = +{ + .rfMode = RF_MODE_AUTO, + .cpePatchFxn = &rf_patch_cpe_ieee_802_15_4, + .mcePatchFxn = 0, + .rfePatchFxn = 0 +}; + +// Overrides for CMD_RADIO_SETUP_PA +uint32_t pOverrides_ieee154[] = +{ + // override_ieee_802_15_4.json + // Rx: Set LNA bias current offset to +15 to saturate trim to max (default: 0) + (uint32_t)0x000F8883, + // Tx: Set DCDC settings IPEAK=3, dither = off + (uint32_t)0x00F388D3, + (uint32_t)0xFFFFFFFF +}; + + + +// CMD_RADIO_SETUP_PA +// Radio Setup Command for Pre-Defined Schemes +const rfc_CMD_RADIO_SETUP_PA_t RF_cmdRadioSetup_ieee154 = +{ + .commandNo = 0x0802, + .status = 0x0000, + .pNextOp = 0, + .startTime = 0x00000000, + .startTrigger.triggerType = 0x0, + .startTrigger.bEnaCmd = 0x0, + .startTrigger.triggerNo = 0x0, + .startTrigger.pastTrig = 0x0, + .condition.rule = 0x1, + .condition.nSkip = 0x0, + .mode = 0x01, + .loDivider = 0x00, + .config.frontEndMode = 0x0, + .config.biasMode = 0x1, + .config.analogCfgMode = 0x0, + .config.bNoFsPowerUp = 0x0, + .txPower = 0x7217, + .pRegOverride = pOverrides_ieee154, + .pRegOverrideTxStd = 0, + .pRegOverrideTx20 = 0 +}; + +// CMD_FS +// Frequency Synthesizer Programming Command +const rfc_CMD_FS_t RF_cmdFs_ieee154 = +{ + .commandNo = 0x0803, + .status = 0x0000, + .pNextOp = 0, + .startTime = 0x00000000, + .startTrigger.triggerType = 0x0, + .startTrigger.bEnaCmd = 0x0, + .startTrigger.triggerNo = 0x0, + .startTrigger.pastTrig = 0x0, + .condition.rule = 0x1, + .condition.nSkip = 0x0, + .frequency = 0x0965, + .fractFreq = 0x0000, + .synthConf.bTxMode = 0x0, + .synthConf.refFreq = 0x0, + .__dummy0 = 0x00, + .__dummy1 = 0x00, + .__dummy2 = 0x00, + .__dummy3 = 0x0000 +}; + +// CMD_IEEE_TX +// IEEE 802.15.4 Transmit Command +const rfc_CMD_IEEE_TX_t RF_cmdIeeeTx_ieee154 = +{ + .commandNo = 0x2C01, + .status = 0x0000, + .pNextOp = 0, + .startTime = 0x00000000, + .startTrigger.triggerType = 0x0, + .startTrigger.bEnaCmd = 0x0, + .startTrigger.triggerNo = 0x0, + .startTrigger.pastTrig = 0x0, + .condition.rule = 0x1, + .condition.nSkip = 0x0, + .txOpt.bIncludePhyHdr = 0x0, + .txOpt.bIncludeCrc = 0x0, + .txOpt.payloadLenMsb = 0x0, + .payloadLen = 0x1E, + .pPayload = 0, + .timeStamp = 0x00000000 +}; + +// CMD_IEEE_RX +// IEEE 802.15.4 Receive Command +const rfc_CMD_IEEE_RX_t RF_cmdIeeeRx_ieee154 = +{ + .commandNo = 0x2801, + .status = 0x0000, + .pNextOp = 0, + .startTime = 0x00000000, + .startTrigger.triggerType = 0x0, + .startTrigger.bEnaCmd = 0x0, + .startTrigger.triggerNo = 0x0, + .startTrigger.pastTrig = 0x0, + .condition.rule = 0x1, + .condition.nSkip = 0x0, + .channel = 0x00, + .rxConfig.bAutoFlushCrc = 0x0, + .rxConfig.bAutoFlushIgn = 0x0, + .rxConfig.bIncludePhyHdr = 0x0, + .rxConfig.bIncludeCrc = 0x0, + .rxConfig.bAppendRssi = 0x1, + .rxConfig.bAppendCorrCrc = 0x1, + .rxConfig.bAppendSrcInd = 0x0, + .rxConfig.bAppendTimestamp = 0x0, + .pRxQ = 0, + .pOutput = 0, + .frameFiltOpt.frameFiltEn = 0x0, + .frameFiltOpt.frameFiltStop = 0x0, + .frameFiltOpt.autoAckEn = 0x0, + .frameFiltOpt.slottedAckEn = 0x0, + .frameFiltOpt.autoPendEn = 0x0, + .frameFiltOpt.defaultPend = 0x0, + .frameFiltOpt.bPendDataReqOnly = 0x0, + .frameFiltOpt.bPanCoord = 0x0, + .frameFiltOpt.maxFrameVersion = 0x3, + .frameFiltOpt.fcfReservedMask = 0x0, + .frameFiltOpt.modifyFtFilter = 0x0, + .frameFiltOpt.bStrictLenFilter = 0x0, + .frameTypes.bAcceptFt0Beacon = 0x1, + .frameTypes.bAcceptFt1Data = 0x1, + .frameTypes.bAcceptFt2Ack = 0x1, + .frameTypes.bAcceptFt3MacCmd = 0x1, + .frameTypes.bAcceptFt4Reserved = 0x1, + .frameTypes.bAcceptFt5Reserved = 0x1, + .frameTypes.bAcceptFt6Reserved = 0x1, + .frameTypes.bAcceptFt7Reserved = 0x1, + .ccaOpt.ccaEnEnergy = 0x0, + .ccaOpt.ccaEnCorr = 0x0, + .ccaOpt.ccaEnSync = 0x0, + .ccaOpt.ccaCorrOp = 0x1, + .ccaOpt.ccaSyncOp = 0x1, + .ccaOpt.ccaCorrThr = 0x0, + .ccaRssiThr = 0x64, + .__dummy0 = 0x00, + .numExtEntries = 0x00, + .numShortEntries = 0x00, + .pExtEntryList = 0, + .pShortEntryList = 0, + .localExtAddr = 0x12345678, + .localShortAddr = 0xABBA, + .localPanID = 0x0000, + .__dummy1 = 0x000000, + .endTrigger.triggerType = 0x1, + .endTrigger.bEnaCmd = 0x0, + .endTrigger.triggerNo = 0x0, + .endTrigger.pastTrig = 0x0, + .endTime = 0x00000000 +}; + +// CMD_IEEE_CSMA +// IEEE 802.15.4 CSMA-CA Command +const rfc_CMD_IEEE_CSMA_t RF_cmdIeeeCsma_ieee154 = +{ + .commandNo = 0x2C02, + .status = 0x0000, + .pNextOp = 0, + .startTime = 0x00000000, + .startTrigger.triggerType = 0x0, + .startTrigger.bEnaCmd = 0x0, + .startTrigger.triggerNo = 0x0, + .startTrigger.pastTrig = 0x0, + .condition.rule = 0x0, + .condition.nSkip = 0x0, + .randomState = 0x0000, + .macMaxBE = 0x00, + .macMaxCSMABackoffs = 0x00, + .csmaConfig.initCW = 0x0, + .csmaConfig.bSlotted = 0x0, + .csmaConfig.rxOffMode = 0x0, + .NB = 0x00, + .BE = 0x00, + .remainingPeriods = 0x00, + .lastRssi = 0x00, + .endTrigger.triggerType = 0x0, + .endTrigger.bEnaCmd = 0x0, + .endTrigger.triggerNo = 0x0, + .endTrigger.pastTrig = 0x0, + .lastTimeStamp = 0x00000000, + .endTime = 0x00000000 +}; + +// CMD_IEEE_RX_ACK +// IEEE 802.15.4 Receive Acknowledgement Command +const rfc_CMD_IEEE_RX_ACK_t RF_cmdIeeeRxAck_ieee154 = +{ + .commandNo = 0x2C03, + .status = 0x0000, + .pNextOp = 0, + .startTime = 0x00000000, + .startTrigger.triggerType = 0x0, + .startTrigger.bEnaCmd = 0x0, + .startTrigger.triggerNo = 0x0, + .startTrigger.pastTrig = 0x0, + .condition.rule = 0x0, + .condition.nSkip = 0x0, + .seqNo = 0x00, + .endTrigger.triggerType = 0x0, + .endTrigger.bEnaCmd = 0x0, + .endTrigger.triggerNo = 0x0, + .endTrigger.pastTrig = 0x0, + .endTime = 0x00000000 +}; + + diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_radio_config.h b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_radio_config.h new file mode 100644 index 0000000..2477c99 --- /dev/null +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_radio_config.h @@ -0,0 +1,77 @@ +/* + * ======== ti_radio_config.h ======== + * Configured RadioConfig module definitions + * + * DO NOT EDIT - This file is generated for the CC1352P1F3RGZ + * by the SysConfig tool. + * + * Radio Config module version : 1.9 + * SmartRF Studio data version : 2.21.0 + */ +#ifndef _TI_RADIO_CONFIG_H_ +#define _TI_RADIO_CONFIG_H_ + +#include +#include DeviceFamily_constructPath(driverlib/rf_mailbox.h) +#include DeviceFamily_constructPath(driverlib/rf_common_cmd.h) +#include DeviceFamily_constructPath(driverlib/rf_ieee_cmd.h) +#include + +// ********************************************************************************* +// RF Frontend configuration +// ********************************************************************************* +// RF design based on: LAUNCHXL-CC1352P-2 (CC1352PEM-XD4251-XD24-PA24_10dBm) +#define LAUNCHXL_CC1352P_2 + +// High-Power Amplifier supported +#define SUPPORT_HIGH_PA + +// RF frontend configuration +#define FRONTEND_SUB1G_DIFF_RF +#define FRONTEND_SUB1G_EXT_BIAS +#define FRONTEND_24G_DIFF_RF +#define FRONTEND_24G_EXT_BIAS + +// Supported frequency bands +#define SUPPORT_FREQBAND_868 +#define SUPPORT_FREQBAND_2400 + +// TX power table size definitions +#define TXPOWERTABLE_868_PA13_SIZE 20 // 868 MHz, 13 dBm +#define TXPOWERTABLE_2400_PA5_SIZE 16 // 2400 MHz, 5 dBm +#define TXPOWERTABLE_2400_PA5_20_SIZE 23 // 2400 MHz, 5 + 20 dBm + +// TX power tables +extern RF_TxPowerTable_Entry txPowerTable_868_pa13[]; // 868 MHz, 13 dBm +extern RF_TxPowerTable_Entry txPowerTable_2400_pa5[]; // 2400 MHz, 5 dBm +extern RF_TxPowerTable_Entry txPowerTable_2400_pa5_20[]; // 2400 MHz, 5 + 20 dBm + + + +//********************************************************************************* +// RF Setting: IEEE 802.15.4-2006, 250 kbps, OQPSK, DSSS = 1:8 +// +// PHY: ieee154 +// Setting file: setting_ieee_802_15_4.json +//********************************************************************************* + +// PA table usage +#define TX_POWER_TABLE_SIZE_ieee154 TXPOWERTABLE_2400_PA5_SIZE + +#define txPowerTable_ieee154 txPowerTable_2400_pa5 + +// TI-RTOS RF Mode object +extern RF_Mode RF_prop_ieee154; + +// RF Core API commands +extern const rfc_CMD_RADIO_SETUP_PA_t RF_cmdRadioSetup_ieee154; +extern const rfc_CMD_FS_t RF_cmdFs_ieee154; +extern const rfc_CMD_IEEE_TX_t RF_cmdIeeeTx_ieee154; +extern const rfc_CMD_IEEE_RX_t RF_cmdIeeeRx_ieee154; +extern const rfc_CMD_IEEE_CSMA_t RF_cmdIeeeCsma_ieee154; +extern const rfc_CMD_IEEE_RX_ACK_t RF_cmdIeeeRxAck_ieee154; + +// RF Core API overrides +extern uint32_t pOverrides_ieee154[]; + +#endif // _TI_RADIO_CONFIG_H_ diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_utils_build_linker.cmd.genlibs b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_utils_build_linker.cmd.genlibs new file mode 100644 index 0000000..fa697e6 --- /dev/null +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_utils_build_linker.cmd.genlibs @@ -0,0 +1,35 @@ +/* + * ======== ti_utils_build_linker.cmd.genlibs ======== + * Libraries needed to link this application's configuration + * + * NOTE, this feature requires software components configured in your + * system to correctly indicate their dependencies and report the + * libraries needed for your specific configuration. If you find + * errors, please report them on TI's E2E forums + * (https://e2e.ti.com/) so they can be addressed in a future + * release. + * + * This file allows one to portably link applications that use SysConfig + * _without_ having to make changes to build rules when moving to a new + * device OR when upgrading to a new version of a SysConfig enabled + * product. + * + * DO NOT EDIT - This file is generated by the SysConfig tool for the + * TI C/C++ toolchain + */ + +/* libraries required for /third_party/spiffs */ +-l"third_party/spiffs/lib/ccs/m4f/spiffs.a" + +/* libraries required for /ti/drivers/RF */ +-l"ti/drivers/rf/lib/rf_multiMode_cc13x2.aem4f" + +/* libraries required for /ti/drivers */ +-l"ti/drivers/lib/ccs/m4f/drivers_cc13x2.a" +-l"ti/grlib/lib/ccs/m4f/grlib.a" +-l"ti/dpl/lib/ccs/m4f/dpl_cc13x2.a" + +/* libraries required for /ti/zstack */ +-l"ti/ti154stack/library/tirtos/ccs/bin/maclib_nosecure_cc13x2_2_4g.a" +-l"ti/zstack/lib/ccs/libZStack_nwk_all_ccs.a" + diff --git a/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_zstack_config.h b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_zstack_config.h new file mode 100644 index 0000000..69447c1 --- /dev/null +++ b/znp_CC1352P_2_LAUNCHXL_tirtos_ccs/syscfg/ti_zstack_config.h @@ -0,0 +1,226 @@ +/* + * Copyright (c) 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. + * + */ + +/* + * ti_zstack_config.h + * + * DO NOT EDIT - This file was generated by the SysConfig tool. + * + * Macros used to define a TI Z-Stack ZigBee device. New user defined + * options may be added to this file, as necessary. + * + */ + +#ifndef TI_ZSTACK_CONFIG_H +#define TI_ZSTACK_CONFIG_H + +/* Default (primary) and secondary channel masks. Secondary mask is used when the + * default channels fail. + * Channels are defined in the following: + * 11 - 26 : 2.4 GHz 0x07FFF800 + */ +#ifndef DEFAULT_CHANLIST +#define DEFAULT_CHANLIST 0x00000800 +#endif + +#ifndef SECONDARY_CHANLIST +#define SECONDARY_CHANLIST 0x00000000 +#endif + +/* Define the default PAN ID. + * + * Setting this to a value other than 0xFFFF causes + * ZDO_COORD to use this value as its PAN ID and + * Routers and end devices to join PAN with this ID + */ +#ifndef ZDAPP_CONFIG_PAN_ID +#define ZDAPP_CONFIG_PAN_ID 0xFFFF +#endif + +/* Specifiy whether to set the EPID to the Extended Address, or to use the + * custom Extended Pan ID (EPID) defined by ZDAPP_CONFIG_EPID + */ +#ifndef SET_EPID_AS_EXT_ADDR +#define SET_EPID_AS_EXT_ADDR TRUE +#endif + +/* Define the default Extended Pan ID (EPID) + * ZDAPP_CONFIG_EPID is only used if SET_EPID_AS_EXT_ADDR is FALSE. Otherwise, + * the EPID is set to the Extended Address. + */ +#ifndef ZDAPP_CONFIG_EPID +#define ZDAPP_CONFIG_EPID {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF} +#endif + +/* in seconds; set to 255 to turn off route expiry */ +#ifndef ROUTE_EXPIRY_TIME +#define ROUTE_EXPIRY_TIME 30 +#endif + +/* Default indirect message holding timeout value: + * 1-65535 (0 -> 65536) X CNT_RTG_TIMER X RTG_TIMER_INTERVAL + */ +#ifndef NWK_INDIRECT_MSG_TIMEOUT +#define NWK_INDIRECT_MSG_TIMEOUT 7 +#endif + +/* The number of simultaneous route discoveries in network */ +#ifndef MAX_RREQ_ENTRIES +#define MAX_RREQ_ENTRIES 8 +#endif + +/* The maximum number of MAC frame transmission attempts allowed */ +#ifndef ZMAC_MAX_FRAME_RETRIES +#define ZMAC_MAX_FRAME_RETRIES 3 +#endif + +/* Max number of times attempts looking for the next hop address of a message */ +#ifndef NWK_MAX_DATA_RETRIES +#define NWK_MAX_DATA_RETRIES 2 +#endif + +/* The maximum number of times APS frames are retried after not receiving an APS ACK */ +#ifndef APSC_MAX_FRAME_RETRIES +#define APSC_MAX_FRAME_RETRIES 3 +#endif + +/* This number is used by polled devices, since the spec'd formula + * doesn't work for sleeping end devices. For non-polled devices, + * a formula is used. Value is in 2 milliseconds periods + */ +#ifndef APSC_ACK_WAIT_DURATION_POLLED +#define APSC_ACK_WAIT_DURATION_POLLED 3000 +#endif + +/* The maximum number of groups in the groups table */ +#ifndef APS_MAX_GROUPS +#define APS_MAX_GROUPS 16 +#endif + +/* Number of entries in the regular routing table plus additional + * entries for route repair + */ +#ifndef MAX_RTG_ENTRIES +#define MAX_RTG_ENTRIES 40 +#endif + +/* Maximum number of entries in the Binding table. */ +#ifndef NWK_MAX_BINDING_ENTRIES +#define NWK_MAX_BINDING_ENTRIES 4 +#endif + +/* Default security key. */ +#ifndef DEFAULT_KEY +#define DEFAULT_KEY {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} +#endif + +/* ZigBee Alliance Pre-configured Distributed Link Key (for Distributed networks) */ +#ifndef DISTRIBUTED_GLOBAL_LINK_KEY +#define DISTRIBUTED_GLOBAL_LINK_KEY {0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} +#endif + +/* ZigBee Alliance Pre-configured TC Link Key - 'ZigBeeAlliance09' (for Centralized networks) */ +#ifndef DEFAULT_TC_LINK_KEY +#define DEFAULT_TC_LINK_KEY {0x5a,0x69,0x67,0x42,0x65,0x65,0x41,0x6c,0x6c,0x69,0x61,0x6e,0x63,0x65,0x30,0x39} +#endif + +/* The number of milliseconds to wait between data request polls to the coordinator. */ +#ifndef TXPOWER +#define TXPOWER 5 +#endif + +/**************************************** + * The following are for End Devices only + ***************************************/ + +/* Determine whether the radio on an End Device is always on */ +#ifndef RFD_RX_ALWAYS_ON_CAPABLE +#define RFD_RX_ALWAYS_ON_CAPABLE TRUE +#endif + +#ifndef RFD_RX_ALWAYS_ON +#define RFD_RX_ALWAYS_ON FALSE +#endif + +/* The minimum poll rate. */ +#ifndef MINIMUM_APP_POLL_RATE +#define MINIMUM_APP_POLL_RATE 100 +#endif + +/* The number of milliseconds to wait between data request polls to the coordinator. */ +#ifndef POLL_RATE +#define POLL_RATE 3000 +#endif + +/* This is used after receiving a data indication to poll immediately + * for queued messages...in milliseconds. + */ +#ifndef QUEUED_POLL_RATE +#define QUEUED_POLL_RATE 100 +#endif + +/* This is used after receiving a data confirmation to poll immediately + * for response messages...in milliseconds + */ +#ifndef RESPONSE_POLL_RATE +#define RESPONSE_POLL_RATE 100 +#endif + +/* This is used as an alternate response poll rate only for rejoin request. + * This rate is determined by the response time of the parent that the device + * is trying to join. + */ +#ifndef REJOIN_POLL_RATE +#define REJOIN_POLL_RATE 440 +#endif + +/* Maximum number of devices in the Assoc/Device list. */ +#ifndef NWK_MAX_DEVICE_LIST +#define NWK_MAX_DEVICE_LIST 20 +#endif + +/* Total Number of APS keys that a TC can manage. This is equal to the number of devices a ZC can allow to join the network */ +#ifndef ZDSECMGR_TC_DEVICE_MAX +#define ZDSECMGR_TC_DEVICE_MAX 40 +#endif + +/* Value used by end device when sending End Device Timeout Request */ +/* This is an index into table timeoutValue[] defined in nwk_globals.c */ +#ifndef END_DEV_TIMEOUT_VALUE +#define END_DEV_TIMEOUT_VALUE 8 +#endif + + + + +#endif /* TI_ZSTACK_CONFIG_H */ diff --git a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt.h b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt.h index 2c5073c..48f050b 100644 --- a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt.h +++ b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt.h @@ -415,6 +415,8 @@ extern "C" #define MT_UTIL_CALLBACK_SUB_CMD 0x06 #define MT_UTIL_TIME_ALIVE 0x09 +#define MT_UTIL_LED_CONTROL 0x0A + #define MT_UTIL_TEST_LOOPBACK 0x10 #define MT_UTIL_DATA_REQ 0x11 @@ -441,6 +443,8 @@ extern "C" #define MT_UTIL_SRNG_GENERATE 0x4C #endif #define MT_UTIL_BIND_ADD_ENTRY 0x4D +#define MT_UTIL_ASSOC_REMOVE 0x63 // Custom command +#define MT_UTIL_ASSOC_ADD 0x64 // Custom command #define MT_UTIL_ZCL_KEY_EST_INIT_EST 0x80 #define MT_UTIL_ZCL_KEY_EST_SIGN 0x81 diff --git a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt_util.c b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt_util.c index 90d6d4a..4f416e8 100644 --- a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt_util.c +++ b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt_util.c @@ -53,6 +53,9 @@ #include "mt_zdo.h" #include "ssp.h" +#include +#include "ti_drivers_config.h" + #if !defined NONWK #include "mt_nwk.h" @@ -95,6 +98,8 @@ static void MT_UtilSpi2Addr( zAddrType_t *pDst, uint8_t *pSrc ); #endif #if defined (MT_UTIL_FUNC) +static LED_Handle gLedHandle; + static void MT_UtilGetDeviceInfo(void); static void MT_UtilGetNvInfo(void); static void MT_UtilSetPanID(uint8_t *pBuf); @@ -128,6 +133,9 @@ static void MT_UtilAPSME_LinkKeyNvIdGet(uint8_t *pBuf); #endif //MT_SYS_KEY_MANAGEMENT static void MT_UtilAPSME_RequestKeyCmd(uint8_t *pBuf); static void MT_UtilAssocCount(uint8_t *pBuf); +static void MT_UtilLedControl(uint8_t *pBuf); +static void MT_UtilAssocRemove(uint8_t *pBuf); +static void MT_UtilAssocAdd(uint8_t *pBuf); static void MT_UtilAssocFindDevice(uint8_t *pBuf); static void MT_UtilAssocGetWithAddress(uint8_t *pBuf); static void MT_UtilBindAddEntry(uint8_t *pBuf); @@ -260,6 +268,10 @@ uint8_t MT_UtilCommandProcessing(uint8_t *pBuf) MT_UtilAssocCount(pBuf); break; + case MT_UTIL_LED_CONTROL: + MT_UtilLedControl(pBuf); + break; + case MT_UTIL_ASSOC_FIND_DEVICE: MT_UtilAssocFindDevice(pBuf); break; @@ -272,6 +284,14 @@ uint8_t MT_UtilCommandProcessing(uint8_t *pBuf) MT_UtilBindAddEntry(pBuf); break; + case MT_UTIL_ASSOC_REMOVE: + MT_UtilAssocRemove(pBuf); + break; + + case MT_UTIL_ASSOC_ADD: + MT_UtilAssocAdd(pBuf); + break; + case MT_UTIL_SYNC_REQ: MT_UtilSync(); break; @@ -1375,6 +1395,92 @@ static void MT_UtilAssocCount(uint8_t *pBuf) MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 2, pBuf); } +/*************************************************************************************************** + * @fn MT_UtilLedControl + * + * @brief Proxy the LedControl() function. + * + * @param pBuf - pointer to the received buffer + * + * @return void + ***************************************************************************************************/ +static void MT_UtilLedControl(uint8_t *pBuf) +{ + uint8_t cmdId = pBuf[MT_RPC_POS_CMD1]; + pBuf += MT_RPC_FRAME_HDR_SZ; + + uint8_t mode = pBuf[1]; + + if (gLedHandle == NULL) { + LED_Params ledParams; + LED_Params_init(&ledParams); + gLedHandle = LED_open(CONFIG_LED_GREEN, &ledParams); + } + + if (mode==0) { + LED_setOff(gLedHandle); + } else { + LED_setOn(gLedHandle, LED_BRIGHTNESS_MAX); + } + + uint8_t retValue = 0; + MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); +} + +/*************************************************************************************************** + * @fn MT_UtilAssocRemove + * + * @brief Proxy the AssocRemove() function. + * + * @param pBuf - pointer to the received buffer + * + * @return void + ***************************************************************************************************/ +static void MT_UtilAssocRemove(uint8_t *pBuf) +{ + uint8_t cmdId; + uint8_t ieeeAddr[Z_EXTADDR_LEN]; + uint8_t retValue = 0; + + // parse header + cmdId = pBuf[MT_RPC_POS_CMD1]; + pBuf += MT_RPC_FRAME_HDR_SZ; + + /* IeeAddress */ + OsalPort_memcpy(ieeeAddr, pBuf, Z_EXTADDR_LEN); + + AssocRemove(ieeeAddr); + + MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); +} + +/*************************************************************************************************** + * @fn MT_UtilAssocAdd + * + * @brief Proxy the AssocAdd() function. + * + * @param pBuf - pointer to the received buffer + * + * @return void + ***************************************************************************************************/ +static void MT_UtilAssocAdd(uint8_t *pBuf) +{ + uint8_t cmdId; + uint8_t retValue = 0; + + // parse header + cmdId = pBuf[MT_RPC_POS_CMD1]; + pBuf += MT_RPC_FRAME_HDR_SZ; + + AssocAddNew( + BUILD_UINT16(pBuf[Z_EXTADDR_LEN], pBuf[Z_EXTADDR_LEN + 1]), + pBuf, + pBuf[Z_EXTADDR_LEN + 2] + ); + + MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); +} + /*************************************************************************************************** * @fn MT_UtilAssocFindDevice * diff --git a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt_version.c b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt_version.c index 63c143b..590ec09 100644 --- a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt_version.c +++ b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt_version.c @@ -43,15 +43,21 @@ #include "zcomdef.h" #include "mt_version.h" +#define CODE_REVISION_NUMBER 20210708 + /****************************************************************************** * CONSTANTS *****************************************************************************/ const uint8_t MTVersionString[] = { 2, /* Transport protocol revision */ - 0, /* Product ID */ + 1, /* Product ID */ 2, /* Software major release number */ 7, /* Software minor release number */ 1, /* Software maintenance release number */ + ((CODE_REVISION_NUMBER >> 0) & 0xFF), + ((CODE_REVISION_NUMBER >> 8) & 0xFF), + ((CODE_REVISION_NUMBER >> 16) & 0xFF), + ((CODE_REVISION_NUMBER >> 24) & 0xFF), }; /****************************************************************************** diff --git a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt_zdo.c b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt_zdo.c index 9755b1d..1571e2b 100644 --- a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt_zdo.c +++ b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Application/mt/mt_zdo.c @@ -1659,6 +1659,11 @@ static void MT_ZdoMgmtPermitJoinRequest(uint8_t *pBuf) retValue = (uint8_t)ZDP_MgmtPermitJoinReq( &destAddr, duration, tcSignificance, 0); ignoreIndication = FALSE; + // If joining is enabled via a router, ZDO_ProcessMgmtPermitJoinReq is never triggered thus + // ZDSecMgrPermitJoining is never called. Joining via a router would always fail now since + // ZDSecMgrPermitJoiningEnabled in zd_sec_mgr.c stays FALSE + ZDSecMgrPermitJoining(duration); + MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_ZDO), cmdId, 1, &retValue); } diff --git a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/Config/preinclude.h b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/Config/preinclude.h new file mode 100644 index 0000000..a19e37a --- /dev/null +++ b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/Config/preinclude.h @@ -0,0 +1,60 @@ +#define MT_SYS_KEY_MANAGEMENT 1 +#define FEATURE_NVEXID 1 + +// Increase MAC buffers +#undef MAC_CFG_TX_DATA_MAX +#define MAC_CFG_TX_DATA_MAX 20 +#undef MAC_CFG_TX_MAX +#define MAC_CFG_TX_MAX 32 +#undef MAC_CFG_RX_MAX +#define MAC_CFG_RX_MAX 20 + +// Save memory +#undef NWK_MAX_BINDING_ENTRIES +#define NWK_MAX_BINDING_ENTRIES 1 +#undef APS_MAX_GROUPS +#define APS_MAX_GROUPS 1 + +// Increase NV pages to 3 to allow for bigger device tables +#undef NVOCMP_NVPAGES +#define NVOCMP_NVPAGES 3 + +// Disabling MULTICAST is required in order for proper group support. +// If MULTICAST is not disabled, the group adress is not included in the APS header +#define MULTICAST_ENABLED FALSE + +// Increase the max number of boardcasts, the default broadcast delivery time is 3 seconds +// with the value below this will allow for 1 broadcast every 0.15 second +#define MAX_BCAST 30 + +/** + * Enable MTO routing + */ +#define CONCENTRATOR_ENABLE TRUE +#define CONCENTRATOR_DISCOVERY_TIME 100 +#define CONCENTRATOR_ROUTE_CACHE TRUE +#define MAX_RTG_SRC_ENTRIES 200 +#define SRC_RTG_EXPIRY_TIME 2 + +/** + * Scale other device tables appropriately + */ +#define NWK_MAX_DEVICE_LIST 50 +#define ZDSECMGR_TC_DEVICE_MAX 200 +#define MAX_NEIGHBOR_ENTRIES 20 +#define MAX_RTG_ENTRIES 100 + +/** + * Reduce the APS ack wait duration from 6000 ms to 1000 ms (value * 2 = value in ms). + * This will make requests timeout quicker, in pratice the default timeout of 6000ms is too long. + */ +#define APSC_ACK_WAIT_DURATION_POLLED 500 + +// From https://www.ti.com/lit/an/swra650b/swra650b.pdf +#define LINK_DOWN_TRIGGER 12 +#define NWK_ROUTE_AGE_LIMIT 5 +#define DEF_NWK_RADIUS 15 +#define DEFAULT_ROUTE_REQUEST_RADIUS 8 +#define ZDNWKMGR_MIN_TRANSMISSIONS 0 +#define ROUTE_DISCOVERY_TIME 13 +#define MTO_RREQ_LIMIT_TIME 5000 diff --git a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/Config/znp_cnf.opts b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/Config/znp_cnf.opts index 6e3cb6a..886d0b4 100644 --- a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/Config/znp_cnf.opts +++ b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/Config/znp_cnf.opts @@ -32,3 +32,5 @@ -DMT_GP_CB_FUNC -DMT_APP_CNF_FUNC + +--preinclude=preinclude.h \ No newline at end of file diff --git a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/af/af.c b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/af/af.c index 3a7afa3..2dcef5a 100644 --- a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/af/af.c +++ b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/af/af.c @@ -407,10 +407,18 @@ void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress, uint16_t S #if !defined ( APS_NO_GROUPS ) // Find the first endpoint for this group grpEp = aps_FindGroupForEndpoint( aff->GroupID, APS_GROUPS_FIND_FIRST ); - if ( grpEp == APS_GROUPS_EP_NOT_FOUND ) - return; // No endpoint found + if ( grpEp == APS_GROUPS_EP_NOT_FOUND ) { + // No endpoint found, default to endpoint 1. + // In the original source code there is a return here. + // This prevent the messags from being forwarded. + // For our use-case we want to capture all messages. + // Even if the coordinator is not in the group. + epDesc = afFindEndPointDesc( 1 ); + } + else { + epDesc = afFindEndPointDesc( grpEp ); + } - epDesc = afFindEndPointDesc( grpEp ); if ( epDesc == NULL ) return; // Endpoint descriptor not found @@ -457,7 +465,9 @@ void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress, uint16_t S // if the Wildcard ProfileID is received the message should not be sent to ZDO endpoint if ( (aff->ProfileID == epProfileID) || ((epDesc->endPoint == ZDO_EP) && (aff->ProfileID == ZDO_PROFILE_ID)) || - ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) ) + ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) || + // Forward messages to endpoint even with profileID mismatches + ((aff->ProfileID >= 0x100) && (aff->ProfileID <= 0xFC01)) ) { // Save original endpoint uint8_t endpoint = aff->DstEndPoint; diff --git a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/nwk/nwk_globals.c b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/nwk/nwk_globals.c index 2b63c06..6ac3fb2 100644 --- a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/nwk/nwk_globals.c +++ b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/nwk/nwk_globals.c @@ -65,10 +65,10 @@ * CONSTANTS */ // Maximums for the data buffer queue -#define NWK_MAX_DATABUFS_WAITING 8 // Waiting to be sent to MAC -#define NWK_MAX_DATABUFS_SCHEDULED 5 // Timed messages to be sent -#define NWK_MAX_DATABUFS_CONFIRMED 5 // Held after MAC confirms -#define NWK_MAX_DATABUFS_TOTAL 12 // Total number of buffers +#define NWK_MAX_DATABUFS_WAITING 32 // Waiting to be sent to MAC +#define NWK_MAX_DATABUFS_SCHEDULED 20 // Timed messages to be sent +#define NWK_MAX_DATABUFS_CONFIRMED 20 // Held after MAC confirms +#define NWK_MAX_DATABUFS_TOTAL 48 // Total number of buffers // 1-255 (0 -> 256) X RTG_TIMER_INTERVAL // A known shortcoming is that when a message is enqueued as "hold" for a diff --git a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/sys/zglobals.c b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/sys/zglobals.c index 764dabd..e9135fb 100644 --- a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/sys/zglobals.c +++ b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/sys/zglobals.c @@ -105,7 +105,7 @@ uint8_t zgSecurePermitJoin = TRUE; // TC Link Key. In this scenario, if this flag is TRUE, the Trust Center will // encrypt the outgoing NWK Key with the default TC Link Key (ZigbeeAlliance09). // If this flag is FALSE (default), the Trust Center will not send the NWK Key at all. -uint8_t zgAllowRejoinsWithWellKnownKey = FALSE; +uint8_t zgAllowRejoinsWithWellKnownKey = TRUE; // https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread/f/158/p/882650/3265311#3265311 //allowInstallCodes uint8_t zgAllowInstallCodes = ZG_IC_SUPPORTED_NOT_REQUIRED; @@ -199,7 +199,9 @@ uint8_t zgEndDeviceConfiguration = END_DEV_CONFIGURATION; // // NOTICE: Before enabling Child Aging make sure to review all the related // definitions in this file, especially zgNwkParentInformation. -uint8_t zgChildAgingEnable = TRUE; + +// Disable child aging, otherwise Xiaomi devices are being kicked off the network. +uint8_t zgChildAgingEnable = FALSE; //========== TouchLink NWK configuration =============== // Values used by Router when starts a network as initiator diff --git a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/zdo/zd_app.c b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/zdo/zd_app.c index 1f807ca..b3e2694 100644 --- a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/zdo/zd_app.c +++ b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/Stack/zdo/zd_app.c @@ -419,12 +419,11 @@ uint32_t ZDApp_event_loop( uint8_t task_id, uint32_t events ) ZDApp_ChangeState( DEV_ROUTER ); } - if ( zgChildAgingEnable == TRUE ) - { - // Once the device has changed its state to a ROUTER set the timer to send - // Parent annce - ZDApp_SetParentAnnceTimer(); - } + // As we cannot enable child aging as Xiaomi devices will drop off + // but we stil want to have the parent announces we always enable it here. + // Otherwise some end devices could be unreachable when they changed parent + // while the coordinator was powered off. + ZDApp_SetParentAnnceTimer(); } else { @@ -885,12 +884,11 @@ void ZDApp_NetworkStartEvt( void ) bdb_reportCommissioningState(BDB_INITIALIZATION,TRUE); } - if ( zgChildAgingEnable == TRUE ) - { - // Once the device has changed its state to a COORDINATOR set the timer to send - // Parent annce - ZDApp_SetParentAnnceTimer(); - } + // As we cannot enable child aging as Xiaomi devices will drop off + // but we stil want to have the parent announces we always enable it here. + // Otherwise some end devices could be unreachable when they changed parent + // while the coordinator was powered off. + ZDApp_SetParentAnnceTimer(); } else { @@ -3132,6 +3130,14 @@ void ZDO_NetworkStatusCB( uint16_t nwkDstAddr, uint8_t statusCode, uint16_t dstA // Routing error for dstAddr, this is informational and a Route // Request should happen automatically. } + + if ( (nwkDstAddr == NLME_GetShortAddr()) + && (statusCode == NWKSTAT_SOURCE_ROUTE_FAILURE) ) + { + // Received a source route failure, remove route and rediscover. + RTG_RemoveRtgEntry( dstAddr, 0 ); + NLME_RouteDiscoveryRequest( dstAddr, 0, 30 ); + } } /****************************************************************************** diff --git a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/cc13x2_cc26x2.cmd b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/cc13x2_cc26x2.cmd index 2dcc711..a8b8d93 100755 --- a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/cc13x2_cc26x2.cmd +++ b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/cc13x2_cc26x2.cmd @@ -70,9 +70,9 @@ /* must be located at the beginning of the application. */ #define FLASH_BASE 0x00000000 -#define FLASH_SIZE 0x52000 -#define FLASH_NV_BASE 0x52000 -#define FLASH_NV_SIZE 0x4000 +#define FLASH_SIZE 0x50000 +#define FLASH_NV_BASE 0x50000 +#define FLASH_NV_SIZE 0x6000 #define FLASH_LAST_BASE 0x56000 #define FLASH_LAST_SIZE 0x2000 diff --git a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/znp.syscfg b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/znp.syscfg index 352db90..fae442b 100644 --- a/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/znp.syscfg +++ b/znp_CC26X2R1_LAUNCHXL_tirtos_ccs/znp.syscfg @@ -49,6 +49,7 @@ CCFG.enableBootloader = true; CCFG.enableBootloaderBackdoor = true; CCFG.dioBootloaderBackdoor = 13; CCFG.levelBootloaderBackdoor = "Active low"; +CCFG.enableDCDC = false; CCFG.ccfgTemplate.$name = "ti_devices_CCFGTemplate0"; AESCBC1.$name = "CONFIG_AESCBC_0"; @@ -67,8 +68,8 @@ ECJPAKE1.$name = "CONFIG_ECJPAKE_0"; NVS1.$name = "CONFIG_NVSINTERNAL"; NVS1.internalFlash.$name = "ti_drivers_nvs_NVSCC26XX0"; -NVS1.internalFlash.regionBase = 0x52000; -NVS1.internalFlash.regionSize = 0x4000; +NVS1.internalFlash.regionBase = 0x50000; +NVS1.internalFlash.regionSize = 0x6000; NVS2.$name = "CONFIG_NVSEXTERNAL"; NVS2.nvsType = "External"; @@ -121,18 +122,20 @@ SPI1.sclkPinInstance.$name = "CONFIG_PIN_SPI_SCLK"; SPI1.misoPinInstance.$name = "CONFIG_PIN_SPI_MISO"; SPI1.mosiPinInstance.$name = "CONFIG_PIN_SPI_MOSI"; -zstack.deviceType = "znp"; -zstack.deviceTypeReadOnly = true; -zstack.touchlink.$name = "ti_zstack_touchlink_zstack_touchlink0"; -zstack.pm.$name = "ti_zstack_pm_zstack_pm0"; -zstack.rf.$name = "ti_zstack_rf_zstack_rf0"; -zstack.rf.radioConfig.$name = "ti_devices_radioconfig_settings_ieee_15_40"; -zstack.rf.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param0"; -zstack.network.$name = "ti_zstack_network_zstack_network0"; -zstack.advanced.$name = "ti_zstack_advanced_zstack_advanced0"; -zstack.advanced.routing.$name = "ti_zstack_advanced_zstack_routing0"; -zstack.advanced.packetSending.$name = "ti_zstack_advanced_zstack_packet_sending0"; -zstack.advanced.tableSize.$name = "ti_zstack_advanced_zstack_table_size0"; +zstack.deviceType = "znp"; +zstack.deviceTypeReadOnly = true; +zstack.touchlink.$name = "ti_zstack_touchlink_zstack_touchlink0"; +zstack.pm.$name = "ti_zstack_pm_zstack_pm0"; +zstack.rf.$name = "ti_zstack_rf_zstack_rf0"; +zstack.rf.txPower = "5"; +zstack.rf.radioConfig.$name = "ti_devices_radioconfig_settings_ieee_15_40"; +zstack.rf.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param0"; +zstack.network.$name = "ti_zstack_network_zstack_network0"; +zstack.advanced.$name = "ti_zstack_advanced_zstack_advanced0"; +zstack.advanced.routing.$name = "ti_zstack_advanced_zstack_routing0"; +zstack.advanced.packetSending.$name = "ti_zstack_advanced_zstack_packet_sending0"; +zstack.advanced.packetSending.apsAckWaitDurationPolled = 1000; +zstack.advanced.tableSize.$name = "ti_zstack_advanced_zstack_table_size0"; /** * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future diff --git a/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt.h b/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt.h index 2c5073c..48f050b 100644 --- a/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt.h +++ b/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt.h @@ -415,6 +415,8 @@ extern "C" #define MT_UTIL_CALLBACK_SUB_CMD 0x06 #define MT_UTIL_TIME_ALIVE 0x09 +#define MT_UTIL_LED_CONTROL 0x0A + #define MT_UTIL_TEST_LOOPBACK 0x10 #define MT_UTIL_DATA_REQ 0x11 @@ -441,6 +443,8 @@ extern "C" #define MT_UTIL_SRNG_GENERATE 0x4C #endif #define MT_UTIL_BIND_ADD_ENTRY 0x4D +#define MT_UTIL_ASSOC_REMOVE 0x63 // Custom command +#define MT_UTIL_ASSOC_ADD 0x64 // Custom command #define MT_UTIL_ZCL_KEY_EST_INIT_EST 0x80 #define MT_UTIL_ZCL_KEY_EST_SIGN 0x81 diff --git a/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt_util.c b/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt_util.c index 90d6d4a..4f416e8 100644 --- a/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt_util.c +++ b/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt_util.c @@ -53,6 +53,9 @@ #include "mt_zdo.h" #include "ssp.h" +#include +#include "ti_drivers_config.h" + #if !defined NONWK #include "mt_nwk.h" @@ -95,6 +98,8 @@ static void MT_UtilSpi2Addr( zAddrType_t *pDst, uint8_t *pSrc ); #endif #if defined (MT_UTIL_FUNC) +static LED_Handle gLedHandle; + static void MT_UtilGetDeviceInfo(void); static void MT_UtilGetNvInfo(void); static void MT_UtilSetPanID(uint8_t *pBuf); @@ -128,6 +133,9 @@ static void MT_UtilAPSME_LinkKeyNvIdGet(uint8_t *pBuf); #endif //MT_SYS_KEY_MANAGEMENT static void MT_UtilAPSME_RequestKeyCmd(uint8_t *pBuf); static void MT_UtilAssocCount(uint8_t *pBuf); +static void MT_UtilLedControl(uint8_t *pBuf); +static void MT_UtilAssocRemove(uint8_t *pBuf); +static void MT_UtilAssocAdd(uint8_t *pBuf); static void MT_UtilAssocFindDevice(uint8_t *pBuf); static void MT_UtilAssocGetWithAddress(uint8_t *pBuf); static void MT_UtilBindAddEntry(uint8_t *pBuf); @@ -260,6 +268,10 @@ uint8_t MT_UtilCommandProcessing(uint8_t *pBuf) MT_UtilAssocCount(pBuf); break; + case MT_UTIL_LED_CONTROL: + MT_UtilLedControl(pBuf); + break; + case MT_UTIL_ASSOC_FIND_DEVICE: MT_UtilAssocFindDevice(pBuf); break; @@ -272,6 +284,14 @@ uint8_t MT_UtilCommandProcessing(uint8_t *pBuf) MT_UtilBindAddEntry(pBuf); break; + case MT_UTIL_ASSOC_REMOVE: + MT_UtilAssocRemove(pBuf); + break; + + case MT_UTIL_ASSOC_ADD: + MT_UtilAssocAdd(pBuf); + break; + case MT_UTIL_SYNC_REQ: MT_UtilSync(); break; @@ -1375,6 +1395,92 @@ static void MT_UtilAssocCount(uint8_t *pBuf) MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 2, pBuf); } +/*************************************************************************************************** + * @fn MT_UtilLedControl + * + * @brief Proxy the LedControl() function. + * + * @param pBuf - pointer to the received buffer + * + * @return void + ***************************************************************************************************/ +static void MT_UtilLedControl(uint8_t *pBuf) +{ + uint8_t cmdId = pBuf[MT_RPC_POS_CMD1]; + pBuf += MT_RPC_FRAME_HDR_SZ; + + uint8_t mode = pBuf[1]; + + if (gLedHandle == NULL) { + LED_Params ledParams; + LED_Params_init(&ledParams); + gLedHandle = LED_open(CONFIG_LED_GREEN, &ledParams); + } + + if (mode==0) { + LED_setOff(gLedHandle); + } else { + LED_setOn(gLedHandle, LED_BRIGHTNESS_MAX); + } + + uint8_t retValue = 0; + MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); +} + +/*************************************************************************************************** + * @fn MT_UtilAssocRemove + * + * @brief Proxy the AssocRemove() function. + * + * @param pBuf - pointer to the received buffer + * + * @return void + ***************************************************************************************************/ +static void MT_UtilAssocRemove(uint8_t *pBuf) +{ + uint8_t cmdId; + uint8_t ieeeAddr[Z_EXTADDR_LEN]; + uint8_t retValue = 0; + + // parse header + cmdId = pBuf[MT_RPC_POS_CMD1]; + pBuf += MT_RPC_FRAME_HDR_SZ; + + /* IeeAddress */ + OsalPort_memcpy(ieeeAddr, pBuf, Z_EXTADDR_LEN); + + AssocRemove(ieeeAddr); + + MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); +} + +/*************************************************************************************************** + * @fn MT_UtilAssocAdd + * + * @brief Proxy the AssocAdd() function. + * + * @param pBuf - pointer to the received buffer + * + * @return void + ***************************************************************************************************/ +static void MT_UtilAssocAdd(uint8_t *pBuf) +{ + uint8_t cmdId; + uint8_t retValue = 0; + + // parse header + cmdId = pBuf[MT_RPC_POS_CMD1]; + pBuf += MT_RPC_FRAME_HDR_SZ; + + AssocAddNew( + BUILD_UINT16(pBuf[Z_EXTADDR_LEN], pBuf[Z_EXTADDR_LEN + 1]), + pBuf, + pBuf[Z_EXTADDR_LEN + 2] + ); + + MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_UTIL), cmdId, 1, &retValue); +} + /*************************************************************************************************** * @fn MT_UtilAssocFindDevice * diff --git a/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt_version.c b/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt_version.c index 63c143b..590ec09 100644 --- a/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt_version.c +++ b/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt_version.c @@ -43,15 +43,21 @@ #include "zcomdef.h" #include "mt_version.h" +#define CODE_REVISION_NUMBER 20210708 + /****************************************************************************** * CONSTANTS *****************************************************************************/ const uint8_t MTVersionString[] = { 2, /* Transport protocol revision */ - 0, /* Product ID */ + 1, /* Product ID */ 2, /* Software major release number */ 7, /* Software minor release number */ 1, /* Software maintenance release number */ + ((CODE_REVISION_NUMBER >> 0) & 0xFF), + ((CODE_REVISION_NUMBER >> 8) & 0xFF), + ((CODE_REVISION_NUMBER >> 16) & 0xFF), + ((CODE_REVISION_NUMBER >> 24) & 0xFF), }; /****************************************************************************** diff --git a/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt_zdo.c b/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt_zdo.c index 9755b1d..1571e2b 100644 --- a/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt_zdo.c +++ b/znp_LP_CC2652RB_tirtos_ccs/Application/mt/mt_zdo.c @@ -1659,6 +1659,11 @@ static void MT_ZdoMgmtPermitJoinRequest(uint8_t *pBuf) retValue = (uint8_t)ZDP_MgmtPermitJoinReq( &destAddr, duration, tcSignificance, 0); ignoreIndication = FALSE; + // If joining is enabled via a router, ZDO_ProcessMgmtPermitJoinReq is never triggered thus + // ZDSecMgrPermitJoining is never called. Joining via a router would always fail now since + // ZDSecMgrPermitJoiningEnabled in zd_sec_mgr.c stays FALSE + ZDSecMgrPermitJoining(duration); + MT_BuildAndSendZToolResponse(((uint8_t)MT_RPC_CMD_SRSP | (uint8_t)MT_RPC_SYS_ZDO), cmdId, 1, &retValue); } diff --git a/znp_LP_CC2652RB_tirtos_ccs/Stack/Config/preinclude.h b/znp_LP_CC2652RB_tirtos_ccs/Stack/Config/preinclude.h new file mode 100644 index 0000000..a19e37a --- /dev/null +++ b/znp_LP_CC2652RB_tirtos_ccs/Stack/Config/preinclude.h @@ -0,0 +1,60 @@ +#define MT_SYS_KEY_MANAGEMENT 1 +#define FEATURE_NVEXID 1 + +// Increase MAC buffers +#undef MAC_CFG_TX_DATA_MAX +#define MAC_CFG_TX_DATA_MAX 20 +#undef MAC_CFG_TX_MAX +#define MAC_CFG_TX_MAX 32 +#undef MAC_CFG_RX_MAX +#define MAC_CFG_RX_MAX 20 + +// Save memory +#undef NWK_MAX_BINDING_ENTRIES +#define NWK_MAX_BINDING_ENTRIES 1 +#undef APS_MAX_GROUPS +#define APS_MAX_GROUPS 1 + +// Increase NV pages to 3 to allow for bigger device tables +#undef NVOCMP_NVPAGES +#define NVOCMP_NVPAGES 3 + +// Disabling MULTICAST is required in order for proper group support. +// If MULTICAST is not disabled, the group adress is not included in the APS header +#define MULTICAST_ENABLED FALSE + +// Increase the max number of boardcasts, the default broadcast delivery time is 3 seconds +// with the value below this will allow for 1 broadcast every 0.15 second +#define MAX_BCAST 30 + +/** + * Enable MTO routing + */ +#define CONCENTRATOR_ENABLE TRUE +#define CONCENTRATOR_DISCOVERY_TIME 100 +#define CONCENTRATOR_ROUTE_CACHE TRUE +#define MAX_RTG_SRC_ENTRIES 200 +#define SRC_RTG_EXPIRY_TIME 2 + +/** + * Scale other device tables appropriately + */ +#define NWK_MAX_DEVICE_LIST 50 +#define ZDSECMGR_TC_DEVICE_MAX 200 +#define MAX_NEIGHBOR_ENTRIES 20 +#define MAX_RTG_ENTRIES 100 + +/** + * Reduce the APS ack wait duration from 6000 ms to 1000 ms (value * 2 = value in ms). + * This will make requests timeout quicker, in pratice the default timeout of 6000ms is too long. + */ +#define APSC_ACK_WAIT_DURATION_POLLED 500 + +// From https://www.ti.com/lit/an/swra650b/swra650b.pdf +#define LINK_DOWN_TRIGGER 12 +#define NWK_ROUTE_AGE_LIMIT 5 +#define DEF_NWK_RADIUS 15 +#define DEFAULT_ROUTE_REQUEST_RADIUS 8 +#define ZDNWKMGR_MIN_TRANSMISSIONS 0 +#define ROUTE_DISCOVERY_TIME 13 +#define MTO_RREQ_LIMIT_TIME 5000 diff --git a/znp_LP_CC2652RB_tirtos_ccs/Stack/Config/znp_cnf.opts b/znp_LP_CC2652RB_tirtos_ccs/Stack/Config/znp_cnf.opts index 6e3cb6a..886d0b4 100644 --- a/znp_LP_CC2652RB_tirtos_ccs/Stack/Config/znp_cnf.opts +++ b/znp_LP_CC2652RB_tirtos_ccs/Stack/Config/znp_cnf.opts @@ -32,3 +32,5 @@ -DMT_GP_CB_FUNC -DMT_APP_CNF_FUNC + +--preinclude=preinclude.h \ No newline at end of file diff --git a/znp_LP_CC2652RB_tirtos_ccs/Stack/af/af.c b/znp_LP_CC2652RB_tirtos_ccs/Stack/af/af.c index 3a7afa3..2dcef5a 100644 --- a/znp_LP_CC2652RB_tirtos_ccs/Stack/af/af.c +++ b/znp_LP_CC2652RB_tirtos_ccs/Stack/af/af.c @@ -407,10 +407,18 @@ void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress, uint16_t S #if !defined ( APS_NO_GROUPS ) // Find the first endpoint for this group grpEp = aps_FindGroupForEndpoint( aff->GroupID, APS_GROUPS_FIND_FIRST ); - if ( grpEp == APS_GROUPS_EP_NOT_FOUND ) - return; // No endpoint found + if ( grpEp == APS_GROUPS_EP_NOT_FOUND ) { + // No endpoint found, default to endpoint 1. + // In the original source code there is a return here. + // This prevent the messags from being forwarded. + // For our use-case we want to capture all messages. + // Even if the coordinator is not in the group. + epDesc = afFindEndPointDesc( 1 ); + } + else { + epDesc = afFindEndPointDesc( grpEp ); + } - epDesc = afFindEndPointDesc( grpEp ); if ( epDesc == NULL ) return; // Endpoint descriptor not found @@ -457,7 +465,9 @@ void afIncomingData( aps_FrameFormat_t *aff, zAddrType_t *SrcAddress, uint16_t S // if the Wildcard ProfileID is received the message should not be sent to ZDO endpoint if ( (aff->ProfileID == epProfileID) || ((epDesc->endPoint == ZDO_EP) && (aff->ProfileID == ZDO_PROFILE_ID)) || - ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) ) + ((epDesc->endPoint != ZDO_EP) && ( aff->ProfileID == ZDO_WILDCARD_PROFILE_ID )) || + // Forward messages to endpoint even with profileID mismatches + ((aff->ProfileID >= 0x100) && (aff->ProfileID <= 0xFC01)) ) { // Save original endpoint uint8_t endpoint = aff->DstEndPoint; diff --git a/znp_LP_CC2652RB_tirtos_ccs/Stack/nwk/nwk_globals.c b/znp_LP_CC2652RB_tirtos_ccs/Stack/nwk/nwk_globals.c index 2b63c06..6ac3fb2 100644 --- a/znp_LP_CC2652RB_tirtos_ccs/Stack/nwk/nwk_globals.c +++ b/znp_LP_CC2652RB_tirtos_ccs/Stack/nwk/nwk_globals.c @@ -65,10 +65,10 @@ * CONSTANTS */ // Maximums for the data buffer queue -#define NWK_MAX_DATABUFS_WAITING 8 // Waiting to be sent to MAC -#define NWK_MAX_DATABUFS_SCHEDULED 5 // Timed messages to be sent -#define NWK_MAX_DATABUFS_CONFIRMED 5 // Held after MAC confirms -#define NWK_MAX_DATABUFS_TOTAL 12 // Total number of buffers +#define NWK_MAX_DATABUFS_WAITING 32 // Waiting to be sent to MAC +#define NWK_MAX_DATABUFS_SCHEDULED 20 // Timed messages to be sent +#define NWK_MAX_DATABUFS_CONFIRMED 20 // Held after MAC confirms +#define NWK_MAX_DATABUFS_TOTAL 48 // Total number of buffers // 1-255 (0 -> 256) X RTG_TIMER_INTERVAL // A known shortcoming is that when a message is enqueued as "hold" for a diff --git a/znp_LP_CC2652RB_tirtos_ccs/Stack/sys/zglobals.c b/znp_LP_CC2652RB_tirtos_ccs/Stack/sys/zglobals.c index 764dabd..e9135fb 100644 --- a/znp_LP_CC2652RB_tirtos_ccs/Stack/sys/zglobals.c +++ b/znp_LP_CC2652RB_tirtos_ccs/Stack/sys/zglobals.c @@ -105,7 +105,7 @@ uint8_t zgSecurePermitJoin = TRUE; // TC Link Key. In this scenario, if this flag is TRUE, the Trust Center will // encrypt the outgoing NWK Key with the default TC Link Key (ZigbeeAlliance09). // If this flag is FALSE (default), the Trust Center will not send the NWK Key at all. -uint8_t zgAllowRejoinsWithWellKnownKey = FALSE; +uint8_t zgAllowRejoinsWithWellKnownKey = TRUE; // https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread/f/158/p/882650/3265311#3265311 //allowInstallCodes uint8_t zgAllowInstallCodes = ZG_IC_SUPPORTED_NOT_REQUIRED; @@ -199,7 +199,9 @@ uint8_t zgEndDeviceConfiguration = END_DEV_CONFIGURATION; // // NOTICE: Before enabling Child Aging make sure to review all the related // definitions in this file, especially zgNwkParentInformation. -uint8_t zgChildAgingEnable = TRUE; + +// Disable child aging, otherwise Xiaomi devices are being kicked off the network. +uint8_t zgChildAgingEnable = FALSE; //========== TouchLink NWK configuration =============== // Values used by Router when starts a network as initiator diff --git a/znp_LP_CC2652RB_tirtos_ccs/Stack/zdo/zd_app.c b/znp_LP_CC2652RB_tirtos_ccs/Stack/zdo/zd_app.c index 1f807ca..b3e2694 100644 --- a/znp_LP_CC2652RB_tirtos_ccs/Stack/zdo/zd_app.c +++ b/znp_LP_CC2652RB_tirtos_ccs/Stack/zdo/zd_app.c @@ -419,12 +419,11 @@ uint32_t ZDApp_event_loop( uint8_t task_id, uint32_t events ) ZDApp_ChangeState( DEV_ROUTER ); } - if ( zgChildAgingEnable == TRUE ) - { - // Once the device has changed its state to a ROUTER set the timer to send - // Parent annce - ZDApp_SetParentAnnceTimer(); - } + // As we cannot enable child aging as Xiaomi devices will drop off + // but we stil want to have the parent announces we always enable it here. + // Otherwise some end devices could be unreachable when they changed parent + // while the coordinator was powered off. + ZDApp_SetParentAnnceTimer(); } else { @@ -885,12 +884,11 @@ void ZDApp_NetworkStartEvt( void ) bdb_reportCommissioningState(BDB_INITIALIZATION,TRUE); } - if ( zgChildAgingEnable == TRUE ) - { - // Once the device has changed its state to a COORDINATOR set the timer to send - // Parent annce - ZDApp_SetParentAnnceTimer(); - } + // As we cannot enable child aging as Xiaomi devices will drop off + // but we stil want to have the parent announces we always enable it here. + // Otherwise some end devices could be unreachable when they changed parent + // while the coordinator was powered off. + ZDApp_SetParentAnnceTimer(); } else { @@ -3132,6 +3130,14 @@ void ZDO_NetworkStatusCB( uint16_t nwkDstAddr, uint8_t statusCode, uint16_t dstA // Routing error for dstAddr, this is informational and a Route // Request should happen automatically. } + + if ( (nwkDstAddr == NLME_GetShortAddr()) + && (statusCode == NWKSTAT_SOURCE_ROUTE_FAILURE) ) + { + // Received a source route failure, remove route and rediscover. + RTG_RemoveRtgEntry( dstAddr, 0 ); + NLME_RouteDiscoveryRequest( dstAddr, 0, 30 ); + } } /****************************************************************************** diff --git a/znp_LP_CC2652RB_tirtos_ccs/cc13x2_cc26x2.cmd b/znp_LP_CC2652RB_tirtos_ccs/cc13x2_cc26x2.cmd index 2dcc711..a8b8d93 100755 --- a/znp_LP_CC2652RB_tirtos_ccs/cc13x2_cc26x2.cmd +++ b/znp_LP_CC2652RB_tirtos_ccs/cc13x2_cc26x2.cmd @@ -70,9 +70,9 @@ /* must be located at the beginning of the application. */ #define FLASH_BASE 0x00000000 -#define FLASH_SIZE 0x52000 -#define FLASH_NV_BASE 0x52000 -#define FLASH_NV_SIZE 0x4000 +#define FLASH_SIZE 0x50000 +#define FLASH_NV_BASE 0x50000 +#define FLASH_NV_SIZE 0x6000 #define FLASH_LAST_BASE 0x56000 #define FLASH_LAST_SIZE 0x2000 diff --git a/znp_LP_CC2652RB_tirtos_ccs/znp.syscfg b/znp_LP_CC2652RB_tirtos_ccs/znp.syscfg index a63cc20..95397f1 100644 --- a/znp_LP_CC2652RB_tirtos_ccs/znp.syscfg +++ b/znp_LP_CC2652RB_tirtos_ccs/znp.syscfg @@ -50,6 +50,7 @@ CCFG.enableBootloaderBackdoor = true; CCFG.dioBootloaderBackdoor = 13; CCFG.levelBootloaderBackdoor = "Active low"; CCFG.srcClkLF = "Derived from HF XOSC"; +CCFG.enableDCDC = false; CCFG.ccfgTemplate.$name = "ti_devices_CCFGTemplate0"; AESCBC1.$name = "CONFIG_AESCBC_0"; @@ -68,8 +69,8 @@ ECJPAKE1.$name = "CONFIG_ECJPAKE_0"; NVS1.$name = "CONFIG_NVSINTERNAL"; NVS1.internalFlash.$name = "ti_drivers_nvs_NVSCC26XX0"; -NVS1.internalFlash.regionBase = 0x52000; -NVS1.internalFlash.regionSize = 0x4000; +NVS1.internalFlash.regionBase = 0x50000; +NVS1.internalFlash.regionSize = 0x6000; NVS2.$name = "CONFIG_NVSEXTERNAL"; NVS2.nvsType = "External"; @@ -122,18 +123,20 @@ SPI1.sclkPinInstance.$name = "CONFIG_PIN_SPI_SCLK"; SPI1.misoPinInstance.$name = "CONFIG_PIN_SPI_MISO"; SPI1.mosiPinInstance.$name = "CONFIG_PIN_SPI_MOSI"; -zstack.deviceType = "znp"; -zstack.deviceTypeReadOnly = true; -zstack.touchlink.$name = "ti_zstack_touchlink_zstack_touchlink0"; -zstack.pm.$name = "ti_zstack_pm_zstack_pm0"; -zstack.rf.$name = "ti_zstack_rf_zstack_rf0"; -zstack.rf.radioConfig.$name = "ti_devices_radioconfig_settings_ieee_15_40"; -zstack.rf.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param0"; -zstack.network.$name = "ti_zstack_network_zstack_network0"; -zstack.advanced.$name = "ti_zstack_advanced_zstack_advanced0"; -zstack.advanced.routing.$name = "ti_zstack_advanced_zstack_routing0"; -zstack.advanced.packetSending.$name = "ti_zstack_advanced_zstack_packet_sending0"; -zstack.advanced.tableSize.$name = "ti_zstack_advanced_zstack_table_size0"; +zstack.deviceType = "znp"; +zstack.deviceTypeReadOnly = true; +zstack.touchlink.$name = "ti_zstack_touchlink_zstack_touchlink0"; +zstack.pm.$name = "ti_zstack_pm_zstack_pm0"; +zstack.rf.$name = "ti_zstack_rf_zstack_rf0"; +zstack.rf.txPower = "5"; +zstack.rf.radioConfig.$name = "ti_devices_radioconfig_settings_ieee_15_40"; +zstack.rf.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param0"; +zstack.network.$name = "ti_zstack_network_zstack_network0"; +zstack.advanced.$name = "ti_zstack_advanced_zstack_advanced0"; +zstack.advanced.routing.$name = "ti_zstack_advanced_zstack_routing0"; +zstack.advanced.packetSending.$name = "ti_zstack_advanced_zstack_packet_sending0"; +zstack.advanced.packetSending.apsAckWaitDurationPolled = 1000; +zstack.advanced.tableSize.$name = "ti_zstack_advanced_zstack_table_size0"; /** * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future -- 2.32.0