SDAA260 April 2026 CC1310 , CC1311P3 , CC1312PSIP , CC1312R , CC1312R7 , CC1314R10 , CC1350 , CC1352P , CC1352P7 , CC1352R , CC1354P10 , CC1354R10
1: //--------------------------------------------------------------------------------------------
2: // Receive Standard Packet Format (2 Length Bytes) with PHYs using CMD_PROP_RX_ADV by Default
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 2 // Changed from 1
13: #define MAX_LENGTH 4093 // Changed from 255
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: // packetLength
18: uint16_t packetLength; // Changed from uint8_t
19:
20: static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
21:
22: static RF_Object rfObject;
23: static RF_Handle rfHandle;
24:
25: static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES, MAX_LENGTH,
26: NUM_APPENDED_BYTES)]__attribute__((aligned(4)));
27: static dataQueue_t dataQueue;
28: static rfc_dataEntryGeneral_t* currentDataEntry;
29: static uint8_t* packetDataPointer;
30: rfc_propRxOutput_t rxStatistics;
31: uint16_t crc16;
32: int8_t rssi;
33: uint32_t timestamp;
34: uint8_t status;
35:
36: void *mainThread(void *arg0)
37: {
38: RF_Params rfParams;
39: RF_Params_init(&rfParams);
40:
41: if(RFQueue_defineQueue(&dataQueue, rxDataEntryBuffer, sizeof(rxDataEntryBuffer),
42: NUM_DATA_ENTRIES, MAX_LENGTH + NUM_APPENDED_BYTES))
43: {
44: while(1);
45: }
46:
47: RF_cmdPropRxAdv.pktConf.bRepeatOk = 0x1; // Application specific settings
48: RF_cmdPropRxAdv.pktConf.bRepeatNok = 0x1;
49: RF_cmdPropRxAdv.pktConf.bCrcIncHdr = 0x1;
50: RF_cmdPropRxAdv.rxConf.bAutoFlushCrcErr = 0x1;
51: RF_cmdPropRxAdv.syncWord0 = 0x930B51DE;
52: RF_cmdPropRxAdv.maxPktLen = MAX_LENGTH;
53: RF_cmdPropRxAdv.hdrConf.numHdrBits = 0x10; // Changed from 0x8
54: RF_cmdPropRxAdv.hdrConf.numLenBits = 0x10; // Changed from 0x8
55: RF_cmdPropRxAdv.lenOffset = 0x0;
56: RF_cmdPropRxAdv.pQueue = &dataQueue;
57:
58: RF_cmdPropRxAdv.pOutput = (uint8_t*)&rxStatistics; // Optional (for debugging)
59:
60: // Necessary changes to the Setup command to support the standard packet format
61: RF_cmdPropRadioDivSetup.formatConf.nSwBits = 0x20; // 32 bits sync word
62: RF_cmdPropRadioDivSetup.formatConf.whitenMode = 0x0; // No whitening
63:
64: rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup,
65: &rfParams);
66: RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
67: RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxAdv, RF_PriorityNormal,
68: &callback, RF_EventRxEntryDone);
69: while(1);
70: }
71:72: //--------------------------------------------------------------------------------------------
73: // Callback for Receiving Standard Packet Format (2 Length Bytes) with PHYs
74: // using CMD_PROP_RX_ADV by Default
75: //--------------------------------------------------------------------------------------------
76:
77: void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
78: {
79: if(e & RF_EventRxEntryDone)
80: {
81: currentDataEntry = RFQueue_getDataEntry();
82:
83: packetLength = ((uint16_t)(*(uint8_t*)(¤tDataEntry->data + 1) << 8) |
84: (uint16_t)(*(uint8_t*)(¤tDataEntry->data + 0) << 0));
85: // Changed from
86: // packetLength = *(uint8_t*)(¤tDataEntry->data);
87:
88: packetDataPointer = (uint8_t*)(¤tDataEntry->data + LENGTH_FIELD);
89:
90: memcpy(packet, packetDataPointer,
91: (packetLength + NUM_APPENDED_BYTES - LENGTH_FIELD));
92:
93: crc16 = ((uint16_t)(packet[packetLength + 0] << 8) +
94: (uint16_t)(packet[packetLength + 1] << 0));
95:
96: rssi = packet[packetLength + 2];
97:
98: timestamp = ((uint32_t)(packet[packetLength + 3] << 0 ) +
99: (uint32_t)(packet[packetLength + 4] << 8 ) +
100: (uint32_t)(packet[packetLength + 5] << 16) +
101: (uint32_t)(packet[packetLength + 6] << 24));
102:
103: status = packet[packetLength + 7];
104:
105: RFQueue_nextEntry();
106: }
107: }