42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
66#define ECG6_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
76#define ECG6_RETVAL uint8_t
79#define ECG6_INIT_ERROR 0xFF
86#define ECG6_REG_INTERRUPT_STATUS_1 0x00
87#define ECG6_REG_INTERRUPT_STATUS_2 0x01
88#define ECG6_REG_INTERRUPT_ENABLE_1 0x02
89#define ECG6_REG_INTERRUPT_ENABLE_2 0x03
96#define ECG6_REG_FIFO_WRITE 0x04
97#define ECG6_REG_OVERFLOW_CNT 0x05
98#define ECG6_REG_FIFO_READ 0x06
99#define ECG6_REG_FIFO_DATA 0x07
100#define ECG6_REG_FIFO_CFG 0x08
107#define ECG6_REG_FIFO_DATA_CTRL_1 0x09
108#define ECG6_REG_FIFO_DATA_CTRL_2 0x0A
115#define ECG6_REG_SYSTEM_CTRL 0x0D
123#define ECG6_REG_PPG_CFG_1 0x0E
124#define ECG6_REG_PPG_CFG_2 0x0F
125#define ECG6_REG_PROX_INT_THR 0x10
132#define ECG6_REG_LED_PULSE_AMPLITUDE_1 0x11
133#define ECG6_REG_LED_PULSE_AMPLITUDE_2 0x12
134#define ECG6_REG_LED_RANGE 0x14
135#define ECG6_REG_LED_PILOT_PULSE_AMPLITUDE 0x15
142#define ECG6_REG_CONFIG_1 0x3C
143#define ECG6_REG_CONFIG_3 0x3E
150#define ECG6_REG_PART_ID 0xFF
157#define ECG6_INTS1_A_FULL_ON 0x80
158#define ECG6_INTS1_A_FULL_OFF 0x00
159#define ECG6_INTS1_PPG_RDY_ON 0x40
160#define ECG6_INTS1_PPG_RDY_OFF 0x00
161#define ECG6_INTS1_ALC_OVF_ON 0x20
162#define ECG6_INTS1_ALC_OVF_OFF 0x00
163#define ECG6_INTS1_PROX_INIT_ON 0x10
164#define ECG6_INTS1_PROX_INIT_OFF 0x00
165#define ECG6_INTS1_PWR_RDY_ON 0x01
166#define ECG6_INTS1_PWR_RDY_OFF 0x00
173#define ECG6_INTS2_VDD_OOR_ON 0x80
174#define ECG6_INTS2_VDD_OOR_OFF 0x00
175#define ECG6_INTS2_DRDY_ON 0x04
176#define ECG6_INTS2_DRDY_OFF 0x00
183#define ECG6_INTE1_A_FULL_ENABLE 0x80
184#define ECG6_INTE1_A_FULL_DISABLE 0x00
185#define ECG6_INTE1_PPG_RDY_ENABLE 0x40
186#define ECG6_INTE1_PPG_RDY_DISABLE 0x00
187#define ECG6_INTE1_ALC_OVF_ENABLE 0x20
188#define ECG6_INTE1_ALC_OVF_DISABLE 0x00
189#define ECG6_INTE1_PROX_INT_ENABLE 0x10
190#define ECG6_INTE1_PROX_INT_DISABLE 0x00
197#define ECG6_INTS2_VDD_OOR_ENABLE 0x80
198#define ECG6_INTS2_VDD_OOR_DISABLE 0x00
199#define ECG6_INTS2_DRDY_ENABLE 0x04
200#define ECG6_INTS2_DRDY_DISABLE 0x00
207#define ECG6_FCFG_A_FULL_CLR 0x40
208#define ECG6_FCFG_A_FULL_NO_CLR 0x00
209#define ECG6_FCFG_A_FULL_TYPE_RPT 0x00
210#define ECG6_FCFG_A_FULL_TYPE_ONCE 0x20
211#define ECG6_FCFG_FIFO_ROLLS_ON_FULL_ON 0x10
212#define ECG6_FCFG_FIFO_ROLLS_ON_FULL_OFF 0x00
219#define ECG6_SYSCTRL_FIFO_ENABLE 0x04
220#define ECG6_SYSCTRL_FIFO_DISABLE 0x00
221#define ECG6_SYSCTRL_SHUTDOWN_ENABLE 0x02
222#define ECG6_SYSCTRL_SHUTDOWN_DISABLE 0x00
223#define ECG6_SYSCTRL_RESET_ENABLE 0x01
224#define ECG6_SYSCTRL_RESET_DISABLE 0x00
231#define ECG6_PPGCFG1_PPG_ADC_RGE_4096nA 0x00
232#define ECG6_PPGCFG1_PPG_ADC_RGE_8192nA 0x40
233#define ECG6_PPGCFG1_PPG_ADC_RGE_16384nA 0x80
234#define ECG6_PPGCFG1_PPG_ADC_RGE_32768nA 0xC0
236#define ECG6_PPGCFG1_PPG_SR_10n1 0x00
237#define ECG6_PPGCFG1_PPG_SR_20n1 0x04
238#define ECG6_PPGCFG1_PPG_SR_50n1 0x08
239#define ECG6_PPGCFG1_PPG_SR_84n1 0x0C
240#define ECG6_PPGCFG1_PPG_SR_100n1 0x10
241#define ECG6_PPGCFG1_PPG_SR_200 0x14
242#define ECG6_PPGCFG1_PPG_SR_400 0x18
243#define ECG6_PPGCFG1_PPG_SR_800 0x1C
244#define ECG6_PPGCFG1_PPG_SR_1000 0x20
245#define ECG6_PPGCFG1_PPG_SR_1600 0x24
246#define ECG6_PPGCFG1_PPG_SR_3200 0x28
247#define ECG6_PPGCFG1_PPG_SR_10n2 0x2C
248#define ECG6_PPGCFG1_PPG_SR_20n2 0x30
249#define ECG6_PPGCFG1_PPG_SR_50n2 0x34
250#define ECG6_PPGCFG1_PPG_SR_84n2 0x38
251#define ECG6_PPGCFG1_PPG_SR_100n2 0x3C
253#define ECG6_PPGCFG1_PPG_PW_50us 0x00
254#define ECG6_PPGCFG1_PPG_PW_100us 0x01
255#define ECG6_PPGCFG1_PPG_PW_200us 0x02
256#define ECG6_PPGCFG1_PPG_PW_400us 0x03
263#define ECG6_PPGCFG2_SMP_AVE_1 0x00
264#define ECG6_PPGCFG2_SMP_AVE_2 0x01
265#define ECG6_PPGCFG2_SMP_AVE_4 0x02
266#define ECG6_PPGCFG2_SMP_AVE_8 0x03
267#define ECG6_PPGCFG2_SMP_AVE_16 0x04
268#define ECG6_PPGCFG2_SMP_AVE_32 0x05
275#define ECG6_LRANG_LED2_SMP_AVE_50 0x00
276#define ECG6_LRANG_LED2_SMP_AVE_100 0x04
277#define ECG6_LRANG_LED1_SMP_AVE_50 0x00
278#define ECG6_LRANG_LED1_SMP_AVE_100 0x01
285#define ECG6_CFG1_ADC_OSR_1600 0x00
286#define ECG6_CFG1_ADC_OSR_800 0x01
287#define ECG6_CFG1_ADC_OSR_400 0x02
288#define ECG6_CFG1_ADC_OSR_200 0x03
289#define ECG6_CFG1_ADC_OSR_3200 0x04
296#define ECG6_CFG3_PGA_GAIN_1 0x00
297#define ECG6_CFG3_PGA_GAIN_2 0x04
298#define ECG6_CFG3_PGA_GAIN_4 0x08
299#define ECG6_CFG3_PGA_GAIN_8 0x0C
300#define ECG6_CFG3_IA_GAIN_5 0x00
301#define ECG6_CFG3_IA_GAIN_9p5 0x01
302#define ECG6_CFG3_IA_GAIN_20 0x02
303#define ECG6_CFG3_IA_GAIN_50 0x03
310#define ECG6_DEF_PART_ID 0x1E
317#define ECG6_DEVICE_SLAVE_ADDRESS 0x5E
324#define ECG6_SENSOR_PPG_LED_1 0x01
325#define ECG6_SENSOR_PPG_LED_2 0x02
326#define ECG6_SENSOR_PPG_PILOT_LED_1 0x05
327#define ECG6_SENSOR_PPG_PILOT_LED_2 0x06
328#define ECG6_SENSOR_ECG 0x09
329#define ECG6_SENSOR_NONE 0x00
648void ecg6_set_led_pulse(
ecg6_t *ctx, uint8_t ir_led, uint8_t red_led );
#define ECG6_RETVAL
Definition ecg6.h:76
uint8_t ecg6_ppg_default_config(ecg6_t *ctx)
Function for configuration sensors to element.
uint8_t ecg6_int_pin_state(ecg6_t *ctx)
Get Interrupt pin state.
void ecg6_get_all_samples(ecg6_t *ctx, ecg6_fifo_t *fifo_data)
Get all samples from FIFO.
void ecg6_get_sample_data(ecg6_t *ctx, ecg6_element_t *element, uint8_t num_sample)
Get one sample from FIFO.
void ecg6_default_cfg(ecg6_t *ctx)
Default configuration for ECG sensor.
void ecg6_cfg_setup(ecg6_cfg_t *cfg)
Config Object Initialization function.
void ecg6_write_data(ecg6_t *ctx, uint8_t reg, uint8_t in_data)
Generic Write function.
uint8_t ecg6_check_path_id(ecg6_t *ctx)
Function for check path ID.
uint8_t ecg6_read_data(ecg6_t *ctx, uint8_t reg)
Generic Read function.
void ecg6_write_data_buf(ecg6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic Write buffer function.
void ecg6_get_interrupt_status(ecg6_t *ctx, ecg6_int_status_t *status)
Get Interrupt registers status.
ECG6_RETVAL ecg6_init(ecg6_t *ctx, ecg6_cfg_t *cfg)
Initialization function.
void ecg6_read_data_buf(ecg6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic Read buffer function.
uint8_t element_2
Definition ecg6.h:399
uint8_t element_3
Definition ecg6.h:400
uint8_t element_4
Definition ecg6.h:401
uint8_t element_1
Definition ecg6.h:398
Click configuration structure definition.
Definition ecg6.h:431
uint32_t i2c_speed
Definition ecg6.h:443
pin_name_t scl
Definition ecg6.h:434
pin_name_t int_pin
Definition ecg6.h:439
pin_name_t sda
Definition ecg6.h:435
uint8_t i2c_address
Definition ecg6.h:444
uint32_t element_1
Definition ecg6.h:352
uint32_t element_4
Definition ecg6.h:355
uint32_t element_3
Definition ecg6.h:354
uint32_t element_2
Definition ecg6.h:353
ecg6_element_t sample_23
Definition ecg6.h:384
ecg6_element_t sample_16
Definition ecg6.h:377
ecg6_element_t sample_27
Definition ecg6.h:388
ecg6_element_t sample_18
Definition ecg6.h:379
ecg6_element_t sample_26
Definition ecg6.h:387
ecg6_element_t sample_31
Definition ecg6.h:392
ecg6_element_t sample_21
Definition ecg6.h:382
ecg6_element_t sample_6
Definition ecg6.h:367
ecg6_element_t sample_15
Definition ecg6.h:376
ecg6_element_t sample_19
Definition ecg6.h:380
ecg6_element_t sample_13
Definition ecg6.h:374
ecg6_element_t sample_12
Definition ecg6.h:373
ecg6_element_t sample_24
Definition ecg6.h:385
ecg6_element_t sample_20
Definition ecg6.h:381
ecg6_element_t sample_29
Definition ecg6.h:390
ecg6_element_t sample_11
Definition ecg6.h:372
ecg6_element_t sample_17
Definition ecg6.h:378
ecg6_element_t sample_5
Definition ecg6.h:366
ecg6_element_t sample_25
Definition ecg6.h:386
ecg6_element_t sample_4
Definition ecg6.h:365
ecg6_element_t sample_8
Definition ecg6.h:369
ecg6_element_t sample_0
Definition ecg6.h:361
ecg6_element_t sample_1
Definition ecg6.h:362
ecg6_element_t sample_2
Definition ecg6.h:363
ecg6_element_t sample_14
Definition ecg6.h:375
ecg6_element_t sample_28
Definition ecg6.h:389
ecg6_element_t sample_3
Definition ecg6.h:364
ecg6_element_t sample_10
Definition ecg6.h:371
ecg6_element_t sample_30
Definition ecg6.h:391
ecg6_element_t sample_7
Definition ecg6.h:368
ecg6_element_t sample_22
Definition ecg6.h:383
ecg6_element_t sample_9
Definition ecg6.h:370
uint8_t prox_int
Definition ecg6.h:343
uint8_t ppg_rdy
Definition ecg6.h:341
uint8_t alc_ovf
Definition ecg6.h:342
uint8_t ecg_rdy
Definition ecg6.h:346
uint8_t vdd_oor
Definition ecg6.h:345
uint8_t pwr_rdy
Definition ecg6.h:344
uint8_t a_full
Definition ecg6.h:340
Click ctx object definition.
Definition ecg6.h:409
digital_in_t int_pin
Definition ecg6.h:415
i2c_master_t i2c
Definition ecg6.h:419
uint8_t slave_address
Definition ecg6.h:423