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.

CC1310: Retrieving RSSI from RF Core

Part Number: CC1310

Hi,

I'm trying to access the RSSI value from the RF core on receipt of a packet.

I am using rfc_CMD_HS_RX_t, which, unlike rfc_CMD_PROP_RX_ADV_t, does not have a bAppendRssi attribute on its rxConf member. I am therefore trying to use RF_getRssi(Cc1310_CcRf_RfHandle_g) in the RF callback that fires on successful receipt of a packet, which I set up like this:

RxOperation = (RF_Op*)&RF_cmdRxHS;

RxHandle = RF_postCmd(
Cc1310_CcRf_RfHandle_g,
RxOperation,
RF_PriorityNormal,
&RxBlocksCallback,
IRQ_COMMAND_DONE
);

Assert(RxHandle >= 0) // Always succeeds

Within RxBlocksCallback(), which fires when I expect it to, I call RF_getRssi(Cc1310_CcRf_RfHandle_g) but it always returns RF_GET_RSSI_ERROR_VAL (-128)

Please advise.

TIA

Sean.

  • I did a test where I posted the HS RX command and then read the RSSI. Once the radio had entered RX state (status = 2) then RF_getRssi returned something other than RF_GET_RSSI_ERROR_VAL. I did not have the chance to check if the RSSI value is correct.

    /* Request access to the radio */
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdRadioSetup, &rfParams);
    
    /* Set the frequency */
    RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    
    /* Enter RX mode and stay forever in RX */
    RF_postCmd(rfHandle, (RF_Op*)&RF_cmdRxHS, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
    
    while(1)
    {
        rssi = RF_getRssi(rfHandle);
    }

    You can also find the RSSI of a received packet in the output structure for the CMD_HS_RX:

    //! \addtogroup hsRxOutput
    //! @{
    //! Output structure for CMD_HS_RX
    
    struct __RFC_STRUCT rfc_hsRxOutput_s {
       uint16_t nRxOk;                      //!<        Number of packets that have been received with CRC OK
       uint16_t nRxNok;                     //!<        Number of packets that have been received with CRC error
       uint16_t nRxAborted;                 //!<        Number of packets not received due to illegal length or address mismatch
       uint8_t nRxBufFull;                  //!<        Number of packets that have been received and discarded due to lack of buffer space
       int8_t lastRssi;                     //!<        RSSI of last received packet
       ratmr_t timeStamp;                   //!<        Time stamp of last received packet
    } __RFC_STRUCT_ATTR;

    static rfc_hsRxOutput_t rxStatistics;
    
    RF_cmdRxHS.pOutput = &rxStatistics;

    Siri

  • Hi Siri,

    Thanks for such a fast response. Unfortunately, this doesn't seem to work for me. I'm using rfc_hsRxOutput_s as you suggest:

    static RF_Op* RxOperation;
    static rfc_hsRxOutput_t RxStatsHs;
    ...
    RF_cmdRxHS.pOutput = &RxStatsHs;
    ...
    RxOperation = (RF_Op*)&RF_cmdRxHS;
    
    RxHandle = RF_postCmd(
            Cc1310_CcRf_RfHandle_g,
            RxOperation,
            RF_PriorityNormal,
            &RxBlocksCallback,
            RF_EventRxEntryDone
        );
        TiDrv_TiGpio_MyValidateAssert(RxHandle >= 0, 15);
    ...
    
    static void RxBlocksCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
        int8_t rssi;
        
        if(e & RF_EventRxEntryDone)
        {        
            rssi = RxStatsHs.lastRssi;
    
            TiDrv_TiGpio_TestPointsWriteData(0x11, TIDRV_GPIO_TESTPIN_DEBUG_ENCODE);
            // This line reports that RxStatsHs.lastRssi is always zero
            TiDrv_TiGpio_TestPointsWriteData(RxStatsHs.lastRssi, TIDRV_GPIO_TESTPIN_DEBUG_ENCODE);
            
            // These lines report a non-zero timeStamp, which increases every time RxBlocksCallback() is executed.
            TiDrv_TiGpio_TestPointsWriteData((uint8_t)(RxStatsHs.timeStamp >> 24), TIDRV_GPIO_TESTPIN_DEBUG_ENCODE);
            TiDrv_TiGpio_TestPointsWriteData((uint8_t)(RxStatsHs.timeStamp >> 16), TIDRV_GPIO_TESTPIN_DEBUG_ENCODE);
            TiDrv_TiGpio_TestPointsWriteData((uint8_t)(RxStatsHs.timeStamp >>  8), TIDRV_GPIO_TESTPIN_DEBUG_ENCODE);
            TiDrv_TiGpio_TestPointsWriteData((uint8_t)(RxStatsHs.timeStamp >>  0), TIDRV_GPIO_TESTPIN_DEBUG_ENCODE);
    ...
    }
        

    In the first few lines of callback(), I inspect RxStatsHs.lastRssi but the value is always 0x00. When I look at RxStatsHs.timeStamp, however, this has data in it that appears to be behaving correctly (i.e. it increases on every callback() execution). Any ideas what I'm doing wrong? I prefer the rfc_hsRxOutput_s approach rather than RF_getRssi() because I can be certain that the RF core is in the necessary state with rfc_hsRxOutput_s because the callback has just triggered, so lastRssi must be trustworthy.

    Do I need to apply any overrides to the PHY? Could this be related to differences between CC1310 silicon Rev A (2.0) and Rev B (2.1)?

    TIA

    Sean.

  • I have no idea why you are having problems. 

    Please provide the following info:

    1) Which SDK are you using?

    2) are you using rev. A or rev. B?

    Which High speed mode are you referring to? I have used the 4 mbps HSM which is used in the rfPacketERrorRate example.

    I know that there are some settings available on E2E for a ghs mode (1.5 mbps). This is not fully characterized, and if this is the one you are using, I will need you to provide me with all of your setting and overrides.

    BR

    Siri 

  • Hi Siri,

    Thanks for replying so soon again.

    I'm using SDK 4.20.00.05

    The CC1310 packaging has printed on it "7AI", which I believe means October 2017, which makes it a Rev B (2.1) chip.

    I am using the 1.5Mbps "ghs," with settings as follows:

    rfc_CMD_HS_RX_t RF_cmdRxHS =
    {
        .commandNo = CMD_HS_RX,
        .status = 0x0000,
        .pNextOp = 0x00000000,
        .startTime = 0x00000000,
        .startTrigger.triggerType = 0x0,
        .startTrigger.bEnaCmd = 0x0,
        .startTrigger.triggerNo = 0x0,
        .startTrigger.pastTrig = 0x0,
        .condition.rule = 0x1,
        .condition.nSkip = 0x0,
        .pktConf.bFsOff = 0,
        .pktConf.bUseCrc = 0,
        .pktConf.bVarLen = 0,
        .pktConf.bRepeatOk = 0,
        .pktConf.bRepeatNok = 0,
        .pktConf.addressMode = 0,
        .rxConf.bAutoFlushCrcErr = 0,
        .rxConf.bIncludeLen = 0,
        .rxConf.bIncludeCrc = 0,
        .rxConf.bAppendStatus = 0,
        .rxConf.bAppendTimestamp = 0,
        .maxPktLen = 0,
        .address0 = 0,
        .address1 = 0,
        .__dummy0 = 0,
        .endTrigger.triggerType = 1,
        .endTrigger.bEnaCmd = 0,
        .endTrigger.triggerNo = 0,
        .endTrigger.pastTrig = 0,
        .endTime = 0,
        .pQueue = 0,
        .pOutput = 0,    
    };
    
    ...
    
    RF_cmdRxHS.maxPktLen = 16;
    RF_cmdRxHS.startTrigger.triggerType = TRIG_NOW;
    RF_cmdRxHS.startTrigger.pastTrig = 1;
    RF_cmdRxHS.startTime = 0;
    RF_cmdRxHS.pOutput = &RxStatsHs;
            
    RxOperation = (RF_Op*)&RF_cmdRxHS;
    
    // 1.5Mbps
    
    // See SVS's post here for these trusted, official settings:
    // https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/628551/cc1310-receive-nothing-using-433m-1mbps-with-rf_cmdproptxadv-rf_cmdproprxadv/2363574#2363574
    const rfc_CMD_PROP_RADIO_DIV_SETUP_t Cc1310_Rf900vol_PHY_900M_750KSYM_4fsk_g =
    {
        // Use Smart RF Studio to generate rxBw, rateWord, deviation and preScale. 
        // Refer to RD1155 Rev 1.1 Section 3.2.4.2
    
        .commandNo = 0x3807,
        .status = 0x0000,
        .pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
        .startTime = 0x00000000,
        .startTrigger.triggerType = 0x0,
        .startTrigger.bEnaCmd = 0x0,
        .startTrigger.triggerNo = 0x0,
        .startTrigger.pastTrig = 0x0,
        .condition.rule = 0x1,
        .condition.nSkip = 0x0,
        .modulation.modType = 0x1,
        .modulation.deviation = 600,
        .symbolRate.preScale = 8,
        .symbolRate.rateWord = 262144,
        .rxBw = 0x30,
        .preamConf.nPreamBytes = 0x6,
        .preamConf.preamMode = 0x1,
        .formatConf.nSwBits = 0x20,
        .formatConf.bBitReversal = 0x0,
        .formatConf.bMsbFirst = 0x1,
        .formatConf.fecMode = 9,
        .formatConf.whitenMode = 0x0,
        .config.frontEndMode = 0x0,
        .config.biasMode = 0x1,
        .config.frontEndMode = 0x02, // Single-ended Mode RFN.
        .config.bNoFsPowerUp = 0x0,
        .txPower = 0x23F,
        .pRegOverride = (uint32_t*)PHY_900M_4_fsk_pOverrides,
        .centerFreq = 915,
        .intFreq = 0x0A66,
        .loDivider = 0x05,
    };
    
    // TI-RTOS RF Mode Object (includes patches for high speed operation)
    // https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz/f/156/p/628551/2363574#2363574
    static const RF_Mode RfSettings_RF_prop_hs_4fsk =
    {
        .rfMode       =  RF_MODE_PROPRIETARY_SUB_1,
        .cpePatchFxn  =  &rf_patch_cpe_ghs,
        .mcePatchFxn  =  &rf_patch_mce_ghs,
        .rfePatchFxn  =  &rf_patch_rfe_ghs,
    };
    
    static const uint32_t PHY_900M_4_fsk_pOverrides[] =
    {
        // PHY: Use MCE RAM patch, RFE RAM patch 
        MCE_RFE_OVERRIDE(1, 0, 0, 1, 0, 0),
        // Rx: Set anti-aliasing filter bandwidth to Maximum
        ADI_HALFREG_OVERRIDE(0,61,0xF,0x0),
        // Synth: Set recommended RTRIM to 7
        HW_REG_OVERRIDE(0x4038,0x0037),
        // Synth: Configure fine calibration setting
        HW_REG_OVERRIDE(0x4020,0x7F00),
        // Synth: Configure fine calibration setting
        HW_REG_OVERRIDE(0x4064,0x0040),
        // Synth: Set Fref to 4 MHz
        (uint32_t)0x000684A3,
        // Synth: Configure fine calibration setting
        (uint32_t)0xC0040141,             
        (uint32_t)0x0533B107, 
        // Synth: Set loop bandwidth after lock
        (uint32_t)0xA480583,              
        (uint32_t)0x7AB80603,
        // Synth: Configure VCO LDO (in ADI1, set VCOLDOCFG=0x9F to use voltage input reference)
        ADI_REG_OVERRIDE(1,4,0x9F),
        // Synth: Configure synth LDO (in ADI1, set SLDOCTL0.COMP_CAP=1)
        ADI_HALFREG_OVERRIDE(1,7,0x4,0x4),
        // Rx: Set LNA bias current trim offset to 3
        (uint32_t)0x00038883,
        // Rx: Set RSSI offset to adjust reported RSSI
        (uint32_t)0x00FB88A3,             
        // Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering
        (uint32_t)0x02010403,
        // Synth: Configure extra PLL filtering
        (uint32_t)0x00108463,
        // Synth: Increase synth programming timeout (0x04B0 RAT ticks = 300 us)
        (uint32_t)0x04B00243,
        //Configure thershold for Sync word detection
        HW_REG_OVERRIDE(0x5104,0x302B),
        //Set FIFO threshold
        (uint32_t) 0x002C82C3,            
        (uint32_t) 0x002882D3,
        // Rx: Do not freeze RSSI on sync found event
        HW_REG_OVERRIDE(0x6084,0x25F1),
        // ****PA Ramping overrides
        HW_REG_OVERRIDE(0x6088,0x4121),    
        HW_REG_OVERRIDE(0x608C,0x0A12), 
        // ****Length of CW tone
        HW_REG_OVERRIDE(0x52B0,0x00F0),    
        // DC estimation
        HW_REG_OVERRIDE(0x51F8,0x0F90),
        //Zero IF in TX
        (uint32_t) 0x00000343, 
        // Tx: Set PA trim to max (in ADI0, set PACTL0=0xF8)
        ADI_REG_OVERRIDE(0,12,0xF8),
    
        // Single-ended Operation
        ADI_HALFREG_OVERRIDE(0, 16, 0x7, 1), // Output on RFP
        
        /* RF Core monitors */
        (uint32_t)0x008F88B3, // For RAT_GPO1
        //                           MOD (MCE_GPO0) to RFC_GPO0           DEMOD (MCE_GPO1) to RFC_GPO1         TX (RAT_GPO0) to RFC_GPO2                RX (RAT_GPO1) to RFC_GPO3
        HW_REG_OVERRIDE(0x1110, RFC_DBELL_SYSGPOCTL_GPOCTL0_MCEGPO0 | RFC_DBELL_SYSGPOCTL_GPOCTL1_MCEGPO1 | RFC_DBELL_SYSGPOCTL_GPOCTL2_RATGPO0 | RFC_DBELL_SYSGPOCTL_GPOCTL3_RATGPO1),
        
        // End Override
        (uint32_t)0xFFFFFFFF,              
    };
    
    
    

    TIA

    Sean.

  • I tested with your overrides and settings (except using CRC and variable packet length), and everything still worked as expected.

    Settings and code is is below:

    #include <ti/devices/DeviceFamily.h>
    #include DeviceFamily_constructPath(driverlib/rf_mailbox.h)
    #include DeviceFamily_constructPath(driverlib/rf_hs_mailbox.h)
    #include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
    #include DeviceFamily_constructPath(driverlib/rf_hs_cmd.h)
    #include <ti/drivers/rf/RF.h>
    #include DeviceFamily_constructPath(rf_patches/rf_patch_mce_ghs.h)
    #include DeviceFamily_constructPath(rf_patches/rf_patch_rfe_ghs.h)
    #include DeviceFamily_constructPath(rf_patches/rf_patch_cpe_ghs.h)
    #include "smartrf_settings.h"
    
    RF_Mode RF_prop =
    {
         .rfMode       =  RF_MODE_PROPRIETARY_SUB_1,
         .cpePatchFxn  =  &rf_patch_cpe_ghs,
         .mcePatchFxn  =  &rf_patch_mce_ghs,
         .rfePatchFxn  =  &rf_patch_rfe_ghs,
    };
    
    // Overrides for CMD_PROP_RADIO_DIV_SETUP
    uint32_t pOverrides[] =
    {
        // PHY: Use MCE RAM patch, RFE RAM patch
        MCE_RFE_OVERRIDE(1, 0, 0, 1, 0, 0),
        // Rx: Set anti-aliasing filter bandwidth to Maximum
        ADI_HALFREG_OVERRIDE(0,61,0xF,0x0),
        // Synth: Set recommended RTRIM to 7
        HW_REG_OVERRIDE(0x4038,0x0037),
        // Synth: Configure fine calibration setting
        HW_REG_OVERRIDE(0x4020,0x7F00),
        // Synth: Configure fine calibration setting
        HW_REG_OVERRIDE(0x4064,0x0040),
        // Synth: Set Fref to 4 MHz
        (uint32_t)0x000684A3,
        // Synth: Configure fine calibration setting
        (uint32_t)0xC0040141,
        (uint32_t)0x0533B107,
        // Synth: Set loop bandwidth after lock
        (uint32_t)0xA480583,
        (uint32_t)0x7AB80603,
        // Synth: Configure VCO LDO (in ADI1, set VCOLDOCFG=0x9F to use voltage input reference)
        ADI_REG_OVERRIDE(1,4,0x9F),
        // Synth: Configure synth LDO (in ADI1, set SLDOCTL0.COMP_CAP=1)
        ADI_HALFREG_OVERRIDE(1,7,0x4,0x4),
        // Rx: Set LNA bias current trim offset to 3
        (uint32_t)0x00038883,
        // Rx: Set RSSI offset to adjust reported RSSI
        (uint32_t)0x00FB88A3,
        // Synth: Use 24 MHz XOSC as synth clock, enable extra PLL filtering
        (uint32_t)0x02010403,
        // Synth: Configure extra PLL filtering
        (uint32_t)0x00108463,
        // Synth: Increase synth programming timeout (0x04B0 RAT ticks = 300 us)
        (uint32_t)0x04B00243,
        //Configure thershold for Sync word detection
        HW_REG_OVERRIDE(0x5104,0x302B),
        //Set FIFO threshold
        (uint32_t) 0x002C82C3,
        (uint32_t) 0x002882D3,
        // Rx: Do not freeze RSSI on sync found event
        HW_REG_OVERRIDE(0x6084,0x25F1),
        // ****PA Ramping overrides
        HW_REG_OVERRIDE(0x6088,0x4121),
        HW_REG_OVERRIDE(0x608C,0x0A12),
        // ****Length of CW tone
        HW_REG_OVERRIDE(0x52B0,0x00F0),
        // DC estimation
        HW_REG_OVERRIDE(0x51F8,0x0F90),
        //Zero IF in TX
        (uint32_t) 0x00000343,
        // TX power override
        // Tx: Set PA trim to max (in ADI0, set PACTL0=0xF8)
        ADI_REG_OVERRIDE(0,12,0xF8),
        // End Override
        (uint32_t)0xFFFFFFFF,
    };
    
    // CMD_PROP_RADIO_DIV_SETUP
    rfc_CMD_PROP_RADIO_DIV_SETUP_t RF_cmdPropRadioDivSetup =
    {
        .commandNo = 0x3807,
        .status = 0x0000,
        .pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
        .startTime = 0x00000000,
        .startTrigger.triggerType = 0x0,
        .startTrigger.bEnaCmd = 0x0,
        .startTrigger.triggerNo = 0x0,
        .startTrigger.pastTrig = 0x0,
        .condition.rule = 0x1,
        .condition.nSkip = 0x0,
        .modulation.modType = 0x1,
        .modulation.deviation = 600,
        .symbolRate.preScale = 8,
        .symbolRate.rateWord = 262144,
        .rxBw = 48,
        .preamConf.nPreamBytes = 0x6,
        .preamConf.preamMode = 0x1,
        .formatConf.nSwBits = 0x20,
        .formatConf.bBitReversal = 0x0,
        .formatConf.bMsbFirst = 0x1,
        .formatConf.fecMode = 9,
        .formatConf.whitenMode = 0x0,
        .config.frontEndMode = 0x0,
        .config.biasMode = 0x1,
        .config.bNoFsPowerUp = 0x0,
        .txPower = 0xA63F,
        .pRegOverride = pOverrides,
        .centerFreq = 0x0364,
        .intFreq = 0x8000,
        .loDivider = 0x05,
    };
    
    // CMD_FS
    rfc_CMD_FS_t RF_cmdFs =
    {
        .commandNo = 0x0803,
        .status = 0x0000,
        .pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx
        .startTime = 0x00000000,
        .startTrigger.triggerType = 0x0,
        .startTrigger.bEnaCmd = 0x0,
        .startTrigger.triggerNo = 0x0,
        .startTrigger.pastTrig = 0x0,
        .condition.rule = 0x1,
        .condition.nSkip = 0x0,
        .frequency = 0x0364,
        .fractFreq = 0x0000,
        .synthConf.bTxMode = 0x0,
        .synthConf.refFreq = 0x0,
        .__dummy0 = 0x00,
        .__dummy1 = 0x00,
        .__dummy2 = 0x00,
        .__dummy3 = 0x0000,
    };
    
    // CMD_RX_HS
    rfc_CMD_HS_RX_t RF_cmdRxHS =
    {
        .commandNo = CMD_HS_RX,
        .status = 0x0000,
        .pNextOp = 0x00000000,
        .startTime = 0x00000000,
        .startTrigger.triggerType = 0x0,
        .startTrigger.bEnaCmd = 0x0,
        .startTrigger.triggerNo = 0x0,
        .startTrigger.pastTrig = 0x0,
        .condition.rule = 0x1,
        .condition.nSkip = 0x0,
        .pktConf.bFsOff = 0,
        .pktConf.bUseCrc = 1,
        .pktConf.bVarLen = 1,
        .pktConf.bRepeatOk = 0,
        .pktConf.bRepeatNok = 0,
        .pktConf.addressMode = 0,
        .rxConf.bAutoFlushCrcErr = 0,
        .rxConf.bIncludeLen = 1,
        .rxConf.bIncludeCrc = 0,
        .rxConf.bAppendStatus = 0,
        .rxConf.bAppendTimestamp = 0,
        .maxPktLen = 0,
        .address0 = 0,
        .address1 = 0,
        .__dummy0 = 0,
        .endTrigger.triggerType = 1,
        .endTrigger.bEnaCmd = 0,
        .endTrigger.triggerNo = 0,
        .endTrigger.pastTrig = 0,
        .endTime = 0,
        .pQueue = 0,
        .pOutput = 0,
    };
    
    // CMD_TX_HS
    rfc_CMD_HS_TX_t RF_cmdTxHS =
    {
        .commandNo = 0x3841,
        .status = 0x0000,
        .pNextOp = 0x00000000,
        .startTime = 0x00000000,
        .startTrigger.triggerType = 0x0,
        .startTrigger.bEnaCmd = 0x0,
        .startTrigger.triggerNo = 0x0,
        .startTrigger.pastTrig = 0x0,
        .condition.rule = 0x1,
        .condition.nSkip = 0x0,
        .pktConf.bFsOff = 0x0,
        .pktConf.bUseCrc = 0x1,
        .pktConf.bVarLen = 0x1,
        .pQueue = 0,
    };
    
    //----------------------------------------------------------------------------
    // TX:
    //----------------------------------------------------------------------------
    
    /***** Includes *****/
    /* Standard C Libraries */
    #include <stdlib.h>
    #include <unistd.h>
    
    /* TI Drivers */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/pin/PINCC26XX.h>
    
    /* Driverlib Header files */
    #include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
    
    /* Board Header files */
    #include "Board.h"
    
    /* Application specific files */
    #include "smartrf_settings/smartrf_settings.h"
    #include "RFQueue.h"
    
    #include <ti/drivers/Power.h>
    #include <ti/drivers/power/PowerCC26XX.h>
    
    /* Packet TX Configuration */
    #define PAYLOAD_LENGTH          15
    
    #define DATA_ENTRY_HEADER_SIZE  8               // Constant header size of a Generic Data Entry
    #define MAX_LENGTH              PAYLOAD_LENGTH  // Set the length of the data entry
    #define NUM_DATA_ENTRIES_TX     1
    #define NUM_APPENDED_BYTES_TX   0
    #define PACKET_INTERVAL         50000  /* Set packet interval to 50000 us or 50 ms */
    
    /***** Variable declarations *****/
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    
    /* Pin driver handle */
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;
    
    static uint8_t *pPacket;
    
    #pragma DATA_ALIGN (txDataEntryBuffer, 4);
    static uint8_t txDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES_TX, MAX_LENGTH, NUM_APPENDED_BYTES_TX)];
    
    static dataQueue_t dataQueue;
    static rfc_dataEntryGeneral_t* currentDataEntry;
    static uint16_t counter = 0;
    
    PIN_Config pinTable[] =
    {
        Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PIN_TERMINATE
    };
    
    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,
                                txDataEntryBuffer,
                                sizeof(txDataEntryBuffer),
                                NUM_DATA_ENTRIES_TX,
                                MAX_LENGTH + NUM_APPENDED_BYTES_TX))
        {
            /* Failed to allocate space for all data entries */
            while(true);
        }
    
        RF_cmdTxHS.pQueue = &dataQueue;
        RF_cmdTxHS.startTrigger.triggerType = TRIG_NOW;
    
        currentDataEntry = (rfc_dataEntryGeneral_t*)&txDataEntryBuffer;
        currentDataEntry->length = PAYLOAD_LENGTH;
        pPacket = &currentDataEntry->data;
    
        /* 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);
    
        while(counter++ < 1000)
        {
            uint8_t i;
            for (i = 0; i < PAYLOAD_LENGTH; i++)
            {
                pPacket[i] = i + 1;
            }
    
            /* Send packet */
            RF_EventMask terminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdTxHS, RF_PriorityNormal, NULL, 0);
    
            PIN_setOutputValue(ledPinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1));
    
            /* Power down the radio */
            RF_yield(rfHandle);
    
            /* Sleep for PACKET_INTERVAL us */
            usleep(PACKET_INTERVAL);
        }
        while(1);
    }
    
    //----------------------------------------------------------------------------
    // RX:
    //----------------------------------------------------------------------------
    
    /***** Includes *****/
    /* Standard C Libraries */
    #include <stdlib.h>
    
    /* TI Drivers */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>
    
    /* Driverlib Header files */
    #include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
    
    /* Board Header files */
    #include "Board.h"
    
    /* Application Header files */
    #include "RFQueue.h"
    #include "smartrf_settings/smartrf_settings.h"
    
    /***** Defines *****/
    
    /* Packet RX Configuration */
    #define DATA_ENTRY_HEADER_SIZE 8   /* Constant header size of a Generic Data Entry */
    #define MAX_LENGTH             16  /* Max length byte the radio will accept.
                                        * Must be set to 1 larger than PAYLOAD_LENGTH in the rfPacketTx example */
    #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:
                                        * 2 length bytes. No other bytes appended */
    
    /***** Prototypes *****/
    static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
    
    /***** Variable declarations *****/
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    
    /* Pin driver handle */
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;
    
    /* Buffer which contains all Data Entries for receiving data.
     * Pragmas are needed to make sure this buffer is 4 byte aligned (requirement from the RF Core) */
    #pragma DATA_ALIGN (rxDataEntryBuffer, 4);
    static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES, MAX_LENGTH, NUM_APPENDED_BYTES)];
    
    /* Receive dataQueue for RF Core to fill in data */
    static dataQueue_t dataQueue;
    static rfc_dataEntryGeneral_t* currentDataEntry;
    static uint16_t packetLength;
    static uint8_t* packetDataPointer;
    static rfc_propRxOutput_t rxStatistics;
    static int8_t rssi;
    
    static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 2]; /* The 2-byte long length is stored in a separate variable */
    
    PIN_Config pinTable[] =
    {
        Board_PIN_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PIN_TERMINATE
    };
    
    /***** Function definitions *****/
    
    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_RX_HS command for application needs */
        /* Set the Data Entity queue for received data */
        RF_cmdRxHS.pQueue = &dataQueue;
        /* Discard packets with CRC error from Rx queue */
        RF_cmdRxHS.rxConf.bAutoFlushCrcErr = 1;
        /* Discard packets with CRC error from Rx queue */
        RF_cmdRxHS.rxConf.bAutoFlushCrcErr = 1;
        /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
        RF_cmdRxHS.maxPktLen = MAX_LENGTH;
        RF_cmdRxHS.pktConf.bRepeatOk = 1;
        RF_cmdRxHS.pktConf.bRepeatNok = 1;
        RF_cmdRxHS.pOutput = (rfc_hsRxOutput_t*)&rxStatistics;
    
        /* 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_cmdRxHS, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
    
        while(1);
    }
    
    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 &currentDataEntry->data */
            packetLength      = ((*(uint8_t*)(&currentDataEntry->data + 1)) << 8) |
                                 (*(uint8_t*)(&currentDataEntry->data));
            packetDataPointer = (uint8_t*)(&currentDataEntry->data + 2);
    
            /* Copy the payload to the packet variable */
            memcpy(packet, packetDataPointer, packetLength);
    
            rssi = rxStatistics.lastRssi;
    
            RFQueue_nextEntry();
        }
    }
    
    
    

    Siri