example_cargo_reg_protocol.c
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 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 <stddef.h>
9 #include <stdint.h>
10
11 #include "acc_reg_protocol.h"
12 #include "example_cargo_reg_protocol.h"
13
14
15 /**
16 * This struct defines the links between a register address and the register read and/or write function.
17 */
18 const acc_reg_protocol_t example_cargo_reg_protocol[EXAMPLE_CARGO_REG_REGISTER_COUNT] = {
19 {
20 EXAMPLE_CARGO_REG_VERSION_ADDRESS, // version address
21 example_cargo_reg_read_version, // version read access function
22 NULL,
23 },
24 {
25 EXAMPLE_CARGO_REG_PROTOCOL_STATUS_ADDRESS, // protocol_status address
26 example_cargo_reg_read_protocol_status, // protocol_status read access function
27 NULL,
28 },
29 {
30 EXAMPLE_CARGO_REG_MEASURE_COUNTER_ADDRESS, // measure_counter address
31 example_cargo_reg_read_measure_counter, // measure_counter read access function
32 NULL,
33 },
34 {
35 EXAMPLE_CARGO_REG_ACTUAL_PRESENCE_UPDATE_RATE_ADDRESS, // actual_presence_update_rate address
36 example_cargo_reg_read_actual_presence_update_rate, // actual_presence_update_rate read access function
37 NULL,
38 },
39 {
40 EXAMPLE_CARGO_REG_APPLICATION_STATUS_ADDRESS, // application_status address
41 example_cargo_reg_read_application_status, // application_status read access function
42 NULL,
43 },
44 {
45 EXAMPLE_CARGO_REG_CONTAINER_SIZE_ADDRESS, // container_size address
46 example_cargo_reg_read_container_size, // container_size read access function
47 example_cargo_reg_write_container_size, // container_size write access function
48 },
49 {
50 EXAMPLE_CARGO_REG_ACTIVATE_UTILIZATION_LEVEL_ADDRESS, // activate_utilization_level address
51 example_cargo_reg_read_activate_utilization_level, // activate_utilization_level read access function
52 example_cargo_reg_write_activate_utilization_level, // activate_utilization_level write access function
53 },
54 {
55 EXAMPLE_CARGO_REG_UTILIZATION_SIGNAL_QUALITY_ADDRESS, // utilization_signal_quality address
56 example_cargo_reg_read_utilization_signal_quality, // utilization_signal_quality read access function
57 example_cargo_reg_write_utilization_signal_quality, // utilization_signal_quality write access function
58 },
59 {
60 EXAMPLE_CARGO_REG_UTILIZATION_THRESHOLD_SENSITIVITY_ADDRESS, // utilization_threshold_sensitivity address
61 example_cargo_reg_read_utilization_threshold_sensitivity, // utilization_threshold_sensitivity read access function
62 example_cargo_reg_write_utilization_threshold_sensitivity, // utilization_threshold_sensitivity write access function
63 },
64 {
65 EXAMPLE_CARGO_REG_ACTIVATE_PRESENCE_ADDRESS, // activate_presence address
66 example_cargo_reg_read_activate_presence, // activate_presence read access function
67 example_cargo_reg_write_activate_presence, // activate_presence write access function
68 },
69 {
70 EXAMPLE_CARGO_REG_PRESENCE_UPDATE_RATE_ADDRESS, // presence_update_rate address
71 example_cargo_reg_read_presence_update_rate, // presence_update_rate read access function
72 example_cargo_reg_write_presence_update_rate, // presence_update_rate write access function
73 },
74 {
75 EXAMPLE_CARGO_REG_PRESENCE_SWEEPS_PER_FRAME_ADDRESS, // presence_sweeps_per_frame address
76 example_cargo_reg_read_presence_sweeps_per_frame, // presence_sweeps_per_frame read access function
77 example_cargo_reg_write_presence_sweeps_per_frame, // presence_sweeps_per_frame write access function
78 },
79 {
80 EXAMPLE_CARGO_REG_PRESENCE_SIGNAL_QUALITY_ADDRESS, // presence_signal_quality address
81 example_cargo_reg_read_presence_signal_quality, // presence_signal_quality read access function
82 example_cargo_reg_write_presence_signal_quality, // presence_signal_quality write access function
83 },
84 {
85 EXAMPLE_CARGO_REG_PRESENCE_INTER_DETECTION_THRESHOLD_ADDRESS, // presence_inter_detection_threshold address
86 example_cargo_reg_read_presence_inter_detection_threshold, // presence_inter_detection_threshold read access function
87 example_cargo_reg_write_presence_inter_detection_threshold, // presence_inter_detection_threshold write access function
88 },
89 {
90 EXAMPLE_CARGO_REG_PRESENCE_INTRA_DETECTION_THRESHOLD_ADDRESS, // presence_intra_detection_threshold address
91 example_cargo_reg_read_presence_intra_detection_threshold, // presence_intra_detection_threshold read access function
92 example_cargo_reg_write_presence_intra_detection_threshold, // presence_intra_detection_threshold write access function
93 },
94 {
95 EXAMPLE_CARGO_REG_RESULT_HEADER_ADDRESS, // result_header address
96 example_cargo_reg_read_result_header, // result_header read access function
97 NULL,
98 },
99 {
100 EXAMPLE_CARGO_REG_UTILIZATION_DISTANCE_ADDRESS, // utilization_distance address
101 example_cargo_reg_read_utilization_distance, // utilization_distance read access function
102 NULL,
103 },
104 {
105 EXAMPLE_CARGO_REG_UTILIZATION_LEVEL_MM_ADDRESS, // utilization_level_mm address
106 example_cargo_reg_read_utilization_level_mm, // utilization_level_mm read access function
107 NULL,
108 },
109 {
110 EXAMPLE_CARGO_REG_UTILIZATION_LEVEL_PERCENT_ADDRESS, // utilization_level_percent address
111 example_cargo_reg_read_utilization_level_percent, // utilization_level_percent read access function
112 NULL,
113 },
114 {
115 EXAMPLE_CARGO_REG_PRESENCE_DETECTED_ADDRESS, // presence_detected address
116 example_cargo_reg_read_presence_detected, // presence_detected read access function
117 NULL,
118 },
119 {
120 EXAMPLE_CARGO_REG_MAX_INTER_PRESENCE_SCORE_ADDRESS, // max_inter_presence_score address
121 example_cargo_reg_read_max_inter_presence_score, // max_inter_presence_score read access function
122 NULL,
123 },
124 {
125 EXAMPLE_CARGO_REG_MAX_INTRA_PRESENCE_SCORE_ADDRESS, // max_intra_presence_score address
126 example_cargo_reg_read_max_intra_presence_score, // max_intra_presence_score read access function
127 NULL,
128 },
129 {
130 EXAMPLE_CARGO_REG_COMMAND_ADDRESS, // command address
131 NULL,
132 example_cargo_reg_write_command, // command write access function
133 },
134 {
135 EXAMPLE_CARGO_REG_APPLICATION_ID_ADDRESS, // application_id address
136 example_cargo_reg_read_application_id, // application_id read access function
137 NULL,
138 },
139 };
140
141
142 void example_cargo_reg_protocol_setup(void)
143 {
144 acc_reg_protocol_setup(example_cargo_reg_protocol, EXAMPLE_CARGO_REG_REGISTER_COUNT);
145 }
146
147
148 void example_cargo_reg_protocol_write_default(void)
149 {
150 }
EXAMPLE_CARGO_REG_UTILIZATION_SIGNAL_QUALITY_ADDRESS
#define EXAMPLE_CARGO_REG_UTILIZATION_SIGNAL_QUALITY_ADDRESS
Definition: example_cargo_reg_protocol.h:21
EXAMPLE_CARGO_REG_MEASURE_COUNTER_ADDRESS
#define EXAMPLE_CARGO_REG_MEASURE_COUNTER_ADDRESS
Definition: example_cargo_reg_protocol.h:16
example_cargo_reg_read_protocol_status
void example_cargo_reg_read_protocol_status(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:39
example_cargo_reg_write_presence_inter_detection_threshold
bool example_cargo_reg_write_presence_inter_detection_threshold(const uint32_t value)
Definition: example_cargo_reg_protocol_access.c:256
example_cargo_reg_read_utilization_level_mm
void example_cargo_reg_read_utilization_level_mm(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:312
EXAMPLE_CARGO_REG_UTILIZATION_DISTANCE_ADDRESS
#define EXAMPLE_CARGO_REG_UTILIZATION_DISTANCE_ADDRESS
Definition: example_cargo_reg_protocol.h:30
example_cargo_reg_read_presence_intra_detection_threshold
void example_cargo_reg_read_presence_intra_detection_threshold(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:265
EXAMPLE_CARGO_REG_ACTUAL_PRESENCE_UPDATE_RATE_ADDRESS
#define EXAMPLE_CARGO_REG_ACTUAL_PRESENCE_UPDATE_RATE_ADDRESS
Definition: example_cargo_reg_protocol.h:17
EXAMPLE_CARGO_REG_PROTOCOL_STATUS_ADDRESS
#define EXAMPLE_CARGO_REG_PROTOCOL_STATUS_ADDRESS
Definition: example_cargo_reg_protocol.h:15
example_cargo_reg_read_presence_update_rate
void example_cargo_reg_read_presence_update_rate(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:201
example_cargo_reg_read_actual_presence_update_rate
void example_cargo_reg_read_actual_presence_update_rate(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:77
EXAMPLE_CARGO_REG_MAX_INTER_PRESENCE_SCORE_ADDRESS
#define EXAMPLE_CARGO_REG_MAX_INTER_PRESENCE_SCORE_ADDRESS
Definition: example_cargo_reg_protocol.h:34
EXAMPLE_CARGO_REG_PRESENCE_DETECTED_ADDRESS
#define EXAMPLE_CARGO_REG_PRESENCE_DETECTED_ADDRESS
Definition: example_cargo_reg_protocol.h:33
EXAMPLE_CARGO_REG_COMMAND_ADDRESS
#define EXAMPLE_CARGO_REG_COMMAND_ADDRESS
Definition: example_cargo_reg_protocol.h:36
example_cargo_reg_write_utilization_signal_quality
bool example_cargo_reg_write_utilization_signal_quality(const uint32_t value)
Definition: example_cargo_reg_protocol_access.c:160
EXAMPLE_CARGO_REG_PRESENCE_INTER_DETECTION_THRESHOLD_ADDRESS
#define EXAMPLE_CARGO_REG_PRESENCE_INTER_DETECTION_THRESHOLD_ADDRESS
Definition: example_cargo_reg_protocol.h:27
example_cargo_reg_read_activate_presence
void example_cargo_reg_read_activate_presence(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:185
example_cargo_reg_read_container_size
void example_cargo_reg_read_container_size(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:92
EXAMPLE_CARGO_REG_APPLICATION_STATUS_ADDRESS
#define EXAMPLE_CARGO_REG_APPLICATION_STATUS_ADDRESS
Definition: example_cargo_reg_protocol.h:18
example_cargo_reg_write_presence_signal_quality
bool example_cargo_reg_write_presence_signal_quality(const uint32_t value)
Definition: example_cargo_reg_protocol_access.c:240
example_cargo_reg_read_utilization_signal_quality
void example_cargo_reg_read_utilization_signal_quality(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:153
acc_reg_protocol_setup
void acc_reg_protocol_setup(const acc_reg_protocol_t *protocol_struct, uint16_t register_count)
Setup register protocol.
Definition: acc_reg_protocol.c:202
example_cargo_reg_read_application_status
void example_cargo_reg_read_application_status(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:87
example_cargo_reg_write_utilization_threshold_sensitivity
bool example_cargo_reg_write_utilization_threshold_sensitivity(const uint32_t value)
Definition: example_cargo_reg_protocol_access.c:176
example_cargo_reg_protocol_setup
void example_cargo_reg_protocol_setup(void)
Definition: example_cargo_reg_protocol.c:142
example_cargo_reg_read_version
void example_cargo_reg_read_version(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:34
EXAMPLE_CARGO_REG_PRESENCE_SWEEPS_PER_FRAME_ADDRESS
#define EXAMPLE_CARGO_REG_PRESENCE_SWEEPS_PER_FRAME_ADDRESS
Definition: example_cargo_reg_protocol.h:25
example_cargo_reg_read_presence_detected
void example_cargo_reg_read_presence_detected(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:330
EXAMPLE_CARGO_REG_VERSION_ADDRESS
#define EXAMPLE_CARGO_REG_VERSION_ADDRESS
Definition: example_cargo_reg_protocol.h:14
EXAMPLE_CARGO_REG_ACTIVATE_PRESENCE_ADDRESS
#define EXAMPLE_CARGO_REG_ACTIVATE_PRESENCE_ADDRESS
Definition: example_cargo_reg_protocol.h:23
EXAMPLE_CARGO_REG_MAX_INTRA_PRESENCE_SCORE_ADDRESS
#define EXAMPLE_CARGO_REG_MAX_INTRA_PRESENCE_SCORE_ADDRESS
Definition: example_cargo_reg_protocol.h:35
example_cargo_reg_read_result_header
void example_cargo_reg_read_result_header(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:281
EXAMPLE_CARGO_REG_PRESENCE_INTRA_DETECTION_THRESHOLD_ADDRESS
#define EXAMPLE_CARGO_REG_PRESENCE_INTRA_DETECTION_THRESHOLD_ADDRESS
Definition: example_cargo_reg_protocol.h:28
example_cargo_reg_protocol
const acc_reg_protocol_t example_cargo_reg_protocol[EXAMPLE_CARGO_REG_REGISTER_COUNT]
Definition: example_cargo_reg_protocol.c:18
EXAMPLE_CARGO_REG_PRESENCE_UPDATE_RATE_ADDRESS
#define EXAMPLE_CARGO_REG_PRESENCE_UPDATE_RATE_ADDRESS
Definition: example_cargo_reg_protocol.h:24
EXAMPLE_CARGO_REG_CONTAINER_SIZE_ADDRESS
#define EXAMPLE_CARGO_REG_CONTAINER_SIZE_ADDRESS
Definition: example_cargo_reg_protocol.h:19
example_cargo_reg_write_presence_update_rate
bool example_cargo_reg_write_presence_update_rate(const uint32_t value)
Definition: example_cargo_reg_protocol_access.c:208
example_cargo_reg_write_container_size
bool example_cargo_reg_write_container_size(const uint32_t value)
Definition: example_cargo_reg_protocol_access.c:113
example_cargo_reg_read_measure_counter
void example_cargo_reg_read_measure_counter(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:72
example_cargo_reg_write_presence_intra_detection_threshold
bool example_cargo_reg_write_presence_intra_detection_threshold(const uint32_t value)
Definition: example_cargo_reg_protocol_access.c:272
example_cargo_reg_write_activate_presence
bool example_cargo_reg_write_activate_presence(const uint32_t value)
Definition: example_cargo_reg_protocol_access.c:192
example_cargo_reg_write_activate_utilization_level
bool example_cargo_reg_write_activate_utilization_level(const uint32_t value)
Definition: example_cargo_reg_protocol_access.c:144
example_cargo_reg_read_presence_sweeps_per_frame
void example_cargo_reg_read_presence_sweeps_per_frame(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:217
example_cargo_reg_read_max_intra_presence_score
void example_cargo_reg_read_max_intra_presence_score(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:348
example_cargo_reg_read_utilization_level_percent
void example_cargo_reg_read_utilization_level_percent(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:321
EXAMPLE_CARGO_REG_RESULT_HEADER_ADDRESS
#define EXAMPLE_CARGO_REG_RESULT_HEADER_ADDRESS
Definition: example_cargo_reg_protocol.h:29
example_cargo_reg_read_application_id
void example_cargo_reg_read_application_id(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:29
example_cargo_reg_read_presence_inter_detection_threshold
void example_cargo_reg_read_presence_inter_detection_threshold(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:249
example_cargo_reg_read_utilization_distance
void example_cargo_reg_read_utilization_distance(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:303
EXAMPLE_CARGO_REG_UTILIZATION_THRESHOLD_SENSITIVITY_ADDRESS
#define EXAMPLE_CARGO_REG_UTILIZATION_THRESHOLD_SENSITIVITY_ADDRESS
Definition: example_cargo_reg_protocol.h:22
acc_reg_protocol_t
Register access mode and functions struct.
Definition: acc_reg_protocol.h:38
example_cargo_reg_read_max_inter_presence_score
void example_cargo_reg_read_max_inter_presence_score(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:339
example_cargo_reg_read_utilization_threshold_sensitivity
void example_cargo_reg_read_utilization_threshold_sensitivity(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:169
acc_reg_protocol.h
example_cargo_reg_write_command
bool example_cargo_reg_write_command(const uint32_t value)
Definition: example_cargo_reg_protocol_access.c:82
EXAMPLE_CARGO_REG_REGISTER_COUNT
#define EXAMPLE_CARGO_REG_REGISTER_COUNT
Definition: example_cargo_reg_protocol.h:11
EXAMPLE_CARGO_REG_ACTIVATE_UTILIZATION_LEVEL_ADDRESS
#define EXAMPLE_CARGO_REG_ACTIVATE_UTILIZATION_LEVEL_ADDRESS
Definition: example_cargo_reg_protocol.h:20
example_cargo_reg_protocol_write_default
void example_cargo_reg_protocol_write_default(void)
Definition: example_cargo_reg_protocol.c:148
EXAMPLE_CARGO_REG_APPLICATION_ID_ADDRESS
#define EXAMPLE_CARGO_REG_APPLICATION_ID_ADDRESS
Definition: example_cargo_reg_protocol.h:37
EXAMPLE_CARGO_REG_UTILIZATION_LEVEL_MM_ADDRESS
#define EXAMPLE_CARGO_REG_UTILIZATION_LEVEL_MM_ADDRESS
Definition: example_cargo_reg_protocol.h:31
EXAMPLE_CARGO_REG_UTILIZATION_LEVEL_PERCENT_ADDRESS
#define EXAMPLE_CARGO_REG_UTILIZATION_LEVEL_PERCENT_ADDRESS
Definition: example_cargo_reg_protocol.h:32
example_cargo_reg_write_presence_sweeps_per_frame
bool example_cargo_reg_write_presence_sweeps_per_frame(const uint32_t value)
Definition: example_cargo_reg_protocol_access.c:224
example_cargo_reg_protocol.h
example_cargo_reg_read_activate_utilization_level
void example_cargo_reg_read_activate_utilization_level(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:137
example_cargo_reg_read_presence_signal_quality
void example_cargo_reg_read_presence_signal_quality(uint32_t *value)
Definition: example_cargo_reg_protocol_access.c:233
EXAMPLE_CARGO_REG_PRESENCE_SIGNAL_QUALITY_ADDRESS
#define EXAMPLE_CARGO_REG_PRESENCE_SIGNAL_QUALITY_ADDRESS
Definition: example_cargo_reg_protocol.h:26