Chirp SonicLib
4.5.2
|
Internal definitions for the Chirp ICU General Purpose Transceiver (GPT) firmware. More...
#include <stdint.h>
#include <invn/soniclib/details/icu.h>
#include <invn/icu_interface/ch-rangefinder/structs.h>
#include <invn/soniclib/ch_rangefinder_types.h>
#include <invn/soniclib/soniclib.h>
Go to the source code of this file.
Classes | |
struct | icu_gpt_algo_config_t |
Algorithm configuration. More... | |
Macros | |
#define | CH_THRESH_LEVEL_HOLDOFF (40000) |
#define | ICU_GPT_MAX_SAMPLES (IQ_SAMPLES_MAX) |
#define | ICU_GPT_NUM_THRESHOLDS (LEN_THRESH) |
Functions | |
uint16_t | get_icu_gpt_fw_ram_init_addr (void) |
uint16_t | get_icu_gpt_fw_ram_init_size (void) |
const unsigned char * | get_ram_icu_gpt_init_ptr (void) |
uint8_t | icu_gpt_algo_configure (ch_dev_t *dev_ptr, uint8_t meas_num, const icu_gpt_algo_config_t *algo_config_ptr, const ch_thresholds_t *lib_thresh_ptr) |
Configure GPT Algorithm. More... | |
ch_output_type_t | icu_gpt_algo_get_iq_output (ch_dev_t *dev_ptr, uint8_t meas_num) |
Get the I/Q data output format of GPT Algorithm. More... | |
uint8_t | icu_gpt_algo_get_num_targets (ch_dev_t *dev_ptr) |
Get the number of targets detected in last measurement. More... | |
uint16_t | icu_gpt_algo_get_target_amplitude (ch_dev_t *dev_ptr, uint8_t target_num) |
Get the amplitude for a specific target detected in last measurement. More... | |
uint32_t | icu_gpt_algo_get_target_range (ch_dev_t *dev_ptr, uint8_t target_num, ch_range_t range_type) |
Get the range to a specific target detected in last measurement. More... | |
uint32_t | icu_gpt_algo_get_target_tof_us (ch_dev_t *dev_ptr, uint8_t target_num) |
Get the measured time-of-flight for a specific target in microseconds. More... | |
uint8_t | icu_gpt_algo_init (ch_dev_t *dev_ptr, InvnAlgoRangeFinderConfig *algo_cfg) |
Initialize GPT Algorithm. More... | |
uint8_t | icu_gpt_algo_is_target_in_ringdown (ch_dev_t *dev_ptr) |
Return if a target is detected near sensor (in the ringdown) More... | |
void | icu_gpt_algo_reset (ch_dev_t *dev_ptr, uint8_t meas_num) |
Reset GPT Algorithm configuration. More... | |
uint8_t | icu_gpt_algo_set_data_output (ch_dev_t *dev_ptr, const ch_output_t *output_ptr) |
Set data output format and rate. More... | |
uint8_t | icu_gpt_algo_set_iq_output (ch_dev_t *dev_ptr, uint8_t meas_num, ch_output_type_t output_format) |
Set the I/Q data output format of GPT Algorithm. More... | |
void | icu_gpt_algo_update_odr (ch_dev_t *dev_ptr, uint8_t meas_num, ch_odr_t new_odr) |
Update algo ODR. More... | |
uint8_t | icu_gpt_display_algo_thresholds (ch_dev_t *dev_ptr) |
Display GPT thresholds for debug purpose. More... | |
uint8_t | icu_gpt_get_filter_update (ch_dev_t *dev_ptr, uint8_t meas_num) |
Get the filter update interval for a measurement. More... | |
uint8_t | icu_gpt_get_num_ranges (ch_dev_t *dev_ptr, uint8_t meas_num) |
Get the max number of reported target ranges for a measurement. More... | |
uint16_t | icu_gpt_get_ringdown_cancel (ch_dev_t *dev_ptr, uint8_t meas_num) |
Get the number of ringdown cancellation samples for a measurement. More... | |
uint16_t | icu_gpt_get_rx_holdoff (ch_dev_t *dev_ptr, uint8_t meas_num) |
Get the receive holdoff sample count for a specific measurement. More... | |
uint16_t | icu_gpt_get_static_filter (ch_dev_t *dev_ptr, uint8_t meas_num) |
Get the number of static target filter samples for a measurement. More... | |
uint8_t | icu_gpt_get_thresholds (ch_dev_t *dev_ptr, uint8_t meas_num, ch_thresholds_t *lib_thresh_buf_ptr) |
Get detection thresholds for a specific measurement. More... | |
uint8_t | icu_gpt_init (ch_dev_t *dev_ptr, fw_info_t **fw_info) |
Initialize GPT FW. More... | |
uint8_t | icu_gpt_set_filter_update (ch_dev_t *dev_ptr, uint8_t meas_num, uint8_t update_interval) |
Set the filter update interval for a measurement. More... | |
uint8_t | icu_gpt_set_num_ranges (ch_dev_t *dev_ptr, uint8_t meas_num, uint8_t num_ranges) |
Set the max number of reported target ranges for a measurement. More... | |
uint8_t | icu_gpt_set_ringdown_cancel (ch_dev_t *dev_ptr, uint8_t meas_num, uint16_t num_samples) |
Set the number of ringdown cancellation samples for a measurement. More... | |
uint8_t | icu_gpt_set_rx_holdoff (ch_dev_t *dev_ptr, uint8_t meas_num, uint16_t num_samples) |
Set the receive holdoff sample count for a specific measurement. More... | |
uint8_t | icu_gpt_set_static_filter (ch_dev_t *dev_ptr, uint8_t meas_num, uint16_t num_samples) |
Set the number of static target filter samples for a measurement. More... | |
uint8_t | icu_gpt_set_thresholds (ch_dev_t *dev_ptr, uint8_t meas_num, const ch_thresholds_t *lib_thresh_buf_ptr) |
Set detection thresholds for a specific measurement. More... | |
Variables | |
const uint8_t | icu_gpt_fw_text [] |
const uint8_t | icu_gpt_fw_vec [] |
const uint16_t | icu_gpt_text_size |
const uint16_t | icu_gpt_vec_size |
const char * | icu_gpt_version |
Internal definitions for the Chirp ICU General Purpose Transceiver (GPT) firmware.
This file contains various definitions and values for use with the icu_gpt sensor firmware.
You should not need to edit this file or call the driver functions directly. Doing so will reduce your ability to benefit from future enhancements and releases from Chirp.
uint8_t icu_gpt_algo_configure | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num, | ||
const icu_gpt_algo_config_t * | algo_config_ptr, | ||
const ch_thresholds_t * | lib_thresh_ptr | ||
) |
Configure GPT Algorithm.
dev_ptr | pointer to the ch_dev_t descriptor structure | |
[in] | meas_num | The measurement number |
[in] | algo_config_ptr | Pointer to the configuration to apply to algorithm |
[in] | lib_thresh_ptr | Pointer to detection threshold definitions |
This function initializes the measurement specified by meas_num with the specified configuration and detection thresholds.
filter_update_interval - how often to update the ringdown and STR filters
thresh_ptr is a pointer to a structure containing the definitions of the detection thresholds that will be used to detect a target. (This same type of structure is used by ch_set_thresholds().)
ch_output_type_t icu_gpt_algo_get_iq_output | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num | ||
) |
Get the I/Q data output format of GPT Algorithm.
dev_ptr | pointer to the ch_dev_t descriptor structure | |
[in] | meas_num | The measurement number |
This function returns the measurement I/Q data output format, as follows:
uint8_t icu_gpt_algo_get_num_targets | ( | ch_dev_t * | dev_ptr | ) |
Get the number of targets detected in last measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
This function returns the number of valid targets that were detected in the last measurement completed by the sensor. Data for each of these targets may then be read using ch_get_target_range() and ch_get_target_amplitude().
See also ch_get_target_range(), ch_set_num_ranges().
uint16_t icu_gpt_algo_get_target_amplitude | ( | ch_dev_t * | dev_ptr, |
uint8_t | target_num | ||
) |
Get the amplitude for a specific target detected in last measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
target_num | number of target to report |
This function reads the measurement data for a specific target and returns the measured amplitude value. The amplitude is representative of the incoming sound pressure. The value is expressed in internal sensor counts (LSBs) and is not calibrated to any standard units.
The amplitude value is not updated if a measurement cycle resulted in CH_NO_TARGET, as returned by ch_get_target_range().
See also ch_get_target_range(), ch_get_amplitude().
uint32_t icu_gpt_algo_get_target_range | ( | ch_dev_t * | dev_ptr, |
uint8_t | target_num, | ||
ch_range_t | range_type | ||
) |
Get the range to a specific target detected in last measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
target_num | number of target to report |
range_type | the range type to be reported (e.g. one-way vs. round-trip) |
This function reads the measurement data for a specific target and then computes the actual range. It should be called after the sensor has indicated that a measurement cycle is complete by generating a signal on the INT line. (Typically, this will be set up by an interrupt handler associated with that input line.)
target_num specifies the target whose range is to be calculated. The ch_get_num_targets() function may be used to determine the total number of valid targets detected by the measurement.
The range_type parameter indicates whether the measurement is based on the one-way or round-trip distance to/from a target, or the direct distance between two sensors operating in pitch-catch mode. The possible values are:
See also ch_get_target_amplitude(), ch_get_range(), ch_get_num_targets().
uint32_t icu_gpt_algo_get_target_tof_us | ( | ch_dev_t * | dev_ptr, |
uint8_t | target_num | ||
) |
Get the measured time-of-flight for a specific target in microseconds.
dev_ptr | pointer to the ch_dev_t descriptor structure |
target_num | number of the detected target to be reported |
This function reads the measurement result registers from the sensor and then computes the time-of-flight in microseconds. The time-of-flight is returned as a 32-bit integer.
If the sensor did not successfully find the range of a target during the most recent measurement, the returned value will be zero (0). If an error occurs when getting or calculating the range, zero (0) will be returned.
uint8_t icu_gpt_algo_init | ( | ch_dev_t * | dev_ptr, |
InvnAlgoRangeFinderConfig * | algo_cfg | ||
) |
Initialize GPT Algorithm.
dev_ptr | pointer to the ch_dev_t descriptor structure |
algo_cfg | Pointer to algorithm configuration instanciated in application |
uint8_t icu_gpt_algo_is_target_in_ringdown | ( | ch_dev_t * | dev_ptr | ) |
Return if a target is detected near sensor (in the ringdown)
dev_ptr | pointer to the ch_dev_t descriptor structure |
void icu_gpt_algo_reset | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num | ||
) |
Reset GPT Algorithm configuration.
dev_ptr | pointer to the ch_dev_t descriptor structure | |
[in] | meas_num | The measurement number |
uint8_t icu_gpt_algo_set_data_output | ( | ch_dev_t * | dev_ptr, |
const ch_output_t * | output_ptr | ||
) |
Set data output format and rate.
dev_ptr | pointer to the ch_dev_t descriptor structure |
output_ptr | pointer to the data output type, including format and decimation factor |
This function sets both the data output format type and rate for sample data within a measurement. The values are passed in a ch_output_t structure specified by output_ptr, which contains two fields, output_type and decimation_factor. The decimation factor is equivalent to the sample output data rate (ODR) of the sensor, expressed differently.
The possible values for output_type are:
The possible values for decimation_factor and the equivalent output rate (ODR) values are as follows:
Decimation Factor | ODR Value | Sample Rate vs. Default |
---|---|---|
CH_DECIMATION_NONE | CH_ODR_FREQ_DIV_8 (CH_ODR_DEFAULT) | default |
CH_DECIMATION_0_25 | CH_ODR_FREQ_DIV_2 | 4 x default |
CH_DECIMATION_0_50 | CH_ODR_FREQ_DIV_4 | 2 x default |
CH_DECIMATION_2 | CH_ODR_FREQ_DIV_16 | 1/2 default |
CH_DECIMATION_3 | no equivalent | 1/3 default - only in special CHx01 f/w |
CH_DECIMATION_4 | CH_ODR_FREQ_DIV_32 | 1/4 default |
Both measurements will be set to the specified output type. To change the output format for a single measurement, use ch_meas_set_iq_output(). To change the output data rate for a single measurement, use ch_meas_set_odr().
uint8_t icu_gpt_algo_set_iq_output | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num, | ||
ch_output_type_t | output_format | ||
) |
Set the I/Q data output format of GPT Algorithm.
dev_ptr | pointer to the ch_dev_t descriptor structure |
meas_num | measurement number |
output_format | I/Q output format 0=normal (Q,I) pairs; 1=amplitude,threshold pairs, 2=amplitude array |
This function sets the measurement I/Q data output format. The data may be output in three different formats, based on the value of output_format:
Update algo ODR.
dev_ptr | pointer to the ch_dev_t descriptor structure | |
[in] | meas_num | The measurement number |
[in] | new_odr | The new odr |
Shall be called before ch_meas_set_odr because it relies on current ODR to update algorithm configuration
uint8_t icu_gpt_display_algo_thresholds | ( | ch_dev_t * | dev_ptr | ) |
Display GPT thresholds for debug purpose.
dev_ptr | pointer to the ch_dev_t descriptor structure |
uint8_t icu_gpt_get_filter_update | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num | ||
) |
Get the filter update interval for a measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
This function returns the interval value for how often the ringdown cancellation and static target rejection (STR) filters are updated in the sensor. A value of 0 will update the filters during every measurement. A value of 1 will update every second measurement, a value of 2 will update every third measurement, etc.
See also icu_gpt_set_filter_update().
uint8_t icu_gpt_get_num_ranges | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num | ||
) |
Get the max number of reported target ranges for a measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
This function returns the maximum number of separate target range values that the sensor will report in a single measurement.
uint16_t icu_gpt_get_ringdown_cancel | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num | ||
) |
Get the number of ringdown cancellation samples for a measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
meas_num | measurement number |
This function returns the number of samples in the specified measurement that will receive "ringdown cancellation" processing. These samples are always the first in the measurement (corresponding to targets closest to the sensor).
See also icu_gpt_set_ringdown_cancel().
uint16_t icu_gpt_get_rx_holdoff | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num | ||
) |
Get the receive holdoff sample count for a specific measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
meas_num | measurement number |
This function gets the receive (rx) holdoff sample count for the specified measurement. The rx holdoff count is the number of samples at the beginning of a measurement that will be ignored for the purpose of detecting a target, as previously set by icu_gpt_set_rx_holdoff().
To convert the returned sample count to a physical distance, use ch_samples_to_mm().
The ch_get_rx_holdoff() function performs the same operation for the default measurement (same as setting meas_num to CH_DEFAULT_MEAS_NUM).
See also icu_gpt_set_rx_holdoff().
uint16_t icu_gpt_get_static_filter | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num | ||
) |
Get the number of static target filter samples for a measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
meas_num | measurement number |
This function returns the number pf samples in the specified measurement that will have static target rejection (STR) filtering. STR filtering compares the active measurement with previously observed values and will only report a target detection when there has been noticeable change in the measured signal.
The STR samples are always the first in the measurement (corresponding to targets closest to the sensor).
The ch_get_static_filter() function performs the same operation for the default measurement (same as setting meas_num to CH_DEFAULT_MEAS_NUM).
See also icu_gpt_set_static_filter().
uint8_t icu_gpt_get_thresholds | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num, | ||
ch_thresholds_t * | lib_thresh_buf_ptr | ||
) |
Get detection thresholds for a specific measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
meas_num | measurement number |
thresh_ptr | pointer to ch_thresholds_t structure to receive threshold data |
This function obtains the current detection threshold values for one of the two measurements, as specified by meas_num.
The threshold values are returned in a ch_thresholds_t structure specified by thresh_ptr. The ch_thresholds_t structure holds an array of ch_thresh_t structures, each of which contains a starting sample number and amplitude threshold value.
The ch_get_thresholds() function performs the same operation for the default measurement (same as setting meas_num to CH_DEFAULT_MEAS_NUM).
Initialize GPT FW.
This function shall not be directly called. It shall be passed in parameter of ch_init
uint8_t icu_gpt_set_filter_update | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num, | ||
uint8_t | update_interval | ||
) |
Set the filter update interval for a measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
meas_num | measurement number |
update_interval | how often to update, 0 = every sample |
This function specifies how often the ringdown cancellation and static target rejection (STR) filters are updated in the sensor. A value of 0 will update the filters during every measurement. A value of 1 will update every second measurement, a value of 2 will update every third measurement, etc.
See also icu_gpt_get_filter_update().
uint8_t icu_gpt_set_num_ranges | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num, | ||
uint8_t | num_ranges | ||
) |
Set the max number of reported target ranges for a measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
meas_num | measurement number |
num_ranges | maximum number of target range values to report |
This function sets the maximum number of separate target range values that the sensor will report in a single measurement.
If num_ranges is set to 1, only a single target will be reported. Generally, this will be the closest target whose signal exceeds the detection threshold value for that part of the measurement. Other targets will not be reported.
If num_ranges is greater than 1, if multiple targets have ultrasound signals that exceed the applicable threshold value, the sensor will report range (and amplitude) values for each.
See also ch_get_target_range(), ch_get_target_amplitude(), icu_gpt_get_num_ranges().
uint8_t icu_gpt_set_ringdown_cancel | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num, | ||
uint16_t | num_samples | ||
) |
Set the number of ringdown cancellation samples for a measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
meas_num | measurement number |
num_samples | number of samples (closest to sensor) to get ringdown cancellation |
This function sets the number of samples in the specified measurement that will receive "ringdown cancellation" processing. These samples are always the first in the measurement (corresponding to targets closest to the sensor).
Ringdown is the physical settling time of the ultrasound transducer after generating a transmit pulse. This settling causes a large false signal in the first receive samples after the transmit segment ends. Ringdown cancellation is a filtering technique to remove these ringdown artifacts. However, it can also affect the sensing ability at close range. The number of ringdown samples may be tuned to obtain the best performance in a specific application.
If the ringdown cancel sample count is too low, it will result in false detections at very close indicated ranges.
See also icu_gpt_get_ringdown_cancel()
uint8_t icu_gpt_set_rx_holdoff | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num, | ||
uint16_t | num_samples | ||
) |
Set the receive holdoff sample count for a specific measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
meas_num | measurement number |
num_samples | number of samples to be ignored at the beginning of each measurement |
This function sets the receive (rx) holdoff sample count for the specified measurement. num_samples specifies a number of samples at the beginning of a measurement that will be ignored for the purpose of detecting a target. (These samples correspond to the closest distances from the sensor.)
To convert a physical distance into a sample count value to use here, use ch_meas_mm_to_samples().
The ch_set_rx_holdoff() function performs the same operation for the default measurement (same as setting meas_num to CH_DEFAULT_MEAS_NUM).
See also icu_gpt_get_rx_holdoff().
uint8_t icu_gpt_set_static_filter | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num, | ||
uint16_t | num_samples | ||
) |
Set the number of static target filter samples for a measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
meas_num | measurement number |
num_samples | number of samples (closest to sensor) to have STR filtering |
This function sets the number pf samples in the specified measurement that will have static target rejection (STR) filtering. STR filtering compares the active measurement with previously observed values and will only report a target detection when there has been noticeable change in the measured signal.
The STR samples are always the first in the measurement (corresponding to targets closest to the sensor).
The ch_set_static_range() function performs the same operation for the default measurement (same as setting meas_num to CH_DEFAULT_MEAS_NUM).
See also icu_gpt_get_static_filter()
uint8_t icu_gpt_set_thresholds | ( | ch_dev_t * | dev_ptr, |
uint8_t | meas_num, | ||
const ch_thresholds_t * | lib_thresh_buf_ptr | ||
) |
Set detection thresholds for a specific measurement.
dev_ptr | pointer to the ch_dev_t descriptor structure |
meas_num | measurement number |
thresh_ptr | pointer to ch_thresholds_t structure containing threshold data |
This function sets the detection threshold values for the measurement specified by meas_num, based on the values in the ch_thresholds_t structure specified by thresh_ptr. The ch_thresholds_t structure holds an array of ch_thresh_t structures, each of which contains a starting sample number and amplitude threshold value.
To use this function, first initialize the fields in the ch_thresh_t structure with the sample/level pair of values for each threshold. The ICU sensor supports eight (8) separate thresholds. Each threshold has a maximum sample length of 255.
It is not necessary to use the full set of thresholds, if the appliction and sensing environment do not require that many different levels. Unused thresholds should occupy the last ch_thresh_t elements in the ch_thresholds_t structure and should have zero (0) for their starting sample number. These entries will be ignored, and the threshold specified in the final valid entry will apply to the rest of the measurement.
The ch_set_thresholds() function performs the same operation for the default measurement (same as setting meas_num to CH_DEFAULT_MEAS_NUM).
See also ch_set_thresholds(), icu_gpt_get_thresholds().