/*
|
* Copyright (c) 2019-2023 Beijing Hanwei Innovation Technology Ltd. Co. and
|
* its subsidiaries and affiliates (collectly called MKSEMI).
|
*
|
* All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* 1. Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
*
|
* 2. Redistributions in binary form, except as embedded into an MKSEMI
|
* integrated circuit in a product or a software update for such product,
|
* must reproduce the above copyright notice, this list of conditions and
|
* the following disclaimer in the documentation and/or other materials
|
* provided with the distribution.
|
*
|
* 3. Neither the name of MKSEMI nor the names of its contributors may be used
|
* to endorse or promote products derived from this software without
|
* specific prior written permission.
|
*
|
* 4. This software, with or without modification, must only be used with a
|
* MKSEMI integrated circuit.
|
*
|
* 5. Any software provided in binary form under this license must not be
|
* reverse engineered, decompiled, modified and/or disassembled.
|
*
|
* THIS SOFTWARE IS PROVIDED BY MKSEMI "AS IS" AND ANY EXPRESS OR IMPLIED
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
* MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* DISCLAIMED. IN NO EVENT SHALL MKSEMI OR CONTRIBUTORS BE LIABLE FOR ANY
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
*/
|
|
#ifndef AOA_LIB_H
|
#define AOA_LIB_H
|
#include "mk_uwb.h"
|
|
/**
|
* @addtogroup MK8000_ALGO_AOA
|
* @{
|
*
|
* AoA support:
|
* - Linear 2/3/4-ants
|
* - Square 4-ants (horizontal - 360 degree)
|
*
|
*/
|
|
#ifndef AOA_3D_EN
|
#define AOA_3D_EN (0)
|
#endif
|
|
#if AOA_3D_EN
|
|
#ifndef XIP_EN
|
extern const uint32_t svec_ch5_ptr[120 * 19 * RX_ANT_PORTS_NUM];
|
extern const uint32_t svec_ch9_ptr[120 * 19 * RX_ANT_PORTS_NUM];
|
#else
|
extern uint32_t svec_ch5_ptr[120 * 19 * RX_ANT_PORTS_NUM];
|
extern uint32_t svec_ch9_ptr[120 * 19 * RX_ANT_PORTS_NUM];
|
#endif
|
|
#else
|
|
#ifndef XIP_EN
|
extern const uint32_t svec_ch5_ptr[360 * RX_ANT_PORTS_NUM];
|
extern const uint32_t svec_ch9_ptr[360 * RX_ANT_PORTS_NUM];
|
#else
|
extern uint32_t svec_ch5_ptr[360 * RX_ANT_PORTS_NUM];
|
extern uint32_t svec_ch9_ptr[360 * RX_ANT_PORTS_NUM];
|
#endif
|
|
#endif
|
|
/* for 4 symbol based switching, max size is 2*11*256 */
|
/* for segment based switching, max size is 4*11*256 = 11K */
|
/* if set 11k, it has memory issue when run time */
|
/* we may not use segment based switching */
|
#define AOA_STS_SIZE (2 * 11 * 32 + 1)
|
extern float g_sts_lsp_result[AOA_STS_SIZE];
|
|
// (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
|
|
/**
|
* @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);
|
|
/**
|
* @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);
|
|
/**
|
* @brief Calculate AoA.
|
*
|
* @param [out] elevation AoA elevation result
|
* @param [out] azimuth AoA azimuth result
|
* @return 1: success, 2: failure
|
*/
|
uint8_t aoa_calculate(int16_t *elevation, int16_t *azimuth);
|
|
/**
|
* @brief Get AoA FoM.
|
*
|
* @param [out] elevation_fom AoA elevation FoM
|
* @param [out] azimuth_fom AoA azimuth FoM
|
*/
|
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
|
*/
|
void aoa_steering_vector_set(const float *vector_table);
|
|
/**
|
* @brief Get PDoA ANT IQ result.
|
*
|
* @param [out] iq Pointer of raw IQ data for all antennas
|
* @return 1: success, 0: failure
|
*/
|
uint8_t pdoa_iq_get(float **iq);
|
|
/**
|
* @brief Get PDoA result from ANT_start_index - ANT_end_index.
|
*
|
* @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);
|
|
/**
|
* @brief Set delay of antenna for PDoA
|
*
|
* @param [in] delays Delay list of antenna port, uint: ps
|
* @param [in] rx_ant_num The number of antenna delays to be set
|
* @return 0: success, -1: fail
|
*/
|
int pdoa_ant_delays_set(int16_t *delays, uint8_t rx_ant_num);
|
|
/**
|
* @brief Get antenna delay for PDoA
|
*
|
* @param [in] delays Delay list of antenna port, uint: ps
|
* @param [in] rx_ant_num The number of antenna delays to be get
|
* @return 0: success, -1: fail
|
*/
|
int pdoa_ant_delays_get(int16_t *delays, uint8_t rx_ant_num);
|
|
/**
|
* @brief Set adjacent antenna space
|
*
|
* @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.
|
*
|
* @return String of AoA library version
|
*/
|
const char *MK8000_get_aoalib_version(void);
|
|
#ifdef __cplusplus
|
}
|
#endif
|
|
/**
|
* @}
|
*/
|
|
#endif // AOA_LIB_H
|