CC1310 ListenBeforeTalk例程应用
为了解决数据冲突问题,移植ListenBeforeTalk程序后,数据发送不正常,RF_cmdPropTx.status一直为0,这是什么原因呢?
发送部分的代码如下:
/*
* ======== callback ========
*/
static void Wcallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
if ((e & RF_EventLastCmdDone) && (RF_cmdPropTx.status == PROP_DONE_OK))
{
PIN_setOutputValue(ledPinHandle, NODE_RECEIVE_LED,!PIN_getOutputValue(NODE_RECEIVE_LED));
}
else
{
PIN_setOutputValue(ledPinHandle, NODE_RESEND_LED,!PIN_getOutputValue(NODE_RESEND_LED));
}
}
EasyLink_Status EasyLink_transmit(EasyLink_TxPacket *txPacket)
{
EasyLink_Status status = EasyLink_Status_Tx_Error;
if ( (!configured) || suspended)
{
return EasyLink_Status_Config_Error;
}
//Check and take the busyMutex
if (Semaphore_pend(busyMutex, 0) == FALSE)
{
return EasyLink_Status_Busy_Error;
}
if (txPacket->len > EASYLINK_MAX_DATA_LENGTH)
{
return EasyLink_Status_Param_Error;
}
memcpy(txBuffer, txPacket->dstAddr, addrSize);
memcpy(txBuffer + addrSize, txPacket->payload, txPacket->len);
//packet length to Tx includes address
// EasyLink_cmdPropTx.pktLen = txPacket->len + addrSize;
// EasyLink_cmdPropTx.pPkt = txBuffer;
// if (txPacket->absTime != 0)
// {
// EasyLink_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME;
// EasyLink_cmdPropTx.startTrigger.pastTrig = 1;
// EasyLink_cmdPropTx.startTime = txPacket->absTime;
// }
// else
// {
// EasyLink_cmdPropTx.startTrigger.triggerType = TRIG_NOW;
// EasyLink_cmdPropTx.startTrigger.pastTrig = 1;
// EasyLink_cmdPropTx.startTime = 0;
// }
//packet length to Tx includes address
EasyLink_cmdPropTx.pktLen = txPacket->len + addrSize;
EasyLink_cmdPropTx.pPkt = txBuffer;
if (txPacket->absTime != 0)
{
RF_cmdNop.startTrigger.triggerType = TRIG_ABSTIME;
RF_cmdNop.startTrigger.pastTrig = 1;
RF_cmdNop.startTime = txPacket->absTime;
}
else
{
RF_cmdNop.startTrigger.triggerType = TRIG_NOW;
RF_cmdNop.startTrigger.pastTrig = 1;
RF_cmdNop.startTime = 0;
}
// // Send packet
// RF_CmdHandle cmdHdl = RF_postCmd(rfHandle, (RF_Op*)&EasyLink_cmdPropTx,
// RF_PriorityNormal, 0, EASYLINK_RF_EVENT_MASK);
//
// // Wait for Command to complete
// RF_EventMask result = RF_pendCmd(rfHandle, cmdHdl, (RF_EventLastCmdDone |
// RF_EventCmdError));
/* 添加侦听机制 */
/* Set up the next pointers for the command chain */
RF_cmdNop.pNextOp = (rfc_radioOp_t*)&RF_cmdPropCs;
RF_cmdPropCs.pNextOp = (rfc_radioOp_t*)&RF_cmdCountBranch;
RF_cmdCountBranch.pNextOp = (rfc_radioOp_t*)&EasyLink_cmdPropTx;
RF_cmdCountBranch.pNextOpIfOk = (rfc_radioOp_t*)&RF_cmdPropCs;
/* Customize the API commands with application specific defines */
RF_cmdPropCs.rssiThr = RSSI_THRESHOLD_DBM;
RF_cmdPropCs.csEndTime = (IDLE_TIME_US + 150) * 4; /* Add some margin */
// RF_cmdPropCs.csEndTime = (IDLE_TIME_US ) ; /* Add some margin */
RF_cmdCountBranch.counter = CS_RETRIES_WHEN_BUSY;
/* send packet */
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdNop, RF_PriorityNormal, &Wcallback, 0);
status = EasyLink_Status_Success;
RF_cmdNop.status = IDLE;
RF_cmdPropCs.status = IDLE;
RF_cmdCountBranch.status = IDLE;
RF_cmdPropTx.status = IDLE;
RF_cmdCountBranch.counter = CS_RETRIES_WHEN_BUSY;
// if (result & RF_EventLastCmdDone)
// {
// status = EasyLink_Status_Success;
// }
//Release the busyMutex
Semaphore_post(busyMutex);
return status;
}
是不是还有其他地方需要修改呢?
TI工程师们,怎么没人回复呀,急!谢谢谢谢谢谢。
//packet length to Tx includes address
RF_cmdPropTx.pktLen = txPacket->len + addrSize;
RF_cmdPropTx.pPkt = txBuffer;
RF_cmdCountBranch.pNextOp = (rfc_radioOp_t*)&RF_cmdPropTx;
修改后问题解决,发送完成后RF_cmdPropTx.status = PROP_DONE_OK。