example_detector_presence_low_power_hibernate.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_definitions_common.h"
14 #include "acc_detector_presence.h"
15 #include "acc_hal_definitions_a121.h"
16 #include "acc_hal_integration_a121.h"
17 #include "acc_integration.h"
18 #include "acc_rss_a121.h"
19 #include "acc_sensor.h"
20
21 #include "acc_version.h"
22
23 /** \example example_detector_presence_low_power_hibernate.c
24 * @brief This is an example on how to put the sensor in hibernation and the system in a low power state between measurements
25 * @n
26 * The example executes as follows:
27 * - Create a presence configuration
28 * - Create a sensor instance
29 * - Enable sensor
30 * - Create a detector instance
31 * - Calibrate the sensor
32 * - Prepare the detector
33 * - Enter hibernation
34 * - Loop forever:
35 * - Exit hibernation
36 * - Perform a sensor measurement and read out the data
37 * - Enter hibernation
38 * - Process the measurement and get detector result
39 * - Put the system in deep sleep for a specified amount of time
40 * - Destroy the configuration
41 * - Destroy the detector instance
42 * - Destroy the sensor instance
43 */
44
45 typedef enum
46 {
47 PRESENCE_PRESET_CONFIG_NONE = 0,
48 PRESENCE_PRESET_CONFIG_SHORT_RANGE,
49 PRESENCE_PRESET_CONFIG_MEDIUM_RANGE,
50 PRESENCE_PRESET_CONFIG_LONG_RANGE,
51 PRESENCE_PRESET_CONFIG_LOW_POWER_WAKEUP,
52 } presence_preset_config_t;
53
54 #define SENSOR_ID (1U)
55 #define SENSOR_TIMEOUT_MS (1000U)
56
57 #define DEFAULT_PRESET_CONFIG PRESENCE_PRESET_CONFIG_MEDIUM_RANGE
58
59 static bool do_sensor_calibration(acc_sensor_t *sensor, acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size);
60
61 static void print_result(acc_detector_presence_result_t *result);
62
63 static void cleanup(acc_detector_presence_handle_t *presence_handle,
64 acc_detector_presence_config_t *presence_config,
65 acc_sensor_t *sensor,
66 void *buffer);
67
68 static void set_config(acc_detector_presence_config_t *presence_config, presence_preset_config_t preset);
69
70 int acconeer_main(int argc, char *argv[]);
71
72 int acconeer_main(int argc, char *argv[])
73 {
74 (void)argc;
75 (void)argv;
76 acc_detector_presence_config_t *presence_config = NULL;
77 acc_detector_presence_handle_t *presence_handle = NULL;
78 acc_detector_presence_metadata_t metadata;
79 acc_sensor_t *sensor = NULL;
80 void *buffer = NULL;
81 uint32_t buffer_size = 0U;
82
83 printf("Acconeer software version %s\n", acc_version_get());
84
85 const acc_hal_a121_t *hal = acc_hal_rss_integration_get_implementation();
86
87 if (!acc_rss_hal_register(hal))
88 {
89 return EXIT_FAILURE;
90 }
91
92 presence_config = acc_detector_presence_config_create();
93 if (presence_config == NULL)
94 {
95 printf("acc_detector_presence_config_create() failed\n");
96 cleanup(presence_handle, presence_config, sensor, buffer);
97 return EXIT_FAILURE;
98 }
99
100 set_config(presence_config, DEFAULT_PRESET_CONFIG);
101
102 uint32_t sleep_time_ms = (uint32_t)(1000.0f / acc_detector_presence_config_frame_rate_get(presence_config));
103
104 acc_integration_set_periodic_wakeup(sleep_time_ms);
105
106 presence_handle = acc_detector_presence_create(presence_config, &metadata);
107 if (presence_handle == NULL)
108 {
109 printf("acc_detector_presence_create() failed\n");
110 cleanup(presence_handle, presence_config, sensor, buffer);
111 return EXIT_FAILURE;
112 }
113
114 if (!acc_detector_presence_get_buffer_size(presence_handle, &buffer_size))
115 {
116 printf("acc_detector_presence_get_buffer_size() failed\n");
117 cleanup(presence_handle, presence_config, sensor, buffer);
118 return EXIT_FAILURE;
119 }
120
121 buffer = acc_integration_mem_alloc(buffer_size);
122 if (buffer == NULL)
123 {
124 printf("buffer allocation failed\n");
125 cleanup(presence_handle, presence_config, sensor, buffer);
126 return EXIT_FAILURE;
127 }
128
129 acc_hal_integration_sensor_supply_on(SENSOR_ID);
130 acc_hal_integration_sensor_enable(SENSOR_ID);
131
132 sensor = acc_sensor_create(SENSOR_ID);
133 if (sensor == NULL)
134 {
135 printf("acc_sensor_create() failed\n");
136 cleanup(presence_handle, presence_config, sensor, buffer);
137 return EXIT_FAILURE;
138 }
139
140 acc_cal_result_t cal_result;
141
142 if (!do_sensor_calibration(sensor, &cal_result, buffer, buffer_size))
143 {
144 printf("do_sensor_calibration() failed\n");
145 cleanup(presence_handle, presence_config, sensor, buffer);
146 return EXIT_FAILURE;
147 }
148
149 // Reset sensor after calibration by disabling it
150 acc_hal_integration_sensor_disable(SENSOR_ID);
151
152 acc_hal_integration_sensor_enable(SENSOR_ID);
153
154 if (!acc_detector_presence_prepare(presence_handle, presence_config, sensor, &cal_result, buffer, buffer_size))
155 {
156 printf("acc_detector_presence_prepare() failed\n");
157 cleanup(presence_handle, presence_config, sensor, buffer);
158 return EXIT_FAILURE;
159 }
160
161 if (!acc_sensor_hibernate_on(sensor))
162 {
163 printf("acc_sensor_hibernate_on failed\n");
164 acc_sensor_status(sensor);
165 cleanup(presence_handle, presence_config, sensor, buffer);
166 return EXIT_FAILURE;
167 }
168
169 acc_hal_integration_sensor_disable(SENSOR_ID);
170
171 while (true)
172 {
173 acc_detector_presence_result_t result;
174
175 acc_hal_integration_sensor_enable(SENSOR_ID);
176 if (!acc_sensor_hibernate_off(sensor))
177 {
178 printf("acc_sensor_hibernate_off failed\n");
179 acc_sensor_status(sensor);
180 cleanup(presence_handle, presence_config, sensor, buffer);
181 return EXIT_FAILURE;
182 }
183
184 if (!acc_sensor_measure(sensor))
185 {
186 printf("acc_sensor_measure failed\n");
187 cleanup(presence_handle, presence_config, sensor, buffer);
188 return EXIT_FAILURE;
189 }
190
191 if (!acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS))
192 {
193 printf("Sensor interrupt timeout\n");
194 cleanup(presence_handle, presence_config, sensor, buffer);
195 return EXIT_FAILURE;
196 }
197
198 if (!acc_sensor_read(sensor, buffer, buffer_size))
199 {
200 printf("acc_sensor_read failed\n");
201 cleanup(presence_handle, presence_config, sensor, buffer);
202 return EXIT_FAILURE;
203 }
204
205 if (!acc_sensor_hibernate_on(sensor))
206 {
207 printf("acc_sensor_hibernate_on failed\n");
208 acc_sensor_status(sensor);
209 cleanup(presence_handle, presence_config, sensor, buffer);
210 return EXIT_FAILURE;
211 }
212
213 acc_hal_integration_sensor_disable(SENSOR_ID);
214
215 if (!acc_detector_presence_process(presence_handle, buffer, &result))
216 {
217 printf("acc_detector_presence_process failed\n");
218 cleanup(presence_handle, presence_config, sensor, buffer);
219 return EXIT_FAILURE;
220 }
221
222 /* If "calibration_needed" is indicated, the sensor needs to be recalibrated. */
223 if (result.processing_result.calibration_needed)
224 {
225 printf("Sensor recalibration needed ... \n");
226
227 acc_hal_integration_sensor_enable(SENSOR_ID);
228
229 if (!acc_sensor_hibernate_off(sensor))
230 {
231 printf("acc_sensor_hibernate_off failed\n");
232 acc_sensor_status(sensor);
233 cleanup(presence_handle, presence_config, sensor, buffer);
234 return EXIT_FAILURE;
235 }
236
237 if (!do_sensor_calibration(sensor, &cal_result, buffer, buffer_size))
238 {
239 printf("do_sensor_calibration() failed\n");
240 cleanup(presence_handle, presence_config, sensor, buffer);
241 return EXIT_FAILURE;
242 }
243
244 printf("Sensor recalibration done!\n");
245
246 /* Before measuring again, the sensor needs to be prepared through the detector. */
247 if (!acc_detector_presence_prepare(presence_handle, presence_config, sensor, &cal_result, buffer, buffer_size))
248 {
249 printf("acc_detector_presence_prepare() failed\n");
250 cleanup(presence_handle, presence_config, sensor, buffer);
251 return EXIT_FAILURE;
252 }
253
254 if (!acc_sensor_hibernate_on(sensor))
255 {
256 printf("acc_sensor_hibernate_on failed\n");
257 acc_sensor_status(sensor);
258 cleanup(presence_handle, presence_config, sensor, buffer);
259 return EXIT_FAILURE;
260 }
261
262 acc_hal_integration_sensor_disable(SENSOR_ID);
263 }
264 else
265 {
266 print_result(&result);
267 }
268
269 acc_integration_sleep_until_periodic_wakeup();
270 }
271
272 cleanup(presence_handle, presence_config, sensor, buffer);
273
274 printf("Application finished OK\n");
275
276 return EXIT_SUCCESS;
277 }
278
279 static void cleanup(acc_detector_presence_handle_t *presence_handle,
280 acc_detector_presence_config_t *presence_config,
281 acc_sensor_t *sensor,
282 void *buffer)
283 {
284 acc_hal_integration_sensor_disable(SENSOR_ID);
285 acc_hal_integration_sensor_supply_off(SENSOR_ID);
286
287 if (presence_config != NULL)
288 {
289 acc_detector_presence_config_destroy(presence_config);
290 }
291
292 if (presence_handle != NULL)
293 {
294 acc_detector_presence_destroy(presence_handle);
295 }
296
297 if (sensor != NULL)
298 {
299 acc_sensor_destroy(sensor);
300 }
301
302 if (buffer != NULL)
303 {
304 acc_integration_mem_free(buffer);
305 }
306 }
307
308 static void set_config(acc_detector_presence_config_t *presence_config, presence_preset_config_t preset)
309 {
310 switch (preset)
311 {
312 case PRESENCE_PRESET_CONFIG_NONE:
313 acc_detector_presence_config_frame_rate_app_driven_set(presence_config, true);
314 // Add configuration of the detector here
315 break;
316
317 case PRESENCE_PRESET_CONFIG_SHORT_RANGE:
318 acc_detector_presence_config_start_set(presence_config, 0.06f);
319 acc_detector_presence_config_end_set(presence_config, 1.0f);
320 acc_detector_presence_config_automatic_subsweeps_set(presence_config, true);
321 acc_detector_presence_config_signal_quality_set(presence_config, 30.0f);
322 acc_detector_presence_config_inter_frame_idle_state_set(presence_config, ACC_CONFIG_IDLE_STATE_DEEP_SLEEP);
323 acc_detector_presence_config_sweeps_per_frame_set(presence_config, 16);
324 acc_detector_presence_config_frame_rate_set(presence_config, 10.0f);
325 acc_detector_presence_config_frame_rate_app_driven_set(presence_config, true);
326 acc_detector_presence_config_reset_filters_on_prepare_set(presence_config, true);
327 acc_detector_presence_config_intra_detection_set(presence_config, true);
328 acc_detector_presence_config_intra_detection_threshold_set(presence_config, 1.4f);
329 acc_detector_presence_config_intra_frame_time_const_set(presence_config, 0.15f);
330 acc_detector_presence_config_intra_output_time_const_set(presence_config, 0.3f);
331 acc_detector_presence_config_inter_detection_set(presence_config, true);
332 acc_detector_presence_config_inter_detection_threshold_set(presence_config, 1.0f);
333 acc_detector_presence_config_inter_frame_deviation_time_const_set(presence_config, 0.5f);
334 acc_detector_presence_config_inter_frame_fast_cutoff_set(presence_config, 5.0f);
335 acc_detector_presence_config_inter_frame_slow_cutoff_set(presence_config, 0.20f);
336 acc_detector_presence_config_inter_output_time_const_set(presence_config, 2.0f);
337 acc_detector_presence_config_inter_frame_presence_timeout_set(presence_config, 3);
338
339 break;
340
341 case PRESENCE_PRESET_CONFIG_MEDIUM_RANGE:
342 acc_detector_presence_config_start_set(presence_config, 0.3f);
343 acc_detector_presence_config_end_set(presence_config, 2.5f);
344 acc_detector_presence_config_automatic_subsweeps_set(presence_config, true);
345 acc_detector_presence_config_signal_quality_set(presence_config, 20.0f);
346 acc_detector_presence_config_inter_frame_idle_state_set(presence_config, ACC_CONFIG_IDLE_STATE_DEEP_SLEEP);
347 acc_detector_presence_config_sweeps_per_frame_set(presence_config, 16);
348 acc_detector_presence_config_frame_rate_set(presence_config, 12.0f);
349 acc_detector_presence_config_frame_rate_app_driven_set(presence_config, true);
350 acc_detector_presence_config_reset_filters_on_prepare_set(presence_config, true);
351 acc_detector_presence_config_intra_detection_set(presence_config, true);
352 acc_detector_presence_config_intra_detection_threshold_set(presence_config, 1.3f);
353 acc_detector_presence_config_intra_frame_time_const_set(presence_config, 0.15f);
354 acc_detector_presence_config_intra_output_time_const_set(presence_config, 0.3f);
355 acc_detector_presence_config_inter_detection_set(presence_config, true);
356 acc_detector_presence_config_inter_detection_threshold_set(presence_config, 1.0f);
357 acc_detector_presence_config_inter_frame_deviation_time_const_set(presence_config, 0.5f);
358 acc_detector_presence_config_inter_frame_fast_cutoff_set(presence_config, 6.0f);
359 acc_detector_presence_config_inter_frame_slow_cutoff_set(presence_config, 0.20f);
360 acc_detector_presence_config_inter_output_time_const_set(presence_config, 2.0f);
361 acc_detector_presence_config_inter_frame_presence_timeout_set(presence_config, 3);
362
363 break;
364
365 case PRESENCE_PRESET_CONFIG_LONG_RANGE:
366 acc_detector_presence_config_start_set(presence_config, 5.0f);
367 acc_detector_presence_config_end_set(presence_config, 7.5f);
368 acc_detector_presence_config_automatic_subsweeps_set(presence_config, true);
369 acc_detector_presence_config_signal_quality_set(presence_config, 10.0f);
370 acc_detector_presence_config_inter_frame_idle_state_set(presence_config, ACC_CONFIG_IDLE_STATE_DEEP_SLEEP);
371 acc_detector_presence_config_sweeps_per_frame_set(presence_config, 16);
372 acc_detector_presence_config_frame_rate_set(presence_config, 12.0f);
373 acc_detector_presence_config_frame_rate_app_driven_set(presence_config, true);
374 acc_detector_presence_config_reset_filters_on_prepare_set(presence_config, true);
375 acc_detector_presence_config_intra_detection_set(presence_config, true);
376 acc_detector_presence_config_intra_detection_threshold_set(presence_config, 1.2f);
377 acc_detector_presence_config_intra_frame_time_const_set(presence_config, 0.15f);
378 acc_detector_presence_config_intra_output_time_const_set(presence_config, 0.3f);
379 acc_detector_presence_config_inter_detection_set(presence_config, true);
380 acc_detector_presence_config_inter_detection_threshold_set(presence_config, 0.8f);
381 acc_detector_presence_config_inter_frame_deviation_time_const_set(presence_config, 0.5f);
382 acc_detector_presence_config_inter_frame_fast_cutoff_set(presence_config, 6.0f);
383 acc_detector_presence_config_inter_frame_slow_cutoff_set(presence_config, 0.20f);
384 acc_detector_presence_config_inter_output_time_const_set(presence_config, 2.0f);
385 acc_detector_presence_config_inter_frame_presence_timeout_set(presence_config, 3);
386
387 break;
388
389 case PRESENCE_PRESET_CONFIG_LOW_POWER_WAKEUP:
390 acc_detector_presence_config_start_set(presence_config, 0.38f);
391 acc_detector_presence_config_end_set(presence_config, 0.67f);
392 acc_detector_presence_config_automatic_subsweeps_set(presence_config, false);
393 acc_detector_presence_config_auto_step_length_set(presence_config, true);
394 acc_detector_presence_config_auto_profile_set(presence_config, false);
395 acc_detector_presence_config_profile_set(presence_config, ACC_CONFIG_PROFILE_5);
396 acc_detector_presence_config_inter_frame_idle_state_set(presence_config, ACC_CONFIG_IDLE_STATE_DEEP_SLEEP);
397 acc_detector_presence_config_hwaas_set(presence_config, 8);
398 acc_detector_presence_config_sweeps_per_frame_set(presence_config, 8);
399 acc_detector_presence_config_frame_rate_set(presence_config, 0.7f);
400 acc_detector_presence_config_frame_rate_app_driven_set(presence_config, true);
401 acc_detector_presence_config_reset_filters_on_prepare_set(presence_config, true);
402 acc_detector_presence_config_intra_detection_set(presence_config, true);
403 acc_detector_presence_config_intra_detection_threshold_set(presence_config, 1.7f);
404 acc_detector_presence_config_intra_frame_time_const_set(presence_config, 0.3f);
405 acc_detector_presence_config_intra_output_time_const_set(presence_config, 0.3f);
406 acc_detector_presence_config_inter_detection_set(presence_config, true);
407 acc_detector_presence_config_inter_detection_threshold_set(presence_config, 1.2f);
408 acc_detector_presence_config_inter_frame_deviation_time_const_set(presence_config, 0.5f);
409 acc_detector_presence_config_inter_frame_fast_cutoff_set(presence_config, 5.0f);
410 acc_detector_presence_config_inter_frame_slow_cutoff_set(presence_config, 0.20f);
411 acc_detector_presence_config_inter_output_time_const_set(presence_config, 0.5f);
412 acc_detector_presence_config_inter_frame_presence_timeout_set(presence_config, 2);
413
414 break;
415 }
416 }
417
418 static bool do_sensor_calibration(acc_sensor_t *sensor, acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
419 {
420 bool status = false;
421 bool cal_complete = false;
422 const uint16_t calibration_retries = 1U;
423
424 // Random disturbances may cause the calibration to fail. At failure, retry at least once.
425 for (uint16_t i = 0; !status && (i <= calibration_retries); i++)
426 {
427 // Reset sensor before calibration by disabling/enabling it
428 acc_hal_integration_sensor_disable(SENSOR_ID);
429 acc_hal_integration_sensor_enable(SENSOR_ID);
430
431 do
432 {
433 status = acc_sensor_calibrate(sensor, &cal_complete, cal_result, buffer, buffer_size);
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
442 if (status)
443 {
444 /* Reset sensor after calibration by disabling/enabling it */
445 acc_hal_integration_sensor_disable(SENSOR_ID);
446 acc_hal_integration_sensor_enable(SENSOR_ID);
447 }
448
449 return status;
450 }
451
452 static void print_result(acc_detector_presence_result_t *result)
453 {
454 if (result->presence_detected)
455 {
456 printf("Motion\n");
457 }
458 else
459 {
460 printf("No motion\n");
461 }
462
463 // Score and distance is multiplied by 1000 to avoid printing floats
464 printf("Intra presence score: %d, Inter presence score: %d, Distance (mm): %d\n",
465 (int)(result->intra_presence_score * 1000.0f),
466 (int)(result->inter_presence_score * 1000.0f),
467 (int)(result->presence_distance * 1000.0f));
468 }
acc_detector_presence_config_inter_detection_set
void acc_detector_presence_config_inter_detection_set(acc_detector_presence_config_t *presence_config, bool enable)
Set inter-frame presence detection.
acc_detector_presence_config_sweeps_per_frame_set
void acc_detector_presence_config_sweeps_per_frame_set(acc_detector_presence_config_t *presence_config, uint16_t sweeps_per_frame)
Set the number of sweeps per frame.
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
cargo_result_t::calibration_needed
bool calibration_needed
Definition: example_cargo.h:112
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
acc_detector_presence_destroy
void acc_detector_presence_destroy(acc_detector_presence_handle_t *presence_handle)
Destroy a presence detector identified with the provided handle.
acc_detector_presence_config_hwaas_set
void acc_detector_presence_config_hwaas_set(acc_detector_presence_config_t *presence_config, uint16_t hwaas)
Set the hardware accelerated average samples (HWAAS)
acc_sensor_read
bool acc_sensor_read(const acc_sensor_t *sensor, void *buffer, uint32_t buffer_size)
Read out radar data.
SENSOR_TIMEOUT_MS
#define SENSOR_TIMEOUT_MS
Definition: example_detector_presence_low_power_hibernate.c:55
buffer
void * buffer
Definition: i2c_example_cargo.c:40
acc_version.h
acc_detector_presence_config_inter_frame_deviation_time_const_set
void acc_detector_presence_config_inter_frame_deviation_time_const_set(acc_detector_presence_config_t *presence_config, float inter_frame_deviation_time_const)
Set the time constant of the low pass filter for the inter-frame deviation between fast and slow.
PRESENCE_PRESET_CONFIG_NONE
@ PRESENCE_PRESET_CONFIG_NONE
Definition: example_detector_presence_low_power_hibernate.c:47
acc_detector_presence_config_auto_profile_set
void acc_detector_presence_config_auto_profile_set(acc_detector_presence_config_t *presence_config, bool enable)
Enable automatic selection of profile based on start point of measurement.
cleanup
static void cleanup(acc_detector_presence_handle_t *presence_handle, acc_detector_presence_config_t *presence_config, acc_sensor_t *sensor, void *buffer)
Definition: example_detector_presence_low_power_hibernate.c:279
acc_cal_result_t
The result from a completed calibration.
Definition: acc_definitions_a121.h:30
acc_detector_presence_config_frame_rate_set
void acc_detector_presence_config_frame_rate_set(acc_detector_presence_config_t *presence_config, float frame_rate)
Set the frame rate.
ACC_CONFIG_IDLE_STATE_DEEP_SLEEP
@ ACC_CONFIG_IDLE_STATE_DEEP_SLEEP
Definition: acc_definitions_a121.h:73
ACC_CONFIG_PROFILE_5
@ ACC_CONFIG_PROFILE_5
Definition: acc_definitions_a121.h:57
acc_integration.h
acc_detector_presence_get_buffer_size
bool acc_detector_presence_get_buffer_size(const acc_detector_presence_handle_t *presence_handle, uint32_t *buffer_size)
Get the buffer size needed for the provided presence detector handle.
print_result
static void print_result(acc_detector_presence_result_t *result)
Definition: example_detector_presence_low_power_hibernate.c:452
cargo_result_t::inter_presence_score
float inter_presence_score
Definition: example_cargo.h:137
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_presence_config_intra_detection_threshold_set
void acc_detector_presence_config_intra_detection_threshold_set(acc_detector_presence_config_t *presence_config, float intra_detection_threshold)
Set the detection threshold for the intra-frame presence detection.
acc_integration_mem_alloc
void * acc_integration_mem_alloc(size_t size)
Allocate dynamic memory.
Definition: acc_integration_stm32.c:592
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_integration_set_periodic_wakeup
void acc_integration_set_periodic_wakeup(uint32_t time_msec)
Set up a periodic timer used to wake up the system from sleep.
Definition: acc_integration_stm32.c:496
acc_sensor.h
acc_detector_presence_result_t
Presence detector results container.
Definition: acc_detector_presence.h:46
buffer_size
uint32_t buffer_size
Definition: i2c_example_cargo.c:41
PRESENCE_PRESET_CONFIG_SHORT_RANGE
@ PRESENCE_PRESET_CONFIG_SHORT_RANGE
Definition: example_detector_presence_low_power_hibernate.c:48
acc_detector_presence_config_inter_frame_presence_timeout_set
void acc_detector_presence_config_inter_frame_presence_timeout_set(acc_detector_presence_config_t *presence_config, uint16_t inter_frame_presence_timeout)
Set the inter-frame presence timeout in seconds.
sensor
acc_sensor_t * sensor
Definition: i2c_example_cargo.c:33
ref_app_parking_handle::cal_result
acc_cal_result_t cal_result
Definition: ref_app_parking.c:45
acc_detector_presence_config_destroy
void acc_detector_presence_config_destroy(acc_detector_presence_config_t *presence_config)
Destroy a presence detector configuration.
acc_detector_presence_metadata_t
Definition: acc_detector_presence.h:88
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
PRESENCE_PRESET_CONFIG_LONG_RANGE
@ PRESENCE_PRESET_CONFIG_LONG_RANGE
Definition: example_detector_presence_low_power_hibernate.c:50
acc_hal_integration_a121.h
acc_detector_presence_config_end_set
void acc_detector_presence_config_end_set(acc_detector_presence_config_t *presence_config, float end)
Set the end point of measurement interval in meters.
acc_detector_presence_config_intra_output_time_const_set
void acc_detector_presence_config_intra_output_time_const_set(acc_detector_presence_config_t *presence_config, float intra_output_time_const)
Set the time constant for the output in the intra-frame part.
acc_sensor_hibernate_off
bool acc_sensor_hibernate_off(const acc_sensor_t *sensor)
Restore sensor after exiting hibernation.
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
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_detector_presence_config_inter_frame_idle_state_set
void acc_detector_presence_config_inter_frame_idle_state_set(acc_detector_presence_config_t *presence_config, acc_config_idle_state_t idle_state)
Set inter frame idle state.
PRESENCE_PRESET_CONFIG_MEDIUM_RANGE
@ PRESENCE_PRESET_CONFIG_MEDIUM_RANGE
Definition: example_detector_presence_low_power_hibernate.c:49
acc_hal_definitions_a121.h
acc_detector_presence_process
bool acc_detector_presence_process(acc_detector_presence_handle_t *presence_handle, void *buffer, acc_detector_presence_result_t *result)
Process the data according to the configuration used in acc_detector_presence_config_create.
acc_detector_presence_config_inter_output_time_const_set
void acc_detector_presence_config_inter_output_time_const_set(acc_detector_presence_config_t *presence_config, float inter_output_time_const)
Set the time constant for the output in the inter-frame part.
acc_detector_presence_config_reset_filters_on_prepare_set
void acc_detector_presence_config_reset_filters_on_prepare_set(acc_detector_presence_config_t *presence_config, bool enable)
Set if the presence filters should reset on prepare.
acconeer_main
int acconeer_main(int argc, char *argv[])
Assembly test example.
Definition: example_detector_presence_low_power_hibernate.c:72
acc_detector_presence_prepare
bool acc_detector_presence_prepare(const acc_detector_presence_handle_t *presence_handle, acc_detector_presence_config_t *presence_config, acc_sensor_t *sensor, const acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
Prepare the detector to do a measurement.
acc_detector_presence_config_intra_detection_set
void acc_detector_presence_config_intra_detection_set(acc_detector_presence_config_t *presence_config, bool enable)
Set intra-frame presence detection.
cargo_result_t::intra_presence_score
float intra_presence_score
Definition: example_cargo.h:140
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
SENSOR_ID
#define SENSOR_ID
Definition: example_detector_presence_low_power_hibernate.c:54
acc_detector_presence_config_t
struct acc_detector_presence_config acc_detector_presence_config_t
Definition: acc_detector_presence.h:41
presence_preset_config_t
presence_preset_config_t
Definition: example_detector_presence_low_power_hibernate.c:45
do_sensor_calibration
static bool do_sensor_calibration(acc_sensor_t *sensor, acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
Definition: example_detector_presence_low_power_hibernate.c:418
acc_detector_presence_config_inter_frame_slow_cutoff_set
void acc_detector_presence_config_inter_frame_slow_cutoff_set(acc_detector_presence_config_t *presence_config, float inter_frame_slow_cutoff)
Set the cutoff frequency of the low pass filter for the slow filtered absolute sweep mean.
acc_sensor_hibernate_on
bool acc_sensor_hibernate_on(acc_sensor_t *sensor)
Prepare sensor for entering hibernation.
acc_sensor_status
void acc_sensor_status(const acc_sensor_t *sensor)
Check the status of the sensor.
acc_detector_presence_config_frame_rate_get
float acc_detector_presence_config_frame_rate_get(const acc_detector_presence_config_t *presence_config)
Get the frame rate.
DEFAULT_PRESET_CONFIG
#define DEFAULT_PRESET_CONFIG
Definition: example_detector_presence_low_power_hibernate.c:57
acc_detector_presence_config_profile_set
void acc_detector_presence_config_profile_set(acc_detector_presence_config_t *presence_config, acc_config_profile_t profile)
Set a profile.
acc_integration_mem_free
void acc_integration_mem_free(void *ptr)
Free dynamic memory.
Definition: acc_integration_stm32.c:602
acc_integration_sleep_until_periodic_wakeup
void acc_integration_sleep_until_periodic_wakeup(void)
Put the system in sleep until the periodic timer triggers.
Definition: acc_integration_stm32.c:552
acc_definitions_common.h
acc_detector_presence_create
acc_detector_presence_handle_t * acc_detector_presence_create(acc_detector_presence_config_t *presence_config, acc_detector_presence_metadata_t *metadata)
Create a presence detector with the provided configuration.
acc_detector_presence_handle_t
struct acc_detector_presence_handle acc_detector_presence_handle_t
Definition: acc_detector_presence.h:34
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.
acc_detector_presence_config_create
acc_detector_presence_config_t * acc_detector_presence_config_create(void)
Create a configuration for a presence detector.
cargo_result_t::presence_detected
bool presence_detected
Definition: example_cargo.h:134
acc_detector_presence_config_signal_quality_set
void acc_detector_presence_config_signal_quality_set(acc_detector_presence_config_t *presence_config, float signal_quality)
Set signal quality.
acc_detector_presence_config_start_set
void acc_detector_presence_config_start_set(acc_detector_presence_config_t *presence_config, float start)
Set the start point of measurement interval in meters.
set_config
static void set_config(acc_detector_presence_config_t *presence_config, presence_preset_config_t preset)
Definition: example_detector_presence_low_power_hibernate.c:308
acc_detector_presence.h
acc_detector_presence_config_inter_detection_threshold_set
void acc_detector_presence_config_inter_detection_threshold_set(acc_detector_presence_config_t *presence_config, float inter_detection_threshold)
Set the detection threshold for the inter-frame presence detection.
acc_sensor_measure
bool acc_sensor_measure(acc_sensor_t *sensor)
Start a radar measurement with previously prepared configuration.
acc_detector_presence_config_auto_step_length_set
void acc_detector_presence_config_auto_step_length_set(acc_detector_presence_config_t *presence_config, bool enable)
Enable automatic selection of step length based on the profile.
acc_sensor_t
struct acc_sensor acc_sensor_t
Definition: acc_sensor.h:31
acc_detector_presence_config_intra_frame_time_const_set
void acc_detector_presence_config_intra_frame_time_const_set(acc_detector_presence_config_t *presence_config, float intra_frame_time_const)
Set the time constant for the depthwise filtering in the intra-frame part.
acc_detector_presence_config_automatic_subsweeps_set
void acc_detector_presence_config_automatic_subsweeps_set(acc_detector_presence_config_t *presence_config, bool automatic_subsweeps)
Set if automatic subsweeps should be used.
acc_sensor_destroy
void acc_sensor_destroy(acc_sensor_t *sensor)
Destroy a sensor instance freeing any resources allocated.
acc_definitions_a121.h
PRESENCE_PRESET_CONFIG_LOW_POWER_WAKEUP
@ PRESENCE_PRESET_CONFIG_LOW_POWER_WAKEUP
Definition: example_detector_presence_low_power_hibernate.c:51
acc_detector_presence_config_frame_rate_app_driven_set
void acc_detector_presence_config_frame_rate_app_driven_set(acc_detector_presence_config_t *presence_config, bool enable)
Set if the application should maintain the requested frame rate.
acc_detector_presence_config_inter_frame_fast_cutoff_set
void acc_detector_presence_config_inter_frame_fast_cutoff_set(acc_detector_presence_config_t *presence_config, float inter_frame_fast_cutoff)
Set the cutoff frequency of the low pass filter for the fast filtered absolute sweep mean.
acc_sensor_create
acc_sensor_t * acc_sensor_create(acc_sensor_id_t sensor_id)
Create a sensor instance.