a121-sys 0.7.0

Raw bindings to the A121 radar sensor C SDK
Documentation
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
// Copyright (c) Acconeer AB, 2020-2025
// All rights reserved

#ifndef ACC_CONFIG_H_
#define ACC_CONFIG_H_

#include <stdbool.h>
#include <stdint.h>

#include "acc_definitions_a121.h"
#include "acc_definitions_common.h"

/**
 * @defgroup config Config
 * @ingroup service
 *
 * @brief Module to configure sensor and processing
 *
 * @{
 */

struct acc_config;

typedef struct acc_config acc_config_t;

/**
 * @brief Create a configuration
 *
 * A configuration is created and populated with default values.
 *
 * @return A configuration instance
 */
acc_config_t *acc_config_create(void);

/**
 * @brief Destroy a configuration freeing any resources allocated
 *
 * Destroy a configuration that is no longer needed.
 *
 * @param[in] config The configuration to destroy, can be NULL
 */
void acc_config_destroy(acc_config_t *config);

/**
 * @brief Print a configuration to the log
 *
 * @param[in] config The configuration to log
 */
void acc_config_log(const acc_config_t *config);

/**
 * @brief Set the starting point of the sweep
 *
 * This sets the starting point of the sweep. The corresponding start
 * in millimeter is approximately start_point * 2.5 mm. For the exact
 * distance in meter, use the @ref acc_processing_points_to_meter function.
 *
 * @param[in] config The configuration
 * @param[in] start_point The starting point of the sweep
 */
void acc_config_start_point_set(acc_config_t *config, int32_t start_point);

/**
 * @brief Get the starting point of the sweep
 *
 * @see acc_config_start_point_set
 *
 * @param[in] config The configuration
 * @return The starting point of the sweep
 */
int32_t acc_config_start_point_get(const acc_config_t *config);

/**
 * @brief Set the number of data points to measure
 *
 * This sets the number of data points to measure in a sweep.
 *
 * @param[in] config The configuration
 * @param[in] num_points Number of data points to measure
 */
void acc_config_num_points_set(acc_config_t *config, uint16_t num_points);

/**
 * @brief Get the number of data points to measure
 *
 * @see acc_config_num_points_set
 *
 * @param[in] config The configuration
 * @return Number of data points to measure
 */
uint16_t acc_config_num_points_get(const acc_config_t *config);

/**
 * @brief Set the step length in a sweep
 *
 * This sets the number of steps to have between each data point.
 *
 * Sampling produces complex (IQ) data points with configurable distance spacing,
 * starting from ~2.5mm.
 *
 * The step length has the following constraints:
 * if step_length <= 24:
 *   24 % step_length == 0
 *
 * if step_length > 24:
 *   step_length % 24 == 0
 *
 * This leads to the following valid values:
 * 1, 2, 3, 4, 6, 8, 12, 24, 48, 72 ...
 *
 * @param[in] config The configuration
 * @param[in] step_length The step length
 */
void acc_config_step_length_set(acc_config_t *config, uint16_t step_length);

/**
 * @brief Get the step length in a sweep
 *
 * @see acc_config_step_length_set
 *
 * @param[in] config The configuration
 * @return The step length
 */
uint16_t acc_config_step_length_get(const acc_config_t *config);

/**
 * @brief Set a profile
 *
 * Each profile consists of a number of settings for the sensor that configures
 * the RX and TX paths. Lower profiles have higher depth resolution while
 * higher profiles have higher SNR.
 *
 * @param[in] config The config to set a profile for
 * @param[in] profile The profile to set
 */
void acc_config_profile_set(acc_config_t *config, acc_config_profile_t profile);

/**
 * @brief Get the currently used profile
 *
 * See @ref acc_config_profile_set
 *
 * @param[in] config The config to get a profile for
 * @return The profile currently used
 */
acc_config_profile_t acc_config_profile_get(const acc_config_t *config);

/**
 * @brief Set the hardware accelerated average samples (HWAAS)
 *
 * Each data point can be sampled several times and the sensor hardware then
 * produces an average value of those samples. The time needed to measure a sweep is roughly proportional
 * to the number of averaged samples. Hence, if there is a need to obtain a higher update rate, HWAAS
 * could be decreased but this leads to lower SNR.
 *
 * HWAAS must be between 1 and 511 inclusive
 *
 * @param[in] config The config to set HWAAS for
 * @param[in] hwaas Hardware accelerated average samples
 */
void acc_config_hwaas_set(acc_config_t *config, uint16_t hwaas);

/**
 * @brief Get the hardware accelerated average samples (HWAAS)
 *
 * @see acc_config_hwaas_set
 *
 * @param[in] config The config to get HWAAS from
 * @return Hardware accelerated average samples
 */
uint16_t acc_config_hwaas_get(const acc_config_t *config);

/**
 * @brief Set receiver gain setting
 *
 * Must be a value between 0 and 23 inclusive where 23 is the highest gain and 0 the lowest.
 *
 * Lower gain gives higher SNR. However, too low gain may result in quantization, lowering SNR.
 * Too high gain may result in saturation, corrupting the data.
 *
 * @param[in] config The configuration
 * @param[in] gain Receiver gain setting
 */
void acc_config_receiver_gain_set(acc_config_t *config, uint8_t gain);

/**
 * @brief Get receiver gain setting
 *
 * See @ref acc_config_receiver_gain_set
 *
 * @param[in] config The configuration
 * @return Receiver gain setting
 */
uint8_t acc_config_receiver_gain_get(const acc_config_t *config);

/**
 * @brief Set sweeps per frame
 *
 * Sets the number of sweeps that will be captured in each frame (measurement).
 * Can be set to 0 if e.g. only temperature measurement is wanted.
 *
 * @param[in] config The configuration
 * @param[in] sweeps Sweeps per frame
 */
void acc_config_sweeps_per_frame_set(acc_config_t *config, uint16_t sweeps);

/**
 * @brief Get the number of sweeps per frame
 *
 * See @ref acc_config_sweeps_per_frame_set
 *
 * @param[in] config The configuration
 * @return Sweeps per frame
 */
uint16_t acc_config_sweeps_per_frame_get(const acc_config_t *config);

/**
 * @brief Set the sweep rate
 *
 * Sets the sweep rate for sweeps in a frame (measurement).
 *
 * @param[in] config The configuration
 * @param[in] sweep_rate Sweep rate in Hz. Must be >= 0, 0 is interpreted as max sweep rate
 */
void acc_config_sweep_rate_set(acc_config_t *config, float sweep_rate);

/**
 * @brief Get the sweep rate
 *
 * See @ref acc_config_sweep_rate_set
 *
 * @param[in] config The configuration
 * @return Sweep rate in Hz
 */
float acc_config_sweep_rate_get(const acc_config_t *config);

/**
 * @brief Set continuous sweep mode
 *
 * In continuous sweep mode the timing will be identical over all sweeps, not
 * just the sweeps in a frame.
 *
 * Constraints:
 * - Frame rate must be set to unlimited (0.0)
 * - Sweep rate must be set (> 0)
 * - Inter frame idle state must be set equal to inter sweep idle state
 *
 * @param[in] config The configuration
 * @param[in] enabled true if continuous sweep mode should be enabled, false otherwise
 */
void acc_config_continuous_sweep_mode_set(acc_config_t *config, bool enabled);

/**
 * @brief Get continuous sweep mode
 *
 * See @ref acc_config_continuous_sweep_mode_set
 *
 * @param[in] config The configuration
 * @return true if continuous sweep mode is enabled, false otherwise
 */
bool acc_config_continuous_sweep_mode_get(const acc_config_t *config);

/**
 * @brief Set the frame rate
 *
 * Sets the frame rate.
 *
 * Setting the frame rate to unlimited (0) means that the rate is not limited by the
 * sensor but the rate that the host acknowledge and reads out the measurement data.
 *
 * @param[in] config The configuration
 * @param[in] frame_rate Frame rate in Hz. Must be >= 0, 0 is interpreted as unlimited
 */
void acc_config_frame_rate_set(acc_config_t *config, float frame_rate);

/**
 * @brief Get the frame rate
 *
 * See @ref acc_config_frame_rate_set
 *
 * @param[in] config The configuration
 * @return Frame rate
 */
float acc_config_frame_rate_get(const acc_config_t *config);

/**
 * @brief Enable or disable the transmitter
 *
 * If set to true, TX is enabled. This will enable the radio transmitter.
 * By turning the transmitter off the RX noise floor can be measured.
 *
 * @param[in] config The configuration
 * @param[in] enable true to enable the transmitter, false to disable it
 */
void acc_config_enable_tx_set(acc_config_t *config, bool enable);

/**
 * @brief Get transmitter enable configuration
 *
 * See @ref acc_config_enable_tx_set
 *
 * @param[in] config The configuration
 * @return true if the transmitter is enabled, false if it is disabled
 */
bool acc_config_enable_tx_get(const acc_config_t *config);

/**
 * @brief Set inter frame idle state
 *
 * The 'inter-frame idle state' is the state the sensor idles in between each frame.
 *
 * See also @ref acc_config_idle_state_t.
 *
 * The inter frame idle state of the frame must be deeper or the same as the inter sweep idle state.
 *
 * @param[in] config The configuration
 * @param[in] idle_state The idle state to use between frames
 */
void acc_config_inter_frame_idle_state_set(acc_config_t *config, acc_config_idle_state_t idle_state);

/**
 * @brief Get inter frame idle state
 *
 * See @ref acc_config_inter_frame_idle_state_set
 *
 * @param[in] config The configuration
 * @return The idle state to use between frames
 */
acc_config_idle_state_t acc_config_inter_frame_idle_state_get(const acc_config_t *config);

/**
 * @brief Set inter sweep idle state
 *
 * The 'inter-sweep idle state' is the state the sensor idles in between each sweep in a frame.
 *
 * See also @ref acc_config_idle_state_t.
 *
 * @param[in] config The configuration
 * @param[in] idle_state The idle state to use between sweeps within a frame
 */
void acc_config_inter_sweep_idle_state_set(acc_config_t *config, acc_config_idle_state_t idle_state);

/**
 * @brief Get inter sweep idle state
 *
 * See @ref acc_config_inter_sweep_idle_state_set
 *
 * @param[in] config The configuration
 * @return The idle state to use between sweeps within a frame
 */
acc_config_idle_state_t acc_config_inter_sweep_idle_state_get(const acc_config_t *config);

/**
 * @brief Set Pulse Repetition Frequency
 *
 * See @ref acc_config_prf_t for details.
 *
 * @param[in] config The configuration
 * @param[in] prf The Pulse Repetition Frequency to use
 */
void acc_config_prf_set(acc_config_t *config, acc_config_prf_t prf);

/**
 * @brief Get Pulse Repetition Frequency
 *
 * See @ref acc_config_prf_t for details.
 *
 * @param[in] config The configuration
 * @return Pulse Repetition Frequency
 */
acc_config_prf_t acc_config_prf_get(const acc_config_t *config);

/**
 * @brief Enable or disable phase enhancement
 *
 * If enabled, the data phase will be enhanced such that coherent distance filtering can be applied.
 * Given a single reflection from an object, the phase will appear as "flat" around the amplitude peak.
 *
 * Enabling the phase enhancement increases the processing execution time.
 *
 * @param[in] config The configuration
 * @param[in] enable true if phase enhancement should be enabled, false otherwise
 */
void acc_config_phase_enhancement_set(acc_config_t *config, bool enable);

/**
 * @brief Get the phase enhancement configuration
 *
 * See @ref acc_config_phase_enhancement_set
 *
 * @param[in] config The configuration
 * @return true if phase enhancement is enabled, false otherwise
 */
bool acc_config_phase_enhancement_get(const acc_config_t *config);

/**
 * @brief Enable or disable the IQ imbalance compensation
 *
 * @param[in] config The configuration
 * @param[in] enable true if IQ imbalance compensation should be enabled, false otherwise
 */
void acc_config_iq_imbalance_compensation_set(acc_config_t *config, bool enable);

/**
 * @brief Get the IQ imbalance compensation configuration
 *
 * See @ref acc_config_iq_imbalance_compensation_set
 *
 * @param[in] config The configuration
 * @return true if IQ imbalance compensation is enabled, false otherwise
 */
bool acc_config_iq_imbalance_compensation_get(const acc_config_t *config);

/**
 * @brief Enable or disable loopback
 *
 * Constraints:
 * - Loopback can't be enabled together with profile 2.
 *
 * @param[in] config The configuration
 * @param[in] enable true if loopback should be enabled, false otherwise
 */
void acc_config_enable_loopback_set(acc_config_t *config, bool enable);

/**
 * @brief Get the enable loopback configuration
 *
 * See @ref acc_config_enable_loopback_set
 *
 * @param[in] config The configuration
 * @return true if loopback is enabled, false otherwise
 */
bool acc_config_enable_loopback_get(const acc_config_t *config);

/**
 * @brief Enable or disable double buffering
 *
 * If enabled, the sensor buffer will be split in two halves reducing the
 * maximum number of samples. A frame can be read using @ref acc_sensor_read while
 * sampling is done into the other buffer. Switching of buffers is done automatically
 * by @ref acc_sensor_measure.
 *
 * When using double buffering, measurements coinciding with SPI activity may have distorted phase.
 * To mitigate this issue, applying a median filter is recommended.
 *
 * @param[in] config The configuration
 * @param[in] enable true if double buffering should be enabled, false otherwise
 */
void acc_config_double_buffering_set(acc_config_t *config, bool enable);

/**
 * @brief Get the double buffering configuration
 *
 * See @ref acc_config_double_buffering_set
 *
 * @param[in] config The configuration
 * @return true if double buffering is enabled, false otherwise
 */
bool acc_config_double_buffering_get(const acc_config_t *config);

/**
 * @}
 */

#endif