Go to the documentation of this file.
56 #define SENSOR_ID (1U)
58 #define SENSOR_TIMEOUT_MS (2000U)
112 if (resources.
config == NULL)
114 printf(
"acc_detector_distance_config_create() failed\n");
123 printf(
"Initializing detector resources failed\n");
136 if (resources.
sensor == NULL)
138 printf(
"acc_sensor_create() failed\n");
147 printf(
"Sensor calibration failed\n");
154 printf(
"Detector calibration failed\n");
165 printf(
"Could not get next result\n");
173 printf(
"Sensor recalibration and detector calibration update needed ... \n");
177 printf(
"Sensor calibration failed\n");
185 printf(
"Detector calibration update failed\n");
190 printf(
"Sensor recalibration and detector calibration update done!\n");
216 if (resources->
sensor != NULL)
262 if (resources->
handle == NULL)
264 printf(
"acc_detector_distance_create() failed\n");
270 printf(
"acc_detector_distance_get_sizes() failed\n");
275 if (resources->
buffer == NULL)
277 printf(
"sensor buffer allocation failed\n");
284 printf(
"calibration buffer allocation failed\n");
294 bool cal_complete =
false;
295 const uint16_t calibration_retries = 1U;
298 for (uint16_t i = 0; !status && (i <= calibration_retries); i++)
308 if (status && !cal_complete)
312 }
while (status && !cal_complete);
346 }
while (status && !done);
370 }
while (status && !done);
379 bool result_available =
false;
390 printf(
"acc_detector_distance_prepare() failed\n");
396 printf(
"acc_sensor_measure() failed\n");
402 printf(
"Sensor interrupt timeout\n");
408 printf(
"acc_sensor_read() failed\n");
419 printf(
"acc_detector_distance_process() failed\n");
428 }
while (!result_available);
443 uint16_t sweep_length = processing_metadata->
frame_data_length / sweeps_per_frame;
445 printf(
"BEGIN:Distance(m), [Frame], Amplitude\n");
448 for (uint8_t subsweep_idx = 0; subsweep_idx < num_subsweeps; subsweep_idx++)
459 for (uint16_t point_idx = 0; point_idx < subsweep_length; point_idx++)
466 int32_t iq_point_real_acc = 0;
467 int32_t iq_point_imag_acc = 0;
470 for (uint16_t sweep_idx = 0; sweep_idx < sweeps_per_frame; sweep_idx++)
472 uint16_t point_offset = sweep_idx * sweep_length + subsweep_offset + point_idx;
473 iq_point_real_acc += frame[point_offset].
real;
474 iq_point_imag_acc += frame[point_offset].
imag;
478 int16_t imag = frame[point_offset].
imag;
487 printf(
"%" PRIi16
"%s%" PRIi16
"i%s", frame[point_offset].real, sign, imag, ((sweep_idx + 1 == sweeps_per_frame) ?
"" :
", "));
490 iq_point_real_acc = iq_point_real_acc / sweeps_per_frame;
491 iq_point_imag_acc = iq_point_imag_acc / sweeps_per_frame;
494 uint32_t iq_point_abs = (uint32_t)sqrt(iq_point_real_acc * iq_point_real_acc + iq_point_imag_acc * iq_point_imag_acc);
497 printf(
"], %" PRIu32
"\n", iq_point_abs);
501 printf(
"END:Distance(m), [Frame], Amplitude\n");
507 if (
result->num_distances > 0)
511 for (uint8_t i = 0; i <
result->num_distances; i++)
void acc_hal_integration_sensor_supply_off(acc_sensor_id_t sensor_id)
Power off sensor supply.
bool acc_detector_distance_get_sizes(const acc_detector_distance_handle_t *handle, uint32_t *buffer_size, uint32_t *detector_cal_result_static_size)
Get the memory size needed to use the Distance Detector API functions.
void acc_detector_distance_config_peak_sorting_set(acc_detector_distance_config_t *config, acc_detector_distance_peak_sorting_t peak_sorting)
Set peak sorting method.
@ DISTANCE_PRESET_CONFIG_HIGH_ACCURACY
void acc_hal_integration_sensor_supply_on(acc_sensor_id_t sensor_id)
Power on sensor supply.
Result provided by the processing module.
static bool do_detector_get_next(distance_detector_resources_t *resources, const acc_cal_result_t *sensor_cal_result, acc_detector_distance_result_t *result)
static bool do_detector_calibration_update(distance_detector_resources_t *resources, const acc_cal_result_t *sensor_cal_result)
uint32_t detector_cal_result_static_size
bool acc_sensor_read(const acc_sensor_t *sensor, void *buffer, uint32_t buffer_size)
Read out radar data.
acc_cal_result_t sensor_cal_result
uint8_t acc_config_num_subsweeps_get(const acc_config_t *config)
Get the number of subsweeps to use.
static void cleanup(distance_detector_resources_t *resources)
Data type for interger-based representation of complex numbers.
@ ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST
void acc_detector_distance_config_threshold_method_set(acc_detector_distance_config_t *config, acc_detector_distance_threshold_method_t threshold_method)
Set threshold method.
static void print_distance_result(const acc_detector_distance_result_t *result)
The result from a completed calibration.
void acc_detector_distance_config_start_set(acc_detector_distance_config_t *config, float start_m)
Set start of measured interval (m)
int acconeer_main(int argc, char *argv[])
Assembly test example.
acc_detector_distance_handle_t * acc_detector_distance_create(const acc_detector_distance_config_t *config)
Create Distance Detector handle using the provided Distance Detector configuration.
static bool do_sensor_calibration(acc_sensor_t *sensor, acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
void acc_detector_distance_config_destroy(acc_detector_distance_config_t *config)
Destroy Distance Detector configuration.
@ DISTANCE_PRESET_CONFIG_BALANCED
const acc_hal_a121_t * acc_hal_rss_integration_get_implementation(void)
Get hal implementation reference.
@ DISTANCE_PRESET_CONFIG_NONE
bool acc_detector_distance_calibrate(acc_sensor_t *sensor, acc_detector_distance_handle_t *handle, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, uint8_t *detector_cal_result_static, uint32_t detector_cal_result_static_size, acc_detector_cal_result_dynamic_t *detector_cal_result_dynamic, bool *calibration_complete)
Calibrate detector.
acc_detector_cal_result_dynamic_t detector_cal_result_dynamic
bool acc_detector_distance_process(acc_detector_distance_handle_t *handle, void *buffer, uint8_t *detector_cal_result_static, acc_detector_cal_result_dynamic_t *detector_cal_result_dynamic, bool *result_available, acc_detector_distance_result_t *result)
Process sensor data into a Detector result.
void * acc_integration_mem_alloc(size_t size)
Allocate dynamic memory.
static uint8_t * detector_cal_result_static
The result from a completed calibration update.
uint8_t * detector_cal_result_static
void acc_detector_distance_config_close_range_leakage_cancellation_set(acc_detector_distance_config_t *config, bool enable)
Enable close range leakage cancellation.
void acc_detector_distance_config_max_profile_set(acc_detector_distance_config_t *config, acc_config_profile_t max_profile)
Set maximum Profile.
uint16_t acc_config_sweeps_per_frame_get(const acc_config_t *config)
Get the number of sweeps per frame.
void acc_detector_distance_destroy(acc_detector_distance_handle_t *handle)
Destroy Distance Detector handle, freeing its resources.
bool acc_hal_integration_wait_for_sensor_interrupt(acc_sensor_id_t sensor_id, uint32_t timeout_ms)
Wait for a sensor interrupt.
void acc_detector_distance_config_signal_quality_set(acc_detector_distance_config_t *config, float signal_quality)
Set signal quality (dB)
const char * acc_version_get(void)
Get the version of the Acconeer software.
struct acc_config acc_config_t
uint16_t acc_config_subsweep_step_length_get(const acc_config_t *config, uint8_t index)
Get the step length in a sweep.
float acc_processing_points_to_meter(int32_t points)
Convert a distance or step length in points to meter.
static uint32_t detector_cal_result_static_size
void acc_hal_integration_sensor_enable(acc_sensor_id_t sensor_id)
Enable sensor.
static bool initialize_detector_resources(distance_detector_resources_t *resources)
static void set_config(acc_detector_distance_config_t *detector_config, distance_preset_config_t preset)
void acc_detector_distance_config_log(const acc_detector_distance_handle_t *handle, const acc_detector_distance_config_t *config)
Log Distance configuration, typically through printf.
bool acc_detector_distance_prepare(const acc_detector_distance_handle_t *handle, const acc_detector_distance_config_t *config, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
Prepare the Detector for measurements.
acc_config_t * sensor_config
static bool do_full_detector_calibration(distance_detector_resources_t *resources, const acc_cal_result_t *sensor_cal_result)
Distance Detector result returned from acc_detector_distance_process.
@ ACC_DETECTOR_DISTANCE_THRESHOLD_METHOD_CFAR
acc_detector_distance_config_t * config
acc_int16_complex_t * frame
void acc_hal_integration_sensor_disable(acc_sensor_id_t sensor_id)
Disable sensor.
void acc_detector_distance_config_end_set(acc_detector_distance_config_t *config, float end_m)
Set end of measured interval (m)
struct acc_detector_distance_handle acc_detector_distance_handle_t
Distance Detector handle.
#define ACC_LOG_FLOAT_TO_INTEGER(a)
bool acc_detector_distance_update_calibration(acc_sensor_t *sensor, acc_detector_distance_handle_t *handle, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, acc_detector_cal_result_dynamic_t *detector_cal_result_dynamic, bool *calibration_complete)
Perform a subset of the full Detector calibration.
static void print_iq_data(const acc_config_t *sensor_config, acc_processing_result_t *processing_result, acc_processing_metadata_t *processing_metadata)
void acc_integration_mem_free(void *ptr)
Free dynamic memory.
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.
void acc_detector_distance_config_threshold_sensitivity_set(acc_detector_distance_config_t *config, float threshold_sensitivity)
Set threshold sensitivity.
acc_detector_distance_config_t * acc_detector_distance_config_create(void)
Create a Distance Detector configuration.
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.
#define PRIfloat
Specifier for printing float type using integers.
acc_detector_distance_handle_t * handle
struct acc_detector_distance_config acc_detector_distance_config_t
Distance Detector configuration.
@ ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_GENERIC
void acc_detector_distance_config_max_step_length_set(acc_detector_distance_config_t *config, uint16_t max_step_length)
Set maximum step length.
bool acc_sensor_measure(acc_sensor_t *sensor)
Start a radar measurement with previously prepared configuration.
#define SENSOR_TIMEOUT_MS
int32_t acc_config_subsweep_start_point_get(const acc_config_t *config, uint8_t index)
Get the starting point of the sweep.
struct acc_sensor acc_sensor_t
void acc_sensor_destroy(acc_sensor_t *sensor)
Destroy a sensor instance freeing any resources allocated.
acc_sensor_t * acc_sensor_create(acc_sensor_id_t sensor_id)
Create a sensor instance.