/*
|
* Copyright (c) 2019-2025 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 "lib_ranging.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
|
|
#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(angle_span_t *span);
|
|
angle_span_t *aoa_angle_search_span_get(void);
|
|
/**
|
* @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 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.
|
*
|
* 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_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
|
*
|
* @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 AoA library version.
|
*
|
* @return String of AoA library version
|
*/
|
const char *MK8000_get_aoalib_version(void);
|
|
#ifdef __cplusplus
|
}
|
#endif
|
|
/**
|
* @}
|
*/
|
|
#endif // AOA_LIB_H
|