From f8013e4f432b323dfc3e3725a62858e73176742a Mon Sep 17 00:00:00 2001
From: zhangbo <zhangbo@qq.com>
Date: 星期五, 01 十一月 2024 15:16:32 +0800
Subject: [PATCH] 更换了新的sdk,测试了实际的uwb测距

---
 keil/include/components/uwb/inc/uwb_api.h |   91 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 75 insertions(+), 16 deletions(-)

diff --git a/keil/include/components/uwb/inc/uwb_api.h b/keil/include/components/uwb/inc/uwb_api.h
index e5e1a36..0663dfd 100644
--- a/keil/include/components/uwb/inc/uwb_api.h
+++ b/keil/include/components/uwb/inc/uwb_api.h
@@ -89,7 +89,8 @@
 #define SESSION_TYPE_RANGING_ONLY (0x03)
 #define SESSION_TYPE_IN_BAND_DATA (0x04)
 #define SESSION_TYPE_RANGING_WITH_DATA (0x05)
-// 0xA0-0x9F Reserved for Vendor Specific use case
+#define SESSION_TYPE_CCC_RANGING (0xA0)
+// 0xA1-0x9F Reserved for Vendor Specific use case
 // device test mode, 0xD1-0xDF RFU
 #define SESSION_TYPE_DEVICE_TEST_MODE (0xD0)
 // 0xE0-0xFE  Vendor Specific use
@@ -97,8 +98,6 @@
 #define SESSION_TYPE_VENDOR_ALONE_RADAR (0xFE)
 
 #define FREQ_OFFSET_SAMPLES_NUM 5
-
-#define INITIATION_NUM (4)
 
 // In Fira spec the number of controlees 1~8
 #ifndef RESPONDER_NUM_MAX
@@ -145,6 +144,7 @@
 #define UWB_MODE_VENDOR_RX 9
 #define UWB_MODE_VENDOR_CARRIER_TX 10
 #define UWB_MODE_TEST_SS_TWR 11
+#define UWB_MODE_TEST_DS_TWR 12
 
 /** UWB status */
 enum UWB_STATUS_T
@@ -211,6 +211,8 @@
 {
     DEV_TYPE_CONTROLEE = 0,
     DEV_TYPE_CONTROLLER = 1,
+    DEV_TYPE_DEVICE = 0xA0,
+    DEV_TYPE_VEHICLE = 0xA1,
 };
 
 /** UWB device role */
@@ -350,7 +352,7 @@
 /** UWB MAC address mode */
 enum MAC_ADDRESS_MODE_T
 {
-    ARRD_SHORT_USE_SHORT = 0, // MAC address is 2 bytes and 2 bytes to be used in MAC header
+    ADDR_SHORT_USE_SHORT = 0, // MAC address is 2 bytes and 2 bytes to be used in MAC header
     ADDR_LONG_USE_SHORT = 1,  // MAC address is 8 bytes and 2 bytes to be used in MAC header (Not supported)
     ADDR_LONG_USE_LONG = 2,   // MAC address is 8 bytes and 8 bytes to be used in MAC header
 };
@@ -560,10 +562,14 @@
 
     /* Reserved for Vendor Specific use 0xA0-0xDF */
     /* Additional configuration applicable only for CCC */
-    uint32_t hop_mode_key;      // 0xA0
-    uint16_t ranging_proto_ver; // 0xA3
-    uint16_t uwb_cfg_id;        // 0xA4
-    uint8_t pulseshape_combo;   // 0xA5
+    uint32_t hop_mode_key;                  // 0xA0
+    uint8_t ccc_responder_slot_idx;         // 0xA2
+    uint8_t pulseshape_combo;               // 0xA5
+    uint16_t ranging_proto_ver;             // 0xA3
+    uint16_t uwb_cfg_id;                    // 0xA4
+    uint16_t ursk_ttl;                      // 0xA6
+    uint32_t last_sts_index_used;           // 0xA8
+    uint8_t responder_participation_config; // 0xA7
 
     /* Reserved for Vendor Specific Use */
     uint8_t tx_power_level;    // 0xF2
@@ -741,8 +747,8 @@
     uint8_t *data;
 };
 
-/** UWB ranging measurement report */
-struct RANGING_MEASUREMENT_T
+/** UWB two-way ranging measurement report */
+struct TWR_MEASUREMENT_T
 {
     uint8_t mac_addr[8];
     uint8_t status;
@@ -759,8 +765,7 @@
     uint8_t aoa_dst_azimuth_fom;
     uint8_t aoa_dst_elevation_fom;
     uint8_t slot_idx;
-    uint8_t rfu[12];
-    uint8_t reserved;
+    uint32_t rfu[3];
 };
 
 /** UWB ranging data report */
@@ -770,11 +775,41 @@
     uint32_t session_id;
     // unit: ms
     uint32_t ranging_interval;
-    uint8_t rcr_ind;
     uint8_t ranging_type;
+    uint8_t rfu;
     uint8_t mac_addr_mode;
     uint8_t measurements_num;
-    struct RANGING_MEASUREMENT_T measurements[MEASUREMENT_NUM_MAX];
+    struct TWR_MEASUREMENT_T measurements[MEASUREMENT_NUM_MAX];
+};
+
+/** CCC ranging measurement report */
+struct CCC_MEASUREMENT_T
+{
+    uint8_t status;
+    uint8_t slot_index;
+    uint16_t rr_index;
+    uint32_t sts_index;
+    uint16_t distance;
+    uint8_t anchor_fom;
+    uint8_t initiator_fom;
+    int16_t aoa_azimuth;
+    int16_t aoa_elevation;
+    uint8_t aoa_azimuth_fom;
+    uint8_t aoa_elevation_fom;
+};
+
+/** UWB ranging data report */
+struct CCC_RANGE_DATA_T
+{
+    uint32_t sequence_num;
+    uint32_t session_id;
+    // unit: ms
+    uint32_t ranging_interval;
+    uint8_t ranging_type;
+    uint8_t rfu;
+    uint8_t mac_addr_mode;
+    uint8_t measurements_num;
+    struct CCC_MEASUREMENT_T measurements[MEASUREMENT_NUM_MAX];
 };
 
 /** UWB test environment variable */
@@ -786,6 +821,13 @@
     uint8_t *tx_pkt_data;
     uint32_t trx_count_packet; /* This variable used to count how many packets were received or sent */
     uint32_t sync_time;        /* This variable is used to record the timestamp of the synchronization moment (unit:8ns) */
+};
+
+/** UWB data transfer report */
+struct DATA_TRANSFER_T
+{
+    uint16_t length;
+    uint8_t data[256];
 };
 
 /** UWB operations handler */
@@ -801,7 +843,9 @@
     uint8_t (*session_responder_num_get)(void);
     uint16_t (*session_responder_addr_get)(uint8_t idx);
     uint8_t (*session_dynamic_update_responder_list)(uint8_t action, uint16_t addr);
-    void (*session_set_ccc_ursk)(const uint8_t *ursk);
+    void (*session_initiator_addr_set)(uint16_t short_addr);
+    void (*session_controller_addr_set)(uint16_t short_addr);
+    bool (*session_set_ccc_ursk)(uint32_t session_id, const uint8_t *ursk);
     void (*vendor_session_start)(void);
     void (*vendor_session_stop)(void);
     void (*vendor_session_configure)(void);
@@ -853,6 +897,7 @@
 typedef void (*test_per_rx_report_cb_t)(struct TEST_PER_RX_T *report);
 typedef void (*test_rx_report_cb_t)(struct TEST_RX_T *report);
 typedef void (*test_ss_twr_report_cb_t)(uint8_t *, uint32_t);
+typedef void (*test_ds_twr_report_cb_t)(uint8_t *, uint32_t);
 typedef void (*vendor_rx_report_cb_t)(const uint16_t *data_len, const uint8_t *data);
 typedef uint8_t (*vendor_user_defined_data_process_cb_t)(uint16_t cmd_len, const uint8_t *p_cmd);
 
@@ -1042,6 +1087,13 @@
 uint8_t uwbapi_test_ss_twr(test_ss_twr_report_cb_t func);
 
 /**
+ * @brief Start DS-TWR test, This API can be used to measure single DS-TWR ToF using SP0/SP3 packets.
+ * @param[in] func          callback function to report result.
+ * @return UWB Status code @ref UWB_STATUS_T
+ */
+uint8_t uwbapi_test_ds_twr(test_ds_twr_report_cb_t func);
+
+/**
  * @brief Stop the test session.
  * @return UWB Status code @ref UWB_STATUS_T
  */
@@ -1159,11 +1211,12 @@
 
 /**
  * @brief Set URSK for CCC work mode
+ * @param[in] session_id session id
  * @param[in] ursk URSK data.
  * @param[in] len URSK length.
  * @return UWB Status code @ref UWB_STATUS_T
  */
-uint8_t uwbapi_vendor_set_ccc_ursk(const uint8_t *ursk, uint16_t len);
+uint8_t uwbapi_vendor_set_ccc_ursk(uint32_t session_id, const uint8_t *ursk, uint16_t len);
 
 /**
  * @}
@@ -1280,6 +1333,12 @@
 uint8_t uwbs_ccc_uwb_config_id_set(uint16_t uwb_cfg_id);
 
 /**
+ * @brief Set pulse shape combination for CCC.
+ * @param[in] pulseshape_combo  pulse shape combination
+ */
+uint8_t uwbs_ccc_pulseshape_combo_set(uint8_t pulseshape_combo);
+
+/**
  * @brief Clear RSSI statistical result in PER test procedure.
  */
 void uwbs_clear_rssi(void);

--
Gitblit v1.9.3