1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
 * 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