ZHDA134 April   2026 CC1310 , CC1311P3 , CC1312PSIP , CC1312R , CC1312R7 , CC1314R10 , CC1350 , CC1352P , CC1352P7 , CC1352R , CC1354P10 , CC1354R10

 

  1.   1
  2.   摘要
  3.   商标
  4. 1简介
  5. 2使用标准命令导出的 PHY 设置
    1. 2.1 标准数据包格式(1 个长度字节)
      1. 2.1.1 使用 CMD_PROP_TX 和标准数据包格式(1 个长度字节)的 TX
      2. 2.1.2 使用 CMD_PROP_RX 和标准数据包格式(1 个长度字节)的 RX
      3. 2.1.3 使用 CMD_PROP_TX_ADV 命令和标准数据包格式(1 个长度字节)的 TX
      4. 2.1.4 使用 CMD_PROP_RX_ADV 和标准数据包格式(1 个长度字节)的 RX
    2. 2.2 标准数据包格式(2 个长度字节)
      1. 2.2.1 使用 CMD_PROP_TX_ADV 和标准数据包格式(2 个长度字节)的 TX
      2. 2.2.2 使用 CMD_PROP_RX_ADV 和标准数据包格式(2 个长度字节)的 RX
  6. 3使用高级命令导出的 TX 和 RX 设置
    1. 3.1 高级数据包格式
      1. 3.1.1 使用 CMD_PROP_TX_ADV 和高级数据包格式的 TX
      2. 3.1.2 使用 CMD_PROP_RX_ADV 和高级数据包格式的 RX
    2. 3.2 标准数据包格式(1 个长度字节)
      1. 3.2.1 使用 CMD_PROP_TX_ADV 命令和标准数据包格式(1 个长度字节)的 TX
      2. 3.2.2 使用 CMD_PROP_RX_ADV 和标准数据包格式(1 个长度字节)的 RX
    3. 3.3 标准数据包格式(2 个长度字节)
      1. 3.3.1 使用 CMD_PROP_TX_ADV 和标准数据包格式(2 个长度字节)的 TX
      2. 3.3.2 使用 CMD_PROP_RX_ADV 和标准数据包格式(2 个长度字节)的 RX
  7. 4参考资料

使用 CMD_PROP_RX_ADV 和标准数据包格式(1 个长度字节)的 RX

1:   //--------------------------------------------------------------------------------------------
2:   // Receive Standard Packet Format (1 Length Byte) 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            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_cmdPropRxAdv.pktConf.bRepeatOk = 0x1; // Application specific settings
47:      RF_cmdPropRxAdv.pktConf.bRepeatNok = 0x1;
48:      RF_cmdPropRxAdv.pktConf.bCrcIncHdr = 0x1;
49:      RF_cmdPropRxAdv.rxConf.bAutoFlushCrcErr = 0x1;
50:      RF_cmdPropRxAdv.syncWord0 = 0x930B51DE;
51:      RF_cmdPropRxAdv.maxPktLen = MAX_LENGTH;
52:      RF_cmdPropRxAdv.hdrConf.numHdrBits = 0x8;
53:      RF_cmdPropRxAdv.hdrConf.numLenBits = 0x8;
54:      RF_cmdPropRxAdv.lenOffset = 0x0;
55:      RF_cmdPropRxAdv.pQueue = &dataQueue;
56:
57:      RF_cmdPropRxAdv.pOutput = (uint8_t*)&rxStatistics; // Opt. (for debug)
58:
59:      // Necessary changes to the Setup command to support the standard packet format
60:      RF_cmdPropRadioDivSetup.formatConf.nSwBits = 0x20; // 32 bits sync word
61:      RF_cmdPropRadioDivSetup.formatConf.whitenMode = 0x0; // No whitening
62:
63:      rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, 
64:                         &rfParams);
65:      RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
66:      RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxAdv, RF_PriorityNormal, 
67:                &callback, RF_EventRxEntryDone);
68:      while(1);
69:  }
70:
71:  //--------------------------------------------------------------------------------------------
72:  // Callback for Receiving Standard Packet Format (1 Length Byte) with PHYs using 
73:  // CMD_PROP_RX_ADV by Default
74:  //--------------------------------------------------------------------------------------------
75:
76:  void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
77:  {
78:      if(e & RF_EventRxEntryDone)
79:      {
80:          currentDataEntry = RFQueue_getDataEntry();
81:
82:          packetLength = *(uint8_t*)(&currentDataEntry->data);
83:          packetDataPointer = (uint8_t*)(&currentDataEntry->data + LENGTH_FIELD);
84:
85:          memcpy(packet, packetDataPointer, 
86:	                (packetLength + NUM_APPENDED_BYTES - LENGTH_FIELD));
87:
88:          crc16 = ((uint16_t)(packet[packetLength + 0] << 8) +
89:                   (uint16_t)(packet[packetLength + 1] << 0));
90:
91:          rssi = packet[packetLength + 2];
92:
93:          timestamp = ((uint32_t)(packet[packetLength + 3] << 0 ) +
94:                       (uint32_t)(packet[packetLength + 4] << 8 ) +
95:                       (uint32_t)(packet[packetLength + 5] << 16) +
96:                       (uint32_t)(packet[packetLength + 6] << 24));
97:
98:          status = packet[packetLength + 7];
99:
100:         RFQueue_nextEntry();
101:     }
102: }