Lines Matching +full:full +full:- +full:scale

3  * SPDX-License-Identifier: Apache-2.0
31 struct icm42688_emul_data *data = target->data; in icm42688_emul_set_reg()
34 memcpy(data->reg + reg_addr, val, count); in icm42688_emul_set_reg()
39 struct icm42688_emul_data *data = target->data; in icm42688_emul_get_reg()
42 memcpy(val, data->reg + reg_addr, count); in icm42688_emul_get_reg()
47 struct icm42688_emul_data *data = target->data; in icm42688_emul_handle_write()
53 memset(data->reg, 0, NUM_REGS); in icm42688_emul_handle_write()
54 /* Initialized the who-am-i register */ in icm42688_emul_handle_write()
55 data->reg[REG_WHO_AM_I] = WHO_AM_I_ICM42688; in icm42688_emul_handle_write()
57 data->reg[REG_INT_STATUS] |= BIT_INT_STATUS_RESET_DONE; in icm42688_emul_handle_write()
67 struct icm42688_emul_data *data = target->data; in icm42688_emul_io_spi()
75 tx = tx_bufs->buffers; in icm42688_emul_io_spi()
77 __ASSERT_NO_MSG(tx->len > 0); in icm42688_emul_io_spi()
79 regn = *(uint8_t *)tx->buf; in icm42688_emul_io_spi()
84 __ASSERT_NO_MSG(rx_bufs->count > 1); in icm42688_emul_io_spi()
86 rx = &rx_bufs->buffers[1]; in icm42688_emul_io_spi()
87 __ASSERT_NO_MSG(rx->buf != NULL); in icm42688_emul_io_spi()
88 __ASSERT_NO_MSG(rx->len > 0); in icm42688_emul_io_spi()
89 for (uint16_t i = 0; i < rx->len; ++i) { in icm42688_emul_io_spi()
90 ((uint8_t *)rx->buf)[i] = data->reg[regn + i]; in icm42688_emul_io_spi()
96 __ASSERT_NO_MSG(tx_bufs->count > 1); in icm42688_emul_io_spi()
97 tx = &tx_bufs->buffers[1]; in icm42688_emul_io_spi()
99 __ASSERT_NO_MSG(tx->len > 0); in icm42688_emul_io_spi()
100 value = ((uint8_t *)tx->buf)[0]; in icm42688_emul_io_spi()
109 struct icm42688_emul_data *data = target->data; in icm42688_emul_init()
111 /* Initialized the who-am-i register */ in icm42688_emul_init()
112 data->reg[REG_WHO_AM_I] = WHO_AM_I_ICM42688; in icm42688_emul_init()
124 * @brief Get current full-scale range in g's based on register config, along with corresponding
177 * @brief Helper function for calculating accelerometer ranges. Considers the current full-scale
178 * register config (i.e. +/-2g, +/-4g, etc...)
188 /* Epsilon is equal to 1.5 bit-counts worth of error. */ in icm42688_emul_get_accel_ranges()
191 *lower = -*upper; in icm42688_emul_get_accel_ranges()
195 * @brief Get current full-scale gyro range in milli-degrees per second based on register config,
210 /* Milli-degrees per second */ in icm42688_emul_get_gyro_settings()
215 shift_out = 6; /* +/- 34.90659 */ in icm42688_emul_get_gyro_settings()
220 shift_out = 5; /* +/- 17.44444 */ in icm42688_emul_get_gyro_settings()
225 shift_out = 4; /* +/- 8.72222 */ in icm42688_emul_get_gyro_settings()
230 shift_out = 3; /* +/- 4.36111 */ in icm42688_emul_get_gyro_settings()
235 shift_out = 2; /* +/- 2.18055 */ in icm42688_emul_get_gyro_settings()
240 shift_out = 1; /* +/- 1.09027 */ in icm42688_emul_get_gyro_settings()
245 shift_out = 0; /* +/- 0.54513 */ in icm42688_emul_get_gyro_settings()
250 shift_out = -1; /* +/- 0.27256 */ in icm42688_emul_get_gyro_settings()
268 * @brief Helper function for calculating gyroscope ranges. Considers the current full-scale
281 /* Reduce the actual range of gyroscope values. Some full-scale ranges actually exceed the in icm42688_emul_get_gyro_ranges()
282 * size of an int16 by a small margin. For example, FS_SEL=0 has a +/-2000 deg/s range with in icm42688_emul_get_gyro_ranges()
284 * +/-2000 * 16.4 = +/-32800. This will cause the expected value to get clipped when in icm42688_emul_get_gyro_ranges()
285 * setting the register and throw off the actual reading. Therefore, scale down the range in icm42688_emul_get_gyro_ranges()
291 /* Epsilon is equal to 1.5 bit-counts worth of error. */ in icm42688_emul_get_gyro_ranges()
295 *lower = -*upper; in icm42688_emul_get_gyro_ranges()
303 return -EINVAL; in icm42688_emul_backend_get_sample_range()
308 /* degrees C = ([16-bit signed temp_data register] / 132.48) + 25 */ in icm42688_emul_backend_get_sample_range()
310 *lower = (int64_t)(-222.342995169 * Q31_SCALE) >> *shift; in icm42688_emul_backend_get_sample_range()
325 return -ENOTSUP; in icm42688_emul_backend_get_sample_range()
334 if (!target || !target->data) { in icm42688_emul_backend_set_channel()
335 return -EINVAL; in icm42688_emul_backend_set_channel()
338 struct icm42688_emul_data *data = target->data; in icm42688_emul_backend_set_channel()
344 shift < 0 ? ((int64_t)*value >> -shift) : ((int64_t)*value << shift); in icm42688_emul_backend_set_channel()
349 reg_val = ((value_unshifted - (25 * Q31_SCALE)) * 13248) / (100 * Q31_SCALE); in icm42688_emul_backend_set_channel()
393 return -ENOTSUP; in icm42688_emul_backend_set_channel()
396 data->reg[reg_addr] = (reg_val >> 8) & 0xFF; in icm42688_emul_backend_set_channel()
397 data->reg[reg_addr + 1] = reg_val & 0xFF; in icm42688_emul_backend_set_channel()
400 data->reg[REG_INT_STATUS] |= BIT_INT_STATUS_DATA_RDY; in icm42688_emul_backend_set_channel()