如何修改rfPacketRx例程,使RF在既定的超时时间到达时或收到有效数据后,结束本次的无线接收?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
对于该例程
For every packet received, Board_PIN_LED2 is toggled. The frequency and other RF settings can be modified using SmartRF Studio
每次接收到数据包之后就会改变Board_PIN_LED2 的状态
这是在下面的代码内完成的
void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
if (e & RF_EventRxEntryDone)
{
/* Toggle pin to indicate RX */
PIN_setOutputValue(ledPinHandle, Board_PIN_LED2,
!PIN_getOutputValue(Board_PIN_LED2));
/* Get current unhandled data entry */
currentDataEntry = RFQueue_getDataEntry();
/* Handle the packet data, located at ¤tDataEntry->data:
* - Length is the first byte with the current configuration
* - Data starts from the second byte */
packetLength = *(uint8_t*)(¤tDataEntry->data);
packetDataPointer = (uint8_t*)(¤tDataEntry->data + 1);
/* Copy the payload + the status byte to the packet variable */
memcpy(packet, packetDataPointer, (packetLength + 1));
RFQueue_nextEntry();
}
使RF在既定的超时时间到达时或收到有效数据后,结束本次的无线接收?
您可以尝试下面的代码
RF_cmdPropRxSniff.endTrigger.triggerType = TRIG_NOW;
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxSniff, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
RF_yield(rfHandle);//进入sleep
在此,您可以把endTrigger.triggerType设置成TRIG_REL_START,然后endTime设置成100ms。
则该命令会在开始执行100ms后结束,从RX状态切换到IDLE状态