forked from Archive/PX4-Autopilot
i2c_spi_buses: method to count instances per bus
Signed-off-by: Julian Oes <julian@oes.ch>
This commit is contained in:
parent
742d237ae3
commit
895ddee16a
|
@ -392,6 +392,19 @@ int BusInstanceIterator::runningInstancesCount() const
|
|||
return num_instances;
|
||||
}
|
||||
|
||||
int BusInstanceIterator::runningInstancesOnBusCount() const
|
||||
{
|
||||
int num_instances = 0;
|
||||
|
||||
for (const auto &modules : i2c_spi_module_instances) {
|
||||
if (modules->_bus == bus() && strcmp(modules->_module_name, _module_name) == 0) {
|
||||
++num_instances;
|
||||
}
|
||||
}
|
||||
|
||||
return num_instances;
|
||||
}
|
||||
|
||||
I2CSPIInstance *BusInstanceIterator::instance() const
|
||||
{
|
||||
if (_current_instance == i2c_spi_module_instances.end()) {
|
||||
|
|
|
@ -229,6 +229,7 @@ public:
|
|||
I2CSPIBusOption configuredBusOption() const { return _bus_option; }
|
||||
|
||||
int runningInstancesCount() const;
|
||||
int runningInstancesOnBusCount() const;
|
||||
|
||||
bool next();
|
||||
|
||||
|
|
Loading…
Reference in New Issue