Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v1.13] boards/platform: remove confusing override #20264

Merged
merged 2 commits into from Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/cuav/x7pro/test.px4board
Expand Up @@ -10,3 +10,4 @@ CONFIG_MODULES_ROVER_POS_CONTROL=n
CONFIG_BOARD_TESTING=y
CONFIG_DRIVERS_TEST_PPM=y
CONFIG_SYSTEMCMDS_MICROBENCH=y
CONFIG_SYSTEMCMDS_BL_UPDATE=n
4 changes: 2 additions & 2 deletions boards/px4/fmu-v2/src/i2c.cpp
Expand Up @@ -47,14 +47,14 @@ constexpr px4_i2c_bus_t px4_i2c_buses[I2C_BUS_MAX_BUS_ITEMS] = {
};


bool px4_i2c_bus_external(const px4_i2c_bus_t &bus)
bool px4_i2c_bus_external(int bus)
{
if (HW_VER_FMUV3 == board_get_hw_version()) {
/* All FMUV3 2.1 i2c buses are external */
return true;

} else {
if (bus.bus != 2) {
if (bus != 2) {
return true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions boards/px4/fmu-v3/src/i2c.cpp
Expand Up @@ -47,14 +47,14 @@ constexpr px4_i2c_bus_t px4_i2c_buses[I2C_BUS_MAX_BUS_ITEMS] = {
};


bool px4_i2c_bus_external(const px4_i2c_bus_t &bus)
bool px4_i2c_bus_external(int bus)
{
if (HW_VER_FMUV3 == board_get_hw_version()) {
/* All FMUV3 2.1 i2c buses are external */
return true;

} else {
if (bus.bus != 2) {
if (bus != 2) {
return true;
}
}
Expand Down
14 changes: 10 additions & 4 deletions platforms/common/i2c.cpp
Expand Up @@ -38,9 +38,15 @@
#if defined(CONFIG_I2C)

#ifndef BOARD_OVERRIDE_I2C_BUS_EXTERNAL
bool px4_i2c_bus_external(const px4_i2c_bus_t &bus)
bool px4_i2c_bus_external(int bus)
{
return bus.is_external;
for (int i = 0; i < I2C_BUS_MAX_BUS_ITEMS; ++i) {
if (px4_i2c_buses[i].bus == bus) {
return px4_i2c_buses[i].is_external;
}
}

return true;
}
#endif // BOARD_OVERRIDE_I2C_BUS_EXTERNAL

Expand Down Expand Up @@ -72,7 +78,7 @@ bool I2CBusIterator::next()
break;

case FilterType::InternalBus:
if (!px4_i2c_bus_external(bus_data)) {
if (!px4_i2c_bus_external(bus_data.bus)) {
if (_bus == bus_data.bus || _bus == -1) {
return true;
}
Expand All @@ -81,7 +87,7 @@ bool I2CBusIterator::next()
break;

case FilterType::ExternalBus:
if (px4_i2c_bus_external(bus_data)) {
if (px4_i2c_bus_external(bus_data.bus)) {
++_external_bus_counter;

if (_bus == bus_data.bus || _bus == -1) {
Expand Down
18 changes: 2 additions & 16 deletions platforms/common/include/px4_platform_common/i2c.h
Expand Up @@ -50,21 +50,7 @@ __EXPORT extern const px4_i2c_bus_t px4_i2c_buses[I2C_BUS_MAX_BUS_ITEMS]; ///< b
* runtime-check if a board has a specific bus as external.
* This can be overridden by a board to add run-time checks.
*/
__EXPORT bool px4_i2c_bus_external(const px4_i2c_bus_t &bus);

/**
* runtime-check if a board has a specific bus as external.
*/
static inline bool px4_i2c_bus_external(int bus)
{
for (int i = 0; i < I2C_BUS_MAX_BUS_ITEMS; ++i) {
if (px4_i2c_buses[i].bus == bus) {
return px4_i2c_bus_external(px4_i2c_buses[i]);
}
}

return true;
}
__EXPORT bool px4_i2c_bus_external(int bus);

/**
* runtime-check if a board has a specific device as external.
Expand Down Expand Up @@ -98,7 +84,7 @@ class I2CBusIterator

int externalBusIndex() const { return _external_bus_counter; }

bool external() const { return px4_i2c_bus_external(bus()); }
bool external() const { return px4_i2c_bus_external(_bus); }

private:
const FilterType _filter;
Expand Down