ranging_algorithm_private.h

Allows to fetch data from ranging algorithm for analysis.

Copyright

Copyright (C) 2020 SPARK Microsystems International Inc. All rights reserved.

License

This source code is proprietary and subject to the SPARK Microsystems Software EULA found in this package in file EULA.txt.

Author

SPARK FW Team.

Defines

RANGING_DEV_MAX_SIZE 256

Maximum array size for data accumulation

Typedefs

typedef int16_t (*dev_print_func)(void *pbuf, size_t buf_len)

Print private ranging data.

Parameters
  • pbuf – [in] Pointer to data to print.

  • buf_len – [in] Length of data to print.

Returns number

of byte print.

typedef char *(*str_cat_func)(char *dest, char *src)

Concatenate two strings.

Parameters
  • dest – [in] Destination.

  • src – [in] Source.

Returns Pointer

to new string .

typedef char *(*format_float_func)(float nbr, unsigned char digit, unsigned char decimal_point, char lead_char, unsigned char nul, char *str)

Format float to a string.

Parameters
  • nbr – [in] Floating number to convert.

  • digit – [in] Number of digit wanted in the string output.

  • decimal_point – [in] Seperator for integer and floating part.

  • lead_char – [in] Char to append in front of the formated string.

  • nul – [in] Char to append a the float formated string.

  • str – [in] Pointer to string formated.

Returns Pointer

to string formated.

typedef struct ranging_prv_data ranging_prv_data_t

Ranging data for each part of the calculus.

typedef struct ranging_prv ranging_prv_t

Structure of every intermediate steps of the ranging calculus.

Functions

void ranging_algorithm_prv_init(ranging_prv_t *ranging_prv)

Initialize ranging private data and information.

Parameters

ranging_prv – Ranging private information.

void ranging_algorithm_prv_set_utils(ranging_prv_t *ranging_prv, dev_print_func print_ptr, str_cat_func cat, format_float_func format_float)

Set utils functions for ranging information.

Parameters
  • ranging_prv – Ranging private instance.

  • print_ptr – [in] Pointer to print to interface.

  • cat – [in] Pointer to cat defintion.

  • format_float – [in] Pointer to float_to_string defintion.

void ranging_algorithm_prv_set_raw_data(ranging_prv_t *ranging_prv, ranging_master_slave_info_t *r_info, uint16_t size)

Set private ranging raw data.

Parameters
  • ranging_prv – Ranging private instance.

  • r_info – [in] Phase information.

  • size – [in] Size to be copy.

void ranging_algorithm_prv_set_raw_del_prop(ranging_prv_t *ranging_prv, float *raw_prop, uint16_t size)

Set private ranging raw delay propagation.

Parameters
  • ranging_prv – Ranging private instance.

  • raw_prop – [in] Raw delay propgation.

  • size – [in] Size to be copy.

void ranging_algorithm_prv_set_prop_del_corrected(ranging_prv_t *ranging_prv, float *prop_corrected, uint16_t size)

Set private ranging corrected delay propagation.

Parameters
  • ranging_prv – Ranging private instance.

  • prop_corrected – [in] Value to write to private value.

  • size – [in] Size to copy.

void ranging_algorithm_prv_set_last_distance_data(ranging_prv_t *ranging_prv, float dist)

Set private ranging last distance.

Parameters
  • ranging_prv – Ranging private instance.

  • dist – [in] Distance to write to private value.

void ranging_algorithm_prv_set_prop_del_avg(ranging_prv_t *ranging_prv, float del_prop_avg)

Set private ranging average propgation delay.

Parameters
  • ranging_prv – Ranging private instance.

  • del_prop_avg – [in] Delay of propagation average.

void ranging_algorithm_prv_print_column_label(ranging_prv_t *ranging_prv)

Print the column label for the ranging dev data.

Parameters

ranging_prv – Ranging private instance.

void ranging_algorithm_prv_print(ranging_prv_t *ranging_prv)

Print current ranging information to interface.

Parameters

ranging_prv – Ranging private instance.

void ranging_algorithm_prv_increment_idx(ranging_prv_t *ranging_prv, uint16_t nb_sample)

Increment ranging private index.

Parameters
  • ranging_prv – Ranging private instance.

  • nb_sample – [in] Number of sample taken.

bool ranging_algorithm_prv_is_buf_full(ranging_prv_t *ranging_prv)

Look if the buffer is full.

Parameters

ranging_prv – Ranging private instance.

Returns True

Buffer is full.

Returns False

Buffer is not full.

bool ranging_algorithm_prv_is_buf_empty(ranging_prv_t *ranging_prv)

Look if the buffer is empty.

Parameters

ranging_prv – Ranging private instance.

Returns True

Buffer is empty.

Returns False

Buffer is not empty.

struct ranging_prv_data
#include <ranging_algorithm_private.h>

Ranging data for each part of the calculus.

Public Members

ranging_master_slave_info_t ranging_master_slave[RANGING_DEV_MAX_SIZE]

RX waited and phases of the master

float prop_del_raw[RANGING_DEV_MAX_SIZE]

Propagation delay calculated without correction

float prop_del_corrected[RANGING_DEV_MAX_SIZE]

Propagation delay calculated with correction

float prop_del_average[RANGING_DEV_MAX_SIZE]

Propagation delay average

float last_distance[RANGING_DEV_MAX_SIZE]

The latest calculated distance

struct ranging_prv
#include <ranging_algorithm_private.h>

Structure of every intermediate steps of the ranging calculus.

Public Members

ranging_prv_data_t ranging_prv_data

Ranging data for each part of the calculus

uint16_t current_idx

Current index to enqueueded data in private

dev_print_func print

Print private ranging data

str_cat_func cat

Concatenate two strings

format_float_func format_float

Format float to a string