example_diagnostic_test.c

This is an example on how to use RSS to execute the diagnostic test
The example executes as follows:

// Copyright (c) Acconeer AB, 2022-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_rss_a121.h"
#include "acc_version.h"
/** \example example_diagnostic_test.c
* @brief This is an example on how to use RSS to execute the diagnostic test
* @n
* The example executes as follows:
* - Register the RSS HAL
* - Power on the sensor
* - Create diagnostic test
* - Enable the sensor
* - Execute diagnostic test
* - Destroy diagnostic test
* - Disable the sensor
* - Power off the sensor
*/
#define SENSOR_ID (1U)
#define SENSOR_TIMEOUT_MS (1000U)
int app_main(int argc, char *argv[]);
int app_main(int argc, char *argv[])
{
(void)argc;
(void)argv;
bool test_ok = true;
printf("Acconeer software version %s\n", acc_version_get());
{
return EXIT_FAILURE;
}
if (buffer == NULL)
{
printf("Diagnostic test: Memory allocation failed\n");
return EXIT_FAILURE;
}
if (assembly_test != NULL)
{
/* Enable all tests */
/* Enable the diagnostic logs from the assembly test */
do
{
test_state = acc_rss_assembly_test_execute(assembly_test, integration_status);
switch (test_state)
{
integration_status = ACC_RSS_TEST_INTEGRATION_STATUS_OK;
break;
{
/* Wait for interrupt failed */
}
break;
default:
integration_status = ACC_RSS_TEST_INTEGRATION_STATUS_OK;
break;
}
} while (test_state != ACC_RSS_TEST_STATE_COMPLETE);
}
else
{
printf("Diagnostic test: Could not create assembly test\n");
test_ok = false;
}
if (buffer != NULL)
{
}
if (test_ok)
{
printf("Diagnostic test completed\n");
printf("Application finished OK\n");
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}
ACC_RSS_TEST_STATE_WAIT_FOR_INTERRUPT
@ ACC_RSS_TEST_STATE_WAIT_FOR_INTERRUPT
Definition: acc_rss_a121.h:41
acc_rss_assembly_test_execute
acc_rss_test_state_t acc_rss_assembly_test_execute(acc_rss_assembly_test_t *assembly_test, acc_rss_test_integration_status_t integration_status)
Execute the assembly test.
acc_hal_integration_sensor_supply_off
void acc_hal_integration_sensor_supply_off(acc_sensor_id_t sensor_id)
Power off sensor supply.
Definition: acc_hal_integration_espidf_xe121.c:192
acc_rss_a121.h
acc_hal_integration_sensor_supply_on
void acc_hal_integration_sensor_supply_on(acc_sensor_id_t sensor_id)
Power on sensor supply.
Definition: acc_hal_integration_espidf_xe121.c:185
acc_version.h
app_main
int app_main(int argc, char *argv[])
Assembly test example.
Definition: example_diagnostic_test.c:42
SENSOR_ID
#define SENSOR_ID
Definition: example_diagnostic_test.c:35
ACC_RSS_TEST_INTEGRATION_STATUS_TIMEOUT
@ ACC_RSS_TEST_INTEGRATION_STATUS_TIMEOUT
Definition: acc_rss_a121.h:56
acc_rss_assembly_test_enable_diagnostic_logs
void acc_rss_assembly_test_enable_diagnostic_logs(void)
Enable diagnostic logs for the assembly test,.
acc_integration.h
ACC_RSS_ASSEMBLY_TEST_MIN_BUFFER_SIZE
#define ACC_RSS_ASSEMBLY_TEST_MIN_BUFFER_SIZE
The minimum buffer size needed for the assembly test.
Definition: acc_rss_a121.h:27
acc_rss_assembly_test_destroy
void acc_rss_assembly_test_destroy(acc_rss_assembly_test_t *assembly_test)
Destroy a sensor assembly test instance freeing any resources allocated.
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_integration_mem_alloc
void * acc_integration_mem_alloc(size_t size)
Allocate dynamic memory.
Definition: acc_integration_esp32.c:38
acc_hal_a121_t
Definition: acc_hal_definitions_a121.h:82
acc_rss_hal_register
bool acc_rss_hal_register(const acc_hal_a121_t *hal)
Register an integration.
ACC_RSS_TEST_INTEGRATION_STATUS_OK
@ ACC_RSS_TEST_INTEGRATION_STATUS_OK
Definition: acc_rss_a121.h:54
acc_rss_assembly_test_create
acc_rss_assembly_test_t * acc_rss_assembly_test_create(acc_sensor_id_t sensor_id, void *buffer, uint32_t buffer_size)
Create a sensor assembly test instance.
ACC_RSS_TEST_STATE_ONGOING
@ ACC_RSS_TEST_STATE_ONGOING
Definition: acc_rss_a121.h:37
acc_rss_assembly_test_enable_all_tests
void acc_rss_assembly_test_enable_all_tests(acc_rss_assembly_test_t *assembly_test)
Enable all assembly tests.
acc_hal_integration_wait_for_sensor_interrupt
bool acc_hal_integration_wait_for_sensor_interrupt(acc_sensor_id_t sensor_id, uint32_t timeout_ms)
Wait for a sensor interrupt.
Definition: acc_hal_integration_espidf_xe121.c:100
acc_hal_integration_a121.h
acc_version_get
const char * acc_version_get(void)
Get the version of the Acconeer software.
SENSOR_TIMEOUT_MS
#define SENSOR_TIMEOUT_MS
Definition: example_diagnostic_test.c:37
acc_hal_integration_sensor_enable
void acc_hal_integration_sensor_enable(acc_sensor_id_t sensor_id)
Enable sensor.
Definition: acc_hal_integration_espidf_xe121.c:199
acc_hal_definitions_a121.h
ACC_RSS_TEST_STATE_COMPLETE
@ ACC_RSS_TEST_STATE_COMPLETE
Definition: acc_rss_a121.h:43
acc_rss_test_state_t
acc_rss_test_state_t
Return code for rss tests.
Definition: acc_rss_a121.h:34
acc_hal_integration_sensor_disable
void acc_hal_integration_sensor_disable(acc_sensor_id_t sensor_id)
Disable sensor.
Definition: acc_hal_integration_espidf_xe121.c:214
acc_rss_test_integration_status_t
acc_rss_test_integration_status_t
Integration status for rss tests.
Definition: acc_rss_a121.h:51
acc_rss_assembly_test_t
struct acc_rss_assembly_test acc_rss_assembly_test_t
Definition: acc_rss_a121.h:98
hal
static const acc_hal_a121_t hal
Definition: acc_hal_integration_espidf_xe121.c:121
ACC_RSS_TEST_STATE_TOGGLE_ENABLE_PIN
@ ACC_RSS_TEST_STATE_TOGGLE_ENABLE_PIN
Definition: acc_rss_a121.h:39
acc_integration_mem_free
void acc_integration_mem_free(void *ptr)
Free dynamic memory.
Definition: acc_integration_esp32.c:57
acc_definitions_common.h
acc_definitions_a121.h