start splitting up BMX055 into the three ICs in its package
Some checks failed
Build / build (ubuntu-22.04) (push) Failing after 1m44s
Documentation / build (push) Successful in 22s

This commit is contained in:
2024-07-04 23:08:40 -06:00
parent e0a90fd875
commit d0fd24548c
10 changed files with 101 additions and 66 deletions

View File

@ -83,7 +83,7 @@ static void bt_ready(int err)
int main(void)
{
const struct device *display, *ina, *baro, *imu, *lis, *hdc;
const struct device *display, *ina, *baro, *accel, *gyro, *mag, *lis, *hdc;
int err;
uint16_t x_res;
uint16_t y_res;
@ -187,13 +187,31 @@ int main(void)
return 0;
}
imu = DEVICE_DT_GET(DT_NODELABEL(bmx055));
if (!device_is_ready(imu))
accel = DEVICE_DT_GET(DT_NODELABEL(bmx055_accel));
if (!device_is_ready(accel))
{
LOG_ERR("Device %s not ready", imu->name);
LOG_ERR("Device %s not ready", accel->name);
return 0;
}
LOG_INF("Initialized %s", imu->name);
LOG_INF("Initialized %s", accel->name);
gyro = accel; // FIXME: this is a hack while splitting apart BMX055
// gyro = DEVICE_DT_GET(DT_NODELABEL(bmx055_gyro));
// if (!device_is_ready(gyro))
// {
// LOG_ERR("Device %s not ready", gyro->name);
// return 0;
// }
// LOG_INF("Initialized %s", gyro->name);
mag = accel; // FIXME: this is a hack while splitting apart BMX055
// mag = DEVICE_DT_GET(DT_NODELABEL(bmx055_mag));
// if (!device_is_ready(mag))
// {
// LOG_ERR("Device %s not ready", mag->name);
// return 0;
// }
// LOG_INF("Initialized %s", mag->name);
lis = DEVICE_DT_GET(DT_NODELABEL(lis2dh));
if (!device_is_ready(lis))
@ -238,47 +256,53 @@ int main(void)
LOG_ERR("Could not get temperature");
}
if (sensor_sample_fetch(imu) < 0)
if (sensor_sample_fetch(accel) < 0)
{
LOG_ERR("Could not fetch sample from imu");
LOG_ERR("Could not fetch sample from accel");
}
if (sensor_channel_get(imu, SENSOR_CHAN_DIE_TEMP, &temperature) < 0)
{
LOG_ERR("Could not get temperature");
}
if (sensor_channel_get(imu, SENSOR_CHAN_ACCEL_X, &accel_x) < 0)
if (sensor_channel_get(accel, SENSOR_CHAN_ACCEL_X, &accel_x) < 0)
{
LOG_ERR("Could not get acceleration");
}
if (sensor_channel_get(imu, SENSOR_CHAN_ACCEL_Y, &accel_y) < 0)
if (sensor_channel_get(accel, SENSOR_CHAN_ACCEL_Y, &accel_y) < 0)
{
LOG_ERR("Could not get acceleration");
}
if (sensor_channel_get(imu, SENSOR_CHAN_ACCEL_Z, &accel_z) < 0)
if (sensor_channel_get(accel, SENSOR_CHAN_ACCEL_Z, &accel_z) < 0)
{
LOG_ERR("Could not get acceleration");
}
if (sensor_channel_get(imu, SENSOR_CHAN_GYRO_X, &gyro_x) < 0)
// if (sensor_sample_fetch(gyro) < 0)
// {
// LOG_ERR("Could not fetch sample from gyro");
// }
if (sensor_channel_get(gyro, SENSOR_CHAN_GYRO_X, &gyro_x) < 0)
{
LOG_ERR("Could not get gyro");
}
if (sensor_channel_get(imu, SENSOR_CHAN_GYRO_Y, &gyro_y) < 0)
if (sensor_channel_get(gyro, SENSOR_CHAN_GYRO_Y, &gyro_y) < 0)
{
LOG_ERR("Could not get gyro");
}
if (sensor_channel_get(imu, SENSOR_CHAN_GYRO_Z, &gyro_z) < 0)
if (sensor_channel_get(gyro, SENSOR_CHAN_GYRO_Z, &gyro_z) < 0)
{
LOG_ERR("Could not get gyro");
}
if (sensor_channel_get(imu, SENSOR_CHAN_MAGN_X, &mag_x) < 0)
// if (sensor_sample_fetch(mag) < 0)
// {
// LOG_ERR("Could not fetch sample from mag");
// }
if (sensor_channel_get(mag, SENSOR_CHAN_MAGN_X, &mag_x) < 0)
{
LOG_ERR("Could not get mag");
}
if (sensor_channel_get(imu, SENSOR_CHAN_MAGN_Y, &mag_y) < 0)
if (sensor_channel_get(mag, SENSOR_CHAN_MAGN_Y, &mag_y) < 0)
{
LOG_ERR("Could not get mag");
}
if (sensor_channel_get(imu, SENSOR_CHAN_MAGN_Z, &mag_z) < 0)
if (sensor_channel_get(mag, SENSOR_CHAN_MAGN_Z, &mag_z) < 0)
{
LOG_ERR("Could not get mag");
}