mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 03:49:12 +08:00
platforms/common:SPI - fix hang on bords supporting BOARD_HAS_BUS_MANIFEST
This commit is contained in:
committed by
Lorenz Meier
parent
d01cec192f
commit
f5e5794930
+32
-33
@@ -112,49 +112,48 @@ bool SPIBusIterator::next()
|
|||||||
while (_index < SPI_BUS_MAX_BUS_ITEMS && px4_spi_buses[_index].bus != -1) {
|
while (_index < SPI_BUS_MAX_BUS_ITEMS && px4_spi_buses[_index].bus != -1) {
|
||||||
const px4_spi_bus_t &bus_data = px4_spi_buses[_index];
|
const px4_spi_bus_t &bus_data = px4_spi_buses[_index];
|
||||||
|
|
||||||
if (!board_has_bus(BOARD_SPI_BUS, bus_data.bus)) {
|
if (board_has_bus(BOARD_SPI_BUS, bus_data.bus)) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: we use bus_data.is_external here instead of px4_spi_bus_external(),
|
// Note: we use bus_data.is_external here instead of px4_spi_bus_external(),
|
||||||
// otherwise the chip-select matching does not work if a bus is configured as
|
// otherwise the chip-select matching does not work if a bus is configured as
|
||||||
// external/internal, but at runtime the other way around.
|
// external/internal, but at runtime the other way around.
|
||||||
// (On boards where a bus can be internal/external at runtime, it should be
|
// (On boards where a bus can be internal/external at runtime, it should be
|
||||||
// configured as external.)
|
// configured as external.)
|
||||||
switch (_filter) {
|
switch (_filter) {
|
||||||
case FilterType::InternalBus:
|
case FilterType::InternalBus:
|
||||||
if (!bus_data.is_external) {
|
if (!bus_data.is_external) {
|
||||||
if (_bus == bus_data.bus || _bus == -1) {
|
if (_bus == bus_data.bus || _bus == -1) {
|
||||||
// find device id
|
// find device id
|
||||||
for (int i = _bus_device_index + 1; i < SPI_BUS_MAX_DEVICES; ++i) {
|
for (int i = _bus_device_index + 1; i < SPI_BUS_MAX_DEVICES; ++i) {
|
||||||
if (PX4_SPI_DEVICE_ID == PX4_SPIDEVID_TYPE(bus_data.devices[i].devid) &&
|
if (PX4_SPI_DEVICE_ID == PX4_SPIDEVID_TYPE(bus_data.devices[i].devid) &&
|
||||||
_devid_driver_index == bus_data.devices[i].devtype_driver) {
|
_devid_driver_index == bus_data.devices[i].devtype_driver) {
|
||||||
_bus_device_index = i;
|
_bus_device_index = i;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FilterType::ExternalBus:
|
case FilterType::ExternalBus:
|
||||||
if (bus_data.is_external) {
|
if (bus_data.is_external) {
|
||||||
uint16_t cs_index = _devid_driver_index - 1;
|
uint16_t cs_index = _devid_driver_index - 1;
|
||||||
|
|
||||||
if (_bus == _external_bus_counter && cs_index < SPI_BUS_MAX_DEVICES &&
|
if (_bus == _external_bus_counter && cs_index < SPI_BUS_MAX_DEVICES &&
|
||||||
bus_data.devices[cs_index].cs_gpio != 0 && cs_index != _bus_device_index) {
|
bus_data.devices[cs_index].cs_gpio != 0 && cs_index != _bus_device_index) {
|
||||||
// we know that bus_data.devices[cs_index].devtype_driver == cs_index
|
// we know that bus_data.devices[cs_index].devtype_driver == cs_index
|
||||||
_bus_device_index = cs_index;
|
_bus_device_index = cs_index;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
if (bus_data.is_external) {
|
||||||
}
|
++_external_bus_counter;
|
||||||
|
}
|
||||||
if (bus_data.is_external) {
|
|
||||||
++_external_bus_counter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
++_index;
|
++_index;
|
||||||
|
|||||||
Reference in New Issue
Block a user