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.

LAUNCHXL-CC1310: TMS320F28379D follow up

Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: SYSBIOS, TMS320F28379D

Hi Team

Good day.

My customer follow up the last post

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz/f/sub-1-ghz-forum/976410/launchxl-cc1310-tms320f28379d-problem

information:


So for the past 2 weeks I have tried to use the rfPacketRx example with your advice on replacing where to post and open the rfHandle.
I have also tried integrating the semaphore function however, I find my program still halting and not receiving anything after the first load of data.
When I had a look to see where it was halting, it was at line 276 (See code as attached), where the program goes into an uncaught error event state, as described in rf_mailbox.h.

Do you know of a way I can get around this?


/*
* Copyright (c) 2019, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/***** Includes *****/
/* Standard C Libraries */
#include <stdlib.h>

/* TI Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
//#include <semaphore.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <BIOS.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 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) */

//static Semaphore_Struct semHandle;
static Semaphore_Handle semHandle;

//sem_t semHandle;
uint32_t cmdStatus;
/***** 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;

int potatotrack = 0;
/* 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) */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_ALIGN (rxDataEntryBuffer, 4);
static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(
NUM_DATA_ENTRIES, MAX_LENGTH, NUM_APPENDED_BYTES)];
#elif defined(__IAR_SYSTEMS_ICC__)
#pragma data_alignment = 4
static uint8_t
rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
MAX_LENGTH,
NUM_APPENDED_BYTES)];
#elif defined(__GNUC__)
static uint8_t
rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
MAX_LENGTH,
NUM_APPENDED_BYTES)]
__attribute__((aligned(4)));
#else
#error This compiler is not supported.
#endif

/* Receive dataQueue for RF Core to fill in data */
static dataQueue_t dataQueue;
static rfc_dataEntryGeneral_t* currentDataEntry;
static uint8_t packetLength;
static uint8_t* packetDataPointer;

static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */

/*
* Application LED pin configuration table:
* - All LEDs board LEDs are off.
*/
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)
{
// sem_init(&semHandle, 0, 0);
potatotrack = 1;
RF_Params rfParams;
RF_Params_init(&rfParams);

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

potatotrack = 3;

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)
;
}

potatotrack = 4;
/* 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;

potatotrack = 5;
/* Request access to the radio */
#if defined(DeviceFamily_CC26X0R2)
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);
#else
rfHandle = RF_open(&rfObject, &RF_prop,
(RF_RadioSetup*) &RF_cmdPropRadioDivSetup, &rfParams);
#endif// DeviceFamily_CC26X0R2

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

potatotrack = 61;
/* Enter RX mode and stay forever in RX */
RF_EventMask terminationReason = RF_postCmd(rfHandle,
(RF_Op*) &RF_cmdPropRx,
RF_PriorityNormal, &callback,
RF_EventRxEntryDone);
potatotrack = 7;

switch (terminationReason)
{
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)
;
}

potatotrack = 8;

cmdStatus = ((volatile RF_Op*) &RF_cmdPropRx)->status;
switch (cmdStatus)
{
case PROP_DONE_OK:
// Packet received with CRC OK
potatotrack = 81;
break;
case PROP_DONE_RXERR:
// Packet received with CRC error
potatotrack = 82;
break;
case PROP_DONE_RXTIMEOUT:
// Observed end trigger while in sync search
potatotrack = 83;
break;
case PROP_DONE_BREAK:
// Observed end trigger while receiving packet when the command is
// configured with endType set to 1
potatotrack = 84;
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
potatotrack = 85;
break;
case PROP_DONE_STOPPED:
// received CMD_STOP after command started and, if sync found,
// packet is received
potatotrack = 86;
break;
case PROP_DONE_ABORT:
// Received CMD_ABORT after command started
potatotrack = 87;
break;
case PROP_ERROR_RXBUF:
// No RX buffer large enough for the received data available at
// the start of a packet
potatotrack = 88;
break;
case PROP_ERROR_RXFULL:
// Out of RX buffer space during reception in a partial read
potatotrack = 89;
break;
case PROP_ERROR_PAR:
// Observed illegal parameter
potatotrack = 810;
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
potatotrack = 811;
break;
case PROP_ERROR_NO_FS:
// Command sent without the synthesizer being programmed
potatotrack = 812;
break;
case PROP_ERROR_RXOVF:
// RX overflow observed during operation
potatotrack = 813;
break;
default:
// Uncaught error event - these could come from the
// pool of states defined in rf_mailbox.h
potatotrack = 814;
while (1)
;
}

potatotrack = 9;

while (1)
{

Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);

}
}

void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
potatotrack = 91;
if (e & RF_EventRxEntryDone)
{
potatotrack = 10;
/* Toggle pin to indicate RX */
PIN_setOutputValue(ledPinHandle, Board_PIN_LED2,
!PIN_getOutputValue(Board_PIN_LED2));
potatotrack = 11;
/* Get current unhandled data entry */
currentDataEntry = RFQueue_getDataEntry();
potatotrack = 12;
/* Handle the packet data, located at &currentDataEntry->data:
* - Length is the first byte with the current configuration
* - Data starts from the second byte */
packetLength = *(uint8_t*) (&currentDataEntry->data);
packetDataPointer = (uint8_t*) (&currentDataEntry->data + 1);

potatotrack = 13;
/* Copy the payload + the status byte to the packet variable */
memcpy(packet, packetDataPointer, (packetLength + 1));
potatotrack = 14;
RFQueue_nextEntry();
potatotrack = 15;
Semaphore_post(semHandle);
}
}

Regards

Aosker

  • I took the rfPacketRX and tested something similar with the default 50 kbps settings.

    Everytime a packet was received, the LED toggled, before it went back to pending on a semaphore.

    Code is shown below:

    /***** Includes *****/
    /* Standard C Libraries */
    #include <stdlib.h>
    
    /* TI Drivers */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>
    
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Semaphore.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             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) */
    
    static Semaphore_Struct rxSemaphore;
    static Semaphore_Handle rxSemaphoreHandle;
    
    /***** 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) */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_ALIGN (rxDataEntryBuffer, 4);
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                      MAX_LENGTH,
                                                      NUM_APPENDED_BYTES)];
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma data_alignment = 4
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                      MAX_LENGTH,
                                                      NUM_APPENDED_BYTES)];
    #elif defined(__GNUC__)
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                      MAX_LENGTH,
                                                      NUM_APPENDED_BYTES)]
                                                      __attribute__((aligned(4)));
    #else
    #error This compiler is not supported.
    #endif
    
    /* Receive dataQueue for RF Core to fill in data */
    static dataQueue_t dataQueue;
    static rfc_dataEntryGeneral_t* currentDataEntry;
    static uint8_t packetLength;
    static uint8_t* packetDataPointer;
    
    
    static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */
    
    /*
     * Application LED pin configuration table:
     *   - All LEDs board LEDs are off.
     */
    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);
    
        Semaphore_construct(&rxSemaphore, 0, NULL);
        rxSemaphoreHandle = Semaphore_handle(&rxSemaphore);
    
        /* 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 */
    #if defined(DeviceFamily_CC26X0R2)
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);
    #else
        rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    #endif// DeviceFamily_CC26X0R2
    
        /* 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_cmdPropRx, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
    
       while(1)
       {
           Semaphore_pend(rxSemaphoreHandle, BIOS_WAIT_FOREVER);
           PIN_setOutputValue(ledPinHandle, Board_PIN_LED2, !PIN_getOutputValue(Board_PIN_LED2));
       }
    
    }
    
    void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
        if (e & RF_EventRxEntryDone)
        {
            /* Get current unhandled data entry */
            currentDataEntry = RFQueue_getDataEntry();
    
            /* Handle the packet data, located at &currentDataEntry->data:
             * - Length is the first byte with the current configuration
             * - Data starts from the second byte */
            packetLength      = *(uint8_t*)(&currentDataEntry->data);
            packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1);
    
            /* Copy the payload + the status byte to the packet variable */
            memcpy(packet, packetDataPointer, (packetLength + 1));
    
            RFQueue_nextEntry();
    
            Semaphore_post(rxSemaphoreHandle);
        }
    }
    

  • Thanks so much for that Siri.
    Now when I try to run your code, it gets stuck at this while loop, waiting for the rxSemaphoreHandle.


    while(1)
    {
    Semaphore_pend(rxSemaphoreHandle, BIOS_WAIT_FOREVER);
    PIN_setOutputValue(ledPinHandle, Board_PIN_LED2, !PIN_getOutputValue(Board_PIN_LED2));
    }

    I had a look at what's in the rxSemaphoreHandle and nothing seems to be changing about it. I thought it might be the fact that we're using a semaphore here, so I tried commenting it out and running it again. It still gets stuck at the end of the code, given that this while loop is at the end of the main method.

    So I have a reeeeeeal odd hunch this might be the lack of a loopback setting (which I'm not too sure where to look to setup) or this receiver isn't matching the transmitter's data rate.

    In either case, I have attached the code I am using for the transmitter.

    As a aside note, when I run Smart RF Studio's Packet Rx example while my other side is transmitting, I'm able to receive packets nice and easily. Albeit with a relatively high error rate, I am still receiving things!

    Thanks so much in advance, but please do tell me what I am missing from this code!

  • /*
     * Copyright (c) 2019, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /***** 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>
    //#include <ti/drivers/SPI.h>
    //
    ///* Driverlib Header files */
    //#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
    //
    ///* Board Header files */
    //#include "Board.h"
    //#include "smartrf_settings/smartrf_settings.h"
    /***** Defines *****/
    
    /* Do power measurement */
    //#define POWER_MEASUREMENT
    /* Packet TX Configuration */
    #define PAYLOAD_LENGTH      100
    #ifdef POWER_MEASUREMENT
    #define PACKET_INTERVAL     5  /* For power measurement set packet interval to 5s */
    #else
    #define PACKET_INTERVAL     500000  /* Set packet interval to 500000us or 500ms */
    #endif
    
    #define SPI_MSG_LENGTH  (40)
    #define SLAVE_MSG       ("123456 ")
    /***** Prototypes *****/
    
    //  ======== spislave.c ========
    #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>
    //#include <ti/drivers/SPI.h>
    
    /* Driverlib Header files */
    #include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
    
    /* Board Header files */
    //#include "Board.h"
    #include "smartrf_settings/smartrf_settings.h"
    //#include "RFQueue.c"
    
    #include <stddef.h>
    #include <stdint.h>
    #include <string.h>
    
    /* POSIX Header files */
    #include <pthread.h>
    #include <semaphore.h>
    #include <unistd.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/SPI.h>
    #include <ti/display/Display.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    #define THREADSTACKSIZE (1024)
    
    #define SPI_MSG_LENGTH  (40)
    #define SLAVE_MSG       ("123456 ")
    
    #define MAX_LOOP        (1000)
    int potatotrack = 0;
    static Display_Handle display;
    
    unsigned char slaveRxBuffer[SPI_MSG_LENGTH];
    unsigned char slaveTxBuffer[SPI_MSG_LENGTH];
    
    /* Semaphore to block slave until transfer is complete */
    sem_t slaveSem;
    
    uint16_t phaseBI;
    uint16_t phaseAI;
    uint16_t DCLinkV;
    uint16_t CoilT;
    uint16_t DCLinkI;
    uint16_t AuxT;
    uint16_t BattT;
    
    uint16_t hall1;
    uint16_t hall2;
    uint16_t hall3;
    
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    RF_Params rfParams;
    
    /* Pin driver handle */
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;
    
    static uint8_t packet[PAYLOAD_LENGTH];
    static uint16_t seqNumber;
    
    //SPI STUFF
    SPI_Handle slaveSpi;
    SPI_Params spiParams;
    SPI_Transaction transaction;
    uint32_t i;
    bool transferOK;
    int32_t status;
    /*
    
     * Application LED pin configuration table:
     *   - All LEDs board LEDs are off.
     */
    
    PIN_Config pinTable[] =
            {
            Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL
                      | PIN_DRVSTR_MAX,
    #ifdef POWER_MEASUREMENT
    #if defined(Board_CC1350_LAUNCHXL)
              Board_DIO30_SWPWR | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    #endif
    #endif
              PIN_TERMINATE };
    
    /*
     *  ======== transferCompleteFxn ========
     *  Callback function for SPI_transfer().
     */
    void transferCompleteFxn(SPI_Handle handle, SPI_Transaction *transaction)
    {
        sem_post(&slaveSem);
    }
    
    /*
     * ======== slaveThread ========
     *  Slave SPI sends a message to master while simultaneously receiving a
     *  message from the master.
     */
    void *slaveThread(void *arg0)
    {
    
        potatotrack = 1;
        /*
         * Board_SPI_MASTER_READY & Board_SPI_SLAVE_READY are GPIO pins connected
         * between the master & slave.  These pins are used to synchronize
         * the master & slave applications via a small 'handshake'.  The pins
         * are later used to synchronize transfers & ensure the master will not
         * start a transfer until the slave is ready.  These pins behave
         * differently between spimaster & spislave examples:
         *
         * spislave example:
         *     * Board_SPI_MASTER_READY is configured as an input pin.  During the
         *       'handshake' this pin is read & a high value will indicate the
         *       master is ready to run the application.  Afterwards, the pin is
         *       read to determine if the master has already opened its SPI pins.
         *       The master will pull this pin low when it has opened its SPI.
         *
         *     * Board_SPI_SLAVE_READY is configured as an output pin.  During the
         *       'handshake' this pin is changed from low to high output.  This
         *       notifies the master the slave is ready to run the application.
         *       Afterwards, the pin is used by the slave to notify the master it
         *       is ready for a transfer.  When ready for a transfer, this pin will
         *       be pulled low.
         *
         * Below we set Board_SPI_MASTER_READY & Board_SPI_SLAVE_READY initial
         * conditions for the 'handshake'.
         */
        GPIO_setConfig(Board_SPI_SLAVE_READY, GPIO_CFG_OUTPUT | GPIO_CFG_OUT_LOW);
        GPIO_setConfig(Board_SPI_MASTER_READY, GPIO_CFG_INPUT);
        potatotrack = 2;
        /*
         * Handshake - Set Board_SPI_SLAVE_READY high to indicate slave is ready
         * to run.  Wait for Board_SPI_MASTER_READY to be high.
         */
        GPIO_write(Board_SPI_SLAVE_READY, 1);
    //    while (GPIO_read(Board_SPI_MASTER_READY) == 0) {}
        potatotrack = 3;
        /*
         * Create synchronization semaphore; this semaphore will block the slave
         * until a transfer is complete.  The slave is configured in callback mode
         * to allow us to configure the SPI transfer & then notify the master the
         * slave is ready.  However, we must still wait for the current transfer
         * to be complete before setting up the next.  Thus, we wait on slaveSem;
         * once the transfer is complete the callback function will unblock the
         * slave.
         */
        status = sem_init(&slaveSem, 0, 0);
        potatotrack = 4;
        if (status != 0)
        {
    //        Display_printf(display, 0, 0, "Error creating slaveSem\n");
    
            while (1)
                ;
        }
        potatotrack = 5;
    
        /*
         * Wait until master SPI is open.  When the master is configuring SPI pins
         * the clock may toggle from low to high (or high to low depending on
         * polarity).  If using 3-pin SPI & the slave has been opened before the
         * master, clock transitions may cause the slave to shift bits out assuming
         * it is an actual transfer.  We can prevent this behavior by opening the
         * master first & then opening the slave.
         */
    //    while (GPIO_read(Board_SPI_MASTER_READY)) {}
        potatotrack = 6;
        /*
         * Open SPI as slave in callback mode; callback mode is used to allow us to
         * configure the transfer & then set Board_SPI_SLAVE_READY high.
         */
        SPI_Params_init(&spiParams);
        potatotrack = 7;
    //        spiParams.frameFormat = SPI_POL1_PHA0;
        spiParams.frameFormat = SPI_POL1_PHA1; // gets the old alg going
    //    spiParams.frameFormat = SPI_POL0_PHA1;
        potatotrack = 8;
        spiParams.mode = SPI_SLAVE;
        potatotrack = 9;
    //    spiParams.transferCallbackFxn = transferCompleteFxn;
        potatotrack = 10;
    //    spiParams.bitRate = 500000;
    //    potatotrack = 111;
    //    spiParams.transferMode = SPI_MODE_CALLBACK;
        potatotrack = 11;
        slaveSpi = SPI_open(Board_SPI_SLAVE, &spiParams);
        potatotrack = 12;
        if (slaveSpi == NULL)
        {
    //        Display_printf(display, 0, 0, "Error initializing slave SPI\n");
            while (1)
                ;
        }
        else
        {
            Display_printf(display, 0, 0, "Slave SPI initialized\n");
        }
        potatotrack = 13;
    
        /* Copy message to transmit buffer */
        strncpy((char *) slaveTxBuffer, SLAVE_MSG, SPI_MSG_LENGTH);
        potatotrack = 14;
        i = 0;
    //    memset((void *) slaveRxBuffer, 0, SPI_MSG_LENGTH);
    //    for (i = 0; i < MAX_LOOP; i++) {
        rfHandle = RF_open(&rfObject, &RF_prop,
                           (RF_RadioSetup*) &RF_cmdPropRadioDivSetup,
                           &rfParams);
        potatotrack = 111;
        /* Set the frequency */
        RF_postCmd(rfHandle, (RF_Op*) &RF_cmdFs, RF_PriorityNormal, NULL, 0);
        potatotrack = 12;
        while (true)
        {
            /* Initialize slave SPI transaction structure */
    //        slaveTxBuffer[sizeof(SLAVE_MSG) - 1] = (i % 10) + '0';
            potatotrack = 15;
            memset((void *) slaveRxBuffer, 0, SPI_MSG_LENGTH);
            potatotrack = 16;
            transaction.count = SPI_MSG_LENGTH;
            potatotrack = 17;
            transaction.txBuf = (void *) slaveTxBuffer;
            potatotrack = 18;
            transaction.rxBuf = (void *) slaveRxBuffer;
            potatotrack = 19;
            /* Toggle on user LED, indicating a SPI transfer is in progress */
            GPIO_toggle(Board_GPIO_LED1);
            potatotrack = 20;
    
    
            RF_Params_init(&rfParams);
    
            potatotrack = 51;
            /* Open LED pins */
    //        ledPinHandle = PIN_open(&ledPinState, pinTable);
    //        potatotrack = 61;
    //        if (ledPinHandle == NULL)
    //        {
    //            while (1)
    //            {
    //                potatotrack = 661;
    //            }
    //        }
            potatotrack = 71;
            RF_cmdPropTx.pktLen = PAYLOAD_LENGTH;
            potatotrack = 81;
            RF_cmdPropTx.startTrigger.triggerType = TRIG_NOW;
            potatotrack = 91;
            // Init SPI
            // Set the SPI up for Slave mode
            // and SPI_MODE_BLOCKING.
            potatotrack = 101;
            /* Request access to the radio */
    
    
    //
    //        while (1)
    //        {
    //            memset((void *) slaveRxBuffer, 0, SPI_MSG_LENGTH);
    //            potatotrack = 13;
    //            transaction.count = SPI_MSG_LENGTH;
    //            potatotrack = 14;
    //            transaction.txBuf = (void *) slaveTxBuffer;
    //            potatotrack = 15;
    //            transaction.rxBuf = (void *) slaveRxBuffer;
    //            potatotrack = 16;
    //            // Read the bytes you want to read over SPI
    //
    //
    //        }
    
            /*
             * Setup SPI transfer; Board_SPI_SLAVE_READY will be set to notify
             * master the slave is ready.
             */
            transferOK = SPI_transfer(slaveSpi, &transaction);
            potatotrack = 21;
    
            if (transferOK)
            {
                GPIO_write(Board_SPI_SLAVE_READY, 0);
                potatotrack = 211;
    //             Wait until transfer has completed
    //            sem_wait(&slaveSem);
                potatotrack = 22;
    
    //             * Drive Board_SPI_SLAVE_READY high to indicate slave is not ready
    //             * for another transfer yet.
    
                GPIO_write(Board_SPI_SLAVE_READY, 1);
                potatotrack = 23;
    
                phaseAI = slaveRxBuffer[0] * 256 + slaveRxBuffer[1];
                phaseBI = slaveRxBuffer[2] * 256 + slaveRxBuffer[3];
    
                CoilT = slaveRxBuffer[4] * 256 + slaveRxBuffer[5];
                BattT = slaveRxBuffer[6] * 256 + slaveRxBuffer[7];
                AuxT = slaveRxBuffer[8] * 256 + slaveRxBuffer[9];
    
                hall1 = slaveRxBuffer[10] * 256 + slaveRxBuffer[11];
                hall2 = slaveRxBuffer[12] * 256 + slaveRxBuffer[13];
                hall3 = slaveRxBuffer[14] * 256 + slaveRxBuffer[15];
    
                DCLinkI = slaveRxBuffer[16] * 256 + slaveRxBuffer[17];
                DCLinkV = slaveRxBuffer[18] * 256 + slaveRxBuffer[19];
    //            Display_printf(display, 0, 0, "Slave received: %s", slaveRxBuffer);
    
                potatotrack = 17;
    
                // Copy the rxBuf to packet
                potatotrack = 18;
                memcpy(packet, slaveRxBuffer, PAYLOAD_LENGTH);
                potatotrack = 19;
                RF_cmdPropTx.pPkt = packet;
                /* Send packet */
                potatotrack = 20;
                RF_runCmd(rfHandle, (RF_Op*) &RF_cmdPropTx, RF_PriorityNormal, NULL,
                          0);
            }
            else
            {
    //            Display_printf(display, 0, 0, "Unsuccessful slave SPI transfer");
                potatotrack = 233;
            }
    
            sleep(1);
            i++;
            potatotrack = 24;
        }
    
        SPI_close(slaveSpi);
        Display_printf(display, 0, 0, "Clearing Buffer");
        potatotrack = 25;
        /* Example complete - set pins to a known state */
        GPIO_setConfig(Board_SPI_MASTER_READY, GPIO_CFG_OUTPUT | GPIO_CFG_OUT_LOW);
        GPIO_write(Board_SPI_SLAVE_READY, 0);
        potatotrack = 26;
        Display_printf(display, 0, 0, "\nDone");
        potatotrack = 27;
        return (NULL);
    }
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        pthread_t thread0;
        pthread_attr_t attrs;
        struct sched_param priParam;
        int retc;
        int detachState;
    
        /* Call driver init functions. */
        Display_init();
        GPIO_init();
        SPI_init();
    
        /* Configure the LED pins */
        GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
        GPIO_setConfig(Board_GPIO_LED1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* Open the display for output */
        display = Display_open(Display_Type_UART, NULL);
        if (display == NULL)
        {
            /* Failed to open display driver */
            while (1)
                ;
        }
    
        /* Turn on user LED */
        GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
    
        Display_printf(display, 0, 0, "Starting the SPI slave example");
        Display_printf(
                display,
                0,
                0,
                "This example requires external wires to be "
                "connected to the header pins. Please see the Board.html for details.\n");
    
        /* Create application thread */
        pthread_attr_init(&attrs);
    
        detachState = PTHREAD_CREATE_DETACHED;
        /* Set priority and stack size attributes */
        retc = pthread_attr_setdetachstate(&attrs, detachState);
        if (retc != 0)
        {
            /* pthread_attr_setdetachstate() failed */
            while (1)
                ;
        }
    
        retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE);
        if (retc != 0)
        {
            /* pthread_attr_setstacksize() failed */
            while (1)
                ;
        }
    
        /* Create slave thread */
        priParam.sched_priority = 1;
        pthread_attr_setschedparam(&attrs, &priParam);
    
        retc = pthread_create(&thread0, &attrs, slaveThread, NULL);
        if (retc != 0)
        {
            /* pthread_create() failed */
            while (1)
                ;
        }
    
        return (NULL);
    }
    
    //                                                              SSSSSSSSSSSSSSSSSSSSSSSSSSSSSPLITTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
    
    //
    //
    //
    ////#define PAYLOAD_LENGTH 10
    //
    //static RF_Object rfObject;
    //static RF_Handle rfHandle;
    //
    //SPI_Handle spiHandle;
    //SPI_Transaction spiTransaction;
    //
    //static uint8_t rfPacket[PAYLOAD_LENGTH];
    //static uint8_t spiRxBuffer[PAYLOAD_LENGTH];
    //
    //void *mainThread(void *arg0)
    //{
    //    RF_Params rfParams;
    //    RF_Params_init(&rfParams);
    //
    //    RF_cmdPropTx.pktLen = PAYLOAD_LENGTH;
    //    RF_cmdPropTx.pPkt = rfPacket;
    //    RF_cmdPropTx.startTrigger.triggerType = TRIG_NOW;
    //
    //    SPI_Params      spiParams;
    //    SPI_init();
    //    SPI_Params_init(&spiParams);
    //    spiParams.frameFormat = SPI_POL1_PHA1;
    //    spiParams.mode = SPI_SLAVE;
    //    spiParams.transferMode = SPI_MODE_CALLBACK;
    ////    spiParams.bitRate = 2000000;
    //
    //    spiHandle = SPI_open(CC1310_LAUNCHXL_SPI0, &spiParams);
    //
    //    spiTransaction.count = PAYLOAD_LENGTH;
    //    spiTransaction.txBuf = NULL;
    //    spiTransaction.rxBuf = spiRxBuffer;
    //
    //    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    //
    //    RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    //
    //    while(1)
    //    {
    //        SPI_transfer(spiHandle, &spiTransaction);
    //        memcpy(rfPacket, spiRxBuffer, PAYLOAD_LENGTH);
    //        RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
    //    }
    //}
    //
    //
    //
    //
    //
    //
    //
    
    //SSSSSSSSSSSSSSSSSSSSSSSSSSSSSPPPPPPPPPPPPPPPPLLLLLLLLLLLLLIIIIIIIIIIIIIIIIIIIIITTTTTTTTTTTTTTTTT
    
    ///***** Variable declarations *****/
    //
    //int potatotrack = 0;
    //
    //SPI_Handle slaveSpi;
    //SPI_Params spiParams;
    //SPI_Transaction transaction;
    //uint32_t i;
    //bool transferOK;
    //int32_t status;
    //unsigned char slaveRxBuffer[SPI_MSG_LENGTH];
    //unsigned char slaveTxBuffer[SPI_MSG_LENGTH];
    //
    //static RF_Object rfObject;
    //static RF_Handle rfHandle;
    //
    ///* Pin driver handle */
    //static PIN_Handle ledPinHandle;
    //static PIN_State ledPinState;
    //
    //static uint8_t packet[PAYLOAD_LENGTH];
    //static uint16_t seqNumber;
    //
    ///*
    // * Application LED pin configuration table:
    // *   - All LEDs board LEDs are off.
    // */
    //PIN_Config pinTable[] =
    //        {
    //        Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL
    //                  | PIN_DRVSTR_MAX,
    //#ifdef POWER_MEASUREMENT
    //#if defined(Board_CC1350_LAUNCHXL)
    //          Board_DIO30_SWPWR | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    //#endif
    //#endif
    //          PIN_TERMINATE };
    //
    ///***** Function definitions *****/
    //void *mainThread(void *arg0)
    //{
    //
    //    potatotrack = 1;
    ////    spiParams.frameFormat = SPI_POL1_PHA1; // gets the old alg going
    //    spiParams.frameFormat = SPI_POL0_PHA1;
    ////    potatotrack = 8;
    //    potatotrack = 2;
    //    spiParams.mode = SPI_SLAVE;
    ////    potatotrack = 9;
    ////    spiParams.transferCallbackFxn = transferCompleteFxn;
    ////    potatotrack = 10;
    ////    spiParams.bitRate = 500000;
    //    potatotrack = 3;
    ////    spiParams.transferMode = SPI_MODE_BLOCKING;
    ////    potatotrack = 11;
    //    potatotrack = 4;
    //    RF_Params rfParams;
    //    RF_Params_init(&rfParams);
    //
    //    potatotrack = 5;
    //    /* Open LED pins */
    //    ledPinHandle = PIN_open(&ledPinState, pinTable);
    //    potatotrack = 6;
    //    if (ledPinHandle == NULL)
    //    {
    //        while (1)
    //        {
    //            potatotrack = 66;
    //        }
    //    }
    //    potatotrack = 7;
    //    RF_cmdPropTx.pktLen = PAYLOAD_LENGTH;
    //    potatotrack = 8;
    //    RF_cmdPropTx.startTrigger.triggerType = TRIG_NOW;
    //    potatotrack = 9;
    //    // Init SPI
    //    // Set the SPI up for Slave mode
    //    // and SPI_MODE_BLOCKING.
    //    slaveSpi = SPI_open(Board_SPI_SLAVE, &spiParams);
    //    potatotrack = 10;
    //    /* Request access to the radio */
    //    rfHandle = RF_open(&rfObject, &RF_prop,
    //                       (RF_RadioSetup*) &RF_cmdPropRadioDivSetup, &rfParams);
    //    potatotrack = 11;
    //    /* Set the frequency */
    //    RF_postCmd(rfHandle, (RF_Op*) &RF_cmdFs, RF_PriorityNormal, NULL, 0);
    //    potatotrack = 12;
    //    while (1)
    //    {
    //        memset((void *) slaveRxBuffer, 0, SPI_MSG_LENGTH);
    //        potatotrack = 13;
    //        transaction.count = SPI_MSG_LENGTH;
    //        potatotrack = 14;
    //        transaction.txBuf = (void *) slaveTxBuffer;
    //        potatotrack = 15;
    //        transaction.rxBuf = (void *) slaveRxBuffer;
    //        potatotrack = 16;
    //        // Read the bytes you want to read over SPI
    //        SPI_transfer(slaveSpi, &transaction);
    //        potatotrack = 17;
    //
    //        // Copy the rxBuf to packet
    //        potatotrack = 18;
    //        memcpy(packet, slaveRxBuffer, PAYLOAD_LENGTH);
    //        potatotrack = 19;
    //        RF_cmdPropTx.pPkt = packet;
    //        /* Send packet */
    //        potatotrack = 20;
    //        RF_runCmd(rfHandle, (RF_Op*) &RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
    //
    //    }
    //}
    
    //                                                              SSSSSSSSSSSSSSSSSSSSSSSSSSSSSPLITTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
    
    //void *mainThread(void *arg0)
    //{
    //    RF_Params rfParams;
    //    RF_Params_init(&rfParams);
    //
    //    /* Open LED pins */
    //    ledPinHandle = PIN_open(&ledPinState, pinTable);
    //    if (ledPinHandle == NULL)
    //    {
    //        while(1);
    //    }
    //
    //#ifdef POWER_MEASUREMENT
    //#if defined(Board_CC1350_LAUNCHXL)
    //    /* Route out PA active pin to Board_DIO30_SWPWR */
    //    PINCC26XX_setMux(ledPinHandle, Board_DIO30_SWPWR, PINCC26XX_MUX_RFC_GPO1);
    //#endif
    //#endif
    //
    //    RF_cmdPropTx.pktLen = PAYLOAD_LENGTH;
    //    RF_cmdPropTx.pPkt = packet;
    //    RF_cmdPropTx.startTrigger.triggerType = TRIG_NOW;
    //
    //    /* Request access to the radio */
    //#if defined(DeviceFamily_CC26X0R2)
    //    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);
    //#else
    //    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    //#endif// DeviceFamily_CC26X0R2
    //
    //    /* Set the frequency */
    //    RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
    //
    //    while(1)
    //    {
    //        /* Create packet with incrementing sequence number and random payload */
    //        packet[0] = (uint8_t)(seqNumber >> 8);
    //        packet[1] = (uint8_t)(seqNumber++);
    //        uint8_t i;
    //        for (i = 2; i < PAYLOAD_LENGTH; i++)
    //        {
    //            packet[i] = rand();
    //        }
    //
    //        /* Send packet */
    //        RF_EventMask terminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx,
    //                                                   RF_PriorityNormal, NULL, 0);
    //
    //        switch(terminationReason)
    //        {
    //            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_cmdPropTx)->status;
    //        switch(cmdStatus)
    //        {
    //            case PROP_DONE_OK:
    //                // Packet transmitted successfully
    //                break;
    //            case PROP_DONE_STOPPED:
    //                // received CMD_STOP while transmitting packet and finished
    //                // transmitting packet
    //                break;
    //            case PROP_DONE_ABORT:
    //                // Received CMD_ABORT while transmitting packet
    //                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_TXUNF:
    //                // TX underflow observed during operation
    //                break;
    //            default:
    //                // Uncaught error event - these could come from the
    //                // pool of states defined in rf_mailbox.h
    //                while(1);
    //        }
    //
    //#ifndef POWER_MEASUREMENT
    //        PIN_setOutputValue(ledPinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1));
    //#endif
    //        /* Power down the radio */
    //        RF_yield(rfHandle);
    //
    //#ifdef POWER_MEASUREMENT
    //        /* Sleep for PACKET_INTERVAL s */
    //        sleep(PACKET_INTERVAL);
    //#else
    //        /* Sleep for PACKET_INTERVAL us */
    //        usleep(PACKET_INTERVAL);
    //#endif
    //
    //    }
    //}
  • You are sending packet with PAYLOAD_LENGTH 100 and then you are setting the Max packet length on the receiver to 30 (if you are using my code).

    Note that the way my code works is that it will only receive packets with CRC OK. All other packets are discarded.

    BR

    Siri

  • Sweet, that actually works!
    I can see data being received, albeit on a slightly wacky rxDataEntryBuffer, but I'm still receiving it nevertheless yay!
    
    Now I am sooo sorry for dragging this out, but you guys are the only ones who can help me right through this.
    I am now trying the vice versa SPI integration where this CC1310 is now the master.
    I have tried integrating a bit of the standalone SPI Master code that I got working independently with another TMS320F28379D launchpad.
    The program once again gets stuck at the following line.
    
    transferOK = SPI_transfer(masterSpi, &transaction);
    
    
    
    I am aware that there's a sequence that these things should happen at as when you last corrected it for me on the other side (when CC1310 was slave and TMS320F28379D), but this RF example is different and I can't really see an obvious place to put one time setup things for example.
    
    Can you tell me if everything is where it's meant to be?
    
    You are a legend
    
    Thanks 
  • /*
    * Copyright (c) 2019, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */

    /***** Includes *****/
    /* Standard C Libraries */
    #include <stdlib.h>

    #include <stdint.h>
    #include <string.h>


    /* TI Drivers */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>

    #include <pthread.h>
    #include <semaphore.h>
    #include <unistd.h>

    /* Driverlib Header files */
    #include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)

    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/SPI.h>
    #include <ti/display/Display.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 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) */

    /***** 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) */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_ALIGN (rxDataEntryBuffer, 4);
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
    MAX_LENGTH,
    NUM_APPENDED_BYTES)];
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma data_alignment = 4
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
    MAX_LENGTH,
    NUM_APPENDED_BYTES)];
    #elif defined(__GNUC__)
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
    MAX_LENGTH,
    NUM_APPENDED_BYTES)]
    __attribute__((aligned(4)));
    #else
    #error This compiler is not supported.
    #endif

    /* Receive dataQueue for RF Core to fill in data */
    static dataQueue_t dataQueue;
    static rfc_dataEntryGeneral_t* currentDataEntry;
    static uint8_t packetLength;
    static uint8_t* packetDataPointer;


    //SPI stuff
    SPI_Handle masterSpi;
    SPI_Params spiParams;
    SPI_Transaction transaction;
    uint32_t i;
    bool transferOK;
    int32_t status;


    #define SPI_MSG_LENGTH (30)
    #define MASTER_MSG ("123 567 ")
    int potatotrack=0;
    #define MAX_LOOP (1000)

    unsigned char masterRxBuffer[SPI_MSG_LENGTH];
    unsigned char masterTxBuffer[SPI_MSG_LENGTH];


    //potatotrack=5;
    /* Open SPI as master (default) */

    //potatotrack=9;

    //#define THREADSTACKSIZE (1024)

    static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */

    /*
    * Application LED pin configuration table:
    * - All LEDs board LEDs are off.
    */
    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_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 */
    #if defined(DeviceFamily_CC26X0R2)
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);
    #else
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    #endif// DeviceFamily_CC26X0R2

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

    // if (transferOK) {
    // Display_printf(display, 0, 0, "Master received: %s", masterRxBuffer);
    // }
    // else {
    // Display_printf(display, 0, 0, "Unsuccessful master SPI transfer");
    // }
    potatotrack=21;
    /* Sleep for a bit before starting the next SPI transfer */
    // sleep(3);
    potatotrack=22;


    switch(terminationReason)
    {
    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);
    }

    void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
    if (e & RF_EventRxEntryDone)
    {

    //potatotrack=6;
    spiParams.frameFormat = SPI_POL0_PHA1;
    //potatotrack=7;
    spiParams.bitRate = 100000;
    //potatotrack=8;
    SPI_Params_init(&spiParams);
    masterSpi = SPI_open(Board_SPI_MASTER, &spiParams);
    /* Toggle pin to indicate RX */
    PIN_setOutputValue(ledPinHandle, Board_PIN_LED2,
    !PIN_getOutputValue(Board_PIN_LED2));

    // strncpy((char *) masterTxBuffer, (unsigned char)rxDataEntryBuffer, SPI_MSG_LENGTH);
    strncpy((char *) masterTxBuffer, rxDataEntryBuffer, SPI_MSG_LENGTH);

    memset((void *) masterRxBuffer, 0, SPI_MSG_LENGTH);
    potatotrack=15;
    transaction.count = SPI_MSG_LENGTH;
    potatotrack=16;
    transaction.txBuf = (void *) masterTxBuffer;
    potatotrack=17;
    transaction.rxBuf = (void *) masterRxBuffer;
    potatotrack=18;

    GPIO_toggle(Board_GPIO_LED1);
    potatotrack=19;
    /* Perform SPI transfer */
    transferOK = SPI_transfer(masterSpi, &transaction);
    potatotrack=20;


    /* Get current unhandled data entry */
    currentDataEntry = RFQueue_getDataEntry();

    /* Handle the packet data, located at &currentDataEntry->data:
    * - Length is the first byte with the current configuration
    * - Data starts from the second byte */
    packetLength = *(uint8_t*)(&currentDataEntry->data);
    packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1);

    /* Copy the payload + the status byte to the packet variable */
    memcpy(packet, packetDataPointer, (packetLength + 1));

    RFQueue_nextEntry();
    }
    }

  • I already recommended how you should do this over a month ago (9th of march) using semaphores. It is kind of difficult to help you when you are not following the advice I give you. You need to move all of the UART stuff out of the callback.

    Also, it is not rxDataEntryBuffer you want to transmit over SPI, it is the "packet" you want to send.

    Start by getting the RF part up and running using semaphores, but instead of sending data over SPI every time a packet is received, you toggle a LED (do not do this in the callback, but after pending on the semaphore.

    Once you have that up and running, you replace the LED toggling with the SPI code.

    Siri

  • Hi Siri

    customer Shaetrun Pathmanathan don't know why his account can't reply your information,

    customer reply:

    Heya Siri,
    Thanks for your patience.
    I have the LED toggling and the packets are being received yay!
    I tried following your advice on getting the LED to toggle and it toggles.
    Now I'm trying to replace this with my Master SPI code that I have somewhat working with my Primary side TMS320F28379D.
    I try to transmit the packets as you say, however, the code hangs at this point again:

    transferOK = SPI_transfer(masterSpi, &transaction);

    I try to inspect the variables SPI_transfer is being passed and masterSpi is empty but the transaction variabel seems to have some form of address going to it.
    I've tried looking further up to see what the holdup is, but I can't see anything obvious.
    One last time, would you mind having a look for me?

    Thank you 3000!

    code;

    /***** Includes *****/
    /* Standard C Libraries */
    #include <stdlib.h>

    /* TI Drivers */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>

    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/drivers/SPI.h>
    #include <ti/drivers/GPIO.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 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) */

    static Semaphore_Struct rxSemaphore;
    static Semaphore_Handle rxSemaphoreHandle;

    //SPI things
    #define THREADSTACKSIZE (1024)

    /***** 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) */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_ALIGN (rxDataEntryBuffer, 4);
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
    MAX_LENGTH,
    NUM_APPENDED_BYTES)];
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma data_alignment = 4
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
    MAX_LENGTH,
    NUM_APPENDED_BYTES)];
    #elif defined(__GNUC__)
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
    MAX_LENGTH,
    NUM_APPENDED_BYTES)]
    __attribute__((aligned(4)));
    #else
    #error This compiler is not supported.
    #endif

    /* Receive dataQueue for RF Core to fill in data */
    static dataQueue_t dataQueue;
    static rfc_dataEntryGeneral_t* currentDataEntry;
    static uint8_t packetLength;
    static uint8_t* packetDataPointer;


    static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */

    SPI_Handle masterSpi;
    SPI_Params spiParams;
    SPI_Transaction transaction;
    uint32_t i;
    bool transferOK;
    int32_t status;

    #define SPI_MSG_LENGTH (MAX_LENGTH + NUM_APPENDED_BYTES - 1)
    #define MASTER_MSG ("123 567 ")
    int potatotrack=0;
    #define MAX_LOOP (1000)

    //unsigned char masterRxBuffer[packetLength];
    //unsigned char masterTxBuffer[packetLength];

    unsigned char masterRxBuffer[SPI_MSG_LENGTH];
    unsigned char masterTxBuffer[SPI_MSG_LENGTH];

    /*
    * Application LED pin configuration table:
    * - All LEDs board LEDs are off.
    */
    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)
    {
    // SPI_Handle masterSpi;
    // SPI_Params spiParams;
    // SPI_Transaction transaction;
    // uint32_t i;
    // bool transferOK;
    // int32_t status;
    potatotrack=1;


    RF_Params rfParams;
    RF_Params_init(&rfParams);

    Semaphore_construct(&rxSemaphore, 0, NULL);
    rxSemaphoreHandle = Semaphore_handle(&rxSemaphore);

    /* 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 */
    #if defined(DeviceFamily_CC26X0R2)
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);
    #else
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    #endif// DeviceFamily_CC26X0R2

    /* 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_cmdPropRx, RF_PriorityNormal, &callback, RF_EventRxEntryDone);

    SPI_Params_init(&spiParams);
    potatotrack=6;
    spiParams.frameFormat = SPI_POL0_PHA1;
    potatotrack=7;
    spiParams.bitRate = 100000;
    potatotrack=8;
    masterSpi = SPI_open(Board_SPI_MASTER, &spiParams);
    potatotrack=9;

    while(1)
    {
    Semaphore_pend(rxSemaphoreHandle, BIOS_WAIT_FOREVER);
    PIN_setOutputValue(ledPinHandle, Board_PIN_LED2, !PIN_getOutputValue(Board_PIN_LED2));

    // memcpy(masterTxBuffer,packet, (packetLength + 1));
    potatotrack=14;
    memset((void *) masterRxBuffer, 0, SPI_MSG_LENGTH);
    potatotrack=15;
    transaction.count = packetLength;
    potatotrack=16;
    transaction.txBuf = (void *) packet;
    potatotrack=17;
    transaction.rxBuf = (void *) masterRxBuffer;
    potatotrack=18;

    /* Toggle user LED, indicating a SPI transfer is in progress */
    GPIO_toggle(Board_GPIO_LED1);
    potatotrack=19;
    /* Perform SPI transfer */
    transferOK = SPI_transfer(masterSpi, &transaction);
    potatotrack=20;


    }

    }

    void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
    if (e & RF_EventRxEntryDone)
    {
    /* Get current unhandled data entry */
    currentDataEntry = RFQueue_getDataEntry();

    /* Handle the packet data, located at &currentDataEntry->data:
    * - Length is the first byte with the current configuration
    * - Data starts from the second byte */
    packetLength = *(uint8_t*)(&currentDataEntry->data);
    packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1);

    /* Copy the payload + the status byte to the packet variable */
    memcpy(packet, packetDataPointer, (packetLength + 1));

    RFQueue_nextEntry();

    Semaphore_post(rxSemaphoreHandle);
    }
    }

    regards

  • The below code receives packet on RF and transmit them over SPI (payload only):

    /***** Includes *****/
    /* Standard C Libraries */
    #include <stdlib.h>
    
    /* TI Drivers */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/SPI.h>
    #include <ti/drivers/spi/SPICC26X2DMA.h>
    
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Semaphore.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             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) */
    
    static Semaphore_Struct rxSemaphore;
    static Semaphore_Handle rxSemaphoreHandle;
    
    /***** 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) */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_ALIGN (rxDataEntryBuffer, 4);
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                      MAX_LENGTH,
                                                      NUM_APPENDED_BYTES)];
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma data_alignment = 4
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                      MAX_LENGTH,
                                                      NUM_APPENDED_BYTES)];
    #elif defined(__GNUC__)
    static uint8_t
    rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                      MAX_LENGTH,
                                                      NUM_APPENDED_BYTES)]
                                                      __attribute__((aligned(4)));
    #else
    #error This compiler is not supported.
    #endif
    
    /* Receive dataQueue for RF Core to fill in data */
    static dataQueue_t dataQueue;
    static rfc_dataEntryGeneral_t* currentDataEntry;
    static uint8_t packetLength;
    static uint8_t* packetDataPointer;
    
    SPI_Handle      spiHandle;
    SPI_Transaction spiTransaction;
    
    static uint8_t spiPacket[MAX_LENGTH]; // Only transmit payload on SPI
    static uint8_t rfPacket[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */
    
    /*
     * Application LED pin configuration table:
     *   - All LEDs board LEDs are off.
     */
    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);
    
        Semaphore_construct(&rxSemaphore, 0, NULL);
        rxSemaphoreHandle = Semaphore_handle(&rxSemaphore);
    
        /* 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);
        }
    
        SPI_Params      spiParams;
    
        SPI_init();
        SPI_Params_init(&spiParams);
        spiParams.frameFormat           = SPI_POL0_PHA0;
        spiParams.mode                  = SPI_MASTER;
        spiParams.transferMode          = SPI_MODE_BLOCKING;
        spiParams.bitRate               = 4000000;
    
        spiHandle = SPI_open(Board_SPI_MASTER, &spiParams);
    
        if (spiHandle == NULL)
        {
            while (1);
        }
    
        spiTransaction.txBuf = spiPacket;
    
        /* 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_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
    
       while(1)
       {
           Semaphore_pend(rxSemaphoreHandle, BIOS_WAIT_FOREVER);
           PIN_setOutputValue(ledPinHandle, Board_PIN_LED2, !PIN_getOutputValue(Board_PIN_LED2));
           memcpy(spiPacket, rfPacket, packetLength);
           spiTransaction.count = packetLength;
           SPI_transfer(spiHandle, &spiTransaction);
       }
    
    }
    
    void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
        if (e & RF_EventRxEntryDone)
        {
            /* Get current unhandled data entry */
            currentDataEntry = RFQueue_getDataEntry();
    
            /* Handle the packet data, located at &currentDataEntry->data:
             * - Length is the first byte with the current configuration
             * - Data starts from the second byte */
            packetLength      = *(uint8_t*)(&currentDataEntry->data);
            packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1);
    
            /* Copy the payload + the status byte to the packet variable */
            memcpy(rfPacket, packetDataPointer, (packetLength + 1));
    
            RFQueue_nextEntry();
    
            Semaphore_post(rxSemaphoreHandle);
        }
    }
    

    Siri