i2c_ref_app_breathing.c
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2023-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 <stdarg.h>
8 #include <stdbool.h>
9 #include <stdint.h>
10 #include <stdio.h>
11 #include <string.h>
12
13 #include "acc_definitions_a121.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_version.h"
20
21 #include "acc_reg_protocol.h"
22 #include "i2c_application_system.h"
23 #include "i2c_ref_app_breathing.h"
24 #include "ref_app_breathing_reg_protocol.h"
25
26 #define SENSOR_ID (1U)
27 #define SENSOR_TIMEOUT_MS (10000U)
28
29 typedef struct
30 {
31 acc_sensor_t *sensor;
32 ref_app_breathing_config_t *config;
33 ref_app_breathing_handle_t *handle;
34 ref_app_breathing_result_t result;
35 acc_cal_result_t sensor_cal_result;
36 void *buffer;
37 uint32_t buffer_size;
38 } ref_app_breathing_resources_t;
39
40 static ref_app_breathing_resources_t app_resources = {0};
41 static uint32_t i2c_app_command = 0U;
42 static uint32_t i2c_app_status = 0U;
43 static bool ref_app_breathing_active = false;
44 static bool result_ready = false;
45 static bool result_ready_sticky = false;
46 static float breathing_rate = 0.0f;
47 static ref_app_breathing_app_state_t app_state = REF_APP_BREATHING_APP_STATE_INIT;
48 static uint32_t breathing_frame_counter = 0U;
49 static uint32_t breathing_last_tick_ms = 0U;
50 static uint32_t breathing_frame_rate_mhz = 0U;
51 static bool uart_logs_enabled = false;
52
53 #define UART_LOG_BUFFER_SIZE 100
54
55 /**
56 * @brief Get the i2c_app_command values
57 *
58 * The i2c_app_command is cleared during this read
59 * The read and clear are protected by a critical section
60 *
61 * @return The command sent from the host
62 */
63 static uint32_t get_command(void);
64
65 /**
66 * @brief Execute the command sent from the host
67 *
68 * @param[in] command The command to execute
69 */
70 static void command_handler(uint32_t command);
71
72 /**
73 * @brief Set bits in the i2c_app_status
74 *
75 * The i2c_app_status is protected by a critical section
76 *
77 * @param[in] bit_mask The bit_mask to set
78 */
79 static void app_status_set_bits(uint32_t bit_mask);
80
81 /**
82 * @brief Clear bits in the i2c_app_status
83 *
84 * The i2c_app_status is protected by a critical section
85 *
86 * @param[in] bit_mask The bit_mask to clear
87 */
88 static void app_status_clr_bits(uint32_t bit_mask);
89
90 /**
91 * @brief Test bits in the i2c_app_status
92 *
93 * The i2c_app_status is protected by a critical section
94 *
95 * @param[in] bit_mask The bit_mask to test
96 * @return true if all the bits in bit_mask is set in i2c_app_status
97 */
98 static bool app_status_test_bits(uint32_t bit_mask);
99
100 /**
101 * @brief Create sensor
102 *
103 * @param[in] resources Application resources struct
104 */
105 static void create_sensor(ref_app_breathing_resources_t *resources);
106
107 /**
108 * @brief Calibrate sensor
109 *
110 * @param[in] resources Application resources struct
111 * @return true if successful
112 */
113 static bool calibrate_sensor(ref_app_breathing_resources_t *resources);
114
115 /**
116 * @brief Apply application config
117 *
118 * This function will create the ref app breathing and
119 * allocate the needed memory
120 *
121 * @param[in] resources Application resources struct
122 */
123 static void apply_app_config(ref_app_breathing_resources_t *resources);
124
125 /**
126 * @brief Activate application
127 *
128 * This function will activate the application
129 *
130 * @param[in] resources Application resources struct
131 * @param[in] enable set to true to enable the application
132 * @return true if successful
133 */
134 static bool app_activate(ref_app_breathing_resources_t *resources, bool enable);
135
136 /**
137 * @brief Get next breathing measurement
138 *
139 * @param[in] resources Application resources struct
140 * @return true if successful
141 */
142 static bool app_get_next(ref_app_breathing_resources_t *resources);
143
144 /**
145 * @brief Try to set module in low power mode
146 */
147 static void module_low_power(void);
148
149 /**
150 * @brief Enter sensor hibernation state
151 */
152 static bool enter_hibernate(acc_sensor_t *sensor);
153
154 /**
155 * @brief Exit sensor hibernation state
156 */
157 static bool exit_hibernate(acc_sensor_t *sensor);
158
159 /**
160 * @brief Print the ref app breathing result
161 *
162 * Only available when the UART logs have been enabled with ENABLE_UART_LOGS
163 *
164 * @param[in] result The ref app breathing result
165 */
166 static void print_breathing_result(ref_app_breathing_result_t *result);
167
168 /**
169 * @brief UART logging function (can be enabled/disabled by command)
170 */
171 static void uart_log(const char *format, ...);
172
173 //
174 // PUBLIC FUNCTIONS
175 //
176
177 ref_app_breathing_config_t *i2c_ref_app_breathing_get_config(void)
178 {
179 return app_resources.config;
180 }
181
182 bool i2c_ref_app_breathing_command(uint32_t command)
183 {
184 bool status = false;
185
186 /* Make sure we do not have a race for i2c_app_command/i2c_app_status */
187 acc_integration_critical_section_enter();
188
189 if (i2c_app_command == 0U)
190 {
191 /* Set Ready PIN to LOW while processing the command */
192 i2c_application_system_set_ready_pin(false);
193
194 /* Set status BUSY bit */
195 i2c_app_status |= REF_APP_BREATHING_REG_APP_STATUS_FIELD_BUSY_MASK;
196 i2c_app_command = command;
197 status = true;
198 }
199
200 acc_integration_critical_section_exit();
201 return status;
202 }
203
204 uint32_t i2c_ref_app_breathing_get_status(void)
205 {
206 /* Make sure we do not have a race for i2c_app_status */
207 acc_integration_critical_section_enter();
208
209 uint32_t status = i2c_app_status;
210
211 acc_integration_critical_section_exit();
212
213 return status;
214 }
215
216 uint32_t i2c_ref_app_breathing_get_result(void)
217 {
218 uint32_t value = 0;
219
220 /* Make sure we do not have a race for results */
221 acc_integration_critical_section_enter();
222
223 if (result_ready)
224 {
225 value |= REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_RESULT_READY_MASK;
226 }
227
228 if (result_ready_sticky)
229 {
230 value |= REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_RESULT_READY_STICKY_MASK;
231 result_ready_sticky = false;
232 }
233
234 /* Add temperature */
235 uint32_t temp = (uint32_t)app_resources.result.presence_result.processing_result.temperature;
236
237 temp = (temp << REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_TEMPERATURE_POS) & REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_TEMPERATURE_MASK;
238 value |= temp;
239
240 acc_integration_critical_section_exit();
241
242 return value;
243 }
244
245 float i2c_ref_app_breathing_get_breathing_rate(void)
246 {
247 /* Make sure we do not have a race for breathing_rate */
248 acc_integration_critical_section_enter();
249
250 float value = breathing_rate;
251
252 acc_integration_critical_section_exit();
253
254 return value;
255 }
256
257 ref_app_breathing_app_state_t i2c_ref_app_breathing_get_app_state(void)
258 {
259 /* Make sure we do not have a race for app_state */
260 acc_integration_critical_section_enter();
261
262 ref_app_breathing_app_state_t state = app_state;
263
264 acc_integration_critical_section_exit();
265
266 return state;
267 }
268
269 uint32_t i2c_ref_app_breathing_get_counter(void)
270 {
271 /* Make sure we do not have a race for breathing_frame_counter */
272 acc_integration_critical_section_enter();
273
274 uint32_t counter = breathing_frame_counter;
275
276 acc_integration_critical_section_exit();
277
278 return counter;
279 }
280
281 uint32_t i2c_ref_app_breathing_get_frame_rate_mhz(void)
282 {
283 acc_integration_critical_section_enter();
284 uint32_t value = breathing_frame_rate_mhz;
285 acc_integration_critical_section_exit();
286 return value;
287 }
288
289 //
290 // MAIN
291 //
292
293 int acconeer_main(int argc, char *argv[]);
294
295 int acconeer_main(int argc, char *argv[])
296 {
297 (void)argc;
298 (void)argv;
299
300 bool setup_status = true;
301 bool get_next_frame = false;
302
303 printf("I2C Ref App Breathing\n");
304 printf("Acconeer software version %s\n", acc_version_get());
305
306 const acc_hal_a121_t *hal = acc_hal_rss_integration_get_implementation();
307
308 if (acc_rss_hal_register(hal))
309 {
310 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_RSS_REGISTER_OK_MASK);
311 }
312 else
313 {
314 printf("ERROR: acc_rss_hal_register() failed\n\n");
315 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK | REF_APP_BREATHING_REG_APP_STATUS_FIELD_RSS_REGISTER_ERROR_MASK);
316 setup_status = false;
317 }
318
319 if (setup_status)
320 {
321 app_resources.config = ref_app_breathing_config_create();
322 if (app_resources.config != NULL)
323 {
324 /* Config is created, write default values to registers */
325 ref_app_breathing_reg_protocol_write_default();
326
327 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_CREATE_OK_MASK);
328 }
329 else
330 {
331 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK |
332 REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_CREATE_ERROR_MASK);
333 printf("ERROR: ref_app_breathing_config_create() failed\n\n");
334 setup_status = false;
335 }
336 }
337
338 /* Turn the sensor on */
339 acc_hal_integration_sensor_supply_on(SENSOR_ID);
340
341 if (setup_status)
342 {
343 /* Create sensor */
344 create_sensor(&app_resources);
345 }
346
347 i2c_application_system_init();
348
349 /* Setup i2c register protocol */
350 ref_app_breathing_reg_protocol_setup();
351
352 while (true)
353 {
354
355 /* Handle Ref App Breathing */
356 if (ref_app_breathing_active && get_next_frame && !app_status_test_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK))
357 {
358 get_next_frame = false;
359 if (app_get_next(&app_resources))
360 {
361 print_breathing_result(&app_resources.result);
362 }
363 else
364 {
365 printf("ERROR: Could not get next result\n");
366 app_activate(&app_resources, false);
367 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK);
368 }
369 }
370
371 /* Handle Commands */
372 uint32_t command = get_command();
373
374 if (command == 0)
375 {
376 /* Try to set module in low power mode */
377 module_low_power();
378
379 /* Test if a periodic wakeup was the wakeup reason */
380 get_next_frame = i2c_application_is_periodic_wakeup();
381 if (get_next_frame)
382 {
383 acc_integration_critical_section_enter();
384 uint32_t time_ms = acc_integration_get_time();
385 uint32_t diff_ms = time_ms - breathing_last_tick_ms;
386 breathing_last_tick_ms = time_ms;
387 breathing_frame_rate_mhz = (diff_ms > 0) ? (1000000 / diff_ms) : 0;
388
389 acc_integration_critical_section_exit();
390 }
391
392 continue;
393 }
394
395 /* Special command, always handle reset module command, even if error has occured */
396 if (command == REF_APP_BREATHING_REG_COMMAND_ENUM_RESET_MODULE)
397 {
398 /* Reset system */
399 i2c_application_system_reset();
400 continue;
401 }
402
403 if (app_status_test_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK))
404 {
405 /* Do not process commands after error state */
406 continue;
407 }
408
409 /* Handle command */
410 command_handler(command);
411
412 /* Command handler done, clear busy bit */
413 app_status_clr_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_BUSY_MASK);
414
415 /* Set Ready PIN to HIGH when command processing is done */
416 i2c_application_system_set_ready_pin(true);
417 }
418
419 return EXIT_FAILURE;
420 }
421
422 //
423 // PRIVATE HELPER FUNCTIONS
424 //
425
426 static uint32_t get_command(void)
427 {
428 /* Make sure we do not have a race for i2c_app_command */
429 acc_integration_critical_section_enter();
430
431 uint32_t command = i2c_app_command;
432
433 i2c_app_command = 0U;
434
435 acc_integration_critical_section_exit();
436
437 return command;
438 }
439
440 static void command_handler(uint32_t command)
441 {
442 switch (command)
443 {
444 case REF_APP_BREATHING_REG_COMMAND_ENUM_APPLY_CONFIGURATION:
445 if (!app_status_test_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_APPLY_OK_MASK))
446 {
447 // Apply configuration
448 apply_app_config(&app_resources);
449 }
450
451 break;
452 case REF_APP_BREATHING_REG_COMMAND_ENUM_START_APP:
453 if (!ref_app_breathing_active)
454 {
455 if (app_activate(&app_resources, true))
456 {
457 ref_app_breathing_active = true;
458 }
459 else
460 {
461 printf("ERROR: Could not start application\n");
462 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK);
463 }
464 }
465
466 break;
467 case REF_APP_BREATHING_REG_COMMAND_ENUM_STOP_APP:
468 if (ref_app_breathing_active)
469 {
470 if (app_activate(&app_resources, false))
471 {
472 ref_app_breathing_active = false;
473 }
474 else
475 {
476 printf("ERROR: Could not stop application\n");
477 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK);
478 }
479 }
480
481 break;
482 case REF_APP_BREATHING_REG_COMMAND_ENUM_ENABLE_UART_LOGS:
483 uart_logs_enabled = true;
484 uart_log("UART logs enabled\n");
485 break;
486 case REF_APP_BREATHING_REG_COMMAND_ENUM_DISABLE_UART_LOGS:
487 uart_log("UART logs disabled\n");
488 uart_logs_enabled = false;
489 break;
490 case REF_APP_BREATHING_REG_COMMAND_ENUM_LOG_CONFIGURATION:
491 // Print the configuration
492 acc_detector_presence_config_log(app_resources.config->presence_config);
493 break;
494 default:
495 printf("ERROR: Unknown command: %" PRIu32 "", command);
496 break;
497 }
498 }
499
500 static void app_status_set_bits(uint32_t bit_mask)
501 {
502 /* Make sure we do not have a race for i2c_app_status */
503 acc_integration_critical_section_enter();
504
505 i2c_app_status |= bit_mask;
506 uint32_t temp_app_status = i2c_app_status;
507
508 acc_integration_critical_section_exit();
509
510 uart_log("App Status = 0x%" PRIx32 "\n", temp_app_status);
511 }
512
513 static void app_status_clr_bits(uint32_t bit_mask)
514 {
515 /* Make sure we do not have a race for i2c_app_status */
516 acc_integration_critical_section_enter();
517
518 i2c_app_status &= ~bit_mask;
519 uint32_t temp_app_status = i2c_app_status;
520
521 acc_integration_critical_section_exit();
522
523 uart_log("App Status = 0x%" PRIx32 "\n", temp_app_status);
524 }
525
526 static bool app_status_test_bits(uint32_t bit_mask)
527 {
528 /* Make sure we do not have a race for i2c_app_status */
529 acc_integration_critical_section_enter();
530
531 bool status = (i2c_app_status & bit_mask) == bit_mask;
532
533 acc_integration_critical_section_exit();
534
535 return status;
536 }
537
538 static void create_sensor(ref_app_breathing_resources_t *resources)
539 {
540 acc_hal_integration_sensor_enable(SENSOR_ID);
541
542 resources->sensor = acc_sensor_create(SENSOR_ID);
543
544 acc_hal_integration_sensor_disable(SENSOR_ID);
545
546 if (resources->sensor != NULL)
547 {
548 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CREATE_OK_MASK);
549 }
550 else
551 {
552 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK | REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CREATE_ERROR_MASK);
553 printf("ERROR: acc_sensor_create() failed\n");
554 }
555 }
556
557 static bool calibrate_sensor(ref_app_breathing_resources_t *resources)
558 {
559 app_status_clr_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CALIBRATE_OK_MASK |
560 REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CALIBRATE_ERROR_MASK);
561
562 bool status = false;
563 bool cal_complete = false;
564 const uint16_t calibration_retries = 1U;
565
566 // Random disturbances may cause the calibration to fail. At failure, retry at least once.
567 for (uint16_t i = 0; !status && (i <= calibration_retries); i++)
568 {
569 acc_hal_integration_sensor_enable(SENSOR_ID);
570
571 do
572 {
573 status = acc_sensor_calibrate(resources->sensor, &cal_complete, &resources->sensor_cal_result, resources->buffer, resources->buffer_size);
574 if (status && !cal_complete)
575 {
576 status = acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS);
577 }
578 } while (status && !cal_complete);
579
580 /* Reset sensor after calibration by disabling it */
581 acc_hal_integration_sensor_disable(SENSOR_ID);
582 }
583
584 if (status)
585 {
586 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CALIBRATE_OK_MASK);
587 }
588 else
589 {
590 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CALIBRATE_ERROR_MASK);
591 printf("ERROR: acc_sensor_calibrate() failed\n");
592 }
593
594 return status;
595 }
596
597 static void apply_app_config(ref_app_breathing_resources_t *resources)
598 {
599 bool status = true;
600
601 acc_detector_presence_config_frame_rate_app_driven_set(resources->config->presence_config, true);
602
603 /* Always use DEEP_SLEEP for inter_frame_idle_state to save power */
604 acc_detector_presence_config_inter_frame_idle_state_set(resources->config->presence_config, ACC_CONFIG_IDLE_STATE_DEEP_SLEEP);
605
606 resources->handle = ref_app_breathing_create(resources->config);
607 if (resources->handle != NULL)
608 {
609 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_CREATE_OK_MASK);
610 }
611 else
612 {
613 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK | REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_CREATE_ERROR_MASK);
614 printf("ERROR: ref_app_breathing_create() failed\n");
615 status = false;
616 }
617
618 if (status)
619 {
620 if (ref_app_breathing_get_buffer_size(resources->handle, &(resources->buffer_size)))
621 {
622 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_BUFFER_OK_MASK);
623 }
624 else
625 {
626 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK | REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_BUFFER_ERROR_MASK);
627 printf("ERROR: ref_app_breathing_get_buffer_size() failed\n");
628 status = false;
629 }
630 }
631
632 if (status)
633 {
634 resources->buffer = acc_integration_mem_alloc(resources->buffer_size);
635 if (resources->buffer != NULL)
636 {
637 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_BUFFER_OK_MASK);
638 }
639 else
640 {
641 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK |
642 REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_BUFFER_ERROR_MASK);
643 printf("ERROR: sensor buffer allocation failed\n");
644 status = false;
645 }
646 }
647
648 if (status)
649 {
650 status = calibrate_sensor(&app_resources);
651 }
652
653 if (status)
654 {
655 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_APPLY_OK_MASK);
656 }
657 else
658 {
659 printf("ERROR: apply application config failed\n");
660 app_status_set_bits(REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK | REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_APPLY_ERROR_MASK);
661 }
662 }
663
664 static bool app_activate(ref_app_breathing_resources_t *resources, bool enable)
665 {
666 bool status = true;
667
668 if (enable)
669 {
670 uart_log("Start ref app breathing\n");
671 acc_hal_integration_sensor_enable(SENSOR_ID);
672
673 if (!ref_app_breathing_prepare(resources->handle,
674 resources->config,
675 resources->sensor,
676 &resources->sensor_cal_result,
677 resources->buffer,
678 resources->buffer_size))
679 {
680 status = false;
681 printf("ERROR: ref_app_breathing_prepare() failed\n");
682 }
683
684 if (status)
685 {
686 status = enter_hibernate(resources->sensor);
687 }
688
689 if (status)
690 {
691 uint32_t sleep_time_ms = (uint32_t)(1000.0f / acc_detector_presence_config_frame_rate_get(resources->config->presence_config));
692 i2c_application_set_periodic_wakeup(sleep_time_ms);
693 }
694 }
695 else
696 {
697 uart_log("Stop ref app breathing\n");
698
699 status = exit_hibernate(resources->sensor);
700
701 acc_hal_integration_sensor_disable(SENSOR_ID);
702 i2c_application_set_periodic_wakeup(0);
703 }
704
705 return status;
706 }
707
708 static bool app_get_next(ref_app_breathing_resources_t *resources)
709 {
710 bool status = true;
711
712 /* Exit from hibernation */
713 status = exit_hibernate(resources->sensor);
714
715 if (status)
716 {
717 if (!acc_sensor_measure(resources->sensor))
718 {
719 printf("ERROR: acc_sensor_measure() failed\n");
720 status = false;
721 }
722 }
723
724 if (status)
725 {
726 if (!acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS))
727 {
728 printf("ERROR: Sensor interrupt timeout\n");
729 status = false;
730 }
731 }
732
733 if (status)
734 {
735 if (!acc_sensor_read(resources->sensor, resources->buffer, resources->buffer_size))
736 {
737 printf("ERROR: acc_sensor_read() failed\n");
738 status = false;
739 }
740 }
741
742 if (status)
743 {
744 /* Enter hibernation */
745 status = enter_hibernate(resources->sensor);
746 }
747
748 if (status)
749 {
750 if (!ref_app_breathing_process(resources->handle, resources->buffer, &resources->result))
751 {
752 printf("ERROR: ref_app_breathing_process() failed\n");
753 status = false;
754 }
755 }
756
757 if (status)
758 {
759 /* Make sure we do not have a race for breathing_frame_counter */
760 acc_integration_critical_section_enter();
761
762 breathing_frame_counter++;
763
764 acc_integration_critical_section_exit();
765
766 if (resources->result.presence_result.processing_result.calibration_needed)
767 {
768 uart_log("Recalibration\n");
769
770 status = app_activate(resources, false);
771
772 if (status && calibrate_sensor(resources))
773 {
774 status = app_activate(resources, true);
775 }
776 }
777 }
778
779 if (status)
780 {
781 /* Make sure we do not have a race for results */
782 acc_integration_critical_section_enter();
783
784 app_state = resources->result.app_state;
785 result_ready = resources->result.result_ready;
786
787 if (result_ready)
788 {
789 breathing_rate = resources->result.breathing_rate;
790 result_ready_sticky = true;
791 }
792 else if (app_state != REF_APP_BREATHING_APP_STATE_ESTIMATE_BREATHING_RATE)
793 {
794 breathing_rate = 0.0f;
795 }
796
797 acc_integration_critical_section_exit();
798 }
799
800 return status;
801 }
802
803 static void module_low_power(void)
804 {
805 if (i2c_application_system_test_wakeup_pin())
806 {
807 i2c_application_system_wait_for_interrupt();
808 }
809 else
810 {
811 /* Set ready pin LOW, we are about to power down */
812 i2c_application_system_set_ready_pin(false);
813
814 uart_log("Enter low power state\n");
815 i2c_application_enter_low_power_state();
816 uart_log("Exit low power state\n");
817 }
818
819 if (i2c_application_system_test_wakeup_pin())
820 {
821 /* Set ready pin HIGH, we are ready for a command */
822 i2c_application_system_set_ready_pin(true);
823 }
824 }
825
826 static bool enter_hibernate(acc_sensor_t *sensor)
827 {
828 bool status = true;
829
830 if (!acc_sensor_hibernate_on(sensor))
831 {
832 printf("ERROR: acc_sensor_hibernate_on failed\n");
833 status = false;
834 }
835
836 acc_hal_integration_sensor_disable(SENSOR_ID);
837 return status;
838 }
839
840 static bool exit_hibernate(acc_sensor_t *sensor)
841 {
842 bool status = true;
843
844 acc_hal_integration_sensor_enable(SENSOR_ID);
845 if (!acc_sensor_hibernate_off(sensor))
846 {
847 printf("ERROR: acc_sensor_hibernate_off failed\n");
848 status = false;
849 }
850
851 return status;
852 }
853
854 static void print_breathing_result(ref_app_breathing_result_t *result)
855 {
856 if (result->result_ready)
857 {
858 uart_log("Breaths: %" PRIu16 " bpm\n", (uint16_t)result->breathing_rate);
859 }
860 }
861
862 static void uart_log(const char *format, ...)
863 {
864 char log_buffer[UART_LOG_BUFFER_SIZE];
865
866 va_list ap;
867
868 va_start(ap, format);
869
870 if (uart_logs_enabled)
871 {
872 int ret = vsnprintf(log_buffer, UART_LOG_BUFFER_SIZE, format, ap);
873
874 if (ret >= UART_LOG_BUFFER_SIZE)
875 {
876 log_buffer[UART_LOG_BUFFER_SIZE - 4] = '.';
877 log_buffer[UART_LOG_BUFFER_SIZE - 3] = '.';
878 log_buffer[UART_LOG_BUFFER_SIZE - 2] = '.';
879 log_buffer[UART_LOG_BUFFER_SIZE - 1] = 0;
880 }
881
882 printf("%s", log_buffer);
883 }
884
885 va_end(ap);
886 }
exit_hibernate
static bool exit_hibernate(acc_sensor_t *sensor)
Exit sensor hibernation state.
Definition: i2c_ref_app_breathing.c:840
REF_APP_BREATHING_APP_STATE_ESTIMATE_BREATHING_RATE
@ REF_APP_BREATHING_APP_STATE_ESTIMATE_BREATHING_RATE
Definition: ref_app_breathing.h:66
ref_app_breathing_result_t::result_ready
bool result_ready
Definition: ref_app_breathing.h:77
i2c_ref_app_breathing_get_config
ref_app_breathing_config_t * i2c_ref_app_breathing_get_config(void)
Get ref app breathing configuration handle.
Definition: i2c_ref_app_breathing.c:177
ref_app_breathing_prepare
bool ref_app_breathing_prepare(ref_app_breathing_handle_t *handle, ref_app_breathing_config_t *config, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
Prepare the application to do a measurement.
Definition: ref_app_breathing.c:358
REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_BUFFER_ERROR_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_BUFFER_ERROR_MASK
Definition: ref_app_breathing_reg_protocol.h:87
acc_rss_a121.h
REF_APP_BREATHING_REG_COMMAND_ENUM_START_APP
#define REF_APP_BREATHING_REG_COMMAND_ENUM_START_APP
Definition: ref_app_breathing_reg_protocol.h:119
REF_APP_BREATHING_REG_APP_STATUS_FIELD_BUSY_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_BUSY_MASK
Definition: ref_app_breathing_reg_protocol.h:93
REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CALIBRATE_OK_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CALIBRATE_OK_MASK
Definition: ref_app_breathing_reg_protocol.h:65
SENSOR_ID
#define SENSOR_ID
Definition: i2c_ref_app_breathing.c:26
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
REF_APP_BREATHING_APP_STATE_INIT
@ REF_APP_BREATHING_APP_STATE_INIT
Definition: ref_app_breathing.h:62
acc_integration_get_time
uint32_t acc_integration_get_time(void)
Get current time.
Definition: acc_integration_stm32.c:587
acc_sensor_read
bool acc_sensor_read(const acc_sensor_t *sensor, void *buffer, uint32_t buffer_size)
Read out radar data.
ref_app_breathing_active
static bool ref_app_breathing_active
Definition: i2c_ref_app_breathing.c:43
vsnprintf
#define vsnprintf
Definition: printf.h:85
acc_version.h
i2c_application_system_reset
void i2c_application_system_reset(void)
Reset the system.
Definition: i2c_application_system_stm32.c:158
REF_APP_BREATHING_REG_COMMAND_ENUM_RESET_MODULE
#define REF_APP_BREATHING_REG_COMMAND_ENUM_RESET_MODULE
Definition: ref_app_breathing_reg_protocol.h:124
result_ready
static bool result_ready
Definition: i2c_ref_app_breathing.c:44
ref_app_breathing_get_buffer_size
bool ref_app_breathing_get_buffer_size(ref_app_breathing_handle_t *handle, uint32_t *buffer_size)
Get the buffer size needed for the provided ref app breathing handle.
Definition: ref_app_breathing.c:353
acc_detector_presence_result_t::processing_result
acc_processing_result_t processing_result
Definition: acc_detector_presence.h:82
acc_cal_result_t
The result from a completed calibration.
Definition: acc_definitions_a121.h:30
ref_app_breathing_create
ref_app_breathing_handle_t * ref_app_breathing_create(ref_app_breathing_config_t *config)
Create a handle for the ref app breathing.
Definition: ref_app_breathing.c:156
acc_integration_critical_section_exit
void acc_integration_critical_section_exit(void)
Definition: acc_integration_cortex.c:16
ACC_CONFIG_IDLE_STATE_DEEP_SLEEP
@ ACC_CONFIG_IDLE_STATE_DEEP_SLEEP
Definition: acc_definitions_a121.h:73
uart_log
static void uart_log(const char *format,...)
UART logging function (can be enabled/disabled by command)
Definition: i2c_ref_app_breathing.c:862
ref_app_breathing_result_t
Breathing application results container.
Definition: ref_app_breathing.h:72
REF_APP_BREATHING_REG_COMMAND_ENUM_LOG_CONFIGURATION
#define REF_APP_BREATHING_REG_COMMAND_ENUM_LOG_CONFIGURATION
Definition: ref_app_breathing_reg_protocol.h:123
REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_TEMPERATURE_POS
#define REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_TEMPERATURE_POS
Definition: ref_app_breathing_reg_protocol.h:100
i2c_ref_app_breathing.h
uart_logs_enabled
static bool uart_logs_enabled
Definition: i2c_ref_app_breathing.c:51
acc_integration.h
ref_app_breathing_reg_protocol_setup
void ref_app_breathing_reg_protocol_setup(void)
Definition: ref_app_breathing_reg_protocol.c:132
ref_app_breathing_resources_t::config
ref_app_breathing_config_t * config
Definition: i2c_ref_app_breathing.c:32
REF_APP_BREATHING_REG_APP_STATUS_FIELD_RSS_REGISTER_OK_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_RSS_REGISTER_OK_MASK
Definition: ref_app_breathing_reg_protocol.h:59
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
REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_BUFFER_OK_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_BUFFER_OK_MASK
Definition: ref_app_breathing_reg_protocol.h:71
i2c_ref_app_breathing_get_frame_rate_mhz
uint32_t i2c_ref_app_breathing_get_frame_rate_mhz(void)
Get the actual frame rate for the current ref app breathing configuration.
Definition: i2c_ref_app_breathing.c:281
ref_app_breathing_resources_t
Definition: i2c_ref_app_breathing.c:29
REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_CREATE_ERROR_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_CREATE_ERROR_MASK
Definition: ref_app_breathing_reg_protocol.h:77
ref_app_breathing_reg_protocol_write_default
void ref_app_breathing_reg_protocol_write_default(void)
Definition: ref_app_breathing_reg_protocol.c:138
module_low_power
static void module_low_power(void)
Try to set module in low power mode.
Definition: i2c_ref_app_breathing.c:803
acc_integration_mem_alloc
void * acc_integration_mem_alloc(size_t size)
Allocate dynamic memory.
Definition: acc_integration_stm32.c:592
ref_app_breathing_result_t::breathing_rate
float breathing_rate
Definition: ref_app_breathing.h:81
ref_app_breathing_config_create
ref_app_breathing_config_t * ref_app_breathing_config_create(void)
Create a configuration for the ref app breathing.
Definition: ref_app_breathing.c:100
acc_hal_a121_t
Definition: acc_hal_definitions_a121.h:82
enter_hibernate
static bool enter_hibernate(acc_sensor_t *sensor)
Enter sensor hibernation state.
Definition: i2c_ref_app_breathing.c:826
calibrate_sensor
static bool calibrate_sensor(ref_app_breathing_resources_t *resources)
Calibrate sensor.
Definition: i2c_ref_app_breathing.c:557
REF_APP_BREATHING_REG_COMMAND_ENUM_APPLY_CONFIGURATION
#define REF_APP_BREATHING_REG_COMMAND_ENUM_APPLY_CONFIGURATION
Definition: ref_app_breathing_reg_protocol.h:118
i2c_ref_app_breathing_get_app_state
ref_app_breathing_app_state_t i2c_ref_app_breathing_get_app_state(void)
Get app state.
Definition: i2c_ref_app_breathing.c:257
acc_rss_hal_register
bool acc_rss_hal_register(const acc_hal_a121_t *hal)
Register an integration.
i2c_application_system_wait_for_interrupt
void i2c_application_system_wait_for_interrupt(void)
Wait for interrupt to occur.
Definition: i2c_application_system_stm32.c:169
REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_APPLY_OK_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_APPLY_OK_MASK
Definition: ref_app_breathing_reg_protocol.h:73
ref_app_breathing_resources_t::sensor
acc_sensor_t * sensor
Definition: i2c_ref_app_breathing.c:31
REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_BUFFER_ERROR_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_BUFFER_ERROR_MASK
Definition: ref_app_breathing_reg_protocol.h:85
REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_RESULT_READY_STICKY_MASK
#define REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_RESULT_READY_STICKY_MASK
Definition: ref_app_breathing_reg_protocol.h:99
sensor
acc_sensor_t * sensor
Definition: i2c_example_cargo.c:33
i2c_ref_app_breathing_get_result
uint32_t i2c_ref_app_breathing_get_result(void)
Get ref app breathing result.
Definition: i2c_ref_app_breathing.c:216
get_command
static uint32_t get_command(void)
Get the i2c_app_command values.
Definition: i2c_ref_app_breathing.c:426
create_sensor
static void create_sensor(ref_app_breathing_resources_t *resources)
Create sensor.
Definition: i2c_ref_app_breathing.c:538
ref_app_breathing_result_t::presence_result
acc_detector_presence_result_t presence_result
Definition: ref_app_breathing.h:89
ref_app_breathing_process
bool ref_app_breathing_process(ref_app_breathing_handle_t *handle, void *buffer, ref_app_breathing_result_t *result)
Process the data.
Definition: ref_app_breathing.c:368
ref_app_breathing_resources_t::result
ref_app_breathing_result_t result
Definition: i2c_ref_app_breathing.c:34
i2c_app_status
static uint32_t i2c_app_status
Definition: i2c_ref_app_breathing.c:42
i2c_app_command
static uint32_t i2c_app_command
Definition: i2c_ref_app_breathing.c:41
ref_app_breathing_result_t::app_state
ref_app_breathing_app_state_t app_state
Definition: ref_app_breathing.h:85
REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CREATE_ERROR_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CREATE_ERROR_MASK
Definition: ref_app_breathing_reg_protocol.h:79
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
app_get_next
static bool app_get_next(ref_app_breathing_resources_t *resources)
Get next breathing measurement.
Definition: i2c_ref_app_breathing.c:708
acc_hal_integration_a121.h
REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_TEMPERATURE_MASK
#define REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_TEMPERATURE_MASK
Definition: ref_app_breathing_reg_protocol.h:101
REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CALIBRATE_ERROR_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CALIBRATE_ERROR_MASK
Definition: ref_app_breathing_reg_protocol.h:81
i2c_application_system.h
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
app_state
static ref_app_breathing_app_state_t app_state
Definition: i2c_ref_app_breathing.c:47
result_ready_sticky
static bool result_ready_sticky
Definition: i2c_ref_app_breathing.c:45
ref_app_breathing_reg_protocol.h
REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_ERROR_MASK
Definition: ref_app_breathing_reg_protocol.h:91
i2c_application_enter_low_power_state
void i2c_application_enter_low_power_state(void)
Make the MCU enter its low power state.
Definition: i2c_application_system_stm32.c:215
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.
REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_CREATE_OK_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_CREATE_OK_MASK
Definition: ref_app_breathing_reg_protocol.h:61
acc_hal_definitions_a121.h
i2c_ref_app_breathing_get_breathing_rate
float i2c_ref_app_breathing_get_breathing_rate(void)
Get breathing rate.
Definition: i2c_ref_app_breathing.c:245
ref_app_breathing_resources_t::buffer_size
uint32_t buffer_size
Definition: i2c_ref_app_breathing.c:37
breathing_frame_rate_mhz
static uint32_t breathing_frame_rate_mhz
Definition: i2c_ref_app_breathing.c:50
REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_BUFFER_OK_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_BUFFER_OK_MASK
Definition: ref_app_breathing_reg_protocol.h:69
i2c_application_system_set_ready_pin
void i2c_application_system_set_ready_pin(bool enable)
Set the ready pin state.
Definition: i2c_application_system_stm32.c:181
SENSOR_TIMEOUT_MS
#define SENSOR_TIMEOUT_MS
Definition: i2c_ref_app_breathing.c:27
i2c_ref_app_breathing_get_status
uint32_t i2c_ref_app_breathing_get_status(void)
Get ref app breathing status.
Definition: i2c_ref_app_breathing.c:204
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
REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_CREATE_OK_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_CREATE_OK_MASK
Definition: ref_app_breathing_reg_protocol.h:67
i2c_application_set_periodic_wakeup
void i2c_application_set_periodic_wakeup(uint32_t period_ms)
Set up a periodic timer used to wake up the system from sleep.
Definition: i2c_application_system_stm32.c:238
REF_APP_BREATHING_REG_COMMAND_ENUM_STOP_APP
#define REF_APP_BREATHING_REG_COMMAND_ENUM_STOP_APP
Definition: ref_app_breathing_reg_protocol.h:120
REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CREATE_OK_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_SENSOR_CREATE_OK_MASK
Definition: ref_app_breathing_reg_protocol.h:63
acc_sensor_hibernate_on
bool acc_sensor_hibernate_on(acc_sensor_t *sensor)
Prepare sensor for entering hibernation.
i2c_application_system_init
void i2c_application_system_init(void)
Init the system.
Definition: i2c_application_system_stm32.c:130
REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_CREATE_ERROR_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_APP_CREATE_ERROR_MASK
Definition: ref_app_breathing_reg_protocol.h:83
app_activate
static bool app_activate(ref_app_breathing_resources_t *resources, bool enable)
Activate application.
Definition: i2c_ref_app_breathing.c:664
ref_app_breathing_resources_t::buffer
void * buffer
Definition: i2c_ref_app_breathing.c:36
breathing_frame_counter
static uint32_t breathing_frame_counter
Definition: i2c_ref_app_breathing.c:48
app_status_set_bits
static void app_status_set_bits(uint32_t bit_mask)
Set bits in the i2c_app_status.
Definition: i2c_ref_app_breathing.c:500
acconeer_main
int acconeer_main(int argc, char *argv[])
Assembly test example.
Definition: i2c_ref_app_breathing.c:295
acc_detector_presence_config_log
void acc_detector_presence_config_log(acc_detector_presence_config_t *presence_config)
Print a configuration to the log.
acc_reg_protocol.h
i2c_application_is_periodic_wakeup
bool i2c_application_is_periodic_wakeup(void)
Test if a periodic wake up has occurred.
Definition: i2c_application_system_stm32.c:244
REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_APPLY_ERROR_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_CONFIG_APPLY_ERROR_MASK
Definition: ref_app_breathing_reg_protocol.h:89
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.
acc_integration_critical_section_enter
void acc_integration_critical_section_enter(void)
Definition: acc_integration_cortex.c:9
ref_app_breathing_resources_t::handle
ref_app_breathing_handle_t * handle
Definition: i2c_ref_app_breathing.c:33
command_handler
static void command_handler(uint32_t command)
Execute the command sent from the host.
Definition: i2c_ref_app_breathing.c:440
ref_app_breathing_handle
Definition: ref_app_breathing.c:23
acc_processing_result_t::temperature
int16_t temperature
Definition: acc_processing.h:89
REF_APP_BREATHING_REG_APP_STATUS_FIELD_RSS_REGISTER_ERROR_MASK
#define REF_APP_BREATHING_REG_APP_STATUS_FIELD_RSS_REGISTER_ERROR_MASK
Definition: ref_app_breathing_reg_protocol.h:75
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.
print_breathing_result
static void print_breathing_result(ref_app_breathing_result_t *result)
Print the ref app breathing result.
Definition: i2c_ref_app_breathing.c:854
ref_app_breathing_config_t
Breathing application config container.
Definition: ref_app_breathing.h:25
apply_app_config
static void apply_app_config(ref_app_breathing_resources_t *resources)
Apply application config.
Definition: i2c_ref_app_breathing.c:597
REF_APP_BREATHING_REG_COMMAND_ENUM_ENABLE_UART_LOGS
#define REF_APP_BREATHING_REG_COMMAND_ENUM_ENABLE_UART_LOGS
Definition: ref_app_breathing_reg_protocol.h:121
i2c_ref_app_breathing_get_counter
uint32_t i2c_ref_app_breathing_get_counter(void)
Get measure counter.
Definition: i2c_ref_app_breathing.c:269
REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_RESULT_READY_MASK
#define REF_APP_BREATHING_REG_BREATHING_RESULT_FIELD_RESULT_READY_MASK
Definition: ref_app_breathing_reg_protocol.h:97
acc_processing_result_t::calibration_needed
bool calibration_needed
Definition: acc_processing.h:84
acc_detector_presence.h
acc_sensor_measure
bool acc_sensor_measure(acc_sensor_t *sensor)
Start a radar measurement with previously prepared configuration.
i2c_application_system_test_wakeup_pin
bool i2c_application_system_test_wakeup_pin(void)
Check if wakeup pin is high.
Definition: i2c_application_system_stm32.c:174
breathing_rate
static float breathing_rate
Definition: i2c_ref_app_breathing.c:46
breathing_last_tick_ms
static uint32_t breathing_last_tick_ms
Definition: i2c_ref_app_breathing.c:49
app_status_clr_bits
static void app_status_clr_bits(uint32_t bit_mask)
Clear bits in the i2c_app_status.
Definition: i2c_ref_app_breathing.c:513
acc_sensor_t
struct acc_sensor acc_sensor_t
Definition: acc_sensor.h:31
REF_APP_BREATHING_REG_COMMAND_ENUM_DISABLE_UART_LOGS
#define REF_APP_BREATHING_REG_COMMAND_ENUM_DISABLE_UART_LOGS
Definition: ref_app_breathing_reg_protocol.h:122
UART_LOG_BUFFER_SIZE
#define UART_LOG_BUFFER_SIZE
Definition: i2c_ref_app_breathing.c:53
ref_app_breathing_app_state_t
ref_app_breathing_app_state_t
State of the application.
Definition: ref_app_breathing.h:60
acc_definitions_a121.h
app_resources
static ref_app_breathing_resources_t app_resources
Definition: i2c_ref_app_breathing.c:40
ref_app_breathing_resources_t::sensor_cal_result
acc_cal_result_t sensor_cal_result
Definition: i2c_ref_app_breathing.c:35
i2c_ref_app_breathing_command
bool i2c_ref_app_breathing_command(uint32_t command)
Send command to be executed to i2c ref app breathing.
Definition: i2c_ref_app_breathing.c:182
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.
ref_app_breathing_config_t::presence_config
acc_detector_presence_config_t * presence_config
Definition: ref_app_breathing.h:54
app_status_test_bits
static bool app_status_test_bits(uint32_t bit_mask)
Test bits in the i2c_app_status.
Definition: i2c_ref_app_breathing.c:526
acc_sensor_create
acc_sensor_t * acc_sensor_create(acc_sensor_id_t sensor_id)
Create a sensor instance.