acc_processing.h
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2020-2023
2 // All rights reserved
3
4 #ifndef ACC_PROCESSING_H_
5 #define ACC_PROCESSING_H_
6
7 #include <stdbool.h>
8 #include <stdint.h>
9
10 #include "acc_config_subsweep.h"
11 #include "acc_definitions_a121.h"
12 #include "acc_definitions_common.h"
13
14
15 /**
16 * @defgroup processing Processing
17 * @ingroup service
18 *
19 * @brief Module to interpret and process data read from sensor
20 *
21 * @{
22 */
23
24
25 /**
26 * @brief Generic processing handle
27 */
28 struct acc_processing_handle;
29
30 typedef struct acc_processing_handle acc_processing_t;
31
32
33 /**
34 * @brief Metadata that will be populated by the processing module during creation
35 */
36 typedef struct
37 {
38 /** Number of elements in the frame */
39 uint16_t frame_data_length;
40 /** Number of elements in the sweep */
41 uint16_t sweep_data_length;
42 /** Offset to the subsweeps data */
43 uint16_t subsweep_data_offset[ACC_MAX_NUM_SUBSWEEPS];
44 /** Number of elements in the subsweeps */
45 uint16_t subsweep_data_length[ACC_MAX_NUM_SUBSWEEPS];
46 /** Maximum sweep rate that the sensor can provide for the given configuration.
47 * Note that this is not the actual exact sweep rate. To obtain an exact rate,
48 * use the sweep rate parameter, @ref acc_config_sweep_rate_set.
49 *
50 * If no max sweep rate is applicable, it's set to 0.0f.
51 */
52 float max_sweep_rate;
53 /** Flag indicating if high speed mode is used.
54 * If true, it means that the sensor has been configured in a way where it
55 * can optimize its measurements and obtain a high max_sweep_rate.
56 *
57 * Configuration limitations to enable high speed mode:
58 *
59 * continuous_sweep_mode false, see @ref acc_config_continuous_sweep_mode_set
60 * inter_sweep_idle_state READY, see @ref acc_config_inter_sweep_idle_state_set
61 * num_subsweeps 1, see @ref acc_config_num_subsweeps_set
62 * profile 3-5, see @ref acc_config_profile_set
63 */
64 bool high_speed_mode;
65 } acc_processing_metadata_t;
66
67
68 /**
69 * @brief Result provided by the processing module
70 */
71 typedef struct
72 {
73 /** Indication of sensor data being saturated, can cause data corruption.
74 * Lower the receiver gain if this indication is set.
75 */
76 bool data_saturated;
77 /** Indication of a delayed frame.
78 * The frame rate might need to be lowered if this indication is set.
79 */
80 bool frame_delayed;
81 /** Indication of calibration needed
82 * The sensor calibration needs to be redone if this indication is set.
83 */
84 bool calibration_needed;
85 /** Temperature in sensor during measurement (in degree Celsius).
86 * Note that it has poor absolute accuracy and should only be used
87 * for relative temperature measurements.
88 */
89 int16_t temperature;
90 /** Pointer to the frame data */
91 acc_int16_complex_t *frame;
92 } acc_processing_result_t;
93
94
95 /**
96 * @brief Create a processing instance with the provided configuration
97 *
98 * @param[in] config The configuration to create a processing instance with
99 * @param[out] processing_metadata The metadata of the created processing instance
100 * @return Processing handle, NULL if processing instance was not possible to create
101 */
102 acc_processing_t *acc_processing_create(const acc_config_t *config, acc_processing_metadata_t *processing_metadata);
103
104
105 /**
106 * @brief Process the data according to the configuration used in create
107 *
108 * @param[in] handle A reference to the processing handle
109 * @param[in] buffer A reference to the buffer (populated by @ref acc_sensor_read) containing the
110 * data to be processed.
111 *
112 * @param[out] result Processing result
113 */
114 void acc_processing_execute(acc_processing_t *handle, void *buffer,
115 acc_processing_result_t *result);
116
117
118 /**
119 * @brief Destroy a processing instance identified with the provided processing handle
120 *
121 * @param[in] handle A reference to the processing handle to destroy, can be NULL
122 */
123 void acc_processing_destroy(acc_processing_t *handle);
124
125
126 /**
127 * @brief Convert a distance or step length in points to meter
128 *
129 * Does not include any zero-point offset since it is highly integration dependant. In other words,
130 * calling this function with a 0 always returns 0.0.
131 *
132 * @param[in] points Number of points to convert to meter
133 * @return The corresponding length in meters
134 */
135 float acc_processing_points_to_meter(int32_t points);
136
137
138 /**
139 * @brief Convert a distance or step length in meter to points
140 *
141 * Does not include any zero-point offset since it is highly integration dependant. In other words,
142 * calling this function with a 0.0 always returns 0.
143 *
144 * @param[in] length Length in meter to convert to points
145 * @return The corresponding length in points
146 */
147 int32_t acc_processing_meter_to_points(float length);
148
149
150 /**
151 * @}
152 */
153
154
155 #endif
acc_processing_destroy
void acc_processing_destroy(acc_processing_t *handle)
Destroy a processing instance identified with the provided processing handle.
acc_processing_result_t
Result provided by the processing module.
Definition: acc_processing.h:71
acc_int16_complex_t
Data type for interger-based representation of complex numbers.
Definition: acc_definitions_common.h:43
acc_processing_execute
void acc_processing_execute(acc_processing_t *handle, void *buffer, acc_processing_result_t *result)
Process the data according to the configuration used in create.
acc_config_subsweep.h
acc_processing_metadata_t
Metadata that will be populated by the processing module during creation.
Definition: acc_processing.h:36
acc_processing_meter_to_points
int32_t acc_processing_meter_to_points(float length)
Convert a distance or step length in meter to points.
acc_processing_metadata_t::sweep_data_length
uint16_t sweep_data_length
Definition: acc_processing.h:41
acc_processing_metadata_t::high_speed_mode
bool high_speed_mode
Definition: acc_processing.h:64
acc_processing_metadata_t::frame_data_length
uint16_t frame_data_length
Definition: acc_processing.h:39
acc_config_t
struct acc_config acc_config_t
Definition: acc_config.h:26
acc_processing_points_to_meter
float acc_processing_points_to_meter(int32_t points)
Convert a distance or step length in points to meter.
acc_processing_result_t::frame_delayed
bool frame_delayed
Definition: acc_processing.h:80
acc_processing_result_t::frame
acc_int16_complex_t * frame
Definition: acc_processing.h:91
acc_processing_t
struct acc_processing_handle acc_processing_t
Definition: acc_processing.h:30
acc_definitions_common.h
acc_processing_result_t::temperature
int16_t temperature
Definition: acc_processing.h:89
acc_processing_result_t::data_saturated
bool data_saturated
Definition: acc_processing.h:76
ACC_MAX_NUM_SUBSWEEPS
#define ACC_MAX_NUM_SUBSWEEPS
Definition: acc_definitions_a121.h:14
acc_processing_result_t::calibration_needed
bool calibration_needed
Definition: acc_processing.h:84
acc_processing_metadata_t::max_sweep_rate
float max_sweep_rate
Definition: acc_processing.h:52
acc_processing_create
acc_processing_t * acc_processing_create(const acc_config_t *config, acc_processing_metadata_t *processing_metadata)
Create a processing instance with the provided configuration.
acc_definitions_a121.h