mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-17 07:27:34 +08:00
Support PX4_I2C_BUS_ONBOARD not defined
This commit is contained in:
committed by
Lorenz Meier
parent
2641ebb99b
commit
d6c6cb72b2
@@ -97,7 +97,7 @@ LidarLite *get_dev(const bool use_i2c, const int bus)
|
||||
LidarLite *g_dev = nullptr;
|
||||
|
||||
if (use_i2c) {
|
||||
g_dev = static_cast<LidarLite *>(bus == PX4_I2C_BUS_ONBOARD ? g_dev_int : g_dev_ext);
|
||||
g_dev = static_cast<LidarLite *>(bus == PX4_I2C_BUS_EXPANSION ? g_dev_ext : g_dev_int);
|
||||
|
||||
if (g_dev == nullptr) {
|
||||
errx(1, "i2c driver not running");
|
||||
@@ -231,11 +231,12 @@ void start(const bool use_i2c, const int bus)
|
||||
|
||||
fail:
|
||||
|
||||
#ifdef PX4_I2C_BUS_ONBOARD
|
||||
if (g_dev_int != nullptr && (bus == -1 || bus == PX4_I2C_BUS_ONBOARD)) {
|
||||
delete g_dev_int;
|
||||
g_dev_int = nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (g_dev_ext != nullptr && (bus == -1 || bus == PX4_I2C_BUS_EXPANSION)) {
|
||||
delete g_dev_ext;
|
||||
g_dev_ext = nullptr;
|
||||
@@ -255,17 +256,16 @@ fail:
|
||||
void stop(const bool use_i2c, const int bus)
|
||||
{
|
||||
if (use_i2c) {
|
||||
if (bus == PX4_I2C_BUS_ONBOARD) {
|
||||
if (g_dev_int != nullptr) {
|
||||
delete g_dev_int;
|
||||
g_dev_int = nullptr;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (bus == PX4_I2C_BUS_EXPANSION) {
|
||||
if (g_dev_ext != nullptr) {
|
||||
delete g_dev_ext;
|
||||
g_dev_ext = nullptr;
|
||||
}
|
||||
} else {
|
||||
if (g_dev_int != nullptr) {
|
||||
delete g_dev_int;
|
||||
g_dev_int = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -293,7 +293,7 @@ test(const bool use_i2c, const int bus)
|
||||
const char *path;
|
||||
|
||||
if (use_i2c) {
|
||||
path = ((bus == PX4_I2C_BUS_ONBOARD) ? LL40LS_DEVICE_PATH_INT : LL40LS_DEVICE_PATH_EXT);
|
||||
path = ((bus == PX4_I2C_BUS_EXPANSION) ? LL40LS_DEVICE_PATH_EXT : LL40LS_DEVICE_PATH_INT);
|
||||
|
||||
} else {
|
||||
path = LL40LS_DEVICE_PATH_PWM;
|
||||
@@ -366,7 +366,7 @@ reset(const bool use_i2c, const int bus)
|
||||
const char *path;
|
||||
|
||||
if (use_i2c) {
|
||||
path = ((bus == PX4_I2C_BUS_ONBOARD) ? LL40LS_DEVICE_PATH_INT : LL40LS_DEVICE_PATH_EXT);
|
||||
path = ((bus == PX4_I2C_BUS_EXPANSION) ? LL40LS_DEVICE_PATH_EXT : LL40LS_DEVICE_PATH_INT);
|
||||
|
||||
} else {
|
||||
path = LL40LS_DEVICE_PATH_PWM;
|
||||
|
||||
@@ -694,7 +694,9 @@ start()
|
||||
#ifdef PX4_I2C_BUS_ESC
|
||||
PX4_I2C_BUS_ESC,
|
||||
#endif
|
||||
#ifdef PX4_I2C_BUS_ONBOARD
|
||||
PX4_I2C_BUS_ONBOARD,
|
||||
#endif
|
||||
-1
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user