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.
Hi Team,
Now customer is using DATA_ENTRY_TYPE_PARTIAL mode in CC1310 project. Is there anyone have the Partial Mode example based on CC1310 platform? Thanks a lot.
I tested some of the code I found when searching for partial read entries and were able to receive packets from SmartRF Studio using a modified version of the rfPacketRX example.
the receiver code in this example expect the length byte to be the 5th byte after sync:
From Studio I sent the following packet, where the 5th 8 is the length byte:
the modified rfPacketRx.c is below:
/***** 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 */ /* Packet RX Configuration */ #define DATA_ENTRY_HEADER_SIZE 12 /* Constant header size of a Generic Data Entry */ #define MAX_LENGTH 20 #define LENGTH_POSITION 5 #define APPENDED_BYTES 1 /***** 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[DATA_ENTRY_HEADER_SIZE + MAX_LENGTH + LENGTH_POSITION + APPENDED_BYTES]; rfc_dataEntryPartial_t* partialReadEntry = (rfc_dataEntryPartial_t*)&rxDataEntryBuffer; /* Receive dataQueue for RF Core to fill in data */ static dataQueue_t dataQueue; rfc_dataEntryPartial_t* currentReadEntry = (rfc_dataEntryPartial_t*)&rxDataEntryBuffer; #elif defined(__IAR_SYSTEMS_ICC__) #pragma data_alignment = 4 static uint8_t rxDataEntryBuffer[DATA_ENTRY_HEADER_SIZE + MAX_LENGTH + LENGTH_POSITION + APPENDED_BYTES]; rfc_dataEntryPartial_t* partialReadEntry = (rfc_dataEntryPartial_t*)&rxDataEntryBuffer; /* Receive dataQueue for RF Core to fill in data */ static dataQueue_t dataQueue; rfc_dataEntryPartial_t* currentReadEntry = (rfc_dataEntryPartial_t*)&rxDataEntryBuffer; #else #error This compiler is not supported. #endif rfc_propRxOutput_t rxStatistics; static uint8_t lengthWritten = false; static uint8_t rxDone = false; /* * 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, #if defined __CC1352R1_LAUNCHXL_BOARD_H__ Board_DIO30_RFSW | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, #endif 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); } partialReadEntry->length = MAX_LENGTH + LENGTH_POSITION + APPENDED_BYTES + 4; partialReadEntry->config.irqIntv = LENGTH_POSITION; partialReadEntry->config.type = DATA_ENTRY_TYPE_PARTIAL; partialReadEntry->status = DATA_ENTRY_PENDING; partialReadEntry->pNextEntry = (uint8_t*)partialReadEntry; dataQueue.pCurrEntry = (uint8_t*)partialReadEntry; dataQueue.pLastEntry = NULL; /* Modify CMD_PROP_RX command for application needs */ RF_cmdPropRx.pQueue = &dataQueue; /* Set the Data Entity queue for received data */ RF_cmdPropRx.maxPktLen = 0; /* Unlimited length */ RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 0x0; /* Auto-flush packets with invalid CRC */ RF_cmdPropRx.pktConf.bRepeatNok = 0x0; /* Exit RX after a packet is recived */ RF_cmdPropRx.pktConf.bRepeatOk = 0x0; /* Exit RX after a packet is recived */ RF_cmdPropRx.pOutput = (uint8_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); while(1) { rxDone = false; lengthWritten = false; RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, IRQ_RX_N_DATA_WRITTEN); while(!rxDone); 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_EventNDataWritten) { if (!lengthWritten) { lengthWritten = true; RF_cmdPropSetLen.rxLen = rxDataEntryBuffer[DATA_ENTRY_HEADER_SIZE + LENGTH_POSITION - 1] + (LENGTH_POSITION - 1); RF_runImmediateCmd(rfHandle, (uint32_t*)&RF_cmdPropSetLen); } } else { partialReadEntry->status = DATA_ENTRY_PENDING; rxDone = true; } }
Remember that RF_cmdPropSetLen must be set up in the smartrf_settings.c/h file:
// CMD_PROP_SET_LEN rfc_CMD_PROP_SET_LEN_t RF_cmdPropSetLen = { .commandNo = CMD_PROP_SET_LEN, .rxLen = 0, // SET IN THE APPLICATION };
Please note that there are no error handling etc. in this code snippet. This is simply to show how the partial read entries works.
There are no processing of the packets either, but you can see the packets in the rxDataEntryBuffer and you can check the CRC in the rxStatistics structure:
Siri