STS_P2 #6

Closed
sundp wants to merge 9 commits from STS_P2 into master
16 changed files with 3980 additions and 0 deletions
Showing only changes of commit a579c67643 - Show all commits

View File

@ -0,0 +1,228 @@
// Copyright (c) Acconeer AB, 2018-2021
// All rights reserved
#ifndef ACC_BASE_CONFIGURATION_H_
#define ACC_BASE_CONFIGURATION_H_
#include <stdbool.h>
#include <stdint.h>
#include "acc_definitions_a111.h"
#include "acc_definitions_common.h"
/**
* @defgroup Base Service Base Configuration
*
* @brief Service base configuration API description
*
* @{
*/
#define ACC_BASE_CONFIGURATION_POWER_SAVE_MODE_OFF ACC_POWER_SAVE_MODE_OFF
#define ACC_BASE_CONFIGURATION_POWER_SAVE_MODE_SLEEP ACC_POWER_SAVE_MODE_SLEEP
#define ACC_BASE_CONFIGURATION_POWER_SAVE_MODE_READY ACC_POWER_SAVE_MODE_READY
#define ACC_BASE_CONFIGURATION_POWER_SAVE_MODE_ACTIVE ACC_POWER_SAVE_MODE_ACTIVE
#define ACC_BASE_CONFIGURATION_POWER_SAVE_MODE_HIBERNATE ACC_POWER_SAVE_MODE_HIBERNATE
/**
* @brief Power save mode data type, see @ref acc_power_save_mode_enum_t
*/
typedef acc_power_save_mode_t acc_base_configuration_power_save_mode_t;
/**
* @brief Service base configuration container
*/
struct acc_base_configuration;
typedef struct acc_base_configuration *acc_base_configuration_t;
/**
* @brief Get the sensor ID for the sensor to be configured
*
* @param[in] configuration The base configuration to get the sensor id from
* @return Sensor Id
*/
acc_sensor_id_t acc_base_configuration_sensor_get(acc_base_configuration_t configuration);
/**
* @brief Set the sensor ID for the sensor to be configured
*
* @param[in] configuration The base configuration to set the sensor id in
* @param[in] sensor_id The sensor id to set
*/
void acc_base_configuration_sensor_set(acc_base_configuration_t configuration, acc_sensor_id_t sensor_id);
/**
* @brief Get the requested start of the sweep
*
* @param[in] configuration The base configuration to get the requested start from
* @return Requested start
*/
float acc_base_configuration_requested_start_get(acc_base_configuration_t configuration);
/**
* @brief Set the requested start of the sweep
*
* @param[in] configuration The base configuration to set the requested start in
* @param[in] start_m The requested start in meters
*/
void acc_base_configuration_requested_start_set(acc_base_configuration_t configuration, float start_m);
/**
* @brief Get the requested length of the sweep
*
* @param[in] configuration The base configuration to get the requested length from
* @return Requested length
*/
float acc_base_configuration_requested_length_get(acc_base_configuration_t configuration);
/**
* @brief Set the requested length of the sweep
*
* @param[in] configuration The base configuration to set the requested length in
* @param[in] length_m The requested length in meters
*/
void acc_base_configuration_requested_length_set(acc_base_configuration_t configuration, float length_m);
/**
* @brief Set the service repetition mode to on demand
*
* In on demand mode, the sensor produces data when requested by the application.
* The application is also responsible for the timing between updates.
*
* This mode must be used if the configured length requires stitching in the service.
*
* @param[in] configuration The base configuration to set on demand mode in
*/
void acc_base_configuration_repetition_mode_on_demand_set(acc_base_configuration_t configuration);
/**
* @brief Set the service repetition mode to streaming mode
*
* The sensor produces data according to the configured update rate using sensor
* hardware timing which is very accurate.
*
* @param[in] configuration The base configuration to set streaming mode in
* @param[in] update_rate The output data rate from the service in hertz
*/
void acc_base_configuration_repetition_mode_streaming_set(acc_base_configuration_t configuration, float update_rate);
/**
* @brief Get power save mode
*
* The power save modes of the sensor correspond to how much of the sensor hardware is shutdown
* between data frame aquisition. The supported power save modes are defined in
* @ref acc_power_save_mode_enum_t.
*
* @param[in] configuration The base configuration to get power save mode for
* @return Power save mode
*/
acc_power_save_mode_t acc_base_configuration_power_save_mode_get(acc_base_configuration_t configuration);
/**
* @brief Set power save mode
*
* The power save modes of the sensor correspond to how much of the sensor hardware is shutdown
* between data frame aquisition. The supported power save modes are defined in
* @ref acc_power_save_mode_enum_t.
*
* @param[in] configuration The base configuration to set power save mode in
* @param[in] power_save_mode The power save mode to use
*/
void acc_base_configuration_power_save_mode_set(acc_base_configuration_t configuration,
acc_power_save_mode_t power_save_mode);
/**
* @brief Get receiver gain setting
*
* Will be a value between 0.0 and 1.0, where 0.0 is the lowest gain and 1.0 is the highest gain.
*
* @param[in] configuration The base configuration to get receiver gain setting for
* @return Receiver gain setting
*/
float acc_base_configuration_receiver_gain_get(acc_base_configuration_t configuration);
/**
* @brief Set receiver gain setting
*
* Must be a value between 0.0 and 1.0, where 0.0 is the lowest gain and 1.0 is the highest gain.
*
* @param[in] configuration The base configuration to set receiver gain setting in
* @param[in] gain Receiver gain setting, must be between 0.0 and 1.0
*/
void acc_base_configuration_receiver_gain_set(acc_base_configuration_t configuration, float gain);
/**
* @brief Get TX disable mode
*
* Will be true if TX is disabled, false otherwise.
*
* @param[in] configuration The base configuration to set TX disable mode in
* @return TX disable mode
*/
bool acc_base_configuration_tx_disable_get(acc_base_configuration_t configuration);
/**
* @brief Set TX disable mode
*
* If set to true, TX disable mode is enabled. This will disable the radio transmitter.
* To measure RX noise floor, it is recommended to also switch off internal
* noise level normalization (see each service if applicable).
*
* @param[in] configuration The base configuration to set TX disable mode in
* @param[in] tx_disable TX disable mode, true or false
*/
void acc_base_configuration_tx_disable_set(acc_base_configuration_t configuration, bool tx_disable);
/**
* @brief Get the hardware accelerated average samples (HWAAS)
*
* Each data point can be sampled between 1 and 63 times, inclusive, and the sensor hardware then
* produces an average value of those samples. The time needed to measure a sweep is roughly proportional
* to the number of averaged samples. Hence, if there is a need to obtain a higher update rate, HWAAS
* could be decreased but this leads to lower SNR.
*
* @param[in] configuration The base configuration to get hardware accelerated average samples from
* @return Hardware accelerated average samples
*/
uint8_t acc_base_configuration_hw_accelerated_average_samples_get(acc_base_configuration_t configuration);
/**
* @brief Set the hardware accelerated average samples (HWAAS)
*
* Each data point can be sampled between 1 and 63 times, inclusive, and the sensor hardware then
* produces an average value of those samples. The time needed to measure a sweep is roughly proportional
* to the number of averaged samples. Hence, if there is a need to obtain a higher update rate, HWAAS
* could be decreased but this leads to lower SNR.
*
* @param[in] configuration The base configuration to set hardware accelerated average samples in
* @param[in] samples Hardware accelerated average samples
*/
void acc_base_configuration_hw_accelerated_average_samples_set(acc_base_configuration_t configuration, uint8_t samples);
/**
* @}
*/
#endif

View File

@ -0,0 +1,76 @@
// Copyright (c) Acconeer AB, 2018-2021
// All rights reserved
#ifndef ACC_DEFINITIONS_A111_H_
#define ACC_DEFINITIONS_A111_H_
#include <stdint.h>
/**
* @brief Power save mode
*
* Each power save mode corresponds to how much of the sensor hardware is shutdown
* between data frame aquisition. Mode 'OFF' means that the whole sensor is shutdown.
* Mode 'ACTIVE' means that the sensor is in its active state all the time.
* Mode 'HIBERNATE' means that the sensor is still powered but the internal oscillator is
* turned off and the application needs to clock the sensor by toggling a GPIO a pre-defined
* number of times to enter and exit this mode. Mode 'HIBERNATE' is currently only supported
* by the Sparse service
*
* For each power save mode there will be a limit in the achievable update rate. Mode 'OFF'
* can achieve the lowest power consumption but also has the lowest update rate limit
*/
typedef enum
{
ACC_POWER_SAVE_MODE_OFF,
ACC_POWER_SAVE_MODE_SLEEP,
ACC_POWER_SAVE_MODE_READY,
ACC_POWER_SAVE_MODE_ACTIVE,
ACC_POWER_SAVE_MODE_HIBERNATE,
} acc_power_save_mode_enum_t;
typedef uint32_t acc_power_save_mode_t;
/**
* @brief Service profile
*
* Each profile consists of a number of settings for the sensor that configures
* the RX and TX paths. Profile 1 maximizes on the depth resolution and
* profile 5 maximizes on radar loop gain with a sliding scale in between.
*/
typedef enum
{
ACC_SERVICE_PROFILE_1 = 1,
ACC_SERVICE_PROFILE_2,
ACC_SERVICE_PROFILE_3,
ACC_SERVICE_PROFILE_4,
ACC_SERVICE_PROFILE_5,
} acc_service_profile_t;
/**
* @brief Maximum Unambiguous Range
*/
typedef enum
{
/** Maximum unambiguous range 11.5 m, maximum measurable distance 7.0 m, pulse repetition frequency 13.0 MHz */
ACC_SERVICE_MUR_6 = 6,
/** Maximum unambiguous range 17.3 m, maximum measurable distance 12.7 m , pulse repetition frequency 8.7 MHz */
ACC_SERVICE_MUR_9 = 9,
/** Default maximum unambiguous range */
ACC_SERVICE_MUR_DEFAULT = ACC_SERVICE_MUR_6,
} acc_service_mur_t;
/**
* Type used when retrieving and setting a sensor calibration context
*/
typedef struct
{
uint8_t data[64];
} acc_calibration_context_t;
#endif

View File

@ -0,0 +1,45 @@
// Copyright (c) Acconeer AB, 2018-2021
// All rights reserved
#ifndef ACC_DEFINITIONS_COMMON_H_
#define ACC_DEFINITIONS_COMMON_H_
#include <inttypes.h>
#include <stdint.h>
/**
* @brief Type representing a sensor ID
*/
typedef uint32_t acc_sensor_id_t;
/**
* @brief Macro for printing sensor id
*/
#define PRIsensor_id PRIu32
/**
* @brief This enum represents the different log levels for RSS
*/
typedef enum
{
ACC_LOG_LEVEL_ERROR,
ACC_LOG_LEVEL_WARNING,
ACC_LOG_LEVEL_INFO,
ACC_LOG_LEVEL_VERBOSE,
ACC_LOG_LEVEL_DEBUG
} acc_log_level_t;
/**
* @brief Data type for interger-based representation of complex numbers
*/
typedef struct
{
int16_t real;
int16_t imag;
} acc_int16_complex_t;
#endif

View File

@ -0,0 +1,831 @@
// Copyright (c) Acconeer AB, 2020-2021
// All rights reserved
#ifndef ACC_DETECTOR_DISTANCE_H_
#define ACC_DETECTOR_DISTANCE_H_
#include <stdbool.h>
#include <stdint.h>
#include "acc_definitions_a111.h"
#include "acc_definitions_common.h"
/**
* @defgroup Distance Distance Detector
* @ingroup Detectors
*
* @brief Distance detector API description
*
* @{
*/
/**
* @brief Metadata for the distance detector
*/
typedef struct
{
/** Start of measurement in meters, derived from request set by @ref acc_detector_distance_configuration_requested_start_set */
float start_m;
/** Length of measurement in meters, derived from request set by @ref acc_detector_distance_configuration_requested_length_set */
float length_m;
/** Length needed for potential background, used in @ref acc_detector_distance_record_background */
uint16_t background_length;
} acc_detector_distance_metadata_t;
/**
* @brief Metadata for the recorded background
*/
typedef struct
{
/** Indication of missed data from the sensor */
bool missed_data;
/** Indication of a sensor communication error, service probably needs to be restarted */
bool sensor_communication_error;
/** Indication of sensor data being saturated, can cause result instability */
bool data_saturated;
/** Indication of bad data quality that may be addressed by restarting the service to recalibrate the sensor */
bool data_quality_warning;
} acc_detector_distance_recorded_background_info_t;
/**
* @brief Metadata for each result provided by the distance detector
*/
typedef struct
{
/** Indication of missed data from the sensor */
bool missed_data;
/** Indication of a sensor communication error, service probably needs to be restarted */
bool sensor_communication_error;
/** Indication of sensor data being saturated, can cause result instability */
bool data_saturated;
/** Indication of bad data quality that may be addressed by restarting the service to recalibrate the sensor */
bool data_quality_warning;
/** Number of detected peaks returned to application. Maximum is number of requested peaks.*/
uint16_t number_of_peaks;
/** Indicating if any measurement samples are above the threshold.*/
bool measurement_sample_above_threshold;
/** The closest measurement distance above the threshold. Only valid if any measurement samples are above
* threshold. Note, it is valid even if no peaks are found.*/
float closest_detection_m;
} acc_detector_distance_result_info_t;
/**
* @brief Enum for threshold type
*/
typedef enum
{
ACC_DETECTOR_DISTANCE_THRESHOLD_TYPE_FIXED,
ACC_DETECTOR_DISTANCE_THRESHOLD_TYPE_RECORDED,
ACC_DETECTOR_DISTANCE_THRESHOLD_TYPE_CFAR
} acc_detector_distance_threshold_type_t;
/**
* @brief Enum for peak sorting algorithms
*/
typedef enum
{
/* Return peaks with the closest detection first. */
ACC_DETECTOR_DISTANCE_PEAK_SORTING_CLOSEST_FIRST,
/* Return peaks with the peak with the highest amplitude first. */
ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST_FIRST,
/* Return peaks with the peak from the strongest reflector first.
The decrease in amplitude over distance is accounted for.
Cannot be combined with negative start range. */
ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST_REFLECTOR_FIRST,
/* Return peaks with the peak from the strongest flat reflector first.
The decrease in amplitude over distance is accounted for.
Cannot be combined with negative start range. */
ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST_FLAT_REFLECTOR_FIRST
} acc_detector_distance_peak_sorting_t;
/**
* @brief Distance detector handle
*/
struct acc_detector_distance_handle;
typedef struct acc_detector_distance_handle *acc_detector_distance_handle_t;
/**
* @brief Distance detector configuration container
*/
struct acc_detector_distance_configuration;
typedef struct acc_detector_distance_configuration *acc_detector_distance_configuration_t;
/**
* @brief Result type for distance detector
*
* @param[out] amplitude Absolute amplitude of peak
* @param[out] distance Distance to peak in meters
*/
typedef struct
{
uint16_t amplitude;
float distance_m;
} acc_detector_distance_result_t;
/**
* @brief A callback for retrieving the service data buffer that the detector is based on
*
* @param[in] data A pointer to the buffer with envelope data
* @param[in] data_length Length of the data buffer
*/
typedef void (*acc_detector_distance_service_data_callback_t)(const uint16_t *data, uint16_t data_length);
/**
* @brief Create a configuration for a distance detector
*
* @return Distance detector configuration, NULL if creation was not possible
*/
acc_detector_distance_configuration_t acc_detector_distance_configuration_create(void);
/**
* @brief Destroy a configuration for a distance detector
*
* @param[in] distance_configuration The configuration to destroy, set to NULL
*/
void acc_detector_distance_configuration_destroy(acc_detector_distance_configuration_t *distance_configuration);
/**
* @brief Create a distance detector with the provided configuration
*
* Only one distance detector may exist for a specific sensor at any given time and
* invalid configurations will not allow for a distance detector creation.
*
* @param[in] distance_configuration The distance detector configuration to create a distance detector with
* @return Distance detector handle, NULL if distance detector was not possible to create
*/
acc_detector_distance_handle_t acc_detector_distance_create(acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Destroy a distance detector identified with provided handle
*
* Destroy the context of a distance detector allowing another distance detector to be created using the
* same resources. The distance detector handle reference is set to NULL after destruction.
* If NULL is sent in, nothing happens
*
* @param[in] distance_handle A reference to the distance detector handle to destroy
*/
void acc_detector_distance_destroy(acc_detector_distance_handle_t *distance_handle);
/**
* @brief Activate the distance detector associated with the provided handle
*
* @param[in] distance_handle The distance detector handle for the distance detector to activate
* @return True if successful, otherwise false
*/
bool acc_detector_distance_activate(acc_detector_distance_handle_t distance_handle);
/**
* @brief Deactivate the distance detector associated with the provided handle
*
* @param[in] distance_handle The distance detector handle for the distance detector to deactivate
* @return True if successful, otherwise false
*/
bool acc_detector_distance_deactivate(acc_detector_distance_handle_t distance_handle);
/**
* @brief Reconfigure a distance detector with the provided configuration
*
* Only one distance detector may exist for a specific sensor at any given time.
* A distance detector may not be active when reconfiguring the detector.
* Invalid configurations will not allow for distance detector reconfiguration and
* the distance detector will be destroyed.
*
* NOTE! The old distance handle will be invalid after reconfigure.
*
* @param[in, out] distance_handle A reference to the distance detector handle to reconfigure
* @param[in] distance_configuration The distance detector configuration to reconfigure a distance detector with
* @return True if possible to reconfigure
*/
bool acc_detector_distance_reconfigure(acc_detector_distance_handle_t *distance_handle,
acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Get detector metadata
*
* The detector provides metadata after being created with information that could be relevant for an application.
*
* May only be called after a detector has been created.
*
* @param[in] distance_handle The distance detector handle to get metadata for
* @param[out] metadata Metadata are provided in this parameter
* @return True if successful
*/
bool acc_detector_distance_metadata_get(acc_detector_distance_handle_t distance_handle,
acc_detector_distance_metadata_t *metadata);
/**
* @brief Record background
*
* Must be called after @ref acc_detector_distance_create and before @ref acc_detector_distance_activate
* when ACC_DETECTOR_DISTANCE_THRESHOLD_TYPE_RECORDED is set.
*
* Can be called again to make a new recording. Detector has to be deactivated to record a new background.
*
* The background length can be retrieved from @ref acc_detector_distance_metadata_get.
*
* The result should typically be set to the detector by calling @ref acc_detector_distance_set_background
*
* @param[in] distance_handle The distance detector handle for the distance detector to record background for
* @param[out] background The recorded background will be stored here
* @param[in] background_length The length of the background
* @param[out] background_info Recorded background metadata, passing NULL is OK
* @return True if successful
*/
bool acc_detector_distance_record_background(acc_detector_distance_handle_t distance_handle,
uint16_t *background,
uint16_t background_length,
acc_detector_distance_recorded_background_info_t *background_info);
/**
* @brief Set a background
*
* Set a previously recorded background. The background can typically be generated using
* @ref acc_detector_distance_record_background. The background must have a length corresponding
* to the configuration that was used when creating the detector. For example, if the background
* was created using @ref acc_detector_distance_record_background, the configuration of the detector
* should be the same both when generating the background as when later setting it.
*
* Must always be called for detector to work in ACC_DETECTOR_DISTANCE_THRESHOLD_TYPE_RECORDED mode.
*
* Must be called after @ref acc_detector_distance_create and before @ref acc_detector_distance_activate
*
* The background length can be retrieved from @ref acc_detector_distance_metadata_get.
*
* @param[in] distance_handle The distance detector handle for the distance detector to set background for
* @param[in] background The background to be set
* @param[in] background_length The length of the background to be set
* @return True if successful
*/
bool acc_detector_distance_set_background(acc_detector_distance_handle_t distance_handle, const uint16_t *background, uint16_t background_length);
/**
* @brief Retrieve the next result from the distance detector
*
* May only be called after a distance detector has been activated, blocks
* the application until result is ready.
*
* When using CFAR threshold, no detections will be made outside of range
* [range_start + (guard / 2) + window, range_end - (guard / 2) - window], if only_lower_distances is not set.
* If only_lower_distances is set, no detections will be made outside of range
* [range_start + (guard / 2) + window, range_end].
*
* @param[in] distance_handle The distance detector handle for the distance detector to get next result for
* @param[out] result Distance detector results, can be NULL if no result is wanted
* @param[in] result_length Length of data array passed to function. Number of peaks returned <= result_length.
* @param[out] result_info Detector result info
* @return True if successful, otherwise false
*/
bool acc_detector_distance_get_next(acc_detector_distance_handle_t distance_handle,
acc_detector_distance_result_t *result,
uint16_t result_length,
acc_detector_distance_result_info_t *result_info);
/**
* @brief Get the sensor ID for the sensor to be configured
*
* @param[in] distance_configuration The detector distance configuration to get the sensor ID from
* @return Sensor ID
*/
acc_sensor_id_t acc_detector_distance_configuration_sensor_get(acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set the sensor ID for the sensor to be configured
*
* @param[in] distance_configuration The detector distance configuration to set the sensor ID in
* @param[in] sensor_id The sensor ID to set
*/
void acc_detector_distance_configuration_sensor_set(acc_detector_distance_configuration_t distance_configuration, acc_sensor_id_t sensor_id);
/**
* @brief Get the requested start distance for measurement in meters
*
* @param[in] distance_configuration The detector distance configuration to get the requested start from
* @return Requested start in meters
*/
float acc_detector_distance_configuration_requested_start_get(acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set the requested start distance for measurement in meters
*
* @param[in] distance_configuration The detector distance configuration to set the requested start in
* @param[in] start_m The requested start in meters
*/
void acc_detector_distance_configuration_requested_start_set(acc_detector_distance_configuration_t distance_configuration, float start_m);
/**
* @brief Get the requested length of the measurement in meters
*
* @param[in] distance_configuration The detector distance configuration to get the requested length from
* @return Requested length in meters
*/
float acc_detector_distance_configuration_requested_length_get(acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set the requested length of the measurement in meters
*
* @param[in] distance_configuration The detector distance configuration to set the requested length in
* @param[in] length_m The requested length in meters
*/
void acc_detector_distance_configuration_requested_length_set(acc_detector_distance_configuration_t distance_configuration, float length_m);
/**
* @brief Get power save mode
*
* The power save modes of the sensor correspond to how much of the sensor hardware is shutdown
* between data aquisition. The supported power save modes are defined in
* @ref acc_power_save_mode_enum_t.
*
* @param[in] distance_configuration The detector distance configuration to get power save mode from
* @return Power save mode
*/
acc_power_save_mode_t acc_detector_distance_configuration_power_save_mode_get(acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set power save mode
*
* The power save modes of the sensor correspond to how much of the sensor hardware is shutdown
* between data aquisition. The supported power save modes are defined in
* @ref acc_power_save_mode_enum_t.
*
* @param[in] distance_configuration The detector distance configuration to set power save mode in
* @param[in] power_save_mode The power save mode to use
*/
void acc_detector_distance_configuration_power_save_mode_set(acc_detector_distance_configuration_t distance_configuration,
acc_power_save_mode_t power_save_mode);
/**
* @brief Get the sensor downsampling factor
*
* Gets the downsampling factor - the number of steps taken between each data point. A downsampling factor of 1 samples
* every possible point in the range. A downsampling factor of 2 samples every other point, and so on. Only 1, 2 and 4
* are valid numbers.
*
* @param[in] distance_configuration The detector distance configuration to get downsampling factor for
* @return Downsampling factor
*/
uint16_t acc_detector_distance_configuration_downsampling_factor_get(acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set the sensor downsampling factor
*
* Gets the downsampling factor - the number of steps taken between each data point. A downsampling factor of 1 samples
* every possible point in the range. A downsampling factor of 2 samples every other point, and so on. Only 1, 2 and 4
* are valid numbers.
*
* @param[in] distance_configuration The detector distance configuration to set downsampling factor for
* @param[in] downsampling_factor Downsampling factor
*/
void acc_detector_distance_configuration_downsampling_factor_set(acc_detector_distance_configuration_t distance_configuration,
uint16_t downsampling_factor);
/**
* @brief Get the service profile
*
* See @ref acc_service_profile_t for details
*
* @param[in] distance_configuration The detector distance configuration to get service profile for
* @return The service profile
*/
acc_service_profile_t acc_detector_distance_configuration_service_profile_get(acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set the service profile
*
* See @ref acc_service_profile_t for details
*
* @param[in] distance_configuration The detector distance configuration to set service profile for
* @param[in] service_profile
*/
void acc_detector_distance_configuration_service_profile_set(acc_detector_distance_configuration_t distance_configuration,
acc_service_profile_t service_profile);
/**
* @brief Get Maximize signal attenuation mode
*
* Will be true if Maximize signal attenuation mode is enabled, false otherwise
*
* @param[in] distance_configuration The detector distance configuration to get Maximize signal attenuation mode for
* @return Maximize signal attenuation mode
*/
bool acc_detector_distance_configuration_maximize_signal_attenuation_get(acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set Maximize signal attenuation mode
*
* Enable or disable Maximize signal attenuation mode to measure the direct leakage
*
* @param[in] distance_configuration The detector distance configuration to set Maximize signal attenuation mode in
* @param[in] maximize_signal_attenuation Maximize signal attenuation mode, true or false
*/
void acc_detector_distance_configuration_maximize_signal_attenuation_set(acc_detector_distance_configuration_t distance_configuration,
bool maximize_signal_attenuation);
/**
* @brief Get receiver gain setting
*
* Will be a value between 0.0 and 1.0, where 0.0 is the lowest gain and 1.0 is the highest gain.
*
* @param[in] distance_configuration The detector distance configuration to get gain setting for
* @return Receiver gain setting
*/
float acc_detector_distance_configuration_receiver_gain_get(acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set receiver gain setting
*
* Must be a value between 0.0 and 1.0, where 0.0 is the lowest gain and 1.0 is the highest gain.
*
* @param[in] distance_configuration The detector distance configuration to set gain setting for
* @param[in] gain Receiver gain setting, must be between 0.0 and 1.0
*/
void acc_detector_distance_configuration_receiver_gain_set(acc_detector_distance_configuration_t distance_configuration, float gain);
/**
* @brief Get the hardware accelerated average samples (HWAAS)
*
* Each data point can be sampled between 1 and 63 times, inclusive, and the sensor hardware then
* produces an average value of those samples. The time needed to measure a sweep is roughly proportional
* to the number of averaged samples. Hence, if there is a need to obtain a higher update rate, HWAAS
* could be decreased but this leads to lower SNR.
*
* @param[in] distance_configuration The distance configuration to get hardware accelerated average samples from
* @return Hardware accelerated average samples
*/
uint8_t acc_detector_distance_configuration_hw_accelerated_average_samples_get(
acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set the hardware accelerated average samples (HWAAS)
*
* Each data point can be sampled between 1 and 63 times, inclusive, and the sensor hardware then
* produces an average value of those samples. The time needed to measure a sweep is roughly proportional
* to the number of averaged samples. Hence, if there is a need to obtain a higher update rate, HWAAS
* could be decreased but this leads to lower SNR.
*
* @param[in] distance_configuration The distance configuration to set hardware accelerated average samples in
* @param[in] samples Hardware accelerated average samples
*/
void acc_detector_distance_configuration_hw_accelerated_average_samples_set(
acc_detector_distance_configuration_t distance_configuration, uint8_t samples);
/**
* @brief Get asynchronous measurement mode
*
* If set to true, asynchronous measurement is enabled.
* In synchronous mode the sensor will measure while the host is waiting.
* In asynchronous mode the sensor will measure while the host is working.
*
* This means that if in synchronous mode, the sensor will only measure during
* a get_next call, while in asynchronous mode the sensor can measure outside
* of the get_next call.
*
* @param[in] distance_configuration The configuration to get asynchronous_measurement mode from
* @return Asynchronous measurement mode
*/
bool acc_detector_distance_configuration_asynchronous_measurement_get(acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set asynchronous measurement mode
*
* If set to true, asynchronous measurement is enabled.
* In synchronous mode the sensor will measure while the host is waiting.
* In asynchronous mode the sensor will measure while the host is working.
*
* This means that if in synchronous mode, the sensor will only measure during
* a get_next call, while in asynchronous mode the sensor can measure outside
* of the get_next call.
*
* @param[in] distance_configuration The configuration to set asynchronous_measurement mode in
* @param[in] asynchronous_measurement asynchronous measurement mode, true or false
*/
void acc_detector_distance_configuration_asynchronous_measurement_set(acc_detector_distance_configuration_t distance_configuration,
bool asynchronous_measurement);
/**
* @brief Get number of sweeps to calculate average for
*
* @param[in] distance_configuration The detector distance configuration to get sweep average for
* @return Number of sweeps to calculate average for
*/
uint16_t acc_detector_distance_configuration_sweep_averaging_get(
acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set number of sweeps to calculate average for
*
* @param[in] distance_configuration The detector distance configuration to set sweep average for
* @param[in] sweep_averaging Number of sweeps to calculate average for
*/
void acc_detector_distance_configuration_sweep_averaging_set(acc_detector_distance_configuration_t distance_configuration,
uint16_t sweep_averaging);
/**
* @brief Get threshold type
*
* @param[in] distance_configuration The detector distance configuration to set threshold type for
* @return Used threshold type
*/
acc_detector_distance_threshold_type_t acc_detector_distance_configuration_threshold_type_get(
acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set threshold type
*
* @param[in] distance_configuration The detector distance configuration to set threshold type for
* @param[in] threshold Threshold type to be used
*/
void acc_detector_distance_configuration_threshold_type_set(acc_detector_distance_configuration_t distance_configuration,
acc_detector_distance_threshold_type_t threshold);
/**
* @brief Get fixed threshold
*
* @param[in] distance_configuration The detector distance configuration to get fixed threshold from
* @return Fixed threshold
*/
uint16_t acc_detector_distance_configuration_fixed_threshold_get(acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set fixed threshold
*
* @param[in] distance_configuration The detector distance configuration to set fixed threshold in
* @param[in] threshold Fixed threshold to be used by the detector
*/
void acc_detector_distance_configuration_fixed_threshold_set(acc_detector_distance_configuration_t distance_configuration,
uint16_t threshold);
/**
* @brief Get number of sweeps to record
*
* @param[in] distance_configuration The detector distance configuration to get number of sweeps to record for
* @return Number of sweeps to record
*/
uint16_t acc_detector_distance_configuration_record_background_sweeps_get(
acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set number of sweeps to record
*
* @param[in] distance_configuration The detector distance configuration to set number of sweeps to record in
* @param[in] record_sweeps Number of sweeps to record
*/
void acc_detector_distance_configuration_record_background_sweeps_set(
acc_detector_distance_configuration_t distance_configuration, uint16_t record_sweeps);
/**
* @brief Get threshold sensitivity
*
* Applicable when using recorded threshold or CFAR threshold
*
* @param[in] distance_configuration The detector distance configuration to get threshold sensitivity for
* @return Threshold sensitivity
*/
float acc_detector_distance_configuration_threshold_sensitivity_get(
acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set threshold sensitivity
*
* Applicable when using recorded threshold or CFAR threshold
*
* @param[in] distance_configuration The detector distance configuration to set threshold sensitivity in
* @param[in] sensitivity
*/
void acc_detector_distance_configuration_threshold_sensitivity_set(
acc_detector_distance_configuration_t distance_configuration,
float sensitivity);
/**
* @brief Get guard for CFAR threshold
*
* Range around the distance of interest that is omitted when calculating
* CFAR threshold. Can be low, ~0.04 m, for Profile 1, and should be
* increased for higher Profiles.
*
* @param[in] distance_configuration The detector distance configuration to get threshold guard for
* @return Threshold guard in meters
*/
float acc_detector_distance_configuration_cfar_threshold_guard_get(
acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set guard for CFAR threshold
*
* Range around the distance of interest that is omitted when calculating
* CFAR threshold. Can be low, ~0.04 cm, for Profile 1, and should be
* increased for higher Profiles.
*
* @param[in] distance_configuration The detector distance configuration to set threshold guard in
* @param[in] guard_m Threshold guard in meters
*/
void acc_detector_distance_configuration_cfar_threshold_guard_set(
acc_detector_distance_configuration_t distance_configuration,
float guard_m);
/**
* @brief Get window for CFAR threshold
*
* Range next to the CFAR guard from which the threshold level will be calculated.
*
* @param[in] distance_configuration The detector distance configuration to get threshold window for
* @return Threshold window in meters
*/
float acc_detector_distance_configuration_cfar_threshold_window_get(
acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set window for CFAR threshold
*
* Range next to the CFAR guard from which the threshold level will be calculated.
*
* @param[in] distance_configuration The detector distance configuration to set threshold window in
* @param[in] window_m Threshold window in meters
*/
void acc_detector_distance_configuration_cfar_threshold_window_set(
acc_detector_distance_configuration_t distance_configuration,
float window_m);
/**
* @brief Get if only lower distance is set
*
* Instead of determining the CFAR threshold from sweep amplitudes from
* distances both closer and father away, use only closer. Helpful e.g. for
* fluid level in small tanks, where many multipath signals can appear
* just after the main peak.
*
* @param[in] distance_configuration The detector distance configuration to get setting for
* @return True, if only lower distance is set
*/
bool acc_detector_distance_configuration_cfar_threshold_only_lower_distance_get(
acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set only lower distance
*
* Instead of determining the CFAR threshold from sweep amplitudes from
* distances both closer and father away, use only closer. Helpful e.g. for
* fluid level in small tanks, where many multipath signals can appear
* just after the main peak.
*
* @param[in] distance_configuration The detector distance configuration to set setting for
* @param[in] only_lower_distance True if only lower distances should be used
*/
void acc_detector_distance_configuration_cfar_threshold_only_lower_distance_set(
acc_detector_distance_configuration_t distance_configuration,
bool only_lower_distance);
/**
* @brief Get peak sorting algorithm
*
* Peak sorting algoritm specifies in what order peaks should be reported back to the application.
*
* @param[in] distance_configuration The detector distance configuration to get peak sorting algorithm from
* @return Peak sorting algorithm
*/
acc_detector_distance_peak_sorting_t acc_detector_distance_configuration_peak_sorting_get(
acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set peak sorting algorithm to be used
*
* Peak sorting algoritm specifies in what order peaks should be reported back to the application.
*
* @param[in] distance_configuration The detector distance configuration to set peak sorting algorithm in
* @param[in] peak_sorting Peak sorting algorithm to be used
*/
void acc_detector_distance_configuration_peak_sorting_set(acc_detector_distance_configuration_t distance_configuration,
acc_detector_distance_peak_sorting_t peak_sorting);
/**
* @brief Get peak merge limit in meters
*
* Defining minimum distance between peaks to be considered individual peaks
*
* @param[in] distance_configuration The detector distance configuration to get peak merge limit from
* @return Peak merge limit in meters
*/
float acc_detector_distance_configuration_peak_merge_limit_get(acc_detector_distance_configuration_t distance_configuration);
/**
* @brief Set peak merge limit in meters
*
* Defining minimum distance between peaks to be considered individual peaks
*
* @param[in] distance_configuration The detector distance configuration to set peak merge limit in
* @param[in] peak_merge_limit_m Peak merge limit in meters
*/
void acc_detector_distance_configuration_peak_merge_limit_set(acc_detector_distance_configuration_t distance_configuration,
float peak_merge_limit_m);
/**
* @brief Set a callback function to get the service data
*
* A callback can be used to get the envelope service buffer that the detector is based on.
* The data is the unprocessed envelope data that is fed into the distance algorithm.
* Set service_data_callback to NULL to disable callback.
*
* @param[in] distance_configuration The configuration to set the service data callback for
* @param[in] service_data_callback The callback to get service data
*/
void acc_detector_distance_configuration_service_data_callback_set(
acc_detector_distance_configuration_t distance_configuration,
acc_detector_distance_service_data_callback_t service_data_callback);
/**
* @brief Set the maximum unambiguous range
*
* Experimental.
*
* See acc_service_mur_set() for more detailed information.
*
* @param[in] distance_configuration The configuration
* @param[in] max_unambiguous_range The desired maximum unambiguous range
*/
void acc_detector_distance_configuration_mur_set(acc_detector_distance_configuration_t distance_configuration,
acc_service_mur_t max_unambiguous_range);
/**
* @brief Get the maximum unambiguous range
*
* Experimental.
*
* See acc_service_mur_get() for more detailed information.
*
* @param[in] distance_configuration The configuration
* @return Maximum unambiguous range
*/
acc_service_mur_t acc_detector_distance_configuration_mur_get(acc_detector_distance_configuration_t distance_configuration);
/**
* @}
*/
#endif

View File

@ -0,0 +1,582 @@
// Copyright (c) Acconeer AB, 2019-2022
// All rights reserved
#ifndef ACC_DETECTOR_PRESENCE_H_
#define ACC_DETECTOR_PRESENCE_H_
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "acc_definitions_a111.h"
#include "acc_definitions_common.h"
/**
* @defgroup Presence Presence Detector
* @ingroup Detectors
*
* @brief Presence detector API description
*
* @{
*/
/**
* @brief Presence detector handle
*/
struct acc_detector_presence_handle;
typedef struct acc_detector_presence_handle *acc_detector_presence_handle_t;
/**
* @brief Presence detector configuration container
*/
struct acc_detector_presence_configuration;
typedef struct acc_detector_presence_configuration *acc_detector_presence_configuration_t;
/**
* @brief Parameter structure for data filtering settings
*/
typedef struct
{
/** Time constant in s for inter-frame signal smoothing after the bandpass filtering */
float inter_frame_deviation_time_const;
/** Low pass cutoff frequency in Hz for inter-frame signal bandpass filtering */
float inter_frame_fast_cutoff;
/** High pass cutoff frequency in Hz for inter-frame signal bandpass filtering */
float inter_frame_slow_cutoff;
/** Time constant in s for inter-frame signal smoothing */
float intra_frame_time_const;
/** Weight between 0 and 1 for presence score interpolation between the inter-frame and intra-frame signals */
float intra_frame_weight;
/** Time constant in s for smoothing of the presence score */
float output_time_const;
} acc_detector_presence_configuration_filter_parameters_t;
/**
* @brief Presence detector results container
*/
typedef struct
{
/** True if presence was detected, False otherwise */
bool presence_detected;
/** A measure of the amount of motion detected */
float presence_score;
/** The distance, in meters, to the detected object */
float presence_distance;
/** Indication of a sensor communication error, detector probably needs to be restarted */
bool sensor_communication_error;
/** Indication of sensor data being saturated, can cause result instability */
bool data_saturated;
} acc_detector_presence_result_t;
/**
* @brief A callback for retrieving the service data buffer that the detector is based on
*
* @param[in] data A pointer to the buffer with sparse data
* @param[in] data_size Size of the data buffer in bytes
* @param[in] client_reference Pointer to a client reference
*/
typedef void (*acc_detector_presence_service_data_callback_t)(const uint16_t *data, size_t data_size, void *client_reference);
/**
* @brief Create a configuration for a presence detector
*
* @return Presence detector configuration, NULL if creation was not possible
*/
acc_detector_presence_configuration_t acc_detector_presence_configuration_create(void);
/**
* @brief Destroy a presence detector configuration
*
* @param[in] presence_configuration The configuration to destroy, set to NULL
*/
void acc_detector_presence_configuration_destroy(acc_detector_presence_configuration_t *presence_configuration);
/**
* @brief Create a presence detector with the provided configuration
*
* Only one presence detector may exist for a specific sensor at any given time and
* invalid configurations will not allow for presence detector creation.
*
* @param[in] presence_configuration The presence detector configuration to create a presence detector with
* @return Presence detector handle, NULL if presence detector was not possible to create
*/
acc_detector_presence_handle_t acc_detector_presence_create(acc_detector_presence_configuration_t presence_configuration);
/**
* @brief Destroy a presence detector identified with the provided handle
*
* Destroy the context of a presence detector allowing another presence detector to be created using the
* same resources. The presence detector handle reference is set to NULL after destruction.
* If NULL is sent in, nothing happens.
*
* @param[in] presence_handle A reference to the presence detector handle to destroy
*/
void acc_detector_presence_destroy(acc_detector_presence_handle_t *presence_handle);
/**
* @brief Reconfigure a presence detector with the provided configuration
*
* Only one presence detector may exist for a specific sensor at any given time and
* invalid reconfigurations will not allow for presence detector creation.
*
* @param[in] presence_handle A reference to the presence detector handle to reconfigure
* @param[in] presence_configuration The presence detector configuration to reconfigure a presence detector with
* @return True if possible to reconfigure
*/
bool acc_detector_presence_reconfigure(acc_detector_presence_handle_t *presence_handle,
acc_detector_presence_configuration_t presence_configuration);
/**
* @brief Activate the presence detector associated with the provided handle
*
* @param[in] presence_handle The presence detector handle for the presence detector to activate
* @return True if successful, otherwise false
*/
bool acc_detector_presence_activate(acc_detector_presence_handle_t presence_handle);
/**
* @brief Deactivate the presence detector associated with the provided handle
*
* @param[in] presence_handle The presence detector handle for the presence detector to deactivate
* @return True if successful, otherwise false
*/
bool acc_detector_presence_deactivate(acc_detector_presence_handle_t presence_handle);
/**
* @brief Retrieve the next result from the presence detector
*
* May only be called after a presence detector has been activated, blocks
* the application until a result is ready. Can still be called after vector
* output mode has been selected.
*
* @param[in] presence_handle The presence detector handle for the presence detector to get the next result for
* @param[out] result Presence detector results, can be NULL if no result is wanted.
* @return True if successful, otherwise false
*/
bool acc_detector_presence_get_next(acc_detector_presence_handle_t presence_handle, acc_detector_presence_result_t *result);
/**
* @brief Retrieve the next distance point vector from the presence detector
*
* May only be called after a presence detector has been activated, blocks
* the application until a result is ready. Vector output mode has to be set
* to true with the function @ref acc_detector_presence_configuration_vector_output_mode_set,
* otherwise returns with an error. Memory is owned by the detector and the client receives a pointer.
*
* @param[in] presence_handle The presence detector handle for the presence detector to get the next result for
* @param[out] distance_point_vector_length The number of elements in the distance_point_vector, can be NULL if no result is wanted
* @param[out] distance_point_vector The distance point vector, can be NULL if no result is wanted
* @param[out] result Presence detector results, same as result from acc_detector_presence_get_next
* @return True if successful, otherwise false
*/
bool acc_detector_presence_distance_point_vector_get_next(acc_detector_presence_handle_t presence_handle,
uint16_t *distance_point_vector_length,
float **distance_point_vector,
acc_detector_presence_result_t *result);
/**
* @brief Get start of sweep in m
*
* @param[in] configuration The configuration to get the sweep start for
* @return requested sweep start in m
*/
float acc_detector_presence_configuration_start_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Set start of sweep in m
*
* @param[in] configuration The configuration to set the sweep start for
* @param[in] start The requested sweep start in m
*/
void acc_detector_presence_configuration_start_set(acc_detector_presence_configuration_t configuration, float start);
/**
* @brief Get length of sweep in m
*
* @param[in] configuration The configuration to get the sweep length for
* @return requested sweep length in m
*/
float acc_detector_presence_configuration_length_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Set length of sweep in m
*
* @param[in] configuration The configuration to set the requested sweep length for
* @param[in] length The requested sweep length in m
*/
void acc_detector_presence_configuration_length_set(acc_detector_presence_configuration_t configuration, float length);
/**
* @brief Get sensor ID
*
* @param[in] configuration The configuration to get the sensor ID for
* @return sensor ID
*/
acc_sensor_id_t acc_detector_presence_configuration_sensor_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Set sensor ID
*
* @param[in] configuration The configuration to set the sensor ID for
* @param[in] sensor_id The sensor ID
*/
void acc_detector_presence_configuration_sensor_set(acc_detector_presence_configuration_t configuration, acc_sensor_id_t sensor_id);
/**
* @brief Get detection threshold
*
* @param[in] configuration The configuration to get the detection threshold for
* @return detection threshold
*/
float acc_detector_presence_configuration_detection_threshold_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Set detection threshold
*
* @param[in] configuration The configuration to set the detection threshold for
* @param[in] detection_threshold The threshold
*/
void acc_detector_presence_configuration_detection_threshold_set(acc_detector_presence_configuration_t configuration,
float detection_threshold);
/**
* @brief Get detection update rate
*
* Set the update rate of which the client call the detector to produce data. It's the clients responsibility
* to keep the configured timing.
*
* @param[in] configuration The configuration to get the detection update rate for
* @return detection update rate
*/
float acc_detector_presence_configuration_update_rate_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Set detection update rate
*
* Set the update rate of which the client call the detector to produce data. It's the clients responsibility
* to keep the configured timing.
*
* @param[in] configuration The configuration to set the detection update rate for
* @param[in] update_rate
*/
void acc_detector_presence_configuration_update_rate_set(acc_detector_presence_configuration_t configuration,
float update_rate);
/**
* @brief Get the number of sweeps per frame
*
* @param[in] configuration The configuration to get the number of sweeps per frame for
* @return The number of sweeps per frame
*/
uint16_t acc_detector_presence_configuration_sweeps_per_frame_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Set the number of sweeps per frame
*
* @param[in] configuration The configuration to set the number of sweeps per frame for
* @param[in] sweeps_per_frame The requested number of sweeps per frame
*/
void acc_detector_presence_configuration_sweeps_per_frame_set(acc_detector_presence_configuration_t configuration,
uint16_t sweeps_per_frame);
/**
* @brief Get the sweep rate
*
* Gets the requested sweep rate. Values of zero of lower are treated as the maximum possible rate.
*
* @param[in] configuration The configuration to get the sweep rate from
* @return sweep_rate The sweep rate
*/
float acc_detector_presence_configuration_sweep_rate_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Set sweep rate
*
* Sets the requested sweep rate. Values of zero of lower are treated as the maximum possible rate.
*
* @param[in] configuration The configuration to set the sweep rate in
* @param[in] sweep_rate The sweep rate
*/
void acc_detector_presence_configuration_sweep_rate_set(acc_detector_presence_configuration_t configuration, float sweep_rate);
/**
* @brief Get sensor data filtering parameters
*
* See @ref acc_detector_presence_configuration_filter_parameters_set
*
* @param[in] configuration The configuration to get the filter parameters for
* @return The filter parameters, see @ref acc_detector_presence_configuration_filter_parameters_t
*/
acc_detector_presence_configuration_filter_parameters_t acc_detector_presence_configuration_filter_parameters_get(
acc_detector_presence_configuration_t configuration);
/**
* @brief Set sensor data filtering parameters
*
* Set filter parameters for the sensor data filtering that is performed before presence detection thresholding.
*
* @param[in] configuration The configuration to set the filter parameters for
* @param[in] filter_parameters The filter parameter structure, see @ref acc_detector_presence_configuration_filter_parameters_t
*/
void acc_detector_presence_configuration_filter_parameters_set(acc_detector_presence_configuration_t configuration,
const acc_detector_presence_configuration_filter_parameters_t *filter_parameters);
/**
* @brief Get the number of principal components removed in the PCA based noise reduction
*
* @param[in] configuration The configuration to get the number of principal components of noise to remove for
* @return The number of principal components of noise to remove, between 0 and 2
*/
uint8_t acc_detector_presence_configuration_nbr_removed_pc_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Set the number of principal components removed in the PCA based noise reduction
*
* Sets the number of principal components removed in the PCA based noise reduction.
* Filters out static reflections.
* Setting to 0 (default) disables the PCA based noise reduction completely.
* For more information on the PCA based noise reduction algorithm, see
* <a href="https://acconeer-python-exploration.readthedocs.io/en/latest/processing/
* presence_detection_sparse.html#pca-based-noise-reduction">Read-the-Docs</a>
*
* @param[in] configuration The configuration to set the number of principal components of noise to remove for
* @param[in] nbr_removed_pc The number of principal components of noise to remove, between 0 and 2
*/
void acc_detector_presence_configuration_nbr_removed_pc_set(acc_detector_presence_configuration_t configuration, uint8_t nbr_removed_pc);
/**
* @brief Get power save mode
*
* @param[in] configuration The configuration to get the power save mode for
* @return power save mode
*/
acc_power_save_mode_t acc_detector_presence_configuration_power_save_mode_get(
acc_detector_presence_configuration_t configuration);
/**
* @brief Set power save mode
*
* @param[in] configuration The configuration to set the power save mode for
* @param[in] power_save_mode The power save mode
*/
void acc_detector_presence_configuration_power_save_mode_set(acc_detector_presence_configuration_t configuration,
acc_power_save_mode_t power_save_mode);
/**
* @brief Get the current service profile used by the detector
*
* See @ref acc_service_profile_t for details
*
* @param[in] configuration The configuration to get a profile from
* @return The current profile, 0 if configuration is invalid
*/
acc_service_profile_t acc_detector_presence_configuration_service_profile_get(
acc_detector_presence_configuration_t configuration);
/**
* @brief Set a service profile to be used by the detector
*
* See @ref acc_service_profile_t for details
*
* @param[in] configuration The configuration to set a profile for
* @param[in] service_profile The profile to set
*/
void acc_detector_presence_configuration_service_profile_set(acc_detector_presence_configuration_t configuration,
acc_service_profile_t service_profile);
/**
* @brief Get the current receiver gain used by the detector
*
* @param[in] configuration The configuration to get gain from
* @return The current gain
*/
float acc_detector_presence_configuration_receiver_gain_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Set a receiver gain to be used by the detector
*
* @param[in] configuration The configuration to set gain for
* @param[in] gain The gain to set
*/
void acc_detector_presence_configuration_receiver_gain_set(acc_detector_presence_configuration_t configuration,
float gain);
/**
* @brief Get the sensor downsampling factor
*
* Gets the downsampling factor - the number of steps taken between each data point. A downsampling factor of 1 samples
* every possible point in the range. A downsampling factor of 2 samples every other point, and so on.
*
* In the sparse service, the base step length is ~6cm. Thus, for example setting downsampling factor to 3 makes
* the distance between two points in the measured range ~18cm.
*
* @param[in] configuration The configuration to get downsampling factor from
* @return The downsampling factor
*/
uint16_t acc_detector_presence_configuration_downsampling_factor_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Set the sensor downsampling factor
*
* Sets the downsampling factor - the number of steps taken between each data point. A downsampling factor of 1 samples
* every possible point in the range. A downsampling factor of 2 samples every other point, and so on.
*
* In the sparse service, the base step length is ~6cm. Thus, for example setting downsampling factor to 3 makes
* the distance between two points in the measured range ~18cm.
*
* The sparse service supports setting an arbitrary downsampling factor of at least 1.
*
* @param[in] configuration The configuration to set downsampling factor in
* @param[in] downsampling_factor The downsampling factor
*/
void acc_detector_presence_configuration_downsampling_factor_set(acc_detector_presence_configuration_t configuration, uint16_t downsampling_factor);
/**
* @brief Get the hardware accelerated average samples
*
* Each data point can be sampled between 1 and 63 times, inclusive, and the sensor hardware then
* produces an average value of those samples. The time needed to measure a sweep is roughly proportional
* to the number of averaged samples. Hence, if there is a need to obtain a higher update rate, HWAAS
* could be decreased but this leads to lower SNR.
*
* @param[in] configuration The configuration to get hardware accelerated average samples from
* @return Hardware accelerated average samples
*/
uint8_t acc_detector_presence_configuration_hw_accelerated_average_samples_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Set the hardware accelerated average samples
*
* Each data point can be sampled between 1 and 63 times, inclusive, and the sensor hardware then
* produces an average value of those samples. The time needed to measure a sweep is roughly proportional
* to the number of averaged samples. Hence, if there is a need to obtain a higher update rate, HWAAS
* could be decreased but this leads to lower SNR.
*
* @param[in] configuration The configuration to set hardware accelerated average samples in
* @param[in] samples Hardware accelerated average samples
*/
void acc_detector_presence_configuration_hw_accelerated_average_samples_set(acc_detector_presence_configuration_t configuration, uint8_t samples);
/**
* @brief Get asynchronous measurement mode
*
* If set to true, asynchronous measurement is enabled.
* In synchronous mode the sensor will measure while the host is waiting.
* In asynchronous mode the sensor will measure while the host is working.
*
* This means that if in synchronous mode, the sensor will only measure during
* a get_next call, while in asynchronous mode the sensor can measure outside
* of the get_next call.
*
* @param[in] configuration The configuration to get asynchronous_measurement mode from
* @return Asynchronous measurement mode
*/
bool acc_detector_presence_configuration_asynchronous_measurement_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Set asynchronous measurement mode
*
* If set to true, asynchronous measurement is enabled.
* In synchronous mode the sensor will measure while the host is waiting.
* In asynchronous mode the sensor will measure while the host is working.
*
* This means that if in synchronous mode, the sensor will only measure during
* a get_next call, while in asynchronous mode the sensor can measure outside
* of the get_next call.
*
* @param[in] configuration The configuration to set asynchronous_measurement mode in
* @param[in] asynchronous_measurement asynchronous measurement mode, true or false
*/
void acc_detector_presence_configuration_asynchronous_measurement_set(acc_detector_presence_configuration_t configuration,
bool asynchronous_measurement);
/**
* @brief Gets vector output mode
*
* vector_output_mode decides whether or not the presence detector should output a distance point vector
* from the function @ref acc_detector_presence_distance_point_vector_get_next.
*
* @param[in] configuration The configuration to get vector_output_mode from
* @return vector_output_mode
*/
bool acc_detector_presence_configuration_vector_output_mode_get(acc_detector_presence_configuration_t configuration);
/**
* @brief Sets vector output mode
*
* vector_output_mode decides whether or not the presence detector should output a distance point vector.
*
* @param[in] configuration The configuration to set vector_output_mode in
* @param[in] vector_output_mode The vector_output_mode
*/
void acc_detector_presence_configuration_vector_output_mode_set(acc_detector_presence_configuration_t configuration, bool vector_output_mode);
/**
* @brief Set a callback function to get the service data
*
* A callback can be used to get the sparse service buffer. The data is the sparse data that is fed into the presence algorithm
*
* @param[in] configuration The configuration to set vector_output_mode in
* @param[in] service_data_callback The callback to get service data
* @param[in] client_reference Pointer to a client reference
*/
void acc_detector_presence_configuration_set_service_data_callback(acc_detector_presence_configuration_t configuration,
acc_detector_presence_service_data_callback_t service_data_callback,
void *client_reference);
/**
* @}
*/
#endif

View File

@ -0,0 +1,312 @@
// Copyright (c) Acconeer AB, 2018-2022
// All rights reserved
#ifndef ACC_HAL_DEFINITIONS_H_
#define ACC_HAL_DEFINITIONS_H_
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "acc_definitions_common.h"
/**
* @brief Defines the largest allowed value of a sensor ID
*/
#define ACC_SENSOR_ID_MAX 42U
/**
* @brief Specifies the minimal size in bytes that SPI transfers must be able to handle
*/
#define ACC_SPI_TRANSFER_SIZE_REQUIRED 16
/**
* @brief Specifies the number of clock cycles needed for sensor to enter hibernate mode
*/
#define ACC_NBR_CLOCK_CYCLES_REQUIRED_HIBERNATE_ENTER 10
/**
* @brief Specifies the number of clock cycles needed for the first part of the sensor exiting hibernate mode
*/
#define ACC_NBR_CLOCK_CYCLES_REQUIRED_STEP_1_HIBERNATE_EXIT 3
/**
* @brief Specifies the number of clock cycles needed for the second part of the sensor exiting hibernate mode
*/
#define ACC_NBR_CLOCK_CYCLES_REQUIRED_STEP_2_HIBERNATE_EXIT (13 - ACC_NBR_CLOCK_CYCLES_REQUIRED_STEP_1_HIBERNATE_EXIT)
/**
* @brief Specifies the number of millisonds of delay needed for the Oscillator to stabilize when exiting hibernate mode
*/
#define ACC_WAIT_TIME_HIBERNATE_EXIT_MS 2
/**
* @defgroup OS OS Integration
* @ingroup Integration
*
* @brief Integration OS primitives
*
* @{
*/
/**
* @brief Definition of a memory allocation function
*
* Allocated memory should be suitably aligned for any built-in type. Returning NULL is seen as failure.
*/
typedef void *(*acc_os_mem_alloc_function_t)(size_t);
/**
* @brief Definition of a memory free function
*
* Free memory which is previously allocated.
*/
typedef void (*acc_os_mem_free_function_t)(void *);
/**
* @brief Definition of a time retrieval function
*
* The time returned must be in milliseconds.
*
* Must be implemented by integration.
*/
typedef uint32_t (*acc_os_get_time_function_t)(void);
/**
* @brief Struct that contains the implementation of os integration primitives
*/
typedef struct
{
acc_os_mem_alloc_function_t mem_alloc;
acc_os_mem_free_function_t mem_free;
acc_os_get_time_function_t gettime;
} acc_rss_integration_os_primitives_t;
/**
* @}
*/
/**
* @defgroup HAL Hardware Integration
* @ingroup Integration
*
* @brief Integration of Hardware Abstraction Layer for the radar sensor
*
* @{
*/
/**
* @brief Definition of a sensor power function
*
* These functions control the power of the sensor. It typically control PS_ENABLE
* and PMU_ENABLE. The hibernate functions should also toggle the CTRL pin.
*
* In the case of the power_on function:
* Any pending sensor interrupts should be cleared before returning from function.
*/
typedef void (*acc_hal_sensor_power_function_t)(acc_sensor_id_t sensor_id);
/**
* @brief Definition of a hal get frequency function
*
* This function shall return the frequency of the reference clock connected to the sensor.
*
*/
typedef float (*acc_hal_get_frequency_function_t)(void);
/**
* @brief Definition of a wait for sensor interrupt function
*
* This function shall wait at most timeout_ms for the interrupt to become active and
* then return true. It may return true immediately if an interrupt have
* occurred since last call to this function.
*
* If waited more than timeout_ms for the interrupt to become active it shall
* return false.
*
* Note that this function can be called with a timeout_ms = 0.
*
*/
typedef bool (*acc_hal_sensor_wait_for_interrupt_function_t)(acc_sensor_id_t sensor_id, uint32_t timeout_ms);
/**
* @brief Definition of a sensor transfer function
*
* This function shall transfer data to and from the sensor over spi. It's beneficial from a performance perspective
* to use dma if available.
* The buffer is naturally aligned to a maximum of 4 bytes.
*
*/
typedef void (*acc_hal_sensor_transfer_function_t)(acc_sensor_id_t sensor_id, uint8_t *buffer, size_t buffer_size);
/**
* @brief This struct contains function pointers that point to
* functions needed for communication with the radar sensor.
*/
typedef struct
{
acc_hal_sensor_power_function_t power_on;
acc_hal_sensor_power_function_t power_off;
acc_hal_sensor_power_function_t hibernate_enter;
acc_hal_sensor_power_function_t hibernate_exit;
acc_hal_sensor_wait_for_interrupt_function_t wait_for_interrupt;
acc_hal_sensor_transfer_function_t transfer;
acc_hal_get_frequency_function_t get_reference_frequency;
} acc_rss_integration_sensor_device_t;
/**
* @}
*/
/**
* @defgroup Properties Integration Properties
* @ingroup Integration
*
* @brief Integration specific properties that is used for configuration of RSS.
*
* Number of sensors connected to each board and the maximum buffer size that the
* spi driver can handle can be different between applications. These values shall
* be configured by the client.
*
* @{
*/
/**
* @brief This struct contains information about board properties that
* are needed by RSS.
*
* @ref sensor_count is the maximal sensor ID that the integration layer supports.
* This value must not exceed @ref ACC_SENSOR_ID_MAX.
*
* @ref max_spi_transfer_size is the maximal buffer size that is supported
* by the implementation of @ref acc_hal_sensor_transfer_function_t.
* This value must not be smaller than @ref ACC_SPI_TRANSFER_SIZE_REQUIRED.
*/
typedef struct
{
uint32_t sensor_count;
size_t max_spi_transfer_size;
} acc_rss_integration_properties_t;
/**
* @}
*/
/**
* @defgroup Opimization Optional optimizations
* @ingroup Integration
*
* @brief Support for different optimizations
*
* @{
*/
/**
* @brief Definition of an optimized 16-bit sensor transfer function
*
* This function shall transfer data to and from the sensor over spi with 16 bits data size.
* It's beneficial from a performance perspective to use dma if available.
* The buffer is naturally aligned to a minimum of 4 bytes.
*
* If defined it will be used instead of the (8-bit) transfer function @ref acc_hal_sensor_transfer_function_t
*
*/
typedef void (*acc_sensor_transfer16_function_t)(acc_sensor_id_t sensor_id, uint16_t *buffer, size_t buffer_length);
/**
* @brief This struct contains function pointers that are optional to support different optimizations
*
* Optional
*
* This struct contains function pointers to support different optimizations.
* These optimizations can be utilized for some integrations.
* If they are defined, they will override the corresponding non-optimized function.
*
* For example, if the transfer16 function is implemented, it will be used instead of the transfer function.
*/
typedef struct
{
acc_sensor_transfer16_function_t transfer16;
} acc_optimization_t;
/**
* @}
*/
/**
* @defgroup Log Log Integration
* @ingroup Integration
*
* @brief Integration for log functionality
*
* @{
*/
/**
* @brief Definition of a log function
*/
typedef void (*acc_log_function_t)(acc_log_level_t level, const char *module, const char *format, ...);
/**
* @brief This struct contains information about log properties and functions
* needed by RSS
*/
typedef struct
{
acc_log_level_t log_level;
acc_log_function_t log;
} acc_rss_integration_log_t;
/**
* @}
*/
/**
* @defgroup Integration Integration
* @brief Driver and OS Integration
*
* @{
*/
/**
* @brief This struct contains the information about the sensor
* integration that RSS needs.
*/
typedef struct
{
acc_rss_integration_properties_t properties;
acc_rss_integration_os_primitives_t os;
acc_rss_integration_sensor_device_t sensor_device;
acc_rss_integration_log_t log;
acc_optimization_t optimization;
} acc_hal_t;
/**
* @}
*/
#endif

View File

@ -0,0 +1,148 @@
// Copyright (c) Acconeer AB, 2018-2022
// All rights reserved
#ifndef ACC_RSS_H_
#define ACC_RSS_H_
#include <stdbool.h>
#include "acc_definitions_a111.h"
#include "acc_definitions_common.h"
#include "acc_hal_definitions.h"
/**
* @defgroup RSS Radar System Software, RSS
*
* @brief Acconeer Radar System Software, RSS
*
* @{
*/
/**
* @brief Activate the Acconeer Radar System Software, RSS
*
* A HAL struct containing integration functions (such as 'wait_for_interrupt', 'mem_alloc' and 'log')
* needed by RSS must first be populated and then sent in. See 'acc_definitions_common.h' for a full list
* of functions needed.
*
* This function must be called before any other RSS function. If it is not, or it failed,
* calling any other RSS function is undefined behaviour.
*
* @param[in] hal Reference to a HAL struct containing integration functions that is needed by RSS
* @return True if RSS activated successfully
*/
bool acc_rss_activate(const acc_hal_t *hal);
/**
* @brief Deactivate the Acconeer Radar System Software, RSS
*/
void acc_rss_deactivate(void);
/**
* @brief Get the sensor calibration context
*
* Must be called after RSS has been activated.
* A calibration will be done for the specific sensor.
* A successful call to this function will also trigger context reset.
*
* @param[in] sensor_id The sensor to get the context for
* @param[out] calibration_context Reference to struct where the context will be stored
* @return True if successful, false otherwise
*/
bool acc_rss_calibration_context_get(acc_sensor_id_t sensor_id, acc_calibration_context_t *calibration_context);
/**
* @brief Set a previously saved sensor calibration context and verify that the sensor calibration context is valid
*
* Must be called after RSS has been activated.
* No active service is allowed on the sensor when setting the context.
* If this function is successfully called, a new sensor calibration will not be done during service creation step.
*
* @param[in] sensor_id The sensor to set the context on
* @param[in] calibration_context The calibration context to set
*
* @return True if successful, false otherwise
*/
bool acc_rss_calibration_context_set(acc_sensor_id_t sensor_id, acc_calibration_context_t *calibration_context);
/**
* @brief Set a previously saved sensor calibration context, ignore the result from calibration context validation
*
* Must be called after RSS has been activated. Must only be used with a fresh calibration context
* immediately after a successfull call to acc_rss_calibration_context_get.
* No active service is allowed on the sensor when setting the context.
* If this function is successfully called, a new sensor calibration will not be done during service creation step.
*
* @param[in] sensor_id The sensor to set the context on
* @param[in] calibration_context The calibration context to set
*
* @return True if successful, false otherwise
*/
bool acc_rss_calibration_context_forced_set(acc_sensor_id_t sensor_id, acc_calibration_context_t *calibration_context);
/**
* @brief Reset a calibration done on the specific sensor (or remove a previously set calibration context)
*
* No active service is allowed on the sensor when resetting the calibration
* If this function is successfully called, a new sensor calibration will be done during service creation step.
*
* @param[in] sensor_id The sensor to reset the calibration on
*
* @return True if successful, false otherwise
*/
bool acc_rss_calibration_reset(acc_sensor_id_t sensor_id);
/**
* @brief Enable or disable check of sensor id when creating a service or detector
*
* Must be called after RSS has been activated and before creating several services or detectors for the same sensor id.
* After this function is called, with enable override set to true, it is possible to create several services or
* detectors for the same sensor id. It is still only possible to have one service or detector per sensor id active
* at the same time.
*
* @param[in] enable_override True if the sensor id check override should be enabled
*/
void acc_rss_override_sensor_id_check_at_creation(bool enable_override);
/**
* @brief Check if a sensor is connected at the specified sensor id
*
* This function will try to communicate with the sensor at the specified sensor id.
* @details
* - This function must be called after @ref acc_rss_activate.
* - This function must be called before any service is created.
*
* @param[in] sensor_id The sensor to check the connection status for
* @param[out] connected True if a sensor is connected at the specified sensor id
*
* @return True if successful, false otherwise
*/
bool acc_rss_sensor_connected(acc_sensor_id_t sensor_id, bool *connected);
/**
* @brief Set the log level that determines when the integration HAL logger function is called
*
* This function enables adjustment of the log level after RSS has been activated. Shall be called when
* RSS is active as it has no effect otherwise. The severity of the logged messages is selected in the
* same way as for log.log_level in @ref acc_hal_t.
*
* @param[in] level The severity level for selection of log output via @ref acc_log_function_t.
*/
void acc_rss_log_level_set(acc_log_level_t level);
/**
* @}
*/
#endif

View File

@ -0,0 +1,227 @@
// Copyright (c) Acconeer AB, 2019-2022
// All rights reserved
#ifndef ACC_RSS_ASSEMBLY_TEST_H_
#define ACC_RSS_ASSEMBLY_TEST_H_
#include "acc_definitions_common.h"
#include <stdbool.h>
#define ACC_RSS_ASSEMBLY_TEST_MAX_NUMBER_OF_TESTS (20U)
/**
* @defgroup Assembly_test Assembly test
* @ingroup RSS
*
* @brief RSS Assembly test
*
* @{
*/
/**
* @brief The result of an assembly test run
*/
typedef struct
{
const char *test_name;
bool test_passed;
} acc_rss_assembly_test_result_t;
/**
* @brief Assembly test configuration container
*/
struct acc_rss_assembly_test_configuration;
typedef struct acc_rss_assembly_test_configuration *acc_rss_assembly_test_configuration_t;
/**
* @brief Create a configuration for an assembly test run
*
* @return An assembly test configuration, NULL if creation was not possible
*/
acc_rss_assembly_test_configuration_t acc_rss_assembly_test_configuration_create(void);
/**
* @brief Destroy an assembly test configuration
*
* The assembly test configuration reference is set to NULL after destruction.
*
* @param[in] configuration The configuration to destroy, set to NULL
*/
void acc_rss_assembly_test_configuration_destroy(acc_rss_assembly_test_configuration_t *configuration);
/**
* @brief Set the sensor id
*
* @param[in] configuration An assembly test configuration
* @param[in] sensor_id The sensor id to set
*/
void acc_rss_assembly_test_configuration_sensor_set(acc_rss_assembly_test_configuration_t configuration, acc_sensor_id_t sensor_id);
/**
* @brief Get the sensor id that is configured
*
* @param[in] configuration An assembly test configuration
* @return Sensor id
*/
acc_sensor_id_t acc_rss_assembly_test_configuration_sensor_get(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Enable the sensor communication read test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_communication_read_test_enable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Disable the sensor communication read test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_communication_read_test_disable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Enable the sensor communication write and read test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_communication_write_read_test_enable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Disable the sensor communication write and read test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_communication_write_read_test_disable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Enalbe the sensor communication interrupt test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_communication_interrupt_test_enable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Disable the sensor communication interrupt test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_communication_interrupt_test_disable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Enable the sensor communication hibernate test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_communication_hibernate_test_enable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Disable the sensor communication hibernate test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_communication_hibernate_test_disable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Enable the supply test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_supply_test_enable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Disable the supply test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_supply_test_disable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Enable the clock test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_clock_test_enable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Disable the clock test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_clock_test_disable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Enable the power cycle test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_power_cycle_test_enable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Disable the power cycle test
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_power_cycle_test_disable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Disable all tests
*
* @param[in] configuration An assembly test configuration
*/
void acc_rss_assembly_test_configuration_all_tests_disable(acc_rss_assembly_test_configuration_t configuration);
/**
* @brief Run assembly test
*
* This function executes a suite of tests suitable for PCB assembly testing.
*
* @details The caller need to allocate an array of assembly test results of at least the size
* of ACC_RSS_ASSEMBLY_TEST_MAX_NUMBER_OF_TESTS. The array size is to be provided in the
* nr_of_test_results parameter. If the size is not sufficiently large the test will
* fail.
*
* If a test fails to execute the return value will be set to false.
* If a test cannot pass its test limits the test_passed member of test_results will be
* set to false but the return value of this function will still be true.
*
* @param[in] test_configuration The test configuration
* @param[out] test_results Reference to struct where the test results will be stored
* @param[in,out] nr_of_test_results Input is the maximum number of items in the results array.
* Output is the actual number of test results available after
* the execution of the tests.
* @return True if successfully run, false otherwise
*/
bool acc_rss_assembly_test(acc_rss_assembly_test_configuration_t test_configuration, acc_rss_assembly_test_result_t *test_results,
uint16_t *nr_of_test_results);
/**
* @}
*/
#endif

View File

@ -0,0 +1,41 @@
// Copyright (c) Acconeer AB, 2019-2021
// All rights reserved
#ifndef ACC_RSS_DIAGNOSTICS_H_
#define ACC_RSS_DIAGNOSTICS_H_
#include "acc_definitions_common.h"
#include <stdbool.h>
/**
* @defgroup Diagnostic_test Diagnostic test
* @ingroup RSS
*
* @brief RSS Diagnostic test
*
* @{
*/
/**
* @brief Run diagnostic test
*
* This function executes a suite of tests for diagnostic testing of the A111 sensor.
*
* @details
* - This function must be called after #acc_rss_activate.
* - This function must be called before any service is created.
* - If a test fails to execute the return value will be set to false.
*
* @param[in] sensor_id The sensor to run diagnostic test on
* @return True if successfully run, false otherwise
*/
bool acc_rss_diagnostic_test(acc_sensor_id_t sensor_id);
/**
* @}
*/
#endif

View File

@ -0,0 +1,429 @@
// Copyright (c) Acconeer AB, 2018-2022
// All rights reserved
#ifndef ACC_SERVICE_H_
#define ACC_SERVICE_H_
#include <stdbool.h>
#include "acc_base_configuration.h"
#include "acc_definitions_a111.h"
#include "acc_definitions_common.h"
/**
* @defgroup Services Services
*
* @brief Radar services provided by Acconeer
*
* @defgroup Experimental Experimental
* @brief Features in an early version
*
* In our code you might encounter features tagged Experimental.
* This means that the feature in question is an early version that has a
* limited test scope, and the API and/or functionality might change in
* upcoming releases.
*
* The intention is to let users try these features out and we appreciate
* feedback.
*
* @defgroup Generic Generic Service API
* @ingroup Services
*
* @brief Generic service API description
*
* @{
*/
/**
* @brief Generic service configuration container
*/
struct acc_service_configuration;
typedef struct acc_service_configuration *acc_service_configuration_t;
/**
* @brief Generic service handle
*/
struct acc_service_handle;
typedef struct acc_service_handle *acc_service_handle_t;
/**
* @brief Create a service with the provided configuration
*
* Only one service may exist for a specific sensor at any given time,
* unless @ref acc_rss_override_sensor_id_check_at_creation has been invoked.
* Invalid configurations will not allow for service creation.
*
* @param[in] configuration The service configuration to create a service with
* @return Service handle, NULL if service was not possible to create
*/
acc_service_handle_t acc_service_create(acc_service_configuration_t configuration);
/**
* @brief Activate the service associated with the provided handle
*
* When activated, the application can get data from the service with the
* associated handle.
*
* @param[in] service_handle The service handle for the service to activate
* @return True if successful, false otherwise
*/
bool acc_service_activate(acc_service_handle_t service_handle);
/**
* @brief Deactivate the service associated with the provided handle
*
* @param[in] service_handle The service handle for the service to deactivate
* @return True if successful, false otherwise
*/
bool acc_service_deactivate(acc_service_handle_t service_handle);
/**
* @brief Destroy a service identified with the provided service handle
*
* Destroy the context of a service allowing another service to be created using the
* same resources. The service handle reference is set to NULL after destruction.
*
* @param[in] service_handle A reference to the service handle to destroy
*/
void acc_service_destroy(acc_service_handle_t *service_handle);
/**
* @brief Retrieve a base configuration from a service configuration
*
* The base configuration can be used to configure the service for different use cases.
* See @ref acc_base_configuration.h for configuration parameters.
*
* @param[in] service_configuration The service configuration to get a base configuration from
* @return Base configuration, NULL if the service configuration does not contain a base configuration
*/
acc_base_configuration_t acc_service_get_base_configuration(acc_service_configuration_t service_configuration);
/**
* @brief Get the sensor ID for the sensor to be configured
*
* @param[in] configuration The service configuration to get the sensor id from
* @return Sensor Id
*/
acc_sensor_id_t acc_service_sensor_get(acc_service_configuration_t configuration);
/**
* @brief Set the sensor ID for the sensor to be configured
*
* @param[in] configuration The service configuration to set the sensor id in
* @param[in] sensor_id The sensor id to set
*/
void acc_service_sensor_set(acc_service_configuration_t configuration, acc_sensor_id_t sensor_id);
/**
* @brief Get the requested start of the sweep
*
* @param[in] configuration The service configuration to get the requested start from
* @return Requested start
*/
float acc_service_requested_start_get(acc_service_configuration_t configuration);
/**
* @brief Set the requested start of the sweep
*
* @param[in] configuration The service configuration to set the requested start in
* @param[in] start_m The requested start in meters
*/
void acc_service_requested_start_set(acc_service_configuration_t configuration, float start_m);
/**
* @brief Get the requested length of the sweep
*
* @param[in] configuration The service configuration to get the requested length from
* @return Requested length
*/
float acc_service_requested_length_get(acc_service_configuration_t configuration);
/**
* @brief Set the requested length of the sweep
*
* @param[in] configuration The service configuration to set the requested length in
* @param[in] length_m The requested length in meters
*/
void acc_service_requested_length_set(acc_service_configuration_t configuration, float length_m);
/**
* @brief Set the service repetition mode to on demand
*
* In on demand mode, the sensor produces data when requested by the application.
* The application is also responsible for the timing between updates.
*
* This mode must be used if the configured length requires stitching in the service.
*
* @param[in] configuration The service configuration to set on demand mode in
*/
void acc_service_repetition_mode_on_demand_set(acc_service_configuration_t configuration);
/**
* @brief Set the service repetition mode to streaming mode
*
* The sensor produces data according to the configured update rate using sensor
* hardware timing which is very accurate.
*
* @param[in] configuration The service configuration to set streaming mode in
* @param[in] update_rate The output data rate from the service in hertz
*/
void acc_service_repetition_mode_streaming_set(acc_service_configuration_t configuration, float update_rate);
/**
* @brief Get power save mode
*
* The power save modes of the sensor correspond to how much of the sensor hardware is shutdown
* between data frame aquisition. The supported power save modes are defined in
* @ref acc_power_save_mode_enum_t.
*
* @param[in] configuration The service configuration to get power save mode for
* @return Power save mode
*/
acc_power_save_mode_t acc_service_power_save_mode_get(acc_service_configuration_t configuration);
/**
* @brief Set power save mode
*
* The power save modes of the sensor correspond to how much of the sensor hardware is shutdown
* between data frame aquisition. The supported power save modes are defined in
* @ref acc_power_save_mode_enum_t.
*
* @param[in] configuration The service configuration to set power save mode in
* @param[in] power_save_mode The power save mode to use
*/
void acc_service_power_save_mode_set(acc_service_configuration_t configuration,
acc_power_save_mode_t power_save_mode);
/**
* @brief Get receiver gain setting
*
* Will be a value between 0.0 and 1.0, where 0.0 is the lowest gain and 1.0 is the highest gain.
*
* @param[in] configuration The service configuration to get receiver gain setting for
* @return Receiver gain setting
*/
float acc_service_receiver_gain_get(acc_service_configuration_t configuration);
/**
* @brief Set receiver gain setting
*
* Must be a value between 0.0 and 1.0, where 0.0 is the lowest gain and 1.0 is the highest gain.
*
* @param[in] configuration The service configuration to set receiver gain setting in
* @param[in] gain Receiver gain setting, must be between 0.0 and 1.0
*/
void acc_service_receiver_gain_set(acc_service_configuration_t configuration, float gain);
/**
* @brief Get TX disable mode
*
* Will be true if TX is disabled, false otherwise.
*
* @param[in] configuration The service configuration to get TX disable mode for
* @return TX disable mode
*/
bool acc_service_tx_disable_get(acc_service_configuration_t configuration);
/**
* @brief Set TX disable mode
*
* If set to true, TX disable mode is enabled. This will disable the radio transmitter.
* To measure RX noise floor, it is recommended to also switch off internal
* noise level normalization (see each service if applicable).
*
* @param[in] configuration The service configuration to set TX disable mode in
* @param[in] tx_disable TX disable mode, true or false
*/
void acc_service_tx_disable_set(acc_service_configuration_t configuration, bool tx_disable);
/**
* @brief Get the hardware accelerated average samples (HWAAS)
*
* Each data point can be sampled between 1 and 63 times, inclusive, and the sensor hardware then
* produces an average value of those samples. The time needed to measure a sweep is roughly proportional
* to the number of averaged samples. Hence, if there is a need to obtain a higher update rate, HWAAS
* could be decreased but this leads to lower SNR.
*
* @param[in] configuration The service configuration to get hardware accelerated average samples from
* @return Hardware accelerated average samples
*/
uint8_t acc_service_hw_accelerated_average_samples_get(acc_service_configuration_t configuration);
/**
* @brief Set the hardware accelerated average samples (HWAAS)
*
* Each data point can be sampled between 1 and 63 times, inclusive, and the sensor hardware then
* produces an average value of those samples. The time needed to measure a sweep is roughly proportional
* to the number of averaged samples. Hence, if there is a need to obtain a higher update rate, HWAAS
* could be decreased but this leads to lower SNR.
*
* @param[in] configuration The service configuration to set hardware accelerated average samples in
* @param[in] samples Hardware accelerated average samples
*/
void acc_service_hw_accelerated_average_samples_set(acc_service_configuration_t configuration, uint8_t samples);
/**
* @brief Get asynchronous measurement mode
*
* If set to true, asynchronous measurement is enabled.
* In synchronous mode the sensor will generate sweep data while the host is waiting.
* In asynchronous mode the sensor will generate sweep data while the host is working.
*
* This means that if in synchronous mode, the sensor will only measure during
* a get_next call, while in asynchronous mode the sensor can measure outside
* of the get_next call.
*
* Setting asynchronous measurement to false (i.e using synchronous mode) is incompatible
* with repetition mode streaming where the sensor is in control of the update rate timing.
*
* @param[in] configuration The service configuration to get asynchronous_measurement mode from
* @return asynchronous measurement mode
*/
bool acc_service_asynchronous_measurement_get(acc_service_configuration_t configuration);
/**
* @brief Set asynchronous measurement mode
*
* If set to true, asynchronous measurement is enabled.
* In synchronous mode the sensor will generate sweep data while the host is waiting.
* In asynchronous mode the sensor will generate sweep data while the host is working.
*
* This means that if in synchronous mode, the sensor will only measure during
* a get_next call, while in asynchronous mode the sensor can measure outside
* of the get_next call.
*
* Setting asynchronous measurement to false (i.e using synchronous mode) is incompatible
* with repetition mode streaming where the sensor is in control of the update rate timing.
*
* @param[in] configuration The service configuration to set asynchronous_measurement mode in
* @param[in] asynchronous_measurement asynchronous measurement mode, true or false
*/
void acc_service_asynchronous_measurement_set(acc_service_configuration_t configuration, bool asynchronous_measurement);
/**
* @brief Get the currently used service profile
*
* See @ref acc_service_profile_t for details
*
* @param[in] service_configuration The configuration to get a profile for
* @return The current profile, 0 if configuration is invalid
*/
acc_service_profile_t acc_service_profile_get(acc_service_configuration_t service_configuration);
/**
* @brief Set a service profile
*
* See @ref acc_service_profile_t for details
*
* @param[in] service_configuration The configuration to set a profile for
* @param[in] profile The profile to set
*/
void acc_service_profile_set(acc_service_configuration_t service_configuration,
acc_service_profile_t profile);
/**
* @brief Get Maximize signal attenuation mode
*
* Will be true if Maximize signal attenuation mode is enabled, false otherwise
*
* @param[in] service_configuration The configuration to get Maximize signal attenuation mode for
* @return Maximize signal attenuation mode
*/
bool acc_service_maximize_signal_attenuation_get(acc_service_configuration_t service_configuration);
/**
* @brief Set Maximize signal attenuation mode
*
* Enable or disable Maximize signal attenuation mode to measure the direct leakage
*
* @param[in] service_configuration The configuration to set Maximize signal attenuation mode in
* @param[in] maximize_signal_attenuation Maximize signal attenuation mode, true or false
*/
void acc_service_maximize_signal_attenuation_set(acc_service_configuration_t service_configuration,
bool maximize_signal_attenuation);
/**
* @brief Set the maximum unambiguous range
*
* Sets the maximum unambiguous range (MUR), which in turn sets the maximum measurable
* distance (MMD).
*
* The MMD is the maximum value for the range end, i.e., the range start + length. The MMD
* is smaller than the MUR due to hardware limitations.
*
* The MUR is the maximum distance at which an object can be located to guarantee that its
* reflection corresponds to the most recent transmitted pulse. Objects farther away than
* the MUR may fold into the measured range. For example, with a MUR of 10 m, an object at
* 12 m could become visible at 2 m.
*
* A higher setting gives a larger MUR/MMD, but comes at a cost of increasing the
* measurement time for a sweep. The measurement time is approximately proportional to the
* MUR.
*
* This setting changes the pulse repetition frequency (PRF) of the radar system. The
* relation between PRF and MUR is
* MUR = c / (2 * PRF)
* where c is the speed of light.
*
* | Setting | MUR | MMD | PRF |
* |------------------:|-------:|-------:|---------:|
* | ACC_SERVICE_MUR_6 | 11.5 m | 7.0 m | 13.0 MHz |
* | ACC_SERVICE_MUR_9 | 17.3 m | 12.7 m | 8.7 MHz |
*
* It is not possible to change MUR for the IQ service.
*
* @param[in] service_configuration The configuration
* @param[in] max_unambiguous_range The desired maximum unambiguous range
*/
void acc_service_mur_set(acc_service_configuration_t service_configuration,
acc_service_mur_t max_unambiguous_range);
/**
* @brief Get the maximum unambiguous range
*
* This gets the maximum unambiguous range. For more information see acc_service_mur_set().
*
* @param[in] service_configuration The configuration
* @return Maximum unambiguous range
*/
acc_service_mur_t acc_service_mur_get(acc_service_configuration_t service_configuration);
/**
* @}
*/
#endif

View File

@ -0,0 +1,239 @@
// Copyright (c) Acconeer AB, 2018-2021
// All rights reserved
#ifndef ACC_SERVICE_ENVELOPE_H_
#define ACC_SERVICE_ENVELOPE_H_
#include <stdbool.h>
#include <stdint.h>
#include "acc_service.h"
/**
* @defgroup Envelope Envelope Service
* @ingroup Services
*
* @brief Envelope service API description
*
* @{
*/
/**
* @brief Metadata for the envelope service
*/
typedef struct
{
/** Start of sweep, derived from request set by @ref acc_service_requested_start_set */
float start_m;
/** Length of sweep, derived from request set by @ref acc_service_requested_length_set */
float length_m;
/** Number of elements in the envelope data array */
uint16_t data_length;
/** Number of stitches in the data */
uint16_t stitch_count;
/** Distance between adjacent data points */
float step_length_m;
} acc_service_envelope_metadata_t;
/**
* @brief Metadata for each result provided by the envelope service
*/
typedef struct
{
/** Indication of missed data from the sensor */
bool missed_data;
/** Indication of a sensor communication error, service probably needs to be restarted */
bool sensor_communication_error;
/** Indication of sensor data being saturated, can cause result instability */
bool data_saturated;
/** Indication of bad data quality that may be addressed by restarting the service to recalibrate the sensor */
bool data_quality_warning;
} acc_service_envelope_result_info_t;
/**
* @brief Create a configuration for an envelope service
*
* A configuration is created for the envelope service and populated
* with default values.
*
* @return Service configuration, NULL if creation was not possible
*/
acc_service_configuration_t acc_service_envelope_configuration_create(void);
/**
* @brief Destroy an envelope configuration
*
* Destroy an envelope configuration that is no longer needed, may be done even if a
* service has been created with the specific configuration and has not yet been destroyed.
* The service configuration reference is set to NULL after destruction.
*
* @param[in] service_configuration The configuration to destroy, set to NULL
*/
void acc_service_envelope_configuration_destroy(acc_service_configuration_t *service_configuration);
/**
* @brief Get the sensor downsampling factor
*
* Gets the downsampling factor - the number of steps taken between each data point. A downsampling factor of 1 samples
* every possible point in the range. A downsampling factor of 2 samples every other point, and so on.
*
* In the envelope service, the base step length is ~0.5mm. Thus, for example setting downsampling factor to 4
* makes the distance between two points in the measured range ~2mm.
*
* @param[in] service_configuration The configuration to get downsampling factor from
* @return The downsampling factor
*/
uint16_t acc_service_envelope_downsampling_factor_get(acc_service_configuration_t service_configuration);
/**
* @brief Set the sensor downsampling factor
*
* Sets the downsampling factor - the number of steps taken between each data point. A downsampling factor of 1 samples
* every possible point in the range. A downsampling factor of 2 samples every other point, and so on.
*
* In the envelope service, the base step length is ~0.5mm. Thus, for example setting downsampling factor to 4
* makes the distance between two points in the measured range ~2mm.
*
* The envelope service supports a downsampling factor of 1, 2, or 4.
*
* @param[in] service_configuration The configuration to set downsampling factor in
* @param[in] downsampling_factor The downsampling factor
*/
void acc_service_envelope_downsampling_factor_set(acc_service_configuration_t service_configuration, uint16_t downsampling_factor);
/**
* @brief Get running average factor
*
* The running average factor is the factor of which the most recent sweep is weighed against previous sweeps.
* Valid range is between 0.0 and 1.0 where 0.0 means that no history is weighed in, i.e filtering is effectively disabled.
* A factor of 1.0 means that the most recent sweep has no effect on the result,
* which will result in that the first sweep is forever received as the result.
* The filtering is coherent and is done on complex valued IQ data before conversion to envelope data.
*
* @param[in] service_configuration The configuration to get the running average factor for
* @return Running average factor
*/
float acc_service_envelope_running_average_factor_get(acc_service_configuration_t service_configuration);
/**
* @brief Set running average factor
*
* The running average factor is the factor of which the most recent sweep is weighed against previous sweeps.
* Valid range is between 0.0 and 1.0 where 0.0 means that no history is weighed in, i.e filtering is effectively disabled.
* A factor of 1.0 means that the most recent sweep has no effect on the result,
* which will result in that the first sweep is forever received as the result.
* The filtering is coherent and is done on complex valued IQ data before conversion to envelope data.
*
* @param[in] service_configuration The configuration to set the running average factor for
* @param[in] factor The running average factor to set
*/
void acc_service_envelope_running_average_factor_set(acc_service_configuration_t service_configuration, float factor);
/**
* @brief Get if noise level normalization will be done or not
*
* The purpose of the noise level normalization is to scale the signal according to the
* sensor noise level to decrease the signal amplitude variation between individual sensors.
*
* @param[in] service_configuration The configuration to get the noise level normalization setting for
* @return The noise level normalization flag
*/
bool acc_service_envelope_noise_level_normalization_get(acc_service_configuration_t service_configuration);
/**
* @brief Set if noise level normalization should be done or not
*
* This function controls if a noise level normalization will be done at the beginning
* of the envelope processing.
*
* The purpose of the noise level normalization is to scale the signal according to the
* sensor noise level to decrease the signal amplitude variation between individual sensors.
*
* @param[in] service_configuration The configuration to enable or disable the noise level normalization for
* @param[in] noise_level_normalization Flag to determine if noise level normalization should be done or not
*/
void acc_service_envelope_noise_level_normalization_set(acc_service_configuration_t service_configuration, bool noise_level_normalization);
/**
* @brief Get service metadata
*
* Each service provide metadata after being created with information that could be relevant for an application.
* The metadata contain information such as data length and actual start and length.
*
* May only be called after a service has been created.
*
* @param[in] handle The service handle for the service to get metadata for
* @param[out] metadata Metadata results are provided in this parameter
*/
void acc_service_envelope_get_metadata(acc_service_handle_t handle, acc_service_envelope_metadata_t *metadata);
/**
* @brief Retrieve the next result from the service
*
* May only be called after a service has been activated to retrieve the next result, blocks
* the application until a result is ready.
*
* @param[in] handle The service handle for the service to get the next result for
* @param[out] data Envelope result
* @param[in] data_length The length of the buffer provided for the result
* @param[out] result_info Envelope result info, sending in NULL is ok
* @return True if successful, false otherwise
*/
bool acc_service_envelope_get_next(acc_service_handle_t handle, uint16_t *data, uint16_t data_length,
acc_service_envelope_result_info_t *result_info);
/**
* @brief Retrieve the next result from the service
*
* May only be called after a service has been activated to retrieve the next result, blocks
* the application until a result is ready.
*
* The provided memory is only valid until the next call to get_next for the
* specified handle. The memory is specific for the handle and cannot be shared
* between handles/services.
*
* The length of the resulting data is provided in @ref acc_service_envelope_get_metadata
*
* @param[in] handle The service handle for the service to get the next result for
* @param[out] data Reference to Envelope result
* @param[out] result_info Envelope result info, sending in NULL is ok
* @return True if successful, false otherwise
*/
bool acc_service_envelope_get_next_by_reference(acc_service_handle_t handle, uint16_t **data,
acc_service_envelope_result_info_t *result_info);
/**
* @brief Execute service one time
*
* Activates service, produces one result and then deactivates the service. Blocks the
* application until a service result has been produced. May fail if the service is already active.
*
* @param[in] handle The service handle for the service to execute
* @param[out] data Envelope result
* @param[in] data_length The length of the buffer provided for the result
* @param[out] result_info Envelope result info, sending in NULL is ok
* @return True if successful, false otherwise
*/
bool acc_service_envelope_execute_once(acc_service_handle_t handle, uint16_t *data, uint16_t data_length,
acc_service_envelope_result_info_t *result_info);
/**
* @}
*/
#endif

View File

@ -0,0 +1,288 @@
// Copyright (c) Acconeer AB, 2018-2022
// All rights reserved
#ifndef ACC_SERVICE_IQ_H_
#define ACC_SERVICE_IQ_H_
#include <complex.h>
#include <stdbool.h>
#include <stdint.h>
#include "acc_service.h"
/**
* @defgroup IQ IQ Service
* @ingroup Services
*
* @brief IQ Service API description
*
* @{
*/
/**
* @brief Output format
*
*/
typedef enum
{
ACC_SERVICE_IQ_OUTPUT_FORMAT_FLOAT_COMPLEX, // The output format is float complex
ACC_SERVICE_IQ_OUTPUT_FORMAT_INT16_COMPLEX // The output format is acc_int16_complex_t
} acc_service_iq_output_format_enum_t;
typedef uint32_t acc_service_iq_output_format_t;
/**
* @brief Metadata for the iq service
*/
typedef struct
{
/** Start of sweep, derived from request set by @ref acc_service_requested_start_set */
float start_m;
/** Length of sweep, derived from request set by @ref acc_service_requested_length_set */
float length_m;
/** Number of elements in the iq data array */
uint16_t data_length;
/** Number of stitches in the data */
uint16_t stitch_count;
/** Distance between adjacent data points */
float step_length_m;
/** The depth domain lowpass cutoff frequency ratio */
float depth_lowpass_cutoff_ratio;
} acc_service_iq_metadata_t;
/**
* @brief Metadata for each result provided by the iq service
*/
typedef struct
{
/** Indication of missed data from the sensor */
bool missed_data;
/** Indication of a sensor communication error, service probably needs to be restarted */
bool sensor_communication_error;
/** Indication of sensor data being saturated, can cause result instability */
bool data_saturated;
/** Indication of bad data quality that may be addressed by restarting the service to recalibrate the sensor */
bool data_quality_warning;
} acc_service_iq_result_info_t;
/**
* @brief Create a configuration for an iq service
*
* A configuration is created for the iq service and populated
* with default values.
*
* @return Service configuration, NULL if creation was not possible
*/
acc_service_configuration_t acc_service_iq_configuration_create(void);
/**
* @brief Destroy an iq configuration
*
* Destroy an iq configuration that is no longer needed, may be done even if a
* service has been created with the specific configuration and has not yet been destroyed.
* The service configuration reference is set to NULL after destruction.
*
* @param[in] service_configuration The configuration to destroy, set to NULL
*/
void acc_service_iq_configuration_destroy(acc_service_configuration_t *service_configuration);
/**
* @brief Get the distance domain lowpass filter cutoff frequency ratio override parameters
*
* The cutoff for the distance domain lowpass filter is specified as the ratio between the spatial
* frequency cutoff and the sample frequency. A ratio close to zero damps everything except the lowest
* frequencies. Increasing ratios output a wider band of spatial frequencies, and a ratio of 0.5 means
* that the filter is deactivated.
*
* If unset, i.e., if override is false, the ratio will be chosen automatically. This ratio is
* returned in the metadata upon creation of the service.
*
* @param[in] service_configuration The configuration to get the parameters from
* @param[out] override If true, the specified cutoff ratio is used
* @param[out] cutoff_ratio The cutoff ratio to use if override is true
*/
void acc_service_iq_depth_lowpass_cutoff_ratio_get(acc_service_configuration_t service_configuration, bool *override, float *cutoff_ratio);
/**
* @brief Set the distance domain lowpass filter cutoff frequency ratio override parameters
*
* The cutoff for the distance domain lowpass filter is specified as the ratio between the spatial
* frequency cutoff and the sample frequency. An input value of zero for the cutoff ratio will
* configure the smoothest allowed filter. A cutoff ratio of 0.5 turns the filter off.
*
* The set of available cutoff frequencies is limited due to internal properties of the filter
* implementation.
*
* If unset, i.e., if override is false, the ratio will be chosen automatically. This ratio is
* returned in the metadata upon creation of the service.
*
* @param[in] service_configuration The configuration to set the parameters for
* @param[in] override If true, the specified cutoff ratio is used
* @param[in] cutoff_ratio The cutoff ratio to use if override is true
*/
void acc_service_iq_depth_lowpass_cutoff_ratio_set(acc_service_configuration_t service_configuration,
bool override,
float cutoff_ratio);
/**
* @brief Get the sensor downsampling factor
*
* Gets the downsampling factor - the number of steps taken between each data point. A downsampling factor of 1 samples
* every possible point in the range. A downsampling factor of 2 samples every other point, and so on.
*
* In the IQ service, the base step length is ~0.5mm. Thus, for example setting downsampling factor to 4 makes
* the distance between two points in the measured range ~2mm.
*
* @param[in] service_configuration The configuration to get downsampling factor from
* @return downsampling_factor The downsampling factor
*/
uint16_t acc_service_iq_downsampling_factor_get(acc_service_configuration_t service_configuration);
/**
* @brief Set the sensor downsampling factor
*
* Sets the downsampling factor - the number of steps taken between each data point. A downsampling factor of 1 samples
* every possible point in the range. A downsampling factor of 2 samples every other point, and so on.
*
* In the IQ service, the base step length is ~0.5mm. Thus, for example setting downsampling factor to 4 makes
* the distance between two points in the measured range ~2mm.
*
* The IQ service supports a downsampling factor of 1, 2, or 4.
*
* @param[in] service_configuration The configuration to set downsampling factor in
* @param[in] downsampling_factor The downsampling factor
*/
void acc_service_iq_downsampling_factor_set(acc_service_configuration_t service_configuration, uint16_t downsampling_factor);
/**
* @brief Get if noise level normalization will be done or not
*
* The purpose of the noise level normalization is to scale the signal according to the
* sensor noise level to decrease the signal amplitude variation between individual sensors.
*
* @param[in] service_configuration The configuration to get the noise level normalization setting for
* @return The noise level normalization flag
*/
bool acc_service_iq_noise_level_normalization_get(acc_service_configuration_t service_configuration);
/**
* @brief Set if noise level normalization should be done or not
*
* This function controls if a noise level normalization will be done at the beginning
* of the envelope processing.
*
* The purpose of the noise level normalization is to scale the signal according to the
* sensor noise level to decrease the signal amplitude variation between individual sensors.
*
* @param[in] service_configuration The configuration to enable or disable the noise level normalization for
* @param[in] noise_level_normalization Flag to determine if noise level normalization should be done or not
*/
void acc_service_iq_noise_level_normalization_set(acc_service_configuration_t service_configuration, bool noise_level_normalization);
/**
* @brief Configure the output format of the IQ service
*
* @param[in,out] service_configuration The configuration to set the format on
* @param[in] format The format that should be used
*/
void acc_service_iq_output_format_set(acc_service_configuration_t service_configuration,
acc_service_iq_output_format_t format);
/**
* @brief Get the configured output format
*
* @param[in] service_configuration The configuration to get the format from
*
* @returns The configured output format
*/
acc_service_iq_output_format_t acc_service_iq_output_format_get(acc_service_configuration_t service_configuration);
/**
* @brief Get service metadata
*
* Each service provide metadata after being created with information that could be relevant for an application.
* The metadata contain information such as data length and actual start and length.
*
* May only be called after a service has been created.
*
* @param[in] handle The service handle for the service to get metadata for
* @param[out] metadata Metadata results are provided in this parameter
*/
void acc_service_iq_get_metadata(acc_service_handle_t handle, acc_service_iq_metadata_t *metadata);
/**
* @brief Retrieve the next result from the service
*
* May only be called after a service has been activated to retrieve the next result, blocks
* the application until a result is ready. The service must be configured for floating point output.
*
* @param[in] handle The service handle for the service to get the next result for
* @param[out] data IQ data result
* @param[in] data_length The length of the buffer provided for the result
* @param[out] result_info IQ result info, sending in NULL is ok
* @return True if successful, false otherwise
*/
bool acc_service_iq_get_next(acc_service_handle_t handle, void *data, uint16_t data_length,
acc_service_iq_result_info_t *result_info);
/**
* @brief Retrieve the next result from the service
*
* May only be called after a service has been activated to retrieve the next result, blocks
* the application until a result is ready.
*
* The provided memory is only valid until the next call to get_next for the
* specified handle. The memory is specific for the handle and cannot be shared
* between handles/services.
*
* The length of the resulting data is provided in @ref acc_service_iq_get_metadata
*
* Note that this function is only compatible with the ACC_SERVICE_IQ_OUTPUT_FORMAT_INT16_COMPLEX
* option for @ref acc_service_iq_output_format_set
*
* @param[in] handle The service handle for the service to get the next result for
* @param[out] data Reference to IQ result
* @param[out] result_info IQ result info, sending in NULL is ok
* @return True if successful, false otherwise
*/
bool acc_service_iq_get_next_by_reference(acc_service_handle_t handle, acc_int16_complex_t **data,
acc_service_iq_result_info_t *result_info);
/**
* @brief Execute service one time
*
* Activates service, produces one result and then deactivates the service. Blocks the
* application until a service result has been produced. May fail if the service is already
* active. The format of the data is configured by calling acc_service_iq_output_format_set().
*
* @param[in] handle The service handle for the service to execute
* @param[out] data IQ data result
* @param[in] data_length The length of the buffer provided for the result
* @param[out] result_info IQ result info, sending in NULL is ok
* @return True if successful, false otherwise
*/
bool acc_service_iq_execute_once(acc_service_handle_t handle, void *data, uint16_t data_length,
acc_service_iq_result_info_t *result_info);
/**
* @}
*/
#endif

View File

@ -0,0 +1,226 @@
// Copyright (c) Acconeer AB, 2018-2021
// All rights reserved
#ifndef ACC_SERVICE_POWER_BINS_H_
#define ACC_SERVICE_POWER_BINS_H_
#include <stdbool.h>
#include <stdint.h>
#include "acc_service.h"
/**
* @defgroup Power Power Bins Service
* @ingroup Services
*
* @brief Power Bins service API description
*
* @{
*/
/**
* @brief Metadata for the power bins service
*/
typedef struct
{
/** Start of sweep, derived from request set by @ref acc_service_requested_start_set */
float start_m;
/** Length of sweep, derived from request set by @ref acc_service_requested_length_set */
float length_m;
/** Number of elements in the power bins data array */
uint16_t bin_count;
/** Number of stitches in the data */
uint16_t stitch_count;
/** Distance between adjacent data points */
float step_length_m;
} acc_service_power_bins_metadata_t;
/**
* @brief Metadata for each result provided by the power bins service
*/
typedef struct
{
/** Indication of missed data from the sensor */
bool missed_data;
/** Indication of a sensor communication error, service probably needs to be restarted */
bool sensor_communication_error;
/** Indication of sensor data being saturated, can cause result instability */
bool data_saturated;
/** Indication of bad data quality that may be addressed by restarting the service to recalibrate the sensor */
bool data_quality_warning;
} acc_service_power_bins_result_info_t;
/**
* @brief Create a configuration for a power bins service
*
* A configuration is created for the power bins service and populated
* with default values.
*
* @return Service configuration, NULL if creation was not possible
*/
acc_service_configuration_t acc_service_power_bins_configuration_create(void);
/**
* @brief Destroy a power bins configuration
*
* Destroy a power bins configuration that is no longer needed, may be done even if a
* service has been created with the specific configuration and has not yet been destroyed.
* The service configuration reference is set to NULL after destruction.
*
* @param[in] service_configuration The configuration to destroy, set to NULL
*/
void acc_service_power_bins_configuration_destroy(acc_service_configuration_t *service_configuration);
/**
* @brief Get the sensor downsampling factor
*
* Gets the downsampling factor - the number of steps taken between each data point. A downsampling factor of 1 samples
* every possible point in the range. A downsampling factor of 2 samples every other point, and so on.
*
* @param[in] service_configuration The configuration to get downsampling factor from
* @return The downsampling factor
*/
uint16_t acc_service_power_bins_downsampling_factor_get(acc_service_configuration_t service_configuration);
/**
* @brief Set the sensor downsampling factor
*
* Sets the downsampling factor - the number of steps taken between each data point. A downsampling factor of 1 samples
* every possible point in the range. A downsampling factor of 2 samples every other point, and so on.
*
* The power bins service supports a downsampling factor of 1, 2, or 4.
*
* In power bins, the downsampling factor does not affect the resulting data length.
*
* @param[in] service_configuration The configuration to set downsampling factor in
* @param[in] downsampling_factor The downsampling factor
*/
void acc_service_power_bins_downsampling_factor_set(acc_service_configuration_t service_configuration, uint16_t downsampling_factor);
/**
* @brief Get the requested bin count
*
* @param[in] service_configuration The service configuration to get the requested bin count from
* @return Requested bin count
*/
uint16_t acc_service_power_bins_requested_bin_count_get(acc_service_configuration_t service_configuration);
/**
* @brief Set the requested bin count
*
* @param[in] service_configuration The service configuration to set the requested bin count in
* @param[in] requested_bin_count The requested bin count
*/
void acc_service_power_bins_requested_bin_count_set(acc_service_configuration_t service_configuration,
uint16_t requested_bin_count);
/**
* @brief Get if noise level normalization will be done or not
*
* The purpose of the noise level normalization is to scale the signal according to the
* sensor noise level to decrease the signal amplitude variation between individual sensors.
*
* @param[in] service_configuration The configuration to get the noise level normalization setting for
* @return The noise level normalization flag
*/
bool acc_service_power_bins_noise_level_normalization_get(acc_service_configuration_t service_configuration);
/**
* @brief Set if noise level normalization should be done or not
*
* This function controls if a noise level normalization will be done at the beginning
* of the processing.
*
* The purpose of the noise level normalization is to scale the signal according to the
* sensor noise level to decrease the signal amplitude variation between individual sensors.
*
* @param[in] service_configuration The configuration to enable or disable the noise level normalization for
* @param[in] noise_level_normalization Flag to determine if noise level normalization should be done or not
*/
void acc_service_power_bins_noise_level_normalization_set(acc_service_configuration_t service_configuration, bool noise_level_normalization);
/**
* @brief Get service metadata
*
* Each service provide metadata after being created with information that could be relevant for an application.
* The metadata contain information such as data length and actual start and length.
*
* May only be called after a service has been created.
*
* @param[in] handle The service handle for the service to get metadata for
* @param[out] metadata Metadata results are provided in this parameter
*/
void acc_service_power_bins_get_metadata(acc_service_handle_t handle, acc_service_power_bins_metadata_t *metadata);
/**
* @brief Retrieve the next result from the service
*
* May only be called after a service has been activated to retrieve the next result, blocks
* the application until a result is ready.
*
* @param[in] handle The service handle for the service to get the next result for
* @param[out] data Power bins result
* @param[in] data_length The length of the buffer provided for the result
* @param[out] result_info Power Bins result info, sending in NULL is ok
* @return True if successful, false otherwise
*/
bool acc_service_power_bins_get_next(acc_service_handle_t handle, uint16_t *data, uint16_t data_length,
acc_service_power_bins_result_info_t *result_info);
/**
* @brief Retrieve the next result from the service
*
* May only be called after a service has been activated to retrieve the next result, blocks
* the application until a result is ready.
*
* The provided memory is only valid until the next call to get_next for the
* specified handle. The memory is specific for the handle and cannot be shared
* between handles/services.
*
* The length of the resulting data is provided in @ref acc_service_power_bins_get_metadata
*
* @param[in] handle The service handle for the service to get the next result for
* @param[out] data Reference to Power Bins result
* @param[out] result_info Power Bins result info, sending in NULL is ok
* @return True if successful, false otherwise
*/
bool acc_service_power_bins_get_next_by_reference(acc_service_handle_t handle, uint16_t **data,
acc_service_power_bins_result_info_t *result_info);
/**
* @brief Execute service one time
*
* Activates service, produces one result and then deactivates the service. Blocks the
* application until a service result has been produced. May fail if the service is already active.
*
* @param[in] handle The service handle for the service to execute
* @param[out] data Power bins result
* @param[in] data_length The length of the buffer provided for the result
* @param[out] result_info Power Bins result info, sending in NULL is ok
* @return True if successful, false otherwise
*/
bool acc_service_power_bins_execute_once(acc_service_handle_t handle, uint16_t *data, uint16_t data_length,
acc_service_power_bins_result_info_t *result_info);
/**
* @}
*/
#endif

View File

@ -0,0 +1,294 @@
// Copyright (c) Acconeer AB, 2019-2021
// All rights reserved
#ifndef ACC_SERVICE_SPARSE_H_
#define ACC_SERVICE_SPARSE_H_
#include <stdbool.h>
#include <stdint.h>
#include "acc_service.h"
/**
* @defgroup Sparse Sparse Service
* @ingroup Services
*
* @brief Sparse service API description
*
* @{
*/
/**
* @brief Sampling mode
*
* The sampling mode changes how the hardware accelerated averaging is done. Mode A is optimized
* for maximal independence of the depth points, giving a higher depth resolution than mode B.
* Mode B is instead optimized for maximal radar loop gain per unit time spent on measuring. This
* makes it more energy efficient and suitable for cases where small movements are to be detected
* over long ranges. Mode A is more suitable for applications like gesture recognition, measuring
* the distance to a movement, and speed measurements.
*
* Mode B typically gives roughly 3 dB better SNR per unit time than mode A. However, please note
* that very short ranges of only one or a few points are suboptimal with mode B. In those cases,
* always use mode A.
*/
typedef enum
{
ACC_SERVICE_SPARSE_SAMPLING_MODE_A,
ACC_SERVICE_SPARSE_SAMPLING_MODE_B
} acc_service_sparse_sampling_mode_enum_t;
typedef uint32_t acc_service_sparse_sampling_mode_t;
/**
* @brief Metadata for the sparse service
*/
typedef struct
{
/** Start of sweep, derived from request set by @ref acc_service_requested_start_set */
float start_m;
/** Length of sweep, derived from request set by @ref acc_service_requested_length_set */
float length_m;
/** Number of elements in the sparse data array */
uint16_t data_length;
/** Sweep rate used */
float sweep_rate;
/** Distance between adjacent data points */
float step_length_m;
} acc_service_sparse_metadata_t;
/**
* @brief Metadata for each result provided by the sparse service
*/
typedef struct
{
/** Indication of a sensor communication error, service probably needs to be restarted */
bool sensor_communication_error;
/** Indication of sensor data being saturated, can cause result instability */
bool data_saturated;
/** Indication of missed data from the sensor */
bool missed_data;
} acc_service_sparse_result_info_t;
/**
* @brief Create a configuration for a sparse service
*
* A configuration is created for the sparse service and populated
* with default values.
*
* @return Service configuration, NULL if creation was not possible
*/
acc_service_configuration_t acc_service_sparse_configuration_create(void);
/**
* @brief Destroy a sparse configuration
*
* Destroy a sparse configuration that is no longer needed, may be done even if a
* service has been created with the specific configuration and has not yet been destroyed.
* The service configuration reference is set to NULL after destruction.
*
* @param[in] service_configuration The configuration to destroy, set to NULL
*/
void acc_service_sparse_configuration_destroy(acc_service_configuration_t *service_configuration);
/**
* @brief Get the number of sweeps per service frame
*
* Gets the number of sweeps that will be returned in each frame from the service.
*
* @param[in] service_configuration The service configuration to get sweeps per result from
* @return sweeps per frame
*/
uint16_t acc_service_sparse_configuration_sweeps_per_frame_get(acc_service_configuration_t service_configuration);
/**
* @brief Set sweeps per service frame
*
* Sets the number of sweeps that will be returned in each frame from the service.
*
* For sampling mode B, the number of sweeps per frame must be less than or equal to 64.
*
* @param[in] service_configuration The service configuration to set sweeps per results in
* @param[in] sweeps Sweeps per frame
*/
void acc_service_sparse_configuration_sweeps_per_frame_set(acc_service_configuration_t service_configuration, uint16_t sweeps);
/**
* @brief Get the sweep rate
*
* Gets the requested sweep rate. Values of zero of lower are treated as the maximum possible rate.
*
* @param[in] service_configuration The service configuration to get the sweep rate from
* @return sweep_rate The sweep rate
*/
float acc_service_sparse_configuration_sweep_rate_get(acc_service_configuration_t service_configuration);
/**
* @brief Set sweep rate
*
* Sets the requested sweep rate. Values of zero of lower are treated as the maximum possible rate.
*
* @param[in] service_configuration The service configuration to set the sweep rate in
* @param[in] sweep_rate The sweep rate
*/
void acc_service_sparse_configuration_sweep_rate_set(acc_service_configuration_t service_configuration, float sweep_rate);
/**
* @brief Get sampling mode
*
* @param[in] service_configuration The configuration to get the sampling mode for
* @return sampling mode
*/
acc_service_sparse_sampling_mode_t acc_service_sparse_sampling_mode_get(acc_service_configuration_t service_configuration);
/**
* @brief Set sampling mode
*
* @param[in] service_configuration The configuration to set the sampling mode for
* @param[in] sampling_mode The sampling mode to use
*/
void acc_service_sparse_sampling_mode_set(acc_service_configuration_t service_configuration, acc_service_sparse_sampling_mode_t sampling_mode);
/**
* @brief Get the sensor downsampling factor
*
* Gets the downsampling factor - the number of steps taken between each data point. A downsampling factor of 1 samples
* every possible point in the range. A downsampling factor of 2 samples every other point, and so on.
*
* In the sparse service, the base step length is ~6cm. Thus, for example setting downsampling factor to 4 makes
* the distance between two points in the measured range ~24cm.
*
* @param[in] service_configuration The configuration to get downsampling factor from
* @return The downsampling factor
*/
uint16_t acc_service_sparse_downsampling_factor_get(acc_service_configuration_t service_configuration);
/**
* @brief Set the sensor downsampling factor
*
* Sets the downsampling factor - the number of steps taken between each data point. A downsampling factor of 1 samples
* every possible point in the range. A downsampling factor of 2 samples every other point, and so on.
*
* In the sparse service, the base step length is ~6cm. Thus, for example setting downsampling factor to 4 makes
* the distance between two points in the measured range ~24cm.
*
* The sparse service supports setting the downsampling factor to 1, 2, 4, or 8.
*
* @param[in] service_configuration The configuration to set downsampling factor in
* @param[in] downsampling_factor The downsampling factor
*/
void acc_service_sparse_downsampling_factor_set(acc_service_configuration_t service_configuration, uint16_t downsampling_factor);
/**
* @brief Get minimum service memory size
*
* The service memory size depends on several parameters and has a default
* minimum size of around 4kByte. The service memory usage increases with increasing range.
* This parameter changes the default minimum size from 4kByte to the used value.
* With a small value there might be a time penalty for service creation and activation.
*
* @param[in] service_configuration The service configuration to get min service memory size from
* @return The minimum service memory size
*/
uint16_t acc_service_sparse_min_service_memory_size_get(acc_service_configuration_t service_configuration);
/**
* @brief Set minimum service memory size
*
* The service memory size depends on several parameters and has a default
* minimum size of around 4kByte. The service memory usage increases with increasing range.
* This parameter changes the default minimum size from 4kByte to the used value.
* With a small value there might be a time penalty for service creation and activation.
*
* @param[in] service_configuration The service configuration to set min service memory size in
* @param[in] min_service_memory_size The minimum service memory size
*/
void acc_service_sparse_min_service_memory_size_set(acc_service_configuration_t service_configuration, uint16_t min_service_memory_size);
/**
* @brief Get service metadata
*
* Each service provide metadata after being created with information that could be relevant for an application.
* The metadata contain information such as data length and actual start and length.
*
* May only be called after a service has been created.
*
* @param[in] handle The service handle for the service to get metadata for
* @param[out] metadata Metadata results are provided in this parameter
*/
void acc_service_sparse_get_metadata(acc_service_handle_t handle, acc_service_sparse_metadata_t *metadata);
/**
* @brief Retrieve the next result from the service
*
* May only be called after a service has been activated to retrieve the next result, blocks
* the application until a result is ready.
*
* @param[in] handle The service handle for the service to get the next result for
* @param[out] data sparse result
* @param[in] data_length The length of the buffer provided for the result
* @param[out] result_info Sparse result info, sending in NULL is ok
* @return True if successful, false otherwise
*/
bool acc_service_sparse_get_next(acc_service_handle_t handle, uint16_t *data, uint16_t data_length,
acc_service_sparse_result_info_t *result_info);
/**
* @brief Retrieve the next result from the service
*
* May only be called after a service has been activated to retrieve the next result, blocks
* the application until a result is ready.
*
* The provided memory is only valid until the next call to get_next for the
* specified handle. The memory is specific for the handle and cannot be shared
* between handles/services.
*
* The length of the resulting data is provided in @ref acc_service_sparse_get_metadata
*
* @param[in] handle The service handle for the service to get the next result for
* @param[out] data Reference to Sparse result
* @param[out] result_info Sparse result info, sending in NULL is ok
* @return True if successful, false otherwise
*/
bool acc_service_sparse_get_next_by_reference(acc_service_handle_t handle, uint16_t **data,
acc_service_sparse_result_info_t *result_info);
/**
* @brief Execute service one time
*
* Activates service, produces one result and then deactivates the service. Blocks the
* application until a service result has been produced. May fail if the service is already active.
*
* @param[in] handle The service handle for the service to execute
* @param[out] data sparse result
* @param[in] data_length The length of the buffer provided for the result
* @param[out] result_info Sparse result info, sending in NULL is ok
* @return True if successful, false otherwise
*/
bool acc_service_sparse_execute_once(acc_service_handle_t handle, uint16_t *data, uint16_t data_length,
acc_service_sparse_result_info_t *result_info);
/**
* @}
*/
#endif

View File

@ -0,0 +1,14 @@
// Copyright (c) Acconeer AB, 2019-2021
// All rights reserved
#ifndef ACC_VERSION_H_
#define ACC_VERSION_H_
/**
* @brief Get the version of the Acconeer software
*
* @return A string describing the software version.
*/
const char *acc_version_get(void);
#endif

Binary file not shown.