35#include "mikrosdk_version.h"
38#if mikroSDK_GET_VERSION < 20800ul
39#include "rcu_delays.h"
45#include "drv_digital_out.h"
46#include "drv_digital_in.h"
47#include "drv_i2c_master.h"
69#define PCR_REG_VERSION 0x0000
70#define PCR_REG_PROTOCOL_STATUS 0x0001
71#define PCR_REG_MEASURE_CNT 0x0002
72#define PCR_REG_DETECTOR_STATUS 0x0003
73#define PCR_REG_DISTANCE_RESULT 0x0010
74#define PCR_REG_PEAK0_DISTANCE 0x0011
75#define PCR_REG_PEAK1_DISTANCE 0x0012
76#define PCR_REG_PEAK2_DISTANCE 0x0013
77#define PCR_REG_PEAK3_DISTANCE 0x0014
78#define PCR_REG_PEAK4_DISTANCE 0x0015
79#define PCR_REG_PEAK5_DISTANCE 0x0016
80#define PCR_REG_PEAK6_DISTANCE 0x0017
81#define PCR_REG_PEAK7_DISTANCE 0x0018
82#define PCR_REG_PEAK8_DISTANCE 0x0019
83#define PCR_REG_PEAK9_DISTANCE 0x001A
84#define PCR_REG_PEAK0_STRENGTH 0x001B
85#define PCR_REG_PEAK1_STRENGTH 0x001C
86#define PCR_REG_PEAK2_STRENGTH 0x001D
87#define PCR_REG_PEAK3_STRENGTH 0x001E
88#define PCR_REG_PEAK4_STRENGTH 0x001F
89#define PCR_REG_PEAK5_STRENGTH 0x0020
90#define PCR_REG_PEAK6_STRENGTH 0x0021
91#define PCR_REG_PEAK7_STRENGTH 0x0022
92#define PCR_REG_PEAK8_STRENGTH 0x0023
93#define PCR_REG_PEAK9_STRENGTH 0x0024
94#define PCR_REG_START 0x0040
95#define PCR_REG_END 0x0041
96#define PCR_REG_MAX_STEP_LEN 0x0042
97#define PCR_REG_CLOSE_RANGE_LEAK 0x0043
98#define PCR_REG_SIGNAL_QUALITY 0x0044
99#define PCR_REG_MAX_PROFILE 0x0045
100#define PCR_REG_TRESHOLD_SENSITIVITY 0x0046
101#define PCR_REG_PEAK_SORTI 0x0047
102#define PCR_REG_MAX_FRAMES_RECORDED 0x0048
103#define PCR_REG_AMPLITUDE_TERSHOLD 0x0049
104#define PCR_REG_TERSHOLD_SENSITIVITY 0x004A
105#define PCR_REG_REFLECTOR_SHAPE 0x004B
106#define PCR_REG_STRENGHT_TRESHOLD 0x004C
107#define PCR_REG_MEASURE_ON_WAKEUP 0x0080
108#define PCR_REG_COMMAND 0x0100
131#define PCR_STATUS_RSS_REG_OK 0x00000001ul
132#define PCR_STATUS_CFG_CREATE_OK 0x00000002ul
133#define PCR_STATUS_SENSOR_CREATE_OK 0x00000004ul
134#define PCR_STATUS_DETECTOR_CREATE_OK 0x00000008ul
135#define PCR_STATUS_DETECTOR_BUFFER_OK 0x00000010ul
136#define PCR_STATUS_SENSOR_BUFFER_OK 0x00000020ul
137#define PCR_STATUS_CALIB_BUFFER_OK 0x00000040ul
138#define PCR_STATUS_CFG_APPLY_OK 0x00000080ul
139#define PCR_STATUS_SENSOR_CALIB_OK 0x00000100ul
140#define PCR_STATUS_DETECTOR_CALIB_OK 0x00000200ul
141#define PCR_STATUS_RSS_REG_ERR 0x00010000ul
142#define PCR_STATUS_CFG_CREATE_ERR 0x00020000ul
143#define PCR_STATUS_SENSOR_CREATE_ERR 0x00040000ul
144#define PCR_STATUS_DETECTOR_CREATE_ERR 0x00080000ul
145#define PCR_STATUS_DETECTOR_BUFFER_ERR 0x00100000ul
146#define PCR_STATUS_SENSOR_BUFFER_ERR 0x00200000ul
147#define PCR_STATUS_CALIB_BUFFER_ERR 0x00400000ul
148#define PCR_STATUS_CFG_APPLY_ERR 0x00800000ul
149#define PCR_STATUS_SENSOR_CALIB_ERR 0x01000000ul
150#define PCR_STATUS_DETECTOR_CALIB_ERR 0x02000000ul
151#define PCR_STATUS_DETECTOR_ERR 0x10000000ul
152#define PCR_STATUS_BUSY 0x80000000ul
158#define PCR_APPLY_CFG_AND_CALIB_CMD 0x00000001ul
159#define PCR_MEASURE_DISTANCE_CMD 0x00000002ul
160#define PCR_APPLY_CONFIGURATION_CMD 0x00000003ul
161#define PCR_CALIBRATE_CMD 0x00000004ul
162#define PCR_RECALIBRATE_CMD 0x00000005ul
163#define PCR_ENABLE_UART_LOGS_CMD 0x00000020ul
164#define PCR_DISABLE_UART_LOGS_CMD 0x00000021ul
165#define PCR_LOG_CONFIGURATION_CMD 0x00000022ul
166#define PCR_RESET_MODULE_CMD 0x52535421ul
172#define PCR_PIN_STATE_HIGH 0x01
173#define PCR_PIN_STATE_LOW 0x00
179#define PCR_MIN_DISTANCE 10
180#define PCR_MAX_DISTANCE 5000
187#define PCR_DEVICE_ADDRESS 0x52
205#define PCR_MAP_MIKROBUS( cfg, mikrobus ) \
206 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
207 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
208 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
209 cfg.wup = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
210 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
uint8_t pcr_get_int_pin(pcr_t *ctx)
PCR get interrupt pin state function.
err_t pcr_check_if_busy(pcr_t *ctx)
PCR check if device is busy function.
err_t pcr_get_distance(pcr_t *ctx, uint32_t *distance_data)
PCR read distance function.
err_t pcr_read_reg(pcr_t *ctx, uint16_t reg, uint32_t *data_out)
PCR register reading function.
void pcr_set_wup_pin(pcr_t *ctx, uint8_t pin_state)
PCR set wake up pin state function.
err_t pcr_generic_read(pcr_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
PCR I2C reading function.
err_t pcr_generic_write(pcr_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
PCR I2C writing function.
err_t pcr_init(pcr_t *ctx, pcr_cfg_t *cfg)
PCR initialization function.
err_t pcr_default_cfg(pcr_t *ctx)
PCR default configuration function.
void pcr_hw_reset(pcr_t *ctx)
PCR hardware reset function.
void pcr_cfg_setup(pcr_cfg_t *cfg)
PCR configuration object setup function.
err_t pcr_get_status(pcr_t *ctx, uint32_t *status)
PCR get status function.
err_t pcr_write_reg(pcr_t *ctx, uint16_t reg, uint32_t data_in)
PCR register writing function.
void pcr_set_rst_pin(pcr_t *ctx, uint8_t pin_state)
PCR set reset pin state function.
err_t pcr_check_if_ok(pcr_t *ctx)
PCR check if device is ok function.
pcr_return_value_t
PCR Click return value data.
Definition: pcr.h:259
@ PCR_BUSY
Definition: pcr.h:261
@ PCR_ERROR
Definition: pcr.h:262
@ PCR_OK
Definition: pcr.h:260
PCR Click configuration object.
Definition: pcr.h:241
pin_name_t wup
Definition: pcr.h:246
uint32_t i2c_speed
Definition: pcr.h:249
pin_name_t scl
Definition: pcr.h:242
pin_name_t int_pin
Definition: pcr.h:247
pin_name_t sda
Definition: pcr.h:243
pin_name_t rst
Definition: pcr.h:245
uint8_t i2c_address
Definition: pcr.h:250
PCR Click context object.
Definition: pcr.h:220
digital_in_t int_pin
Definition: pcr.h:226
i2c_master_t i2c
Definition: pcr.h:229
digital_out_t wup
Definition: pcr.h:223
digital_out_t rst
Definition: pcr.h:222
uint8_t slave_address
Definition: pcr.h:232