example_control_helper.c

This is an example on how the control helper API can be used
The example executes as follows:

- Create a control helper instance
- Configure the start point
- Activate the radar
- Read out a number of measurements
- Destroy the control helper instance

// Copyright (c) Acconeer AB, 2020-2024
// All rights reserved
// This file is subject to the terms and conditions defined in the file
// 'LICENSES/license_acconeer.txt', (BSD 3-Clause License) which is part
// of this source code package.
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "acc_config.h"
#include "acc_definitions_a121.h"
#include "acc_definitions_common.h"
#include "acc_hal_definitions_a121.h"
#include "acc_hal_integration_a121.h"
#include "acc_integration.h"
#include "acc_processing.h"
#include "acc_rss_a121.h"
#include "acc_sensor.h"
#include "acc_version.h"
#include "acc_control_helper.h"
/** \example example_control_helper.c
* @brief This is an example on how the control helper API can be used
* @n
* The example executes as follows:
* - Create a control helper instance
* - Configure the start point
* - Activate the radar
* - Read out a number of measurements
* - Destroy the control helper instance
*/
#define SENSOR_ID (1U)
#define MAX_DATA_ENTRY_LEN 15 // "-32000+-32000i" + zero termination
static void print_data(acc_int16_complex_t *data, uint16_t data_length);
int acconeer_main(int argc, char *argv[]);
int acconeer_main(int argc, char *argv[])
{
(void)argc;
(void)argv;
printf("Acconeer software version %s\n", acc_version_get());
const acc_hal_a121_t *hal = acc_hal_rss_integration_get_implementation();
if (!acc_rss_hal_register(hal))
{
return EXIT_FAILURE;
}
acc_control_helper_t helper;
if (!acc_control_helper_create(&helper, SENSOR_ID))
{
printf("acc_control_helper_create() failed\n");
return EXIT_FAILURE;
}
acc_config_start_point_set(helper.config, 200);
if (!acc_control_helper_activate(&helper))
{
printf("acc_control_helper_activate() failed\n");
acc_control_helper_destroy(&helper);
return EXIT_FAILURE;
}
for (uint32_t i = 0U; i < 5U; i++)
{
if (!acc_control_helper_get_next(&helper))
{
printf("acc_control_helper_get_next failed\n");
acc_control_helper_destroy(&helper);
return EXIT_FAILURE;
}
print_data(helper.proc_result.frame, helper.proc_meta.frame_data_length);
}
acc_control_helper_destroy(&helper);
printf("Application finished OK\n");
return EXIT_SUCCESS;
}
static void print_data(acc_int16_complex_t *data, uint16_t data_length)
{
printf("Processed data:\n");
char buffer[MAX_DATA_ENTRY_LEN];
for (uint16_t i = 0; i < data_length; i++)
{
if ((i > 0) && ((i % 8) == 0))
{
printf("\n");
}
snprintf(buffer, sizeof(buffer), "%" PRIi16 "%+" PRIi16 "i", data[i].real, data[i].imag);
printf("%14s ", buffer);
}
printf("\n");
}
acc_config_start_point_set
void acc_config_start_point_set(acc_config_t *config, int32_t start_point)
Set the starting point of the sweep.
acc_control_helper_create
bool acc_control_helper_create(acc_control_helper_t *radar, acc_sensor_id_t sensor_id)
Create a helper instance.
Definition: acc_control_helper.c:41
acc_rss_a121.h
acc_control_helper_t::config
acc_config_t * config
Definition: acc_control_helper.h:25
buffer
void * buffer
Definition: i2c_example_cargo.c:40
acc_version.h
acc_int16_complex_t
Data type for interger-based representation of complex numbers.
Definition: acc_definitions_common.h:40
acc_integration.h
acc_control_helper_destroy
void acc_control_helper_destroy(acc_control_helper_t *radar)
Destroy a helper instance.
Definition: acc_control_helper.c:50
print_data
static void print_data(acc_int16_complex_t *data, uint16_t data_length)
Definition: example_control_helper.c:93
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
acc_hal_a121_t
Definition: acc_hal_definitions_a121.h:82
acc_control_helper_t::proc_meta
acc_processing_metadata_t proc_meta
Definition: acc_control_helper.h:32
acc_rss_hal_register
bool acc_rss_hal_register(const acc_hal_a121_t *hal)
Register an integration.
acc_sensor.h
acc_control_helper.h
acc_hal_integration_a121.h
acc_processing_metadata_t::frame_data_length
uint16_t frame_data_length
Definition: acc_processing.h:39
acc_version_get
const char * acc_version_get(void)
Get the version of the Acconeer software.
SENSOR_ID
#define SENSOR_ID
Definition: example_control_helper.c:37
printf
#define printf
Definition: printf.h:60
snprintf
#define snprintf
Definition: printf.h:84
acc_hal_definitions_a121.h
acc_processing_result_t::frame
acc_int16_complex_t * frame
Definition: acc_processing.h:91
acc_control_helper_t
Definition: acc_control_helper.h:23
acc_control_helper_activate
bool acc_control_helper_activate(acc_control_helper_t *radar)
Activate the sensor.
Definition: acc_control_helper.c:81
acc_definitions_common.h
acc_config.h
MAX_DATA_ENTRY_LEN
#define MAX_DATA_ENTRY_LEN
Definition: example_control_helper.c:38
acc_control_helper_get_next
bool acc_control_helper_get_next(acc_control_helper_t *radar)
Perform a radar measurement and wait for the result.
Definition: acc_control_helper.c:157
acc_control_helper_t::proc_result
acc_processing_result_t proc_result
Definition: acc_control_helper.h:33
acc_processing.h
acconeer_main
int acconeer_main(int argc, char *argv[])
Assembly test example.
Definition: example_control_helper.c:44
acc_definitions_a121.h