mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 19:13: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;
|
LidarLite *g_dev = nullptr;
|
||||||
|
|
||||||
if (use_i2c) {
|
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) {
|
if (g_dev == nullptr) {
|
||||||
errx(1, "i2c driver not running");
|
errx(1, "i2c driver not running");
|
||||||
@@ -231,11 +231,12 @@ void start(const bool use_i2c, const int bus)
|
|||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
|
||||||
|
#ifdef PX4_I2C_BUS_ONBOARD
|
||||||
if (g_dev_int != nullptr && (bus == -1 || bus == PX4_I2C_BUS_ONBOARD)) {
|
if (g_dev_int != nullptr && (bus == -1 || bus == PX4_I2C_BUS_ONBOARD)) {
|
||||||
delete g_dev_int;
|
delete g_dev_int;
|
||||||
g_dev_int = nullptr;
|
g_dev_int = nullptr;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (g_dev_ext != nullptr && (bus == -1 || bus == PX4_I2C_BUS_EXPANSION)) {
|
if (g_dev_ext != nullptr && (bus == -1 || bus == PX4_I2C_BUS_EXPANSION)) {
|
||||||
delete g_dev_ext;
|
delete g_dev_ext;
|
||||||
g_dev_ext = nullptr;
|
g_dev_ext = nullptr;
|
||||||
@@ -255,17 +256,16 @@ fail:
|
|||||||
void stop(const bool use_i2c, const int bus)
|
void stop(const bool use_i2c, const int bus)
|
||||||
{
|
{
|
||||||
if (use_i2c) {
|
if (use_i2c) {
|
||||||
if (bus == PX4_I2C_BUS_ONBOARD) {
|
if (bus == PX4_I2C_BUS_EXPANSION) {
|
||||||
if (g_dev_int != nullptr) {
|
|
||||||
delete g_dev_int;
|
|
||||||
g_dev_int = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (g_dev_ext != nullptr) {
|
if (g_dev_ext != nullptr) {
|
||||||
delete g_dev_ext;
|
delete g_dev_ext;
|
||||||
g_dev_ext = nullptr;
|
g_dev_ext = nullptr;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (g_dev_int != nullptr) {
|
||||||
|
delete g_dev_int;
|
||||||
|
g_dev_int = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -293,7 +293,7 @@ test(const bool use_i2c, const int bus)
|
|||||||
const char *path;
|
const char *path;
|
||||||
|
|
||||||
if (use_i2c) {
|
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 {
|
} else {
|
||||||
path = LL40LS_DEVICE_PATH_PWM;
|
path = LL40LS_DEVICE_PATH_PWM;
|
||||||
@@ -366,7 +366,7 @@ reset(const bool use_i2c, const int bus)
|
|||||||
const char *path;
|
const char *path;
|
||||||
|
|
||||||
if (use_i2c) {
|
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 {
|
} else {
|
||||||
path = LL40LS_DEVICE_PATH_PWM;
|
path = LL40LS_DEVICE_PATH_PWM;
|
||||||
|
|||||||
@@ -694,7 +694,9 @@ start()
|
|||||||
#ifdef PX4_I2C_BUS_ESC
|
#ifdef PX4_I2C_BUS_ESC
|
||||||
PX4_I2C_BUS_ESC,
|
PX4_I2C_BUS_ESC,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef PX4_I2C_BUS_ONBOARD
|
||||||
PX4_I2C_BUS_ONBOARD,
|
PX4_I2C_BUS_ONBOARD,
|
||||||
|
#endif
|
||||||
-1
|
-1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user