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 OXIMETER2_SLAVE_ADDRESS 0x64
107#define OXIMETER2_MAP_MIKROBUS( cfg, mikrobus ) \
108 cfg.scl_pin = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
109 cfg.sda_pin = MIKROBUS( mikrobus, MIKROBUS_SDA );
120#define OXIMETER2_RETVAL uint8_t
122#define OXIMETER2_OK 0x00
123#define OXIMETER2_INIT_ERROR 0xFF
130#define OXIMETER2_STATUS_REG 0x00
131#define OXIMETER2_INT_MASK_REG 0x01
132#define OXIMETER2_INT_IO_CTL_REG 0x02
133#define OXIMETER2_FIFO_THRESH_REG 0x06
134#define OXIMETER2_DEVID_REG 0x08
135#define OXIMETER2_CLK_RATIO_REG 0x0A
136#define OXIMETER2_MODE_REG 0x10
137#define OXIMETER2_SLOT_EN_REG 0x11
138#define OXIMETER2_FSAMPLE_REG 0x12
139#define OXIMETER2_PD_LED_SELECT_REG 0x14
140#define OXIMETER2_NUM_AVG_REG 0x15
141#define OXIMETER2_SLOTA_CH1_OFFSET_REG 0x18
142#define OXIMETER2_SLOTA_CH2_OFFSET_REG 0x19
143#define OXIMETER2_SLOTA_CH3_OFFSET_REG 0x1A
144#define OXIMETER2_SLOTA_CH4_OFFSET_REG 0x1B
145#define OXIMETER2_SLOTB_CH1_OFFSET_REG 0x1E
146#define OXIMETER2_SLOTB_CH2_OFFSET_REG 0x1F
147#define OXIMETER2_SLOTB_CH3_OFFSET_REG 0x20
148#define OXIMETER2_SLOTB_CH4_OFFSET_REG 0x21
149#define OXIMETER2_ILED1_COARSE_REG 0x23
150#define OXIMETER2_ILED2_COARSE_REG 0x24
151#define OXIMETER2_ILED_FINE_REG 0x25
152#define OXIMETER2_SLOTA_LEDMODE_REG 0x30
153#define OXIMETER2_SLOTA_NUMPULSES_REG 0x31
154#define OXIMETER2_LED_DISABLE_REG 0x34
155#define OXIMETER2_SLOTB_LEDMODE_REG 0x35
156#define OXIMETER2_SLOTB_NUMPULSES_REG 0x36
157#define OXIMETER2_EXT_SYNC_STARTUP_REG 0x38
158#define OXIMETER2_SLOTA_AFEMODE_REG 0x39
159#define OXIMETER2_SLOTB_AFEMODE_REG 0x3B
160#define OXIMETER2_SLOTA_GAIN_REG 0x42
161#define OXIMETER2_SLOTA_AFE_CON_REG 0x43
162#define OXIMETER2_SLOTB_GAIN_REG 0x44
163#define OXIMETER2_SLOTB_AFE_CON_REG 0x45
164#define OXIMETER2_SAMPLE_CLK_REG 0x4B
165#define OXIMETER2_CLK32M_ADJUST_REG 0x4D
166#define OXIMETER2_ADC_TIMING_REG 0x4E
167#define OXIMETER2_EXT_SYNC_SEL_REG 0x4F
168#define OXIMETER2_CLK32M_CAL_EN_REG 0x50
169#define OXIMETER2_TIA_INDEP_GAIN_REG 0x55
170#define OXIMETER2_DATA_ACCESS_CTL_REG 0x5F
171#define OXIMETER2_FIFO_ACCESS 0x60
172#define OXIMETER2_SLOTA_PD1_16BIT_REG 0x64
173#define OXIMETER2_SLOTA_PD2_16BIT_REG 0x65
174#define OXIMETER2_SLOTA_PD3_16BIT_REG 0x66
175#define OXIMETER2_SLOTA_PD4_16BIT_REG 0x67
176#define OXIMETER2_SLOTB_PD1_16BIT_REG 0x68
177#define OXIMETER2_SLOTB_PD2_16BIT_REG 0x69
178#define OXIMETER2_SLOTB_PD3_16BIT_REG 0x6A
179#define OXIMETER2_SLOTB_PD4_16BIT_REG 0x6B
180#define OXIMETER2_A_PD1_LOW_REG 0x70
181#define OXIMETER2_A_PD2_LOW_REG 0x71
182#define OXIMETER2_A_PD3_LOW_REG 0x72
183#define OXIMETER2_A_PD4_LOW_REG 0x73
184#define OXIMETER2_A_PD1_HIGH_REG 0x74
185#define OXIMETER2_A_PD2_HIGH_REG 0x75
186#define OXIMETER2_A_PD3_HIGH_REG 0x76
187#define OXIMETER2_A_PD4_HIGH_REG 0x77
188#define OXIMETER2_B_PD1_LOW_REG 0x78
189#define OXIMETER2_B_PD2_LOW_REG 0x79
190#define OXIMETER2_B_PD3_LOW_REG 0x7A
191#define OXIMETER2_B_PD4_LOW_REG 0x7B
192#define OXIMETER2_B_PD1_HIGH_REG 0x7C
193#define OXIMETER2_B_PD2_HIGH_REG 0x7D
194#define OXIMETER2_B_PD3_HIGH_REG 0x7E
195#define OXIMETER2_B_PD4_HIGH_REG 0x7F
201#define OXIMETER2_DIS_SLOT 0x00
202#define OXIMETER2_EN_SLOT 0x01
210#define OXIMETER2_MODE_STANDBY 0x0000
211#define OXIMETER2_MODE_PROGRAM 0x0001
212#define OXIMETER2_MODE_SAMPLE 0x0002
219#define OXIMETER2_SAMPLE_CLK_CLK32K_EN 0x0080
226#define OXIMETER2_DATA_ACCESS_CTL_SLOTA_DATA_HOLD 0x0002
227#define OXIMETER2_DATA_ACCESS_CTL_SLOTB_DATA_HOLD 0x0004
234#define SLOTA_LED_SEL_LEDX1 0x0001
235#define SLOTA_LED_SEL_LEDX2 0x0002
237#define SLOTB_LED_SEL_LEDX1 0x0004
238#define SLOTB_LED_SEL_LEDX2 0x0008
245#define OXIMETER2_ALL_CHANNELS_SELECTED 0x00
246#define OXIMETER2_CH3_CH4_SELECTED 0x01
253#define OXIMETER2_LEDX1_EN 0x00
254#define OXIMETER2_LEDX2_EN 0x01
255#define OXIMETER2_DIS_LED 0x02
263#define SLOTA_PD_SEL_CH3_CH4 0x0010
264#define SLOTA_PD_SEL_ALL_CH 0x0040
265#define SLOTB_PD_SEL_CH3_CH4 0x1000
266#define SLOTB_PD_SEL_ALL_CH 0x0400
274#define OXIMETER2_SLOT_A_EN 0x0001
275#define OXIMETER2_SLOT_B_EN 0x0020
282#define OXIMETER2_AVERAGE_RES_MODE 0x00
283#define OXIMETER2_SUM_RES_MODE 0x01
286#define OXIMETER2_16_BIT_DATA_MASK 0x0000FFFF
287#define OXIMETER2_CLEAR_INTERRUPTS 0x00FF
288#define OXIMETER2_PREVENT_UPDATE_OF_DATA_REGS 0x0006
289#define OXIMETER2_ALLOW_UPDATE_OF_DATA_REGS 0x0000
#define OXIMETER2_RETVAL
Definition oximeter2.h:120
void oximeter2_reset(oximeter2_t *ctx)
Oximeter 2 Reset function.
uint8_t oximeter2_read_reg(oximeter2_t *cfg, uint8_t register_address, uint16_t *data_out, uint8_t num_of_regs)
Generic Read function.
void oximeter2_read_data(oximeter2_t *ctx, uint32_t *channel_results)
Oximeter 2 Data Read function.
OXIMETER2_RETVAL oximeter2_init(oximeter2_t *ctx, oximeter2_cfg_t *cfg)
Initialization function.
uint8_t oximeter2_set_time_slot_a(oximeter2_t *ctx, enable_t *dev_enable)
Time Slot A Set function.
uint8_t oximeter2_set_time_slot_b(oximeter2_t *ctx, enable_t *dev_enable)
Time Slot B Set function.
void oximeter2_cfg_setup(oximeter2_cfg_t *cfg)
Oximeter 2 configuration object setup function.
uint8_t oximeter2_write_reg(oximeter2_t *ctx, uint8_t register_address, uint16_t transfer_data)
Generic Write function.
void oximeter2_default_cfg(oximeter2_t *ctx)
Click Default Configuration function.
uint8_t oximeter2_set_mode(oximeter2_t *ctx, uint8_t desired_mode)
Oximeter 2 Mode Set function.
Oximeter 2 hardware selector.
Definition oximeter2.h:346
uint8_t enable_photodiode
Definition oximeter2.h:348
uint8_t enable_slot
Definition oximeter2.h:347
Oximeter 2 Click configuration object.
Definition oximeter2.h:327
pin_name_t sda_pin
Definition oximeter2.h:330
uint8_t dev_enabled_slot_b
Definition oximeter2.h:337
uint32_t i2c_speed
Definition oximeter2.h:333
uint8_t dev_enabled_slot_a
Definition oximeter2.h:336
uint8_t dev_enabled_channel
Definition oximeter2.h:335
pin_name_t scl_pin
Definition oximeter2.h:329
uint8_t i2c_address
Definition oximeter2.h:334
Oximeter 2 Click context object.
Definition oximeter2.h:305
uint8_t enabled_slot_b
Definition oximeter2.h:317
uint8_t enabled_slot_a
Definition oximeter2.h:316
i2c_master_t i2c
Definition oximeter2.h:307
uint8_t slave_address
Definition oximeter2.h:310
uint8_t enabled_channel
Definition oximeter2.h:313