From adfc7e798b9cbdd022bf8df971843436912a0fe5 Mon Sep 17 00:00:00 2001
From: chen <15335560115@163.com>
Date: 星期日, 20 七月 2025 16:58:30 +0800
Subject: [PATCH] 成功移植g_com_map表逻辑,初步测试能读能写,并且TDOA效果和官方一致

---
 keil/include/components/algo/inc/lib_aoa.h |  186 +++++++++++++++-------------------------------
 1 files changed, 61 insertions(+), 125 deletions(-)

diff --git a/keil/include/components/algo/inc/lib_aoa.h b/keil/include/components/algo/inc/lib_aoa.h
index a82a8f4..0030fb0 100644
--- a/keil/include/components/algo/inc/lib_aoa.h
+++ b/keil/include/components/algo/inc/lib_aoa.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019-2023 Beijing Hanwei Innovation Technology Ltd. Co. and
+ * Copyright (c) 2019-2025 Beijing Hanwei Innovation Technology Ltd. Co. and
  * its subsidiaries and affiliates (collectly called MKSEMI).
  *
  * All rights reserved.
@@ -40,7 +40,7 @@
 
 #ifndef AOA_LIB_H
 #define AOA_LIB_H
-#include "mk_uwb.h"
+#include "lib_ranging.h"
 
 /**
  * @addtogroup MK8000_ALGO_AOA
@@ -78,59 +78,21 @@
 
 #endif
 
-// (aux_mode << 4) | (algo_option)
-enum AOA_AUX_OPT_T
-{
-    // 135us
-    AOA_AUX_ANT_IQ_RSSI = ((1 << 4) | 3),
-    // 239us
-    AOA_AUX_ANT_IQ_RSSI_PDOA = ((1 << 4) | 0),
-    // 312us
-    AOA_AUX_ANT_IQ_RSSI_PDOA_AOA = ((1 << 4) | 2),
-    // 930us
-    AOA_AUX_ANT_IQ_RSSI_PDOA_AOA_FOM = ((2 << 4) | 2),
-};
-
-// Structure holding the angle information for steering vector generation
-struct AOA_ANGLE_SPAN_T
-{
-    uint16_t Ndim;    ///> Number of dimensions. 1 - Azimuth only, 2 - Azimuth and Elevation
-    int16_t az_low;   ///> Lower end of azimuth scan range (in degrees)
-    int16_t az_high;  ///> Higher end of azimuth scan range (in degrees)
-    uint16_t az_step; ///> Azimuth step size in degrees. Normally 3
-    int16_t el_low;   ///> Lower end of elevation scan range (in degrees)
-    int16_t el_high;  ///> Higher end of elevation scan range (in degrees)
-    uint16_t el_step; ///> Elevation step size in degrees. Normally 3
-};
-
 #ifdef __cplusplus
 extern "C" {
 #endif
+
+extern int16_t fe_delays_4ports_ps[4];
+extern int16_t g_ant_space;
 
 /**
  * @brief Set angle search span
  *
  * @param [in] span           pointer to AoA angle search span structure
  */
-void aoa_angle_search_span_set(struct AOA_ANGLE_SPAN_T *span);
+void aoa_angle_search_span_set(angle_span_t *span);
 
-/**
- * @brief Configure AoA parameters.
- * @return Size of samples that need LSP to process
- */
-uint16_t aoa_param_config(void);
-
-/**
- * @brief Update AoA parameters.
- * @param [in] main_ant         RX main antenna
- */
-void aoa_param_update(uint8_t main_ant);
-
-/**
- * @brief Enable or disable dynamic port selection
- * @param [in] enable           0: disable, 1: enable
- */
-void aoa_param_dynamic_port_sel(uint8_t enable);
+angle_span_t *aoa_angle_search_span_get(void);
 
 /**
  * @brief Calculate AoA.
@@ -150,71 +112,6 @@
 void aoa_fom_get(uint8_t *elevation_fom, uint8_t *azimuth_fom);
 
 /**
- * @brief Store LSP result of RX ranging frame.
- */
-void sts_lsp_store(void);
-
-/**
- * @brief Stop storing LSP result of RX ranging frame.
- */
-void sts_lsp_store_stop(void);
-
-/**
- * @brief Validate STS.
- * @return 1 represents STS is valid
- */
-uint8_t sts_valid_check(void);
-
-/**
- * @brief Detect the fisrt path of ranging frame based on STS.
- * @param [in] rssi                 RSSI
- * @param [out] sts_main_path_loc   STS main path location
- * @param [out] sts_fap_loc         STS FAP location
- * @return delta of the first path
- */
-int32_t sts_first_path_detect(int8_t rssi, uint16_t *sts_main_path_loc, uint16_t *sts_fap_loc);
-
-/**
- * @brief Calculate RX main antenna based on STS RSSI.
- * @param [in][out]                 Input current main antenna ID, ouput updated main antenna ID
- */
-void sts_rx_main_ant_get(uint8_t *id);
-
-/**
- * @brief Get 4 antenna port RSSI.
- * @return array of 4 antenna port RSSI
- */
-float *sts_4ant_rssi_get(void);
-
-/**
- * @brief Configure location post process filter.
- *
- * @param [in] update_period_ms     Input data update period
- * @param [in] range_en             Enable filter for range data
- * @param [in] angle_en             Enable filter for angle data
- */
-void loc_post_filter_config(uint32_t update_period_ms, uint8_t range_en, uint8_t angle_en);
-
-/**
- * @brief Location post process filter.
- *
- * @param [in] channel              Filter channel
- * @param [in] range_meas           Input range data
- * @param [in] angle_meas           Input angle data
- * @param [out] range_post          Output range data
- * @param [out] angle_post          Output angle data
- * @return 1 represents post filter process successfully
- */
-uint8_t loc_post_filter(uint8_t channel, float range_meas, int angle_meas, float *range_post, float *angle_post);
-
-/**
- * @brief Set AOA aux mode.
- *
- * @param [in] mode     AOA aux mode @ref enum AOA_AUX_OPT_T
- */
-void aoa_aux_info_set(enum AOA_AUX_OPT_T mode);
-
-/**
  * @brief Set AOA steering vector based on channel
  *
  * @param [in] vector_table     AOA steering vector table
@@ -232,11 +129,64 @@
 /**
  * @brief Get PDoA result from ANT_start_index - ANT_end_index.
  *
+ * 4-Antennas
+ * Phase difference from ANT0 to ANT3 = pdoa_result_get(0, 3)
+ * Phase difference from ANT1 to ANT3 = pdoa_result_get(1, 3)
+ * Phase difference from ANT2 to ANT3 = pdoa_result_get(2, 3)
+ *
+ * RX_3PORTS_ANT_3_0_1
+ * Phase difference from ANT0 to ANT3 = pdoa_result_get(1, 0)
+ * Phase difference from ANT1 to ANT3 = pdoa_result_get(2, 0)
+ *
+ * RX_3PORTS_ANT_1_2_3
+ * Phase difference from ANT2 to ANT1 = pdoa_result_get(1, 0)
+ * Phase difference from ANT3 to ANT1 = pdoa_result_get(2, 0)
+ *
+ * RX_3PORTS_ANT_0_1_2
+ * Phase difference from ANT1 to ANT0 = pdoa_result_get(1, 0)
+ * Phase difference from ANT2 to ANT0 = pdoa_result_get(2, 0)
+ *
+ * 2-Antennas
+ * Phase difference = pdoa_result_get(1, 0)
+ *
  * @param [in] start_index      Antenna port start index, from 0 to 3
  * @param [in] end_index        Antenna port end index, from 0 to 3
  * @return PDoA result in radian
  */
-float pdoa_select_get(uint8_t start_index, uint8_t end_index);
+float pdoa_result_get(uint8_t start_index, uint8_t end_index);
+
+/**
+ * @brief Get phase result from specific antenna.
+ *
+ * 4-Antennas
+ * Phase of ANT0 = phase_result_get(0)
+ * Phase of ANT1 = phase_result_get(1)
+ * Phase of ANT2 = phase_result_get(2)
+ * Phase of ANT3 = phase_result_get(3)
+ *
+ * RX_3PORTS_ANT_3_0_1
+ * Phase of ANT3 = phase_result_get(0)
+ * Phase of ANT0 = phase_result_get(1)
+ * Phase of ANT1 = phase_result_get(2)
+ *
+ * RX_3PORTS_ANT_1_2_3
+ * Phase of ANT1 = phase_result_get(0)
+ * Phase of ANT2 = phase_result_get(1)
+ * Phase of ANT3 = phase_result_get(2)
+ *
+ * RX_3PORTS_ANT_0_1_2
+ * Phase of ANT0 = phase_result_get(0)
+ * Phase of ANT1 = phase_result_get(1)
+ * Phase of ANT2 = phase_result_get(2)
+ *
+ * RX_2PORTS_ANT_3_0
+ * Phase of ANT3 = phase_result_get(0)
+ * Phase of ANT0 = phase_result_get(1)
+ *
+ * @param [in] index     Antenna port index, from 0 to 3
+ * @return pahse result in radian
+ */
+float phase_result_get(uint8_t index);
 
 /**
  * @brief Set delay of antenna for PDoA
@@ -262,20 +212,6 @@
  * @param [in] ant_space            the space of adjacent antennas, unit: 0.1mm
  */
 int pdoa_ant_space_set(int16_t ant_space);
-
-/**
- * @brief Get RSSI result.
- *
- * @return RSSI
- */
-float *sts_rssi_output_get(void);
-
-/**
- * @brief Get STS first path IQ of each antenna port, needs to call AoA calculation or PDoA calculation in advanced.
- *
- * @return STS first path IQ
- */
-float *sts_first_path_iq_get(void);
 
 /**
  * @brief Get AoA library version.

--
Gitblit v1.9.3