Data Structures | Typedefs | Enumerations | Functions
example_cargo.h File Reference
`#include <stdbool.h>`
`#include <stdint.h>`
`#include "acc_config.h"`
`#include "acc_detector_distance.h"`
`#include "acc_detector_presence.h"`
`#include "acc_processing.h"`
`#include "acc_sensor.h"`

Go to the source code of this file.

## Data Structures
struct | cargo_config_t
| Configuration struct for cargo. More...
struct | cargo_result_t
| Result type. More...

## Typedefs
typedef struct cargo_handle | cargo_handle_t

## Enumerations
enum | cargo_preset_t { CARGO_PRESET_CONTAINER_10_FEET, CARGO_PRESET_CONTAINER_20_FEET, CARGO_PRESET_CONTAINER_40_FEET, CARGO_PRESET_NO_LENS }
| Cargo Example App Presets. More...
enum | cargo_container_size_t { CARGO_CONTAINER_SIZE_10_FT, CARGO_CONTAINER_SIZE_20_FT, CARGO_CONTAINER_SIZE_40_FT }
| Container size. More...
enum | cargo_mode_t { CARGO_MODE_NONE = 0, CARGO_MODE_UTILIZATION, CARGO_MODE_PRESENCE }
| Cargo mode enumeration. More...

## Functions
void | cargo_config_initialize (cargo_config_t *cargo_config, cargo_preset_t preset)
| Initialize cargo config struct with a preset. More...
void | cargo_config_log (const cargo_config_t *cargo_config)
| Log cargo config to debug uart. More...
cargo_handle_t * | cargo_handle_create (const cargo_config_t *cargo_config)
| Create a cargo handle. More...
void | cargo_handle_destroy (cargo_handle_t *handle)
| Destroy a cargo handle. More...
bool | cargo_get_buffer_size (const cargo_handle_t *handle, uint32_t *buffer_size)
| Get the required buffer sensor data buffer size. More...
bool | cargo_get_distance_cal_result_static_size (const cargo_handle_t *handle, uint32_t *distance_cal_result_static_size)
| Get the required buffer for static distance detector calibration. More...
bool | cargo_calibrate (cargo_handle_t *handle, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, uint8_t *distance_cal_result_static, uint32_t distance_cal_result_static_size, acc_detector_cal_result_dynamic_t *distance_cal_result_dynamic, bool *calibration_complete)
| Calibrate Cargo. More...
bool | cargo_update_calibration (cargo_handle_t *handle, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size, acc_detector_cal_result_dynamic_t *distance_cal_result_dynamic, bool *calibration_complete)
| Update Cargo calibration. More...
bool | cargo_prepare_utilization (cargo_handle_t *handle, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
| Prepare Cargo utilization for measurements. More...
bool | cargo_prepare_presence (cargo_handle_t *handle, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
| Prepare Cargo presence for measurements. More...
bool | cargo_process_utilization (cargo_handle_t *handle, uint8_t *distance_cal_result_static, acc_detector_cal_result_dynamic_t *distance_cal_result_dynamic, void *buffer, cargo_result_t *cargo_result, bool *result_available, acc_detector_distance_result_t *nullable_distance_result)
| Process Sparse IQ data into a Cargo result. More...
bool | cargo_process_presence (cargo_handle_t *handle, void *buffer, cargo_result_t *cargo_result, acc_detector_presence_result_t *nullable_presence_result)
| Process Sparse IQ data into a Cargo result. More...
cargo_mode_t | cargo_current_mode_get (const cargo_handle_t *handle)
| Get current mode of the cargo handle. More...
bool | cargo_presence_metadata_get (cargo_handle_t *handle, acc_detector_presence_metadata_t *presence_metadata)
| Get presence detector metadata. More...

## Typedef Documentation

## ◆ cargo_handle_t

typedef struct cargo_handle cargo_handle_t

Definition at line 148 of file example_cargo.h.

## Enumeration Type Documentation

## ◆ cargo_container_size_t

enum cargo_container_size_t

Container size.

Enumerator
CARGO_CONTAINER_SIZE_10_FT |
CARGO_CONTAINER_SIZE_20_FT |
CARGO_CONTAINER_SIZE_40_FT |

Definition at line 33 of file example_cargo.h.

## ◆ cargo_mode_t

enum cargo_mode_t

Cargo mode enumeration.

Enumerator
CARGO_MODE_NONE |
CARGO_MODE_UTILIZATION |
CARGO_MODE_PRESENCE |

Definition at line 153 of file example_cargo.h.

## ◆ cargo_preset_t

enum cargo_preset_t

Cargo Example App Presets.

Enumerator
CARGO_PRESET_CONTAINER_10_FEET |
CARGO_PRESET_CONTAINER_20_FEET |
CARGO_PRESET_CONTAINER_40_FEET |
CARGO_PRESET_NO_LENS |

Definition at line 22 of file example_cargo.h.

## Function Documentation

## ◆ cargo_calibrate()

bool cargo_calibrate | ( | cargo_handle_t * | handle,
|  | acc_sensor_t * | sensor,
|  | const acc_cal_result_t * | sensor_cal_result,
|  | void * | buffer,
|  | uint32_t | buffer_size,
|  | uint8_t * | distance_cal_result_static,
|  | uint32_t | distance_cal_result_static_size,
|  | acc_detector_cal_result_dynamic_t * | distance_cal_result_dynamic,
|  | bool * | calibration_complete
| ) |  |

Calibrate Cargo.

Calibrating Cargo's internal Detector is needed to ensure reliable Detector results.

See the calibration sections in the Distance Detector User Guide for more information.

Parameters

  [in] | sensor | The sensor instance to use for calibration
  [in] | handle | The Cargo handle
  [in] | sensor_cal_result | Sensor calibration result
  [in] | buffer | Working memory buffer needed by function
  [in] | buffer_size | The size of buffer. Needs to be at least the result of cargo_get_buffer_size
  [out] | distance_cal_result_static | Static result of calibration
  [in] | distance_cal_result_static_size | The size of distance_cal_result_static. Needs to be at least the result of cargo_get_distance_cal_result_static_size
  [out] | distance_cal_result_dynamic | Dynamic result of calibration
  [out] | calibration_complete | Will be set to true when the calibration is complete. If false; at least one more call to this function is needed. Note that it's necessary to wait for interrupt between calls.

Returns
  True if successful, false otherwise

Definition at line 318 of file example_cargo.c.

## ◆ cargo_config_initialize()

void cargo_config_initialize | ( | cargo_config_t * | cargo_config,
|  | cargo_preset_t | preset
| ) |  |

Initialize cargo config struct with a preset.

Parameters

  [out] | cargo_config | The cargo config to initialize
  [in] | preset | A cargo_preset_t to initialize the config to

Definition at line 80 of file example_cargo.c.

## ◆ cargo_config_log()

void cargo_config_log | ( | const cargo_config_t * | cargo_config | ) |

Log cargo config to debug uart.

Parameters

  [in] | cargo_config | The cargo config to log

Definition at line 135 of file example_cargo.c.

## ◆ cargo_current_mode_get()

cargo_mode_t cargo_current_mode_get | ( | const cargo_handle_t * | handle | ) |

Get current mode of the cargo handle.

Really only useful when doing both Presence- & Utilization level measurements.

Parameters

  [in] | handle | The cargo handle

Returns
  The current cargo mode. See cargo_mode_t

Definition at line 622 of file example_cargo.c.

## ◆ cargo_get_buffer_size()

bool cargo_get_buffer_size | ( | const cargo_handle_t * | handle,
|  | uint32_t * | buffer_size
| ) |  |

Get the required buffer sensor data buffer size.

Parameters

  [in] | handle | The cargo handle
  [out] | buffer_size | The required buffer size

Returns
  True if successful, false otherwise

Definition at line 272 of file example_cargo.c.

## ◆ cargo_get_distance_cal_result_static_size()

bool cargo_get_distance_cal_result_static_size | ( | const cargo_handle_t * | handle,
|  | uint32_t * | distance_cal_result_static_size
| ) |  |

Get the required buffer for static distance detector calibration.

Parameters

  [in] | handle | The cargo handle
  [out] | distance_cal_result_static_size | The required buffer size. Will be 0U if activate_utilization_level is false.

Returns
  True if successful, false otherwise

Definition at line 298 of file example_cargo.c.

## ◆ cargo_handle_create()

cargo_handle_t* cargo_handle_create | ( | const cargo_config_t * | cargo_config | ) |

Create a cargo handle.

Parameters

  [in] | cargo_config | Cargo configuration

Returns
  A cargo handle, or NULL if creation failed

Definition at line 164 of file example_cargo.c.

## ◆ cargo_handle_destroy()

void cargo_handle_destroy | ( | cargo_handle_t * | handle | ) |

Destroy a cargo handle.

Parameters

  [in] | handle | The cargo handle to destroy

Definition at line 240 of file example_cargo.c.

## ◆ cargo_prepare_presence()

bool cargo_prepare_presence | ( | cargo_handle_t * | handle,
|  | acc_sensor_t * | sensor,
|  | const acc_cal_result_t * | sensor_cal_result,
|  | void * | buffer,
|  | uint32_t | buffer_size
| ) |  |

Prepare Cargo presence for measurements.

Parameters

  [in,out] | handle | The Cargo handle
  [in] | sensor | The sensor instance
  [in] | sensor_cal_result | The sensor calibration result
  [in] | buffer | Memory used by the detector. Should be at least buffer_size bytes
  [in] | buffer_size | The buffer size received by acc_detector_distance_get_sizes

Returns
  True if successful, false otherwise

Definition at line 423 of file example_cargo.c.

## ◆ cargo_prepare_utilization()

bool cargo_prepare_utilization | ( | cargo_handle_t * | handle,
|  | acc_sensor_t * | sensor,
|  | const acc_cal_result_t * | sensor_cal_result,
|  | void * | buffer,
|  | uint32_t | buffer_size
| ) |  |

Prepare Cargo utilization for measurements.

Parameters

  [in,out] | handle | The Cargo handle
  [in] | sensor | The sensor instance
  [in] | sensor_cal_result | The sensor calibration result
  [in] | buffer | Memory used by the detector. Should be at least buffer_size bytes
  [in] | buffer_size | The buffer size received by acc_detector_distance_get_sizes

Returns
  True if successful, false otherwise

Definition at line 384 of file example_cargo.c.

## ◆ cargo_presence_metadata_get()

bool cargo_presence_metadata_get | ( | cargo_handle_t * | handle,
|  | acc_detector_presence_metadata_t * | presence_metadata
| ) |  |

Get presence detector metadata.

Parameters

  [in] | handle | The cargo handle
  [out] | presence_metadata | The Presence Detector metadata

Returns
  True if handle is valid & configured with presence activated, false otherwise

Definition at line 634 of file example_cargo.c.

## ◆ cargo_process_presence()

bool cargo_process_presence | ( | cargo_handle_t * | handle,
|  | void * | buffer,
|  | cargo_result_t * | cargo_result,
|  | acc_detector_presence_result_t * | nullable_presence_result
| ) |  |

Process Sparse IQ data into a Cargo result.

Parameters

  [in] | handle | The Cargo handle
  [in] | buffer | A reference to the buffer (populated by acc_sensor_read) containing the data to be processed.
  [out] | cargo_result | Cargo result
  [out] | nullable_presence_result | Pointer to auxilliary acc_detector_presence_result_t Can be NULL.

Returns
  True if successful, false otherwise

Definition at line 558 of file example_cargo.c.

## ◆ cargo_process_utilization()

bool cargo_process_utilization | ( | cargo_handle_t * | handle,
|  | uint8_t * | distance_cal_result_static,
|  | acc_detector_cal_result_dynamic_t * | distance_cal_result_dynamic,
|  | void * | buffer,
|  | cargo_result_t * | cargo_result,
|  | bool * | result_available,
|  | acc_detector_distance_result_t * | nullable_distance_result
| ) |  |

Process Sparse IQ data into a Cargo result.

Parameters

  [in] | handle | The Cargo handle
  [in] | distance_cal_result_static | The result from cargo_calibrate
  [in] | distance_cal_result_dynamic | The result from cargo_calibrate
  [in] | buffer | A reference to the buffer (populated by acc_sensor_read) containing the data to be processed.
  [out] | cargo_result | Cargo result
  [out] | result_available | True if the cargo_result is valid
  [out] | nullable_distance_result | Pointer to auxilliary acc_detector_distance_result_t Can be NULL.

Returns
  True if successful, false otherwise

Definition at line 462 of file example_cargo.c.

## ◆ cargo_update_calibration()

bool cargo_update_calibration | ( | cargo_handle_t * | handle,
|  | acc_sensor_t * | sensor,
|  | const acc_cal_result_t * | sensor_cal_result,
|  | void * | buffer,
|  | uint32_t | buffer_size,
|  | acc_detector_cal_result_dynamic_t * | distance_cal_result_dynamic,
|  | bool * | calibration_complete
| ) |  |

Update Cargo calibration.

Updates Cargo's internal calibration.

If calibration_needed has been set to true, you should do the following:

1. Recalibrate sensor (see acc_sensor_calibrate)
2. Call this function in a loop until calibration_complete=true (and while true is returned)
3. Redo the Utilization- or Presence measurement

Parameters

  [in] | sensor | The sensor instance to use for calibration
  [in] | handle | The Cargo handle
  [in] | sensor_cal_result | Sensor calibration result
  [in] | buffer | Working memory buffer needed by function
  [in] | buffer_size | The size of buffer. Needs to be at least the result of cargo_get_buffer_size
  [out] | distance_cal_result_dynamic | Dynamic result of calibration
  [out] | calibration_complete | Will be set to true when the calibration is complete. If false; at least one more call to this function is needed. Note that it's necessary to wait for interrupt between calls.

Returns
  True if successful, false otherwise

Definition at line 353 of file example_cargo.c.