start splitting up BMX055 into the three ICs in its package
Some checks failed
Some checks failed
This commit is contained in:
@ -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");
|
||||
}
|
||||
|
@ -192,11 +192,22 @@
|
||||
reg = <0x40>;
|
||||
};
|
||||
|
||||
bmx055: bmx055@18 {
|
||||
compatible = "bosch,bmx055";
|
||||
// BMX055 = BMA255 + BMG160 + BMM150
|
||||
bmx055_accel: bma255@18 {
|
||||
compatible = "bosch,bma255";
|
||||
reg = <0x18>;
|
||||
};
|
||||
|
||||
bmx055_gyro: bmg160@68 {
|
||||
compatible = "bosch,bmg160";
|
||||
reg = <0x68>;
|
||||
};
|
||||
|
||||
bmx055_mag: bmm150@10 {
|
||||
compatible = "bosch,bmm150";
|
||||
reg = <0x10>;
|
||||
};
|
||||
|
||||
lis2dh: lis2dh@19 {
|
||||
// This is built into the DWM1001 module
|
||||
compatible = "st,lis2dh";
|
||||
|
@ -2,5 +2,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
add_subdirectory_ifdef(CONFIG_EXAMPLE_SENSOR example_sensor)
|
||||
add_subdirectory_ifdef(CONFIG_BMX055 bmx055)
|
||||
add_subdirectory_ifdef(CONFIG_BMA255 bma255)
|
||||
add_subdirectory_ifdef(CONFIG_HDC1080 hdc1080)
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
if SENSOR
|
||||
rsource "example_sensor/Kconfig"
|
||||
rsource "bmx055/Kconfig"
|
||||
rsource "bma255/Kconfig"
|
||||
rsource "hdc1080/Kconfig"
|
||||
endif # SENSOR
|
||||
|
2
drivers/sensor/bma255/CMakeLists.txt
Normal file
2
drivers/sensor/bma255/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
zephyr_library()
|
||||
zephyr_library_sources(bma255.c)
|
17
drivers/sensor/bma255/Kconfig
Normal file
17
drivers/sensor/bma255/Kconfig
Normal file
@ -0,0 +1,17 @@
|
||||
config BMA255
|
||||
bool "BMA255"
|
||||
default y
|
||||
depends on DT_HAS_BOSCH_BMA255_ENABLED
|
||||
help
|
||||
Enable driver for BMA255.
|
||||
|
||||
if BMA255
|
||||
|
||||
config BMA255_TRIGGER
|
||||
bool "BMA255 trigger mode"
|
||||
depends on BMA255
|
||||
help
|
||||
Set to enable trigger mode using gpio interrupt, where
|
||||
interrupts are configured to line ALERT PIN.
|
||||
|
||||
endif # BMA255
|
@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT bosch_bmx055
|
||||
#define DT_DRV_COMPAT bosch_bma255
|
||||
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
@ -12,7 +12,7 @@
|
||||
#include <zephyr/sys/byteorder.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(bmx055, CONFIG_SENSOR_LOG_LEVEL);
|
||||
LOG_MODULE_REGISTER(bma255, CONFIG_SENSOR_LOG_LEVEL);
|
||||
|
||||
// Accelerometer registers
|
||||
const uint8_t ACCEL_REG_BWG_CHIPID = 0x00;
|
||||
@ -168,7 +168,7 @@ const uint8_t MAG_REG_HIGH_THRESH = 0x50;
|
||||
const uint8_t MAG_REG_REP_XY = 0x51;
|
||||
const uint8_t MAG_REG_REP_Z = 0x52;
|
||||
|
||||
struct bmx055_data
|
||||
struct bma255_data
|
||||
{
|
||||
int16_t accel_x;
|
||||
int16_t accel_y;
|
||||
@ -182,7 +182,7 @@ struct bmx055_data
|
||||
int8_t temperature;
|
||||
};
|
||||
|
||||
struct bmx055_config
|
||||
struct bma255_config
|
||||
{
|
||||
struct i2c_dt_spec bus;
|
||||
#ifdef CONFIG_INA230_TRIGGER
|
||||
@ -193,11 +193,11 @@ struct bmx055_config
|
||||
#endif /* CONFIG_INA230_TRIGGER */
|
||||
};
|
||||
|
||||
static int bmx055_sample_fetch(const struct device *dev,
|
||||
static int bma255_sample_fetch(const struct device *dev,
|
||||
enum sensor_channel chan)
|
||||
{
|
||||
const struct bmx055_config *config = dev->config;
|
||||
struct bmx055_data *data = dev->data;
|
||||
const struct bma255_config *config = dev->config;
|
||||
struct bma255_data *data = dev->data;
|
||||
int ret;
|
||||
|
||||
uint8_t accel[6];
|
||||
@ -247,11 +247,11 @@ static int bmx055_sample_fetch(const struct device *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bmx055_channel_get(const struct device *dev,
|
||||
static int bma255_channel_get(const struct device *dev,
|
||||
enum sensor_channel chan,
|
||||
struct sensor_value *val)
|
||||
{
|
||||
struct bmx055_data *data = dev->data;
|
||||
struct bma255_data *data = dev->data;
|
||||
|
||||
switch (chan)
|
||||
{
|
||||
@ -340,14 +340,14 @@ static int bmx055_channel_get(const struct device *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct sensor_driver_api bmx055_api = {
|
||||
.sample_fetch = &bmx055_sample_fetch,
|
||||
.channel_get = &bmx055_channel_get,
|
||||
static const struct sensor_driver_api bma255_api = {
|
||||
.sample_fetch = &bma255_sample_fetch,
|
||||
.channel_get = &bma255_channel_get,
|
||||
};
|
||||
|
||||
static int bmx055_init(const struct device *dev)
|
||||
static int bma255_init(const struct device *dev)
|
||||
{
|
||||
const struct bmx055_config *const config = dev->config;
|
||||
const struct bma255_config *const config = dev->config;
|
||||
int ret;
|
||||
|
||||
if (!device_is_ready(config->bus.bus))
|
||||
@ -443,16 +443,16 @@ static int bmx055_init(const struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define BMX055_INIT(i) \
|
||||
static struct bmx055_data bmx055_data_##i; \
|
||||
#define BMA255_INIT(i) \
|
||||
static struct bma255_data bma255_data_##i; \
|
||||
\
|
||||
static const struct bmx055_config bmx055_config_##i = { \
|
||||
static const struct bma255_config bma255_config_##i = { \
|
||||
.bus = I2C_DT_SPEC_INST_GET(i), \
|
||||
}; \
|
||||
\
|
||||
SENSOR_DEVICE_DT_INST_DEFINE(i, &bmx055_init, NULL, \
|
||||
&bmx055_data_##i, \
|
||||
&bmx055_config_##i, POST_KERNEL, \
|
||||
CONFIG_SENSOR_INIT_PRIORITY, &bmx055_api);
|
||||
SENSOR_DEVICE_DT_INST_DEFINE(i, &bma255_init, NULL, \
|
||||
&bma255_data_##i, \
|
||||
&bma255_config_##i, POST_KERNEL, \
|
||||
CONFIG_SENSOR_INIT_PRIORITY, &bma255_api);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(BMX055_INIT)
|
||||
DT_INST_FOREACH_STATUS_OKAY(BMA255_INIT)
|
@ -1,2 +0,0 @@
|
||||
zephyr_library()
|
||||
zephyr_library_sources(bmx055.c)
|
@ -1,17 +0,0 @@
|
||||
config BMX055
|
||||
bool "BMX055"
|
||||
default y
|
||||
depends on DT_HAS_BOSCH_BMX055_ENABLED
|
||||
help
|
||||
Enable driver for BMX055.
|
||||
|
||||
if BMX055
|
||||
|
||||
config BMX055_TRIGGER
|
||||
bool "BMX055 trigger mode"
|
||||
depends on BMX055
|
||||
help
|
||||
Set to enable trigger mode using gpio interrupt, where
|
||||
interrupts are configured to line ALERT PIN.
|
||||
|
||||
endif # BMX055
|
@ -1,7 +1,7 @@
|
||||
description: |
|
||||
TODO: add a description
|
||||
|
||||
compatible: "bosch,bmx055"
|
||||
compatible: "bosch,bma255"
|
||||
|
||||
include: [sensor-device.yaml, i2c-device.yaml]
|
||||
|
||||
|
Reference in New Issue
Block a user