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"
67#define OXIMETER_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.io0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
71 cfg.io1 = MIKROBUS( mikrobus, MIKROBUS_INT )
79#define OXIMETER_ERROR -1
86#define OXIMETER_REG_STATUS 0x00
87#define OXIMETER_REG_INT_MASK 0x01
88#define OXIMETER_REG_GPIO_DRV 0x02
89#define OXIMETER_REG_FIFO_THRESH 0x06
90#define OXIMETER_REG_DEVID 0x08
91#define OXIMETER_REG_I2CS_ID 0x09
92#define OXIMETER_REG_CLK_RATIO 0x0A
93#define OXIMETER_REG_GPIO_CTRL 0x0B
94#define OXIMETER_REG_SLAVE_ADDRESS_KEY 0x0D
95#define OXIMETER_REG_SW_RESET 0x0F
96#define OXIMETER_REG_MODE 0x10
97#define OXIMETER_REG_SLOT_EN 0x11
98#define OXIMETER_REG_FSAMPLE 0x12
99#define OXIMETER_REG_PD_LED_SELECT 0x14
100#define OXIMETER_REG_NUM_AVG 0x15
101#define OXIMETER_REG_SLOTA_CH1_OFFSET 0x18
102#define OXIMETER_REG_SLOTA_CH2_OFFSET 0x19
103#define OXIMETER_REG_SLOTA_CH3_OFFSET 0x1A
104#define OXIMETER_REG_SLOTA_CH4_OFFSET 0x1B
105#define OXIMETER_REG_SLOTB_CH1_OFFSET 0x1E
106#define OXIMETER_REG_SLOTB_CH2_OFFSET 0x1F
107#define OXIMETER_REG_SLOTB_CH3_OFFSET 0x20
108#define OXIMETER_REG_SLOTB_CH4_OFFSET 0x21
109#define OXIMETER_REG_ILED3_COARSE 0x22
110#define OXIMETER_REG_ILED1_COARSE 0x23
111#define OXIMETER_REG_ILED2_COARSE 0x24
112#define OXIMETER_REG_ILED_FINE 0x25
113#define OXIMETER_REG_SLOTA_LED_PULSE 0x30
114#define OXIMETER_REG_SLOTA_NUMPULSES 0x31
115#define OXIMETER_REG_LED_DISABLE 0x34
116#define OXIMETER_REG_SLOTB_LED_PULSE 0x35
117#define OXIMETER_REG_SLOTB_NUMPULSES 0x36
118#define OXIMETER_REG_ALT_PWR_DN 0x37
119#define OXIMETER_REG_EXT_SYNC_STARTUP 0x38
120#define OXIMETER_REG_SLOTA_AFE_WINDOW 0x39
121#define OXIMETER_REG_SLOTB_AFE_WINDOW 0x3B
122#define OXIMETER_REG_AFE_PWR_CFG1 0x3C
123#define OXIMETER_REG_SLOTA_TIA_CFG 0x42
124#define OXIMETER_REG_SLOTA_AFE_CFG 0x43
125#define OXIMETER_REG_SLOTB_TIA_CFG 0x44
126#define OXIMETER_REG_SLOTB_AFE_CFG 0x45
127#define OXIMETER_REG_SAMPLE_CLK 0x4B
128#define OXIMETER_REG_CLK32M_ADJUST 0x4D
129#define OXIMETER_REG_ADC_CLOCK 0x4E
130#define OXIMETER_REG_EXT_SYNC_SEL 0x4F
131#define OXIMETER_REG_CLK32M_CAL_EN 0x50
132#define OXIMETER_REG_AFE_PWR_CFG2 0x54
133#define OXIMETER_REG_TIA_INDEP_GAIN 0x55
134#define OXIMETER_REG_DIGITAL_INT_EN 0x58
135#define OXIMETER_REG_DIG_INT_CFG 0x5A
136#define OXIMETER_REG_DATA_ACCESS_CTL 0x5F
137#define OXIMETER_REG_FIFO_ACCESS 0x60
138#define OXIMETER_REG_SLOTA_PD1_16BIT 0x64
139#define OXIMETER_REG_SLOTA_PD2_16BIT 0x65
140#define OXIMETER_REG_SLOTA_PD3_16BIT 0x66
141#define OXIMETER_REG_SLOTA_PD4_16BIT 0x67
142#define OXIMETER_REG_SLOTB_PD1_16BIT 0x68
143#define OXIMETER_REG_SLOTB_PD2_16BIT 0x69
144#define OXIMETER_REG_SLOTB_PD3_16BIT 0x6A
145#define OXIMETER_REG_SLOTB_PD4_16BIT 0x6B
146#define OXIMETER_REG_A_PD1_LOW 0x70
147#define OXIMETER_REG_A_PD2_LOW 0x71
148#define OXIMETER_REG_A_PD3_LOW 0x72
149#define OXIMETER_REG_A_PD4_LOW 0x73
150#define OXIMETER_REG_A_PD1_HIGH 0x74
151#define OXIMETER_REG_A_PD2_HIGH 0x75
152#define OXIMETER_REG_A_PD3_HIGH 0x76
153#define OXIMETER_REG_A_PD4_HIGH 0x77
154#define OXIMETER_REG_B_PD1_LOW 0x78
155#define OXIMETER_REG_B_PD2_LOW 0x79
156#define OXIMETER_REG_B_PD3_LOW 0x7A
157#define OXIMETER_REG_B_PD4_LOW 0x7B
158#define OXIMETER_REG_B_PD1_HIGH 0x7C
159#define OXIMETER_REG_B_PD2_HIGH 0x7D
160#define OXIMETER_REG_B_PD3_HIGH 0x7E
161#define OXIMETER_REG_B_PD4_HIGH 0x7F
168#define OXIMETER_DIS_SLOT 0x00
169#define OXIMETER_EN_SLOT 0x01
176#define OXIMETER_NO_PHOTODIODE_CONN 0x00
177#define OXIMETER_ALL_PHOTODIODE_CONN 0x01
178#define OXIMETER_PD5_PD6_PD7_PD8_CONN 0x02
179#define OXIMETER_PD1_PD2_PD3_PD4_CONN 0x03
186#define OXIMETER_PDX_TO_AFE 0x00
187#define OXIMETER_LEDX1_EN 0x01
188#define OXIMETER_LEDX2_EN 0x02
189#define OXIMETER_LEDX3_EN 0x03
190#define OXIMETER_DIS_LED 0x04
197#define OXIMETER_SLOT_NORM_OP_MODE 0x00
198#define OXIMETER_SLOT_DIG_INT_OP_MODE 0x01
205#define OXIMETER_CH1_EN 0x00
206#define OXIMETER_CH2_EN 0x01
207#define OXIMETER_CH1_CH2_EN 0x02
208#define OXIMETER_CH3_CH4_EN 0x03
209#define OXIMETER_CH2_CH3_CH4_EN 0x04
210#define OXIMETER_ALL_CHANN_EN 0x05
217#define OXIMETER_AVERAGE_RES_MODE 0x00
218#define OXIMETER_SUM_RES_MODE 0x01
225#define OXIMETER_DEV_STANDBY_OP_MODE 0x0000
226#define OXIMETER_DEV_PROGRAM_OP_MODE 0x0001
227#define OXIMETER_DEV_NORMAL_OP_MODE 0x0002
234#define OXIMETER_DEVICE_ADDRESS 0x64
void oximeter_default_cfg(oximeter_t *ctx)
Click Default Configuration function.
err_t oximeter_write_reg(oximeter_t *ctx, uint8_t reg, uint16_t data_in)
Generic Write function.
err_t oximeter_enable_channels(oximeter_t *ctx, uint8_t select_channel)
Channels Enable function.
err_t oximeter_init(oximeter_t *ctx, oximeter_cfg_t *cfg)
Initialization function.
err_t oximeter_set_time_slot_b(oximeter_t *ctx, oximeter_enable_t *dev_enable, uint8_t set_mode)
Time Slot B Set function.
uint8_t oximeter_get_int_gpio0(oximeter_t *ctx)
GPIO0 Interrupt Get function.
uint8_t oximeter_get_int_gpio1(oximeter_t *ctx)
GPIO1 Interrupt Get function.
void oximeter_read_data(oximeter_t *ctx, uint32_t *chann_results, uint8_t result_mode)
Data Read function.
err_t oximeter_set_mode(oximeter_t *ctx, uint16_t select_mode)
Mode Set function.
err_t oximeter_set_time_slot_a(oximeter_t *ctx, oximeter_enable_t *dev_enable, uint8_t set_mode)
Time Slot A Set function.
err_t oximeter_read_reg(oximeter_t *ctx, uint8_t reg, uint16_t *data_out, uint8_t len)
Generic Read function.
void oximeter_reset(oximeter_t *ctx)
Reset function.
void oximeter_cfg_setup(oximeter_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition oximeter.h:269
uint8_t dev_enabled_slot_b
Definition oximeter.h:284
uint8_t dev_result_mode_check
Definition oximeter.h:285
pin_name_t io1
Definition oximeter.h:276
pin_name_t io0
Definition oximeter.h:275
uint32_t i2c_speed
Definition oximeter.h:279
uint8_t dev_enabled_chann
Definition oximeter.h:282
uint8_t dev_enabled_slot_a
Definition oximeter.h:283
pin_name_t scl
Definition oximeter.h:271
pin_name_t sda
Definition oximeter.h:272
uint8_t i2c_address
Definition oximeter.h:280
Definition oximeter.h:290
uint8_t enable_led
Definition oximeter.h:293
uint8_t enable_photodiode
Definition oximeter.h:292
uint8_t enable_slot
Definition oximeter.h:291
Click ctx object definition.
Definition oximeter.h:248
digital_in_t io0
Definition oximeter.h:249
uint8_t enabled_chann
Definition oximeter.h:258
uint8_t result_mode_check
Definition oximeter.h:261
uint8_t enabled_slot_b
Definition oximeter.h:260
digital_in_t io1
Definition oximeter.h:250
uint8_t enabled_slot_a
Definition oximeter.h:259
i2c_master_t i2c
Definition oximeter.h:253
uint8_t slave_address
Definition oximeter.h:256