Lines Matching +full:s11059 +full:- +full:02 +full:dt

4  * SPDX-License-Identifier: Apache-2.0
7 * https://datasheetspdf.com/pdf/1323325/Hamamatsu/S11059-02DT/1
20 LOG_MODULE_REGISTER(S11059, CONFIG_SENSOR_LOG_LEVEL);
104 const struct s11059_dev_config *cfg = dev->config; in s11059_samples_read()
108 return -EINVAL; in s11059_samples_read()
111 rc = i2c_burst_read_dt(&cfg->bus, addr, (uint8_t *)val, size); in s11059_samples_read()
125 const struct s11059_dev_config *cfg = dev->config; in s11059_control_write()
128 return i2c_write_dt(&cfg->bus, opcode, sizeof(opcode)); in s11059_control_write()
133 const struct s11059_dev_config *cfg = dev->config; in s11059_manual_timing_write()
137 return i2c_write_dt(&cfg->bus, opcode, sizeof(opcode)); in s11059_manual_timing_write()
142 const struct s11059_dev_config *cfg = dev->config; in s11059_start_measurement()
147 rc = i2c_reg_read_byte_dt(&cfg->bus, S11059_REG_ADDR_CONTROL, &control); in s11059_start_measurement()
149 LOG_ERR("%s, Failed to read current control.", dev->name); in s11059_start_measurement()
158 LOG_ERR("%s, Failed to reset adc.", dev->name); in s11059_start_measurement()
166 LOG_ERR("%s, Failed to start device.", dev->name); in s11059_start_measurement()
176 const struct s11059_dev_config *cfg = dev->config; in s11059_integ_time_calculate()
179 if (cfg->integration_time < integ_time_factor[0]) { in s11059_integ_time_calculate()
186 tmp = cfg->integration_time / integ_time_factor[i]; in s11059_integ_time_calculate()
199 const struct s11059_dev_config *cfg = dev->config; in s11059_sample_fetch()
200 struct s11059_data *drv_data = dev->data; in s11059_sample_fetch()
206 LOG_ERR("%s, Unsupported sensor channel", dev->name); in s11059_sample_fetch()
207 return -ENOTSUP; in s11059_sample_fetch()
212 LOG_ERR("%s, Failed to start measurement.", dev->name); in s11059_sample_fetch()
217 rc = i2c_reg_read_byte_dt(&cfg->bus, S11059_REG_ADDR_CONTROL, &control); in s11059_sample_fetch()
219 LOG_ERR("%s, Failed to read control.", dev->name); in s11059_sample_fetch()
228 LOG_ERR("%s, Failed to get sample.", dev->name); in s11059_sample_fetch()
233 drv_data->samples[i] = values[i]; in s11059_sample_fetch()
242 const struct s11059_dev_config *cfg = dev->config; in s11059_channel_get()
243 struct s11059_data *drv_data = dev->data; in s11059_channel_get()
245 const uint16_t factor = convert_factors[cfg->gain][index]; in s11059_channel_get()
248 meas_value = drv_data->samples[index] * S11059_CARRY_UP / factor; in s11059_channel_get()
249 val->val1 = meas_value / (S11059_CARRY_UP / 10); in s11059_channel_get()
250 val->val2 = meas_value % (S11059_CARRY_UP / 10); in s11059_channel_get()
257 const struct s11059_dev_config *cfg = dev->config; in s11059_init()
264 if (!i2c_is_ready_dt(&cfg->bus)) { in s11059_init()
265 LOG_ERR("%s, device is not ready.", dev->name); in s11059_init()
266 return -ENODEV; in s11059_init()
271 LOG_ERR("%s, Failed to calculate manual timing.", dev->name); in s11059_init()
277 LOG_ERR("%s, Failed to set manual timing.", dev->name); in s11059_init()
283 WRITE_BIT(control, S11059_CONTROL_GAIN, cfg->gain); in s11059_init()
286 LOG_ERR("%s, Failed to set gain and integration time.", dev->name); in s11059_init()