example_detector_distance.c
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2022-2025
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.c
23 * @brief This is an example on how the Detector Distance API can be used
24 * @n
25 * This example executes as follows:
26 * - Retrieve HAL integration
27 * - Initialize distance detector resources:
28 * + Create distance detector configuration
29 * + Update configuration settings
30 * + Create Distance detector handle
31 * + Create buffer for detector calibration data
32 * + Create buffer for sensor data
33 * - Create and calibrate the sensor
34 * - Calibrate the detector
35 * - Measure distances with the detector (loop):
36 * + Prepare sensor with the detector
37 * + Measure and wait until a read can be done
38 * + Process measurement and print the result
39 * + Handle "calibration_needed" indication
40 * - Cleanup:
41 * + Destroy detector configuration
42 * + Destroy detector handle
43 * + Destroy sensor data buffer
44 * + Destroy detector calibration data buffer
45 */
46
47 typedef enum
48 {
49 DISTANCE_PRESET_CONFIG_NONE = 0,
50 DISTANCE_PRESET_CONFIG_BALANCED,
51 DISTANCE_PRESET_CONFIG_HIGH_ACCURACY,
52 } distance_preset_config_t;
53
54 #define SENSOR_ID (1U)
55 // 2 seconds should be enough even for long ranges and high signal quality
56 #define SENSOR_TIMEOUT_MS (2000U)
57
58 typedef struct
59 {
60 acc_sensor_t *sensor;
61 acc_detector_distance_config_t *config;
62 acc_detector_distance_handle_t *handle;
63 void *buffer;
64 uint32_t buffer_size;
65 uint8_t *detector_cal_result_static;
66 uint32_t detector_cal_result_static_size;
67 acc_detector_cal_result_dynamic_t detector_cal_result_dynamic;
68 } distance_detector_resources_t;
69
70 static void cleanup(distance_detector_resources_t *resources);
71
72 static void set_config(acc_detector_distance_config_t *detector_config, distance_preset_config_t preset);
73
74 static bool initialize_detector_resources(distance_detector_resources_t *resources);
75
76 static bool do_sensor_calibration(acc_sensor_t *sensor, acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size);
77
78 static bool do_full_detector_calibration(distance_detector_resources_t *resources, const acc_cal_result_t *sensor_cal_result);
79
80 static bool do_detector_calibration_update(distance_detector_resources_t *resources, const acc_cal_result_t *sensor_cal_result);
81
82 static bool do_detector_get_next(distance_detector_resources_t *resources,
83 const acc_cal_result_t *sensor_cal_result,
84 acc_detector_distance_result_t *result);
85
86 static void print_distance_result(const acc_detector_distance_result_t *result);
87
88 int acconeer_main(int argc, char *argv[]);
89
90 int acconeer_main(int argc, char *argv[])
91 {
92 (void)argc;
93 (void)argv;
94 distance_detector_resources_t resources = {0};
95
96 printf("Acconeer software version %s\n", acc_version_get());
97
98 const acc_hal_a121_t *hal = acc_hal_rss_integration_get_implementation();
99
100 if (!acc_rss_hal_register(hal))
101 {
102 return EXIT_FAILURE;
103 }
104
105 resources.config = acc_detector_distance_config_create();
106 if (resources.config == NULL)
107 {
108 printf("acc_detector_distance_config_create() failed\n");
109 cleanup(&resources);
110 return EXIT_FAILURE;
111 }
112
113 set_config(resources.config, DISTANCE_PRESET_CONFIG_BALANCED);
114
115 if (!initialize_detector_resources(&resources))
116 {
117 printf("Initializing detector resources failed\n");
118 cleanup(&resources);
119 return EXIT_FAILURE;
120 }
121
122 // Print the configuration
123 acc_detector_distance_config_log(resources.handle, resources.config);
124
125 /* Turn the sensor on */
126 acc_hal_integration_sensor_supply_on(SENSOR_ID);
127 acc_hal_integration_sensor_enable(SENSOR_ID);
128
129 resources.sensor = acc_sensor_create(SENSOR_ID);
130 if (resources.sensor == NULL)
131 {
132 printf("acc_sensor_create() failed\n");
133 cleanup(&resources);
134 return EXIT_FAILURE;
135 }
136
137 acc_cal_result_t sensor_cal_result;
138
139 if (!do_sensor_calibration(resources.sensor, &sensor_cal_result, resources.buffer, resources.buffer_size))
140 {
141 printf("Sensor calibration failed\n");
142 cleanup(&resources);
143 return EXIT_FAILURE;
144 }
145
146 if (!do_full_detector_calibration(&resources, &sensor_cal_result))
147 {
148 printf("Detector calibration failed\n");
149 cleanup(&resources);
150 return EXIT_FAILURE;
151 }
152
153 while (true)
154 {
155 acc_detector_distance_result_t result = {0};
156
157 if (!do_detector_get_next(&resources, &sensor_cal_result, &result))
158 {
159 printf("Could not get next result\n");
160 cleanup(&resources);
161 return EXIT_FAILURE;
162 }
163
164 /* If "calibration needed" is indicated, the sensor needs to be recalibrated and the detector calibration updated */
165 if (result.calibration_needed)
166 {
167 printf("Sensor recalibration and detector calibration update needed ... \n");
168
169 if (!do_sensor_calibration(resources.sensor, &sensor_cal_result, resources.buffer, resources.buffer_size))
170 {
171 printf("Sensor calibration failed\n");
172 cleanup(&resources);
173 return EXIT_FAILURE;
174 }
175
176 /* Once the sensor is recalibrated, the detector calibration should be updated and measuring can continue. */
177 if (!do_detector_calibration_update(&resources, &sensor_cal_result))
178 {
179 printf("Detector calibration update failed\n");
180 cleanup(&resources);
181 return EXIT_FAILURE;
182 }
183
184 printf("Sensor recalibration and detector calibration update done!\n");
185 }
186 else
187 {
188 print_distance_result(&result);
189 }
190 }
191
192 cleanup(&resources);
193
194 printf("Done!\n");
195
196 return EXIT_SUCCESS;
197 }
198
199 static void cleanup(distance_detector_resources_t *resources)
200 {
201 acc_hal_integration_sensor_disable(SENSOR_ID);
202 acc_hal_integration_sensor_supply_off(SENSOR_ID);
203
204 acc_detector_distance_config_destroy(resources->config);
205 acc_detector_distance_destroy(resources->handle);
206
207 acc_integration_mem_free(resources->buffer);
208 acc_integration_mem_free(resources->detector_cal_result_static);
209
210 if (resources->sensor != NULL)
211 {
212 acc_sensor_destroy(resources->sensor);
213 }
214 }
215
216 static void set_config(acc_detector_distance_config_t *detector_config, distance_preset_config_t preset)
217 {
218 // Add configuration of the detector here
219 switch (preset)
220 {
221 case DISTANCE_PRESET_CONFIG_NONE:
222 // Add configuration of the detector here
223 break;
224
225 case DISTANCE_PRESET_CONFIG_BALANCED:
226 acc_detector_distance_config_start_set(detector_config, 0.25f);
227 acc_detector_distance_config_end_set(detector_config, 3.0f);
228 acc_detector_distance_config_max_step_length_set(detector_config, 0U);
229 acc_detector_distance_config_max_profile_set(detector_config, ACC_CONFIG_PROFILE_5);
230 acc_detector_distance_config_reflector_shape_set(detector_config, ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC);
231 acc_detector_distance_config_peak_sorting_set(detector_config, ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST);
232 acc_detector_distance_config_threshold_method_set(detector_config, ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR);
233 acc_detector_distance_config_threshold_sensitivity_set(detector_config, 0.5f);
234 acc_detector_distance_config_signal_quality_set(detector_config, 15.0f);
235 acc_detector_distance_config_close_range_leakage_cancellation_set(detector_config, false);
236 break;
237
238 case DISTANCE_PRESET_CONFIG_HIGH_ACCURACY:
239 acc_detector_distance_config_start_set(detector_config, 0.25f);
240 acc_detector_distance_config_end_set(detector_config, 3.0f);
241 acc_detector_distance_config_max_step_length_set(detector_config, 2U);
242 acc_detector_distance_config_max_profile_set(detector_config, ACC_CONFIG_PROFILE_3);
243 acc_detector_distance_config_reflector_shape_set(detector_config, ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC);
244 acc_detector_distance_config_peak_sorting_set(detector_config, ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST);
245 acc_detector_distance_config_threshold_method_set(detector_config, ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR);
246 acc_detector_distance_config_threshold_sensitivity_set(detector_config, 0.5f);
247 acc_detector_distance_config_signal_quality_set(detector_config, 20.0f);
248 acc_detector_distance_config_close_range_leakage_cancellation_set(detector_config, false);
249 break;
250 }
251 }
252
253 static bool initialize_detector_resources(distance_detector_resources_t *resources)
254 {
255 resources->handle = acc_detector_distance_create(resources->config);
256 if (resources->handle == NULL)
257 {
258 printf("acc_detector_distance_create() failed\n");
259 return false;
260 }
261
262 if (!acc_detector_distance_get_sizes(resources->handle, &(resources->buffer_size), &(resources->detector_cal_result_static_size)))
263 {
264 printf("acc_detector_distance_get_sizes() failed\n");
265 return false;
266 }
267
268 resources->buffer = acc_integration_mem_alloc(resources->buffer_size);
269 if (resources->buffer == NULL)
270 {
271 printf("sensor buffer allocation failed\n");
272 return false;
273 }
274
275 resources->detector_cal_result_static = acc_integration_mem_alloc(resources->detector_cal_result_static_size);
276 if (resources->detector_cal_result_static == NULL)
277 {
278 printf("calibration buffer allocation failed\n");
279 return false;
280 }
281
282 return true;
283 }
284
285 static bool do_sensor_calibration(acc_sensor_t *sensor, acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
286 {
287 bool status = false;
288 bool cal_complete = false;
289 const uint16_t calibration_retries = 1U;
290
291 // Random disturbances may cause the calibration to fail. At failure, retry at least once.
292 for (uint16_t i = 0; !status && (i <= calibration_retries); i++)
293 {
294 // Reset sensor before calibration by disabling/enabling it
295 acc_hal_integration_sensor_disable(SENSOR_ID);
296 acc_hal_integration_sensor_enable(SENSOR_ID);
297
298 do
299 {
300 status = acc_sensor_calibrate(sensor, &cal_complete, sensor_cal_result, buffer, buffer_size);
301
302 if (status && !cal_complete)
303 {
304 status = acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS);
305 }
306 } while (status && !cal_complete);
307 }
308
309 if (status)
310 {
311 /* Reset sensor after calibration by disabling/enabling it */
312 acc_hal_integration_sensor_disable(SENSOR_ID);
313 acc_hal_integration_sensor_enable(SENSOR_ID);
314 }
315
316 return status;
317 }
318
319 static bool do_full_detector_calibration(distance_detector_resources_t *resources, const acc_cal_result_t *sensor_cal_result)
320 {
321 bool done = false;
322 bool status;
323
324 do
325 {
326 status = acc_detector_distance_calibrate(resources->sensor,
327 resources->handle,
328 sensor_cal_result,
329 resources->buffer,
330 resources->buffer_size,
331 resources->detector_cal_result_static,
332 resources->detector_cal_result_static_size,
333 &resources->detector_cal_result_dynamic,
334 &done);
335
336 if (status && !done)
337 {
338 status = acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS);
339 }
340 } while (status && !done);
341
342 return status;
343 }
344
345 static bool do_detector_calibration_update(distance_detector_resources_t *resources, const acc_cal_result_t *sensor_cal_result)
346 {
347 bool done = false;
348 bool status;
349
350 do
351 {
352 status = acc_detector_distance_update_calibration(resources->sensor,
353 resources->handle,
354 sensor_cal_result,
355 resources->buffer,
356 resources->buffer_size,
357 &resources->detector_cal_result_dynamic,
358 &done);
359
360 if (status && !done)
361 {
362 status = acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS);
363 }
364 } while (status && !done);
365
366 return status;
367 }
368
369 static bool do_detector_get_next(distance_detector_resources_t *resources,
370 const acc_cal_result_t *sensor_cal_result,
371 acc_detector_distance_result_t *result)
372 {
373 bool result_available = false;
374
375 do
376 {
377 if (!acc_detector_distance_prepare(resources->handle,
378 resources->config,
379 resources->sensor,
380 sensor_cal_result,
381 resources->buffer,
382 resources->buffer_size))
383 {
384 printf("acc_detector_distance_prepare() failed\n");
385 return false;
386 }
387
388 if (!acc_sensor_measure(resources->sensor))
389 {
390 printf("acc_sensor_measure() failed\n");
391 return false;
392 }
393
394 if (!acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS))
395 {
396 printf("Sensor interrupt timeout\n");
397 return false;
398 }
399
400 if (!acc_sensor_read(resources->sensor, resources->buffer, resources->buffer_size))
401 {
402 printf("acc_sensor_read() failed\n");
403 return false;
404 }
405
406 if (!acc_detector_distance_process(resources->handle,
407 resources->buffer,
408 resources->detector_cal_result_static,
409 &resources->detector_cal_result_dynamic,
410 &result_available,
411 result))
412 {
413 printf("acc_detector_distance_process() failed\n");
414 return false;
415 }
416 } while (!result_available);
417
418 return true;
419 }
420
421 static void print_distance_result(const acc_detector_distance_result_t *result)
422 {
423 printf("%d detected distances", result->num_distances);
424 if (result->num_distances > 0)
425 {
426 printf(": ");
427
428 for (uint8_t i = 0; i < result->num_distances; i++)
429 {
430 printf("%" PRIfloat " m ", ACC_LOG_FLOAT_TO_INTEGER(result->distances[i]));
431 }
432 }
433
434 printf("\n");
435 }
acconeer_main
int acconeer_main(int argc, char *argv[])
Assembly test example.
Definition: example_detector_distance.c:90
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.
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.
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
distance_detector_resources_t::detector_cal_result_static_size
uint32_t detector_cal_result_static_size
Definition: i2c_distance_detector.c:39
distance_preset_config_t
distance_preset_config_t
Definition: example_detector_distance.c:47
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
sensor_cal_result
acc_cal_result_t sensor_cal_result
Definition: i2c_example_cargo.c:36
print_distance_result
static void print_distance_result(const acc_detector_distance_result_t *result)
Definition: example_detector_distance.c:421
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.
distance_preset_config_t
distance_preset_config_t
Definition: example_detector_distance_low_power_hibernate.c:47
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)
cleanup
static void cleanup(distance_detector_resources_t *resources)
Definition: example_detector_distance.c:199
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.
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
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.c:319
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.
distance_detector_resources_t::detector_cal_result_dynamic
acc_detector_cal_result_dynamic_t detector_cal_result_dynamic
Definition: i2c_distance_detector.c:40
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_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
acc_detector_cal_result_dynamic_t
The result from a completed calibration update.
Definition: acc_detector_distance_definitions.h:23
distance_detector_resources_t::detector_cal_result_static
uint8_t * detector_cal_result_static
Definition: i2c_distance_detector.c:38
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
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
acc_hal_definitions_a121.h
DISTANCE_PRESET_CONFIG_HIGH_ACCURACY
@ DISTANCE_PRESET_CONFIG_HIGH_ACCURACY
Definition: example_detector_distance.c:51
SENSOR_ID
#define SENSOR_ID
Definition: example_detector_distance.c:54
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
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)
DISTANCE_PRESET_CONFIG_BALANCED
@ DISTANCE_PRESET_CONFIG_BALANCED
Definition: example_detector_distance.c:50
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
ACC_LOG_FLOAT_TO_INTEGER
#define ACC_LOG_FLOAT_TO_INTEGER(a)
Definition: acc_integration_log.h:26
SENSOR_TIMEOUT_MS
#define SENSOR_TIMEOUT_MS
Definition: example_detector_distance.c:56
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.
initialize_detector_resources
static bool initialize_detector_resources(distance_detector_resources_t *resources)
Definition: example_detector_distance.c:253
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.
DISTANCE_PRESET_CONFIG_NONE
@ DISTANCE_PRESET_CONFIG_NONE
Definition: example_detector_distance.c:49
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
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.c:369
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_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, distance_preset_config_t preset)
Definition: example_detector_distance.c:216
do_detector_calibration_update
static bool do_detector_calibration_update(distance_detector_resources_t *resources, const acc_cal_result_t *sensor_cal_result)
Definition: example_detector_distance.c:345
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
ACC_CONFIG_PROFILE_3
@ ACC_CONFIG_PROFILE_3
Definition: acc_definitions_a121.h:54
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.
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.c:285