This is an example on how to use subsweeps with the Service API
The example executes as follows:
- Create a configuration
- Configure multiple subsweeps
- Create a processing instance using the previously created configuration
- Create a sensor instance
- Prepare a sensor
- Perform a sensor measurement and read out the data
- Process the measurement subsweeps
- Destroy the sensor instance
- Destroy the processing instance
- Destroy the configuration
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#define SENSOR_ID (1U)
#define SENSOR_TIMEOUT_MS (1000U)
#define MAX_DATA_ENTRY_LEN 15 // "-32000+-32000i" + zero termination
{
(void)argc;
(void)argv;
void *buffer = NULL;
uint32_t buffer_size = 0;
{
return EXIT_FAILURE;
}
if (config == NULL)
{
printf(
"acc_config_create() failed\n");
cleanup(config, processing, sensor, buffer);
return EXIT_FAILURE;
}
if (processing == NULL)
{
printf(
"acc_processing_create() failed\n");
cleanup(config, processing, sensor, buffer);
return EXIT_FAILURE;
}
{
printf(
"acc_rss_get_buffer_size() failed\n");
cleanup(config, processing, sensor, buffer);
return EXIT_FAILURE;
}
if (buffer == NULL)
{
printf(
"buffer allocation failed\n");
cleanup(config, processing, sensor, buffer);
return EXIT_FAILURE;
}
if (sensor == NULL)
{
printf(
"acc_sensor_create() failed\n");
cleanup(config, processing, sensor, buffer);
return EXIT_FAILURE;
}
bool status;
bool cal_complete = false;
do
{
if (status && !cal_complete)
{
}
} while (status && !cal_complete);
if (!status)
{
printf(
"acc_sensor_calibrate() failed\n");
cleanup(config, processing, sensor, buffer);
return EXIT_FAILURE;
}
{
printf(
"acc_sensor_prepare() failed\n");
cleanup(config, processing, sensor, buffer);
return EXIT_FAILURE;
}
for (uint32_t i = 0U; i < 5U; i++)
{
{
printf(
"acc_sensor_measure failed\n");
cleanup(config, processing, sensor, buffer);
return EXIT_FAILURE;
}
{
printf(
"Sensor interrupt timeout\n");
cleanup(config, processing, sensor, buffer);
return EXIT_FAILURE;
}
{
printf(
"acc_sensor_read failed\n");
cleanup(config, processing, sensor, buffer);
return EXIT_FAILURE;
}
for (uint16_t sweep_index = 0; sweep_index < sweeps_per_frame; sweep_index++)
{
for (uint8_t subsweep_index = 0; subsweep_index < number_of_subsweeps; subsweep_index++)
{
printf(
"Subsweep: %" PRIu8
", sweep: %" PRIu16
", processed data:\n", subsweep_index, sweep_index);
}
}
}
cleanup(config, processing, sensor, buffer);
printf(
"Application finished OK\n");
return EXIT_SUCCESS;
}
{
if (sensor != NULL)
{
}
if (processing != NULL)
{
}
if (config != NULL)
{
}
if (buffer != NULL)
{
}
}
{
for (uint16_t i = 0; i < data_length; i++)
{
if ((i > 0) && ((i % 8) == 0))
{
}
snprintf(buffer,
sizeof(buffer),
"%" PRIi16
"+%" PRIi16
"i", data[i].real, data[i].imag);
}
}
void acc_hal_integration_sensor_supply_off(acc_sensor_id_t sensor_id)
Power off sensor supply.
void acc_processing_destroy(acc_processing_t *handle)
Destroy a processing instance identified with the provided processing handle.
void acc_hal_integration_sensor_supply_on(acc_sensor_id_t sensor_id)
Power on sensor supply.
Result provided by the processing module.
static void print_data(acc_int16_complex_t *data, uint16_t data_length)
bool acc_sensor_read(const acc_sensor_t *sensor, void *buffer, uint32_t buffer_size)
Read out radar data.
uint8_t acc_config_num_subsweeps_get(const acc_config_t *config)
Get the number of subsweeps to use.
Data type for interger-based representation of complex numbers.
void acc_config_sweeps_per_frame_set(acc_config_t *config, uint16_t sweeps)
Set sweeps per frame.
void acc_config_destroy(acc_config_t *config)
Destroy a configuration freeing any resources allocated.
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_t * acc_config_create(void)
Create a configuration.
static void cleanup(acc_config_t *config, acc_processing_t *processing, acc_sensor_t *sensor, void *buffer)
const acc_hal_a121_t * acc_hal_rss_integration_get_implementation(void)
Get hal implementation reference.
void * acc_integration_mem_alloc(size_t size)
Allocate dynamic memory.
bool acc_hal_integration_wait_for_sensor_interrupt(acc_sensor_id_t sensor_id, uint32_t timeout_ms)
Wait for a sensor interrupt.
const char * acc_version_get(void)
Get the version of the Acconeer software.
struct acc_config acc_config_t
void acc_config_num_subsweeps_set(acc_config_t *config, uint8_t num_subsweeps)
Set the number of subsweeps to use.
void acc_hal_integration_sensor_enable(acc_sensor_id_t sensor_id)
Enable sensor.
void acc_config_subsweep_start_point_set(acc_config_t *config, int32_t start_point, uint8_t index)
Set the starting point of the sweep.
#define SENSOR_TIMEOUT_MS
int acconeer_main(int argc, char *argv[])
Assembly test example.
acc_int16_complex_t * frame
void acc_hal_integration_sensor_disable(acc_sensor_id_t sensor_id)
Disable sensor.
struct acc_processing_handle acc_processing_t
void acc_sensor_status(const acc_sensor_t *sensor)
Check the status of the sensor.
void acc_config_subsweep_receiver_gain_set(acc_config_t *config, uint8_t gain, uint8_t index)
Set receiver gain setting.
bool acc_sensor_prepare(acc_sensor_t *sensor, const acc_config_t *config, const acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
Prepare a sensor to do a measurement.
void acc_integration_mem_free(void *ptr)
Free dynamic memory.
void acc_config_log(const acc_config_t *config)
Print a configuration to the log.
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.
void acc_config_subsweep_num_points_set(acc_config_t *config, uint16_t num_points, uint8_t index)
Set the number of data points to measure.
bool acc_sensor_measure(acc_sensor_t *sensor)
Start a radar measurement with previously prepared configuration.
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.
struct acc_sensor acc_sensor_t
void acc_sensor_destroy(acc_sensor_t *sensor)
Destroy a sensor instance freeing any resources allocated.
#define MAX_DATA_ENTRY_LEN
acc_sensor_t * acc_sensor_create(acc_sensor_id_t sensor_id)
Create a sensor instance.