TI中文支持网
TI专业的中文技术问题搜集分享网站

想创建2个任务,1个任务是间隔打开1个tx进行packet发送,1个任务是打开wakeonrx,但是tx任务时需要关闭tx发射,这个是调用rf close?同理想停止wakeonrx,也必须调rf_close?

想创建2个任务,1个任务是间隔打开1个tx进行packet发送,1个任务是打开wakeonrx,但是tx任务时需要关闭tx发射,这个是调用rf close?同理想停止wakeonrx,也必须调rf_close?

Viki Shi:

参考这边类似问题:e2e.ti.com/…/700708

user6129142:

回复 Viki Shi:

参考了如上链接,也将上面问题中的发送改成RF_cmdPropTxAdv命令,但rcv端还是接收不到信息。具体如下

send端:RF_Params rfParams;RF_Params_init(&rfParams);
/* 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;
/* Initialize TX_ADV command from TX command */initializeTxAdvCmdFromTxCmd(&RF_cmdPropTxAdv, &RF_cmdPropTx);/* Set application specific fields */RF_cmdPropTxAdv.pktLen = PAYLOAD_LENGTH +1; /* +1 for length byte */RF_cmdPropTxAdv.pPkt = packet;RF_cmdPropTxAdv.preTrigger.triggerType = TRIG_REL_START;RF_cmdPropTxAdv.preTime = WOR_PREAMBLE_TIME_RAT_TICKS(WOR_WAKEUPS_PER_SECOND);
/* Calculate datarate from prescaler and rate word */
#if defined(DeviceFamily_CC26X0R2)uint32_t datarate = calculateSymbolRate(RF_cmdPropRadioSetup.symbolRate.preScale,RF_cmdPropRadioSetup.symbolRate.rateWord);
#elseuint32_t datarate = calculateSymbolRate(RF_cmdPropRadioDivSetup.symbolRate.preScale,RF_cmdPropRadioDivSetup.symbolRate.rateWord);
#endif// DeviceFamily_CC26X0R2
/* Configure Sniff-mode part of the RX_SNIFF command */configureSniffCmd(&RF_cmdPropRxSniff, WOR_MODE, datarate, WOR_WAKEUPS_PER_SECOND);
/* Request access to the radio */
#if defined(DeviceFamily_CC26X0R2)RxrfHandle = RF_open(&RxrfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);
#elseRxrfHandle = RF_open(&RxrfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
#endif// DeviceFamily_CC26X0R2
/* Set frequency */RF_runCmd(RxrfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, &callback, 0);
/* Save the current radio time */RF_cmdPropRxSniff.startTime = RF_getCurrentTime();
/* Enter main loop */while(1){#if 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(RxrfHandle, (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++;break;default:/* Unhandled status */break;};
#endifpacket[0] = PAYLOAD_LENGTH;packet[1] = 0x1;packet[2] = 0x2;packet[3] = 0x3;RF_runCmd(RxrfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);}

rcv端:
参考rfWakeOnRadioRx代码,发现当send端注释#if 1中的内容(RF_cmdPropRxSniff)就能收到send的包;当#if 1中的内容(RF_cmdPropRxSniff)存在,rcv就收不到send的包。是不是这样不能直接切换?

赞(0)
未经允许不得转载:TI中文支持网 » 想创建2个任务,1个任务是间隔打开1个tx进行packet发送,1个任务是打开wakeonrx,但是tx任务时需要关闭tx发射,这个是调用rf close?同理想停止wakeonrx,也必须调rf_close?
分享到: 更多 (0)