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 int acconeer_main(int argc, char *argv[]);
43 
44 int acconeer_main(int argc, char *argv[])
45 {
46  (void)argc;
47  (void)argv;
48 
49  printf("Acconeer software version %s\n", acc_version_get());
50 
52 
53  if (!acc_rss_hal_register(hal))
54  {
55  return EXIT_FAILURE;
56  }
57 
58  acc_control_helper_t helper;
59  if (!acc_control_helper_create(&helper, SENSOR_ID))
60  {
61  printf("acc_control_helper_create() failed\n");
62  return EXIT_FAILURE;
63  }
64 
66 
67  if (!acc_control_helper_activate(&helper))
68  {
69  printf("acc_control_helper_activate() failed\n");
71  return EXIT_FAILURE;
72  }
73 
74  for (uint32_t i = 0U; i < 5U; i++)
75  {
76  if (!acc_control_helper_get_next(&helper))
77  {
78  printf("acc_control_helper_get_next failed\n");
80  return EXIT_FAILURE;
81  }
82 
84  }
85 
87 
88  printf("Application finished OK\n");
89 
90  return EXIT_SUCCESS;
91 }
92 
93 static void print_data(acc_int16_complex_t *data, uint16_t data_length)
94 {
95  printf("Processed data:\n");
97 
98  for (uint16_t i = 0; i < data_length; i++)
99  {
100  if ((i > 0) && ((i % 8) == 0))
101  {
102  printf("\n");
103  }
104 
105  snprintf(buffer, sizeof(buffer), "%" PRIi16 "%+" PRIi16 "i", data[i].real, data[i].imag);
106 
107  printf("%14s ", buffer);
108  }
109 
110  printf("\n");
111 }
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