Lines Matching +full:i2c +full:- +full:mode

4  * SPDX-License-Identifier: Apache-2.0
18 struct max30101_data *data = dev->data; in max30101_sample_fetch()
19 const struct max30101_config *config = dev->config; in max30101_sample_fetch()
27 num_bytes = data->num_channels * MAX30101_BYTES_PER_CHANNEL; in max30101_sample_fetch()
28 if (i2c_burst_read_dt(&config->i2c, MAX30101_REG_FIFO_DATA, buffer, in max30101_sample_fetch()
31 return -EIO; in max30101_sample_fetch()
36 /* Each channel is 18-bits */ in max30101_sample_fetch()
42 data->raw[fifo_chan++] = fifo_data; in max30101_sample_fetch()
52 struct max30101_data *data = dev->data; in max30101_channel_get()
71 return -ENOTSUP; in max30101_channel_get()
78 fifo_chan = data->map[led_chan]; in max30101_channel_get()
81 return -ENOTSUP; in max30101_channel_get()
85 val->val1 = data->raw[fifo_chan]; in max30101_channel_get()
86 val->val2 = 0; in max30101_channel_get()
98 const struct max30101_config *config = dev->config; in max30101_init()
99 struct max30101_data *data = dev->data; in max30101_init()
105 if (!device_is_ready(config->i2c.bus)) { in max30101_init()
107 return -ENODEV; in max30101_init()
111 if (i2c_reg_read_byte_dt(&config->i2c, MAX30101_REG_PART_ID, in max30101_init()
114 return -EIO; in max30101_init()
119 return -EIO; in max30101_init()
123 if (i2c_reg_write_byte_dt(&config->i2c, MAX30101_REG_MODE_CFG, in max30101_init()
125 return -EIO; in max30101_init()
130 if (i2c_reg_read_byte_dt(&config->i2c, MAX30101_REG_MODE_CFG, in max30101_init()
132 LOG_ERR("Could read mode cfg after reset"); in max30101_init()
133 return -EIO; in max30101_init()
138 if (i2c_reg_write_byte_dt(&config->i2c, MAX30101_REG_FIFO_CFG, in max30101_init()
139 config->fifo)) { in max30101_init()
140 return -EIO; in max30101_init()
143 /* Write the mode configuration register */ in max30101_init()
144 if (i2c_reg_write_byte_dt(&config->i2c, MAX30101_REG_MODE_CFG, in max30101_init()
145 config->mode)) { in max30101_init()
146 return -EIO; in max30101_init()
150 if (i2c_reg_write_byte_dt(&config->i2c, MAX30101_REG_SPO2_CFG, in max30101_init()
151 config->spo2)) { in max30101_init()
152 return -EIO; in max30101_init()
156 if (i2c_reg_write_byte_dt(&config->i2c, MAX30101_REG_LED1_PA, in max30101_init()
157 config->led_pa[0])) { in max30101_init()
158 return -EIO; in max30101_init()
160 if (i2c_reg_write_byte_dt(&config->i2c, MAX30101_REG_LED2_PA, in max30101_init()
161 config->led_pa[1])) { in max30101_init()
162 return -EIO; in max30101_init()
164 if (i2c_reg_write_byte_dt(&config->i2c, MAX30101_REG_LED3_PA, in max30101_init()
165 config->led_pa[2])) { in max30101_init()
166 return -EIO; in max30101_init()
172 /* Write the multi-LED mode control registers */ in max30101_init()
173 multi_led[0] = (config->slot[1] << 4) | (config->slot[0]); in max30101_init()
174 multi_led[1] = (config->slot[3] << 4) | (config->slot[2]); in max30101_init()
176 if (i2c_reg_write_byte_dt(&config->i2c, MAX30101_REG_MULTI_LED, in max30101_init()
178 return -EIO; in max30101_init()
180 if (i2c_reg_write_byte_dt(&config->i2c, MAX30101_REG_MULTI_LED + 1, in max30101_init()
182 return -EIO; in max30101_init()
187 data->num_channels = 0U; in max30101_init()
189 data->map[led_chan] = MAX30101_MAX_NUM_CHANNELS; in max30101_init()
197 led_chan = (config->slot[fifo_chan] & MAX30101_SLOT_LED_MASK)-1; in max30101_init()
199 data->map[led_chan] = fifo_chan; in max30101_init()
200 data->num_channels++; in max30101_init()
208 .i2c = I2C_DT_SPEC_INST_GET(0),
217 .mode = MAX30101_MODE_HEART_RATE,
223 .mode = MAX30101_MODE_SPO2,
229 .mode = MAX30101_MODE_MULTI_LED,