SPI: disable SPI locking where possible

It's not possible for buses that run both NuttX and PX4 drivers, e.g.
Pixracer.

Reduces CPU load:
- v5x: 2.5%
- v3 (pixhawk cube): 4.4%
This commit is contained in:
Beat Küng
2020-03-19 15:01:35 +01:00
committed by Daniel Agar
parent 6a41c9e417
commit 1612f4c2ed
3 changed files with 6 additions and 9 deletions

View File

@@ -68,7 +68,7 @@ static inline constexpr px4_spi_bus_t initSPIBus(SPI::Bus bus, const px4_spi_bus
GPIO::GPIOPin power_enable = {})
{
px4_spi_bus_t ret{};
ret.requires_locking = true; // TODO: set this to false once all drivers are converted to use the I2CSPIDriver class
ret.requires_locking = false;
for (int i = 0; i < SPI_BUS_MAX_DEVICES; ++i) {
ret.devices[i] = devices.devices[i];
@@ -118,8 +118,7 @@ static inline constexpr px4_spi_bus_t initSPIBusExternal(SPI::Bus bus, const bus
ret.bus = (int)bus;
ret.is_external = true;
// TODO: set requires_locking to false once all drivers are converted to use the I2CSPIDriver class
ret.requires_locking = true; // external buses are never accessed by NuttX drivers
ret.requires_locking = false; // external buses are never accessed by NuttX drivers
return ret;
}

View File

@@ -62,7 +62,7 @@ static inline constexpr px4_spi_bus_t initSPIBus(SPI::Bus bus, const px4_spi_bus
GPIO::GPIOPin power_enable = {})
{
px4_spi_bus_t ret{};
ret.requires_locking = true; // TODO: set this to false once all drivers are converted to use the I2CSPIDriver class
ret.requires_locking = false;
for (int i = 0; i < SPI_BUS_MAX_DEVICES; ++i) {
ret.devices[i] = devices.devices[i];
@@ -112,8 +112,7 @@ static inline constexpr px4_spi_bus_t initSPIBusExternal(SPI::Bus bus, const bus
ret.bus = (int)bus;
ret.is_external = true;
// TODO: set requires_locking to false once all drivers are converted to use the I2CSPIDriver class
ret.requires_locking = true; // external buses are never accessed by NuttX drivers
ret.requires_locking = false; // external buses are never accessed by NuttX drivers
return ret;
}

View File

@@ -64,7 +64,7 @@ static inline constexpr px4_spi_bus_t initSPIBus(SPI::Bus bus, const px4_spi_bus
GPIO::GPIOPin power_enable = {})
{
px4_spi_bus_t ret{};
ret.requires_locking = true; // TODO: set this to false once all drivers are converted to use the I2CSPIDriver class
ret.requires_locking = false;
for (int i = 0; i < SPI_BUS_MAX_DEVICES; ++i) {
ret.devices[i] = devices.devices[i];
@@ -114,8 +114,7 @@ static inline constexpr px4_spi_bus_t initSPIBusExternal(SPI::Bus bus, const bus
ret.bus = (int)bus;
ret.is_external = true;
// TODO: set requires_locking to false once all drivers are converted to use the I2CSPIDriver class
ret.requires_locking = true; // external buses are never accessed by NuttX drivers
ret.requires_locking = false; // external buses are never accessed by NuttX drivers
return ret;
}