Go to the documentation of this file.
39 #ifdef PREINIT_SUPPORTED
43 #ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 #include "drv_i2c_master.h"
73 #define PCR_REG_VERSION 0x0000
74 #define PCR_REG_PROTOCOL_STATUS 0x0001
75 #define PCR_REG_MEASURE_CNT 0x0002
76 #define PCR_REG_DETECTOR_STATUS 0x0003
77 #define PCR_REG_DISTANCE_RESULT 0x0010
78 #define PCR_REG_PEAK0_DISTANCE 0x0011
79 #define PCR_REG_PEAK1_DISTANCE 0x0012
80 #define PCR_REG_PEAK2_DISTANCE 0x0013
81 #define PCR_REG_PEAK3_DISTANCE 0x0014
82 #define PCR_REG_PEAK4_DISTANCE 0x0015
83 #define PCR_REG_PEAK5_DISTANCE 0x0016
84 #define PCR_REG_PEAK6_DISTANCE 0x0017
85 #define PCR_REG_PEAK7_DISTANCE 0x0018
86 #define PCR_REG_PEAK8_DISTANCE 0x0019
87 #define PCR_REG_PEAK9_DISTANCE 0x001A
88 #define PCR_REG_PEAK0_STRENGTH 0x001B
89 #define PCR_REG_PEAK1_STRENGTH 0x001C
90 #define PCR_REG_PEAK2_STRENGTH 0x001D
91 #define PCR_REG_PEAK3_STRENGTH 0x001E
92 #define PCR_REG_PEAK4_STRENGTH 0x001F
93 #define PCR_REG_PEAK5_STRENGTH 0x0020
94 #define PCR_REG_PEAK6_STRENGTH 0x0021
95 #define PCR_REG_PEAK7_STRENGTH 0x0022
96 #define PCR_REG_PEAK8_STRENGTH 0x0023
97 #define PCR_REG_PEAK9_STRENGTH 0x0024
98 #define PCR_REG_START 0x0040
99 #define PCR_REG_END 0x0041
100 #define PCR_REG_MAX_STEP_LEN 0x0042
101 #define PCR_REG_CLOSE_RANGE_LEAK 0x0043
102 #define PCR_REG_SIGNAL_QUALITY 0x0044
103 #define PCR_REG_MAX_PROFILE 0x0045
104 #define PCR_REG_TRESHOLD_SENSITIVITY 0x0046
105 #define PCR_REG_PEAK_SORTI 0x0047
106 #define PCR_REG_MAX_FRAMES_RECORDED 0x0048
107 #define PCR_REG_AMPLITUDE_TERSHOLD 0x0049
108 #define PCR_REG_TERSHOLD_SENSITIVITY 0x004A
109 #define PCR_REG_REFLECTOR_SHAPE 0x004B
110 #define PCR_REG_STRENGHT_TRESHOLD 0x004C
111 #define PCR_REG_MEASURE_ON_WAKEUP 0x0080
112 #define PCR_REG_COMMAND 0x0100
135 #define PCR_STATUS_RSS_REG_OK 0x00000001ul
136 #define PCR_STATUS_CFG_CREATE_OK 0x00000002ul
137 #define PCR_STATUS_SENSOR_CREATE_OK 0x00000004ul
138 #define PCR_STATUS_DETECTOR_CREATE_OK 0x00000008ul
139 #define PCR_STATUS_DETECTOR_BUFFER_OK 0x00000010ul
140 #define PCR_STATUS_SENSOR_BUFFER_OK 0x00000020ul
141 #define PCR_STATUS_CALIB_BUFFER_OK 0x00000040ul
142 #define PCR_STATUS_CFG_APPLY_OK 0x00000080ul
143 #define PCR_STATUS_SENSOR_CALIB_OK 0x00000100ul
144 #define PCR_STATUS_DETECTOR_CALIB_OK 0x00000200ul
145 #define PCR_STATUS_RSS_REG_ERR 0x00010000ul
146 #define PCR_STATUS_CFG_CREATE_ERR 0x00020000ul
147 #define PCR_STATUS_SENSOR_CREATE_ERR 0x00040000ul
148 #define PCR_STATUS_DETECTOR_CREATE_ERR 0x00080000ul
149 #define PCR_STATUS_DETECTOR_BUFFER_ERR 0x00100000ul
150 #define PCR_STATUS_SENSOR_BUFFER_ERR 0x00200000ul
151 #define PCR_STATUS_CALIB_BUFFER_ERR 0x00400000ul
152 #define PCR_STATUS_CFG_APPLY_ERR 0x00800000ul
153 #define PCR_STATUS_SENSOR_CALIB_ERR 0x01000000ul
154 #define PCR_STATUS_DETECTOR_CALIB_ERR 0x02000000ul
155 #define PCR_STATUS_DETECTOR_ERR 0x10000000ul
156 #define PCR_STATUS_BUSY 0x80000000ul
162 #define PCR_APPLY_CFG_AND_CALIB_CMD 0x00000001ul
163 #define PCR_MEASURE_DISTANCE_CMD 0x00000002ul
164 #define PCR_APPLY_CONFIGURATION_CMD 0x00000003ul
165 #define PCR_CALIBRATE_CMD 0x00000004ul
166 #define PCR_RECALIBRATE_CMD 0x00000005ul
167 #define PCR_ENABLE_UART_LOGS_CMD 0x00000020ul
168 #define PCR_DISABLE_UART_LOGS_CMD 0x00000021ul
169 #define PCR_LOG_CONFIGURATION_CMD 0x00000022ul
170 #define PCR_RESET_MODULE_CMD 0x52535421ul
176 #define PCR_PIN_STATE_HIGH 0x01
177 #define PCR_PIN_STATE_LOW 0x00
183 #define PCR_MIN_DISTANCE 10
184 #define PCR_MAX_DISTANCE 5000
191 #define PCR_DEVICE_ADDRESS 0x52
209 #define PCR_MAP_MIKROBUS( cfg, mikrobus ) \
210 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
211 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
212 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
213 cfg.wup = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
214 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
void pcr_set_wup_pin(pcr_t *ctx, uint8_t pin_state)
PCR set wake up pin state function.
pin_name_t sda
Definition: pcr.h:247
@ PCR_ERROR
Definition: pcr.h:266
err_t pcr_default_cfg(pcr_t *ctx)
PCR default configuration function.
err_t pcr_init(pcr_t *ctx, pcr_cfg_t *cfg)
PCR initialization function.
err_t pcr_check_if_busy(pcr_t *ctx)
PCR check if device is busy function.
void pcr_hw_reset(pcr_t *ctx)
PCR hardware reset function.
digital_in_t int_pin
Definition: pcr.h:230
uint8_t i2c_address
Definition: pcr.h:254
void pcr_set_rst_pin(pcr_t *ctx, uint8_t pin_state)
PCR set reset pin state function.
digital_out_t rst
Definition: pcr.h:226
err_t pcr_generic_read(pcr_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
PCR I2C reading function.
digital_out_t wup
Definition: pcr.h:227
err_t pcr_get_status(pcr_t *ctx, uint32_t *status)
PCR get status function.
err_t pcr_generic_write(pcr_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
PCR I2C writing function.
PCR Click configuration object.
Definition: pcr.h:245
i2c_master_t i2c
Definition: pcr.h:233
pcr_return_value_t
PCR Click return value data.
Definition: pcr.h:263
PCR Click context object.
Definition: pcr.h:224
uint32_t i2c_speed
Definition: pcr.h:253
@ PCR_BUSY
Definition: pcr.h:265
@ PCR_OK
Definition: pcr.h:264
uint8_t pcr_get_int_pin(pcr_t *ctx)
PCR get interrupt pin state function.
pin_name_t int_pin
Definition: pcr.h:251
pin_name_t wup
Definition: pcr.h:250
pin_name_t scl
Definition: pcr.h:246
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.
err_t pcr_write_reg(pcr_t *ctx, uint16_t reg, uint32_t data_in)
PCR register writing function.
pin_name_t rst
Definition: pcr.h:249
void pcr_cfg_setup(pcr_cfg_t *cfg)
PCR configuration object setup function.
err_t pcr_check_if_ok(pcr_t *ctx)
PCR check if device is ok function.
uint8_t slave_address
Definition: pcr.h:236