Macros | Functions | Variables
i2c_example_cargo.c File Reference
`#include <complex.h>`
`#include <stdarg.h>`
`#include <stdbool.h>`
`#include <stdint.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include "acc_definitions_a121.h"`
`#include "acc_hal_definitions_a121.h"`
`#include "acc_hal_integration_a121.h"`
`#include "acc_integration.h"`
`#include "acc_integration_log.h"`
`#include "acc_rss_a121.h"`
`#include "acc_version.h"`
`#include "example_cargo.h"`
`#include "acc_reg_protocol.h"`
`#include "example_cargo_reg_protocol.h"`
`#include "i2c_application_system.h"`
`#include "i2c_example_cargo.h"`

Go to the source code of this file.

## Macros
#define | SENSOR_ID (1U)
#define | SENSOR_TIMEOUT_MS (10000U)
#define | UART_LOG_BUFFER_SIZE 100

## Functions
static uint32_t | get_command (void)
| Get the i2c_detector_command values. More...
static void | application_status_set_bits (uint32_t bit_mask)
| Set bits in the i2c_application_status. More...
static void | application_status_clr_bits (uint32_t bit_mask)
| Clear bits in the i2c_application_status. More...
static bool | application_status_test_bits (uint32_t bit_mask)
| Test bits in the i2c_application_status. More...
static void | create_sensor (void)
| Create sensor. More...
static bool | calibrate_sensor (void)
| Calibrate sensor. More...
static bool | do_cargo_calibration (bool full_calibration)
| Performs cargo calibration. More...
static bool | enter_hibernation (void)
| Enter sensor hibernation state. More...
static bool | exit_hibernation (void)
| Exit sensor hibernation state. More...
static bool | validate_application_config_for_i2c (void)
| Validate Cargo config for this I2C application. More...
static void | apply_application_config (void)
| Apply config. More...
static bool | utilization_get_next (void)
| Get next utilization level measurement. More...
static bool | presence_get_next (void)
| Get next presence measurement. More...
static void | presence_reset_burst_result (void)
| Reset presence burst result. More...
static void | presence_update_burst_result (const cargo_result_t *cargo_result)
| Update presence brust result. More...
static void | increment_measure_counter (void)
| Increment measure counter by one. More...
static void | update_presence_update_rate_estimate (void)
| Update presence frame estimation. More...
static void | update_most_recent_temperature (int16_t temperature)
| Set most recent temperature to the passed temperature. More...
static void | module_low_power (void)
| Try to set module in low power mode. More...
static void | log_cargo_result_on_uart (const cargo_result_t *result)
| Print the application result. More...
static void | uart_log (const char *format,...)
| UART logging function (can be enabled/disabled by command) More...
cargo_config_t * | i2c_example_cargo_get_config (void)
| Get pointer to internal cargo config struct. More...
bool | i2c_example_cargo_command (uint32_t command)
| Send command to be executed to cargo i2c app. More...
uint32_t | i2c_example_cargo_get_status (void)
| Get cargo example app status. More...
uint32_t | i2c_example_cargo_get_measure_counter (void)
| Get the count of number of measurements performed. More...
uint32_t | i2c_example_cargo_get_actual_presence_update_rate (void)
| Get the estimated presence update rate of the. More...
void | i2c_example_cargo_copy_utilization_result_fields (cargo_result_t *dst_result)
| Copy utilization example app cargo result. More...
void | i2c_example_cargo_copy_presence_burst_result_fields (cargo_result_t *dst_result)
| Copy presence example app cargo result. More...
int16_t | i2c_example_cargo_get_temperature (void)
| Get most recently measured temperature. More...
int | acconeer_main (int argc, char *argv[])
| Assembly test example. More...

## Variables
struct {
acc_sensor_t * sensor
cargo_config_t config
cargo_handle_t * handle
acc_cal_result_t sensor_cal_result
acc_detector_cal_result_dynamic_t distance_cal_result_dynamic
uint8_t * distance_cal_result_static
uint32_t distance_cal_result_static_size
void * buffer
uint32_t buffer_size
cargo_result_t result
int16_t most_recent_temperature
bool utilization_result_available
} | g_resources
struct {
uint32_t i2c_application_command
uint32_t i2c_application_status
uint32_t measure_counter
uint32_t presence_last_tick_ms
uint32_t presence_estimated_frame_rate_mhz
bool uart_logs_enabed
} | g_application_state
struct {
bool presence_valid
bool presence_detected
float max_inter_presence_score
float max_intra_presence_score
} | g_presence_burst_result

## Macro Definition Documentation

## ◆ SENSOR_ID

#define SENSOR_ID (1U)

Definition at line 28 of file i2c_example_cargo.c.

## ◆ SENSOR_TIMEOUT_MS

#define SENSOR_TIMEOUT_MS (10000U)

Definition at line 29 of file i2c_example_cargo.c.

## ◆ UART_LOG_BUFFER_SIZE

#define UART_LOG_BUFFER_SIZE 100

Definition at line 68 of file i2c_example_cargo.c.

## Function Documentation

## ◆ acconeer_main()

int acconeer_main | ( | int | argc,
|  | char * | argv[]
| ) |  |

Assembly test example.

Touchless button application.

Tank level reference application.

Smart presence reference application.

Parking application.

Breathing example application.

Waste level application.

Vibration example.

Surface velocity example application.

Service subsweeps example.

Service multple configurations example.

Low power service example.

Service sensor calibration caching example.

Service example.

Processing subtract adaptive background example.

Processing static presence example.

Processing peak interpolation example.

Processing noncoherent mean example.

Processing coherent mean example.

Processing amplitude example.

hand motion application

Detector presence example with multiple configurations.

Low power detector presence example.

Detector presence example.

Detector distance example with iq data print.

Distance detector low power example.

Detector distance with calibration caching example.

Detector distance example.

Control helper example.

Cargo application.

Returns
  Returns EXIT_SUCCESS if successful, otherwise EXIT_FAILURE

Test if measure on wake up is enable Do a measurement if the the detector is ready (configured and calibrated)

Test if measure on wake up is enable Do a measurement if the the detector is ready (configured and calibrated)

Definition at line 320 of file i2c_example_cargo.c.

## ◆ application_status_clr_bits()

static void application_status_clr_bits | ( | uint32_t | bit_mask | ) |
| static

Clear bits in the i2c_application_status.

The i2c_application_status is protected by a critical section

Parameters

  [in] | bit_mask | The bit_mask to clear

Definition at line 547 of file i2c_example_cargo.c.

## ◆ application_status_set_bits()

static void application_status_set_bits | ( | uint32_t | bit_mask | ) |
| static

Set bits in the i2c_application_status.

The i2c_application_status is protected by a critical section

Parameters

  [in] | bit_mask | The bit_mask to set

Definition at line 534 of file i2c_example_cargo.c.

## ◆ application_status_test_bits()

static bool application_status_test_bits | ( | uint32_t | bit_mask | ) |
| static

Test bits in the i2c_application_status.

The i2c_application_status is protected by a critical section

Parameters

  [in] | bit_mask | The bit_mask to test

Returns
  true if all the bits in bit_mask is set in i2c_application_status

Definition at line 560 of file i2c_example_cargo.c.

## ◆ apply_application_config()

static void apply_application_config | ( | void |  | ) |
| static

Apply config.

This function will create the distance- & presence detector and allocate the needed memory

Definition at line 713 of file i2c_example_cargo.c.

## ◆ calibrate_sensor()

static bool calibrate_sensor | ( | void |  | ) |
| static

Calibrate sensor.

Returns
  true if successful

Definition at line 592 of file i2c_example_cargo.c.

## ◆ create_sensor()

static void create_sensor | ( | void |  | ) |
| static

Create sensor.

Definition at line 572 of file i2c_example_cargo.c.

## ◆ do_cargo_calibration()

static bool do_cargo_calibration | ( | bool | full_calibration | ) |
| static

Performs cargo calibration.

Definition at line 633 of file i2c_example_cargo.c.

## ◆ enter_hibernation()

static bool enter_hibernation | ( | void |  | ) |
| static

Enter sensor hibernation state.

exit_hibernate needs to be called before the sensor can measure again.

Definition at line 685 of file i2c_example_cargo.c.

## ◆ exit_hibernation()

static bool exit_hibernation | ( | void |  | ) |
| static

Exit sensor hibernation state.

Definition at line 699 of file i2c_example_cargo.c.

## ◆ get_command()

static uint32_t get_command | ( | void |  | ) |
| static

Get the i2c_detector_command values.

The i2c_application_command is cleared during this read The read and clear are protected by a critical section

Returns
  The command sent from the host

Definition at line 520 of file i2c_example_cargo.c.

## ◆ i2c_example_cargo_command()

bool i2c_example_cargo_command | ( | uint32_t | command | ) |

Send command to be executed to cargo i2c app.

Parameters

  [in] | command | The command to be executed

Returns
  true if successful

Definition at line 219 of file i2c_example_cargo.c.

## ◆ i2c_example_cargo_copy_presence_burst_result_fields()

void i2c_example_cargo_copy_presence_burst_result_fields | ( | cargo_result_t * | dst_result | ) |

Copy presence example app cargo result.

Returns
  result from example app cargo

Definition at line 289 of file i2c_example_cargo.c.

## ◆ i2c_example_cargo_copy_utilization_result_fields()

void i2c_example_cargo_copy_utilization_result_fields | ( | cargo_result_t * | dst_result | ) |

Copy utilization example app cargo result.

Returns
  result from example app cargo

Definition at line 275 of file i2c_example_cargo.c.

## ◆ i2c_example_cargo_get_actual_presence_update_rate()

uint32_t i2c_example_cargo_get_actual_presence_update_rate | ( | void |  | ) |

Get the estimated presence update rate of the.

The application measures time between presence updates with ms accuraccy.

Returns
  The estimated update rate in mHz

Definition at line 264 of file i2c_example_cargo.c.

## ◆ i2c_example_cargo_get_config()

cargo_config_t* i2c_example_cargo_get_config | ( | void |  | ) |

Get pointer to internal cargo config struct.

Returns
  cargo configuration handle

Definition at line 214 of file i2c_example_cargo.c.

## ◆ i2c_example_cargo_get_measure_counter()

uint32_t i2c_example_cargo_get_measure_counter | ( | void |  | ) |

Get the count of number of measurements performed.

The counter will be increased every time the Cargo example app completes a measurement

Returns
  measure counter from application

Definition at line 253 of file i2c_example_cargo.c.

## ◆ i2c_example_cargo_get_status()

uint32_t i2c_example_cargo_get_status | ( | void |  | ) |

Get cargo example app status.

Returns
  status from cargo example app

Definition at line 241 of file i2c_example_cargo.c.

## ◆ i2c_example_cargo_get_temperature()

int16_t i2c_example_cargo_get_temperature | ( | void |  | ) |

Get most recently measured temperature.

Returns
  temperature as defined in acc_processing_result_t

Definition at line 303 of file i2c_example_cargo.c.

## ◆ increment_measure_counter()

static void increment_measure_counter | ( | void |  | ) |
| static

Increment measure counter by one.

Definition at line 1033 of file i2c_example_cargo.c.

## ◆ log_cargo_result_on_uart()

static void log_cargo_result_on_uart | ( | const cargo_result_t * | result | ) |
| static

Print the application result.

Only available when the UART logs have been enabled with ENABLE_UART_LOGS

Parameters

  [in] | result | The cargo result

Definition at line 1089 of file i2c_example_cargo.c.

## ◆ module_low_power()

static void module_low_power | ( | void |  | ) |
| static

Try to set module in low power mode.

Definition at line 1066 of file i2c_example_cargo.c.

## ◆ presence_get_next()

static bool presence_get_next | ( | void |  | ) |
| static

Get next presence measurement.

Returns
  true if successful

Definition at line 923 of file i2c_example_cargo.c.

## ◆ presence_reset_burst_result()

static void presence_reset_burst_result | ( | void |  | ) |
| static

Reset presence burst result.

Definition at line 994 of file i2c_example_cargo.c.

## ◆ presence_update_burst_result()

static void presence_update_burst_result | ( | const cargo_result_t * | cargo_result | ) |
| static

Update presence brust result.

Definition at line 1006 of file i2c_example_cargo.c.

## ◆ uart_log()

static void uart_log | ( | const char * | format,
|  |  | ...
| ) |  |
| static

UART logging function (can be enabled/disabled by command)

Definition at line 1115 of file i2c_example_cargo.c.

## ◆ update_most_recent_temperature()

static void update_most_recent_temperature | ( | int16_t | temperature | ) |
| static

Set most recent temperature to the passed temperature.

Definition at line 1057 of file i2c_example_cargo.c.

## ◆ update_presence_update_rate_estimate()

static void update_presence_update_rate_estimate | ( | void |  | ) |
| static

Update presence frame estimation.

Definition at line 1045 of file i2c_example_cargo.c.

## ◆ utilization_get_next()

static bool utilization_get_next | ( | void |  | ) |
| static

Get next utilization level measurement.

Returns
  true if successful

Definition at line 830 of file i2c_example_cargo.c.

## ◆ validate_application_config_for_i2c()

static bool validate_application_config_for_i2c | ( | void |  | ) |
| static

Validate Cargo config for this I2C application.

Returns
  true if config is valid

Definition at line 819 of file i2c_example_cargo.c.

## Variable Documentation

## ◆ buffer

void* buffer

Examples
  acc_processing_helpers.c, example_bring_up.c, example_control_helper.c, example_detector_distance.c, example_detector_distance_calibration_caching.c, example_detector_distance_low_power_hibernate.c, example_detector_distance_low_power_off.c, example_detector_distance_with_iq_data_print.c, example_detector_presence.c, example_detector_presence_low_power_hibernate.c, example_detector_presence_low_power_off.c, example_detector_presence_multiple_configurations.c, example_detector_presence_with_iq_data_print.c, example_diagnostic_test.c, example_service.c, example_service_calibration_caching.c, example_service_low_power_sensor_disable.c, example_service_low_power_sensor_hibernate.c, example_service_multiple_configurations.c, example_service_sensor_disable.c, example_service_sensor_hibernate.c, example_service_sensor_off.c, example_service_subsweeps.c, example_vibration_main.c, and ref_app_tank_level.c.

Definition at line 40 of file i2c_example_cargo.c.

## ◆ buffer_size

uint32_t buffer_size

Examples
  example_detector_distance.c, example_detector_distance_calibration_caching.c, example_detector_distance_low_power_hibernate.c, example_detector_distance_low_power_off.c, example_detector_distance_with_iq_data_print.c, example_detector_presence.c, example_detector_presence_low_power_hibernate.c, example_detector_presence_low_power_off.c, example_detector_presence_multiple_configurations.c, example_detector_presence_with_iq_data_print.c, example_service.c, example_service_calibration_caching.c, example_service_low_power_sensor_disable.c, example_service_low_power_sensor_hibernate.c, example_service_multiple_configurations.c, example_service_sensor_disable.c, example_service_sensor_hibernate.c, example_service_sensor_off.c, example_service_subsweeps.c, example_vibration_main.c, and ref_app_tank_level.c.

Definition at line 41 of file i2c_example_cargo.c.

## ◆ config

cargo_config_t config

Examples
  example_detector_distance.c, example_detector_distance_calibration_caching.c, example_detector_distance_with_iq_data_print.c, example_processing_amplitude.c, example_processing_coherent_mean.c, example_processing_noncoherent_mean.c, example_processing_peak_interpolation.c, example_processing_static_presence.c, example_processing_subtract_adaptive_bg.c, example_service.c, example_service_calibration_caching.c, example_service_low_power_sensor_disable.c, example_service_low_power_sensor_hibernate.c, example_service_multiple_configurations.c, example_service_sensor_disable.c, example_service_sensor_hibernate.c, example_service_sensor_off.c, example_service_subsweeps.c, and example_vibration_main.c.

Definition at line 34 of file i2c_example_cargo.c.

## ◆ distance_cal_result_dynamic

acc_detector_cal_result_dynamic_t distance_cal_result_dynamic

Definition at line 37 of file i2c_example_cargo.c.

## ◆ distance_cal_result_static

uint8_t* distance_cal_result_static

Definition at line 38 of file i2c_example_cargo.c.

## ◆ distance_cal_result_static_size

uint32_t distance_cal_result_static_size

Definition at line 39 of file i2c_example_cargo.c.

## ◆ g_application_state

struct { ... } g_application_state

## ◆ g_presence_burst_result

struct { ... } g_presence_burst_result

## ◆ g_resources

struct { ... } g_resources

## ◆ handle

cargo_handle_t* handle

Examples
  example_detector_distance.c, example_detector_distance_calibration_caching.c, example_detector_distance_with_iq_data_print.c, and example_vibration_main.c.

Definition at line 35 of file i2c_example_cargo.c.

## ◆ i2c_application_command

uint32_t i2c_application_command

Definition at line 50 of file i2c_example_cargo.c.

## ◆ i2c_application_status

uint32_t i2c_application_status

Definition at line 51 of file i2c_example_cargo.c.

## ◆ max_inter_presence_score

float max_inter_presence_score

Definition at line 64 of file i2c_example_cargo.c.

## ◆ max_intra_presence_score

float max_intra_presence_score

Definition at line 65 of file i2c_example_cargo.c.

## ◆ measure_counter

uint32_t measure_counter

Definition at line 52 of file i2c_example_cargo.c.

## ◆ most_recent_temperature

int16_t most_recent_temperature

Definition at line 44 of file i2c_example_cargo.c.

## ◆ presence_detected

bool presence_detected

Definition at line 63 of file i2c_example_cargo.c.

## ◆ presence_estimated_frame_rate_mhz

uint32_t presence_estimated_frame_rate_mhz

Definition at line 55 of file i2c_example_cargo.c.

## ◆ presence_last_tick_ms

uint32_t presence_last_tick_ms

Definition at line 54 of file i2c_example_cargo.c.

## ◆ presence_valid

bool presence_valid

Definition at line 62 of file i2c_example_cargo.c.

## ◆ result

cargo_result_t result

Examples
  example_detector_distance.c, example_detector_distance_calibration_caching.c, example_detector_distance_low_power_hibernate.c, example_detector_distance_low_power_off.c, example_detector_distance_with_iq_data_print.c, example_detector_presence.c, example_detector_presence_low_power_hibernate.c, example_detector_presence_low_power_off.c, example_detector_presence_multiple_configurations.c, example_detector_presence_with_iq_data_print.c, example_vibration_main.c, and ref_app_tank_level.c.

Definition at line 43 of file i2c_example_cargo.c.

## ◆ sensor

acc_sensor_t* sensor

Examples
  example_detector_distance.c, example_detector_distance_calibration_caching.c, example_detector_distance_low_power_hibernate.c, example_detector_distance_low_power_off.c, example_detector_distance_with_iq_data_print.c, example_detector_presence.c, example_detector_presence_low_power_hibernate.c, example_detector_presence_low_power_off.c, example_detector_presence_multiple_configurations.c, example_detector_presence_with_iq_data_print.c, example_service.c, example_service_calibration_caching.c, example_service_low_power_sensor_disable.c, example_service_low_power_sensor_hibernate.c, example_service_multiple_configurations.c, example_service_sensor_disable.c, example_service_sensor_hibernate.c, example_service_sensor_off.c, example_service_subsweeps.c, example_vibration_main.c, and ref_app_tank_level.c.

Definition at line 33 of file i2c_example_cargo.c.

## ◆ sensor_cal_result

acc_cal_result_t sensor_cal_result

Examples
  example_detector_distance.c, example_detector_distance_low_power_hibernate.c, example_detector_distance_low_power_off.c, example_detector_distance_with_iq_data_print.c, and ref_app_tank_level.c.

Definition at line 36 of file i2c_example_cargo.c.

## ◆ uart_logs_enabed

bool uart_logs_enabed

Definition at line 57 of file i2c_example_cargo.c.

## ◆ utilization_result_available

bool utilization_result_available

Definition at line 45 of file i2c_example_cargo.c.