example_control_helper.c
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2020-2024
2 // All rights reserved
3 // This file is subject to the terms and conditions defined in the file
4 // 'LICENSES/license_acconeer.txt', (BSD 3-Clause License) which is part
5 // of this source code package.
6 
7 #include <stdbool.h>
8 #include <stdint.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 
12 #include "acc_config.h"
13 #include "acc_definitions_a121.h"
14 #include "acc_definitions_common.h"
17 #include "acc_integration.h"
18 #include "acc_processing.h"
19 #include "acc_rss_a121.h"
20 #include "acc_sensor.h"
21 
22 #include "acc_version.h"
23 
24 #include "acc_control_helper.h"
25 
26 /** \example example_control_helper.c
27  * @brief This is an example on how the control helper API can be used
28  * @n
29  * The example executes as follows:
30  * - Create a control helper instance
31  * - Configure the start point
32  * - Activate the radar
33  * - Read out a number of measurements
34  * - Destroy the control helper instance
35  */
36 
37 #define SENSOR_ID (1U)
38 #define MAX_DATA_ENTRY_LEN 15 // "-32000+-32000i" + zero termination
39 
40 static void print_data(acc_int16_complex_t *data, uint16_t data_length);
41 
42 
43 int app_main(int argc, char *argv[]);
44 
45 
46 int app_main(int argc, char *argv[])
47 {
48  (void)argc;
49  (void)argv;
50 
51  printf("Acconeer software version %s\n", acc_version_get());
52 
54 
56  {
57  return EXIT_FAILURE;
58  }
59 
60  acc_control_helper_t helper;
61  if (!acc_control_helper_create(&helper, SENSOR_ID))
62  {
63  printf("acc_control_helper_create() failed\n");
64  return EXIT_FAILURE;
65  }
66 
68 
69  if (!acc_control_helper_activate(&helper))
70  {
71  printf("acc_control_helper_activate() failed\n");
73  return EXIT_FAILURE;
74  }
75 
76  for (uint32_t i = 0U; i < 5U; i++)
77  {
78  if (!acc_control_helper_get_next(&helper))
79  {
80  printf("acc_control_helper_get_next failed\n");
82  return EXIT_FAILURE;
83  }
84 
86  }
87 
89 
90  printf("Application finished OK\n");
91 
92  return EXIT_SUCCESS;
93 }
94 
95 
96 static void print_data(acc_int16_complex_t *data, uint16_t data_length)
97 {
98  printf("Processed data:\n");
99  char buffer[MAX_DATA_ENTRY_LEN];
100 
101  for (uint16_t i = 0; i < data_length; i++)
102  {
103  if ((i > 0) && ((i % 8) == 0))
104  {
105  printf("\n");
106  }
107 
108  snprintf(buffer, sizeof(buffer), "%" PRIi16 "%+" PRIi16 "i", data[i].real, data[i].imag);
109 
110  printf("%14s ", buffer);
111  }
112 
113  printf("\n");
114 }
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
acc_version.h
acc_int16_complex_t
Data type for interger-based representation of complex numbers.
Definition: acc_definitions_common.h:43
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:96
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_espidf_xe121.c:135
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
app_main
int app_main(int argc, char *argv[])
Assembly test example.
Definition: example_control_helper.c:46
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
acc_hal_definitions_a121.h
acc_processing_result_t::frame
acc_int16_complex_t * frame
Definition: acc_processing.h:91
hal
static const acc_hal_a121_t hal
Definition: acc_hal_integration_espidf_xe121.c:121
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
acc_definitions_a121.h