SDAA260 April 2026 CC1310 , CC1311P3 , CC1312PSIP , CC1312R , CC1312R7 , CC1314R10 , CC1350 , CC1352P , CC1352P7 , CC1352R , CC1354P10 , CC1354R10
To be able to receive a packet with the standard packet format shown in Figure 1-1 using CMD_PROP_RX, the following code could be used (also here the code has been slightly modified compared to the original rfPacketRx, to increase readability and enable easier debugging).
1: //---------------------------------------------------------------------------------------------
2: // Receive Standard Packet Format with CMD_PROP_RX (1 Length Byte)
3: //---------------------------------------------------------------------------------------------
4:
5: // Defines
6: #define DATA_ENTRY_HEADER_SIZE 8 // Constant header size of a Generic Data Entry
7: #define NUM_DATA_ENTRIES 2 // NOTE: Only two data entries supported
8: #define CRC 2 // 2 if .rxConf.bIncludeCrc = 0x1, 0 otherwise
9: #define RSSI 1 // 1 if .rxConf.bAppendRssi = 0x1, 0 otherwise
10: #define TIMESTAMP 4 // 4 if .rxConf.bAppendTimestamp = 0x1, 0 otherwise
11: #define STATUS 1 // 1 if .rxConf.bAppendStatus = 0x1, 0 otherwise
12: #define LENGTH_FIELD 1 // RF_cmdPropRx.rxConf.bIncludeHdr = 0x1
13: #define MAX_LENGTH 255 // Max length the radio will accept
14: #define NUM_APPENDED_BYTES LENGTH_FIELD + CRC + RSSI + TIMESTAMP + STATUS
15:
16: uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - LENGTH_FIELD]; // Length stored in
17: uint8_t packetLength; // packetLength
18:
19: static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
20:
21: static RF_Object rfObject;
22: static RF_Handle rfHandle;
23:
24: static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES, MAX_LENGTH,
25: NUM_APPENDED_BYTES)]__attribute__((aligned(4)));
26: static dataQueue_t dataQueue;
27: static rfc_dataEntryGeneral_t* currentDataEntry;
28: static uint8_t* packetDataPointer;
29: rfc_propRxOutput_t rxStatistics;
30: uint16_t crc16;
31: int8_t rssi;
32: uint32_t timestamp;
33: uint8_t status;
34:
35: void *mainThread(void *arg0)
36: {
37: RF_Params rfParams;
38: RF_Params_init(&rfParams);
39:
40: if(RFQueue_defineQueue(&dataQueue, rxDataEntryBuffer, sizeof(rxDataEntryBuffer),
41: NUM_DATA_ENTRIES, MAX_LENGTH + NUM_APPENDED_BYTES))
42: {
43: while(1);
44: }
45:
46: RF_cmdPropRx.pktConf.bRepeatOk = 0x1; // Application specific settings
47: RF_cmdPropRx.pktConf.bRepeatNok = 0x1;
48: RF_cmdPropRx.rxConf.bAutoFlushIgnored = 0x1;
49: RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 0x1;
50: RF_cmdPropRx.maxPktLen = MAX_LENGTH;
51: RF_cmdPropRx.pQueue = &dataQueue;
52:
53: RF_cmdPropRx.rxConf.bIncludeCrc = 0x1; // Optional bytes to append
54: RF_cmdPropRx.rxConf.bAppendRssi = 0x1;
55: RF_cmdPropRx.rxConf.bAppendTimestamp = 0x1;
56: RF_cmdPropRx.rxConf.bAppendStatus = 0x1;
57:
58: RF_cmdPropRx.pOutput = (uint8_t*)&rxStatistics; // Optional (for debug)
59:
60: rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup,
61: &rfParams);
62: RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
63: RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal,
64: &callback, RF_EventRxEntryDone);
65: while(1);
66: }
67:68: //---------------------------------------------------------------------------------------------
69: // Callback for Receiving Standard Packet Format with CMD_PROP_RX (1 Length Byte)
70: //---------------------------------------------------------------------------------------------
71: void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
72: {
73: if(e & RF_EventRxEntryDone)
74: {
75: currentDataEntry = RFQueue_getDataEntry();
76:
77: packetLength = *(uint8_t*)(¤tDataEntry->data);
78: packetDataPointer = (uint8_t*)(¤tDataEntry->data + LENGTH_FIELD);
79:
80: memcpy(packet, packetDataPointer, (packetLength + NUM_APPENDED_BYTES - LENGTH_FIELD));
81:
82: crc16 = ((uint16_t)(packet[packetLength + 0] << 8) +
83: (uint16_t)(packet[packetLength + 1] << 0));
84:
85: rssi = packet[packetLength + 2];
86:
87: timestamp = ((uint32_t)(packet[packetLength + 3] << 0) +
88: (uint32_t)(packet[packetLength + 4] << 8) +
89: (uint32_t)(packet[packetLength + 5] << 16) +
90: (uint32_t)(packet[packetLength + 6] << 24));
91:
92: status = packet[packetLength + 7];
93:
94: RFQueue_nextEntry();
95: }
96: }
In this code example, no length filtering is implemented, and all optional bytes that can be appended, are appended. If the only packet to be received is the packet shown in Figure 2-1, MAX_LENGTH can be changed from 255 to 3, causing all packets with length byte larger than 3 to be discarded (since rxConf.bAutoFlushIgnored = 1).