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