Go to the documentation of this file.
57 #ifdef PREINIT_SUPPORTED
61 #ifdef MikroCCoreVersion
62 #if MikroCCoreVersion >= 1
67 #include "drv_digital_out.h"
68 #include "drv_digital_in.h"
69 #include "drv_i2c_master.h"
93 #define ECGGSR_SLAVE_ADDRESS 0x30
106 #define ECGGSR_MAP_MIKROBUS( cfg, mikrobus ) \
107 cfg.scl_pin = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
108 cfg.sda_pin = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
109 cfg.enable_pin = MIKROBUS( mikrobus, MIKROBUS_CS );
121 #define ECGGSR_RETVAL uint8_t
128 #define ECGGSR_GPIO_SYNC_REG 0x0F
129 #define ECGGSR_LED_CFG_REG 0x10
130 #define ECGGSR_LED_WAIT_LOW_REG 0x11
131 #define ECGGSR_LED1_CURRL_REG 0x12
132 #define ECGGSR_LED1_CURRH_REG 0x13
133 #define ECGGSR_LED2_CURRL_REG 0x14
134 #define ECGGSR_LED2_CURRH_REG 0x15
135 #define ECGGSR_LED3_CURRL_REG 0x16
136 #define ECGGSR_LED3_CURRH_REG 0x17
137 #define ECGGSR_LED4_CURRL_REG 0x18
138 #define ECGGSR_LED4_CURRH_REG 0x19
139 #define ECGGSR_LED12_MODE_REG 0x2C
140 #define ECGGSR_LED34_MODE_REG 0x2D
141 #define ECGGSR_MAN_SEQ_CFG_REG 0x2E
142 #define ECGGSR_PD_CFG_REG 0x1A
143 #define ECGGSR_PDOFFX_LEDOFF_REG 0x1B
144 #define ECGGSR_PDOFFX_LEDON_REG 0x1C
145 #define ECGGSR_PD_AMPRCCFG_REG 0x1D
146 #define ECGGSR_PD_AMPCFG_REG 0x1E
147 #define ECGGSR_OFE1_PD_THCFG_REG 0x1F
148 #define ECGGSR_SEQ_CNT_REG 0x30
149 #define ECGGSR_SEQ_DIV_REG 0x31
150 #define ECGGSR_SEQ_START_REG 0x32
151 #define ECGGSR_SEQ_PER_REG 0x33
152 #define ECGGSR_SEQ_LED_ST_REG 0x34
153 #define ECGGSR_SEQ_LED_STO_REG 0x35
154 #define ECGGSR_SEQ_SECLED_STA_REG 0x36
155 #define ECGGSR_SEQ_SECLED_STO_REG 0x37
156 #define ECGGSR_SEQ_ITG_STA_REG 0x38
157 #define ECGGSR_SEQ_ITG_STO_REG 0x39
158 #define ECGGSR_SEQ_SDP1_STA_REG 0x3A
159 #define ECGGSR_SEQ_SDP1_STO_REG 0x3B
160 #define ECGGSR_SEQ_SDP2_STA_REG 0x3C
161 #define ECGGSR_SEQ_SDP2_STO_REG 0x3D
162 #define ECGGSR_SEQ_SDM1_STA_REG 0x3E
163 #define ECGGSR_SEQ_SDM1_STO_REG 0x3F
164 #define ECGGSR_SEQ_SDM2_STA_REG 0x40
165 #define ECGGSR_SEQ_SDM2_STO_REG 0x41
166 #define ECGGSR_SEQ_ADC_REG 0x42
167 #define ECGGSR_SEQ_ADC2TIA_REG 0x43
168 #define ECGGSR_SEQ_ADC3TIA_REG 0x44
169 #define ECGGSR_SD_SUBS_REG 0x45
170 #define ECGGSR_SEQ_CFG_REG 0x46
171 #define ECGGSR_SEQ_ERR_REG 0x47
172 #define ECGGSR_SEQ_OVS_SEL_REG 0x48
173 #define ECGGSR_SEQ_OVS_VAL_REG 0x49
174 #define ECGGSR_SEQ_DIS_SEL_REG 0x4A
175 #define ECGGSR_SEQ_DIS_VAL1_REG 0x4B
176 #define ECGGSR_SEQ_DIS_VAL2_REG 0x4C
177 #define ECGGSR_CYC_COUNTER_REG 0x60
178 #define ECGGSR_SEQ_COUNTER_REG 0x61
179 #define ECGGSR_SUBS_COUNTER_REG 0x62
180 #define ECGGSR_OFE_CFGA_REG 0x50
181 #define ECGGSR_OFE1_SD_THCFG_REG 0x51
182 #define ECGGSR_OFE_CFGC_REG 0x52
183 #define ECGGSR_OFE_CFGD_REG 0x53
184 #define ECGGSR_OFE1_CFGA_REG 0x54
185 #define ECGGSR_OFE1_CFGB_REG 0x55
186 #define ECGGSR_OFE2_PD_THCFG_REG 0x56
187 #define ECGGSR_OFE2_SD_THCFG_REG 0x57
188 #define ECGGSR_OFE2_CFGA_REG 0x58
189 #define ECGGSR_OFE2_CFGB_REG 0x59
190 #define ECGGSR_LTFDATA0_L_REG 0x20
191 #define ECGGSR_LTFDATA0_H_REG 0x21
192 #define ECGGSR_LTFDATA1_L_REG 0x22
193 #define ECGGSR_LTFDATA1_H_REG 0x23
194 #define ECGGSR_ITIME_REG 0x24
195 #define ECGGSR_LTF_CONFIG_REG 0x25
196 #define ECGGSR_LTF_SEL_REG 0x26
197 #define ECGGSR_LTF_GAIN_REG 0x27
198 #define ECGGSR_LTF_CONTROL_REG 0x28
199 #define ECGGSR_AZ_CONTROL_REG 0x29
200 #define ECGGSR_OFFSET0_REG 0x2A
201 #define ECGGSR_OFFSET1_REG 0x2B
202 #define ECGGSR_LTF_THRESHOLD_LOW0_REG 0x6C
203 #define ECGGSR_LTF_THRESHOLD_LOW1_REG 0x6D
204 #define ECGGSR_LTF_THRESHOLD_HIGH0_REG 0x6E
205 #define ECGGSR_LTF_THRESHOLD_HIGH1_REG 0x6F
206 #define ECGGSR_EAF_CFG_REG 0x70
207 #define ECGGSR_EAF_GST_REG 0x80
208 #define ECGGSR_EAF_BIAS_REG 0x81
209 #define ECGGSR_EAF_DAC_REG 0x82
210 #define ECGGSR_EAF_DAC1_L_REG 0x83
211 #define ECGGSR_EAF_DAC1_H_REG 0x84
212 #define ECGGSR_EAF_DAC2_L_REG 0x85
213 #define ECGGSR_EAF_DAC2_H_REG 0x86
214 #define ECGGSR_EAF_DAC_CFG_REG 0x87
215 #define ECGGSR_OFE_NOTCH_REG 0x5A
216 #define ECGGSR_ECG_MODE_REG 0x5B
217 #define ECGGSR_ECG_CFGA_REG 0x5C
218 #define ECGGSR_ECG_CFGB_REG 0x5D
219 #define ECGGSR_ECG_THRESHOLD_LOW_REG 0x6A
220 #define ECGGSR_ECG_THRESHOLD_HIGH_REG 0x6B
221 #define ECGGSR_ECG_CFGC_REG 0x5E
222 #define ECGGSR_ECG_CFGD_REG 0x5F
223 #define ECGGSR_ADC_THRESHOLD_REG 0x68
224 #define ECGGSR_ADC_THRESHOLD_CFG_REG 0x69
225 #define ECGGSR_ADC_CFGA_REG 0x88
226 #define ECGGSR_ADC_CFGB_REG 0x89
227 #define ECGGSR_ADC_CFGC_REG 0x8A
228 #define ECGGSR_ADC_CHANNEL_MASK_L_REG 0x8B
229 #define ECGGSR_ADC_CHANNEL_MASK_H_REG 0x8C
230 #define ECGGSR_ADC_DATA_L_REG 0x8E
231 #define ECGGSR_ADC_DATA_H_REG 0x8F
232 #define ECGGSR_FIFO_CFG_REG 0x78
233 #define ECGGSR_FIFO_CNTRL_REG 0x79
234 #define ECGGSR_FIFOL_REG 0xFE
235 #define ECGGSR_FIFOH_REG 0xFF
236 #define ECGGSR_CONTROL_REG 0x00
237 #define ECGGSR_GPIO_A_REG 0x08
238 #define ECGGSR_GPIO_E_REG 0x09
239 #define ECGGSR_GPIO_O_REG 0x0A
240 #define ECGGSR_GPIO_I_REG 0x0B
241 #define ECGGSR_GPIO_P_REG 0x0C
242 #define ECGGSR_GPIO_SR_REG 0x0D
243 #define ECGGSR_SUBID_REG 0x91
244 #define ECGGSR_ID_REG 0x92
245 #define ECGGSR_STATUS_REG 0xA0
246 #define ECGGSR_STATUS2_REG 0xA1
247 #define ECGGSR_CLIPSTATUS_REG 0xA2
248 #define ECGGSR_LEDSTATUS_REG 0xA3
249 #define ECGGSR_FIFOSTATUS_REG 0xA4
250 #define ECGGSR_LTFSTATUS_REG 0xA5
251 #define ECGGSR_FIFOLEVEL_REG 0xA6
252 #define ECGGSR_INTENAB_REG 0xA8
253 #define ECGGSR_INTENAB2_REG 0xA9
254 #define ECGGSR_INTR_REG 0xAA
255 #define ECGGSR_INTR2_REG 0xAB
257 #define ECGGSR_DEV_ID_MASK 0xFC
258 #define ECGGSR_DEV_ID 0x54
262 #define ECGGSR_LED_CURR_LOW_2 0x80
263 #define ECGGSR_LED_CURR_HIGH_2 0x59
267 #define ECGGSR_LED_CURR_LOW_3 0xC0
268 #define ECGGSR_LED_CURR_HIGH_3 0xFF
271 #define ECGGSR_ENABLE_OSC_AND_LDO 0x03
272 #define ECGGSR_READ_VALUE_CONTROL_REG 0x83
273 #define ECGGSR_ENABLE_REF_AND_DIODES 0x8B
274 #define ECGGSR_ENABLE_LED12_OUTPUT 0x99
275 #define ECGGSR_ENABLE_LED4_OUTPUT 0x90
276 #define ECGGSR_CONF_PHOTODIODE 0x3E
277 #define ECGGSR_SUNLIGHT_COMPENSATION 0x5E
278 #define ECGGSR_FEEDBACK_RESISTOR 0xE2
279 #define ECGGSR_ENABLE_PHOTOAMPLIFIER 0xBC
280 #define ECGGSR_START_PPG 0xE1
281 #define ECGGSR_ENABLE_ADC 0x01
282 #define ECGGSR_START_ADC_CONVERSION 0x01
283 #define ECGGSR_ENABLE_OFE_AND_BIAS 0xE6
284 #define ECGGSR_OFE1_CFGA 0x70
285 #define ECGGSR_OFE2_CFGA 0x70
286 #define ECGGSR_ADC_DATA_H_MASK 0x3F
287 #define ECGGSR_PPG_SCALE_VAL 0x64
288 #define ECGGSR_PD_LED_CURRENT 0x80
289 #define ECGGSR_PPG_L_THRESHOLD 0x48
290 #define ECGGSR_PPG_H_THRESHOLD 0x5F
291 #define ECGGSR_PPG_MAX_VAL 0x64
294 #define ECGGSR_ENABLE_SIG_REFERENCE 0x80
295 #define ECGGSR_ENABLE_BIAS_AND_GAIN 0x09
296 #define ECGGSR_INPUT_AND_REF_VOLTAGE 0xB0
297 #define ECGGSR_RESISTIVE_BIASING 0xA0
298 #define ECGGSR_GAIN_SETTINGS_STAGES1_2 0x0B
299 #define ECGGSR_ENABLE_ECG_AMPLIFIER 0x88
300 #define ECGGSR_GAIN_SETTINGS_STAGE3 0x04
301 #define ECGGSR_ENABLE_REF_AMPLIFIER 0x01
302 #define ECGGSR_START_SEQUENCER 0xE1
303 #define ECGGSR_SELECT_EFE 0x40
304 #define ECGGSR_SELECT_AMPLIFIER_INPUT 0x01
305 #define ECGGSR_ECG_SCALE_VAL 0x02
308 #define ECGGSR_ENABLE_GPIO1_ANALOG 0x02
309 #define ECGGSR_SET_SLEW_RATE_GPIO1 0x02
310 #define ECGGSR_SET_GPIO1_AS_INPUT 0x46
311 #define ECGGSR_SET_RES_BIAS_GPIO1 0x40
void ecggsr_reset(ecggsr_t *ctx)
ECG GSR Reset function.
void ecggsr_default_cfg(ecggsr_t *ctx, ecggsr_cfg_t *cfg)
Click Default Configuration function.
uint8_t i2c_address
Definition: ecggsr.h:369
i2c_master_t i2c
Definition: ecggsr.h:345
@ ENABLE_OXIMETER_FUNCTIONALITY
Definition: ecggsr.h:331
@ ENABLE_HEARTRATE_FUNCTIONALITY
Definition: ecggsr.h:332
Context structure.
Definition: ecggsr.h:343
pin_name_t scl_pin
Definition: ecggsr.h:363
@ ecggsr_init_error
Definition: ecggsr.h:383
ecggsr_functionality_t click_functionality
Definition: ecggsr.h:372
@ ENABLE_GALVANIC_SKIN_RESPONSE_FUNCTIONALITY
Definition: ecggsr.h:333
@ DEFAULT_ECGGSR_CLICK_FUNCTIONALITY
Definition: ecggsr.h:335
ecggsr_functionality_t
ECG GSR type of measurement selector.
Definition: ecggsr.h:330
uint32_t i2c_speed
Definition: ecggsr.h:368
Configuration structure.
Definition: ecggsr.h:361
pin_name_t enable_pin
Definition: ecggsr.h:351
err_t ecggsr_write_reg(ecggsr_t *ctx, uint8_t register_address, uint8_t transfer_data)
Generic Write function.
void ecggsr_cfg_setup(ecggsr_cfg_t *cfg)
ECG GSR configuration object setup function.
err_t ecggsr_init(ecggsr_t *ctx, ecggsr_cfg_t *cfg)
Initialization function.
ecggsr_err_t
Error Code.
Definition: ecggsr.h:381
pin_name_t enable_pin
Definition: ecggsr.h:365
err_t ecggsr_read_reg(ecggsr_t *ctx, uint8_t register_address, uint8_t *data_out, uint8_t num_of_regs)
Generic Read function.
@ ecggsr_ok
Definition: ecggsr.h:382
void ecggsr_read_dev_id(ecggsr_t *ctx, uint8_t *dev_id_out)
ECG GSR Read ID function.
uint8_t slave_address
Definition: ecggsr.h:348
pin_name_t sda_pin
Definition: ecggsr.h:364