Chirp SonicLib  4.5.2
Functions
ch101_gpr.c File Reference

Chirp CH101 General Purpose Rangefinding firmware interface. More...

#include "ch101_gpr.h"
#include <invn/soniclib/details/ch_common.h>

Functions

uint8_t ch101_gpr_get_in_ringdown_idx (ch_dev_t *dev_ptr)
 Get the sample index that defines the "in ringdown" region. More...
 
uint16_t ch101_gpr_get_in_ringdown_ths (ch_dev_t *dev_ptr)
 Get the amplitude threshold for "in ringdown" detection. More...
 
uint8_t ch101_gpr_get_target_in_ringdown (ch_dev_t *dev_ptr)
 Get the target "in ringdown" status. More...
 
uint8_t ch101_gpr_init (ch_dev_t *dev_ptr, fw_info_t **fw_info)
 
void ch101_gpr_set_in_ringdown_idx (ch_dev_t *dev_ptr, uint8_t in_ringdown_idx)
 Set the sample index for "in ringdown" status. More...
 
void ch101_gpr_set_in_ringdown_ths (ch_dev_t *dev_ptr, uint16_t in_ringdown_ths)
 Set the amplitude threshold "in ringdown" status. More...
 

Detailed Description

Chirp CH101 General Purpose Rangefinding firmware interface.

This file contains function definitions to interface a specific sensor firmware package to SonicLib, including the main initialization routine for the firmware. That routine initializes various fields within the ch_dev_t device descriptor and specifies the proper functions to implement SonicLib API calls. Those may either be common implementations or firmware-specific routines located in this file.

Function Documentation

◆ ch101_gpr_get_in_ringdown_idx()

uint8_t ch101_gpr_get_in_ringdown_idx ( ch_dev_t dev_ptr)

Get the sample index that defines the "in ringdown" region.

Parameters
dev_ptrpointer to the ch_dev_t descriptor structure
Returns
the sample index that defines the "in ringdown" region. If the range is under this value, the ch101_gpr_get_target_in_ringdown() function will return 1, otherwise 0.
Note
This is a beta function and might move or change name in a future release.

◆ ch101_gpr_get_in_ringdown_ths()

uint16_t ch101_gpr_get_in_ringdown_ths ( ch_dev_t dev_ptr)

Get the amplitude threshold for "in ringdown" detection.

Parameters
dev_ptrpointer to the ch_dev_t descriptor structure
Returns
the threshold in LSB applied to the second peak of the ringdown (sample 15) to recognize if a target is in the ringdown region

◆ ch101_gpr_get_target_in_ringdown()

uint8_t ch101_gpr_get_target_in_ringdown ( ch_dev_t dev_ptr)

Get the target "in ringdown" status.

Parameters
dev_ptrpointer to the ch_dev_t descriptor structure
Returns
0 if the target is absent or far away from the ringdown, 1 when the range is less than about 130mm (default and programmable using in_ringdown_idx parameter) on CH101 and less than about 200mm on CH201

For both sensors, when ch101_gpr_get_target_in_ringdown() goes from 0->1, it will remain at 1 for at least 4 measurements, to prevent glitches. When the target leaves the ringdown region there will be a 4 sample latency before ch101_gpr_get_target_in_ringdown() returns 0.

◆ ch101_gpr_set_in_ringdown_idx()

void ch101_gpr_set_in_ringdown_idx ( ch_dev_t dev_ptr,
uint8_t  in_ringdown_idx 
)

Set the sample index for "in ringdown" status.

Parameters
dev_ptrpointer to the ch_dev_t descriptor structure in_ringdown_idx the sample index that defines the "in ringdown" region. Default value is 17 samples equals at about 130mm.

◆ ch101_gpr_set_in_ringdown_ths()

void ch101_gpr_set_in_ringdown_ths ( ch_dev_t dev_ptr,
uint16_t  in_ringdown_ths 
)

Set the amplitude threshold "in ringdown" status.

Parameters
dev_ptrpointer to the ch_dev_t descriptor structure in_ringdown_ths the threshold in LSB applied to the second peak of the ringdown (sample 15) to recognize if a target is in the ringdown region. Default value is 3000