CC1310怎么读取RSSI?
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.
http://dev.ti.com/tirex/content/simplelink_cc13x0_sdk_1_50_00_08/docs/tidrivers/doxygen/html/_r_f_8h.html#ac3fe0d39243fb6bbefe0216d958a6779
另外需要注意的是收到数据包后,除非bRepeatOk = 1,否则RF将不再处于接收模式。如果不处于接收模式,则无法读取RSSI。如果您想要您收到的数据包的RSSI,您可以从rfc_propRxOutput_t中读取RSSI。
你如果是希望读取接收数据包时的RSSI值,可以直接使用bAppendRssi,然后从rx buffer中读取
如果你是希望读取当前信道的信号强度,可以将RF设置到RX状态,然后使用RF_getRSSI进行读取
void *mainThread(void *arg0){ RF_Params rfParams; RF_Params_init(&rfParams);
/* Open LED pins */ ledPinHandle = PIN_open(&ledPinState, pinTable); if (ledPinHandle == NULL) { while(1); }
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 */ /* Set the Data Entity queue for received data */ RF_cmdPropRx.pQueue = &dataQueue; /* Discard ignored packets from Rx queue */ RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1; /* Discard packets with CRC error from Rx queue */ RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1; /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */ RF_cmdPropRx.maxPktLen = MAX_LENGTH; 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, &rfParams);
/* Set the frequency */ RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
/* Enter RX mode and stay forever in RX */// RF_EventMask terminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRx,// RF_PriorityNormal, &callback,// RF_EventRxEntryDone); RF_EventMask terminationReason = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
while(1) { value = RF_getRssi(rfHandle); }
switch(terminationReason) { case RF_EventCmdDone: // A radio operation command in a chain finished break; case RF_EventLastCmdDone: // A stand-alone radio operation command or the last radio // operation command in a chain finished. break; case RF_EventCmdCancelled: // Command cancelled before it was started; it can be caused // by RF_cancelCmd() or RF_flushCmd(). break; case RF_EventCmdAborted: // Abrupt command termination caused by RF_cancelCmd() or // RF_flushCmd(). break; case RF_EventCmdStopped: // Graceful command termination caused by RF_cancelCmd() or // RF_flushCmd(). break; default: // Uncaught error event while(1); }
uint32_t cmdStatus = ((volatile RF_Op*)&RF_cmdPropRx)->status; switch(cmdStatus) { case PROP_DONE_OK: // Packet received with CRC OK break; case PROP_DONE_RXERR: // Packet received with CRC error break; case PROP_DONE_RXTIMEOUT: // Observed end trigger while in sync search break; case PROP_DONE_BREAK: // Observed end trigger while receiving packet when the command is // configured with endType set to 1 break; case PROP_DONE_ENDED: // Received packet after having observed the end trigger; if the // command is configured with endType set to 0, the end trigger // will not terminate an ongoing reception break; case PROP_DONE_STOPPED: // received CMD_STOP after command started and, if sync found, // packet is received break; case PROP_DONE_ABORT: // Received CMD_ABORT after command started break; case PROP_ERROR_RXBUF: // No RX buffer large enough for the received data available at // the start of a packet break; case PROP_ERROR_RXFULL: // Out of RX buffer space during reception in a partial read break; case PROP_ERROR_PAR: // Observed illegal parameter break; case PROP_ERROR_NO_SETUP: // Command sent without setting up the radio in a supported // mode using CMD_PROP_RADIO_SETUP or CMD_RADIO_SETUP break; case PROP_ERROR_NO_FS: // Command sent without the synthesizer being programmed break; case PROP_ERROR_RXOVF: // RX overflow observed during operation break; default: // Uncaught error event - these could come from the // pool of states defined in rf_mailbox.h while(1); }
while(1);}
使用bAppendRssi和使用RF_getRssi()是两种不同的获取RSSI值的方式,二选一即可。
使用bAppendRssi是在每次收到的数据包后面附上接收时的RSSI数值,注意设置接收缓存时,留出足够空间存放RSSI值。
/* Packet RX Configuration */
#define DATA_ENTRY_HEADER_SIZE 8 /* Constant header size of a Generic Data Entry */
#define MAX_LENGTH 30 /* Max length byte the radio will accept */
#define NUM_DATA_ENTRIES 2 /* NOTE: Only two data entries supported at the moment */
#define NUM_APPENDED_BYTES 2 /* The Data Entries data field will contain:
* 1 Header byte (RF_cmdPropRx.rxConf.bIncludeHdr = 0x1)
* Max 30 payload bytes
* 1 status byte (RF_cmdPropRx.rxConf.bAppendStatus = 0x1) */
rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
MAX_LENGTH,
NUM_APPENDED_BYTES)];
使用RF_getRssi()读取当前RSSI值,不需要接收到数据包,只要射频处于接收状态,就可以读到当前信道上的信号强度。
通过下面的流程进入连续接收模式,但是怎么去读取RSSI,程序会一直在连续接收模式那里循环,无法进入后面的while(1)
void *mainThread(void *arg0)
{
RF_Params rfParams;
RF_Params_init(&rfParams);
/* Request access to the radio */
rfHandle = RF_open(&rfObject, &RF_prop,
(RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
/* Set the frequency */
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
/*设置为连续接收模式*/
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdRxTest, RF_PriorityNormal, NULL, 0);
while(1)
{
temp=RF_getRssi(rfHandle);
};
}