example_detector_distance_with_iq_data_print.c
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2023
2 // All rights reserved
3 // This file is subject to the terms and conditions defined in the file
4 // 'LICENSES/license_acconeer.txt', (BSD 3-Clause License) which is part
5 // of this source code package.
6
7 #include <math.h>
8 #include <stdbool.h>
9 #include <stdint.h>
10 #include <stdio.h>
11 #include <stdlib.h>
12
13 #include "acc_definitions_a121.h"
14 #include "acc_detector_distance.h"
15 #include "acc_hal_definitions_a121.h"
16 #include "acc_hal_integration_a121.h"
17 #include "acc_integration.h"
18 #include "acc_integration_log.h"
19 #include "acc_rss_a121.h"
20 #include "acc_sensor.h"
21 #include "acc_version.h"
22
23
24 /** \example example_detector_distance_with_iq_data_print.c
25 * @brief This is an example on how the Detector Distance API can be used
26 * @n
27 * This example executes as follows:
28 * - Retrieve HAL integration
29 * - Initialize distance detector resources:
30 * + Create distance detector configuration
31 * + Update configuration settings
32 * + Create Distance detector handle
33 * + Create buffer for detector calibration data
34 * + Create buffer for sensor data
35 * - Create and calibrate the sensor
36 * - Calibrate the detector
37 * - Measure distances with the detector (loop):
38 * + Prepare sensor with the detector
39 * + Measure and wait until a read can be done
40 * + Print IQ data amplitude
41 * + Process measurement and print the result
42 * + Handle "sensor_calibration_needed" indication
43 * - Cleanup:
44 * + Destroy detector configuration
45 * + Destroy detector handle
46 * + Destroy sensor data buffer
47 * + Destroy detector calibration data buffer
48 */
49
50
51 typedef enum
52 {
53 DISTANCE_PRESET_CONFIG_NONE = 0,
54 DISTANCE_PRESET_CONFIG_BALANCED,
55 DISTANCE_PRESET_CONFIG_HIGH_ACCURACY,
56 } distance_preset_config_t;
57
58
59 #define SENSOR_ID (1U)
60 // 2 seconds should be enough even for long ranges and high signal quality
61 #define SENSOR_TIMEOUT_MS (2000U)
62
63
64 typedef struct
65 {
66 acc_sensor_t *sensor;
67 acc_detector_distance_config_t *config;
68 acc_detector_distance_handle_t *handle;
69 void *buffer;
70 uint32_t buffer_size;
71 void *calibration_buffer;
72 uint32_t calibration_buffer_size;
73 } distance_detector_resources_t;
74
75
76 static void cleanup(distance_detector_resources_t *resources);
77
78
79 static void set_config(acc_detector_distance_config_t *detector_config, distance_preset_config_t preset);
80
81
82 static bool initialize_detector_resources(distance_detector_resources_t *resources);
83
84
85 static bool do_sensor_calibration(acc_sensor_t *sensor,
86 acc_cal_result_t *sensor_cal_result,
87 void *buffer,
88 uint32_t buffer_size);
89
90
91 static bool do_full_detector_calibration(distance_detector_resources_t *resources,
92 const acc_cal_result_t *sensor_cal_result);
93
94
95 static bool do_detector_recalibration(distance_detector_resources_t *resources,
96 const acc_cal_result_t *sensor_cal_result);
97
98
99 static bool do_detector_get_next(distance_detector_resources_t *resources,
100 const acc_cal_result_t *sensor_cal_result,
101 acc_detector_distance_result_t *result);
102
103
104 static void print_distance_result(const acc_detector_distance_result_t *result);
105
106
107 static void print_iq_data(const acc_config_t *sensor_config,
108 acc_processing_result_t *processing_result,
109 acc_processing_metadata_t *processing_metadata);
110
111
112 int acconeer_main(int argc, char *argv[]);
113
114
115 int acconeer_main(int argc, char *argv[])
116 {
117 (void)argc;
118 (void)argv;
119 distance_detector_resources_t resources = { 0 };
120
121 printf("Acconeer software version %s\n", acc_version_get());
122
123 const acc_hal_a121_t *hal = acc_hal_rss_integration_get_implementation();
124
125 if (!acc_rss_hal_register(hal))
126 {
127 return EXIT_FAILURE;
128 }
129
130 resources.config = acc_detector_distance_config_create();
131 if (resources.config == NULL)
132 {
133 printf("acc_detector_distance_config_create() failed\n");
134 cleanup(&resources);
135 return EXIT_FAILURE;
136 }
137
138 set_config(resources.config, DISTANCE_PRESET_CONFIG_BALANCED);
139
140 if (!initialize_detector_resources(&resources))
141 {
142 printf("Initializing detector resources failed\n");
143 cleanup(&resources);
144 return EXIT_FAILURE;
145 }
146
147 // Print the configuration
148 acc_detector_distance_config_log(resources.handle, resources.config);
149
150 /* Turn the sensor on */
151 acc_hal_integration_sensor_supply_on(SENSOR_ID);
152 acc_hal_integration_sensor_enable(SENSOR_ID);
153
154 resources.sensor = acc_sensor_create(SENSOR_ID);
155 if (resources.sensor == NULL)
156 {
157 printf("acc_sensor_create() failed\n");
158 cleanup(&resources);
159 return EXIT_FAILURE;
160 }
161
162 acc_cal_result_t sensor_cal_result;
163
164 if (!do_sensor_calibration(resources.sensor, &sensor_cal_result, resources.buffer, resources.buffer_size))
165 {
166 printf("Sensor calibration failed\n");
167 cleanup(&resources);
168 return EXIT_FAILURE;
169 }
170
171 if (!do_full_detector_calibration(&resources, &sensor_cal_result))
172 {
173 printf("Detector calibration failed\n");
174 cleanup(&resources);
175 return EXIT_FAILURE;
176 }
177
178 while (true)
179 {
180 acc_detector_distance_result_t result = { 0 };
181
182 if (!do_detector_get_next(&resources, &sensor_cal_result, &result))
183 {
184 printf("Could not get next result\n");
185 cleanup(&resources);
186 return EXIT_FAILURE;
187 }
188
189 print_distance_result(&result);
190
191 /* If "sensor calibration needed" is indicated, the sensor and detector needs to be recalibrated.
192 *
193 * Note that the detector result (printed above) is invalid if 'sensor_calibration_needed' is true.
194 */
195 if (result.sensor_calibration_needed)
196 {
197 printf("Sensor- and detector recalibration needed ... \n");
198
199 if (!do_sensor_calibration(resources.sensor, &sensor_cal_result, resources.buffer, resources.buffer_size))
200 {
201 printf("Sensor calibration failed\n");
202 cleanup(&resources);
203 return EXIT_FAILURE;
204 }
205
206 /* Once the sensor is recalibrated, the detector should be recalibrated and measuring can continue. */
207 if (!do_detector_recalibration(&resources, &sensor_cal_result))
208 {
209 printf("Detector recalibration failed\n");
210 cleanup(&resources);
211 return EXIT_FAILURE;
212 }
213
214 printf("Sensor- and detector recalibration done!\n");
215 }
216 }
217
218 cleanup(&resources);
219
220 printf("Done!\n");
221
222 return EXIT_SUCCESS;
223 }
224
225
226 static void cleanup(distance_detector_resources_t *resources)
227 {
228 acc_hal_integration_sensor_disable(SENSOR_ID);
229 acc_hal_integration_sensor_supply_off(SENSOR_ID);
230
231 acc_detector_distance_config_destroy(resources->config);
232 acc_detector_distance_destroy(resources->handle);
233
234 acc_integration_mem_free(resources->buffer);
235 acc_integration_mem_free(resources->calibration_buffer);
236
237 if (resources->sensor != NULL)
238 {
239 acc_sensor_destroy(resources->sensor);
240 }
241 }
242
243
244 static void set_config(acc_detector_distance_config_t *detector_config, distance_preset_config_t preset)
245 {
246 // Add configuration of the detector here
247 switch (preset)
248 {
249 case DISTANCE_PRESET_CONFIG_NONE:
250 // Add configuration of the detector here
251 break;
252
253 case DISTANCE_PRESET_CONFIG_BALANCED:
254 acc_detector_distance_config_start_set(detector_config, 0.25f);
255 acc_detector_distance_config_end_set(detector_config, 3.0f);
256 acc_detector_distance_config_max_step_length_set(detector_config, 0U);
257 acc_detector_distance_config_max_profile_set(detector_config, ACC_CONFIG_PROFILE_5);
258 acc_detector_distance_config_reflector_shape_set(detector_config, ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC);
259 acc_detector_distance_config_peak_sorting_set(detector_config, ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST);
260 acc_detector_distance_config_threshold_method_set(detector_config, ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR);
261 acc_detector_distance_config_num_frames_recorded_threshold_set(detector_config, 100U);
262 acc_detector_distance_config_threshold_sensitivity_set(detector_config, 0.5f);
263 acc_detector_distance_config_signal_quality_set(detector_config, 15.0f);
264 acc_detector_distance_config_close_range_leakage_cancellation_set(detector_config, true);
265 break;
266
267 case DISTANCE_PRESET_CONFIG_HIGH_ACCURACY:
268 acc_detector_distance_config_start_set(detector_config, 0.25f);
269 acc_detector_distance_config_end_set(detector_config, 3.0f);
270 acc_detector_distance_config_max_step_length_set(detector_config, 2U);
271 acc_detector_distance_config_max_profile_set(detector_config, ACC_CONFIG_PROFILE_3);
272 acc_detector_distance_config_reflector_shape_set(detector_config, ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC);
273 acc_detector_distance_config_peak_sorting_set(detector_config, ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST);
274 acc_detector_distance_config_threshold_method_set(detector_config, ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR);
275 acc_detector_distance_config_num_frames_recorded_threshold_set(detector_config, 100U);
276 acc_detector_distance_config_threshold_sensitivity_set(detector_config, 0.5f);
277 acc_detector_distance_config_signal_quality_set(detector_config, 20.0f);
278 acc_detector_distance_config_close_range_leakage_cancellation_set(detector_config, true);
279 break;
280 }
281 }
282
283
284 static bool initialize_detector_resources(distance_detector_resources_t *resources)
285 {
286 resources->handle = acc_detector_distance_create(resources->config);
287 if (resources->handle == NULL)
288 {
289 printf("acc_detector_distance_create() failed\n");
290 return false;
291 }
292
293 if (!acc_detector_distance_get_buffer_sizes(resources->handle, &(resources->buffer_size), &(resources->calibration_buffer_size)))
294 {
295 printf("acc_detector_distance_get_buffer_sizes() failed\n");
296 return false;
297 }
298
299 resources->buffer = acc_integration_mem_alloc(resources->buffer_size);
300 if (resources->buffer == NULL)
301 {
302 printf("sensor buffer allocation failed\n");
303 return false;
304 }
305
306 resources->calibration_buffer = acc_integration_mem_alloc(resources->calibration_buffer_size);
307 if (resources->calibration_buffer == NULL)
308 {
309 printf("calibration buffer allocation failed\n");
310 return false;
311 }
312
313 return true;
314 }
315
316
317 static bool do_sensor_calibration(acc_sensor_t *sensor,
318 acc_cal_result_t *sensor_cal_result,
319 void *buffer,
320 uint32_t buffer_size)
321 {
322 bool status = false;
323 bool cal_complete = false;
324 const uint16_t calibration_retries = 1U;
325
326 // Random disturbances may cause the calibration to fail. At failure, retry at least once.
327 for (uint16_t i = 0; !status && (i <= calibration_retries); i++)
328 {
329 // Reset sensor before calibration by disabling/enabling it
330 acc_hal_integration_sensor_disable(SENSOR_ID);
331 acc_hal_integration_sensor_enable(SENSOR_ID);
332
333 do
334 {
335 status = acc_sensor_calibrate(sensor, &cal_complete, sensor_cal_result, buffer, buffer_size);
336
337 if (status && !cal_complete)
338 {
339 status = acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS);
340 }
341 } while (status && !cal_complete);
342 }
343
344 if (status)
345 {
346 /* Reset sensor after calibration by disabling/enabling it */
347 acc_hal_integration_sensor_disable(SENSOR_ID);
348 acc_hal_integration_sensor_enable(SENSOR_ID);
349 }
350
351 return status;
352 }
353
354
355 static bool do_full_detector_calibration(distance_detector_resources_t *resources,
356 const acc_cal_result_t *sensor_cal_result)
357 {
358 bool done = false;
359 bool status;
360
361 do
362 {
363 status = acc_detector_distance_calibrate(resources->sensor,
364 resources->handle,
365 sensor_cal_result,
366 resources->buffer,
367 resources->buffer_size,
368 resources->calibration_buffer,
369 resources->calibration_buffer_size,
370 &done);
371
372 if (status && !done)
373 {
374 status = acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS);
375 }
376 } while (status && !done);
377
378 return status;
379 }
380
381
382 static bool do_detector_recalibration(distance_detector_resources_t *resources,
383 const acc_cal_result_t *sensor_cal_result)
384 {
385 bool done = false;
386 bool status;
387
388 do
389 {
390 status = acc_detector_distance_recalibrate(resources->sensor,
391 resources->handle,
392 sensor_cal_result,
393 resources->buffer,
394 resources->buffer_size,
395 resources->calibration_buffer,
396 resources->calibration_buffer_size,
397 &done);
398
399 if (status && !done)
400 {
401 status = acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS);
402 }
403 } while (status && !done);
404
405 return status;
406 }
407
408
409 static bool do_detector_get_next(distance_detector_resources_t *resources,
410 const acc_cal_result_t *sensor_cal_result,
411 acc_detector_distance_result_t *result)
412 {
413 bool result_available = false;
414
415 do
416 {
417 if (!acc_detector_distance_prepare(resources->handle, resources->config, resources->sensor, sensor_cal_result, resources->buffer,
418 resources->buffer_size))
419 {
420 printf("acc_detector_distance_prepare() failed\n");
421 return false;
422 }
423
424 if (!acc_sensor_measure(resources->sensor))
425 {
426 printf("acc_sensor_measure() failed\n");
427 return false;
428 }
429
430 if (!acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS))
431 {
432 printf("Sensor interrupt timeout\n");
433 return false;
434 }
435
436 if (!acc_sensor_read(resources->sensor, resources->buffer, resources->buffer_size))
437 {
438 printf("acc_sensor_read() failed\n");
439 return false;
440 }
441
442 if (!acc_detector_distance_process(resources->handle, resources->buffer, resources->calibration_buffer, &result_available,
443 result))
444 {
445 printf("acc_detector_distance_process() failed\n");
446 return false;
447 }
448
449 /**
450 * The function for printing the IQ data must be called every time
451 * the acc_detector_distance_process has been called.
452 */
453 print_iq_data(result->sensor_config, result->processing_result, result->processing_metadata);
454 } while (!result_available);
455
456 return true;
457 }
458
459
460 static void print_iq_data(const acc_config_t *sensor_config,
461 acc_processing_result_t *processing_result,
462 acc_processing_metadata_t *processing_metadata)
463 {
464 /* Get the iq data frame from the processing result */
465 acc_int16_complex_t *frame = processing_result->frame;
466
467 /* Get information about the frame from the sensor config */
468 uint16_t sweeps_per_frame = acc_config_sweeps_per_frame_get(sensor_config);
469 uint8_t num_subsweeps = acc_config_num_subsweeps_get(sensor_config);
470
471 printf("BEGIN:Distance(m),Amplitude\n");
472
473 /* Loop over all subsweeps */
474 for (uint8_t subsweep_idx = 0; subsweep_idx < num_subsweeps; subsweep_idx++)
475 {
476 /* Get information about the start point and step length from the sensor config */
477 int32_t start_point = acc_config_subsweep_start_point_get(sensor_config, subsweep_idx);
478 uint16_t step_length = acc_config_subsweep_step_length_get(sensor_config, subsweep_idx);
479
480 /* Get subsweep offset and length from the processing metadata */
481 uint16_t subsweep_offset = processing_metadata->subsweep_data_offset[subsweep_idx];
482 uint16_t subsweep_length = processing_metadata->subsweep_data_length[subsweep_idx];
483
484 /* Loop over all points in subsweep */
485 for (uint16_t point_idx = 0; point_idx < subsweep_length; point_idx++)
486 {
487 /* Perform a coherent mean calculation for the point over sweeps per frame */
488 uint32_t iq_point_real_acc = 0;
489 uint32_t iq_point_imag_acc = 0;
490
491 /* Loop over all points in sweeps_per_frame */
492 for (uint16_t sweep_idx = 0; sweep_idx < sweeps_per_frame; sweep_idx++)
493 {
494 uint16_t point_offset = sweep_idx * subsweep_length + subsweep_offset + point_idx;
495 iq_point_real_acc += frame[point_offset].real;
496 iq_point_imag_acc += frame[point_offset].imag;
497 }
498
499 iq_point_real_acc = iq_point_real_acc / sweeps_per_frame;
500 iq_point_imag_acc = iq_point_imag_acc / sweeps_per_frame;
501
502 /* Calculate the absolute value of the IQ point */
503 uint32_t iq_point_abs = (uint32_t)sqrt(iq_point_real_acc * iq_point_real_acc + iq_point_imag_acc * iq_point_imag_acc);
504
505 /* Print the point distance, in meters, and the point absolute value */
506 float distance = acc_processing_points_to_meter(start_point + point_idx*step_length);
507 printf("%" PRIfloat ",%" PRIu32 "\n", ACC_LOG_FLOAT_TO_INTEGER(distance), iq_point_abs);
508 }
509 }
510
511 printf("END:Distance(m),Amplitude\n");
512 }
513
514
515 static void print_distance_result(const acc_detector_distance_result_t *result)
516 {
517 printf("%d detected distances", result->num_distances);
518 if (result->num_distances > 0)
519 {
520 printf(": ");
521
522 for (uint8_t i = 0; i < result->num_distances; i++)
523 {
524 printf("%" PRIfloat " m ", ACC_LOG_FLOAT_TO_INTEGER(result->distances[i]));
525 }
526 }
527
528 printf("\n");
529 }
ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC
@ ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC
Definition: acc_detector_distance_definitions.h:42
acc_detector_distance_result_t::processing_result
acc_processing_result_t * processing_result
Definition: acc_detector_distance.h:87
acc_hal_integration_sensor_supply_off
void acc_hal_integration_sensor_supply_off(acc_sensor_id_t sensor_id)
Power off sensor supply.
Definition: acc_hal_integration_stm32cube_xm.c:113
acc_rss_a121.h
acc_processing_metadata_t::subsweep_data_offset
uint16_t subsweep_data_offset[(4U)]
Definition: acc_processing.h:43
acc_detector_distance_config_peak_sorting_set
void acc_detector_distance_config_peak_sorting_set(acc_detector_distance_config_t *config, acc_detector_distance_peak_sorting_t peak_sorting)
Set the peak sorting method.
DISTANCE_PRESET_CONFIG_HIGH_ACCURACY
@ DISTANCE_PRESET_CONFIG_HIGH_ACCURACY
Definition: example_detector_distance_with_iq_data_print.c:55
acc_hal_integration_sensor_supply_on
void acc_hal_integration_sensor_supply_on(acc_sensor_id_t sensor_id)
Power on sensor supply.
Definition: acc_hal_integration_stm32cube_xm.c:107
acc_processing_result_t
Result provided by the processing module.
Definition: acc_processing.h:71
do_detector_get_next
static bool do_detector_get_next(distance_detector_resources_t *resources, const acc_cal_result_t *sensor_cal_result, acc_detector_distance_result_t *result)
Definition: example_detector_distance_with_iq_data_print.c:409
acc_sensor_read
bool acc_sensor_read(const acc_sensor_t *sensor, void *buffer, uint32_t buffer_size)
Read out radar data.
acc_version.h
ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST
@ ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST
Definition: acc_detector_distance_definitions.h:16
acc_config_num_subsweeps_get
uint8_t acc_config_num_subsweeps_get(const acc_config_t *config)
Get the number of subsweeps to use.
cleanup
static void cleanup(distance_detector_resources_t *resources)
Definition: example_detector_distance_with_iq_data_print.c:226
acc_int16_complex_t
Data type for interger-based representation of complex numbers.
Definition: acc_definitions_common.h:43
distance_detector_resources_t::buffer_size
uint32_t buffer_size
Definition: i2c_distance_detector.c:37
acc_detector_distance_config_threshold_method_set
void acc_detector_distance_config_threshold_method_set(acc_detector_distance_config_t *config, acc_detector_distance_threshold_method_t threshold_method)
Set the threshold method.
print_distance_result
static void print_distance_result(const acc_detector_distance_result_t *result)
Definition: example_detector_distance_with_iq_data_print.c:515
acc_cal_result_t
Definition: acc_definitions_a121.h:19
acc_detector_distance_config_start_set
void acc_detector_distance_config_start_set(acc_detector_distance_config_t *config, float start_m)
Set the start of measured interval in meters.
acconeer_main
int acconeer_main(int argc, char *argv[])
Assembly test example.
Definition: example_detector_distance_with_iq_data_print.c:115
acc_detector_distance_get_buffer_sizes
bool acc_detector_distance_get_buffer_sizes(const acc_detector_distance_handle_t *handle, uint32_t *buffer_size, uint32_t *calibration_buffer_size)
Get the buffer sizes needed given the provided detector handle.
acc_detector_distance_recalibrate
bool acc_detector_distance_recalibrate(acc_sensor_t *sensor, acc_detector_distance_handle_t *handle, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, void *calibration_buffer, uint32_t calibration_buffer_size, bool *calibration_complete)
Do a detector recalibration.
acc_integration.h
acc_detector_distance_result_t::num_distances
uint8_t num_distances
Definition: acc_detector_distance.h:62
acc_detector_distance_create
acc_detector_distance_handle_t * acc_detector_distance_create(const acc_detector_distance_config_t *config)
Create a distance detector with the provided configuration.
do_sensor_calibration
static bool do_sensor_calibration(acc_sensor_t *sensor, acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
Definition: example_detector_distance_with_iq_data_print.c:317
ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR
@ ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR
Definition: acc_detector_distance_definitions.h:32
acc_detector_distance_config_destroy
void acc_detector_distance_config_destroy(acc_detector_distance_config_t *config)
Destroy a configuration for a distance detector.
DISTANCE_PRESET_CONFIG_BALANCED
@ DISTANCE_PRESET_CONFIG_BALANCED
Definition: example_detector_distance_with_iq_data_print.c:54
acc_hal_rss_integration_get_implementation
const acc_hal_a121_t * acc_hal_rss_integration_get_implementation(void)
Get hal implementation reference.
Definition: acc_hal_integration_stm32cube_xm.c:166
DISTANCE_PRESET_CONFIG_NONE
@ DISTANCE_PRESET_CONFIG_NONE
Definition: example_detector_distance_with_iq_data_print.c:53
acc_detector_distance_process
bool acc_detector_distance_process(acc_detector_distance_handle_t *handle, void *buffer, void *calibration_buffer, bool *result_available, acc_detector_distance_result_t *result)
Process the data according to the configuration used in acc_detector_distance_config_create.
acc_detector_distance_result_t::sensor_config
const acc_config_t * sensor_config
Definition: acc_detector_distance.h:101
acc_integration_mem_alloc
void * acc_integration_mem_alloc(size_t size)
Allocate dynamic memory.
Definition: acc_integration_stm32.c:632
acc_processing_metadata_t
Metadata that will be populated by the processing module during creation.
Definition: acc_processing.h:36
acc_hal_a121_t
Definition: acc_hal_definitions_a121.h:82
acc_detector_distance_calibrate
bool acc_detector_distance_calibrate(acc_sensor_t *sensor, acc_detector_distance_handle_t *handle, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, void *calibration_buffer, uint32_t calibration_buffer_size, bool *calibration_complete)
Do a detector calibration.
acc_rss_hal_register
bool acc_rss_hal_register(const acc_hal_a121_t *hal)
Register an integration.
acc_sensor.h
acc_detector_distance_config_close_range_leakage_cancellation_set
void acc_detector_distance_config_close_range_leakage_cancellation_set(acc_detector_distance_config_t *config, bool enable)
Enable the close range leakage cancellation logic.
distance_detector_resources_t
Definition: i2c_distance_detector.c:29
acc_detector_distance_config_max_profile_set
void acc_detector_distance_config_max_profile_set(acc_detector_distance_config_t *config, acc_config_profile_t max_profile)
Set the max profile.
acc_config_sweeps_per_frame_get
uint16_t acc_config_sweeps_per_frame_get(const acc_config_t *config)
Get the number of sweeps per frame.
acc_detector_distance_destroy
void acc_detector_distance_destroy(acc_detector_distance_handle_t *handle)
Destroy the distance detector handle, freeing its resources.
acc_hal_integration_wait_for_sensor_interrupt
bool acc_hal_integration_wait_for_sensor_interrupt(acc_sensor_id_t sensor_id, uint32_t timeout_ms)
Wait for a sensor interrupt.
Definition: acc_hal_integration_stm32cube_xm.c:142
acc_hal_integration_a121.h
acc_detector_distance_config_signal_quality_set
void acc_detector_distance_config_signal_quality_set(acc_detector_distance_config_t *config, float signal_quality)
Set the signal quality.
acc_int16_complex_t::real
int16_t real
Definition: acc_definitions_common.h:45
acc_version_get
const char * acc_version_get(void)
Get the version of the Acconeer software.
ACC_CONFIG_PROFILE_5
@ ACC_CONFIG_PROFILE_5
Definition: acc_definitions_a121.h:47
acc_config_t
struct acc_config acc_config_t
Definition: acc_config.h:26
printf
#define printf
Definition: printf.h:60
distance_detector_resources_t::calibration_buffer
void * calibration_buffer
Definition: i2c_distance_detector.c:38
acc_config_subsweep_step_length_get
uint16_t acc_config_subsweep_step_length_get(const acc_config_t *config, uint8_t index)
Get the step length in a sweep.
acc_processing_points_to_meter
float acc_processing_points_to_meter(int32_t points)
Convert a distance or step length in points to meter.
acc_detector_distance_result_t::processing_metadata
acc_processing_metadata_t * processing_metadata
Definition: acc_detector_distance.h:94
acc_hal_integration_sensor_enable
void acc_hal_integration_sensor_enable(acc_sensor_id_t sensor_id)
Enable sensor.
Definition: acc_hal_integration_stm32cube_xm.c:119
acc_hal_definitions_a121.h
initialize_detector_resources
static bool initialize_detector_resources(distance_detector_resources_t *resources)
Definition: example_detector_distance_with_iq_data_print.c:284
set_config
static void set_config(acc_detector_distance_config_t *detector_config, distance_preset_config_t preset)
Definition: example_detector_distance_with_iq_data_print.c:244
acc_detector_distance_config_log
void acc_detector_distance_config_log(const acc_detector_distance_handle_t *handle, const acc_detector_distance_config_t *config)
Print a configuration to the log.
acc_detector_distance_prepare
bool acc_detector_distance_prepare(const acc_detector_distance_handle_t *handle, const acc_detector_distance_config_t *config, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
Prepare the detector for measurements.
do_full_detector_calibration
static bool do_full_detector_calibration(distance_detector_resources_t *resources, const acc_cal_result_t *sensor_cal_result)
Definition: example_detector_distance_with_iq_data_print.c:355
acc_detector_distance_result_t
Distance detector result.
Definition: acc_detector_distance.h:49
distance_detector_resources_t::calibration_buffer_size
uint32_t calibration_buffer_size
Definition: i2c_distance_detector.c:39
distance_preset_config_t
distance_preset_config_t
Definition: example_detector_distance_with_iq_data_print.c:51
distance_detector_resources_t::config
acc_detector_distance_config_t * config
Definition: i2c_distance_detector.c:33
acc_processing_result_t::frame
acc_int16_complex_t * frame
Definition: acc_processing.h:91
acc_hal_integration_sensor_disable
void acc_hal_integration_sensor_disable(acc_sensor_id_t sensor_id)
Disable sensor.
Definition: acc_hal_integration_stm32cube_xm.c:130
acc_detector_distance_config_end_set
void acc_detector_distance_config_end_set(acc_detector_distance_config_t *config, float end_m)
Set the end of measured interval in meters.
acc_detector_distance_result_t::sensor_calibration_needed
bool sensor_calibration_needed
Definition: acc_detector_distance.h:74
acc_detector_distance_config_num_frames_recorded_threshold_set
void acc_detector_distance_config_num_frames_recorded_threshold_set(acc_detector_distance_config_t *config, uint16_t num_frames)
Set the number frames to use for recorded threshold.
acc_integration_log.h
acc_detector_distance_handle_t
struct acc_detector_distance_handle acc_detector_distance_handle_t
Definition: acc_detector_distance.h:35
ACC_LOG_FLOAT_TO_INTEGER
#define ACC_LOG_FLOAT_TO_INTEGER(a)
Definition: acc_integration_log.h:26
print_iq_data
static void print_iq_data(const acc_config_t *sensor_config, acc_processing_result_t *processing_result, acc_processing_metadata_t *processing_metadata)
Definition: example_detector_distance_with_iq_data_print.c:460
SENSOR_ID
#define SENSOR_ID
Definition: example_detector_distance_with_iq_data_print.c:59
do_detector_recalibration
static bool do_detector_recalibration(distance_detector_resources_t *resources, const acc_cal_result_t *sensor_cal_result)
Definition: example_detector_distance_with_iq_data_print.c:382
acc_integration_mem_free
void acc_integration_mem_free(void *ptr)
Free dynamic memory.
Definition: acc_integration_stm32.c:644
acc_int16_complex_t::imag
int16_t imag
Definition: acc_definitions_common.h:46
acc_detector_distance_config_reflector_shape_set
void acc_detector_distance_config_reflector_shape_set(acc_detector_distance_config_t *config, acc_detector_distance_reflector_shape_t reflector_shape)
Set reflector shape.
distance_detector_resources_t::sensor
acc_sensor_t * sensor
Definition: i2c_distance_detector.c:31
acc_detector_distance_config_threshold_sensitivity_set
void acc_detector_distance_config_threshold_sensitivity_set(acc_detector_distance_config_t *config, float threshold_sensitivity)
Set threshold sensitivity.
acc_detector_distance_config_create
acc_detector_distance_config_t * acc_detector_distance_config_create(void)
Create a configuration for a distance detector.
acc_detector_distance_result_t::distances
float distances[(10U)]
Definition: acc_detector_distance.h:54
acc_detector_distance.h
acc_sensor_calibrate
bool acc_sensor_calibrate(acc_sensor_t *sensor, bool *cal_complete, acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
Calibrate a sensor.
PRIfloat
#define PRIfloat
Specifier for printing float type using integers.
Definition: acc_integration_log.h:31
distance_detector_resources_t::handle
acc_detector_distance_handle_t * handle
Definition: i2c_distance_detector.c:34
distance_detector_resources_t::buffer
void * buffer
Definition: i2c_distance_detector.c:36
ACC_CONFIG_PROFILE_3
@ ACC_CONFIG_PROFILE_3
Definition: acc_definitions_a121.h:44
acc_detector_distance_config_t
struct acc_detector_distance_config acc_detector_distance_config_t
Definition: acc_detector_distance.h:43
acc_detector_distance_config_max_step_length_set
void acc_detector_distance_config_max_step_length_set(acc_detector_distance_config_t *config, uint16_t max_step_length)
Set the maximum step length.
acc_sensor_measure
bool acc_sensor_measure(acc_sensor_t *sensor)
Start a radar measurement with previously prepared configuration.
SENSOR_TIMEOUT_MS
#define SENSOR_TIMEOUT_MS
Definition: example_detector_distance_with_iq_data_print.c:61
acc_config_subsweep_start_point_get
int32_t acc_config_subsweep_start_point_get(const acc_config_t *config, uint8_t index)
Get the starting point of the sweep.
acc_sensor_t
struct acc_sensor acc_sensor_t
Definition: acc_sensor.h:31
acc_sensor_destroy
void acc_sensor_destroy(acc_sensor_t *sensor)
Destroy a sensor instance freeing any resources allocated.
acc_processing_metadata_t::subsweep_data_length
uint16_t subsweep_data_length[(4U)]
Definition: acc_processing.h:45
acc_definitions_a121.h
acc_sensor_create
acc_sensor_t * acc_sensor_create(acc_sensor_id_t sensor_id)
Create a sensor instance.