example_detector_distance_calibration_caching.c
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2024
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 <stdbool.h>
8 #include <stdint.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 #include "acc_definitions_a121.h"
13 #include "acc_detector_distance.h"
14 #include "acc_hal_definitions_a121.h"
15 #include "acc_hal_integration_a121.h"
16 #include "acc_integration.h"
17 #include "acc_integration_log.h"
18 #include "acc_rss_a121.h"
19 #include "acc_sensor.h"
20 #include "acc_version.h"
21
22 /** \example example_detector_distance_calibration_caching.c
23 * @brief This is an example on how the sensor and detector calibration can be cached
24 * @n
25 * This example executes as follows:
26 * - Retrieve and register HAL struct
27 * - Create and initialize distance detector resources
28 * - Create and calibrate sensor
29 * - Calibrate detector
30 * - Loop:
31 * - Prepare, measure, read, process data using the detector
32 * - Check 'calibration_needed' indication
33 * - If needed, either use cached calibration or perform new calibration and store
34 * - Destroy resources
35 */
36
37 #define SENSOR_ID (1U)
38 // 2 seconds should be enough even for long ranges and high signal quality
39 #define SENSOR_TIMEOUT_MS (2000U)
40
41 /**
42 * A sensor calibration and the dynamic part of a detector calibration are valid at the
43 * temperature they were done +- 15 degrees.
44 *
45 * If the temperature isn't controlled during caching, which is the case in this example,
46 * the maximum amount of caches needs to be calculated from a temperature difference of 16.
47 *
48 * For example
49 * - A calibration is done at 25 degrees, which means it is valid between 10 and 40 degrees
50 * - The temperature changes to 41 degrees
51 * - A new calibration needs to be done at 41 degrees since it is above the valid range for the previous calibration
52 * - The new calibration is then valid between 26 and 56 degrees
53 *
54 * However, if the temperature is controlled, for example in a factory, the maximum amount
55 * of caches can be calculated from a temperature difference of 30.
56 *
57 * For example
58 * - A calibration is done at 25 degrees, which means it is valid between 10 and 40 degrees
59 * - The temperature is manually changed to 55 degrees
60 * - A new calibration can be done which is valid between 40 and 70 degrees
61 *
62 * The maximum temperature variation that the application will operate in is assumed to be
63 * -40 to 85 degrees in this example.
64 */
65 #define MAX_CAL_TEMP_DIFF (16)
66 #define MAX_TEMP_VARIATION (125)
67 #define MAX_CACHE_COUNT ((MAX_TEMP_VARIATION / MAX_CAL_TEMP_DIFF) + 1)
68
69 // Variables for temperature independent caching
70 static uint8_t *detector_cal_result_static;
71 static uint32_t detector_cal_result_static_size = 0;
72
73 // Variables for temperature dependent caching
74 static acc_cal_result_t sensor_cal_results[MAX_CACHE_COUNT];
75 static acc_detector_cal_result_dynamic_t detector_cal_results_dynamic[MAX_CACHE_COUNT];
76 static int16_t cal_temps[MAX_CACHE_COUNT];
77 static uint16_t curr_cache_count = 0;
78 static uint16_t cache_index_in_use = 0;
79
80 typedef struct
81 {
82 acc_sensor_t *sensor;
83 acc_detector_distance_config_t *config;
84 acc_detector_distance_handle_t *handle;
85 void *buffer;
86 uint32_t buffer_size;
87 } distance_detector_resources_t;
88
89 // General control functions
90 static void set_config(acc_detector_distance_config_t *detector_config);
91
92 static bool initialize_detector_resources(distance_detector_resources_t *resources);
93
94 static bool detector_get_next(distance_detector_resources_t *resources, acc_detector_distance_result_t *result);
95
96 static void cleanup(distance_detector_resources_t *resources);
97
98 // Calibration and caching functions
99 static bool sensor_and_detector_calibration(distance_detector_resources_t *resources, uint16_t cache_index);
100
101 static bool sensor_calibration(distance_detector_resources_t *resources, uint16_t cache_index);
102
103 static bool detector_calibration_full(distance_detector_resources_t *resources, uint16_t cache_index);
104
105 static bool detector_calibration_update(distance_detector_resources_t *resources, uint16_t cache_index);
106
107 static bool calibration_caching(distance_detector_resources_t *resources, int16_t temp);
108
109 // Caching helper functions
110 static bool find_cache_index(int16_t temp, uint16_t *cache_index);
111
112 static bool get_next_empty_cache_index(uint16_t *cache_index);
113
114 static bool add_cache(uint16_t cache_index, int16_t temp);
115
116 // Main function
117 int acconeer_main(int argc, char *argv[]);
118
119 int acconeer_main(int argc, char *argv[])
120 {
121 (void)argc;
122 (void)argv;
123 distance_detector_resources_t resources = {0};
124
125 printf("Acconeer software version %s\n", acc_version_get());
126
127 const acc_hal_a121_t *hal = acc_hal_rss_integration_get_implementation();
128
129 if (!acc_rss_hal_register(hal))
130 {
131 return EXIT_FAILURE;
132 }
133
134 resources.config = acc_detector_distance_config_create();
135 if (resources.config == NULL)
136 {
137 printf("Config creation failed\n");
138 return EXIT_FAILURE;
139 }
140
141 set_config(resources.config);
142
143 if (!initialize_detector_resources(&resources))
144 {
145 printf("Initializing detector resources failed\n");
146 cleanup(&resources);
147 return EXIT_FAILURE;
148 }
149
150 acc_detector_distance_config_log(resources.handle, resources.config);
151
152 acc_hal_integration_sensor_supply_on(SENSOR_ID);
153 acc_hal_integration_sensor_enable(SENSOR_ID);
154
155 resources.sensor = acc_sensor_create(SENSOR_ID);
156 if (resources.sensor == NULL)
157 {
158 printf("Sensor creation failed\n");
159 cleanup(&resources);
160 return EXIT_FAILURE;
161 }
162
163 // Do a sensor calibration and a full detector calibration and store first in cache.
164 if (!sensor_and_detector_calibration(&resources, 0))
165 {
166 printf("Sensor or detector calibration failed\n");
167 cleanup(&resources);
168 return EXIT_FAILURE;
169 }
170
171 uint32_t update_count = 5U;
172
173 for (uint32_t i = 0U; i < update_count; i++)
174 {
175 acc_detector_distance_result_t result = {0};
176
177 if (!detector_get_next(&resources, &result))
178 {
179 printf("Could not get next result\n");
180 cleanup(&resources);
181 return EXIT_FAILURE;
182 }
183
184 if (result.calibration_needed)
185 {
186 printf("New calibrations needed due to temperature change\n");
187
188 if (!calibration_caching(&resources, result.temperature))
189 {
190 printf("Calibration caching failed\n");
191 cleanup(&resources);
192 return EXIT_FAILURE;
193 }
194 }
195 else
196 {
197 printf("Distance result retrieved\n");
198 }
199 }
200
201 cleanup(&resources);
202
203 printf("Application finished OK\n");
204
205 return EXIT_SUCCESS;
206 }
207
208 // General control functions
209 static void set_config(acc_detector_distance_config_t *detector_config)
210 {
211 // Balanced detector config
212 acc_detector_distance_config_start_set(detector_config, 0.25f);
213 acc_detector_distance_config_end_set(detector_config, 3.0f);
214 acc_detector_distance_config_max_step_length_set(detector_config, 0U);
215 acc_detector_distance_config_max_profile_set(detector_config, ACC_CONFIG_PROFILE_5);
216 acc_detector_distance_config_reflector_shape_set(detector_config, ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC);
217 acc_detector_distance_config_peak_sorting_set(detector_config, ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST);
218 acc_detector_distance_config_threshold_method_set(detector_config, ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR);
219 acc_detector_distance_config_num_frames_recorded_threshold_set(detector_config, 100U);
220 acc_detector_distance_config_threshold_sensitivity_set(detector_config, 0.5f);
221 acc_detector_distance_config_signal_quality_set(detector_config, 15.0f);
222 acc_detector_distance_config_close_range_leakage_cancellation_set(detector_config, false);
223 }
224
225 static bool initialize_detector_resources(distance_detector_resources_t *resources)
226 {
227 resources->handle = acc_detector_distance_create(resources->config);
228 if (resources->handle == NULL)
229 {
230 printf("acc_detector_distance_create() failed\n");
231 return false;
232 }
233
234 if (!acc_detector_distance_get_sizes(resources->handle, &(resources->buffer_size), &detector_cal_result_static_size))
235 {
236 printf("acc_detector_distance_get_sizes() failed\n");
237 return false;
238 }
239
240 resources->buffer = acc_integration_mem_alloc(resources->buffer_size);
241 if (resources->buffer == NULL)
242 {
243 printf("sensor buffer allocation failed\n");
244 return false;
245 }
246
247 detector_cal_result_static = acc_integration_mem_alloc(detector_cal_result_static_size);
248 if (detector_cal_result_static == NULL)
249 {
250 printf("static cal result allocation failed\n");
251 return false;
252 }
253
254 return true;
255 }
256
257 static bool detector_get_next(distance_detector_resources_t *resources, acc_detector_distance_result_t *result)
258 {
259 bool result_available = false;
260
261 do
262 {
263 if (!acc_detector_distance_prepare(resources->handle,
264 resources->config,
265 resources->sensor,
266 &sensor_cal_results[cache_index_in_use],
267 resources->buffer,
268 resources->buffer_size))
269 {
270 printf("acc_detector_distance_prepare() failed\n");
271 return false;
272 }
273
274 if (!acc_sensor_measure(resources->sensor))
275 {
276 printf("acc_sensor_measure() failed\n");
277 return false;
278 }
279
280 if (!acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS))
281 {
282 printf("Sensor interrupt timeout\n");
283 return false;
284 }
285
286 if (!acc_sensor_read(resources->sensor, resources->buffer, resources->buffer_size))
287 {
288 printf("acc_sensor_read() failed\n");
289 return false;
290 }
291
292 if (!acc_detector_distance_process(resources->handle,
293 resources->buffer,
294 detector_cal_result_static,
295 &detector_cal_results_dynamic[cache_index_in_use],
296 &result_available,
297 result))
298 {
299 printf("acc_detector_distance_process() failed\n");
300 return false;
301 }
302 } while (!result_available);
303
304 return true;
305 }
306
307 static void cleanup(distance_detector_resources_t *resources)
308 {
309 acc_hal_integration_sensor_disable(SENSOR_ID);
310 acc_hal_integration_sensor_supply_off(SENSOR_ID);
311
312 if (resources->sensor != NULL)
313 {
314 acc_sensor_destroy(resources->sensor);
315 }
316
317 if (detector_cal_result_static != NULL)
318 {
319 acc_integration_mem_free(detector_cal_result_static);
320 }
321
322 if (resources->buffer != NULL)
323 {
324 acc_integration_mem_free(resources->buffer);
325 }
326
327 if (resources->handle != NULL)
328 {
329 acc_detector_distance_destroy(resources->handle);
330 }
331
332 if (resources->config != NULL)
333 {
334 acc_detector_distance_config_destroy(resources->config);
335 }
336 }
337
338 // Calibration and caching functions
339 static bool sensor_and_detector_calibration(distance_detector_resources_t *resources, uint16_t cache_index)
340 {
341 bool status = sensor_calibration(resources, cache_index);
342
343 if (status)
344 {
345 status = detector_calibration_full(resources, cache_index);
346 }
347
348 if (status)
349 {
350 acc_cal_info_t cal_info;
351 acc_sensor_get_cal_info(&sensor_cal_results[cache_index], &cal_info);
352 add_cache(cache_index, cal_info.temperature);
353 cache_index_in_use = cache_index;
354 }
355
356 return status;
357 }
358
359 static bool sensor_calibration(distance_detector_resources_t *resources, uint16_t cache_index)
360 {
361 bool status = false;
362 bool cal_complete = false;
363 const uint16_t calibration_retries = 1U;
364
365 // Random disturbances may cause the calibration to fail. At failure, retry at least once.
366 for (uint16_t i = 0; !status && (i <= calibration_retries); i++)
367 {
368 // Reset sensor before calibration by disabling/enabling it
369 acc_hal_integration_sensor_disable(SENSOR_ID);
370 acc_hal_integration_sensor_enable(SENSOR_ID);
371
372 do
373 {
374 status =
375 acc_sensor_calibrate(resources->sensor, &cal_complete, &sensor_cal_results[cache_index], resources->buffer, resources->buffer_size);
376
377 if (status && !cal_complete)
378 {
379 status = acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS);
380 }
381 } while (status && !cal_complete);
382 }
383
384 if (status)
385 {
386 // Reset sensor after calibration by disabling/enabling it
387 acc_hal_integration_sensor_disable(SENSOR_ID);
388 acc_hal_integration_sensor_enable(SENSOR_ID);
389 }
390
391 return status;
392 }
393
394 static bool detector_calibration_full(distance_detector_resources_t *resources, uint16_t cache_index)
395 {
396 bool status = false;
397 bool cal_complete = false;
398
399 do
400 {
401 status = acc_detector_distance_calibrate(resources->sensor,
402 resources->handle,
403 &sensor_cal_results[cache_index],
404 resources->buffer,
405 resources->buffer_size,
406 detector_cal_result_static,
407 detector_cal_result_static_size,
408 &detector_cal_results_dynamic[cache_index],
409 &cal_complete);
410
411 if (status && !cal_complete)
412 {
413 status = acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS);
414 }
415 } while (status && !cal_complete);
416
417 return status;
418 }
419
420 static bool detector_calibration_update(distance_detector_resources_t *resources, uint16_t cache_index)
421 {
422 bool status = false;
423 bool cal_complete = false;
424
425 do
426 {
427 status = acc_detector_distance_update_calibration(resources->sensor,
428 resources->handle,
429 &sensor_cal_results[cache_index],
430 resources->buffer,
431 resources->buffer_size,
432 &detector_cal_results_dynamic[cache_index],
433 &cal_complete);
434
435 if (status && !cal_complete)
436 {
437 status = acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS);
438 }
439 } while (status && !cal_complete);
440
441 return status;
442 }
443
444 static bool calibration_caching(distance_detector_resources_t *resources, int16_t temp)
445 {
446 bool status = true;
447 uint16_t cache_index = 0;
448 bool use_cache = find_cache_index(temp, &cache_index);
449
450 // If no cached calibration can be used, a new calibration should be made
451 // and the result stored at an empty cache_index
452 if (!use_cache)
453 {
454 printf("New sensor calibration and detector calibration update is performed\n");
455
456 if (!get_next_empty_cache_index(&cache_index))
457 {
458 printf("No empty cache_index to store calibration result\n");
459 return false;
460 }
461
462 status = sensor_calibration(resources, cache_index);
463
464 if (status)
465 {
466 status = detector_calibration_update(resources, cache_index);
467 }
468
469 if (status)
470 {
471 acc_cal_info_t cal_info;
472 acc_sensor_get_cal_info(&sensor_cal_results[cache_index], &cal_info);
473 add_cache(cache_index, cal_info.temperature);
474 cache_index_in_use = cache_index;
475 }
476 }
477 else
478 {
479 cache_index_in_use = cache_index;
480 printf("Using cached calibration for %u degrees Celsius\n", cal_temps[cache_index_in_use]);
481 }
482
483 return status;
484 }
485
486 // Caching helper functions
487 static bool find_cache_index(int16_t temp, uint16_t *cache_index)
488 {
489 bool cache_found = false;
490 uint16_t min_temp_diff = UINT16_MAX;
491
492 // If caches have overlapping temperature ranges, the cache
493 // with center temperature closest to 'temp' will be chosen
494 for (uint16_t index = 0; index < curr_cache_count; index++)
495 {
496 uint16_t temp_diff = abs(cal_temps[index] - temp);
497
498 if (temp_diff < MAX_CAL_TEMP_DIFF && temp_diff < min_temp_diff)
499 {
500 min_temp_diff = temp_diff;
501 *cache_index = index;
502 cache_found = true;
503 }
504 }
505
506 return cache_found;
507 }
508
509 static bool get_next_empty_cache_index(uint16_t *cache_index)
510 {
511 *cache_index = curr_cache_count;
512
513 return curr_cache_count < MAX_CACHE_COUNT;
514 }
515
516 static bool add_cache(uint16_t cache_index, int16_t temp)
517 {
518 bool status = false;
519
520 if ((cache_index == curr_cache_count) && (cache_index < MAX_CACHE_COUNT))
521 {
522 cal_temps[cache_index] = temp;
523 curr_cache_count++;
524 status = true;
525 }
526
527 return status;
528 }
MAX_CAL_TEMP_DIFF
#define MAX_CAL_TEMP_DIFF
Definition: example_detector_distance_calibration_caching.c:65
calibration_caching
static bool calibration_caching(distance_detector_resources_t *resources, int16_t temp)
Definition: example_detector_distance_calibration_caching.c:444
detector_cal_results_dynamic
static acc_detector_cal_result_dynamic_t detector_cal_results_dynamic[(((125)/(16))+1)]
Definition: example_detector_distance_calibration_caching.c:75
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:104
acc_rss_a121.h
acc_detector_distance_get_sizes
bool acc_detector_distance_get_sizes(const acc_detector_distance_handle_t *handle, uint32_t *buffer_size, uint32_t *detector_cal_result_static_size)
Get the memory size needed to use the Distance Detector API functions.
get_next_empty_cache_index
static bool get_next_empty_cache_index(uint16_t *cache_index)
Definition: example_detector_distance_calibration_caching.c:509
cargo_result_t::calibration_needed
bool calibration_needed
Definition: example_cargo.h:112
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 peak sorting method.
cache_index_in_use
static uint16_t cache_index_in_use
Definition: example_detector_distance_calibration_caching.c:78
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:99
SENSOR_ID
#define SENSOR_ID
Definition: example_detector_distance_calibration_caching.c:37
acc_cal_info_t
Information about calibration.
Definition: acc_definitions_a121.h:38
sensor_cal_results
static acc_cal_result_t sensor_cal_results[(((125)/(16))+1)]
Definition: example_detector_distance_calibration_caching.c:74
acc_sensor_read
bool acc_sensor_read(const acc_sensor_t *sensor, void *buffer, uint32_t buffer_size)
Read out radar data.
buffer
void * buffer
Definition: i2c_example_cargo.c:40
acc_version.h
detector_get_next
static bool detector_get_next(distance_detector_resources_t *resources, acc_detector_distance_result_t *result)
Definition: example_detector_distance_calibration_caching.c:257
ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST
@ ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST
Definition: acc_detector_distance_definitions.h:36
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 threshold method.
acc_cal_result_t
The result from a completed calibration.
Definition: acc_definitions_a121.h:30
acc_detector_distance_config_start_set
void acc_detector_distance_config_start_set(acc_detector_distance_config_t *config, float start_m)
Set start of measured interval (m)
ACC_CONFIG_PROFILE_5
@ ACC_CONFIG_PROFILE_5
Definition: acc_definitions_a121.h:57
acc_integration.h
acc_detector_distance_create
acc_detector_distance_handle_t * acc_detector_distance_create(const acc_detector_distance_config_t *config)
Create Distance Detector handle using the provided Distance Detector configuration.
sensor_and_detector_calibration
static bool sensor_and_detector_calibration(distance_detector_resources_t *resources, uint16_t cache_index)
Definition: example_detector_distance_calibration_caching.c:339
acc_detector_distance_config_destroy
void acc_detector_distance_config_destroy(acc_detector_distance_config_t *config)
Destroy Distance Detector configuration.
config
cargo_config_t config
Definition: i2c_example_cargo.c:34
add_cache
static bool add_cache(uint16_t cache_index, int16_t temp)
Definition: example_detector_distance_calibration_caching.c:516
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:152
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, uint8_t *detector_cal_result_static, uint32_t detector_cal_result_static_size, acc_detector_cal_result_dynamic_t *detector_cal_result_dynamic, bool *calibration_complete)
Calibrate detector.
acc_detector_distance_process
bool acc_detector_distance_process(acc_detector_distance_handle_t *handle, void *buffer, uint8_t *detector_cal_result_static, acc_detector_cal_result_dynamic_t *detector_cal_result_dynamic, bool *result_available, acc_detector_distance_result_t *result)
Process sensor data into a Detector result.
acc_integration_mem_alloc
void * acc_integration_mem_alloc(size_t size)
Allocate dynamic memory.
Definition: acc_integration_stm32.c:592
detector_calibration_update
static bool detector_calibration_update(distance_detector_resources_t *resources, uint16_t cache_index)
Definition: example_detector_distance_calibration_caching.c:420
detector_cal_result_static
static uint8_t * detector_cal_result_static
Definition: example_detector_distance_calibration_caching.c:70
acc_hal_a121_t
Definition: acc_hal_definitions_a121.h:82
acc_rss_hal_register
bool acc_rss_hal_register(const acc_hal_a121_t *hal)
Register an integration.
acc_sensor.h
buffer_size
uint32_t buffer_size
Definition: i2c_example_cargo.c:41
acconeer_main
int acconeer_main(int argc, char *argv[])
Assembly test example.
Definition: example_detector_distance_calibration_caching.c:119
acc_detector_cal_result_dynamic_t
The result from a completed calibration update.
Definition: acc_detector_distance_definitions.h:23
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 close range leakage cancellation.
sensor
acc_sensor_t * sensor
Definition: i2c_example_cargo.c:33
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 maximum Profile.
acc_detector_distance_destroy
void acc_detector_distance_destroy(acc_detector_distance_handle_t *handle)
Destroy 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:130
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 signal quality (dB)
handle
cargo_handle_t * handle
Definition: i2c_example_cargo.c:35
result
cargo_result_t result
Definition: i2c_example_cargo.c:43
acc_version_get
const char * acc_version_get(void)
Get the version of the Acconeer software.
printf
#define printf
Definition: printf.h:60
MAX_CACHE_COUNT
#define MAX_CACHE_COUNT
Definition: example_detector_distance_calibration_caching.c:67
acc_sensor_get_cal_info
bool acc_sensor_get_cal_info(const acc_cal_result_t *cal_result, acc_cal_info_t *cal_info)
Gets calibration information from a calibration result.
detector_cal_result_static_size
static uint32_t detector_cal_result_static_size
Definition: example_detector_distance_calibration_caching.c:71
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:109
sensor_calibration
static bool sensor_calibration(distance_detector_resources_t *resources, uint16_t cache_index)
Definition: example_detector_distance_calibration_caching.c:359
acc_hal_definitions_a121.h
curr_cache_count
static uint16_t curr_cache_count
Definition: example_detector_distance_calibration_caching.c:77
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)
Log Distance configuration, typically through printf.
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.
acc_detector_distance_result_t
Distance Detector result returned from acc_detector_distance_process.
Definition: acc_detector_distance.h:48
ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR
@ ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR
Definition: acc_detector_distance_definitions.h:51
distance_detector_resources_t::config
acc_detector_distance_config_t * config
Definition: i2c_distance_detector.c:33
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:119
cal_temps
static int16_t cal_temps[(((125)/(16))+1)]
Definition: example_detector_distance_calibration_caching.c:76
acc_detector_distance_config_end_set
void acc_detector_distance_config_end_set(acc_detector_distance_config_t *config, float end_m)
Set end of measured interval (m)
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 number of 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
Distance Detector handle.
Definition: acc_detector_distance.h:36
cleanup
static void cleanup(distance_detector_resources_t *resources)
Definition: example_detector_distance_calibration_caching.c:307
initialize_detector_resources
static bool initialize_detector_resources(distance_detector_resources_t *resources)
Definition: example_detector_distance_calibration_caching.c:225
acc_detector_distance_update_calibration
bool acc_detector_distance_update_calibration(acc_sensor_t *sensor, acc_detector_distance_handle_t *handle, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, acc_detector_cal_result_dynamic_t *detector_cal_result_dynamic, bool *calibration_complete)
Perform a subset of the full Detector calibration.
detector_calibration_full
static bool detector_calibration_full(distance_detector_resources_t *resources, uint16_t cache_index)
Definition: example_detector_distance_calibration_caching.c:394
acc_integration_mem_free
void acc_integration_mem_free(void *ptr)
Free dynamic memory.
Definition: acc_integration_stm32.c:602
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 Distance Detector configuration.
SENSOR_TIMEOUT_MS
#define SENSOR_TIMEOUT_MS
Definition: example_detector_distance_calibration_caching.c:39
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.
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_detector_distance_config_t
struct acc_detector_distance_config acc_detector_distance_config_t
Distance Detector configuration.
Definition: acc_detector_distance.h:43
acc_cal_info_t::temperature
int16_t temperature
Definition: acc_definitions_a121.h:40
ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC
@ ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC
Definition: acc_detector_distance_definitions.h:60
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 maximum step length.
set_config
static void set_config(acc_detector_distance_config_t *detector_config)
Definition: example_detector_distance_calibration_caching.c:209
acc_sensor_measure
bool acc_sensor_measure(acc_sensor_t *sensor)
Start a radar measurement with previously prepared configuration.
acc_sensor_t
struct acc_sensor acc_sensor_t
Definition: acc_sensor.h:31
find_cache_index
static bool find_cache_index(int16_t temp, uint16_t *cache_index)
Definition: example_detector_distance_calibration_caching.c:487
acc_sensor_destroy
void acc_sensor_destroy(acc_sensor_t *sensor)
Destroy a sensor instance freeing any resources allocated.
acc_definitions_a121.h
acc_sensor_create
acc_sensor_t * acc_sensor_create(acc_sensor_id_t sensor_id)
Create a sensor instance.