Lines Matching +full:divide +full:- +full:10
4 * SPDX-License-Identifier: Apache-2.0
75 #define TMAG5170_SLEEPTIME_POS 10U
123 #define TMAG5170_MT_TO_GAUSS_RATIO 10U
163 int ret = spi_transceive_dt(&config->bus, &tx, &rx); in tmag5170_transmit_raw()
176 int ret = tmag5170_transmit_raw(dev->config, buffer_tx, buffer_rx); in tmag5170_transmit()
184 return -EIO; in tmag5170_transmit()
228 return -ENOTSUP; in tmag5170_convert_magn_reading_to_gauss()
241 int64_t result = chan_reading - ((chan_reading & 0x8000) << 1); in tmag5170_convert_magn_reading_to_gauss()
248 /* Divide as it is shown in datasheet */ in tmag5170_convert_magn_reading_to_gauss()
252 output->val1 = result / 100000; in tmag5170_convert_magn_reading_to_gauss()
253 output->val2 = result % 100000; in tmag5170_convert_magn_reading_to_gauss()
261 int32_t result = chan_reading - TMAG5170_T_ADC_T0; in tmag5170_convert_temp_reading_to_celsius()
265 output->val1 = result / 100000; in tmag5170_convert_temp_reading_to_celsius()
266 output->val2 = (result % 100000) * 10; in tmag5170_convert_temp_reading_to_celsius()
275 output->val1 = chan_reading >> 4; in tmag5170_covert_angle_reading_to_degrees()
276 output->val2 = ((chan_reading & 0xF) * 1000000) / 16; in tmag5170_covert_angle_reading_to_degrees()
282 const struct tmag5170_dev_config *cfg = dev->config; in tmag5170_sample_fetch()
283 struct tmag5170_data *drv_data = dev->data; in tmag5170_sample_fetch()
286 if (cfg->operating_mode == TMAG5170_STAND_BY_MODE || in tmag5170_sample_fetch()
287 cfg->operating_mode == TMAG5170_ACTIVE_TRIGGER_MODE) { in tmag5170_sample_fetch()
303 ret = tmag5170_read_register(dev, TMAG5170_REG_X_CH_RESULT, &drv_data->x, 0U); in tmag5170_sample_fetch()
306 ret = tmag5170_read_register(dev, TMAG5170_REG_Y_CH_RESULT, &drv_data->y, 0U); in tmag5170_sample_fetch()
309 ret = tmag5170_read_register(dev, TMAG5170_REG_Z_CH_RESULT, &drv_data->z, 0U); in tmag5170_sample_fetch()
312 ret = tmag5170_read_register(dev, TMAG5170_REG_X_CH_RESULT, &drv_data->x, 0U); in tmag5170_sample_fetch()
317 &drv_data->y, in tmag5170_sample_fetch()
323 &drv_data->z, in tmag5170_sample_fetch()
330 &drv_data->angle, in tmag5170_sample_fetch()
336 &drv_data->temperature, in tmag5170_sample_fetch()
342 &drv_data->temperature, in tmag5170_sample_fetch()
348 &drv_data->angle, in tmag5170_sample_fetch()
355 &drv_data->x, in tmag5170_sample_fetch()
362 &drv_data->y, in tmag5170_sample_fetch()
369 &drv_data->z, in tmag5170_sample_fetch()
375 ret = -ENOTSUP; in tmag5170_sample_fetch()
386 const struct tmag5170_dev_config *cfg = dev->config; in tmag5170_channel_get()
387 struct tmag5170_data *drv_data = dev->data; in tmag5170_channel_get()
393 drv_data->x, in tmag5170_channel_get()
394 cfg->x_range, in tmag5170_channel_get()
395 drv_data->chip_revision); in tmag5170_channel_get()
399 drv_data->y, in tmag5170_channel_get()
400 cfg->y_range, in tmag5170_channel_get()
401 drv_data->chip_revision); in tmag5170_channel_get()
406 drv_data->z, in tmag5170_channel_get()
407 cfg->z_range, in tmag5170_channel_get()
408 drv_data->chip_revision); in tmag5170_channel_get()
413 drv_data->x, in tmag5170_channel_get()
414 cfg->x_range, in tmag5170_channel_get()
415 drv_data->chip_revision); in tmag5170_channel_get()
419 drv_data->y, in tmag5170_channel_get()
420 cfg->y_range, in tmag5170_channel_get()
421 drv_data->chip_revision); in tmag5170_channel_get()
425 drv_data->z, in tmag5170_channel_get()
426 cfg->z_range, in tmag5170_channel_get()
427 drv_data->chip_revision); in tmag5170_channel_get()
430 tmag5170_covert_angle_reading_to_degrees(val, drv_data->angle); in tmag5170_channel_get()
433 tmag5170_convert_temp_reading_to_celsius(val, drv_data->temperature); in tmag5170_channel_get()
436 ret = -ENOTSUP; in tmag5170_channel_get()
445 const struct tmag5170_dev_config *cfg = dev->config; in tmag5170_init_registers()
446 struct tmag5170_data *drv_data = dev->data; in tmag5170_init_registers()
460 drv_data->chip_revision = TMAG5170_VER_GET(test_cfg_reg); in tmag5170_init_registers()
464 TMAG5170_ANGLE_EN_SET(cfg->angle_measurement) | in tmag5170_init_registers()
465 TMAG5170_SLEEPTIME_SET(cfg->sleep_time) | in tmag5170_init_registers()
466 TMAG5170_MAG_CH_EN_SET(cfg->magnetic_channels) | in tmag5170_init_registers()
467 TMAG5170_Z_RANGE_SET(cfg->z_range) | in tmag5170_init_registers()
468 TMAG5170_Y_RANGE_SET(cfg->y_range) | in tmag5170_init_registers()
469 TMAG5170_X_RANGE_SET(cfg->x_range)); in tmag5170_init_registers()
482 TMAG5170_OPERATING_MODE_SET(cfg->operating_mode) | in tmag5170_init_registers()
483 TMAG5170_CONV_AVG_SET(cfg->oversampling) | in tmag5170_init_registers()
484 TMAG5170_MAG_TEMPCO_SET(cfg->magnet_type) | in tmag5170_init_registers()
485 TMAG5170_T_CH_EN_SET(cfg->tempeature_measurement) | in tmag5170_init_registers()
486 TMAG5170_T_RATE_SET(cfg->disable_temperature_oversampling)); in tmag5170_init_registers()
503 /* As per datasheet, waking up from deep-sleep can take up to 500us */ in tmag5170_pm_action()
513 ret_val = -ENOTSUP; in tmag5170_pm_action()
530 const struct tmag5170_dev_config *cfg = dev->config; in tmag5170_init()
533 if (!spi_is_ready_dt(&cfg->bus)) { in tmag5170_init()
534 LOG_ERR("SPI dev %s not ready", cfg->bus.bus->name); in tmag5170_init()
535 return -ENODEV; in tmag5170_init()
544 if (cfg->int_gpio.port) { in tmag5170_init()