From 6ad5357d1afa35337a41626f06ae0265f56bc716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 18 Feb 2020 18:52:48 +0100 Subject: [PATCH] SPI+I2C: remove unused defines and printf's --- .../px4_platform_common/board_common.h | 48 ------------------- .../common/include/px4_platform_common/spi.h | 6 +-- src/lib/drivers/device/i2c.h | 17 ------- src/lib/drivers/device/nuttx/I2C.cpp | 4 +- src/lib/drivers/device/nuttx/SPI.cpp | 4 +- src/lib/drivers/device/posix/I2C.cpp | 2 +- src/lib/drivers/device/posix/SPI.cpp | 4 +- src/lib/drivers/device/qurt/I2C.cpp | 2 +- src/lib/drivers/device/qurt/SPI.cpp | 4 +- 9 files changed, 13 insertions(+), 78 deletions(-) diff --git a/platforms/common/include/px4_platform_common/board_common.h b/platforms/common/include/px4_platform_common/board_common.h index bc8fa8ed89..3111de030e 100644 --- a/platforms/common/include/px4_platform_common/board_common.h +++ b/platforms/common/include/px4_platform_common/board_common.h @@ -51,54 +51,6 @@ * Definitions ************************************************************************************/ -/* SPI bus defining tools - * - * For new boards we use a board_config.h to define all the SPI functionality - * A board provides SPI bus definitions and a set of buses that should be - * enumerated as well as chip selects that will be iterateable - * - * We will use these in macros place of the uint32_t enumeration to select a - * specific SPI device on given SPI1 bus. - * - * These macros will define BUS:DEV For clarity and indexing - * - * The board config then defines: - * 1) PX4_SPI_BUS_xxx Ids -the buses as a 1 based PX4_SPI_BUS_xxx as n+1 aping to SPI n - * where n is {1-highest SPI supported by SoC} - * 2) PX4_SPIDEV_yyyy handles - PX4_SPIDEV_xxxxx handles using the macros below. - * 3) PX4_xxxx_BUS_CS_GPIO - a set of chip selects that are indexed by the handles. and of set to 0 are - * ignored. - * 4) PX4_xxxx_BUS_FIRST_CS and PX4_xxxxx_BUS_LAST_CS as PX4_SPIDEV_lll for the first CS and - * PX4_SPIDEV_hhhh as the last CS - * - * Example: - * - * The PX4_SPI_BUS_xxx - * #define PX4_SPI_BUS_SENSORS 1 - * #define PX4_SPI_BUS_MEMORY 2 - * - * the PX4_SPIDEV_yyyy - * #define PX4_SPIDEV_ICM_20689 PX4_MK_SPI_SEL(PX4_SPI_BUS_SENSORS,0) - * #define PX4_SPIDEV_ICM_20602 PX4_MK_SPI_SEL(PX4_SPI_BUS_SENSORS,1) - * #define PX4_SPIDEV_BMI055_GYRO PX4_MK_SPI_SEL(PX4_SPI_BUS_SENSORS,2) - * - * The PX4_xxxx_BUS_CS_GPIO - * #define PX4_SENSOR_BUS_CS_GPIO {GPIO_SPI_CS_ICM20689, GPIO_SPI_CS_ICM20602, GPIO_SPI_CS_BMI055_GYR,... - * - * The PX4_xxxx_BUS_FIRST_CS and PX4_xxxxx_BUS_LAST_CS - * #define PX4_SENSORS_BUS_FIRST_CS PX4_SPIDEV_ICM_20689 - * #define PX4_SENSORS_BUS_LAST_CS PX4_SPIDEV_BMI055_ACCEL - * - * - */ -#define PX4_SPIDEV_ID(type, index) ((((type) & 0xffff) << 16) | ((index) & 0xffff)) - -#define PX4_SPI_DEVICE_ID (1 << 12) -#define PX4_MK_SPI_SEL(b,d) PX4_SPIDEV_ID(PX4_SPI_DEVICE_ID, ((((b) & 0xff) << 8) | ((d) & 0xff))) -#define PX4_SPI_BUS_ID(devid) (((devid) >> 8) & 0xff) -#define PX4_SPI_DEV_ID(devid) ((devid) & 0xff) -#define PX4_CHECK_ID(devid) ((devid) & PX4_SPI_DEVICE_ID) - /* I2C PX4 clock configuration * * A board may override BOARD_I2C_BUS_CLOCK_INIT simply by defining the #defines. diff --git a/platforms/common/include/px4_platform_common/spi.h b/platforms/common/include/px4_platform_common/spi.h index f4cf023c46..c5be2e357f 100644 --- a/platforms/common/include/px4_platform_common/spi.h +++ b/platforms/common/include/px4_platform_common/spi.h @@ -41,9 +41,9 @@ * They match with corresponding definitions in NuttX. * 'type' is typically PX4_SPI_DEVICE_ID for PX4 drivers, and 'index' is used for the driver (DRV_*) or chip-select index. */ -//#define PX4_SPIDEV_ID(type, index) ((((type) & 0xffff) << 16) | ((index) & 0xffff)) -//#define PX4_SPI_DEVICE_ID (1 << 12) -//#define PX4_SPI_DEV_ID(devid) ((devid) & 0xffff) +#define PX4_SPIDEV_ID(type, index) ((((type) & 0xffff) << 16) | ((index) & 0xffff)) +#define PX4_SPI_DEVICE_ID (1 << 12) +#define PX4_SPI_DEV_ID(devid) ((devid) & 0xffff) #define PX4_SPIDEVID_TYPE(devid) (((uint32_t)(devid) >> 16) & 0xffff) typedef uint32_t spi_drdy_gpio_t; diff --git a/src/lib/drivers/device/i2c.h b/src/lib/drivers/device/i2c.h index ce47516e65..303ecb97cf 100644 --- a/src/lib/drivers/device/i2c.h +++ b/src/lib/drivers/device/i2c.h @@ -42,20 +42,3 @@ #include - -static const int i2c_bus_options[] = { -#ifdef PX4_I2C_BUS_EXPANSION - PX4_I2C_BUS_EXPANSION, -#endif -#ifdef PX4_I2C_BUS_EXPANSION1 - PX4_I2C_BUS_EXPANSION1, -#endif -#ifdef PX4_I2C_BUS_EXPANSION2 - PX4_I2C_BUS_EXPANSION2, -#endif -#ifdef PX4_I2C_BUS_ONBOARD - PX4_I2C_BUS_ONBOARD, -#endif -}; - -#define NUM_I2C_BUS_OPTIONS (sizeof(i2c_bus_options)/sizeof(i2c_bus_options[0])) diff --git a/src/lib/drivers/device/nuttx/I2C.cpp b/src/lib/drivers/device/nuttx/I2C.cpp index 77b58ff182..128bd40c6a 100644 --- a/src/lib/drivers/device/nuttx/I2C.cpp +++ b/src/lib/drivers/device/nuttx/I2C.cpp @@ -155,8 +155,8 @@ I2C::init() } // tell the world where we are - DEVICE_LOG("on I2C bus %d at 0x%02x (bus: %u KHz, max: %u KHz)", - get_device_bus(), get_device_address(), _bus_clocks[bus_index] / 1000, _frequency / 1000); + DEVICE_DEBUG("on I2C bus %d at 0x%02x (bus: %u KHz, max: %u KHz)", + get_device_bus(), get_device_address(), _bus_clocks[bus_index] / 1000, _frequency / 1000); out: diff --git a/src/lib/drivers/device/nuttx/SPI.cpp b/src/lib/drivers/device/nuttx/SPI.cpp index d6eab6ebe3..cf7336934f 100644 --- a/src/lib/drivers/device/nuttx/SPI.cpp +++ b/src/lib/drivers/device/nuttx/SPI.cpp @@ -121,8 +121,8 @@ SPI::init() return ret; } - /* tell the workd where we are */ - DEVICE_LOG("on SPI bus %d at %d (%u KHz)", get_device_bus(), PX4_SPI_DEV_ID(_device), _frequency / 1000); + /* tell the world where we are */ + DEVICE_DEBUG("on SPI bus %d at %d (%u KHz)", get_device_bus(), PX4_SPI_DEV_ID(_device), _frequency / 1000); return PX4_OK; } diff --git a/src/lib/drivers/device/posix/I2C.cpp b/src/lib/drivers/device/posix/I2C.cpp index fd8119cb94..5719681f43 100644 --- a/src/lib/drivers/device/posix/I2C.cpp +++ b/src/lib/drivers/device/posix/I2C.cpp @@ -103,7 +103,7 @@ I2C::init() } // tell the world where we are - DEVICE_LOG("on I2C bus %d at 0x%02x", get_device_bus(), get_device_address()); + DEVICE_DEBUG("on I2C bus %d at 0x%02x", get_device_bus(), get_device_address()); out: diff --git a/src/lib/drivers/device/posix/SPI.cpp b/src/lib/drivers/device/posix/SPI.cpp index a49ce15187..36a3fe9665 100644 --- a/src/lib/drivers/device/posix/SPI.cpp +++ b/src/lib/drivers/device/posix/SPI.cpp @@ -107,8 +107,8 @@ SPI::init() return ret; } - /* tell the workd where we are */ - DEVICE_LOG("on SPI bus %d at %d (%u KHz)", get_device_bus(), PX4_SPI_DEV_ID(_device), _frequency / 1000); + /* tell the world where we are */ + DEVICE_DEBUG("on SPI bus %d at %d (%u KHz)", get_device_bus(), PX4_SPI_DEV_ID(_device), _frequency / 1000); return PX4_OK; } diff --git a/src/lib/drivers/device/qurt/I2C.cpp b/src/lib/drivers/device/qurt/I2C.cpp index 665e51e6f5..848e5603c8 100644 --- a/src/lib/drivers/device/qurt/I2C.cpp +++ b/src/lib/drivers/device/qurt/I2C.cpp @@ -101,7 +101,7 @@ I2C::init() } // tell the world where we are - DEVICE_LOG("on I2C bus %d at 0x%02x", get_device_bus(), get_device_address()); + DEVICE_DEBUG("on I2C bus %d at 0x%02x", get_device_bus(), get_device_address()); out: diff --git a/src/lib/drivers/device/qurt/SPI.cpp b/src/lib/drivers/device/qurt/SPI.cpp index 316686dd20..8bec20756b 100644 --- a/src/lib/drivers/device/qurt/SPI.cpp +++ b/src/lib/drivers/device/qurt/SPI.cpp @@ -105,8 +105,8 @@ SPI::init() return ret; } - /* tell the workd where we are */ - DEVICE_LOG("on SPI bus %d at %d (%u KHz)", get_device_bus(), PX4_SPI_DEV_ID(_device), _frequency / 1000); + /* tell the world where we are */ + DEVICE_DEBUG("on SPI bus %d at %d (%u KHz)", get_device_bus(), PX4_SPI_DEV_ID(_device), _frequency / 1000); return PX4_OK; }