mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-10 04:31:36 +08:00
move I2C bus clock defaults to board px4_i2c_buses
This commit is contained in:
@@ -51,27 +51,6 @@
|
||||
* Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* I2C PX4 clock configuration
|
||||
*
|
||||
* A board may override BOARD_I2C_BUS_CLOCK_INIT simply by defining the #defines.
|
||||
*/
|
||||
|
||||
#if defined(BOARD_I2C_BUS_CLOCK_INIT)
|
||||
# define PX4_I2C_BUS_CLOCK_INIT BOARD_I2C_BUS_CLOCK_INIT
|
||||
#else
|
||||
# if (PX4_NUMBER_I2C_BUSES) == 1
|
||||
# define PX4_I2C_BUS_CLOCK_INIT {100000}
|
||||
# elif (PX4_NUMBER_I2C_BUSES) == 2
|
||||
# define PX4_I2C_BUS_CLOCK_INIT {100000, 100000}
|
||||
# elif (PX4_NUMBER_I2C_BUSES) == 3
|
||||
# define PX4_I2C_BUS_CLOCK_INIT {100000, 100000, 100000}
|
||||
# elif (PX4_NUMBER_I2C_BUSES) == 4
|
||||
# define PX4_I2C_BUS_CLOCK_INIT {100000, 100000, 100000, 100000}
|
||||
# else
|
||||
# error PX4_NUMBER_I2C_BUSES not supported
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_SPI_BUS_MAX_BUS_ITEMS
|
||||
#define SPI_BUS_MAX_BUS_ITEMS BOARD_SPI_BUS_MAX_BUS_ITEMS
|
||||
#else
|
||||
|
||||
@@ -40,8 +40,9 @@
|
||||
#define I2C_BUS_MAX_BUS_ITEMS PX4_NUMBER_I2C_BUSES
|
||||
|
||||
struct px4_i2c_bus_t {
|
||||
int bus{-1}; ///< physical bus number (1, ...) (-1 means this is unused)
|
||||
bool is_external; ///< static external configuration. Use px4_i2c_bus_external() to check if a bus is really external
|
||||
uint32_t max_speed_hz{100'000}; ///< max speed in Hz
|
||||
int8_t bus{-1}; ///< physical bus number (1, ...) (-1 means this is unused)
|
||||
bool is_external{true}; ///< static external configuration. Use px4_i2c_bus_external() to check if a bus is really external
|
||||
};
|
||||
|
||||
__EXPORT extern const px4_i2c_bus_t px4_i2c_buses[I2C_BUS_MAX_BUS_ITEMS]; ///< board-specific I2C bus configuration
|
||||
@@ -58,6 +59,11 @@ __EXPORT bool px4_i2c_bus_external(int bus);
|
||||
*/
|
||||
__EXPORT bool px4_i2c_device_external(const uint32_t device_id);
|
||||
|
||||
/**
|
||||
* Return board defined max speed per bus in Hz. 0 if unknown or invalid bus.
|
||||
*/
|
||||
__EXPORT int px4_i2c_bus_max_speed(int bus);
|
||||
|
||||
/**
|
||||
* @class I2CBusIterator
|
||||
* Iterate over configured I2C buses by the board
|
||||
|
||||
Reference in New Issue
Block a user