1.5.4.2 Using the Library
The PRIME Time Management service library is called by the PRIME PAL and the PRIME Library for time-related operations..
The following example illustrates how the Time Management service can be used.
Examples of PRIME Time Management Library Usage
uint8_t PAL_PLC_GetTimer(uint32_t *pTimer) { *pTimer = SRV_TIME_MANAGEMENT_GetTimeUS(); return (uint8_t)PAL_CFG_SUCCESS; } uint8_t PAL_PLC_GetTimerExtended(uint64_t *pTimerExtended) { *pTimerExtended = SRV_TIME_MANAGEMENT_GetTimeUS64(); return (uint8_t)PAL_CFG_SUCCESS; }
static void lPAL_RF_DataCfmCb(DRV_RF215_TX_HANDLE txHandle, DRV_RF215_TX_CONFIRM_OBJ *pCfmObj, uintptr_t ctxt) { PAL_MSG_CONFIRM_DATA dataCfm; dataCfm.bufId = (uint8_t)ctxt; if (palRfData.rfCallbacks.dataConfirm != NULL) { dataCfm.txTime = SRV_TIME_MANAGEMENT_CountToUS(pCfmObj->timeIniCount); dataCfm.pch = (uint16_t)(palRfData.currentChannel | PRIME_PAL_RF_CHN_MASK); dataCfm.rmsCalc = 255; dataCfm.frameType = PAL_FRAME_TYPE_RF; switch(pCfmObj->txResult) { case RF215_TX_SUCCESS: dataCfm.result = PAL_TX_RESULT_SUCCESS; break; case RF215_TX_TIMEOUT: dataCfm.result = PAL_TX_RESULT_TIMEOUT; break; default: dataCfm.result = PAL_TX_RESULT_PHY_ERROR; break; } palRfData.rfCallbacks.dataConfirm(&dataCfm); } } uint8_t PAL_RF_DataRequest(PAL_MSG_REQUEST_DATA *pMessageData) { DRV_RF215_TX_REQUEST_OBJ txReqObj; DRV_RF215_TX_HANDLE rfPhyTxReqHandle; uint8_t auxModScheme; txReqObj.psdu = pMessageData->pData; txReqObj.psduLen = pMessageData->dataLength; txReqObj.timeMode = (DRV_RF215_TX_TIME_MODE)pMessageData->timeMode; txReqObj.txPwrAtt = pMessageData->attLevel; auxModScheme = (uint8_t)(pMessageData->scheme) - (uint8_t)(PAL_SCHEME_RF) - 1U; txReqObj.modScheme = (DRV_RF215_PHY_MOD_SCHEME)(auxModScheme); txReqObj.timeCount = SRV_TIME_MANAGEMENT_USToCount(pMessageData->timeDelay); txReqObj.cancelByRx = false; txReqObj.ccaContentionWindow = pMessageData->numSenses; txReqObj.ccaMode = PHY_CCA_MODE_3; rfPhyTxReqHandle = DRV_RF215_TxRequest(palRfData.drvRfPhyHandle, &txReqObj, &txResult); (void)lPAL_RF_SetTxData(rfPhyTxReqHandle, pMessageData->pData, pMessageData->buffId); return ((uint8_t)PAL_TX_RESULT_PROCESS); }
