SPI+I2C: remove unused defines and printf's

This commit is contained in:
Beat Küng
2020-02-18 18:52:48 +01:00
committed by Daniel Agar
parent 2f3174abb0
commit 6ad5357d1a
9 changed files with 13 additions and 78 deletions

View File

@@ -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.

View File

@@ -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;

View File

@@ -42,20 +42,3 @@
#include <board_config.h>
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]))

View File

@@ -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:

View File

@@ -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;
}

View File

@@ -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:

View File

@@ -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;
}

View File

@@ -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:

View File

@@ -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;
}