drivers: sensor: bmi160: Add a constant for number of axes
Define a constant instead of using an open-coded value. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
e944855bbc
commit
2c73f3ed4c
2 changed files with 11 additions and 7 deletions
|
@ -348,7 +348,7 @@ static int bmi160_acc_ofs_set(const struct device *dev,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++, ofs++) {
|
||||
for (i = 0; i < BMI160_AXES; i++, ofs++) {
|
||||
/* convert ofset to micro m/s^2 */
|
||||
ofs_u = ofs->val1 * 1000000ULL + ofs->val2;
|
||||
reg_val = ofs_u / BMI160_ACC_OFS_LSB;
|
||||
|
@ -389,7 +389,7 @@ static int bmi160_acc_calibrate(const struct device *dev,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++, xyz_calib_value++) {
|
||||
for (i = 0; i < BMI160_AXES; i++, xyz_calib_value++) {
|
||||
int32_t accel_g;
|
||||
uint8_t accel_val;
|
||||
|
||||
|
@ -518,7 +518,7 @@ static int bmi160_gyr_ofs_set(const struct device *dev,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++, ofs++) {
|
||||
for (i = 0; i < BMI160_AXES; i++, ofs++) {
|
||||
/* convert offset to micro rad/s */
|
||||
ofs_u = ofs->val1 * 1000000ULL + ofs->val2;
|
||||
|
||||
|
|
|
@ -401,11 +401,13 @@ union bmi160_pmu_status {
|
|||
};
|
||||
};
|
||||
|
||||
#define BMI160_AXES 3
|
||||
|
||||
#if !defined(CONFIG_BMI160_GYRO_PMU_SUSPEND) && \
|
||||
!defined(CONFIG_BMI160_ACCEL_PMU_SUSPEND)
|
||||
# define BMI160_SAMPLE_SIZE (6 * sizeof(uint16_t))
|
||||
# define BMI160_SAMPLE_SIZE (2 * BMI160_AXES * sizeof(uint16_t))
|
||||
#else
|
||||
# define BMI160_SAMPLE_SIZE (3 * sizeof(uint16_t))
|
||||
# define BMI160_SAMPLE_SIZE (BMI160_AXES * sizeof(uint16_t))
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BMI160_GYRO_PMU_SUSPEND)
|
||||
|
@ -417,15 +419,17 @@ union bmi160_pmu_status {
|
|||
#endif
|
||||
|
||||
#define BMI160_BUF_SIZE (BMI160_SAMPLE_SIZE)
|
||||
|
||||
/* Each sample has X, Y and Z */
|
||||
union bmi160_sample {
|
||||
uint8_t raw[BMI160_BUF_SIZE];
|
||||
struct {
|
||||
uint8_t dummy_byte;
|
||||
#if !defined(CONFIG_BMI160_GYRO_PMU_SUSPEND)
|
||||
uint16_t gyr[3];
|
||||
uint16_t gyr[BMI160_AXES];
|
||||
#endif
|
||||
#if !defined(CONFIG_BMI160_ACCEL_PMU_SUSPEND)
|
||||
uint16_t acc[3];
|
||||
uint16_t acc[BMI160_AXES];
|
||||
#endif
|
||||
} __packed;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue