TI中文支持网
TI专业的中文技术问题咨询交流网站

WakeOnRadio模式间切换

TI工程师您好。我使用wakeOnRadio的程序,在接受完数据后该如何切换速率呢?

/***** Function definitions *****/
/* RX task function. Executed in Task context by TI-RTOS when the scheduler starts. */
void *mainThread(void *arg0)
{
RF_Params rfParams;
RF_Params_init(&rfParams);

/* Open LED pins */
ledPinHandle = PIN_open(&ledPinState, pinTable);
if (ledPinHandle == NULL)
{
while(1);
}

/* Route out LNA active pin to LED1 */
PINCC26XX_setMux(ledPinHandle, Board_PIN_LED0, PINCC26XX_MUX_RFC_GPO0);

/* Create queue and data entries */
if (RFQueue_defineQueue(&dataQueue,
rxDataEntryBuffer,
sizeof(rxDataEntryBuffer),
NUM_DATA_ENTRIES,
MAX_LENGTH + NUM_APPENDED_BYTES))
{
/* Failed to allocate space for all data entries */
while(1);
}

/* Copy all RX options from the SmartRF Studio exported RX command to the RX Sniff command */
initializeSniffCmdFromRxCmd(&RF_cmdPropRxSniff, &RF_cmdPropRx);

/* Configure RX part of RX_SNIFF command */
RF_cmdPropRxSniff.pQueue = &dataQueue;
RF_cmdPropRxSniff.pOutput = (uint8_t*)&rxStatistics;
RF_cmdPropRxSniff.maxPktLen = MAX_LENGTH;

/* Discard ignored packets and CRC errors from Rx queue */
RF_cmdPropRxSniff.rxConf.bAutoFlushIgnored = 1;
RF_cmdPropRxSniff.rxConf.bAutoFlushCrcErr = 1;

/* Calculate datarate from prescaler and rate word */
uint32_t datarate = calculateSymbolRate(RF_cmdPropRadioDivSetup.symbolRate.preScale,
RF_cmdPropRadioDivSetup.symbolRate.rateWord);

/* Configure Sniff-mode part of the RX_SNIFF command */
configureSniffCmd(&RF_cmdPropRxSniff, WOR_MODE, datarate, WOR_WAKEUPS_PER_SECOND);

/* 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();

/* Enter main loop */
while(1)
{
/* Set next wakeup time in the future */
RF_cmdPropRxSniff.startTime += WOR_WAKE_UP_INTERVAL_RAT_TICKS(WOR_WAKEUPS_PER_SECOND);

/* 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:
/* Idle based on RSSI */
worStatistics.doneIdle++;
break;
case PROP_DONE_IDLETIMEOUT:
/* Idle based on PQT */
worStatistics.doneIdleTimeout++;
break;
case PROP_DONE_RXTIMEOUT:
/* Got valid preamble on the air, but did not find sync word */
worStatistics.doneRxTimeout++;
break;
case PROP_DONE_OK:
/* Received packet */
worStatistics.doneOk++;

//切换速率,进入完全接受模式

RxMode();
break;
default:
/* Unhandled status */
break;
};
}
}

void RxMode(void)

{

RF_Params rfParams;
RF_Params_init(&rfParams);

if( RFQueue_defineQueue(&dataQueue,
rxDataEntryBuffer,
sizeof(rxDataEntryBuffer),
NUM_DATA_ENTRIES,
MAX_LENGTH + NUM_APPENDED_BYTES))
{
/* Failed to allocate space for all data entries */
while(1);
}

/* Modify CMD_PROP_RX command for application needs */
RF_cmdPropRx.pQueue = &dataQueue; /* Set the Data Entity queue for received data */
RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1; /* Discard ignored packets from Rx queue */
RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1; /* Discard packets with CRC error from Rx queue */
RF_cmdPropRx.maxPktLen = MAX_LENGTH; /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
RF_cmdPropRx.pktConf.bRepeatOk = 1;
RF_cmdPropRx.pktConf.bRepeatNok = 1;

/* Request access to the radio */
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup_next, &rfParams);//发现设置没有作用,还是按原来速率

/* Set the frequency */
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);

/* Enter RX mode and stay forever in RX */
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, IRQ_RX_ENTRY_DONE);

Ack_Successful = false;

while(1)

{

if(Ack_Successful)

{

//进入发送模式

send_Ack();//这里没有想到Rx切换到Tx的方法,请指教下

}

}
}

Viki Shi:

已有工程师在http://www.deyisupport.com/question_answer/wireless_connectivity/f/45/t/140594.aspx 提供方法,请参考

user3895839:

回复 Viki Shi:

如下的指导不太理解。比如在

case PROP_DONE_OK:// 0x3400 /* Received packet */ worStatistics.doneOk++;

中增加该命令,RF_control(rfHandle,RF_CTRL_UPDATE_SETUP_CMD, NULL)

那么命令又是啥呢?我猜想此时命令应该是RX吧?又该如何设置成IDLE呢?

同时切换模式时,肯定需要用到RF_close和重新RF_Open吧。

 

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_openStart RX (using freq. 1)Exit RxRF_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 RxRF_control (RF_CTRL_UPDATE_SETUP_CMD) – change to freq.1Go to standby or atleast power down RF core (either RF_yield or set inactivityTimeout)Start Rx (using freq. 1)Exit Rx

Felix ZF:

回复 user3895839:

可以参考以下链接中关于RF_control 的使用方法和示例

http://www.deyisupport.com/question_answer/wireless_connectivity/f/45/t/140527.aspx

赞(0)
未经允许不得转载:TI中文支持网 » WakeOnRadio模式间切换
分享到: 更多 (0)