distance_reg_protocol_access.c
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2023
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
10 #include "acc_detector_distance.h"
11 #include "acc_detector_distance_definitions.h"
12 #include "acc_integration.h"
13 #include "acc_version.h"
14
15 #include "acc_reg_protocol.h"
16 #include "distance_reg_protocol.h"
17 #include "i2c_distance_detector.h"
18
19
20 /**
21 * @brief Get the protocol error status flags
22 *
23 * @return error flags as uint32 register value
24 */
25 static uint32_t get_protocol_error_flags(void);
26
27
28 /**
29 * @brief Get peak distance
30 *
31 * This function will return the peak distance in mm
32 *
33 * @param[in] peak_id The index of the peak
34 * @return The uint32 value representation of the peak distance
35 */
36 static uint32_t get_peak_distance(uint16_t peak_id);
37
38
39 /**
40 * @brief Get peak strength
41 *
42 * This function will return the peak distance in dB * 1000
43 *
44 * @param[in] peak_id The index of the peak
45 * @return The int32 value representation of the peak strength
46 */
47 static uint32_t get_peak_strength(uint16_t peak_id);
48
49
50 //
51 // REGISTER READ/WRITE ACCESS FUNCTIONS
52 //
53
54
55 void distance_reg_read_version(uint32_t *value)
56 {
57 *value = acc_version_get_hex();
58 }
59
60
61 void distance_reg_read_protocol_status(uint32_t *value)
62 {
63 uint32_t error_flags = get_protocol_error_flags();
64 uint32_t protocol_status = 0;
65
66 if ((error_flags & ACC_REG_ERROR_FLAG_PROTOCOL_STATE_ERROR) != 0)
67 {
68 protocol_status |= DISTANCE_REG_PROTOCOL_STATUS_FIELD_PROTOCOL_STATE_ERROR_MASK;
69 }
70
71 if ((error_flags & ACC_REG_ERROR_FLAG_PACKET_LENGTH_ERROR) != 0)
72 {
73 protocol_status |= DISTANCE_REG_PROTOCOL_STATUS_FIELD_PACKET_LENGTH_ERROR_MASK;
74 }
75
76 if ((error_flags & ACC_REG_ERROR_FLAG_ADDRESS_ERROR) != 0)
77 {
78 protocol_status |= DISTANCE_REG_PROTOCOL_STATUS_FIELD_ADDRESS_ERROR_MASK;
79 }
80
81 if ((error_flags & ACC_REG_ERROR_FLAG_WRITE_FAILED) != 0)
82 {
83 protocol_status |= DISTANCE_REG_PROTOCOL_STATUS_FIELD_WRITE_FAILED_MASK;
84 }
85
86 if ((error_flags & ACC_REG_ERROR_FLAG_WRITE_TO_READ_ONLY) != 0)
87 {
88 protocol_status |= DISTANCE_REG_PROTOCOL_STATUS_FIELD_WRITE_TO_READ_ONLY_MASK;
89 }
90
91 *value = protocol_status;
92 }
93
94
95 void distance_reg_read_measure_counter(uint32_t *value)
96 {
97 *value = i2c_distance_detector_get_counter();
98 }
99
100
101 void distance_reg_read_detector_status(uint32_t *value)
102 {
103 *value = i2c_distance_detector_get_status();
104 }
105
106
107 void distance_reg_read_distance_result(uint32_t *value)
108 {
109 *value = i2c_distance_detector_get_result();
110 }
111
112
113 void distance_reg_read_peak0_distance(uint32_t *value)
114 {
115 *value = get_peak_distance(0);
116 }
117
118
119 void distance_reg_read_peak1_distance(uint32_t *value)
120 {
121 *value = get_peak_distance(1);
122 }
123
124
125 void distance_reg_read_peak2_distance(uint32_t *value)
126 {
127 *value = get_peak_distance(2);
128 }
129
130
131 void distance_reg_read_peak3_distance(uint32_t *value)
132 {
133 *value = get_peak_distance(3);
134 }
135
136
137 void distance_reg_read_peak4_distance(uint32_t *value)
138 {
139 *value = get_peak_distance(4);
140 }
141
142
143 void distance_reg_read_peak5_distance(uint32_t *value)
144 {
145 *value = get_peak_distance(5);
146 }
147
148
149 void distance_reg_read_peak6_distance(uint32_t *value)
150 {
151 *value = get_peak_distance(6);
152 }
153
154
155 void distance_reg_read_peak7_distance(uint32_t *value)
156 {
157 *value = get_peak_distance(7);
158 }
159
160
161 void distance_reg_read_peak8_distance(uint32_t *value)
162 {
163 *value = get_peak_distance(8);
164 }
165
166
167 void distance_reg_read_peak9_distance(uint32_t *value)
168 {
169 *value = get_peak_distance(9);
170 }
171
172
173 void distance_reg_read_peak0_strength(uint32_t *value)
174 {
175 *value = get_peak_strength(0);
176 }
177
178
179 void distance_reg_read_peak1_strength(uint32_t *value)
180 {
181 *value = get_peak_strength(1);
182 }
183
184
185 void distance_reg_read_peak2_strength(uint32_t *value)
186 {
187 *value = get_peak_strength(2);
188 }
189
190
191 void distance_reg_read_peak3_strength(uint32_t *value)
192 {
193 *value = get_peak_strength(3);
194 }
195
196
197 void distance_reg_read_peak4_strength(uint32_t *value)
198 {
199 *value = get_peak_strength(4);
200 }
201
202
203 void distance_reg_read_peak5_strength(uint32_t *value)
204 {
205 *value = get_peak_strength(5);
206 }
207
208
209 void distance_reg_read_peak6_strength(uint32_t *value)
210 {
211 *value = get_peak_strength(6);
212 }
213
214
215 void distance_reg_read_peak7_strength(uint32_t *value)
216 {
217 *value = get_peak_strength(7);
218 }
219
220
221 void distance_reg_read_peak8_strength(uint32_t *value)
222 {
223 *value = get_peak_strength(8);
224 }
225
226
227 void distance_reg_read_peak9_strength(uint32_t *value)
228 {
229 *value = get_peak_strength(9);
230 }
231
232
233 void distance_reg_read_start(uint32_t *value)
234 {
235 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
236 float start = acc_detector_distance_config_start_get(config);
237
238 *value = acc_reg_protocol_float_to_uint32_milli(start);
239 }
240
241
242 bool distance_reg_write_start(const uint32_t value)
243 {
244 bool status = false;
245 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
246
247 if (config != NULL)
248 {
249 float start = acc_reg_protocol_uint32_milli_to_float(value);
250 acc_detector_distance_config_start_set(config, start);
251 status = true;
252 }
253
254 return status;
255 }
256
257
258 void distance_reg_read_end(uint32_t *value)
259 {
260 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
261 float end = acc_detector_distance_config_end_get(config);
262
263 *value = acc_reg_protocol_float_to_uint32_milli(end);
264 }
265
266
267 bool distance_reg_write_end(const uint32_t value)
268 {
269 bool status = false;
270 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
271
272 if (config != NULL)
273 {
274 float end = acc_reg_protocol_uint32_milli_to_float(value);
275 acc_detector_distance_config_end_set(config, end);
276 status = true;
277 }
278
279 return status;
280 }
281
282
283 void distance_reg_read_max_step_length(uint32_t *value)
284 {
285 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
286
287 *value = acc_detector_distance_config_max_step_length_get(config);
288 }
289
290
291 bool distance_reg_write_max_step_length(const uint32_t value)
292 {
293 bool status = false;
294 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
295
296 if (config != NULL)
297 {
298 acc_detector_distance_config_max_step_length_set(config, value);
299 status = true;
300 }
301
302 return status;
303 }
304
305
306 void distance_reg_read_close_range_leakage_cancellation(uint32_t *value)
307 {
308 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
309
310 *value = acc_detector_distance_config_close_range_leakage_cancellation_get(config);
311 }
312
313
314 bool distance_reg_write_close_range_leakage_cancellation(const uint32_t value)
315 {
316 bool status = false;
317 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
318
319 if (config != NULL)
320 {
321 acc_detector_distance_config_close_range_leakage_cancellation_set(config, (value != 0));
322 status = true;
323 }
324
325 return status;
326 }
327
328
329 void distance_reg_read_signal_quality(uint32_t *value)
330 {
331 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
332 float signal_quality = acc_detector_distance_config_signal_quality_get(config);
333
334 *value = acc_reg_protocol_float_to_int32_milli(signal_quality);
335 }
336
337
338 bool distance_reg_write_signal_quality(const uint32_t value)
339 {
340 bool status = false;
341 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
342
343 if (config != NULL)
344 {
345 float signal_quality = acc_reg_protocol_int32_milli_to_float(value);
346 acc_detector_distance_config_signal_quality_set(config, signal_quality);
347 status = true;
348 }
349
350 return status;
351 }
352
353
354 void distance_reg_read_max_profile(uint32_t *value)
355 {
356 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
357 acc_config_profile_t profile = acc_detector_distance_config_max_profile_get(config);
358 uint32_t profile_value = 0;
359
360 switch (profile)
361 {
362 case ACC_CONFIG_PROFILE_1:
363 profile_value = DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE1;
364 break;
365 case ACC_CONFIG_PROFILE_2:
366 profile_value = DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE2;
367 break;
368 case ACC_CONFIG_PROFILE_3:
369 profile_value = DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE3;
370 break;
371 case ACC_CONFIG_PROFILE_4:
372 profile_value = DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE4;
373 break;
374 case ACC_CONFIG_PROFILE_5:
375 profile_value = DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE5;
376 break;
377 default:
378 break;
379 }
380
381 *value = profile_value;
382 }
383
384
385 bool distance_reg_write_max_profile(const uint32_t value)
386 {
387 bool status = false;
388 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
389
390 if (config != NULL)
391 {
392 status = true;
393 acc_config_profile_t profile = ACC_CONFIG_PROFILE_1;
394
395 switch (value)
396 {
397 case DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE1:
398 profile = ACC_CONFIG_PROFILE_1;
399 break;
400 case DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE2:
401 profile = ACC_CONFIG_PROFILE_2;
402 break;
403 case DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE3:
404 profile = ACC_CONFIG_PROFILE_3;
405 break;
406 case DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE4:
407 profile = ACC_CONFIG_PROFILE_4;
408 break;
409 case DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE5:
410 profile = ACC_CONFIG_PROFILE_5;
411 break;
412 default:
413 status = false;
414 break;
415 }
416
417 if (status)
418 {
419 acc_detector_distance_config_max_profile_set(config, profile);
420 }
421 }
422
423 return status;
424 }
425
426
427 void distance_reg_read_threshold_method(uint32_t *value)
428 {
429 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
430 acc_detector_distance_threshold_method_t threshold_method = acc_detector_distance_config_threshold_method_get(config);
431 uint32_t threshold_method_value = 0;
432
433 switch (threshold_method)
434 {
435 case ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_FIXED_AMPLITUDE:
436 threshold_method_value = DISTANCE_REG_THRESHOLD_METHOD_ENUM_FIXED_AMPLITUDE;
437 break;
438 case ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_FIXED_STRENGTH:
439 threshold_method_value = DISTANCE_REG_THRESHOLD_METHOD_ENUM_FIXED_STRENGTH;
440 break;
441 case ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_RECORDED:
442 threshold_method_value = DISTANCE_REG_THRESHOLD_METHOD_ENUM_RECORDED;
443 break;
444 case ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR:
445 threshold_method_value = DISTANCE_REG_THRESHOLD_METHOD_ENUM_CFAR;
446 break;
447 default:
448 break;
449 }
450
451 *value = threshold_method_value;
452 }
453
454
455 bool distance_reg_write_threshold_method(const uint32_t value)
456 {
457 bool status = false;
458 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
459
460 if (config != NULL)
461 {
462 status = true;
463 acc_detector_distance_threshold_method_t threshold_method = ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_FIXED_AMPLITUDE;
464
465 switch (value)
466 {
467 case DISTANCE_REG_THRESHOLD_METHOD_ENUM_FIXED_AMPLITUDE:
468 threshold_method = ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_FIXED_AMPLITUDE;
469 break;
470 case DISTANCE_REG_THRESHOLD_METHOD_ENUM_FIXED_STRENGTH:
471 threshold_method = ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_FIXED_STRENGTH;
472 break;
473 case DISTANCE_REG_THRESHOLD_METHOD_ENUM_RECORDED:
474 threshold_method = ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_RECORDED;
475 break;
476 case DISTANCE_REG_THRESHOLD_METHOD_ENUM_CFAR:
477 threshold_method = ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR;
478 break;
479 default:
480 status = false;
481 break;
482 }
483
484 if (status)
485 {
486 acc_detector_distance_config_threshold_method_set(config, threshold_method);
487 }
488 }
489
490 return status;
491 }
492
493
494 void distance_reg_read_peak_sorting(uint32_t *value)
495 {
496 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
497 acc_detector_distance_peak_sorting_t peak_sorting = acc_detector_distance_config_peak_sorting_get(config);
498 uint32_t peak_sorting_value = 0;
499
500 switch (peak_sorting)
501 {
502 case ACC_DETECTOR_DISTANCE_PEAK_SORTING_CLOSEST:
503 peak_sorting_value = DISTANCE_REG_PEAK_SORTING_ENUM_CLOSEST;
504 break;
505 case ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST:
506 peak_sorting_value = DISTANCE_REG_PEAK_SORTING_ENUM_STRONGEST;
507 break;
508 default:
509 break;
510 }
511
512 *value = peak_sorting_value;
513 }
514
515
516 bool distance_reg_write_peak_sorting(const uint32_t value)
517 {
518 bool status = false;
519 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
520
521 if (config != NULL)
522 {
523 status = true;
524 acc_detector_distance_peak_sorting_t peak_sorting = ACC_DETECTOR_DISTANCE_PEAK_SORTING_CLOSEST;
525
526 switch (value)
527 {
528 case DISTANCE_REG_PEAK_SORTING_ENUM_CLOSEST:
529 peak_sorting = ACC_DETECTOR_DISTANCE_PEAK_SORTING_CLOSEST;
530 break;
531 case DISTANCE_REG_PEAK_SORTING_ENUM_STRONGEST:
532 peak_sorting = ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST;
533 break;
534 default:
535 status = false;
536 break;
537 }
538
539 if (status)
540 {
541 acc_detector_distance_config_peak_sorting_set(config, peak_sorting);
542 }
543 }
544
545 return status;
546 }
547
548
549 void distance_reg_read_num_frames_recorded_threshold(uint32_t *value)
550 {
551 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
552
553 *value = acc_detector_distance_config_num_frames_recorded_threshold_get(config);;
554 }
555
556
557 bool distance_reg_write_num_frames_recorded_threshold(const uint32_t value)
558 {
559 bool status = false;
560 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
561
562 if (config != NULL)
563 {
564 acc_detector_distance_config_num_frames_recorded_threshold_set(config, value);
565 status = true;
566 }
567
568 return status;
569 }
570
571
572 void distance_reg_read_fixed_amplitude_threshold_value(uint32_t *value)
573 {
574 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
575 float fixed_threshold_value = acc_detector_distance_config_fixed_amplitude_threshold_value_get(config);
576
577 *value = acc_reg_protocol_float_to_uint32_milli(fixed_threshold_value);
578 }
579
580
581 bool distance_reg_write_fixed_amplitude_threshold_value(const uint32_t value)
582 {
583 bool status = false;
584 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
585
586 if (config != NULL)
587 {
588 float fixed_threshold_value = acc_reg_protocol_uint32_milli_to_float(value);
589 acc_detector_distance_config_fixed_amplitude_threshold_value_set(config, fixed_threshold_value);
590 status = true;
591 }
592
593 return status;
594 }
595
596
597 void distance_reg_read_fixed_strength_threshold_value(uint32_t *value)
598 {
599 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
600 float fixed_threshold_value = acc_detector_distance_config_fixed_strength_threshold_value_get(config);
601
602 *value = acc_reg_protocol_float_to_int32_milli(fixed_threshold_value);
603 }
604
605
606 bool distance_reg_write_fixed_strength_threshold_value(const uint32_t value)
607 {
608 bool status = false;
609 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
610
611 if (config != NULL)
612 {
613 float fixed_threshold_value = acc_reg_protocol_int32_milli_to_float(value);
614 acc_detector_distance_config_fixed_strength_threshold_value_set(config, fixed_threshold_value);
615 status = true;
616 }
617
618 return status;
619 }
620
621
622 void distance_reg_read_threshold_sensitivity(uint32_t *value)
623 {
624 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
625 float threshold_sensitivity = acc_detector_distance_config_threshold_sensitivity_get(config);
626
627 *value = acc_reg_protocol_float_to_uint32_milli(threshold_sensitivity);
628 }
629
630
631 bool distance_reg_write_threshold_sensitivity(const uint32_t value)
632 {
633 bool status = false;
634 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
635
636 if (config != NULL)
637 {
638 float threshold_sensitivity = acc_reg_protocol_uint32_milli_to_float(value);
639 acc_detector_distance_config_threshold_sensitivity_set(config, threshold_sensitivity);
640 status = true;
641 }
642
643 return status;
644 }
645
646
647 void distance_reg_read_reflector_shape(uint32_t *value)
648 {
649 const acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
650 acc_detector_distance_reflector_shape_t reflector_shape = acc_detector_distance_config_reflector_shape_get(config);
651 uint32_t reflector_shape_value = 0;
652
653 switch (reflector_shape)
654 {
655 case ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC:
656 reflector_shape_value = DISTANCE_REG_REFLECTOR_SHAPE_ENUM_GENERIC;
657 break;
658 case ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR:
659 reflector_shape_value = DISTANCE_REG_REFLECTOR_SHAPE_ENUM_PLANAR;
660 break;
661 default:
662 break;
663 }
664
665 *value = reflector_shape_value;
666 }
667
668
669 bool distance_reg_write_reflector_shape(const uint32_t value)
670 {
671 bool status = false;
672 acc_detector_distance_config_t *config = i2c_distance_detector_get_config();
673
674 if (config != NULL)
675 {
676 status = true;
677 acc_detector_distance_reflector_shape_t reflector_shape = ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC;
678
679 switch (value)
680 {
681 case DISTANCE_REG_REFLECTOR_SHAPE_ENUM_GENERIC:
682 reflector_shape = ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC;
683 break;
684 case DISTANCE_REG_REFLECTOR_SHAPE_ENUM_PLANAR:
685 reflector_shape = ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR;
686 break;
687 default:
688 status = false;
689 break;
690 }
691
692 if (status)
693 {
694 acc_detector_distance_config_reflector_shape_set(config, reflector_shape);
695 }
696 }
697
698 return status;
699 }
700
701
702 void distance_reg_read_measure_on_wakeup(uint32_t *value)
703 {
704 if (i2c_distance_detector_get_measure_on_wakeup())
705 {
706 *value = 1;
707 }
708 else
709 {
710 *value = 0;
711 }
712 }
713
714
715 bool distance_reg_write_measure_on_wakeup(const uint32_t value)
716 {
717 bool enable = (value != 0);
718
719 i2c_distance_detector_measure_on_wakeup(enable);
720
721 return true;
722 }
723
724
725 bool distance_reg_write_command(const uint32_t value)
726 {
727 return i2c_distance_detector_command(value);
728 }
729
730
731 //
732 // PRIVATE HELPER FUNCTIONS
733 //
734
735
736 static uint32_t get_protocol_error_flags(void)
737 {
738 /* Make sure we do not have a race for error flags */
739 acc_integration_critical_section_enter();
740
741 uint32_t error_flags = acc_reg_protocol_get_error_flags();
742
743 acc_integration_critical_section_exit();
744
745 return error_flags;
746 }
747
748
749 static uint32_t get_peak_distance(uint16_t peak_id)
750 {
751 float distance = i2c_distance_detector_get_peak_distance(peak_id);
752
753 return acc_reg_protocol_float_to_uint32_milli(distance);
754 }
755
756
757 static uint32_t get_peak_strength(uint16_t peak_id)
758 {
759 float strength = i2c_distance_detector_get_peak_strength(peak_id);
760
761 return acc_reg_protocol_float_to_int32_milli(strength);
762 }
distance_reg_read_reflector_shape
void distance_reg_read_reflector_shape(uint32_t *value)
Definition: distance_reg_protocol_access.c:647
distance_reg_read_peak9_distance
void distance_reg_read_peak9_distance(uint32_t *value)
Definition: distance_reg_protocol_access.c:167
ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC
@ ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC
Definition: acc_detector_distance_definitions.h:42
acc_detector_distance_config_fixed_amplitude_threshold_value_get
float acc_detector_distance_config_fixed_amplitude_threshold_value_get(const acc_detector_distance_config_t *config)
Get fixed amplitude threshold value.
acc_reg_protocol_float_to_uint32_milli
uint32_t acc_reg_protocol_float_to_uint32_milli(float value)
Convert 1000 * float to uint32.
Definition: acc_reg_protocol.c:336
DISTANCE_REG_PROTOCOL_STATUS_FIELD_WRITE_TO_READ_ONLY_MASK
#define DISTANCE_REG_PROTOCOL_STATUS_FIELD_WRITE_TO_READ_ONLY_MASK
Definition: distance_reg_protocol.h:73
acc_detector_distance_config_peak_sorting_set
void acc_detector_distance_config_peak_sorting_set(acc_detector_distance_config_t *config, acc_detector_distance_peak_sorting_t peak_sorting)
Set the peak sorting method.
distance_reg_read_peak0_strength
void distance_reg_read_peak0_strength(uint32_t *value)
Definition: distance_reg_protocol_access.c:173
distance_reg_read_peak7_distance
void distance_reg_read_peak7_distance(uint32_t *value)
Definition: distance_reg_protocol_access.c:155
distance_reg_write_fixed_strength_threshold_value
bool distance_reg_write_fixed_strength_threshold_value(const uint32_t value)
Definition: distance_reg_protocol_access.c:606
DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE1
#define DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE1
Definition: distance_reg_protocol.h:134
acc_detector_distance_config_close_range_leakage_cancellation_get
bool acc_detector_distance_config_close_range_leakage_cancellation_get(const acc_detector_distance_config_t *config)
Get if the close range leakage cancellation logic is enabled.
acc_reg_protocol_get_error_flags
uint32_t acc_reg_protocol_get_error_flags(void)
Get the error flags for the register protocol.
Definition: acc_reg_protocol.c:319
ACC_REG_ERROR_FLAG_PACKET_LENGTH_ERROR
#define ACC_REG_ERROR_FLAG_PACKET_LENGTH_ERROR
Definition: acc_reg_protocol.h:15
distance_reg_read_end
void distance_reg_read_end(uint32_t *value)
Definition: distance_reg_protocol_access.c:258
DISTANCE_REG_THRESHOLD_METHOD_ENUM_FIXED_AMPLITUDE
#define DISTANCE_REG_THRESHOLD_METHOD_ENUM_FIXED_AMPLITUDE
Definition: distance_reg_protocol.h:141
acc_config_profile_t
acc_config_profile_t
Profile.
Definition: acc_definitions_a121.h:39
distance_reg_read_distance_result
void distance_reg_read_distance_result(uint32_t *value)
Definition: distance_reg_protocol_access.c:107
acc_version.h
distance_reg_read_num_frames_recorded_threshold
void distance_reg_read_num_frames_recorded_threshold(uint32_t *value)
Definition: distance_reg_protocol_access.c:549
ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST
@ ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST
Definition: acc_detector_distance_definitions.h:16
distance_reg_write_close_range_leakage_cancellation
bool distance_reg_write_close_range_leakage_cancellation(const uint32_t value)
Definition: distance_reg_protocol_access.c:314
distance_reg_read_peak9_strength
void distance_reg_read_peak9_strength(uint32_t *value)
Definition: distance_reg_protocol_access.c:227
DISTANCE_REG_THRESHOLD_METHOD_ENUM_FIXED_STRENGTH
#define DISTANCE_REG_THRESHOLD_METHOD_ENUM_FIXED_STRENGTH
Definition: distance_reg_protocol.h:144
distance_reg_read_peak5_distance
void distance_reg_read_peak5_distance(uint32_t *value)
Definition: distance_reg_protocol_access.c:143
ACC_REG_ERROR_FLAG_ADDRESS_ERROR
#define ACC_REG_ERROR_FLAG_ADDRESS_ERROR
Definition: acc_reg_protocol.h:16
acc_detector_distance_config_threshold_method_set
void acc_detector_distance_config_threshold_method_set(acc_detector_distance_config_t *config, acc_detector_distance_threshold_method_t threshold_method)
Set the threshold method.
distance_reg_read_peak2_strength
void distance_reg_read_peak2_strength(uint32_t *value)
Definition: distance_reg_protocol_access.c:185
distance_reg_read_measure_on_wakeup
void distance_reg_read_measure_on_wakeup(uint32_t *value)
Definition: distance_reg_protocol_access.c:702
distance_reg_read_max_profile
void distance_reg_read_max_profile(uint32_t *value)
Definition: distance_reg_protocol_access.c:354
acc_detector_distance_config_start_set
void acc_detector_distance_config_start_set(acc_detector_distance_config_t *config, float start_m)
Set the start of measured interval in meters.
acc_detector_distance_config_fixed_amplitude_threshold_value_set
void acc_detector_distance_config_fixed_amplitude_threshold_value_set(acc_detector_distance_config_t *config, float fixed_threshold_value)
Set fixed amplitude threshold value.
acc_detector_distance_peak_sorting_t
acc_detector_distance_peak_sorting_t
Enum for peak sorting algorithms.
Definition: acc_detector_distance_definitions.h:11
acc_integration_critical_section_exit
void acc_integration_critical_section_exit(void)
Definition: acc_integration_cortex.c:18
distance_reg_read_peak3_distance
void distance_reg_read_peak3_distance(uint32_t *value)
Definition: distance_reg_protocol_access.c:131
acc_detector_distance_config_peak_sorting_get
acc_detector_distance_peak_sorting_t acc_detector_distance_config_peak_sorting_get(const acc_detector_distance_config_t *config)
Get the peak sorting method.
distance_reg_write_peak_sorting
bool distance_reg_write_peak_sorting(const uint32_t value)
Definition: distance_reg_protocol_access.c:516
acc_detector_distance_config_num_frames_recorded_threshold_get
uint16_t acc_detector_distance_config_num_frames_recorded_threshold_get(const acc_detector_distance_config_t *config)
Get the number of frames to use for recorded threshold.
distance_reg_protocol.h
distance_reg_read_max_step_length
void distance_reg_read_max_step_length(uint32_t *value)
Definition: distance_reg_protocol_access.c:283
distance_reg_read_peak6_strength
void distance_reg_read_peak6_strength(uint32_t *value)
Definition: distance_reg_protocol_access.c:209
acc_integration.h
distance_reg_write_start
bool distance_reg_write_start(const uint32_t value)
Definition: distance_reg_protocol_access.c:242
acc_detector_distance_config_threshold_sensitivity_get
float acc_detector_distance_config_threshold_sensitivity_get(const acc_detector_distance_config_t *config)
Get threshold sensitivity.
acc_version_get_hex
uint32_t acc_version_get_hex(void)
Get the version of the Acconeer software as a hex number.
ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR
@ ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR
Definition: acc_detector_distance_definitions.h:32
ACC_CONFIG_PROFILE_4
@ ACC_CONFIG_PROFILE_4
Definition: acc_definitions_a121.h:45
i2c_distance_detector_get_measure_on_wakeup
bool i2c_distance_detector_get_measure_on_wakeup(void)
Get measure on wake up state.
Definition: i2c_distance_detector.c:301
distance_reg_read_peak4_strength
void distance_reg_read_peak4_strength(uint32_t *value)
Definition: distance_reg_protocol_access.c:197
DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE3
#define DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE3
Definition: distance_reg_protocol.h:136
distance_reg_read_detector_status
void distance_reg_read_detector_status(uint32_t *value)
Definition: distance_reg_protocol_access.c:101
distance_reg_write_max_profile
bool distance_reg_write_max_profile(const uint32_t value)
Definition: distance_reg_protocol_access.c:385
ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_RECORDED
@ ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_RECORDED
Definition: acc_detector_distance_definitions.h:30
distance_reg_read_peak8_distance
void distance_reg_read_peak8_distance(uint32_t *value)
Definition: distance_reg_protocol_access.c:161
acc_detector_distance_config_max_step_length_get
uint16_t acc_detector_distance_config_max_step_length_get(const acc_detector_distance_config_t *config)
Get the maximum step length.
DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE4
#define DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE4
Definition: distance_reg_protocol.h:137
ACC_REG_ERROR_FLAG_WRITE_FAILED
#define ACC_REG_ERROR_FLAG_WRITE_FAILED
Definition: acc_reg_protocol.h:17
i2c_distance_detector_get_status
uint32_t i2c_distance_detector_get_status(void)
Get distance detector status.
Definition: i2c_distance_detector.c:203
acc_detector_distance_config_close_range_leakage_cancellation_set
void acc_detector_distance_config_close_range_leakage_cancellation_set(acc_detector_distance_config_t *config, bool enable)
Enable the close range leakage cancellation logic.
distance_reg_write_command
bool distance_reg_write_command(const uint32_t value)
Definition: distance_reg_protocol_access.c:725
acc_detector_distance_config_end_get
float acc_detector_distance_config_end_get(const acc_detector_distance_config_t *config)
Get the end of measured interval in meters.
distance_reg_read_fixed_strength_threshold_value
void distance_reg_read_fixed_strength_threshold_value(uint32_t *value)
Definition: distance_reg_protocol_access.c:597
distance_reg_write_max_step_length
bool distance_reg_write_max_step_length(const uint32_t value)
Definition: distance_reg_protocol_access.c:291
distance_reg_read_peak1_strength
void distance_reg_read_peak1_strength(uint32_t *value)
Definition: distance_reg_protocol_access.c:179
acc_detector_distance_config_max_profile_set
void acc_detector_distance_config_max_profile_set(acc_detector_distance_config_t *config, acc_config_profile_t max_profile)
Set the max profile.
acc_detector_distance_config_max_profile_get
acc_config_profile_t acc_detector_distance_config_max_profile_get(const acc_detector_distance_config_t *config)
Get the max profile.
ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_FIXED_STRENGTH
@ ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_FIXED_STRENGTH
Definition: acc_detector_distance_definitions.h:28
DISTANCE_REG_PROTOCOL_STATUS_FIELD_ADDRESS_ERROR_MASK
#define DISTANCE_REG_PROTOCOL_STATUS_FIELD_ADDRESS_ERROR_MASK
Definition: distance_reg_protocol.h:69
i2c_distance_detector_get_result
uint32_t i2c_distance_detector_get_result(void)
Get distance detector result.
Definition: i2c_distance_detector.c:216
i2c_distance_detector.h
get_protocol_error_flags
static uint32_t get_protocol_error_flags(void)
Get the protocol error status flags.
Definition: distance_reg_protocol_access.c:736
distance_reg_read_signal_quality
void distance_reg_read_signal_quality(uint32_t *value)
Definition: distance_reg_protocol_access.c:329
distance_reg_write_measure_on_wakeup
bool distance_reg_write_measure_on_wakeup(const uint32_t value)
Definition: distance_reg_protocol_access.c:715
get_peak_distance
static uint32_t get_peak_distance(uint16_t peak_id)
Get peak distance.
Definition: distance_reg_protocol_access.c:749
i2c_distance_detector_get_peak_distance
float i2c_distance_detector_get_peak_distance(uint16_t peak_id)
Get the peak distance for a specific peak id.
Definition: i2c_distance_detector.c:264
acc_detector_distance_config_signal_quality_set
void acc_detector_distance_config_signal_quality_set(acc_detector_distance_config_t *config, float signal_quality)
Set the signal quality.
DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE5
#define DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE5
Definition: distance_reg_protocol.h:138
ACC_CONFIG_PROFILE_5
@ ACC_CONFIG_PROFILE_5
Definition: acc_definitions_a121.h:47
i2c_distance_detector_get_counter
uint32_t i2c_distance_detector_get_counter(void)
Get distance detector measure counter.
Definition: i2c_distance_detector.c:251
DISTANCE_REG_PEAK_SORTING_ENUM_CLOSEST
#define DISTANCE_REG_PEAK_SORTING_ENUM_CLOSEST
Definition: distance_reg_protocol.h:147
DISTANCE_REG_THRESHOLD_METHOD_ENUM_CFAR
#define DISTANCE_REG_THRESHOLD_METHOD_ENUM_CFAR
Definition: distance_reg_protocol.h:143
acc_reg_protocol_float_to_int32_milli
int32_t acc_reg_protocol_float_to_int32_milli(float value)
Convert 1000 * float to int32.
Definition: acc_reg_protocol.c:330
distance_reg_read_protocol_status
void distance_reg_read_protocol_status(uint32_t *value)
Definition: distance_reg_protocol_access.c:61
distance_reg_read_threshold_method
void distance_reg_read_threshold_method(uint32_t *value)
Definition: distance_reg_protocol_access.c:427
distance_reg_read_version
void distance_reg_read_version(uint32_t *value)
Definition: distance_reg_protocol_access.c:55
distance_reg_write_num_frames_recorded_threshold
bool distance_reg_write_num_frames_recorded_threshold(const uint32_t value)
Definition: distance_reg_protocol_access.c:557
distance_reg_read_start
void distance_reg_read_start(uint32_t *value)
Definition: distance_reg_protocol_access.c:233
acc_reg_protocol_uint32_milli_to_float
float acc_reg_protocol_uint32_milli_to_float(uint32_t value)
Convert uint32 / 1000 to float.
Definition: acc_reg_protocol.c:351
acc_detector_distance_config_fixed_strength_threshold_value_get
float acc_detector_distance_config_fixed_strength_threshold_value_get(const acc_detector_distance_config_t *config)
Get fixed strength threshold value.
distance_reg_read_peak0_distance
void distance_reg_read_peak0_distance(uint32_t *value)
Definition: distance_reg_protocol_access.c:113
distance_reg_read_peak5_strength
void distance_reg_read_peak5_strength(uint32_t *value)
Definition: distance_reg_protocol_access.c:203
i2c_distance_detector_get_config
acc_detector_distance_config_t * i2c_distance_detector_get_config(void)
Get distance detector configuration handle.
Definition: i2c_distance_detector.c:174
ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_FIXED_AMPLITUDE
@ ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_FIXED_AMPLITUDE
Definition: acc_detector_distance_definitions.h:26
distance_reg_read_peak4_distance
void distance_reg_read_peak4_distance(uint32_t *value)
Definition: distance_reg_protocol_access.c:137
DISTANCE_REG_REFLECTOR_SHAPE_ENUM_GENERIC
#define DISTANCE_REG_REFLECTOR_SHAPE_ENUM_GENERIC
Definition: distance_reg_protocol.h:151
acc_reg_protocol_int32_milli_to_float
float acc_reg_protocol_int32_milli_to_float(int32_t value)
Convert int32 / 1000 to float.
Definition: acc_reg_protocol.c:342
ACC_REG_ERROR_FLAG_PROTOCOL_STATE_ERROR
#define ACC_REG_ERROR_FLAG_PROTOCOL_STATE_ERROR
Definition: acc_reg_protocol.h:14
DISTANCE_REG_PROTOCOL_STATUS_FIELD_PACKET_LENGTH_ERROR_MASK
#define DISTANCE_REG_PROTOCOL_STATUS_FIELD_PACKET_LENGTH_ERROR_MASK
Definition: distance_reg_protocol.h:67
acc_detector_distance_config_end_set
void acc_detector_distance_config_end_set(acc_detector_distance_config_t *config, float end_m)
Set the end of measured interval in meters.
DISTANCE_REG_PROTOCOL_STATUS_FIELD_PROTOCOL_STATE_ERROR_MASK
#define DISTANCE_REG_PROTOCOL_STATUS_FIELD_PROTOCOL_STATE_ERROR_MASK
Definition: distance_reg_protocol.h:65
acc_detector_distance_config_num_frames_recorded_threshold_set
void acc_detector_distance_config_num_frames_recorded_threshold_set(acc_detector_distance_config_t *config, uint16_t num_frames)
Set the number frames to use for recorded threshold.
distance_reg_write_threshold_method
bool distance_reg_write_threshold_method(const uint32_t value)
Definition: distance_reg_protocol_access.c:455
distance_reg_read_peak1_distance
void distance_reg_read_peak1_distance(uint32_t *value)
Definition: distance_reg_protocol_access.c:119
acc_detector_distance_definitions.h
distance_reg_write_signal_quality
bool distance_reg_write_signal_quality(const uint32_t value)
Definition: distance_reg_protocol_access.c:338
acc_detector_distance_reflector_shape_t
acc_detector_distance_reflector_shape_t
Enum for reflector shapes.
Definition: acc_detector_distance_definitions.h:39
ACC_REG_ERROR_FLAG_WRITE_TO_READ_ONLY
#define ACC_REG_ERROR_FLAG_WRITE_TO_READ_ONLY
Definition: acc_reg_protocol.h:18
distance_reg_read_peak8_strength
void distance_reg_read_peak8_strength(uint32_t *value)
Definition: distance_reg_protocol_access.c:221
distance_reg_read_peak2_distance
void distance_reg_read_peak2_distance(uint32_t *value)
Definition: distance_reg_protocol_access.c:125
acc_reg_protocol.h
DISTANCE_REG_PEAK_SORTING_ENUM_STRONGEST
#define DISTANCE_REG_PEAK_SORTING_ENUM_STRONGEST
Definition: distance_reg_protocol.h:148
acc_detector_distance_config_signal_quality_get
float acc_detector_distance_config_signal_quality_get(const acc_detector_distance_config_t *config)
Get the signal quality.
acc_detector_distance_threshold_method_t
acc_detector_distance_threshold_method_t
Enum for threshold methods.
Definition: acc_detector_distance_definitions.h:23
distance_reg_write_reflector_shape
bool distance_reg_write_reflector_shape(const uint32_t value)
Definition: distance_reg_protocol_access.c:669
DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE2
#define DISTANCE_REG_MAX_PROFILE_ENUM_PROFILE2
Definition: distance_reg_protocol.h:135
acc_integration_critical_section_enter
void acc_integration_critical_section_enter(void)
Definition: acc_integration_cortex.c:10
acc_detector_distance_config_threshold_method_get
acc_detector_distance_threshold_method_t acc_detector_distance_config_threshold_method_get(const acc_detector_distance_config_t *config)
Get the threshold method.
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_reg_read_measure_counter
void distance_reg_read_measure_counter(uint32_t *value)
Definition: distance_reg_protocol_access.c:95
ACC_CONFIG_PROFILE_2
@ ACC_CONFIG_PROFILE_2
Definition: acc_definitions_a121.h:43
DISTANCE_REG_PROTOCOL_STATUS_FIELD_WRITE_FAILED_MASK
#define DISTANCE_REG_PROTOCOL_STATUS_FIELD_WRITE_FAILED_MASK
Definition: distance_reg_protocol.h:71
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.
distance_reg_read_threshold_sensitivity
void distance_reg_read_threshold_sensitivity(uint32_t *value)
Definition: distance_reg_protocol_access.c:622
acc_detector_distance_config_fixed_strength_threshold_value_set
void acc_detector_distance_config_fixed_strength_threshold_value_set(acc_detector_distance_config_t *config, float fixed_threshold_value)
Set fixed strength threshold value.
i2c_distance_detector_measure_on_wakeup
void i2c_distance_detector_measure_on_wakeup(bool enable)
Enable/Disable measure on wake up.
Definition: i2c_distance_detector.c:290
acc_detector_distance_config_start_get
float acc_detector_distance_config_start_get(const acc_detector_distance_config_t *config)
Get the start of measured interval in meters.
acc_detector_distance.h
ACC_DETECTOR_DISTANCE_PEAK_SORTING_CLOSEST
@ ACC_DETECTOR_DISTANCE_PEAK_SORTING_CLOSEST
Definition: acc_detector_distance_definitions.h:14
distance_reg_read_peak_sorting
void distance_reg_read_peak_sorting(uint32_t *value)
Definition: distance_reg_protocol_access.c:494
i2c_distance_detector_command
bool i2c_distance_detector_command(uint32_t command)
Send command to be executed to i2c distance detector.
Definition: i2c_distance_detector.c:180
i2c_distance_detector_get_peak_strength
float i2c_distance_detector_get_peak_strength(uint16_t peak_id)
Get the peak strength for a specific peak id.
Definition: i2c_distance_detector.c:277
ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR
@ ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR
Definition: acc_detector_distance_definitions.h:44
distance_reg_write_threshold_sensitivity
bool distance_reg_write_threshold_sensitivity(const uint32_t value)
Definition: distance_reg_protocol_access.c:631
distance_reg_read_peak7_strength
void distance_reg_read_peak7_strength(uint32_t *value)
Definition: distance_reg_protocol_access.c:215
ACC_CONFIG_PROFILE_3
@ ACC_CONFIG_PROFILE_3
Definition: acc_definitions_a121.h:44
acc_detector_distance_config_t
struct acc_detector_distance_config acc_detector_distance_config_t
Definition: acc_detector_distance.h:43
ACC_CONFIG_PROFILE_1
@ ACC_CONFIG_PROFILE_1
Definition: acc_definitions_a121.h:42
acc_detector_distance_config_max_step_length_set
void acc_detector_distance_config_max_step_length_set(acc_detector_distance_config_t *config, uint16_t max_step_length)
Set the maximum step length.
distance_reg_write_fixed_amplitude_threshold_value
bool distance_reg_write_fixed_amplitude_threshold_value(const uint32_t value)
Definition: distance_reg_protocol_access.c:581
distance_reg_write_end
bool distance_reg_write_end(const uint32_t value)
Definition: distance_reg_protocol_access.c:267
DISTANCE_REG_THRESHOLD_METHOD_ENUM_RECORDED
#define DISTANCE_REG_THRESHOLD_METHOD_ENUM_RECORDED
Definition: distance_reg_protocol.h:142
distance_reg_read_peak6_distance
void distance_reg_read_peak6_distance(uint32_t *value)
Definition: distance_reg_protocol_access.c:149
get_peak_strength
static uint32_t get_peak_strength(uint16_t peak_id)
Get peak strength.
Definition: distance_reg_protocol_access.c:757
distance_reg_read_fixed_amplitude_threshold_value
void distance_reg_read_fixed_amplitude_threshold_value(uint32_t *value)
Definition: distance_reg_protocol_access.c:572
acc_detector_distance_config_reflector_shape_get
acc_detector_distance_reflector_shape_t acc_detector_distance_config_reflector_shape_get(const acc_detector_distance_config_t *config)
Get reflector shape.
distance_reg_read_peak3_strength
void distance_reg_read_peak3_strength(uint32_t *value)
Definition: distance_reg_protocol_access.c:191
DISTANCE_REG_REFLECTOR_SHAPE_ENUM_PLANAR
#define DISTANCE_REG_REFLECTOR_SHAPE_ENUM_PLANAR
Definition: distance_reg_protocol.h:152
distance_reg_read_close_range_leakage_cancellation
void distance_reg_read_close_range_leakage_cancellation(uint32_t *value)
Definition: distance_reg_protocol_access.c:306