Chirp SonicLib  2.1.0
ch101_gppc.h
Go to the documentation of this file.
1 
13 /*
14  * Copyright © 2016-2019, Chirp Microsystems. All rights reserved.
15  *
16  * Chirp Microsystems CONFIDENTIAL
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL CHIRP MICROSYSTEMS BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  * You can contact the authors of this program by email at support@chirpmicro.com
30  * or by mail at 2560 Ninth Street, Suite 220, Berkeley, CA 94710.
31  */
32 
33 #ifndef CH101_GPPC_H_
34 #define CH101_GPPC_H_
35 
36 #include "ch101.h"
37 #include "soniclib.h"
38 #include <stdint.h>
39 
40 /* GPPC firmware registers */
41 #define CH101_GPPC_REG_OPMODE 0x01
42 #define CH101_GPPC_REG_TICK_INTERVAL 0x02
43 #define CH101_GPPC_REG_PERIOD 0x05
44 #define CH101_GPPC_REG_CAL_TRIG 0x06
45 #define CH101_GPPC_REG_MAX_RANGE 0x07
46 #define CH101_GPPC_REG_TX_LENGTH 0x08
47 #define CH101_GPPC_REG_CAL_RESULT 0x0A
48 #define CH101_GPPC_REG_DCO_SET 0x0C
49 #define CH101_GPPC_REG_THRESHOLD 0x0E
50 #define CH101_GPPC_REG_RX_HOLDOFF 0x11
51 #define CH101_GPPC_REG_ST_COEFF 0x13
52 #define CH101_GPPC_REG_READY 0x14
53 #define CH101_GPPC_REG_TOF_SF 0x16
54 #define CH101_GPPC_REG_TOF 0x18
55 #define CH101_GPPC_REG_AMPLITUDE 0x1A
56 #define CH101_GPPC_REG_RX_PULSE_LENGTH 0x1C
57 #define CH101_GPPC_REG_DATA 0x1E
58 
59 #define CH101_GPPC_MAX_SAMPLES (350)
60 
61 #define CH101_GPPC_READY_FREQ_LOCKED (0x04)
62 
63 #define CH101_GPPC_THRESHOLD_NUMBER 1
64 
65 #define CH_SF_LOCK_FOUND (0)
66 #define CH_SF_LOCK_START (1)
67 #define CH_DCO_LOW 100
68 #define CH_DCO_HIGH 250
69 #define CH_DCO_SEARCH_THRESHOLD 100 //Hz, if error is above this, do a search
70 #define DEBUG_DCO_SEARCH(X) X
71 //#define DEBUG_DCO_SEARCH(X)
72 
73 extern const char *ch101_gppc_version; // version string in fw .c file
74 extern const uint8_t ch101_gppc_fw[CH101_FW_SIZE];
75 
76 uint16_t get_ch101_gppc_fw_ram_init_addr(void);
77 uint16_t get_ch101_gppc_fw_ram_init_size(void);
78 
79 const unsigned char * get_ram_ch101_gppc_init_ptr(void);
80 
81 uint8_t ch101_gppc_init(ch_dev_t *dev_ptr, ch_group_t *grp_ptr, uint8_t i2c_addr, uint8_t dev_num, uint8_t i2c_bus_index);
82 
83 uint32_t ch101_gppc_set_new_dco_code(ch_dev_t *dev_ptr, uint16_t dcocode);
84 uint8_t ch101_gppc_set_frequency(ch_dev_t *dev_ptr, uint32_t target_freq_Hz);
85 
86 
87 
88 #endif
Chirp SonicLib public API and support functions for Chirp ultrasonic sensors.
Internal definitions for the Chirp CH101 ultrasonic sensor.
Chirp sensor device structure.
Definition: soniclib.h:349
Chirp sensor group configuration structure.
Definition: soniclib.h:329