This is an example on how the Service API can be used with multiple configurations
The example executes as follows:
#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 (15U) // "-32000+-32000i" + zero termination
#define NBR_CONFIGS (2U)
{
{
(void)argc;
(void)argv;
void *buffer = NULL;
uint32_t buffer_size = 0;
{
{
.num_points = 100,
.sweeps_per_frame = 1,
},
{
.start_point = 120,
.num_points = 120,
.sweeps_per_frame = 3,
}
};
{
return EXIT_FAILURE;
}
{
if (config[cfg] == NULL)
{
printf("acc_config_create() failed\n");
return EXIT_FAILURE;
}
if (processing[cfg] == NULL)
{
printf("acc_processing_create() failed\n");
return EXIT_FAILURE;
}
uint32_t current_buffer_size = 0;
{
printf("acc_rss_get_buffer_size() failed\n");
return EXIT_FAILURE;
}
if (buffer_size < current_buffer_size)
{
buffer_size = current_buffer_size;
}
}
if (buffer == NULL)
{
printf("buffer allocation failed\n");
return EXIT_FAILURE;
}
if (sensor == NULL)
{
printf("acc_sensor_create() failed\n");
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");
return EXIT_FAILURE;
}
for (uint32_t i = 0U; i < 5U; i++)
{
{
{
printf("acc_sensor_prepare() failed\n");
return EXIT_FAILURE;
}
{
printf("acc_sensor_measure failed\n");
return EXIT_FAILURE;
}
{
printf("Sensor interrupt timeout\n");
return EXIT_FAILURE;
}
{
printf("acc_sensor_read failed\n");
return EXIT_FAILURE;
}
}
}
printf("Application finished OK\n");
return EXIT_SUCCESS;
}
{
if (sensor != NULL)
{
}
for (uint32_t cfg = 0U; cfg < nbr_configs; cfg++)
{
if (processing[cfg] != NULL)
{
}
if (config[cfg] != NULL)
{
}
}
if (buffer != NULL)
{
}
}
{
printf("Processed data for config %" PRIu32 ":\n", cfg);
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");
}