Data Structures | Macros | Functions
ref_app_parking.c File Reference
`#include <math.h>`
`#include <stdbool.h>`
`#include <stdint.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include "acc_algorithm.h"`
`#include "acc_config.h"`
`#include "acc_definitions_a121.h"`
`#include "acc_definitions_common.h"`
`#include "acc_hal_integration_a121.h"`
`#include "acc_integration.h"`
`#include "acc_integration_log.h"`
`#include "acc_processing.h"`
`#include "acc_rss_a121.h"`
`#include "acc_sensor.h"`
`#include "ref_app_parking.h"`

Go to the source code of this file.

## Data Structures
struct | signature_t
struct | ref_app_parking_handle

## Macros
#define | CAL_ITERATIONS (3U)
#define | MAX_AMPLITUDE (46341.0f)

## Functions
static void | set_sensor_config (ref_app_parking_handle_t *handle)
| Set sensor config using already set parking config. More...
static void | log_config (ref_app_parking_handle_t *handle)
| Log config. More...
static bool | allocate_application_resources (ref_app_parking_handle_t *handle)
| Allocate resources for application. More...
static void | initialize_application_resources (ref_app_parking_handle_t *handle)
| Initialize resources for application using already set parking config. More...
static uint32_t | get_measure_timeout_ms (float update_rate_hz)
| Get timeout value, in ms, for specified update rate. More...
static float | noise_process (acc_int16_complex_t *noise_data, float *noise_magnitudes, uint16_t noise_data_length)
| Calculate noise level from noise data. More...
static float | obstruction_noise (acc_int16_complex_t *obs_noise_data, uint16_t obs_noise_data_length)
| Calculate noise mean from obstruction noise data. More...
static void | obstruction_signature (acc_int16_complex_t *subsweep, float *magnitudes, float *distances, uint16_t length, float noise_level, signature_t *signature)
| Calculate obstruction signature from obstruction data. More...
static void | car_signature (const float *magnitudes, const float *distances, uint16_t length, signature_t *signature)
| Calculate car signature from car data. More...
static bool | objects_present (const ref_app_parking_handle_t *handle)
| Determine if there are any objects present using signature history and thresholds. More...
static bool | same_objects (ref_app_parking_handle_t *handle)
| Determine if multiple signatures relates to same object. More...
static int | compare_signature (const void *a, const void *b)
| Function used to compare two signatures for use in qsort. More...
static bool | enter_hibernate (ref_app_parking_handle_t *handle)
| Make sensor enter hibernate. More...
static bool | exit_hibernate (ref_app_parking_handle_t *handle)
| Make sensor exit hibernate. More...
void | ref_app_parking_set_config (ref_app_parking_parking_preset_t preset, ref_app_parking_config_t *parking_config)
| Set parking config according to specified preset. More...
ref_app_parking_handle_t * | ref_app_parking_handle_create (ref_app_parking_config_t *parking_config, acc_sensor_id_t sensor_id)
| Create parking handle. More...
void | ref_app_parking_handle_destroy (ref_app_parking_handle_t *handle)
| Destroy parking handle. More...
bool | ref_app_parking_sensor_calibration (ref_app_parking_handle_t *handle)
| Sensor calibration. More...
bool | ref_app_parking_noise_calibration (ref_app_parking_handle_t *handle)
| Noise calibration. More...
bool | ref_app_parking_obstruction_calibration (ref_app_parking_handle_t *handle)
| Obstruction calibration. More...
bool | ref_app_parking_sensor_prepare (ref_app_parking_handle_t *handle)
| Prepare sensor for measurement. More...
bool | ref_app_parking_measure (ref_app_parking_handle_t *handle, bool hibernate)
| Perform a sensor measurement. More...
bool | ref_app_parking_handle_indications (ref_app_parking_handle_t *handle, bool *data_reliable)
| Handle indications from a measurement. More...
void | ref_app_parking_obstruction_process (ref_app_parking_handle_t *handle, bool *obstruction_detected)
| Do obstruction processing. More...
void | ref_app_parking_process (ref_app_parking_handle_t *handle, bool *car_detected)
| Do parking processing. More...

## Macro Definition Documentation

## ◆ CAL_ITERATIONS

#define CAL_ITERATIONS (3U)

Definition at line 25 of file ref_app_parking.c.

## ◆ MAX_AMPLITUDE

#define MAX_AMPLITUDE (46341.0f)

Definition at line 26 of file ref_app_parking.c.

## Function Documentation

## ◆ allocate_application_resources()

static bool allocate_application_resources | ( | ref_app_parking_handle_t * | handle | ) |
| static

Allocate resources for application.

Parameters

  [in] | handle | The parking handle

Definition at line 883 of file ref_app_parking.c.

## ◆ car_signature()

static void car_signature | ( | const float * | magnitudes,
|  | const float * | distances,
|  | uint16_t | length,
|  | signature_t * | signature
| ) |  |
| static

Calculate car signature from car data.

Parameters

  [in] | magnitudes | The car data
  [in] | distances | Corresponding distance for each point in the car data
  [in] | length | The length of magnitudes and distances
  [out] | signature | The calculated signature

Definition at line 1083 of file ref_app_parking.c.

## ◆ compare_signature()

static int compare_signature | ( | const void * | a,
|  | const void * | b
| ) |  |
| static

Function used to compare two signatures for use in qsort.

Parameters

  [in] | a | First signature
  [in] | b | Second signature

Returns
  -1 if a is closer to sensor than b 1 if b is closer to sensor than a 0 if a and b is at same distance from sensor

Definition at line 1167 of file ref_app_parking.c.

## ◆ enter_hibernate()

static bool enter_hibernate | ( | ref_app_parking_handle_t * | handle | ) |
| static

Make sensor enter hibernate.

Parameters

  [in] | handle | The parking handle

Definition at line 1186 of file ref_app_parking.c.

## ◆ exit_hibernate()

static bool exit_hibernate | ( | ref_app_parking_handle_t * | handle | ) |
| static

Make sensor exit hibernate.

Parameters

  [in] | handle | The parking handle

Definition at line 1201 of file ref_app_parking.c.

## ◆ get_measure_timeout_ms()

static uint32_t get_measure_timeout_ms | ( | float | update_rate_hz | ) |
| static

Get timeout value, in ms, for specified update rate.

Parameters

  [in] | update_rate_hz | The update rate, in Hz

Returns
  The timeout value, in ms

Definition at line 1017 of file ref_app_parking.c.

## ◆ initialize_application_resources()

static void initialize_application_resources | ( | ref_app_parking_handle_t * | handle | ) |
| static

Initialize resources for application using already set parking config.

Parameters

  [in] | handle | The parking handle

Definition at line 970 of file ref_app_parking.c.

## ◆ log_config()

static void log_config | ( | ref_app_parking_handle_t * | handle | ) |
| static

Log config.

Parameters

  [in] | handle | The parking handle

Definition at line 834 of file ref_app_parking.c.

## ◆ noise_process()

static float noise_process | ( | acc_int16_complex_t * | noise_data,
|  | float * | noise_magnitudes,
|  | uint16_t | noise_data_length
| ) |  |
| static

Calculate noise level from noise data.

Parameters

  [in] | noise_data | The noise data
  [in] | noise_magnitudes | Intermediate step in processing will be stored here
  [in] | noise_data_length | The length of noise data and magnitudes

Returns
  The noise level

Definition at line 1022 of file ref_app_parking.c.

## ◆ objects_present()

static bool objects_present | ( | const ref_app_parking_handle_t * | handle | ) |
| static

Determine if there are any objects present using signature history and thresholds.

Parameters

  [in] | handle | The parking handle

Returns
  true if objects present, false otherwise

Definition at line 1089 of file ref_app_parking.c.

## ◆ obstruction_noise()

static float obstruction_noise | ( | acc_int16_complex_t * | obs_noise_data,
|  | uint16_t | obs_noise_data_length
| ) |  |
| static

Calculate noise mean from obstruction noise data.

Parameters

  [in] | obs_noise_data | The obstruction noise data
  [in] | obs_noise_data_length | The length of obstruction noise data

Returns
  The noise mean

Definition at line 1048 of file ref_app_parking.c.

## ◆ obstruction_signature()

static void obstruction_signature | ( | acc_int16_complex_t * | subsweep,
|  | float * | magnitudes,
|  | float * | distances,
|  | uint16_t | length,
|  | float | noise_level,
|  | signature_t * | signature
| ) |  |
| static

Calculate obstruction signature from obstruction data.

Parameters

  [in] | subsweep | The obstruction data
  [in] | magnitudes | Intermediate step in processing will be stored here
  [in] | distances | Corresponding distance for each point in the obstruction data
  [in] | length | The length of subsweep, magnitudes, and distances
  [in] | noise_level | The current noise level to compensate for
  [out] | signature | The calculated signature

Definition at line 1063 of file ref_app_parking.c.

## ◆ ref_app_parking_handle_create()

ref_app_parking_handle_t* ref_app_parking_handle_create | ( | ref_app_parking_config_t * | parking_config,
|  | acc_sensor_id_t | sensor_id
| ) |  |

Create parking handle.

The handle is used for both control and processing

This function enables the sensor

Parameters

  [in] | parking_config | The parking config used to create the parking handle
  [in] | sensor_id | The sensor_id for the sensor to be used

Returns
  A parking handle, or NULL if creation failed

Definition at line 252 of file ref_app_parking.c.

## ◆ ref_app_parking_handle_destroy()

void ref_app_parking_handle_destroy | ( | ref_app_parking_handle_t * | handle | ) |

Destroy parking handle.

This function disables the sensor

Parameters

  [in] | handle | The handle to destroy

Definition at line 284 of file ref_app_parking.c.

## ◆ ref_app_parking_handle_indications()

bool ref_app_parking_handle_indications | ( | ref_app_parking_handle_t * | handle,
|  | bool * | data_reliable
| ) |  |

Handle indications from a measurement.

Parameters

  [in] | handle | The handle to do a sensor measurement for
  [out] | data_reliable | Flag to determine if data from measurement is reliable. Se log for more details if false

Returns
  true if successful, false otherwise

Definition at line 597 of file ref_app_parking.c.

## ◆ ref_app_parking_measure()

bool ref_app_parking_measure | ( | ref_app_parking_handle_t * | handle,
|  | bool | hibernate
| ) |  |

Perform a sensor measurement.

Parameters

  [in] | handle | The handle to do a sensor measurement for
  [in] | hibernate | Hibernate sensor between measurements

Returns
  true if successful, false otherwise

Definition at line 554 of file ref_app_parking.c.

## ◆ ref_app_parking_noise_calibration()

bool ref_app_parking_noise_calibration | ( | ref_app_parking_handle_t * | handle | ) |

Noise calibration.

Parameters

  [in] | handle | The handle to calibrate noise for

Returns
  true if successful, false otherwise

Definition at line 390 of file ref_app_parking.c.

## ◆ ref_app_parking_obstruction_calibration()

bool ref_app_parking_obstruction_calibration | ( | ref_app_parking_handle_t * | handle | ) |

Obstruction calibration.

Note that the sensor must be free from obstruction when calling this function.

Parameters

  [in] | handle | The handle to calibrate obstruction for

Returns
  true if successful, false otherwise

Definition at line 445 of file ref_app_parking.c.

## ◆ ref_app_parking_obstruction_process()

void ref_app_parking_obstruction_process | ( | ref_app_parking_handle_t * | handle,
|  | bool * | obstruction_detected
| ) |  |

Do obstruction processing.

Parameters

  [in] | handle | The handle to do obstruction processing for
  [out] | obstruction_detected | true if obstruction detected, false otherwise

Definition at line 663 of file ref_app_parking.c.

## ◆ ref_app_parking_process()

void ref_app_parking_process | ( | ref_app_parking_handle_t * | handle,
|  | bool * | car_detected
| ) |  |

Do parking processing.

Parameters

  [in] | handle | The handle to do parking processing for
  [out] | car_detected | true if car detected, false otherwise

Definition at line 711 of file ref_app_parking.c.

## ◆ ref_app_parking_sensor_calibration()

bool ref_app_parking_sensor_calibration | ( | ref_app_parking_handle_t * | handle | ) |

Sensor calibration.

Parameters

  [in] | handle | The handle to calibrate sensor for

Returns
  true if successful, false otherwise

Definition at line 355 of file ref_app_parking.c.

## ◆ ref_app_parking_sensor_prepare()

bool ref_app_parking_sensor_prepare | ( | ref_app_parking_handle_t * | handle | ) |

Prepare sensor for measurement.

Parameters

  [in] | handle | The handle to prepare sensor for

Returns
  true if successful, false otherwise

Definition at line 537 of file ref_app_parking.c.

## ◆ ref_app_parking_set_config()

void ref_app_parking_set_config | ( | ref_app_parking_parking_preset_t | preset,
|  | ref_app_parking_config_t * | parking_config
| ) |  |

Set parking config according to specified preset.

Parameters

  [in] | preset | The preset used to set parking config
  [out] | parking_config | The parking config to be set

Definition at line 201 of file ref_app_parking.c.

## ◆ same_objects()

static bool same_objects | ( | ref_app_parking_handle_t * | handle | ) |
| static

Determine if multiple signatures relates to same object.

Parameters

  [in] | handle | The parking handle

Returns
  true if multiple signatures relates to same object, false otherwise

Definition at line 1108 of file ref_app_parking.c.

## ◆ set_sensor_config()

static void set_sensor_config | ( | ref_app_parking_handle_t * | handle | ) |
| static

Set sensor config using already set parking config.

Parameters

  [in] | handle | The parking handle

Definition at line 764 of file ref_app_parking.c.