CC1310 RF_Open RF_close
TI工程师,您好。我正在修改WakeOnRadioRx的文件,我是在接受到数据后,有WOR模式切换到直接接受模式。我的思路如下:
void wor_wakeup(void)
{
/* Request access to the radio */
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
/* Set frequency */
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, &callback, 0);
/* Save the current radio time */
RF_cmdPropRxSniff.startTime = RF_getCurrentTime();
while(1)
{
packetLength = 0x0;
/* Set next wakeup time in the future */
RF_cmdPropRxSniff.startTime += WOR_WAKE_UP_INTERVAL_RAT_TICKS(WOR_WAKEUPS_PER_SECOND)*3;
//RF_cmdPropRxSniff.endTime = RF_cmdPropRxSniff.startTime + 160000;
/* Schedule RX */
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxSniff, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
/* Log RX_SNIFF status */
switch(RF_cmdPropRxSniff.status) {
case PROP_DONE_IDLE://0x3407
/* Idle based on RSSI */
worStatistics.doneIdle++;
// PIN_setOutputValue(ledPinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
break;
case PROP_DONE_IDLETIMEOUT://0x3409
/* Idle based on PQT */
worStatistics.doneIdleTimeout++;
//.endTrigger.triggerType = TRIG_ABSTIME,//TRIG_REL_START,//TRIG_NOW TRIG_NEVER TRIG_REL_START
// PIN_setOutputValue(ledPinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
break;
case PROP_DONE_RXTIMEOUT://0x3401
/* Got valid preamble on the air, but did not find sync word */
worStatistics.doneRxTimeout++;
// PIN_setOutputValue(ledPinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
break;
case PROP_DONE_OK:// 0x3400
/* Received packet */
worStatistics.doneOk++;
process_wakeupData();
if(packetLength)
{
PIN_setOutputValue(ledPinHandle, Board_PIN_LED0,!PIN_getOutputValue(Board_PIN_LED0));
RF_close(rfHandle);
return;
}
else
{
PIN_setOutputValue(ledPinHandle, Board_PIN_LED0,!PIN_getOutputValue(Board_PIN_LED0));
}
break;
default:
/* Unhandled status */
break;
};
}
}
发现程序一直卡在了RF_close(rfHandle);
请问这个是啥原因。另外是否有办法可以让WOR直接切换到一直接受模式,超时后再切换到WOR模式。谢谢!
1. 就别切了,直接把那个sniff的startTrigger改为TRIG_NOW, 基本也就是直接接收了.
startTrigger.triggerType = TRIG_NOW;
把如下的语句屏蔽掉
/* Set next wakeup time in the future */
RF_cmdPropRxSniff.startTime += WOR_WAKE_UP_INTERVAL_RAT_TICKS(WOR_WAKEUPS_PER_SECOND)*3;
void wor_wakeup(void)
{
/* Request access to the radio */
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
/* Set frequency */
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, &callback, 0);
/* Save the current radio time */
RF_cmdPropRxSniff.startTrigger.triggerType = TRIG_NOW;
RF_cmdPropRxSniff.startTime = RF_getCurrentTime();
while(1)
{
packetLength = 0x0;
/* Set next wakeup time in the future */
//RF_cmdPropRxSniff.startTime += WOR_WAKE_UP_INTERVAL_RAT_TICKS(WOR_WAKEUPS_PER_SECOND)*3;
//RF_cmdPropRxSniff.endTime = RF_cmdPropRxSniff.startTime + 160000;
/* Schedule RX */
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxSniff, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
/* Log RX_SNIFF status */
switch(RF_cmdPropRxSniff.status) {
case PROP_DONE_IDLE://0x3407
/* Idle based on RSSI */
worStatistics.doneIdle++;
// PIN_setOutputValue(ledPinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
break;
case PROP_DONE_IDLETIMEOUT://0x3409
/* Idle based on PQT */
worStatistics.doneIdleTimeout++;
//.endTrigger.triggerType = TRIG_ABSTIME,//TRIG_REL_START,//TRIG_NOW TRIG_NEVER TRIG_REL_START
// PIN_setOutputValue(ledPinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
break;
case PROP_DONE_RXTIMEOUT://0x3401
/* Got valid preamble on the air, but did not find sync word */
worStatistics.doneRxTimeout++;
// PIN_setOutputValue(ledPinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));
break;
case PROP_DONE_OK:// 0x3400
/* Received packet */
worStatistics.doneOk++;
process_wakeupData();
if(packetLength)
{
PIN_setOutputValue(ledPinHandle, Board_PIN_LED0,!PIN_getOutputValue(Board_PIN_LED0));
RF_close(rfHandle);
return;
}
else
{
PIN_setOutputValue(ledPinHandle, Board_PIN_LED0,!PIN_getOutputValue(Board_PIN_LED0));
}
break;
default:
/* Unhandled status */
break;
};
}
}
另外一种考量是使用RF_control(rfHandle, RF_CTRL_UPDATE_SETUP_CMD, NULL) 命令
可以借鉴如下做法:
Use the command RF_control(..,RF_CTRL_UPDATE_SETUP_CMD, ..) after defining the new frequency.
RF_CTRL_UPDATE_SETUP_CMD signals that the change will take effect immidiate on the next power cycle.
The flow could look like this:
RF_open
Start RX (using freq. 1)
Exit Rx
RF_control (RF_CTRL_UPDATE_SETUP_CMD) - change to freq.2
Go to standby or atleast power down RF core (either RF_yield or set inactivityTimeout)
Start Rx (using freq. 2)
Exit Rx
RF_control (RF_CTRL_UPDATE_SETUP_CMD) - change to freq.1
Go to standby or atleast power down RF core (either RF_yield or set inactivityTimeout)
Start Rx (using freq. 1)
Exit Rx
Driver documentation:
http://dev.ti.com/tirex/content/simplelink_cc13x0_sdk_1_30_00_06/docs/tidrivers/doxygen/html/_r_f_8h.html
Description of define RF_CTRL_UPDATE_SETUP_CMD :
Setting this control notifies RF that the setup command is to be updated, so that RF will take proper actions when executing the next setup command. Note the updated setup command will take effect in the next power up cycle when RF executes the setup command. Prior to updating the setup command, user should make sure all pending commands have completed.