35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_i2c_master.h"
59#define PCR_REG_VERSION 0x0000
60#define PCR_REG_PROTOCOL_STATUS 0x0001
61#define PCR_REG_MEASURE_CNT 0x0002
62#define PCR_REG_DETECTOR_STATUS 0x0003
63#define PCR_REG_DISTANCE_RESULT 0x0010
64#define PCR_REG_PEAK0_DISTANCE 0x0011
65#define PCR_REG_PEAK1_DISTANCE 0x0012
66#define PCR_REG_PEAK2_DISTANCE 0x0013
67#define PCR_REG_PEAK3_DISTANCE 0x0014
68#define PCR_REG_PEAK4_DISTANCE 0x0015
69#define PCR_REG_PEAK5_DISTANCE 0x0016
70#define PCR_REG_PEAK6_DISTANCE 0x0017
71#define PCR_REG_PEAK7_DISTANCE 0x0018
72#define PCR_REG_PEAK8_DISTANCE 0x0019
73#define PCR_REG_PEAK9_DISTANCE 0x001A
74#define PCR_REG_PEAK0_STRENGTH 0x001B
75#define PCR_REG_PEAK1_STRENGTH 0x001C
76#define PCR_REG_PEAK2_STRENGTH 0x001D
77#define PCR_REG_PEAK3_STRENGTH 0x001E
78#define PCR_REG_PEAK4_STRENGTH 0x001F
79#define PCR_REG_PEAK5_STRENGTH 0x0020
80#define PCR_REG_PEAK6_STRENGTH 0x0021
81#define PCR_REG_PEAK7_STRENGTH 0x0022
82#define PCR_REG_PEAK8_STRENGTH 0x0023
83#define PCR_REG_PEAK9_STRENGTH 0x0024
84#define PCR_REG_START 0x0040
85#define PCR_REG_END 0x0041
86#define PCR_REG_MAX_STEP_LEN 0x0042
87#define PCR_REG_CLOSE_RANGE_LEAK 0x0043
88#define PCR_REG_SIGNAL_QUALITY 0x0044
89#define PCR_REG_MAX_PROFILE 0x0045
90#define PCR_REG_TRESHOLD_SENSITIVITY 0x0046
91#define PCR_REG_PEAK_SORTI 0x0047
92#define PCR_REG_MAX_FRAMES_RECORDED 0x0048
93#define PCR_REG_AMPLITUDE_TERSHOLD 0x0049
94#define PCR_REG_TERSHOLD_SENSITIVITY 0x004A
95#define PCR_REG_REFLECTOR_SHAPE 0x004B
96#define PCR_REG_STRENGHT_TRESHOLD 0x004C
97#define PCR_REG_MEASURE_ON_WAKEUP 0x0080
98#define PCR_REG_COMMAND 0x0100
121#define PCR_STATUS_RSS_REG_OK 0x00000001ul
122#define PCR_STATUS_CFG_CREATE_OK 0x00000002ul
123#define PCR_STATUS_SENSOR_CREATE_OK 0x00000004ul
124#define PCR_STATUS_DETECTOR_CREATE_OK 0x00000008ul
125#define PCR_STATUS_DETECTOR_BUFFER_OK 0x00000010ul
126#define PCR_STATUS_SENSOR_BUFFER_OK 0x00000020ul
127#define PCR_STATUS_CALIB_BUFFER_OK 0x00000040ul
128#define PCR_STATUS_CFG_APPLY_OK 0x00000080ul
129#define PCR_STATUS_SENSOR_CALIB_OK 0x00000100ul
130#define PCR_STATUS_DETECTOR_CALIB_OK 0x00000200ul
131#define PCR_STATUS_RSS_REG_ERR 0x00010000ul
132#define PCR_STATUS_CFG_CREATE_ERR 0x00020000ul
133#define PCR_STATUS_SENSOR_CREATE_ERR 0x00040000ul
134#define PCR_STATUS_DETECTOR_CREATE_ERR 0x00080000ul
135#define PCR_STATUS_DETECTOR_BUFFER_ERR 0x00100000ul
136#define PCR_STATUS_SENSOR_BUFFER_ERR 0x00200000ul
137#define PCR_STATUS_CALIB_BUFFER_ERR 0x00400000ul
138#define PCR_STATUS_CFG_APPLY_ERR 0x00800000ul
139#define PCR_STATUS_SENSOR_CALIB_ERR 0x01000000ul
140#define PCR_STATUS_DETECTOR_CALIB_ERR 0x02000000ul
141#define PCR_STATUS_DETECTOR_ERR 0x10000000ul
142#define PCR_STATUS_BUSY 0x80000000ul
148#define PCR_APPLY_CFG_AND_CALIB_CMD 0x00000001ul
149#define PCR_MEASURE_DISTANCE_CMD 0x00000002ul
150#define PCR_APPLY_CONFIGURATION_CMD 0x00000003ul
151#define PCR_CALIBRATE_CMD 0x00000004ul
152#define PCR_RECALIBRATE_CMD 0x00000005ul
153#define PCR_ENABLE_UART_LOGS_CMD 0x00000020ul
154#define PCR_DISABLE_UART_LOGS_CMD 0x00000021ul
155#define PCR_LOG_CONFIGURATION_CMD 0x00000022ul
156#define PCR_RESET_MODULE_CMD 0x52535421ul
162#define PCR_PIN_STATE_HIGH 0x01
163#define PCR_PIN_STATE_LOW 0x00
169#define PCR_MIN_DISTANCE 10
170#define PCR_MAX_DISTANCE 5000
177#define PCR_DEVICE_ADDRESS 0x52
195#define PCR_MAP_MIKROBUS( cfg, mikrobus ) \
196 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
197 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
198 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
199 cfg.wup = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
200 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:249
@ PCR_BUSY
Definition: pcr.h:251
@ PCR_ERROR
Definition: pcr.h:252
@ PCR_OK
Definition: pcr.h:250
PCR Click configuration object.
Definition: pcr.h:231
pin_name_t wup
Definition: pcr.h:236
uint32_t i2c_speed
Definition: pcr.h:239
pin_name_t scl
Definition: pcr.h:232
pin_name_t int_pin
Definition: pcr.h:237
pin_name_t sda
Definition: pcr.h:233
pin_name_t rst
Definition: pcr.h:235
uint8_t i2c_address
Definition: pcr.h:240
PCR Click context object.
Definition: pcr.h:210
digital_in_t int_pin
Definition: pcr.h:216
i2c_master_t i2c
Definition: pcr.h:219
digital_out_t wup
Definition: pcr.h:213
digital_out_t rst
Definition: pcr.h:212
uint8_t slave_address
Definition: pcr.h:222