mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-28 11:00:38 +08:00
refactor(platform): out-line BusCLIArguments constructor to save flash (#28441)
The constructor is inlined into every I2C/SPI driver's command-line entry point, and with it the ~15 default member initializers and the 32-byte _options zero-fill, costing ~50-70 B per driver. Move the definition (verbatim) into i2c_spi_buses.cpp, which already holds the rest of the CLI parsing code. Purely cold-path (driver start/CLI). Saves 2456 B of .text on px4_fmu-v6x_default. Signed-off-by: Balduin <balduin@auterion.com> Co-authored-by: Balduin <balduin@auterion.com>
This commit is contained in:
1 parent
d3ca991b8e
commit
255d9c602b
2 files changed
+16
-14
No files matched your search
@@ -48,6 +48,21 @@
|
||||
static List<I2CSPIInstance *> i2c_spi_module_instances; ///< list of currently running instances
|
||||
static pthread_mutex_t i2c_spi_module_instances_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
BusCLIArguments::BusCLIArguments(bool i2c_support, bool spi_support)
|
||||
#if defined(CONFIG_I2C) || defined(CONFIG_SPI)
|
||||
:
|
||||
#endif // CONFIG_I2C || CONFIG_SPI
|
||||
#if defined(CONFIG_I2C)
|
||||
_i2c_support(i2c_support)
|
||||
#endif // CONFIG_I2C
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_SPI)
|
||||
,
|
||||
#endif // CONFIG_I2C && CONFIG_SPI
|
||||
#if defined(CONFIG_SPI)
|
||||
_spi_support(spi_support)
|
||||
#endif // CONFIG_SPI
|
||||
{}
|
||||
|
||||
|
||||
I2CSPIDriverConfig::I2CSPIDriverConfig(const BusCLIArguments &cli, const BusInstanceIterator &iterator,
|
||||
const px4::wq_config_t &wq_config_)
|
||||
|
||||
@@ -140,20 +140,7 @@ private:
|
||||
class BusCLIArguments
|
||||
{
|
||||
public:
|
||||
BusCLIArguments(bool i2c_support, bool spi_support)
|
||||
#if defined(CONFIG_I2C) || defined(CONFIG_SPI)
|
||||
:
|
||||
#endif // CONFIG_I2C || CONFIG_SPI
|
||||
#if defined(CONFIG_I2C)
|
||||
_i2c_support(i2c_support)
|
||||
#endif // CONFIG_I2C
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_SPI)
|
||||
,
|
||||
#endif // CONFIG_I2C && CONFIG_SPI
|
||||
#if defined(CONFIG_SPI)
|
||||
_spi_support(spi_support)
|
||||
#endif // CONFIG_SPI
|
||||
{}
|
||||
BusCLIArguments(bool i2c_support, bool spi_support);
|
||||
|
||||
/**
|
||||
* Parse CLI arguments (for drivers that don't need any custom arguments, otherwise getopt() should be used)
|
||||
|
||||
Reference in new issue
Block a user